~katiekitty/+junk/wordpress-byet

« back to all changes in this revision

Viewing changes to wp-admin/js/common.dev.js

  • Committer: kserver
  • Date: 2010-05-15 01:16:36 UTC
  • Revision ID: kserver@kserver-desktop-20100515011636-mnr1j7t637suptdq
Wordpress 2.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
var showNotice, adminMenu, columns;
 
1
var showNotice, adminMenu, columns, validateForm;
2
2
(function($){
3
3
// sidebar admin menu
4
4
adminMenu = {
5
 
 
6
5
        init : function() {
7
 
                $('#adminmenu div.wp-menu-toggle').each( function() {
8
 
                        if ( $(this).siblings('.wp-submenu').length )
9
 
                                $(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
 
6
                var menu = $('#adminmenu');
 
7
 
 
8
                $('.wp-menu-toggle', menu).each( function() {
 
9
                        var t = $(this), sub = t.siblings('.wp-submenu');
 
10
                        if ( sub.length )
 
11
                                t.click(function(){ adminMenu.toggle( sub ); });
10
12
                        else
11
 
                                $(this).hide();
 
13
                                t.hide();
12
14
                });
13
15
 
14
16
                this.favorites();
15
17
 
16
 
                $('a.separator').click(function(){
 
18
                $('.separator', menu).click(function(){
17
19
                        if ( $('body').hasClass('folded') ) {
18
20
                                adminMenu.fold(1);
19
21
                                deleteUserSetting( 'mfold' );
24
26
                        return false;
25
27
                });
26
28
 
27
 
                if ( $('body').hasClass('folded') ) {
 
29
                if ( $('body').hasClass('folded') )
28
30
                        this.fold();
29
 
                }
 
31
 
30
32
                this.restoreMenuState();
31
33
        },
32
34
 
33
35
        restoreMenuState : function() {
34
 
                $('#adminmenu li.wp-has-submenu').each(function(i, e) {
 
36
                $('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
35
37
                        var v = getUserSetting( 'm'+i );
36
 
                        if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
 
38
                        if ( $(e).hasClass('wp-has-current-submenu') )
 
39
                                return true; // leave the current parent open
37
40
 
38
 
                        if ( 'o' == v ) $(e).addClass('wp-menu-open');
39
 
                        else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
 
41
                        if ( 'o' == v )
 
42
                                $(e).addClass('wp-menu-open');
 
43
                        else if ( 'c' == v )
 
44
                                $(e).removeClass('wp-menu-open');
40
45
                });
41
46
        },
42
47
 
43
48
        toggle : function(el) {
44
 
 
45
 
                el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
46
 
 
47
 
                $('#adminmenu li.wp-has-submenu').each(function(i, e) {
48
 
                        var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
49
 
                        setUserSetting( 'm'+i, v );
50
 
                });
 
49
                var id = el.slideToggle(150, function() {
 
50
                        el.css('display','');
 
51
                }).parent().toggleClass( 'wp-menu-open' ).attr('id');
 
52
 
 
53
                if ( id ) {
 
54
                        $('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
 
55
                                if ( id == e.id ) {
 
56
                                    var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
 
57
                                    setUserSetting( 'm'+i, v );
 
58
                                }
 
59
                        });
 
60
                }
51
61
 
52
62
                return false;
53
63
        },
62
72
                                over: function(e){
63
73
                                        var m, b, h, o, f;
64
74
                                        m = $(this).find('.wp-submenu');
65
 
                                        b = m.parent().offset().top + m.height() + 1; // Bottom offset of the menu
 
75
                                        b = $(this).offset().top + m.height() + 1; // Bottom offset of the menu
66
76
                                        h = $('#wpwrap').height(); // Height of the entire page
67
77
                                        o = 60 + b - h;
68
 
                                        f = $(window).height() + $('body').scrollTop() - 15; // The fold
69
 
                                        if (f < (b - o)) {
 
78
                                        f = $(window).height() + $(window).scrollTop() - 15; // The fold
 
79
                                        if ( f < (b - o) ) {
70
80
                                                o = b - f;
71
81
                                        }
72
 
                                        if (o > 1) {
 
82
                                        if ( o > 1 ) {
73
83
                                                m.css({'marginTop':'-'+o+'px'});
74
84
                                        } else if ( m.css('marginTop') ) {
75
85
                                                m.css({'marginTop':''});
86
96
        },
87
97
 
88
98
        favorites : function() {
89
 
                $('#favorite-inside').width($('#favorite-actions').width()-4);
90
 
                $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } );
91
 
 
92
 
                $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } );
 
99
                $('#favorite-inside').width( $('#favorite-actions').width() - 4 );
 
100
                $('#favorite-toggle, #favorite-inside').bind('mouseenter', function() {
 
101
                        $('#favorite-inside').removeClass('slideUp').addClass('slideDown');
 
102
                        setTimeout(function() {
 
103
                                if ( $('#favorite-inside').hasClass('slideDown') ) {
 
104
                                        $('#favorite-inside').slideDown(100);
 
105
                                        $('#favorite-first').addClass('slide-down');
 
106
                                }
 
107
                        }, 200);
 
108
                }).bind('mouseleave', function() {
 
109
                        $('#favorite-inside').removeClass('slideDown').addClass('slideUp');
 
110
                        setTimeout(function() {
 
111
                                if ( $('#favorite-inside').hasClass('slideUp') ) {
 
112
                                        $('#favorite-inside').slideUp(100, function() {
 
113
                                                $('#favorite-first').removeClass('slide-down');
 
114
                                        });
 
115
                                }
 
116
                        }, 300);
 
117
                });
93
118
        }
94
119
};
95
120
 
96
 
$(document).ready(function(){adminMenu.init();});
 
121
$(document).ready(function(){ adminMenu.init(); });
97
122
 
98
123
// show/hide/save table columns
99
124
columns = {
100
125
        init : function() {
101
 
                $('.hide-column-tog').click( function() {
102
 
                        var column = $(this).val(), show = $(this).attr('checked');
103
 
                        if ( show ) {
 
126
                $('.hide-column-tog', '#adv-settings').click( function() {
 
127
                        var column = $(this).val();
 
128
                        if ( $(this).attr('checked') )
104
129
                                $('.column-' + column).show();
105
 
                        } else {
 
130
                        else
106
131
                                $('.column-' + column).hide();
107
 
                        }
 
132
 
108
133
                        columns.save_manage_columns_state();
109
 
                } );
 
134
                });
110
135
        },
111
136
 
112
137
        save_manage_columns_state : function() {
122
147
 
123
148
$(document).ready(function(){columns.init();});
124
149
 
 
150
validateForm = function( form ) {
 
151
        return !$( form ).find('.form-required').filter( function() { return $('input:visible', this).val() == ''; } ).addClass( 'form-invalid' ).find('input:visible').change( function() { $(this).closest('.form-invalid').removeClass( 'form-invalid' ); } ).size();
 
152
}
 
153
 
125
154
})(jQuery);
126
155
 
127
156
// stub for doing better warnings
143
172
jQuery(document).ready( function($) {
144
173
        var lastClicked = false, checks, first, last, checked;
145
174
 
146
 
        // pulse
147
 
        $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
148
 
 
149
175
        // Move .updated and .error alert boxes
150
 
        $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
151
 
        $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
152
 
 
153
 
        // show warnings
154
 
        $('#doaction, #doaction2').click(function(){
155
 
                if ( $('select[name="action"]').val() == 'delete' || $('select[name="action2"]').val() == 'delete' ) {
156
 
                        return showNotice.warn();
157
 
                }
158
 
        });
 
176
        $('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
 
177
        $('div.updated, div.error').not('.below-h2').insertAfter( $('div.wrap h2:first') );
159
178
 
160
179
        // screen settings tab
161
180
        $('#show-settings-link').click(function () {
162
 
                if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
 
181
                if ( ! $('#screen-options-wrap').hasClass('screen-options-open') )
163
182
                        $('#contextual-help-link-wrap').css('visibility', 'hidden');
164
 
                }
 
183
 
165
184
                $('#screen-options-wrap').slideToggle('fast', function(){
166
185
                        if ( $(this).hasClass('screen-options-open') ) {
167
186
                                $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
177
196
 
178
197
        // help tab
179
198
        $('#contextual-help-link').click(function () {
180
 
                if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
 
199
                if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') )
181
200
                        $('#screen-options-link-wrap').css('visibility', 'hidden');
182
 
                }
183
 
                $('#contextual-help-wrap').slideToggle('fast', function(){
 
201
 
 
202
                $('#contextual-help-wrap').slideToggle('fast', function() {
184
203
                        if ( $(this).hasClass('contextual-help-open') ) {
185
204
                                $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
186
205
                                $('#screen-options-link-wrap').css('visibility', '');
192
211
                });
193
212
                return false;
194
213
        });
195
 
        $('#contextual-help-link-wrap, #screen-options-link-wrap').show();
196
214
 
197
215
        // check all checkboxes
198
 
        $( 'table:visible tbody .check-column :checkbox' ).click( function(e) {
 
216
        $('tbody').children().children('.check-column').find(':checkbox').click( function(e) {
199
217
                if ( 'undefined' == e.shiftKey ) { return true; }
200
218
                if ( e.shiftKey ) {
201
219
                        if ( !lastClicked ) { return true; }
202
 
                        checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
 
220
                        checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' );
203
221
                        first = checks.index( lastClicked );
204
222
                        last = checks.index( this );
205
223
                        checked = $(this).attr('checked');
206
224
                        if ( 0 < first && 0 < last && first != last ) {
207
225
                                checks.slice( first, last ).attr( 'checked', function(){
208
 
                                        if ( $(this).parents('tr').is(':visible') )
 
226
                                        if ( $(this).closest('tr').is(':visible') )
209
227
                                                return checked ? 'checked' : '';
210
228
 
211
229
                                        return '';
214
232
                }
215
233
                lastClicked = this;
216
234
                return true;
217
 
        } );
218
 
        $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) {
219
 
                var c = $(this).attr('checked'), kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard, toggle = e.shiftKey || kbtoggle;
220
 
 
221
 
 
222
 
                $(this).parents( 'form:first' ).find( 'table tbody:visible' ).find( '.check-column :checkbox' ).attr( 'checked', function() {
223
 
                        if ( $(this).parents('tr').is(':hidden') )
 
235
        });
 
236
 
 
237
        $('thead, tfoot').find(':checkbox').click( function(e) {
 
238
                var c = $(this).attr('checked'),
 
239
                        kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard,
 
240
                        toggle = e.shiftKey || kbtoggle;
 
241
 
 
242
                $(this).closest( 'table' ).children( 'tbody' ).filter(':visible')
 
243
                .children().children('.check-column').find(':checkbox')
 
244
                .attr('checked', function() {
 
245
                        if ( $(this).closest('tr').is(':hidden') )
224
246
                                return '';
225
247
                        if ( toggle )
226
248
                                return $(this).attr( 'checked' ) ? '' : 'checked';
228
250
                                return 'checked';
229
251
                        return '';
230
252
                });
231
 
                $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
 
253
 
 
254
                $(this).closest('table').children('thead,  tfoot').filter(':visible')
 
255
                .children().children('.check-column').find(':checkbox')
 
256
                .attr('checked', function() {
232
257
                        if ( toggle )
233
258
                                return '';
234
259
                        else if (c)
236
261
                        return '';
237
262
                });
238
263
        });
 
264
 
239
265
        $('#default-password-nag-no').click( function() {
240
266
                setUserSetting('default_password_nag', 'hide');
241
267
                $('div.default-password-nag').hide();
242
268
                return false;
243
269
        });
244
 
        
245
 
        
246
270
});
247
271
 
248
272
jQuery(document).ready( function($){
249
 
        var turboNag = $('.turbo-nag');
 
273
        var turboNag = $('span.turbo-nag', '#user_info');
250
274
 
251
275
        if ( !turboNag.length || ('undefined' != typeof(google) && google.gears) )
252
276
                return;
263
287
        }
264
288
 
265
289
        turboNag.show();
266
 
 
267
290
});