5 add_postbox_toggles : function(page, args) {
10 $('.postbox h3, .postbox .handlediv').bind('click.postboxes', function() {
11 var p = $(this).parent('.postbox'), id = p.attr('id');
13 if ( 'dashboard_browser_nag' == id )
16 p.toggleClass('closed');
18 if ( page != 'press-this' )
19 self.save_state(page);
22 if ( !p.hasClass('closed') && $.isFunction(postboxes.pbshow) )
24 else if ( p.hasClass('closed') && $.isFunction(postboxes.pbhide) )
29 $('.postbox h3 a').click( function(e) {
33 $('.postbox a.dismiss').bind('click.postboxes', function(e) {
34 var hide_id = $(this).parents('.postbox').attr('id') + '-hide';
35 $( '#' + hide_id ).prop('checked', false).triggerHandler('click');
39 $('.hide-postbox-tog').bind('click.postboxes', function() {
40 var box = $(this).val();
42 if ( $(this).prop('checked') ) {
44 if ( $.isFunction( postboxes.pbshow ) )
48 if ( $.isFunction( postboxes.pbhide ) )
51 self.save_state(page);
55 $('.columns-prefs input[type="radio"]').bind('click.postboxes', function(){
56 var n = parseInt($(this).val(), 10);
60 self.save_order(page);
65 init : function(page, args) {
66 var isMobile = $(document.body).hasClass('mobile');
68 $.extend( this, args || {} );
69 $('#wpbody-content').css('overflow','hidden');
70 $('.meta-box-sortables').sortable({
71 placeholder: 'sortable-placeholder',
72 connectWith: '.meta-box-sortables',
76 delay: ( isMobile ? 200 : 0 ),
79 forcePlaceholderSize: true,
82 stop: function(e,ui) {
83 if ( $(this).find('#dashboard_browser_nag').is(':visible') && 'dashboard_browser_nag' != this.firstChild.id ) {
84 $(this).sortable('cancel');
88 postboxes.save_order(page);
90 receive: function(e,ui) {
91 if ( 'dashboard_browser_nag' == ui.item[0].id )
92 $(ui.sender).sortable('cancel');
94 postboxes._mark_area();
99 $(document.body).bind('orientationchange.postboxes', function(){ postboxes._pb_change(); });
106 save_state : function(page) {
107 var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','),
108 hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
111 action: 'closed-postboxes',
114 closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
119 save_order : function(page) {
120 var postVars, page_columns = $('.columns-prefs input:checked').val() || 0;
123 action: 'meta-box-order',
124 _ajax_nonce: $('#meta-box-order-nonce').val(),
125 page_columns: page_columns,
128 $('.meta-box-sortables').each( function() {
129 postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(',');
131 $.post( ajaxurl, postVars );
134 _mark_area : function() {
135 var visible = $('div.postbox:visible').length, side = $('#post-body #side-sortables');
137 $('#dashboard-widgets .meta-box-sortables:visible').each(function(n, el){
140 if ( visible == 1 || t.children('.postbox:visible').length )
141 t.removeClass('empty-container');
143 t.addClass('empty-container');
147 if ( side.children('.postbox:visible').length )
148 side.removeClass('empty-container');
149 else if ( $('#postbox-container-1').css('width') == '280px' )
150 side.addClass('empty-container');
154 _pb_edit : function(n) {
155 var el = $('.metabox-holder').get(0);
156 el.className = el.className.replace(/columns-\d+/, 'columns-' + n);
159 _pb_change : function() {
160 var check = $( 'label.columns-prefs-1 input[type="radio"]' );
162 switch ( window.orientation ) {
165 if ( !check.length || !check.is(':checked') )
170 if ( $('#poststuff').length ) {
173 if ( !check.length || !check.is(':checked') )