From 3da5e3a7fc27357a1550362329223c4e51b62042 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 20 Nov 2012 18:50:15 +0000 Subject: [PATCH] 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. git-svn-id: http://core.svn.wordpress.org/trunk@22723 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/css/colors-classic.css | 17 ++++++---- wp-admin/css/colors-fresh.css | 17 ++++++---- wp-admin/css/wp-admin-rtl.css | 15 +++++++++ wp-admin/css/wp-admin.css | 51 ++++++++++++++++++++++-------- wp-admin/includes/ajax-actions.php | 45 ++++++++++---------------- wp-admin/includes/template.php | 14 ++------ wp-admin/js/media.js | 48 ++++++++++++++++++++++------ 7 files changed, 130 insertions(+), 77 deletions(-) diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index 2c2e43f21b..99b3b6fb8c 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -20,13 +20,18 @@ TABLE OF CONTENTS: 1.0 - Left to Right Styles ------------------------------------------------------------------------------*/ -.find-box-search { - border-color: #dfdfdf; - background-color: #f1f1f1; +.find-box-search, +.find-box-buttons { + background-color: #eff8ff; + border-top: 1px solid #dce6f8; } .find-box { - background-color: #f1f1f1; + background-color: #5589aa; +} + +.find-box-head { + color: #fff; } .find-box-inside { @@ -167,7 +172,6 @@ textarea.disabled { h3.dashboard-widget-title, h3.dashboard-widget-title span, h3.dashboard-widget-title small, -.find-box-head, .sidebar-name, #nav-menu-header, #nav-menu-footer, @@ -475,8 +479,7 @@ a.page-numbers { .widefat tfoot tr th, h3.dashboard-widget-title, h3.dashboard-widget-title span, -h3.dashboard-widget-title small, -.find-box-head { +h3.dashboard-widget-title small { color: #333; } diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index 5de5ae0f21..215f5e1221 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -20,13 +20,18 @@ TABLE OF CONTENTS: 1.0 - Left to Right Styles ------------------------------------------------------------------------------*/ -.find-box-search { - border-color: #dfdfdf; - background-color: #f1f1f1; +.find-box-search, +.find-box-buttons { + background-color: #f7f7f7; + border-top: 1px solid #ddd; } .find-box { - background-color: #f1f1f1; + background-color: #444; +} + +.find-box-head { + color: #eee; } .find-box-inside { @@ -170,7 +175,6 @@ textarea.disabled { h3.dashboard-widget-title, h3.dashboard-widget-title span, h3.dashboard-widget-title small, -.find-box-head, .sidebar-name, #nav-menu-header, #nav-menu-footer, @@ -477,8 +481,7 @@ a.page-numbers { .widefat tfoot tr th, h3.dashboard-widget-title, h3.dashboard-widget-title span, -h3.dashboard-widget-title small, -.find-box-head { +h3.dashboard-widget-title small { color: #333; } diff --git a/wp-admin/css/wp-admin-rtl.css b/wp-admin/css/wp-admin-rtl.css index 1d49f346b1..233705d9ed 100644 --- a/wp-admin/css/wp-admin-rtl.css +++ b/wp-admin/css/wp-admin-rtl.css @@ -1083,6 +1083,21 @@ span.description, 14.1 - Media Uploader ------------------------------------------------------------------------------*/ +#find-posts-input { + float: right; +} + +#find-posts-search { + float: right; + margin-right: 3px; + margin-left: 4px; +} + +.find-box-search .spinner { + left: auto; + right: 115px; +} + #find-posts-response .found-radio { padding: 5px 8px 0 0; } diff --git a/wp-admin/css/wp-admin.css b/wp-admin/css/wp-admin.css index 7be2f44294..cfb74539c7 100644 --- a/wp-admin/css/wp-admin.css +++ b/wp-admin/css/wp-admin.css @@ -3963,10 +3963,10 @@ abbr.required { ------------------------------------------------------------------------------*/ .find-box { - width: 500px; + width: 600px; height: 300px; overflow: hidden; - padding: 33px 5px 40px; + padding: 33px 0 51px; position: absolute; z-index: 1000; } @@ -3984,19 +3984,37 @@ abbr.required { .find-box-inside { overflow: auto; - width: 100%; + padding: 6px; height: 100%; } .find-box-search { - padding: 12px; - border-width: 1px; - border-style: none none solid; + overflow: hidden; + padding: 9px; + position: relative; +} + +.find-box-search .spinner { + float: none; + left: 125px; + position: absolute; + top: 9px; +} + +#find-posts-input { + float: left; + width: 140px; + height: 24px; +} + +#find-posts-search { + float: left; + margin: 1px 4px 0 3px; } #find-posts-response { margin: 8px 0; - padding: 0 1px; + padding: 0 1px 6px; } #find-posts-response table { @@ -4004,17 +4022,13 @@ abbr.required { } #find-posts-response .found-radio { - padding: 5px 0 0 8px; + padding: 3px 0 0 8px; width: 15px; } .find-box-buttons { - width: 480px; - margin: 8px; -} - -.find-box-search label { - padding-right: 6px; + padding: 8px; + overflow: hidden; } .find-box #resize-se { @@ -4023,6 +4037,15 @@ abbr.required { bottom: 1px; } +.ui-find-overlay { + position: absolute; + top: 0; + left: 0; + background-color: #000; + opacity: 0.6; + filter: alpha(opacity=60); +} + ul#dismissed-updates { display: none; } diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 4f67a1863c..4bfde87b04 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1421,37 +1421,27 @@ function wp_ajax_find_posts() { check_ajax_referer( 'find-posts' ); - if ( empty($_POST['ps']) ) - wp_die(); - - if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) ) - $what = $_POST['post_type']; - else - $what = 'post'; - - $s = stripslashes($_POST['ps']); - preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); - $search_terms = array_map('_search_terms_tidy', $matches[0]); + $post_types = get_post_types( array( 'public' => true ), 'objects' ); + unset( $post_types['attachment'] ); + $s = stripslashes( $_POST['ps'] ); $searchand = $search = ''; - foreach ( (array) $search_terms as $term ) { - $term = esc_sql( like_escape( $term ) ); - $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; - $searchand = ' AND '; - } - $term = esc_sql( like_escape( $s ) ); - if ( count($search_terms) > 1 && $search_terms[0] != $s ) - $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; + $args = array( + 'post_type' => array_keys( $post_types ), + 'post_status' => 'any', + 'posts_per_page' => 50, + ); + if ( '' !== $s ) + $args['s'] = $s; - $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" ); + $posts = get_posts( $args ); - if ( ! $posts ) { - $posttype = get_post_type_object($what); - wp_die( $posttype->labels->not_found ); - } + if ( ! $posts ) + wp_die( __('No items found.') ); - $html = ''; + $html = '

'.__('Title').''.__('Date').''.__('Status').'
'; foreach ( $posts as $post ) { + $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); switch ( $post->post_status ) { case 'publish' : @@ -1477,17 +1467,16 @@ function wp_ajax_find_posts() { } $html .= ''; - $html .= ''."\n\n"; + $html .= '' . "\n\n"; } + $html .= '

'.__('Title').''.__('Type').''.__('Date').''.__('Status').'
'.esc_html( $time ).''.esc_html( $stat ).'
' . esc_html( $post_types[$post->post_type]->labels->singular_name ) . ''.esc_html( $time ) . '' . esc_html( $stat ). '
'; $x = new WP_Ajax_Response(); $x->add( array( - 'what' => $what, 'data' => $html )); $x->send(); - } function wp_ajax_widgets_order() { diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 32962003c2..86a484844a 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1278,18 +1278,8 @@ function find_posts_div($found_action = '') { -
- - true), 'objects' ); - foreach ( $post_types as $post ) { - if ( 'attachment' == $post->name ) - continue; - ?> - name, 'post'); ?> /> - - + +
diff --git a/wp-admin/js/media.js b/wp-admin/js/media.js index 6c589ec371..b4ed0fb6ce 100644 --- a/wp-admin/js/media.js +++ b/wp-admin/js/media.js @@ -3,41 +3,63 @@ var findPosts; (function($){ findPosts = { open : function(af_name, af_val) { - var st = document.documentElement.scrollTop || $(document).scrollTop(); + var st = document.documentElement.scrollTop || $(document).scrollTop(), + overlay = $( '.ui-find-overlay' ); + + if ( overlay.length == 0 ) { + $( 'body' ).append( '
' ); + findPosts.overlay(); + } + + overlay.show(); if ( af_name && af_val ) { $('#affected').attr('name', af_name).val(af_val); } $('#find-posts').show().draggable({ handle: '#find-posts-head' - }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-250px'}); + }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-328px'}); $('#find-posts-input').focus().keyup(function(e){ if (e.which == 27) { findPosts.close(); } // close on Escape }); + // Pull some results up by default + findPosts.send(); + return false; }, close : function() { $('#find-posts-response').html(''); $('#find-posts').draggable('destroy').hide(); + $( '.ui-find-overlay' ).hide(); + }, + + overlay : function() { + $( '.ui-find-overlay' ).css( + { 'z-index': '999', 'width': $( document ).width() + 'px', 'height': $( document ).height() + 'px' } + ).on('click', function () { + findPosts.close(); + }); }, send : function() { var post = { - ps: $('#find-posts-input').val(), - action: 'find_posts', - _ajax_nonce: $('#_ajax_nonce').val(), - post_type: $('input[name="find-posts-what"]:checked').val() - }; + ps: $('#find-posts-input').val(), + action: 'find_posts', + _ajax_nonce: $('#_ajax_nonce').val() + }, + spinner = $( '.find-box-search .spinner' ); + + spinner.show(); $.ajax({ type : 'POST', url : ajaxurl, data : post, - success : function(x) { findPosts.show(x); }, - error : function(r) { findPosts.error(r); } + success : function(x) { findPosts.show(x); spinner.hide(); }, + error : function(r) { findPosts.error(r); spinner.hide(); } }); }, @@ -55,6 +77,11 @@ var findPosts; } r = r.responses[0]; $('#find-posts-response').html(r.data); + + // Enable whole row to be clicked + $( '.found-posts td' ).on( 'click', function () { + $( this ).parent().find( '.found-radio input' ).prop( 'checked', true ); + }); }, error : function(r) { @@ -91,4 +118,7 @@ var findPosts; }); }); }); + $(window).resize(function() { + findPosts.overlay(); + }); })(jQuery);