Auto column switching for the dashboard, see #18198
git-svn-id: https://develop.svn.wordpress.org/trunk@18582 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2ae505d0c6
commit
1e0034e8fd
File diff suppressed because one or more lines are too long
@ -240,7 +240,8 @@ body {
|
|||||||
min-width: 950px; /* to do, responsive admin */
|
min-width: 950px; /* to do, responsive admin */
|
||||||
}
|
}
|
||||||
|
|
||||||
body.post-php {
|
body.post-php,
|
||||||
|
body.index-php {
|
||||||
min-width: 560px;
|
min-width: 560px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2048,7 +2049,6 @@ body.admin-bar #adminmenu {
|
|||||||
|
|
||||||
.postbox-container {
|
.postbox-container {
|
||||||
float: left;
|
float: left;
|
||||||
padding-right: 0.5%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.postbox-container .meta-box-sortables {
|
.postbox-container .meta-box-sortables {
|
||||||
@ -2116,14 +2116,6 @@ body.admin-bar #adminmenu {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.postbox input[type="text"],
|
|
||||||
.postbox textarea,
|
|
||||||
.stuffbox input[type="text"],
|
|
||||||
.stuffbox textarea {
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
}
|
|
||||||
|
|
||||||
.temp-border {
|
.temp-border {
|
||||||
border: 1px dotted #ccc;
|
border: 1px dotted #ccc;
|
||||||
}
|
}
|
||||||
@ -2142,7 +2134,7 @@ body.admin-bar #adminmenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#dashboard-widgets .meta-box-sortables {
|
#dashboard-widgets .meta-box-sortables {
|
||||||
margin: 0 5px;
|
margin: 0 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#dashboard_recent_comments div.undo {
|
#dashboard_recent_comments div.undo {
|
||||||
|
@ -200,33 +200,33 @@ function wp_dashboard() {
|
|||||||
$hide2 = $hide3 = $hide4 = '';
|
$hide2 = $hide3 = $hide4 = '';
|
||||||
switch ( $screen_layout_columns ) {
|
switch ( $screen_layout_columns ) {
|
||||||
case 4:
|
case 4:
|
||||||
$width = 'width:24.5%;';
|
$width = 'width:25%;';
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$width = 'width:32.67%;';
|
$width = 'width:33.333333%;';
|
||||||
$hide4 = 'display:none;';
|
$hide4 = 'display:none;';
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$width = 'width:49%;';
|
$width = 'width:50%;';
|
||||||
$hide3 = $hide4 = 'display:none;';
|
$hide3 = $hide4 = 'display:none;';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$width = 'width:98%;';
|
$width = 'width:100%;';
|
||||||
$hide2 = $hide3 = $hide4 = 'display:none;';
|
$hide2 = $hide3 = $hide4 = 'display:none;';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div id="dashboard-widgets" class="metabox-holder">
|
<div id="dashboard-widgets" class="metabox-holder">
|
||||||
<?php
|
<?php
|
||||||
echo "\t<div class='postbox-container' style='$width'>\n";
|
echo "\t<div id='postbox-container-1' class='postbox-container' style='$width'>\n";
|
||||||
do_meta_boxes( $screen->id, 'normal', '' );
|
do_meta_boxes( $screen->id, 'normal', '' );
|
||||||
|
|
||||||
echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n";
|
echo "\t</div><div id='postbox-container-2' class='postbox-container' style='{$hide2}$width'>\n";
|
||||||
do_meta_boxes( $screen->id, 'side', '' );
|
do_meta_boxes( $screen->id, 'side', '' );
|
||||||
|
|
||||||
echo "\t</div><div class='postbox-container' style='{$hide3}$width'>\n";
|
echo "\t</div><div id='postbox-container-3' class='postbox-container' style='{$hide3}$width'>\n";
|
||||||
do_meta_boxes( $screen->id, 'column3', '' );
|
do_meta_boxes( $screen->id, 'column3', '' );
|
||||||
|
|
||||||
echo "\t</div><div class='postbox-container' style='{$hide4}$width'>\n";
|
echo "\t</div><div id='postbox-container-4' class='postbox-container' style='{$hide4}$width'>\n";
|
||||||
do_meta_boxes( $screen->id, 'column4', '' );
|
do_meta_boxes( $screen->id, 'column4', '' );
|
||||||
?>
|
?>
|
||||||
</div></div>
|
</div></div>
|
||||||
|
@ -48,9 +48,7 @@ var postboxes, wp_auto_columns, wpAutoColumns = false;
|
|||||||
wpAutoColumns = true;
|
wpAutoColumns = true;
|
||||||
wp_auto_columns();
|
wp_auto_columns();
|
||||||
}
|
}
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if ( p.length ) { // write pages
|
if ( p.length ) { // write pages
|
||||||
if ( num == 2 ) {
|
if ( num == 2 ) {
|
||||||
p.addClass('has-right-sidebar');
|
p.addClass('has-right-sidebar');
|
||||||
@ -72,7 +70,8 @@ var postboxes, wp_auto_columns, wpAutoColumns = false;
|
|||||||
if ( el.parent().is(':hidden') )
|
if ( el.parent().is(':hidden') )
|
||||||
el.addClass('temp-border').parent().show();
|
el.addClass('temp-border').parent().show();
|
||||||
}
|
}
|
||||||
$('.postbox-container:visible').css('width', 98/num + '%');
|
$('.postbox-container:visible').css('width', 100/num + '%');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
postboxes.save_order(page);
|
postboxes.save_order(page);
|
||||||
});
|
});
|
||||||
@ -167,35 +166,64 @@ var postboxes, wp_auto_columns, wpAutoColumns = false;
|
|||||||
wpAutoColumns = $('#wp_auto_columns').prop('checked');
|
wpAutoColumns = $('#wp_auto_columns').prop('checked');
|
||||||
|
|
||||||
wp_auto_columns = function() {
|
wp_auto_columns = function() {
|
||||||
var w = $(window).width(), pb;
|
var w = $(window).width(), pb, dw, num = 1;
|
||||||
|
|
||||||
if ( !wpAutoColumns )
|
if ( !wpAutoColumns )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( w < 681 )
|
||||||
|
$(document.body).addClass('folded');
|
||||||
|
|
||||||
|
if ( w > 680 && getUserSetting('mfold') != 'f' )
|
||||||
|
$(document.body).removeClass('folded');
|
||||||
|
|
||||||
if ( adminpage == 'post-php' ) {
|
if ( adminpage == 'post-php' ) {
|
||||||
pb = $('#post-body').width();
|
pb = $('#post-body').width();
|
||||||
|
|
||||||
if ( pb > 1149 )
|
|
||||||
$(document.body).addClass('wide-screen');
|
|
||||||
|
|
||||||
if ( pb < 1150 )
|
|
||||||
$(document.body).removeClass('wide-screen');
|
|
||||||
|
|
||||||
if ( pb < 801 ) {
|
if ( pb < 801 ) {
|
||||||
$('#poststuff').removeClass('has-right-sidebar');
|
$('#poststuff').removeClass('has-right-sidebar');
|
||||||
$('#normal-sortables').before( $('#side-sortables') );
|
$('#normal-sortables').before( $('#side-sortables') );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pb > 800 ) {
|
if ( pb > 800 && pb < 1150 ) {
|
||||||
$('#poststuff').addClass('has-right-sidebar');
|
$('#poststuff').addClass('has-right-sidebar');
|
||||||
$('#side-info-column').append( $('#side-sortables') );
|
$('#side-info-column').append( $('#side-sortables') );
|
||||||
|
$(document.body).removeClass('wide-screen');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( w < 681 )
|
if ( pb > 1149 ) {
|
||||||
$(document.body).addClass('folded');
|
$(document.body).addClass('wide-screen');
|
||||||
|
}
|
||||||
|
|
||||||
if ( w > 680 )
|
} else if ( adminpage == 'index-php' ) {
|
||||||
$(document.body).removeClass('folded');
|
dw = $('#dashboard-widgets').width();
|
||||||
|
|
||||||
|
if ( dw < 801 ) {
|
||||||
|
$('#postbox-container-2').hide();
|
||||||
|
$('#normal-sortables').after( $('#side-sortables') );
|
||||||
|
num = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dw > 800 && dw < 1201 ) {
|
||||||
|
$('#postbox-container-2').show().append( $('#side-sortables') );
|
||||||
|
$('#postbox-container-3').hide();
|
||||||
|
$('#side-sortables').after( $('#column3-sortables') );
|
||||||
|
num = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dw > 1200 && dw < 1601 ) {
|
||||||
|
$('#postbox-container-3').show().append( $('#column3-sortables') );
|
||||||
|
$('#postbox-container-4').hide();
|
||||||
|
$('#column3-sortables').after( $('#column4-sortables') );
|
||||||
|
num = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dw > 1600 ) {
|
||||||
|
$('#postbox-container-4').show().append( $('#column4-sortables') );
|
||||||
|
num = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.postbox-container:visible').css('width', 100/num + '%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
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));
|
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()}}else{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",100/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(),e,d,c=1;if(!wpAutoColumns){return}if(b<681){a(document.body).addClass("folded")}if(b>680&&getUserSetting("mfold")!="f"){a(document.body).removeClass("folded")}if(adminpage=="post-php"){e=a("#post-body").width();if(e<801){a("#poststuff").removeClass("has-right-sidebar");a("#normal-sortables").before(a("#side-sortables"))}if(e>800&&e<1150){a("#poststuff").addClass("has-right-sidebar");a("#side-info-column").append(a("#side-sortables"));a(document.body).removeClass("wide-screen")}if(e>1149){a(document.body).addClass("wide-screen")}}else{if(adminpage=="index-php"){d=a("#dashboard-widgets").width();if(d<801){a("#postbox-container-2").hide();a("#normal-sortables").after(a("#side-sortables"));c=1}if(d>800&&d<1201){a("#postbox-container-2").show().append(a("#side-sortables"));a("#postbox-container-3").hide();a("#side-sortables").after(a("#column3-sortables"));c=2}if(d>1200&&d<1601){a("#postbox-container-3").show().append(a("#column3-sortables"));a("#postbox-container-4").hide();a("#column3-sortables").after(a("#column4-sortables"));c=3}if(d>1600){a("#postbox-container-4").show().append(a("#column4-sortables"));c=4}a(".postbox-container:visible").css("width",100/c+"%")}}};a(window).resize(function(){wp_auto_columns()});wp_auto_columns()})}(jQuery));
|
Loading…
Reference in New Issue
Block a user