Restyles the modal for attaching media to posts, props avryl, see #26952

Built from https://develop.svn.wordpress.org/trunk@27401


git-svn-id: http://core.svn.wordpress.org/trunk@27248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-03-04 23:11:13 +00:00
parent 3533e3575f
commit 19efb78b48
9 changed files with 146 additions and 97 deletions

View File

@ -233,41 +233,39 @@
------------------------------------------------------------------------------*/
.find-box {
background-color: #fff;
width: 600px;
height: 300px;
max-width: 100%;
overflow: hidden;
padding: 33px 0 51px;
position: absolute;
z-index: 1000;
background-color: #444;
margin-right: -300px;
position: fixed;
top: 30px;
right: 50%;
z-index: 160000;
}
.find-box-head {
cursor: move;
color: #eee;
background: #fcfcfc;
border-bottom: 1px solid #dfdfdf;
height: 40px;
font-size: 22px;
font-weight: 600;
height: 2em;
line-height: 2em;
padding: 1px 12px;
position: absolute;
top: 5px;
width: 100%;
line-height: 40px;
padding: 0 16px 0 40px;
overflow: hidden;
}
.find-box-inside {
overflow: auto;
padding: 6px;
height: 100%;
padding: 16px;
background-color: #fff;
max-height: 300px;
overflow-y: scroll;
}
.find-box-search,
.find-box-buttons {
overflow: hidden;
padding: 8px;
position: relative;
background-color: #f7f7f7;
border-top: 1px solid #dfdfdf;
.find-box-search {
padding-bottom: 16px;
}
.find-box-search .spinner {
@ -277,29 +275,49 @@
top: 9px;
}
#find-posts-input {
float: right;
width: 140px;
height: 24px;
}
#find-posts-input,
#find-posts-search {
float: right;
margin: 1px 3px 0 4px;
}
#find-posts-response {
margin: 8px 0;
padding: 0 1px 6px;
#find-posts-input {
width: 140px;
height: 28px;
margin: 0 0 0 4px;
}
#find-posts-response table {
width: 100%;
.found-radio {
width: 16px;
}
#find-posts-response .found-radio {
padding: 3px 8px 0 0;
width: 15px;
#find-posts-close {
width: 40px;
height: 40px;
position: absolute;
top: 0;
left: 0;
cursor: pointer;
text-align: center;
color: #666;
}
#find-posts-close:hover {
color: #2ea2cc;
}
#find-posts-close:before {
font: normal 20px/40px 'dashicons';
vertical-align: top;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: '\f158';
}
.find-box-buttons {
padding: 6px 16px;
background: #fcfcfc;
border-top: 1px solid #dfdfdf;
}
.find-box #resize-se {
@ -309,12 +327,14 @@
}
.ui-find-overlay {
position: absolute;
position: fixed;
top: 0;
right: 0;
background-color: #000;
opacity: 0.6;
filter: alpha(opacity=60);
left: 0;
bottom: 0;
background: #000;
opacity: 0.7;
z-index: 159900;
}
ul#dismissed-updates {

View File

@ -233,41 +233,39 @@
------------------------------------------------------------------------------*/
.find-box {
background-color: #fff;
width: 600px;
height: 300px;
max-width: 100%;
overflow: hidden;
padding: 33px 0 51px;
position: absolute;
z-index: 1000;
background-color: #444;
margin-left: -300px;
position: fixed;
top: 30px;
left: 50%;
z-index: 160000;
}
.find-box-head {
cursor: move;
color: #eee;
background: #fcfcfc;
border-bottom: 1px solid #dfdfdf;
height: 40px;
font-size: 22px;
font-weight: 600;
height: 2em;
line-height: 2em;
padding: 1px 12px;
position: absolute;
top: 5px;
width: 100%;
line-height: 40px;
padding: 0 40px 0 16px;
overflow: hidden;
}
.find-box-inside {
overflow: auto;
padding: 6px;
height: 100%;
padding: 16px;
background-color: #fff;
max-height: 300px;
overflow-y: scroll;
}
.find-box-search,
.find-box-buttons {
overflow: hidden;
padding: 8px;
position: relative;
background-color: #f7f7f7;
border-top: 1px solid #dfdfdf;
.find-box-search {
padding-bottom: 16px;
}
.find-box-search .spinner {
@ -277,29 +275,49 @@
top: 9px;
}
#find-posts-input {
float: left;
width: 140px;
height: 24px;
}
#find-posts-input,
#find-posts-search {
float: left;
margin: 1px 4px 0 3px;
}
#find-posts-response {
margin: 8px 0;
padding: 0 1px 6px;
#find-posts-input {
width: 140px;
height: 28px;
margin: 0 4px 0 0;
}
#find-posts-response table {
width: 100%;
.found-radio {
width: 16px;
}
#find-posts-response .found-radio {
padding: 3px 0 0 8px;
width: 15px;
#find-posts-close {
width: 40px;
height: 40px;
position: absolute;
top: 0;
right: 0;
cursor: pointer;
text-align: center;
color: #666;
}
#find-posts-close:hover {
color: #2ea2cc;
}
#find-posts-close:before {
font: normal 20px/40px 'dashicons';
vertical-align: top;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: '\f158';
}
.find-box-buttons {
padding: 6px 16px;
background: #fcfcfc;
border-top: 1px solid #dfdfdf;
}
.find-box #resize-se {
@ -309,12 +327,14 @@
}
.ui-find-overlay {
position: absolute;
position: fixed;
top: 0;
left: 0;
background-color: #000;
opacity: 0.6;
filter: alpha(opacity=60);
right: 0;
bottom: 0;
background: #000;
opacity: 0.7;
z-index: 159900;
}
ul#dismissed-updates {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1431,8 +1431,10 @@ function wp_ajax_find_posts() {
wp_die( __('No items found.') );
$html = '<table class="widefat"><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>';
$alt = '';
foreach ( $posts as $post ) {
$title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
switch ( $post->post_status ) {
case 'publish' :
@ -1457,7 +1459,7 @@ function wp_ajax_find_posts() {
$time = mysql2date(__('Y/m/d'), $post->post_date);
}
$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 .= '<tr class="' . trim( 'found-posts ' . $alt ) . '"><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( $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";
}

View File

@ -1377,25 +1377,28 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
function find_posts_div($found_action = '') {
?>
<div id="find-posts" class="find-box" style="display: none;">
<div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
<div id="find-posts-head" class="find-box-head">
<?php _e( 'Find Posts or Pages' ); ?>
<div id="find-posts-close"></div>
</div>
<div class="find-box-inside">
<div class="find-box-search">
<?php if ( $found_action ) { ?>
<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
<?php } ?>
<input type="hidden" name="affected" id="affected" value="" />
<?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="" />
<span class="spinner"></span>
<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
<div class="clear"></div>
</div>
<div id="find-posts-response"></div>
</div>
<div class="find-box-buttons">
<input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" />
<?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
<div class="clear"></div>
</div>
</div>
<?php

View File

@ -19,7 +19,11 @@ var findPosts;
}
$('#find-posts').show().draggable({
handle: '#find-posts-head'
}).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-328px'});
});
$('.find-box-inside').css({
'max-height': $( window ).height() - ( ( 30 + 40 + 1 + 16 ) * 2 ) + 'px'
});
$('#find-posts-input').focus().keyup(function(e){
if (e.which == 27) { findPosts.close(); } // close on Escape
@ -38,9 +42,7 @@ var findPosts;
},
overlay : function() {
$( '.ui-find-overlay' ).css(
{ 'z-index': '999', 'width': $( document ).width() + 'px', 'height': $( document ).height() + 'px' }
).on('click', function () {
$( '.ui-find-overlay' ).on( 'click', function () {
findPosts.close();
});
},
@ -120,6 +122,8 @@ var findPosts;
});
});
$(window).resize(function() {
findPosts.overlay();
$('.find-box-inside').css({
'max-height': $( window ).height() - ( ( 30 + 40 + 1 + 16 ) * 2 ) + 'px'
});
});
})(jQuery);

View File

@ -1 +1 @@
var findPosts;!function(a){findPosts={open:function(b,c){var d=document.documentElement.scrollTop||a(document).scrollTop(),e=a(".ui-find-overlay");return 0===e.length&&(a("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),e.show(),b&&c&&a("#affected").attr("name",b).val(c),a("#find-posts").show().draggable({handle:"#find-posts-head"}).css({top:d+50+"px",left:"50%",marginLeft:"-328px"}),a("#find-posts-input").focus().keyup(function(a){27==a.which&&findPosts.close()}),findPosts.send(),!1},close:function(){a("#find-posts-response").html(""),a("#find-posts").draggable("destroy").hide(),a(".ui-find-overlay").hide()},overlay:function(){a(".ui-find-overlay").css({"z-index":"999",width:a(document).width()+"px",height:a(document).height()+"px"}).on("click",function(){findPosts.close()})},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()},c=a(".find-box-search .spinner");c.show(),a.ajax({type:"POST",url:ajaxurl,data:b,success:function(a){findPosts.show(a),c.hide()},error:function(a){findPosts.error(a),c.hide()}})},show:function(b){if("string"==typeof b)return void this.error({responseText:b});var c=wpAjax.parseAjaxResponse(b);c.errors&&this.error({responseText:wpAjax.broken}),c=c.responses[0],a("#find-posts-response").html(c.data),a(".found-posts td").on("click",function(){a(this).parent().find(".found-radio input").prop("checked",!0)})},error:function(b){var c=b.statusText;b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#find-posts-response").html(c)}},a(document).ready(function(){a("#find-posts-submit").click(function(b){""===a("#find-posts-response").html()&&b.preventDefault()}),a("#find-posts .find-box-search :input").keypress(function(a){return 13==a.which?(findPosts.send(),!1):void 0}),a("#find-posts-search").click(findPosts.send),a("#find-posts-close").click(findPosts.close),a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){"attach"==a(this).val()&&(b.preventDefault(),findPosts.open())})})}),a(window).resize(function(){findPosts.overlay()})}(jQuery);
var findPosts;!function(a){findPosts={open:function(b,c){var d=(document.documentElement.scrollTop||a(document).scrollTop(),a(".ui-find-overlay"));return 0===d.length&&(a("body").append('<div class="ui-find-overlay"></div>'),findPosts.overlay()),d.show(),b&&c&&a("#affected").attr("name",b).val(c),a("#find-posts").show().draggable({handle:"#find-posts-head"}),a(".find-box-inside").css({"max-height":a(window).height()-174+"px"}),a("#find-posts-input").focus().keyup(function(a){27==a.which&&findPosts.close()}),findPosts.send(),!1},close:function(){a("#find-posts-response").html(""),a("#find-posts").draggable("destroy").hide(),a(".ui-find-overlay").hide()},overlay:function(){a(".ui-find-overlay").on("click",function(){findPosts.close()})},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()},c=a(".find-box-search .spinner");c.show(),a.ajax({type:"POST",url:ajaxurl,data:b,success:function(a){findPosts.show(a),c.hide()},error:function(a){findPosts.error(a),c.hide()}})},show:function(b){if("string"==typeof b)return void this.error({responseText:b});var c=wpAjax.parseAjaxResponse(b);c.errors&&this.error({responseText:wpAjax.broken}),c=c.responses[0],a("#find-posts-response").html(c.data),a(".found-posts td").on("click",function(){a(this).parent().find(".found-radio input").prop("checked",!0)})},error:function(b){var c=b.statusText;b.responseText&&(c=b.responseText.replace(/<.[^<>]*?>/g,"")),c&&a("#find-posts-response").html(c)}},a(document).ready(function(){a("#find-posts-submit").click(function(b){""===a("#find-posts-response").html()&&b.preventDefault()}),a("#find-posts .find-box-search :input").keypress(function(a){return 13==a.which?(findPosts.send(),!1):void 0}),a("#find-posts-search").click(findPosts.send),a("#find-posts-close").click(findPosts.close),a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){"attach"==a(this).val()&&(b.preventDefault(),findPosts.open())})})}),a(window).resize(function(){a(".find-box-inside").css({"max-height":a(window).height()-174+"px"})})}(jQuery);

View File

@ -145,6 +145,8 @@ wp_enqueue_script( 'wp-ajax-response' );
wp_enqueue_script( 'jquery-ui-draggable' );
wp_enqueue_script( 'media' );
add_action( 'admin_print_footer_scripts', 'find_posts_div' );
add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
get_current_screen()->add_help_tab( array(
@ -238,12 +240,10 @@ if ( !empty($message) ) { ?>
<?php $wp_list_table->display(); ?>
<div id="ajax-response"></div>
<?php find_posts_div(); ?>
<br class="clear" />
</form>
</div>
<div id="ajax-response"></div>
<?php
include( ABSPATH . 'wp-admin/admin-footer.php' );