Auto column switching (post.php only for now), see #18198

git-svn-id: http://svn.automattic.com/wordpress/trunk@18581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-08-22 19:41:11 +00:00
parent c93728e287
commit 18fd646bc3
6 changed files with 85 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -112,15 +112,26 @@ TABLE OF CONTENTS:
float: right;
clear: right;
display: none;
width: 281px;
min-width: 281px;
position: relative;
}
.wide-screen .inner-sidebar {
margin-right: -870px;
width: 100%;
}
.inner-sidebar #side-sortables {
width: 280px;
min-height: 300px;
}
.wide-screen .inner-sidebar #side-sortables {
min-width: 280px;
width: auto;
padding-right: 870px;
}
.has-right-sidebar .inner-sidebar {
display: block;
}
@ -130,6 +141,7 @@ TABLE OF CONTENTS:
clear: left;
width: 100%;
margin-right: -340px;
max-width: 1150px;
}
.has-right-sidebar #post-body-content {
@ -219,13 +231,17 @@ body {
height: 100%;
margin: 0;
padding: 0;
min-width: 950px; /* from widgets, doto */
}
body {
font-family: sans-serif;
font-size: 12px;
line-height: 1.4em;
min-width: 950px; /* to do, responsive admin */
}
body.post-php {
min-width: 560px;
}
td,
@ -1998,10 +2014,6 @@ strong .post-com-count {
8.0 - Layout Blocks
------------------------------------------------------------------------------*/
body.wp-admin {
min-width: 785px;
}
body.admin-bar #wphead,
body.admin-bar #adminmenu {
padding-top: 28px;
@ -2677,6 +2689,10 @@ table .inline-edit-row fieldset ul.cat-hover {
11.0 - Write/Edit Post Screen
------------------------------------------------------------------------------*/
.postarea {
max-width: 900px;
}
#titlediv {
position: relative;
margin-bottom: 20px;
@ -5752,10 +5768,6 @@ body.login {
/* nav-menu */
body {
min-width: 950px;
}
#nav-menus-frame {
margin-left: 300px;
}
@ -7241,10 +7253,6 @@ margin-bottom: 10px;
/* widgets */
html,
body {
min-width: 950px;
}
/* 2 column liquid layout */
div.widget-liquid-left {

View File

@ -1873,11 +1873,11 @@ function screen_layout($screen) {
$screen_layout_columns = get_user_option("screen_layout_$screen->id");
$num = $wp_current_screen_options['layout_columns']['max'];
if ( ! $screen_layout_columns ) {
if ( ! $screen_layout_columns && $screen_layout_columns !== 0 ) {
if ( isset($wp_current_screen_options['layout_columns']['default']) )
$screen_layout_columns = $wp_current_screen_options['layout_columns']['default'];
else
$screen_layout_columns = 2;
$screen_layout_columns = '0';
}
$i = 1;
@ -1886,6 +1886,7 @@ function screen_layout($screen) {
$return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n";
++$i;
}
$return .= "<label><input type='radio' id='wp_auto_columns' name='screen_columns' value='0'" . ( ($screen_layout_columns === '0') ? " checked='checked'" : "" ) . " />" . __('auto') . "</label>\n";
$return .= "</div>\n";
return $return;
}

View File

@ -1,4 +1,5 @@
var postboxes;
var postboxes, wp_auto_columns, wpAutoColumns = false;
(function($) {
postboxes = {
add_postbox_toggles : function(page,args) {
@ -42,13 +43,23 @@ var postboxes;
$('.columns-prefs input[type="radio"]').click(function(){
var num = $(this).val(), i, el, p = $('#poststuff');
if ( num === '0' ) {
if ( typeof(wp_auto_columns) == 'function' ) {
wpAutoColumns = true;
wp_auto_columns();
}
return;
}
if ( p.length ) { // write pages
if ( num == 2 ) {
p.addClass('has-right-sidebar');
$('#side-sortables').addClass('temp-border');
$('#side-info-column').append( $('#side-sortables') );
$(document.body).removeClass('responsive');
} else if ( num == 1 ) {
p.removeClass('has-right-sidebar');
$('#normal-sortables').append($('#side-sortables').children('.postbox'));
$('#normal-sortables').before( $('#side-sortables') );
$(document.body).removeClass('responsive');
}
} else { // dashboard
for ( i = 4; ( i > num && i > 1 ); i-- ) {
@ -150,4 +161,46 @@ var postboxes;
pbhide : false
};
$(document).ready(function(){
// responsive admin
wpAutoColumns = $('#wp_auto_columns').prop('checked');
wp_auto_columns = function() {
var w = $(window).width(), pb;
if ( !wpAutoColumns )
return;
if ( adminpage == 'post-php' ) {
pb = $('#post-body').width();
if ( pb > 1149 )
$(document.body).addClass('wide-screen');
if ( pb < 1150 )
$(document.body).removeClass('wide-screen');
if ( pb < 801 ) {
$('#poststuff').removeClass('has-right-sidebar');
$('#normal-sortables').before( $('#side-sortables') );
}
if ( pb > 800 ) {
$('#poststuff').addClass('has-right-sidebar');
$('#side-info-column').append( $('#side-sortables') );
}
if ( w < 681 )
$(document.body).addClass('folded');
if ( w > 680 )
$(document.body).removeClass('folded');
}
}
$(window).resize(function(){ wp_auto_columns(); });
wp_auto_columns();
});
}(jQuery));

View File

@ -1 +1 @@
var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox"),f=e.attr("id");if("dashboard_browser_nag"==f){return}e.toggleClass("closed");postboxes.save_state(c);if(f){if(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(f)}else{if(e.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(f)}}}});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".postbox a.dismiss").click(function(g){var f=a(this).parents(".postbox").attr("id")+"-hide";a("#"+f).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).prop("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-sortables").addClass("temp-border")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").append(a("#side-sortables").children(".postbox"))}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,stop:function(f,d){if(a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id){a(this).sortable("cancel");return}postboxes.save_order(c);d.item.parent().removeClass("temp-border")},receive:function(f,d){if("dashboard_browser_nag"==d.item[0].id){a(d.sender).sortable("cancel")}}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},pbshow:false,pbhide:false}}(jQuery));
var postboxes,wp_auto_columns,wpAutoColumns=false;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox"),f=e.attr("id");if("dashboard_browser_nag"==f){return}e.toggleClass("closed");postboxes.save_state(c);if(f){if(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(f)}else{if(e.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(f)}}}});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".postbox a.dismiss").click(function(g){var f=a(this).parents(".postbox").attr("id")+"-hide";a("#"+f).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).prop("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(e==="0"){if(typeof(wp_auto_columns)=="function"){wpAutoColumns=true;wp_auto_columns()}return}if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-info-column").append(a("#side-sortables"));a(document.body).removeClass("responsive")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").before(a("#side-sortables"));a(document.body).removeClass("responsive")}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,stop:function(f,d){if(a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id){a(this).sortable("cancel");return}postboxes.save_order(c);d.item.parent().removeClass("temp-border")},receive:function(f,d){if("dashboard_browser_nag"==d.item[0].id){a(d.sender).sortable("cancel")}}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},pbshow:false,pbhide:false};a(document).ready(function(){wpAutoColumns=a("#wp_auto_columns").prop("checked");wp_auto_columns=function(){var b=a(window).width(),c;if(!wpAutoColumns){return}if(adminpage=="post-php"){c=a("#post-body").width();if(c>1149){a(document.body).addClass("wide-screen")}if(c<1150){a(document.body).removeClass("wide-screen")}if(c<801){a("#poststuff").removeClass("has-right-sidebar");a("#normal-sortables").before(a("#side-sortables"))}if(c>800){a("#poststuff").addClass("has-right-sidebar");a("#side-info-column").append(a("#side-sortables"))}if(b<681){a(document.body).addClass("folded")}if(b>680){a(document.body).removeClass("folded")}}};a(window).resize(function(){wp_auto_columns()});wp_auto_columns()})}(jQuery));

View File

@ -279,7 +279,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20110524', 1 );
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110612', 1 );
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20110822', 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524', 1 );
$scripts->add_script_data( 'post', 'postL10n', array(
@ -402,7 +402,7 @@ function wp_default_styles( &$styles ) {
// Any rtl stylesheets that don't have a .dev version for ltr
$no_suffix = array( 'farbtastic' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110820' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110822' );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array('wp-admin'), '20110711' );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );