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
This commit is contained in:
Andrew Nacin 2012-11-20 18:50:15 +00:00
parent a2edda4b6a
commit 3da5e3a7fc
7 changed files with 130 additions and 77 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 = '<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>';
$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>';
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 .= '<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>';
$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";
$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";
}
$html .= '</tbody></table>';
$x = new WP_Ajax_Response();
$x->add( array(
'what' => $what,
'data' => $html
));
$x->send();
}
function wp_ajax_widgets_order() {

View File

@ -1278,18 +1278,8 @@ function find_posts_div($found_action = '') {
<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
<input type="text" id="find-posts-input" name="ps" value="" />
<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
<?php
$post_types = get_post_types( array('public' => true), 'objects' );
foreach ( $post_types as $post ) {
if ( 'attachment' == $post->name )
continue;
?>
<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'); ?> />
<label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label>
<?php
} ?>
<span class="spinner"></span>
<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
</div>
<div id="find-posts-response"></div>
</div>

View File

@ -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( '<div class="ui-find-overlay"></div>' );
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()
};
_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);