WordPress.org

Make WordPress Core

Changeset 22723


Ignore:
Timestamp:
11/20/2012 06:50:15 PM (7 years ago)
Author:
nacin
Message:

Fix up the 'Attach' dialog on upload.php.

We are de-emphasising attaching (see [22630]) but this is existing
core functionality and will remain for now. This commit just cleans
it up a bit so as to be less embarrassing.

props lessbloat, helenyhou.
fixes #20164.

Location:
trunk/wp-admin
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/colors-classic.css

    r22647 r22723  
    2121------------------------------------------------------------------------------*/
    2222
    23 .find-box-search {
    24     border-color: #dfdfdf;
    25     background-color: #f1f1f1;
     23.find-box-search,
     24.find-box-buttons {
     25    background-color: #eff8ff;
     26    border-top: 1px solid #dce6f8;
    2627}
    2728
    2829.find-box {
    29     background-color: #f1f1f1;
     30    background-color: #5589aa;
     31}
     32
     33.find-box-head {
     34    color: #fff;
    3035}
    3136
     
    168173h3.dashboard-widget-title span,
    169174h3.dashboard-widget-title small,
    170 .find-box-head,
    171175.sidebar-name,
    172176#nav-menu-header,
     
    476480h3.dashboard-widget-title,
    477481h3.dashboard-widget-title span,
    478 h3.dashboard-widget-title small,
    479 .find-box-head {
     482h3.dashboard-widget-title small {
    480483    color: #333;
    481484}
  • trunk/wp-admin/css/colors-fresh.css

    r22647 r22723  
    2121------------------------------------------------------------------------------*/
    2222
    23 .find-box-search {
    24     border-color: #dfdfdf;
    25     background-color: #f1f1f1;
     23.find-box-search,
     24.find-box-buttons {
     25    background-color: #f7f7f7;
     26    border-top: 1px solid #ddd;
    2627}
    2728
    2829.find-box {
    29     background-color: #f1f1f1;
     30    background-color: #444;
     31}
     32
     33.find-box-head {
     34    color: #eee;
    3035}
    3136
     
    171176h3.dashboard-widget-title span,
    172177h3.dashboard-widget-title small,
    173 .find-box-head,
    174178.sidebar-name,
    175179#nav-menu-header,
     
    478482h3.dashboard-widget-title,
    479483h3.dashboard-widget-title span,
    480 h3.dashboard-widget-title small,
    481 .find-box-head {
     484h3.dashboard-widget-title small {
    482485    color: #333;
    483486}
  • trunk/wp-admin/css/wp-admin-rtl.css

    r22719 r22723  
    10831083  14.1 - Media Uploader
    10841084------------------------------------------------------------------------------*/
     1085
     1086#find-posts-input {
     1087    float: right;
     1088}
     1089
     1090#find-posts-search {
     1091    float: right;
     1092    margin-right: 3px;
     1093    margin-left: 4px;
     1094}
     1095
     1096.find-box-search .spinner {
     1097    left: auto;
     1098    right: 115px;
     1099}
    10851100
    10861101#find-posts-response .found-radio {
  • trunk/wp-admin/css/wp-admin.css

    r22719 r22723  
    39643964
    39653965.find-box {
    3966     width: 500px;
     3966    width: 600px;
    39673967    height: 300px;
    39683968    overflow: hidden;
    3969     padding: 33px 5px 40px;
     3969    padding: 33px 0 51px;
    39703970    position: absolute;
    39713971    z-index: 1000;
     
    39853985.find-box-inside {
    39863986    overflow: auto;
    3987     width: 100%;
     3987    padding: 6px;
    39883988    height: 100%;
    39893989}
    39903990
    39913991.find-box-search {
    3992     padding: 12px;
    3993     border-width: 1px;
    3994     border-style: none none solid;
     3992    overflow: hidden;
     3993    padding: 9px;
     3994    position: relative;
     3995}
     3996
     3997.find-box-search .spinner {
     3998    float: none;
     3999    left: 125px;
     4000    position: absolute;
     4001    top: 9px;
     4002}
     4003
     4004#find-posts-input {
     4005    float: left;
     4006    width: 140px;
     4007    height: 24px;
     4008}
     4009
     4010#find-posts-search {
     4011    float: left;
     4012    margin: 1px 4px 0 3px;
    39954013}
    39964014
    39974015#find-posts-response {
    39984016    margin: 8px 0;
    3999     padding: 0 1px;
     4017    padding: 0 1px 6px;
    40004018}
    40014019
     
    40054023
    40064024#find-posts-response .found-radio {
    4007     padding: 5px 0 0 8px;
     4025    padding: 3px 0 0 8px;
    40084026    width: 15px;
    40094027}
    40104028
    40114029.find-box-buttons {
    4012     width: 480px;
    4013     margin: 8px;
    4014 }
    4015 
    4016 .find-box-search label {
    4017     padding-right: 6px;
     4030    padding: 8px;
     4031    overflow: hidden;
    40184032}
    40194033
     
    40224036    right: 1px;
    40234037    bottom: 1px;
     4038}
     4039
     4040.ui-find-overlay {
     4041    position: absolute;
     4042    top: 0;
     4043    left: 0;
     4044    background-color: #000;
     4045    opacity: 0.6;
     4046    filter: alpha(opacity=60);
    40244047}
    40254048
  • trunk/wp-admin/includes/ajax-actions.php

    r22653 r22723  
    14221422    check_ajax_referer( 'find-posts' );
    14231423
    1424     if ( empty($_POST['ps']) )
    1425         wp_die();
    1426 
    1427     if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) )
    1428         $what = $_POST['post_type'];
    1429     else
    1430         $what = 'post';
    1431 
    1432     $s = stripslashes($_POST['ps']);
    1433     preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
    1434     $search_terms = array_map('_search_terms_tidy', $matches[0]);
    1435 
     1424    $post_types = get_post_types( array( 'public' => true ), 'objects' );
     1425    unset( $post_types['attachment'] );
     1426
     1427    $s = stripslashes( $_POST['ps'] );
    14361428    $searchand = $search = '';
    1437     foreach ( (array) $search_terms as $term ) {
    1438         $term = esc_sql( like_escape( $term ) );
    1439         $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
    1440         $searchand = ' AND ';
    1441     }
    1442     $term = esc_sql( like_escape( $s ) );
    1443     if ( count($search_terms) > 1 && $search_terms[0] != $s )
    1444         $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')";
    1445 
    1446     $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" );
    1447 
    1448     if ( ! $posts ) {
    1449         $posttype = get_post_type_object($what);
    1450         wp_die( $posttype->labels->not_found );
    1451     }
    1452 
    1453     $html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__('Date').'</th><th>'.__('Status').'</th></tr></thead><tbody>';
     1429    $args = array(
     1430        'post_type' => array_keys( $post_types ),
     1431        'post_status' => 'any',
     1432        'posts_per_page' => 50,
     1433    );
     1434    if ( '' !== $s )
     1435        $args['s'] = $s;
     1436
     1437    $posts = get_posts( $args );
     1438
     1439    if ( ! $posts )
     1440        wp_die( __('No items found.') );
     1441
     1442    $html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th class="no-break">'.__('Type').'</th><th class="no-break">'.__('Date').'</th><th class="no-break">'.__('Status').'</th></tr></thead><tbody>';
    14541443    foreach ( $posts as $post ) {
     1444        $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
    14551445
    14561446        switch ( $post->post_status ) {
     
    14781468
    14791469        $html .= '<tr class="found-posts"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>';
    1480         $html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat ).'</td></tr>'."\n\n";
    1481     }
     1470        $html .= '<td><label for="found-'.$post->ID.'">' . esc_html( $title ) . '</label></td><td class="no-break">' . esc_html( $post_types[$post->post_type]->labels->singular_name ) . '</td><td class="no-break">'.esc_html( $time ) . '</td><td class="no-break">' . esc_html( $stat ). ' </td></tr>' . "\n\n";
     1471    }
     1472
    14821473    $html .= '</tbody></table>';
    14831474
    14841475    $x = new WP_Ajax_Response();
    14851476    $x->add( array(
    1486         'what' => $what,
    14871477        'data' => $html
    14881478    ));
    14891479    $x->send();
    1490 
    14911480}
    14921481
  • trunk/wp-admin/includes/template.php

    r22459 r22723  
    12791279                <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
    12801280                <input type="text" id="find-posts-input" name="ps" value="" />
    1281                 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
    1282 
    1283                 <?php
    1284                 $post_types = get_post_types( array('public' => true), 'objects' );
    1285                 foreach ( $post_types as $post ) {
    1286                     if ( 'attachment' == $post->name )
    1287                         continue;
    1288                 ?>
    1289                 <input type="radio" name="find-posts-what" id="find-posts-<?php echo esc_attr($post->name); ?>" value="<?php echo esc_attr($post->name); ?>" <?php checked($post->name, 'post'); ?> />
    1290                 <label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label>
    1291                 <?php
    1292                 } ?>
     1281                <span class="spinner"></span>
     1282                <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
    12931283            </div>
    12941284            <div id="find-posts-response"></div>
  • trunk/wp-admin/js/media.js

    r21592 r22723  
    44    findPosts = {
    55        open : function(af_name, af_val) {
    6             var st = document.documentElement.scrollTop || $(document).scrollTop();
     6            var st = document.documentElement.scrollTop || $(document).scrollTop(),
     7                overlay = $( '.ui-find-overlay' );
     8
     9            if ( overlay.length == 0 ) {
     10                $( 'body' ).append( '<div class="ui-find-overlay"></div>' );
     11                findPosts.overlay();
     12            }
     13
     14            overlay.show();
    715
    816            if ( af_name && af_val ) {
     
    1119            $('#find-posts').show().draggable({
    1220                handle: '#find-posts-head'
    13             }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-250px'});
     21            }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-328px'});
    1422
    1523            $('#find-posts-input').focus().keyup(function(e){
    1624                if (e.which == 27) { findPosts.close(); } // close on Escape
    1725            });
     26
     27            // Pull some results up by default
     28            findPosts.send();
    1829
    1930            return false;
     
    2334            $('#find-posts-response').html('');
    2435            $('#find-posts').draggable('destroy').hide();
     36            $( '.ui-find-overlay' ).hide();
     37        },
     38
     39        overlay : function() {
     40            $( '.ui-find-overlay' ).css(
     41                { 'z-index': '999', 'width': $( document ).width() + 'px', 'height': $( document ).height() + 'px' }
     42            ).on('click', function () {
     43                findPosts.close();
     44            });
    2545        },
    2646
    2747        send : function() {
    2848            var post = {
    29                 ps: $('#find-posts-input').val(),
    30                 action: 'find_posts',
    31                 _ajax_nonce: $('#_ajax_nonce').val(),
    32                 post_type: $('input[name="find-posts-what"]:checked').val()
    33             };
     49                    ps: $('#find-posts-input').val(),
     50                    action: 'find_posts',
     51                    _ajax_nonce: $('#_ajax_nonce').val()
     52                },
     53                spinner = $( '.find-box-search .spinner' );
     54
     55            spinner.show();
    3456
    3557            $.ajax({
     
    3759                url : ajaxurl,
    3860                data : post,
    39                 success : function(x) { findPosts.show(x); },
    40                 error : function(r) { findPosts.error(r); }
     61                success : function(x) { findPosts.show(x); spinner.hide(); },
     62                error : function(r) { findPosts.error(r); spinner.hide(); }
    4163            });
    4264        },
     
    5678            r = r.responses[0];
    5779            $('#find-posts-response').html(r.data);
     80
     81            // Enable whole row to be clicked
     82            $( '.found-posts td' ).on( 'click', function () {
     83                $( this ).parent().find( '.found-radio input' ).prop( 'checked', true );
     84            });
    5885        },
    5986
     
    92119        });
    93120    });
     121    $(window).resize(function() {
     122        findPosts.overlay();
     123    });
    94124})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.