Clean up unused bits from responsive admin, fix the JS on dashboard, see #18863

git-svn-id: http://svn.automattic.com/wordpress/trunk@18900 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-10-06 08:43:01 +00:00
parent a0f6c4469d
commit 53ac6d4a37
6 changed files with 91 additions and 149 deletions

View File

@ -90,14 +90,7 @@ if ( $is_iphone ) { ?>
<?php } ?>
</head>
<body class="wp-admin no-js <?php echo apply_filters( 'admin_body_class', '' ) . " $admin_body_class"; ?>">
<script type="text/javascript">
(function(){
var bc = document.body.className, w = bc.match(/folded/) ? 1217 : 1330;
document.body.className = bc.replace(/no-js/, 'js');
if ( document.body.clientWidth > w )
document.body.className += ' wide-window';
})();
</script>
<script type="text/javascript">document.body.className = document.body.className.replace('no-js','js');</script>
<div id="wpwrap">
<?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>

File diff suppressed because one or more lines are too long

View File

@ -118,26 +118,12 @@ TABLE OF CONTENTS:
position: relative;
}
.wide-window .inner-sidebar {
margin-right: -870px;
width: 100%;
display: block;
}
.columns-2 .inner-sidebar,
.wide-window .columns-2 .inner-sidebar {
.columns-2 .inner-sidebar {
margin-right: auto;
width: 286px;
display: block;
}
.wide-window .inner-sidebar #side-sortables {
margin-right: 870px;
min-width: 280px;
max-width: 480px;
width: auto;
}
.inner-sidebar #side-sortables,
.columns-2 .inner-sidebar #side-sortables {
min-height: 300px;
@ -170,12 +156,7 @@ TABLE OF CONTENTS:
max-width: none;
}
#side-sortables:empty {
border: 3px dashed #ccc;
height: 500px;
}
#post-body-content #side-sortables:empty {
#post-body-content #side-sortables.empty-container {
border: 0 none;
height: 0;
}
@ -204,6 +185,10 @@ TABLE OF CONTENTS:
width: 59%;
}
.col-wrap {
padding: 0 7px;
}
/* utility classes */
.alignleft {
float: left;
@ -2076,9 +2061,10 @@ body.admin-bar #adminmenu {
float: left;
}
.postbox-container .meta-box-sortables:empty:first-child {
.postbox-container .meta-box-sortables.empty-container,
#side-sortables.empty-container {
border: 3px dashed #CCCCCC;
height: 300px;
height: 350px;
}
.postbox .hndle {
@ -2981,7 +2967,14 @@ div.tabs-panel-inactive {
text-decoration: none;
}
#side-sortables .category-tabs,
#side-sortables .category-tabs {
margin: 8px 0 3px;
}
#category-adder h4 {
margin: 10px 0;
}
#side-sortables .add-menu-item-tabs,
.wp-tab-bar {
margin-bottom: 3px;
@ -3053,7 +3046,7 @@ ul.add-menu-item-tabs li.tabs,
ul.category-tabs li,
ul.add-menu-item-tabs li,
ul.wp-tab-bar li {
padding: 5px;
padding: 3px 5px 5px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
@ -5071,7 +5064,7 @@ div.postbox div.inside {
position: absolute;
right: 30px;
padding: 0;
top: 8px;
top: 5px;
}
#dashboard-widgets h4 {
@ -6732,10 +6725,6 @@ h3.tb {
padding-top: 8px;
}
.press-this #category-adder h4 {
margin: 10px 0;
}
/* Tags */
.press-this .tagsdiv .newtag {
margin-right: 5px;
@ -7399,11 +7388,11 @@ a.widget-control-edit {
@media only screen and (min-width: 769px) {
/* categories */
#col-left {
width: 25%;
width: 35%;
}
#col-right {
width: 75%;
width: 65%;
}
}
@ -7411,11 +7400,11 @@ a.widget-control-edit {
/* categories */
#col-left {
width: 25%;
width: 35%;
}
#col-right {
width: 75%;
width: 65%;
}
}
@ -7423,11 +7412,11 @@ a.widget-control-edit {
/* categories */
#col-left {
width: 25%;
width: 35%;
}
#col-right {
width: 75%;
width: 65%;
}
}

View File

@ -48,40 +48,65 @@ var postboxes;
});
$('.columns-prefs input[type="radio"]').click(function(){
var num = $(this).val(), ps = $('#poststuff');
var num = $(this).val(), i, el, done, ps = $('#poststuff');
if ( num == 'auto' ) {
$(window).bind('resize.responsive', function(){ postboxes.auto_columns(); });
num = parseInt(num, 10);
if ( ps.length )
$('.wrap').removeClass('columns-1').removeClass('columns-2');
if ( ps.length ) { // edit pages
postboxes.auto_columns();
if ( num == 2 ) {
$('.wrap').removeClass('columns-1').addClass('columns-2');
ps.addClass('has-right-sidebar');
} else {
$(window).unbind('resize.responsive');
num = parseInt(num, 10);
if ( !$('#side-info-column #side-sortables').length )
$('#side-info-column').append( $('#side-sortables') );
if ( ps.length ) { // write pages
} else if ( num == 1 ) {
$('.wrap').removeClass('columns-2').addClass('columns-1');
ps.removeClass('has-right-sidebar');
if ( num == 2 ) {
$('.wrap').removeClass('columns-1').addClass('columns-2');
ps.addClass('has-right-sidebar');
if ( !$('#side-info-column #side-sortables').length )
$('#side-info-column').append( $('#side-sortables') );
} else if ( num == 1 ) {
$('.wrap').removeClass('columns-2').addClass('columns-1');
ps.removeClass('has-right-sidebar');
if ( !$('#post-body-content #side-sortables').length )
$('#normal-sortables').before( $('#side-sortables') );
}
} else { // dashboard
postboxes._dash_columns(num);
if ( !$('#post-body-content #side-sortables').length )
$('#normal-sortables').before( $('#side-sortables') );
}
} else { // dashboard
for ( i = 4; ( i > num && i > 1 ); i-- ) {
el = $('#' + postboxes._colname(i) + '-sortables');
$('#' + postboxes._colname(i-1) + '-sortables').append(el.children('.postbox'));
el.parent().hide();
}
for ( i = num; i > 0; i-- ) {
el = $('#' + postboxes._colname(i) + '-sortables');
done = false;
if ( el.parent().is(':hidden') ) {
switch ( i ) {
case 4:
if ( $('#column3-sortables .postbox').length > 1 ) {
el.append( $('#column3-sortables .postbox').last() );
done = true;
}
case 3:
if ( !done && $('#side-sortables .postbox').length > 1 ) {
el.append( $('#side-sortables .postbox').last() );
done = true;
}
case 2:
if ( !done && $('#normal-sortables .postbox').length > 1 ) {
el.append( $('#normal-sortables .postbox').last() );
done = true;
}
default:
if ( !done )
el.addClass('empty-container')
}
el.parent().show();
}
}
$('.postbox-container:visible').css('width', 100/num + '%');
}
postboxes.save_order(page);
});
@ -113,6 +138,15 @@ var postboxes;
receive: function(e,ui) {
if ( 'dashboard_browser_nag' == ui.item[0].id )
$(ui.sender).sortable('cancel');
$.each($('.postbox-container:visible'), function(n, el){
var first = $('.meta-box-sortables:first', el);
if ( !first.children('.postbox:visible').length )
first.addClass('empty-container');
else
first.removeClass('empty-container');
});
}
});
},
@ -144,73 +178,6 @@ var postboxes;
} );
$.post( ajaxurl, postVars );
},
auto_columns : function() { // responsive admin
var poststuff = $('#poststuff'), width;
if ( poststuff.length ) { // post-new, post, links, etc.
width = $('#post-body').width();
if ( width < 800 ) {
poststuff.removeClass('has-right-sidebar');
if ( !$('#post-body-content #side-sortables').length )
$('#normal-sortables').before( $('#side-sortables') );
} else {
poststuff.addClass('has-right-sidebar');
if ( !$('#side-info-column #side-sortables').length )
$('#side-info-column').append( $('#side-sortables') );
if ( width < 1150 )
$(document.body).removeClass('wide-window');
else
$(document.body).addClass('wide-window');
}
} else if ( $('#dashboard-widgets-wrap').length ) { // dashboard
width = $(window).width();
if ( width < 950 ) {
this._dash_columns(1)
} else if ( width < 1300 ) {
this._dash_columns(2)
} else if ( width < 1700 ) {
this._dash_columns(3)
} else {
this._dash_columns(4)
}
}
},
_dash_columns : function(n) {
switch (n) {
case 1:
$('#postbox-container-1').append( $('#side-sortables, #column3-sortables, #column4-sortables') );
$('#postbox-container-2, #postbox-container-3, #postbox-container-4').hide();
break
case 2:
$('#postbox-container-2').append( $('#side-sortables, #column3-sortables, #column4-sortables') ).show();
$('#postbox-container-3, #postbox-container-4').hide();
break
case 3:
$('#postbox-container-2').append( $('#side-sortables') ).show();
$('#postbox-container-3').append( $('#column3-sortables, #column4-sortables') ).show();
$('#postbox-container-4').hide();
break
case 4:
$('#postbox-container-2').append( $('#side-sortables') ).show();
$('#postbox-container-3').append( $('#column3-sortables') ).show();
$('#postbox-container-4').append( $('#column4-sortables') ).show();
break
default:
return;
}
$('.postbox-container:visible').css('width', 100/n + '%');
},
_colname : function(n) {
switch (n) {
@ -237,11 +204,4 @@ var postboxes;
pbhide : false
};
$(document).ready(function(){
if ( !$('#wp_auto_columns').length || $('#wp_auto_columns').prop('checked') ) {
$(window).bind('resize.responsive', function(){ postboxes.auto_columns(); });
postboxes.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 d=a(this).parent(".postbox"),e=d.attr("id");if("dashboard_browser_nag"==e){return}d.toggleClass("closed");postboxes.save_state(c);if(e){if(!d.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}else{if(d.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}}});a(".postbox h3 a").click(function(d){d.stopPropagation()});a(".postbox a.dismiss").click(function(f){var d=a(this).parents(".postbox").attr("id")+"-hide";a("#"+d).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var d=a(this).val();if(a(this).prop("checked")){a("#"+d).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(d)}}else{a("#"+d).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(d)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var d=a(this).val(),e=a("#poststuff");if(d=="auto"){a(window).bind("resize.responsive",function(){postboxes.auto_columns()});if(e.length){a(".wrap").removeClass("columns-1").removeClass("columns-2")}postboxes.auto_columns()}else{a(window).unbind("resize.responsive");d=parseInt(d,10);if(e.length){if(d==2){a(".wrap").removeClass("columns-1").addClass("columns-2");e.addClass("has-right-sidebar");if(!a("#side-info-column #side-sortables").length){a("#side-info-column").append(a("#side-sortables"))}}else{if(d==1){a(".wrap").removeClass("columns-2").addClass("columns-1");e.removeClass("has-right-sidebar");if(!a("#post-body-content #side-sortables").length){a("#normal-sortables").before(a("#side-sortables"))}}}}else{postboxes._dash_columns(d)}}postboxes.save_order(c)})},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)},auto_columns:function(){var b=a("#poststuff"),c;if(b.length){c=a("#post-body").width();if(c<800){b.removeClass("has-right-sidebar");if(!a("#post-body-content #side-sortables").length){a("#normal-sortables").before(a("#side-sortables"))}}else{b.addClass("has-right-sidebar");if(!a("#side-info-column #side-sortables").length){a("#side-info-column").append(a("#side-sortables"))}if(c<1150){a(document.body).removeClass("wide-window")}else{a(document.body).addClass("wide-window")}}}else{if(a("#dashboard-widgets-wrap").length){c=a(window).width();if(c<950){this._dash_columns(1)}else{if(c<1300){this._dash_columns(2)}else{if(c<1700){this._dash_columns(3)}else{this._dash_columns(4)}}}}}},_dash_columns:function(b){switch(b){case 1:a("#postbox-container-1").append(a("#side-sortables, #column3-sortables, #column4-sortables"));a("#postbox-container-2, #postbox-container-3, #postbox-container-4").hide();break;case 2:a("#postbox-container-2").append(a("#side-sortables, #column3-sortables, #column4-sortables")).show();a("#postbox-container-3, #postbox-container-4").hide();break;case 3:a("#postbox-container-2").append(a("#side-sortables")).show();a("#postbox-container-3").append(a("#column3-sortables, #column4-sortables")).show();a("#postbox-container-4").hide();break;case 4:a("#postbox-container-2").append(a("#side-sortables")).show();a("#postbox-container-3").append(a("#column3-sortables")).show();a("#postbox-container-4").append(a("#column4-sortables")).show();break;default:return}a(".postbox-container:visible").css("width",100/b+"%")},_colname:function(b){switch(b){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}},pbshow:false,pbhide:false};a(document).ready(function(){if(!a("#wp_auto_columns").length||a("#wp_auto_columns").prop("checked")){a(window).bind("resize.responsive",function(){postboxes.auto_columns()});postboxes.auto_columns()}})}(jQuery));
var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var d=a(this).parent(".postbox"),e=d.attr("id");if("dashboard_browser_nag"==e){return}d.toggleClass("closed");postboxes.save_state(c);if(e){if(!d.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}else{if(d.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}}});a(".postbox h3 a").click(function(d){d.stopPropagation()});a(".postbox a.dismiss").click(function(f){var d=a(this).parents(".postbox").attr("id")+"-hide";a("#"+d).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var d=a(this).val();if(a(this).prop("checked")){a("#"+d).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(d)}}else{a("#"+d).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(d)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,d,h=a("#poststuff");e=parseInt(e,10);if(h.length){if(e==2){a(".wrap").removeClass("columns-1").addClass("columns-2");h.addClass("has-right-sidebar");if(!a("#side-info-column #side-sortables").length){a("#side-info-column").append(a("#side-sortables"))}}else{if(e==1){a(".wrap").removeClass("columns-2").addClass("columns-1");h.removeClass("has-right-sidebar");if(!a("#post-body-content #side-sortables").length){a("#normal-sortables").before(a("#side-sortables"))}}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+postboxes._colname(f)+"-sortables");a("#"+postboxes._colname(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=e;f>0;f--){g=a("#"+postboxes._colname(f)+"-sortables");d=false;if(g.parent().is(":hidden")){switch(f){case 4:if(a("#column3-sortables .postbox").length>1){g.append(a("#column3-sortables .postbox").last());d=true}case 3:if(!d&&a("#side-sortables .postbox").length>1){g.append(a("#side-sortables .postbox").last());d=true}case 2:if(!d&&a("#normal-sortables .postbox").length>1){g.append(a("#normal-sortables .postbox").last());d=true}default:if(!d){g.addClass("empty-container")}}g.parent().show()}}a(".postbox-container:visible").css("width",100/e+"%")}postboxes.save_order(c)})},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")}a.each(a(".postbox-container:visible"),function(h,e){var g=a(".meta-box-sortables:first",e);if(!g.children(".postbox:visible").length){g.addClass("empty-container")}else{g.removeClass("empty-container")}})}})},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)},_colname:function(b){switch(b){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}},pbshow:false,pbhide:false}}(jQuery));

View File

@ -305,7 +305,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'), '20110920', 1 );
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20111005', 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524', 1 );
$scripts->add_script_data( 'post', 'postL10n', array(
@ -431,7 +431,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(), '20111005a' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20111005b' );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20110919' );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );