3 add_postbox_toggles : function(page,args) {
4 $('.postbox h3, .postbox .handlediv').click( function() {
5 $($(this).parent().get(0)).toggleClass('closed');
6 postboxes.save_state(page);
8 $('.postbox h3 a').click( function(e) {
12 $('.hide-postbox-tog').click( function() {
13 var box = jQuery(this).val();
14 if ( jQuery(this).attr('checked') ) {
15 jQuery('#' + box).show();
16 if ( $.isFunction( postboxes.pbshow ) )
17 postboxes.pbshow( box );
20 jQuery('#' + box).hide();
21 if ( $.isFunction( postboxes.pbhide ) )
22 postboxes.pbhide( box );
25 postboxes.save_state(page);
32 expandSidebar : function(doIt) {
33 if ( doIt || $('#side-sortables > .postbox:visible').length ) {
34 if ( ! $('#post-body').hasClass('has-sidebar') ) {
35 $('#post-body').addClass('has-sidebar');
36 var h = Math.min( $('#post-body').height(), 300 );
37 $('#side-sortables').css({'minHeight':h+'px','height':'auto'});
40 $('#post-body').removeClass('has-sidebar');
41 $('#side-sortables').css({'minHeight':'0'});
42 if ( $.browser.msie && $.browser.version.charAt(0) == 7 )
43 $('#side-sortables').css({'height':'0'});
47 init : function(page, args) {
48 $.extend( this, args || {} );
49 $('#wpbody-content').css('overflow','hidden');
50 $('.meta-box-sortables').sortable( {
51 placeholder: 'sortable-placeholder',
52 connectWith: [ '.meta-box-sortables' ],
57 toleranceMove: 'tolerance',
58 sort: function(e,ui) {
59 if ( $(document).width() - e.clientX < 300 ) {
60 if ( ! $('#post-body').hasClass('has-sidebar') ) {
61 var pos = $('#side-sortables').offset();
63 $('#side-sortables').append(ui.item)
64 $(ui.placeholder).css({'top':pos.top,'left':pos.left}).width($(ui.item).width())
65 postboxes.expandSidebar(1);
71 action: 'meta-box-order',
72 _ajax_nonce: $('#meta-box-order-nonce').val(),
75 $('.meta-box-sortables').each( function() {
76 postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(',');
78 $.post( postboxL10n.requestFile, postVars, function() {
79 postboxes.expandSidebar();
85 save_state : function(page) {
86 var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
87 var hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
88 $.post(postboxL10n.requestFile, {
89 action: 'closed-postboxes',
92 closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
95 postboxes.expandSidebar();