raw
mp-wp_genesis           1 (function($) {
mp-wp_genesis 2 postboxes = {
mp-wp_genesis 3 add_postbox_toggles : function(page,args) {
mp-wp_genesis 4 $('.postbox h3, .postbox .handlediv').click( function() {
mp-wp_genesis 5 $($(this).parent().get(0)).toggleClass('closed');
mp-wp_genesis 6 postboxes.save_state(page);
mp-wp_genesis 7 } );
mp-wp_genesis 8 $('.postbox h3 a').click( function(e) {
mp-wp_genesis 9 e.stopPropagation();
mp-wp_genesis 10 } );
mp-wp_genesis 11
mp-wp_genesis 12 $('.hide-postbox-tog').click( function() {
mp-wp_genesis 13 var box = jQuery(this).val();
mp-wp_genesis 14 if ( jQuery(this).attr('checked') ) {
mp-wp_genesis 15 jQuery('#' + box).show();
mp-wp_genesis 16 if ( $.isFunction( postboxes.pbshow ) )
mp-wp_genesis 17 postboxes.pbshow( box );
mp-wp_genesis 18
mp-wp_genesis 19 } else {
mp-wp_genesis 20 jQuery('#' + box).hide();
mp-wp_genesis 21 if ( $.isFunction( postboxes.pbhide ) )
mp-wp_genesis 22 postboxes.pbhide( box );
mp-wp_genesis 23
mp-wp_genesis 24 }
mp-wp_genesis 25 postboxes.save_state(page);
mp-wp_genesis 26 } );
mp-wp_genesis 27
mp-wp_genesis 28 this.expandSidebar();
mp-wp_genesis 29 this.init(page,args);
mp-wp_genesis 30 },
mp-wp_genesis 31
mp-wp_genesis 32 expandSidebar : function(doIt) {
mp-wp_genesis 33 if ( doIt || $('#side-sortables > .postbox:visible').length ) {
mp-wp_genesis 34 if ( ! $('#post-body').hasClass('has-sidebar') ) {
mp-wp_genesis 35 $('#post-body').addClass('has-sidebar');
mp-wp_genesis 36 var h = Math.min( $('#post-body').height(), 300 );
mp-wp_genesis 37 $('#side-sortables').css({'minHeight':h+'px','height':'auto'});
mp-wp_genesis 38 }
mp-wp_genesis 39 } else {
mp-wp_genesis 40 $('#post-body').removeClass('has-sidebar');
mp-wp_genesis 41 $('#side-sortables').css({'minHeight':'0'});
mp-wp_genesis 42 if ( $.browser.msie && $.browser.version.charAt(0) == 7 )
mp-wp_genesis 43 $('#side-sortables').css({'height':'0'});
mp-wp_genesis 44 }
mp-wp_genesis 45 },
mp-wp_genesis 46
mp-wp_genesis 47 init : function(page, args) {
mp-wp_genesis 48 $.extend( this, args || {} );
mp-wp_genesis 49 $('#wpbody-content').css('overflow','hidden');
mp-wp_genesis 50 $('.meta-box-sortables').sortable( {
mp-wp_genesis 51 placeholder: 'sortable-placeholder',
mp-wp_genesis 52 connectWith: [ '.meta-box-sortables' ],
mp-wp_genesis 53 items: '> .postbox',
mp-wp_genesis 54 handle: '.hndle',
mp-wp_genesis 55 distance: 2,
mp-wp_genesis 56 tolerance: 'pointer',
mp-wp_genesis 57 toleranceMove: 'tolerance',
mp-wp_genesis 58 sort: function(e,ui) {
mp-wp_genesis 59 if ( $(document).width() - e.clientX < 300 ) {
mp-wp_genesis 60 if ( ! $('#post-body').hasClass('has-sidebar') ) {
mp-wp_genesis 61 var pos = $('#side-sortables').offset();
mp-wp_genesis 62
mp-wp_genesis 63 $('#side-sortables').append(ui.item)
mp-wp_genesis 64 $(ui.placeholder).css({'top':pos.top,'left':pos.left}).width($(ui.item).width())
mp-wp_genesis 65 postboxes.expandSidebar(1);
mp-wp_genesis 66 }
mp-wp_genesis 67 }
mp-wp_genesis 68 },
mp-wp_genesis 69 stop: function() {
mp-wp_genesis 70 var postVars = {
mp-wp_genesis 71 action: 'meta-box-order',
mp-wp_genesis 72 _ajax_nonce: $('#meta-box-order-nonce').val(),
mp-wp_genesis 73 page: page
mp-wp_genesis 74 }
mp-wp_genesis 75 $('.meta-box-sortables').each( function() {
mp-wp_genesis 76 postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(',');
mp-wp_genesis 77 } );
mp-wp_genesis 78 $.post( postboxL10n.requestFile, postVars, function() {
mp-wp_genesis 79 postboxes.expandSidebar();
mp-wp_genesis 80 } );
mp-wp_genesis 81 }
mp-wp_genesis 82 } );
mp-wp_genesis 83 },
mp-wp_genesis 84
mp-wp_genesis 85 save_state : function(page) {
mp-wp_genesis 86 var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
mp-wp_genesis 87 var hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
mp-wp_genesis 88 $.post(postboxL10n.requestFile, {
mp-wp_genesis 89 action: 'closed-postboxes',
mp-wp_genesis 90 closed: closed,
mp-wp_genesis 91 hidden: hidden,
mp-wp_genesis 92 closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
mp-wp_genesis 93 page: page
mp-wp_genesis 94 });
mp-wp_genesis 95 postboxes.expandSidebar();
mp-wp_genesis 96 },
mp-wp_genesis 97
mp-wp_genesis 98 /* Callbacks */
mp-wp_genesis 99 pbshow : false,
mp-wp_genesis 100
mp-wp_genesis 101 pbhide : false
mp-wp_genesis 102 };
mp-wp_genesis 103
mp-wp_genesis 104 }(jQuery));