Plugin Directory

Changeset 785449


Ignore:
Timestamp:
10/09/2013 05:49:27 PM (11 years ago)
Author:
lessbloat
Message:

Made a few tweaks to Quick Drafts widget:

  • Show just the 3 latest drafts
  • Only show "view all" link if there are more than 3 drafts
  • Adjusted padding/margins so that horizontal dividing line stretches all the way across the box
  • on click for the form changed effect from show() to slideDown()
  • Changed no drafts notice from "There are no drafts at the moment" to "You have yet to add any drafts."
  • Removed tags field
  • Removed media upload button
  • Hooked up new form post callback function
  • Adjusted margin between draft title and draft description to adjust for drafts with just a title
  • Added 1 sec yellow background highlight on submit to show recently added draft in list below form
Location:
dashboard/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dashboard/trunk/css/quickdraft.css

    r784283 r785449  
    66#dashboard_quick_draft .drafts,
    77#dashboard_quick_draft .easy-blogging {
    8     margin: 0 12px 10px;
     8    padding: 0 12px;
    99}
    1010
     
    1717#dashboard_quick_draft form {
    1818    border-bottom: 1px solid #eee;
     19    overflow: hidden;
    1920}
    2021
     
    2627}
    2728
    28 /* @todo: Position media buttons? Ignore media buttons? */
    29 .wp-media-buttons,
    30 #publishing-action,
    31 p.submit [type="reset"] {
    32     display: none;
    33 }
    34 
    35 .initial-form #title-wrap,
    36 .initial-form #tags-input-wrap,
     29.initial-form #description-wrap,
    3730.initial-form p.submit {
    3831    display: none;
     
    4841}
    4942#title-wrap #title-prompt-text,
    50 .textarea-wrap #content-prompt-text,
    51 #tags-input-wrap #tags-input-prompt-text {
     43.textarea-wrap #content-prompt-text {
    5244    color: #BBB;
    5345}
     
    6254}
    6355
    64 #tags-input-wrap {
    65     margin-right: 95px;
    66 }
    67 #tags-input-wrap #tags-input-prompt-text,
    68 #tags-input-wrap #tags-input {
    69     padding: 4px 6px;
    70     font-size: 1em;
    71     line-height: 18px;
    72 }
    73 
    7456#title-wrap #title {
    7557    margin: 0 0 10px;
     
    7860    margin: 0 0 10px;
    7961    padding: 6px 7px;
    80 }
    81 #tags-input-wrap #tags-input {
    82     margin: 0 0 10px;
    83     padding: 4px 6px;
    8462}
    8563
     
    10886    border: none;
    10987}
     88
     89#draft-list li {
     90    margin-bottom: 1em;
     91}
     92
     93#draft-list p {
     94    margin: 0;
     95}
  • dashboard/trunk/css/wpnews.css

    r784802 r785449  
    11#dashboard_rss .inside {
    2     padding: 0 0 12px;
     2    padding: 0;
    33}
    44
     
    1616.rss-widget:last-child {
    1717    border-bottom: none;
    18     margin-bottom: 0;
    19     padding-bottom: 0;
    2018}
    2119
     
    3331
    3432body #dashboard-widgets .postbox form .submit {
    35     margin: 0;
     33    margin: 0 0 12px;
    3634}
  • dashboard/trunk/js/quickdraft.js

    r784283 r785449  
    1 var quickPressLoad;
     1
    22
    33(function ($) {
     4    var quickPressLoad;
    45    /* QuickPress */
    56    quickPressLoad = function() {
    67        var act = $('#quickpost-action'), t;
    78        t = $('#quick-press').submit( function() {
    8                 $('#dashboard_quick_draft #publishing-action .spinner').show();
    9                 $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
    10    
    11                 if ( 'post' == act.val() ) {
    12                     act.val( 'post-quickpress-publish' );
    13                 }
    14    
    15                 $.post( t.attr( 'action' ), t.serializeArray(), function( data ) {
    16                     // Replace the form, and prepend the published post.
    17                     $('#quick-press').html( $(data).filter('#quick-press').html() ).removeClass('initial-form');
    18                     $('#quick-press').find('#save-post').addClass('button-primary');
    19                     $('#quick-press').prepend( $(data).filter('div.updated') );
    20                     $(data).find('li').prependTo("#draft-list");
    21                    
    22                     $('#dashboard_quick_draft #publishing-action .spinner').hide();
    23                     $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', false);
    24                     quickPressLoad();
    25                 });
    26                 return false;
    27             } );
     9            $('#dashboard_quick_draft #publishing-action .spinner').show();
     10            $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
     11
     12            $.post( t.attr( 'action' ), t.serializeArray(), function( data ) {
     13                // Replace the form, and prepend the published post.
     14                $('#dashboard_quick_draft .inside').html( data );
     15                quickPressLoad();
     16                highlightLatestPost();
     17            });
     18           
     19            function highlightLatestPost () {
     20                var latestPost = $('#draft-list li').first();
     21                latestPost.css('background', '#fffbe5');
     22                setTimeout(function () {
     23                    latestPost.css('background', 'none');
     24                }, 1000);
     25            }
     26           
     27            return false;
     28        } );
    2829   
    2930        $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
     
    4950            });
    5051        });
    51        
    52        
    5352
    5453        $('#quick-press').on( 'click focusin', function() {
    55             $("#title-wrap, #tags-input-wrap, p.submit").show(200);
     54            $("#description-wrap, p.submit").slideDown(200);
    5655            wpActiveEditor = 'content';
    5756        });
  • dashboard/trunk/quickdraft.php

    r784283 r785449  
    99}
    1010
     11add_action( 'admin_post_new-quickdraft-post', 'dashboard_plugin_quickdraft_admin_post' );
     12function dashboard_plugin_quickdraft_admin_post() {
     13    $post = get_post( $_REQUEST['post_ID'] );
     14    check_admin_referer( 'add-' . $post->post_type );
     15    edit_post();
     16    return wp_dashboard_quick_draft();
     17}
     18
    1119// The QuickDraft widget display and creation of drafts
    1220function wp_dashboard_quick_draft() {
    1321    global $post_ID;
    14 
    15     if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
    16         $view = get_permalink( $_POST['post_ID'] );
    17         $edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) );
    18         if ( 'post-quickpress-publish' == $_POST['action'] ) {
    19             if ( current_user_can('publish_posts') )
    20                 printf( '<div class="updated"><p>' . __( 'Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );
    21             else
    22                 printf( '<div class="updated"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
    23         } else {
    24             printf( '<div class="updated"><p>' . __( 'Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
    25         }
    26         printf('<p class="easy-blogging">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );
    27         $_REQUEST = array(); // hack for get_default_post_to_edit()
    28     }
    2922
    3023    /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
     
    4740
    4841    $post_ID = (int) $post->ID;
    49 
    50     $media_settings = array(
    51         'id' => $post->ID,
    52         'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
    53     );
    54 
    55     if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {
    56         $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );
    57         $media_settings['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;
    58     }
    5942?>
    6043
    61     <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form">
     44    <form name="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" id="quick-press" class="initial-form">
    6245        <div class="input-text-wrap" id="title-wrap">
    63             <label class="screen-reader-text prompt" for="title" id="title-prompt-text"><?php _e( 'Enter title here' ); ?></label>
    64             <input type="text" name="post_title" id="title" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" />
     46            <label class="screen-reader-text prompt" for="title" id="title-prompt-text"><?php _e( "What's on your mind?" ); ?></label>
     47            <input type="text" name="post_title" id="title" autocomplete="off" />
    6548        </div>
    6649
    67         <?php if ( current_user_can( 'upload_files' ) ) : ?>
    68         <div id="wp-content-wrap" class="wp-editor-wrap hide-if-no-js wp-media-buttons">
    69             <?php do_action( 'media_buttons', 'content' ); ?>
    70         </div>
    71         <?php endif; ?>
    72 
    73         <div class="textarea-wrap">
    74             <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( "What's on your mind?" ); ?></label>
    75             <textarea name="content" id="content" class="mceEditor" rows="3" cols="15"><?php echo esc_textarea( $post->post_content ); ?></textarea>
    76         </div>
    77 
    78         <script type="text/javascript">
    79         edCanvas = document.getElementById('content');
    80         edInsertContent = null;
    81         <?php if ( $_POST ) : ?>
    82         wp.media.editor.remove('content');
    83         wp.media.view.settings.post = <?php echo json_encode( $media_settings ); // big juicy hack. ?>;
    84         wp.media.editor.add('content');
    85         <?php endif; ?>
    86         </script>
    87 
    88         <div class="input-text-wrap" id="tags-input-wrap">
    89             <label class="screen-reader-text prompt" for="tags-input" id="tags-input-prompt-text"><?php _e( 'Tags (separate with commas)' ); ?></label>
    90             <input type="text" name="tags_input" id="tags-input" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
     50        <div class="textarea-wrap" id="description-wrap">
     51            <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'Enter a description' ); ?></label>
     52            <textarea name="content" id="content" class="mceEditor" rows="3" cols="15"></textarea>
    9153        </div>
    9254
    9355        <p class="submit">
    94             <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
     56            <input type="hidden" name="action" id="quickpost-action" value="new-quickdraft-post" />
    9557            <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
    9658            <input type="hidden" name="post_type" value="post" />
     
    11274            'post_status'    => 'draft',
    11375            'author'         => $GLOBALS['current_user']->ID,
    114             'posts_per_page' => 5,
     76            'posts_per_page' => 4,
    11577            'orderby'        => 'modified',
    11678            'order'          => 'DESC'
     
    12183    if ( $drafts && is_array( $drafts ) ) {
    12284        $list = array();
     85        $draft_count = 0;
    12386        foreach ( $drafts as $draft ) {
     87            if ( 3 == $draft_count )
     88                break;
     89           
     90            $draft_count++;
     91           
    12492            $url = get_edit_post_link( $draft->ID );
    12593            $title = _draft_or_post_title( $draft->ID );
     
    13199?>
    132100    <div class="drafts">
     101        <?php if ( 3 < count($drafts) ) { ?>
    133102        <p class="view-all"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p>
     103        <?php } ?>
    134104        <p class="title"><?php _e('Drafts'); ?></p>
    135105        <ul id="draft-list">
     
    138108    </div>
    139109<?php } else { ?>
    140     <div class="drafts"><p><?php _e('There are no drafts at the moment'); ?></p></div>
     110    <div class="drafts"><p><?php _e("You have yet to add any drafts."); ?></p></div>
    141111<?php }
    142112}
Note: See TracChangeset for help on using the changeset viewer.