Make WordPress Core

Ticket #21042: my-script-2.js

File my-script-2.js, 1.2 KB (added by azaozz, 13 years ago)
Line 
1/**
2 * Example for column switching for plugins that have copied it from the Edit Post screen in WordPress version < 3.4.
3 *
4 * This script needs to be enqueued with dependency on 'postbox' and only for your plugin's page.
5 * Example:
6 * wp_enqueue_script( 'my-script', plugins_url( 'js/my-script.js', __file__ ), array('postbox'), '123', true );
7 */
8
9jQuery(document).ready(function($){
10        $('.columns-prefs input[type="radio"]').unbind('click.postboxes').bind('click.myscript', function(){
11                var n = parseInt($(this).val(), ps = $('#poststuff'), visible = $('.postbox-container:visible').length;
12
13                if ( n && n != visible ) {
14                        if ( n == 2 ) {
15                                $('.wrap').removeClass('columns-1').addClass('columns-2');
16                                ps.addClass('has-right-sidebar');
17
18                                if ( !$('#side-info-column #side-sortables').length )
19                                        $('#side-info-column').append( $('#side-sortables') );
20
21                        } else if ( n == 1 ) {
22                                $('.wrap').removeClass('columns-2').addClass('columns-1');
23                                ps.removeClass('has-right-sidebar');
24
25                                if ( !$('#post-body-content #side-sortables').length )
26                                        $('#normal-sortables').before( $('#side-sortables') );
27                        }
28
29                        postboxes.save_order('my-plugins-page');
30                }
31        });
32});
33