2008-08-20 23:42:31 +02:00
|
|
|
(function($) {
|
|
|
|
postboxes = {
|
2008-10-09 01:32:34 +02:00
|
|
|
add_postbox_toggles : function(page,args) {
|
2008-10-21 06:55:38 +02:00
|
|
|
$('.postbox h3').click( function() {
|
2008-09-14 14:58:00 +02:00
|
|
|
$($(this).parent().get(0)).toggleClass('closed');
|
|
|
|
postboxes.save_state(page);
|
2008-10-22 08:52:06 +02:00
|
|
|
} );
|
2008-10-09 01:32:34 +02:00
|
|
|
$('.postbox h3 a').click( function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
} );
|
2008-08-20 23:42:31 +02:00
|
|
|
|
2008-10-22 08:52:06 +02:00
|
|
|
$('.hide-postbox-tog').click( function() {
|
|
|
|
var box = jQuery(this).val();
|
|
|
|
if ( jQuery(this).attr('checked') ) {
|
|
|
|
jQuery('#' + box).show();
|
|
|
|
if ( $.isFunction( postboxes.onShow ) ) {
|
|
|
|
postboxes.onShow( box );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
jQuery('#' + box).hide();
|
|
|
|
}
|
|
|
|
postboxes.save_state(page);
|
|
|
|
} );
|
|
|
|
|
2008-10-23 00:08:58 +02:00
|
|
|
this.makeItTall();
|
2008-10-09 01:32:34 +02:00
|
|
|
this.init(page,args);
|
2008-08-20 23:42:31 +02:00
|
|
|
},
|
2008-10-23 00:08:58 +02:00
|
|
|
|
|
|
|
makeItTall : function() {
|
|
|
|
var t = $('#make-it-tall').remove();
|
|
|
|
|
|
|
|
if ( t.length < 1 )
|
|
|
|
t = $.browser.mozilla ? '<div id="make-it-tall" style="margin-bottom: -2000px; padding-bottom: 2001px"></div>' : '<div id="make-it-tall"> <br /> <br /></div>';
|
|
|
|
|
|
|
|
$('#side-sortables').append(t);
|
|
|
|
|
|
|
|
if ( $('#side-sortables').children().length > 1 )
|
|
|
|
$('#side-sortables').css({'minHeight':'300px'});
|
|
|
|
|
|
|
|
$('#wpbody-content').css( 'overflow', 'hidden' );
|
|
|
|
},
|
2008-09-14 14:58:00 +02:00
|
|
|
|
2008-08-20 23:42:31 +02:00
|
|
|
expandSidebar : function( doIt ) {
|
|
|
|
if ( doIt || $.trim( $( '#side-info-column' ).text() ) ) {
|
|
|
|
$( '#post-body' ).addClass( 'has-sidebar' );
|
|
|
|
$( '#side-sortables' ).css('z-index','0');
|
|
|
|
} else {
|
|
|
|
$( '#post-body' ).removeClass( 'has-sidebar' );
|
|
|
|
$( '#side-sortables' ).css('z-index','-1');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-10-09 01:32:34 +02:00
|
|
|
init : function(page,args) {
|
|
|
|
$.extend( this, args || {} );
|
2008-08-20 23:42:31 +02:00
|
|
|
jQuery('.meta-box-sortables').sortable( {
|
2008-10-22 00:06:41 +02:00
|
|
|
placeholder: 'sortable-placeholder',
|
2008-08-20 23:42:31 +02:00
|
|
|
connectWith: [ '.meta-box-sortables' ],
|
|
|
|
items: '> .postbox',
|
2008-09-11 23:40:28 +02:00
|
|
|
handle: '.hndle',
|
|
|
|
distance: 2,
|
2008-10-23 00:08:58 +02:00
|
|
|
tolerance: 'pointer',
|
|
|
|
receive: function() {
|
|
|
|
postboxes.makeItTall();
|
|
|
|
},
|
2008-08-20 23:42:31 +02:00
|
|
|
stop: function() {
|
2008-10-23 00:08:58 +02:00
|
|
|
if ( $('#side-sortables').children().length < 2 )
|
|
|
|
$('#side-sortables').css({'minHeight':''});
|
|
|
|
|
2008-08-20 23:42:31 +02:00
|
|
|
var postVars = {
|
|
|
|
action: 'meta-box-order',
|
|
|
|
_ajax_nonce: jQuery('#meta-box-order-nonce').val(),
|
|
|
|
page: page
|
|
|
|
}
|
|
|
|
jQuery('.meta-box-sortables').each( function() {
|
|
|
|
postVars["order[" + this.id.split('-')[0] + "]"] = jQuery(this).sortable( 'toArray' ).join(',');
|
|
|
|
} );
|
|
|
|
jQuery.post( postboxL10n.requestFile, postVars, function() {
|
|
|
|
postboxes.expandSidebar();
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
over: function(e, ui) {
|
|
|
|
if ( !ui.element.is( '#side-sortables' ) )
|
|
|
|
return;
|
|
|
|
postboxes.expandSidebar( true );
|
|
|
|
}
|
|
|
|
} );
|
2008-09-14 14:58:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
save_state : function(page) {
|
|
|
|
var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
|
|
|
|
var hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
|
|
|
|
$.post(postboxL10n.requestFile, {
|
|
|
|
action: 'closed-postboxes',
|
|
|
|
closed: closed,
|
|
|
|
hidden: hidden,
|
|
|
|
closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
|
|
|
|
page: page
|
|
|
|
});
|
2008-10-09 01:32:34 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Callbacks */
|
|
|
|
onShow : false
|
2008-09-14 14:58:00 +02:00
|
|
|
};
|
2008-08-20 23:42:31 +02:00
|
|
|
|
2008-09-14 14:58:00 +02:00
|
|
|
$(document).ready(function(){postboxes.expandSidebar();});
|
2008-01-28 22:34:42 +01:00
|
|
|
|
2008-09-14 14:58:00 +02:00
|
|
|
}(jQuery));
|