7 add_postbox_toggles : function(page, args) {
10 self.init(page, args);
12 $('.postbox h3, .postbox .handlediv').bind('click.postboxes', function() {
13 var p = $(this).parent('.postbox'), id = p.attr('id');
15 if ( 'dashboard_browser_nag' == id )
18 p.toggleClass('closed');
20 if ( page != 'press-this' )
21 self.save_state(page);
24 if ( !p.hasClass('closed') && $.isFunction(postboxes.pbshow) )
26 else if ( p.hasClass('closed') && $.isFunction(postboxes.pbhide) )
31 $('.postbox h3 a').click( function(e) {
35 $( '.postbox a.dismiss' ).bind( 'click.postboxes', function() {
36 var hide_id = $(this).parents('.postbox').attr('id') + '-hide';
37 $( '#' + hide_id ).prop('checked', false).triggerHandler('click');
41 $('.hide-postbox-tog').bind('click.postboxes', function() {
42 var box = $(this).val();
44 if ( $(this).prop('checked') ) {
46 if ( $.isFunction( postboxes.pbshow ) )
50 if ( $.isFunction( postboxes.pbhide ) )
53 self.save_state(page);
57 $('.columns-prefs input[type="radio"]').bind('click.postboxes', function(){
58 var n = parseInt($(this).val(), 10);
62 self.save_order(page);
67 init : function(page, args) {
68 var isMobile = $(document.body).hasClass('mobile');
70 $.extend( this, args || {} );
71 $('#wpbody-content').css('overflow','hidden');
72 $('.meta-box-sortables').sortable({
73 placeholder: 'sortable-placeholder',
74 connectWith: '.meta-box-sortables',
78 delay: ( isMobile ? 200 : 0 ),
81 forcePlaceholderSize: true,
85 if ( $(this).find('#dashboard_browser_nag').is(':visible') && 'dashboard_browser_nag' != this.firstChild.id ) {
86 $(this).sortable('cancel');
90 postboxes.save_order(page);
92 receive: function(e,ui) {
93 if ( 'dashboard_browser_nag' == ui.item[0].id )
94 $(ui.sender).sortable('cancel');
96 postboxes._mark_area();
101 $(document.body).bind('orientationchange.postboxes', function(){ postboxes._pb_change(); });
108 save_state : function(page) {
109 var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','),
110 hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
113 action: 'closed-postboxes',
116 closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
121 save_order : function(page) {
122 var postVars, page_columns = $('.columns-prefs input:checked').val() || 0;
125 action: 'meta-box-order',
126 _ajax_nonce: $('#meta-box-order-nonce').val(),
127 page_columns: page_columns,
130 $('.meta-box-sortables').each( function() {
131 postVars[ 'order[' + this.id.split( '-' )[0] + ']' ] = $( this ).sortable( 'toArray' ).join( ',' );
133 $.post( ajaxurl, postVars );
136 _mark_area : function() {
137 var visible = $('div.postbox:visible').length, side = $('#post-body #side-sortables');
139 $( '#dashboard-widgets .meta-box-sortables:visible' ).each( function() {
142 if ( visible == 1 || t.children('.postbox:visible').length )
143 t.removeClass('empty-container');
145 t.addClass('empty-container');
149 if ( side.children('.postbox:visible').length )
150 side.removeClass('empty-container');
151 else if ( $('#postbox-container-1').css('width') == '280px' )
152 side.addClass('empty-container');
156 _pb_edit : function(n) {
157 var el = $('.metabox-holder').get(0);
160 el.className = el.className.replace(/columns-\d+/, 'columns-' + n);
164 _pb_change : function() {
165 var check = $( 'label.columns-prefs-1 input[type="radio"]' );
167 switch ( window.orientation ) {
170 if ( !check.length || !check.is(':checked') )
175 if ( $('#poststuff').length ) {
178 if ( !check.length || !check.is(':checked') )