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 { .find-box {
background-color: #fff;
width: 600px; width: 600px;
height: 300px; max-width: 100%;
overflow: hidden; overflow: hidden;
padding: 33px 0 51px; margin-right: -300px;
position: absolute; position: fixed;
z-index: 1000; top: 30px;
background-color: #444; right: 50%;
z-index: 160000;
} }
.find-box-head { .find-box-head {
cursor: move; cursor: move;
color: #eee; background: #fcfcfc;
border-bottom: 1px solid #dfdfdf;
height: 40px;
font-size: 22px;
font-weight: 600; font-weight: 600;
height: 2em; line-height: 40px;
line-height: 2em; padding: 0 16px 0 40px;
padding: 1px 12px; overflow: hidden;
position: absolute;
top: 5px;
width: 100%;
} }
.find-box-inside { .find-box-inside {
overflow: auto; overflow: auto;
padding: 6px; padding: 16px;
height: 100%;
background-color: #fff; background-color: #fff;
max-height: 300px;
overflow-y: scroll;
} }
.find-box-search, .find-box-search {
.find-box-buttons { padding-bottom: 16px;
overflow: hidden;
padding: 8px;
position: relative;
background-color: #f7f7f7;
border-top: 1px solid #dfdfdf;
} }
.find-box-search .spinner { .find-box-search .spinner {
@ -277,29 +275,49 @@
top: 9px; top: 9px;
} }
#find-posts-input { #find-posts-input,
float: right;
width: 140px;
height: 24px;
}
#find-posts-search { #find-posts-search {
float: right; float: right;
margin: 1px 3px 0 4px;
} }
#find-posts-response { #find-posts-input {
margin: 8px 0; width: 140px;
padding: 0 1px 6px; height: 28px;
margin: 0 0 0 4px;
} }
#find-posts-response table { .found-radio {
width: 100%; width: 16px;
} }
#find-posts-response .found-radio { #find-posts-close {
padding: 3px 8px 0 0; width: 40px;
width: 15px; 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 { .find-box #resize-se {
@ -309,12 +327,14 @@
} }
.ui-find-overlay { .ui-find-overlay {
position: absolute; position: fixed;
top: 0; top: 0;
right: 0; right: 0;
background-color: #000; left: 0;
opacity: 0.6; bottom: 0;
filter: alpha(opacity=60); background: #000;
opacity: 0.7;
z-index: 159900;
} }
ul#dismissed-updates { ul#dismissed-updates {

View File

@ -233,41 +233,39 @@
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
.find-box { .find-box {
background-color: #fff;
width: 600px; width: 600px;
height: 300px; max-width: 100%;
overflow: hidden; overflow: hidden;
padding: 33px 0 51px; margin-left: -300px;
position: absolute; position: fixed;
z-index: 1000; top: 30px;
background-color: #444; left: 50%;
z-index: 160000;
} }
.find-box-head { .find-box-head {
cursor: move; cursor: move;
color: #eee; background: #fcfcfc;
border-bottom: 1px solid #dfdfdf;
height: 40px;
font-size: 22px;
font-weight: 600; font-weight: 600;
height: 2em; line-height: 40px;
line-height: 2em; padding: 0 40px 0 16px;
padding: 1px 12px; overflow: hidden;
position: absolute;
top: 5px;
width: 100%;
} }
.find-box-inside { .find-box-inside {
overflow: auto; overflow: auto;
padding: 6px; padding: 16px;
height: 100%;
background-color: #fff; background-color: #fff;
max-height: 300px;
overflow-y: scroll;
} }
.find-box-search, .find-box-search {
.find-box-buttons { padding-bottom: 16px;
overflow: hidden;
padding: 8px;
position: relative;
background-color: #f7f7f7;
border-top: 1px solid #dfdfdf;
} }
.find-box-search .spinner { .find-box-search .spinner {
@ -277,29 +275,49 @@
top: 9px; top: 9px;
} }
#find-posts-input { #find-posts-input,
float: left;
width: 140px;
height: 24px;
}
#find-posts-search { #find-posts-search {
float: left; float: left;
margin: 1px 4px 0 3px;
} }
#find-posts-response { #find-posts-input {
margin: 8px 0; width: 140px;
padding: 0 1px 6px; height: 28px;
margin: 0 4px 0 0;
} }
#find-posts-response table { .found-radio {
width: 100%; width: 16px;
} }
#find-posts-response .found-radio { #find-posts-close {
padding: 3px 0 0 8px; width: 40px;
width: 15px; 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 { .find-box #resize-se {
@ -309,12 +327,14 @@
} }
.ui-find-overlay { .ui-find-overlay {
position: absolute; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
background-color: #000; right: 0;
opacity: 0.6; bottom: 0;
filter: alpha(opacity=60); background: #000;
opacity: 0.7;
z-index: 159900;
} }
ul#dismissed-updates { 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.') ); 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>'; $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 ) { foreach ( $posts as $post ) {
$title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
switch ( $post->post_status ) { switch ( $post->post_status ) {
case 'publish' : case 'publish' :
@ -1457,7 +1459,7 @@ function wp_ajax_find_posts() {
$time = mysql2date(__('Y/m/d'), $post->post_date); $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"; $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 = '') { function find_posts_div($found_action = '') {
?> ?>
<div id="find-posts" class="find-box" style="display: none;"> <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-inside">
<div class="find-box-search"> <div class="find-box-search">
<?php if ( $found_action ) { ?> <?php if ( $found_action ) { ?>
<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" /> <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
<?php } ?> <?php } ?>
<input type="hidden" name="affected" id="affected" value="" /> <input type="hidden" name="affected" id="affected" value="" />
<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> <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="text" id="find-posts-input" name="ps" value="" />
<span class="spinner"></span> <span class="spinner"></span>
<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /> <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
<div class="clear"></div>
</div> </div>
<div id="find-posts-response"></div> <div id="find-posts-response"></div>
</div> </div>
<div class="find-box-buttons"> <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 ); ?> <?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
<div class="clear"></div>
</div> </div>
</div> </div>
<?php <?php

View File

@ -19,7 +19,11 @@ var findPosts;
} }
$('#find-posts').show().draggable({ $('#find-posts').show().draggable({
handle: '#find-posts-head' 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){ $('#find-posts-input').focus().keyup(function(e){
if (e.which == 27) { findPosts.close(); } // close on Escape if (e.which == 27) { findPosts.close(); } // close on Escape
@ -38,9 +42,7 @@ var findPosts;
}, },
overlay : function() { overlay : function() {
$( '.ui-find-overlay' ).css( $( '.ui-find-overlay' ).on( 'click', function () {
{ 'z-index': '999', 'width': $( document ).width() + 'px', 'height': $( document ).height() + 'px' }
).on('click', function () {
findPosts.close(); findPosts.close();
}); });
}, },
@ -120,6 +122,8 @@ var findPosts;
}); });
}); });
$(window).resize(function() { $(window).resize(function() {
findPosts.overlay(); $('.find-box-inside').css({
'max-height': $( window ).height() - ( ( 30 + 40 + 1 + 16 ) * 2 ) + 'px'
});
}); });
})(jQuery); })(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( 'jquery-ui-draggable' );
wp_enqueue_script( 'media' ); 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)' )) ); add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
get_current_screen()->add_help_tab( array( get_current_screen()->add_help_tab( array(
@ -238,12 +240,10 @@ if ( !empty($message) ) { ?>
<?php $wp_list_table->display(); ?> <?php $wp_list_table->display(); ?>
<div id="ajax-response"></div>
<?php find_posts_div(); ?>
<br class="clear" />
</form> </form>
</div> </div>
<div id="ajax-response"></div>
<?php <?php
include( ABSPATH . 'wp-admin/admin-footer.php' ); include( ABSPATH . 'wp-admin/admin-footer.php' );