1 var showNotice, adminMenu, columns, validateForm;
6 var menu = $('#adminmenu');
8 $('.wp-menu-toggle', menu).each( function() {
9 var t = $(this), sub = t.siblings('.wp-submenu');
11 t.click(function(){ adminMenu.toggle( sub ); });
18 $('.separator', menu).click(function(){
19 if ( $('body').hasClass('folded') ) {
21 deleteUserSetting( 'mfold' );
24 setUserSetting( 'mfold', 'f' );
29 if ( $('body').hasClass('folded') )
32 this.restoreMenuState();
35 restoreMenuState : function() {
36 $('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
37 var v = getUserSetting( 'm'+i );
38 if ( $(e).hasClass('wp-has-current-submenu') )
39 return true; // leave the current parent open
42 $(e).addClass('wp-menu-open');
44 $(e).removeClass('wp-menu-open');
48 toggle : function(el) {
49 el.slideToggle(150, function() {
50 var id = el.parent().toggleClass( 'wp-menu-open' ).attr('id');
52 $('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
54 var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
55 setUserSetting( 'm'+i, v );
64 fold : function(off) {
66 $('body').removeClass('folded');
67 $('#adminmenu li.wp-has-submenu').unbind();
69 $('body').addClass('folded');
70 $('#adminmenu li.wp-has-submenu').hoverIntent({
73 m = $(this).find('.wp-submenu');
74 b = $(this).offset().top + m.height() + 1; // Bottom offset of the menu
75 h = $('#wpwrap').height(); // Height of the entire page
77 f = $(window).height() + $(window).scrollTop() - 15; // The fold
82 m.css({'marginTop':'-'+o+'px'});
83 } else if ( m.css('marginTop') ) {
84 m.css({'marginTop':''});
86 m.addClass('sub-open');
88 out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
97 favorites : function() {
98 $('#favorite-inside').width( $('#favorite-actions').width() - 4 );
99 $('#favorite-toggle, #favorite-inside').bind('mouseenter', function() {
100 $('#favorite-inside').removeClass('slideUp').addClass('slideDown');
101 setTimeout(function() {
102 if ( $('#favorite-inside').hasClass('slideDown') ) {
103 $('#favorite-inside').slideDown(100);
104 $('#favorite-first').addClass('slide-down');
107 }).bind('mouseleave', function() {
108 $('#favorite-inside').removeClass('slideDown').addClass('slideUp');
109 setTimeout(function() {
110 if ( $('#favorite-inside').hasClass('slideUp') ) {
111 $('#favorite-inside').slideUp(100, function() {
112 $('#favorite-first').removeClass('slide-down');
120 $(document).ready(function(){ adminMenu.init(); });
122 // show/hide/save table columns
126 $('.hide-column-tog', '#adv-settings').click( function() {
127 var $t = $(this), column = $t.val();
128 if ( $t.attr('checked') )
129 that.checked(column);
131 that.unchecked(column);
133 columns.saveManageColumnsState();
137 saveManageColumnsState : function() {
138 var hidden = this.hidden();
140 action: 'hidden-columns',
142 screenoptionnonce: $('#screenoptionnonce').val(),
147 checked : function(column) {
148 $('.column-' + column).show();
149 this.colSpanChange(+1);
152 unchecked : function(column) {
153 $('.column-' + column).hide();
154 this.colSpanChange(-1);
157 hidden : function() {
158 return $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
161 useCheckboxesForHidden : function() {
162 this.hidden = function(){
163 return $('.hide-column-tog').not(':checked').map(function() {
165 return id.substring( id, id.length - 5 );
170 colSpanChange : function(diff) {
171 var $t = $('table').find('.colspanchange'), n;
174 n = parseInt( $t.attr('colspan'), 10 ) + diff;
175 $t.attr('colspan', n.toString());
179 $(document).ready(function(){columns.init();});
181 validateForm = function( form ) {
182 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();
187 // stub for doing better warnings
190 var msg = commonL10n.warnDelete || '';
191 if ( confirm(msg) ) {
198 note : function(text) {
203 jQuery(document).ready( function($) {
204 var lastClicked = false, checks, first, last, checked, bgx = ( isRtl ? 'left' : 'right' );
206 // Move .updated and .error alert boxes. Don't move boxes designed to be inline.
207 $('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
208 $('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );
210 // screen settings tab
211 $('#show-settings-link').click(function () {
212 if ( ! $('#screen-options-wrap').hasClass('screen-options-open') )
213 $('#contextual-help-link-wrap').css('visibility', 'hidden');
215 $('#screen-options-wrap').slideToggle('fast', function(){
216 if ( $(this).hasClass('screen-options-open') ) {
217 $('#show-settings-link').css({'backgroundPosition':'top '+bgx});
218 $('#contextual-help-link-wrap').css('visibility', '');
219 $(this).removeClass('screen-options-open');
221 $('#show-settings-link').css({'backgroundPosition':'bottom '+bgx});
222 $(this).addClass('screen-options-open');
229 $('#contextual-help-link').click(function () {
230 if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') )
231 $('#screen-options-link-wrap').css('visibility', 'hidden');
233 $('#contextual-help-wrap').slideToggle('fast', function() {
234 if ( $(this).hasClass('contextual-help-open') ) {
235 $('#contextual-help-link').css({'backgroundPosition':'top '+bgx});
236 $('#screen-options-link-wrap').css('visibility', '');
237 $(this).removeClass('contextual-help-open');
239 $('#contextual-help-link').css({'backgroundPosition':'bottom '+bgx});
240 $(this).addClass('contextual-help-open');
246 // check all checkboxes
247 $('tbody').children().children('.check-column').find(':checkbox').click( function(e) {
248 if ( 'undefined' == e.shiftKey ) { return true; }
250 if ( !lastClicked ) { return true; }
251 checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' );
252 first = checks.index( lastClicked );
253 last = checks.index( this );
254 checked = $(this).attr('checked');
255 if ( 0 < first && 0 < last && first != last ) {
256 checks.slice( first, last ).attr( 'checked', function(){
257 if ( $(this).closest('tr').is(':visible') )
258 return checked ? 'checked' : '';
268 $('thead, tfoot').find('.check-column :checkbox').click( function(e) {
269 var c = $(this).attr('checked'),
270 kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard,
271 toggle = e.shiftKey || kbtoggle;
273 $(this).closest( 'table' ).children( 'tbody' ).filter(':visible')
274 .children().children('.check-column').find(':checkbox')
275 .attr('checked', function() {
276 if ( $(this).closest('tr').is(':hidden') )
279 return $(this).attr( 'checked' ) ? '' : 'checked';
285 $(this).closest('table').children('thead, tfoot').filter(':visible')
286 .children().children('.check-column').find(':checkbox')
287 .attr('checked', function() {
296 $('#default-password-nag-no').click( function() {
297 setUserSetting('default_password_nag', 'hide');
298 $('div.default-password-nag').hide();
303 $('#newcontent').keydown(function(e) {
304 if ( e.keyCode != 9 )
307 var el = e.target, selStart = el.selectionStart, selEnd = el.selectionEnd, val = el.value, scroll, sel;
310 this.lastKey = 9; // not a standard DOM property, lastKey is to help stop Opera tab event. See blur handler below.
313 if ( document.selection ) {
315 sel = document.selection.createRange();
317 } else if ( selStart >= 0 ) {
318 scroll = this.scrollTop;
319 el.value = val.substring(0, selStart).concat('\t', val.substring(selEnd) );
320 el.selectionStart = el.selectionEnd = selStart + 1;
321 this.scrollTop = scroll;
324 if ( e.stopPropagation )
326 if ( e.preventDefault )
330 $('#newcontent').blur(function(e) {
331 if ( this.lastKey && 9 == this.lastKey )