2009-07-01 04:12:39 -04:00
|
|
|
var showNotice, adminMenu, columns, validateForm;
|
2009-01-12 08:43:17 -05:00
|
|
|
(function($){
|
|
|
|
// sidebar admin menu
|
|
|
|
adminMenu = {
|
|
|
|
init : function() {
|
2009-08-18 05:53:37 -04:00
|
|
|
var menu = $('#adminmenu');
|
|
|
|
|
|
|
|
$('.wp-menu-toggle', menu).each( function() {
|
|
|
|
var t = $(this), sub = t.siblings('.wp-submenu');
|
|
|
|
if ( sub.length )
|
|
|
|
t.click(function(){ adminMenu.toggle( sub ); });
|
2009-01-12 08:43:17 -05:00
|
|
|
else
|
2009-08-18 05:53:37 -04:00
|
|
|
t.hide();
|
2009-01-12 08:43:17 -05:00
|
|
|
});
|
2009-12-09 06:27:47 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
this.favorites();
|
2009-12-09 06:27:47 -05:00
|
|
|
|
2009-08-18 05:53:37 -04:00
|
|
|
$('.separator', menu).click(function(){
|
2009-04-04 13:07:31 -04:00
|
|
|
if ( $('body').hasClass('folded') ) {
|
2009-01-12 08:43:17 -05:00
|
|
|
adminMenu.fold(1);
|
2009-04-29 01:43:03 -04:00
|
|
|
deleteUserSetting( 'mfold' );
|
2009-01-12 08:43:17 -05:00
|
|
|
} else {
|
|
|
|
adminMenu.fold();
|
|
|
|
setUserSetting( 'mfold', 'f' );
|
2009-01-02 10:08:58 -05:00
|
|
|
}
|
2009-04-29 01:43:03 -04:00
|
|
|
return false;
|
2009-01-12 08:43:17 -05:00
|
|
|
});
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-08-18 05:53:37 -04:00
|
|
|
if ( $('body').hasClass('folded') )
|
2009-01-12 08:43:17 -05:00
|
|
|
this.fold();
|
2009-01-02 10:08:58 -05:00
|
|
|
},
|
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
restoreMenuState : function() {
|
2011-04-07 14:45:22 -04:00
|
|
|
// (perhaps) needed for back-compat
|
2009-01-02 10:08:58 -05:00
|
|
|
},
|
|
|
|
|
2010-12-13 16:21:50 -05:00
|
|
|
toggle : function(el) {
|
2010-12-11 03:41:48 -05:00
|
|
|
el.slideToggle(150, function() {
|
2011-04-07 14:45:22 -04:00
|
|
|
var id = el.removeAttr('style').parent().toggleClass( 'wp-menu-open' ).attr('id');
|
2010-12-11 03:41:48 -05:00
|
|
|
if ( id ) {
|
|
|
|
$('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
|
|
|
|
if ( id == e.id ) {
|
2010-12-13 16:21:50 -05:00
|
|
|
var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
|
2010-12-11 03:41:48 -05:00
|
|
|
setUserSetting( 'm'+i, v );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
return false;
|
|
|
|
},
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
fold : function(off) {
|
|
|
|
if (off) {
|
2009-04-04 13:07:31 -04:00
|
|
|
$('body').removeClass('folded');
|
2009-01-12 08:43:17 -05:00
|
|
|
$('#adminmenu li.wp-has-submenu').unbind();
|
|
|
|
} else {
|
2009-04-04 13:07:31 -04:00
|
|
|
$('body').addClass('folded');
|
2009-01-12 08:43:17 -05:00
|
|
|
$('#adminmenu li.wp-has-submenu').hoverIntent({
|
|
|
|
over: function(e){
|
2009-05-29 03:42:55 -04:00
|
|
|
var m, b, h, o, f;
|
|
|
|
m = $(this).find('.wp-submenu');
|
2009-08-18 05:53:37 -04:00
|
|
|
b = $(this).offset().top + m.height() + 1; // Bottom offset of the menu
|
2009-05-29 03:42:55 -04:00
|
|
|
h = $('#wpwrap').height(); // Height of the entire page
|
|
|
|
o = 60 + b - h;
|
2009-08-18 05:53:37 -04:00
|
|
|
f = $(window).height() + $(window).scrollTop() - 15; // The fold
|
|
|
|
if ( f < (b - o) ) {
|
2009-05-29 03:42:55 -04:00
|
|
|
o = b - f;
|
|
|
|
}
|
2009-08-18 05:53:37 -04:00
|
|
|
if ( o > 1 ) {
|
2009-01-12 08:43:17 -05:00
|
|
|
m.css({'marginTop':'-'+o+'px'});
|
|
|
|
} else if ( m.css('marginTop') ) {
|
|
|
|
m.css({'marginTop':''});
|
|
|
|
}
|
|
|
|
m.addClass('sub-open');
|
|
|
|
},
|
|
|
|
out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
|
|
|
|
timeout: 220,
|
|
|
|
sensitivity: 8,
|
|
|
|
interval: 100
|
|
|
|
});
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
}
|
2009-01-02 10:08:58 -05:00
|
|
|
},
|
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
favorites : function() {
|
2009-08-18 05:53:37 -04:00
|
|
|
$('#favorite-inside').width( $('#favorite-actions').width() - 4 );
|
|
|
|
$('#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);
|
|
|
|
}).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);
|
|
|
|
});
|
2009-01-02 10:08:58 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-08-18 05:53:37 -04:00
|
|
|
$(document).ready(function(){ adminMenu.init(); });
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
// show/hide/save table columns
|
|
|
|
columns = {
|
|
|
|
init : function() {
|
2010-11-13 12:21:40 -05:00
|
|
|
var that = this;
|
2010-11-13 10:58:23 -05:00
|
|
|
$('.hide-column-tog', '#adv-settings').click( function() {
|
2010-11-13 12:21:40 -05:00
|
|
|
var $t = $(this), column = $t.val();
|
|
|
|
if ( $t.attr('checked') )
|
|
|
|
that.checked(column);
|
|
|
|
else
|
|
|
|
that.unchecked(column);
|
|
|
|
|
2010-04-28 23:43:11 -04:00
|
|
|
columns.saveManageColumnsState();
|
2009-08-18 05:53:37 -04:00
|
|
|
});
|
2009-01-12 08:43:17 -05:00
|
|
|
},
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2010-04-28 23:43:11 -04:00
|
|
|
saveManageColumnsState : function() {
|
|
|
|
var hidden = this.hidden();
|
2009-01-12 08:43:17 -05:00
|
|
|
$.post(ajaxurl, {
|
|
|
|
action: 'hidden-columns',
|
|
|
|
hidden: hidden,
|
2009-04-05 04:25:10 -04:00
|
|
|
screenoptionnonce: $('#screenoptionnonce').val(),
|
2009-01-12 08:43:17 -05:00
|
|
|
page: pagenow
|
|
|
|
});
|
2010-04-28 23:43:11 -04:00
|
|
|
},
|
2010-05-03 16:26:11 -04:00
|
|
|
|
2010-04-28 23:43:11 -04:00
|
|
|
checked : function(column) {
|
|
|
|
$('.column-' + column).show();
|
2010-11-14 13:00:09 -05:00
|
|
|
this.colSpanChange(+1);
|
2010-04-28 23:43:11 -04:00
|
|
|
},
|
2010-05-03 16:26:11 -04:00
|
|
|
|
2010-04-28 23:43:11 -04:00
|
|
|
unchecked : function(column) {
|
|
|
|
$('.column-' + column).hide();
|
2010-11-14 13:00:09 -05:00
|
|
|
this.colSpanChange(-1);
|
2010-04-28 23:43:11 -04:00
|
|
|
},
|
2010-05-03 16:26:11 -04:00
|
|
|
|
2010-04-28 23:43:11 -04:00
|
|
|
hidden : function() {
|
|
|
|
return $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
|
|
|
|
},
|
2010-05-03 16:26:11 -04:00
|
|
|
|
2010-04-28 23:43:11 -04:00
|
|
|
useCheckboxesForHidden : function() {
|
|
|
|
this.hidden = function(){
|
|
|
|
return $('.hide-column-tog').not(':checked').map(function() {
|
|
|
|
var id = this.id;
|
|
|
|
return id.substring( id, id.length - 5 );
|
|
|
|
}).get().join(',');
|
|
|
|
};
|
2010-11-14 13:00:09 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
colSpanChange : function(diff) {
|
2010-11-16 23:52:01 -05:00
|
|
|
var $t = $('table').find('.colspanchange'), n;
|
2010-11-14 13:00:09 -05:00
|
|
|
if ( !$t.length )
|
|
|
|
return;
|
2010-11-16 23:52:01 -05:00
|
|
|
n = parseInt( $t.attr('colspan'), 10 ) + diff;
|
2010-11-14 13:00:09 -05:00
|
|
|
$t.attr('colspan', n.toString());
|
2010-05-06 10:13:31 -04:00
|
|
|
}
|
2009-01-02 10:08:58 -05:00
|
|
|
}
|
2009-03-27 18:47:47 -04:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
$(document).ready(function(){columns.init();});
|
2009-03-27 18:47:47 -04:00
|
|
|
|
2009-07-01 04:12:39 -04:00
|
|
|
validateForm = function( form ) {
|
2009-11-19 05:24:14 -05:00
|
|
|
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();
|
2009-07-01 04:12:39 -04:00
|
|
|
}
|
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
})(jQuery);
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
// stub for doing better warnings
|
|
|
|
showNotice = {
|
|
|
|
warn : function() {
|
|
|
|
var msg = commonL10n.warnDelete || '';
|
|
|
|
if ( confirm(msg) ) {
|
|
|
|
return true;
|
|
|
|
}
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
return false;
|
|
|
|
},
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2009-01-12 08:43:17 -05:00
|
|
|
note : function(text) {
|
|
|
|
alert(text);
|
|
|
|
}
|
|
|
|
};
|
2009-01-02 10:08:58 -05:00
|
|
|
|
|
|
|
jQuery(document).ready( function($) {
|
2010-11-16 23:52:01 -05:00
|
|
|
var lastClicked = false, checks, first, last, checked, bgx = ( isRtl ? 'left' : 'right' );
|
2009-05-24 19:47:49 -04:00
|
|
|
|
2010-02-26 16:19:10 -05:00
|
|
|
// Move .updated and .error alert boxes. Don't move boxes designed to be inline.
|
2009-08-20 21:03:26 -04:00
|
|
|
$('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
|
2010-02-26 16:19:10 -05:00
|
|
|
$('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );
|
2009-01-02 10:08:58 -05:00
|
|
|
|
|
|
|
// screen settings tab
|
|
|
|
$('#show-settings-link').click(function () {
|
2009-08-18 05:53:37 -04:00
|
|
|
if ( ! $('#screen-options-wrap').hasClass('screen-options-open') )
|
2009-05-18 01:10:50 -04:00
|
|
|
$('#contextual-help-link-wrap').css('visibility', 'hidden');
|
2009-08-18 05:53:37 -04:00
|
|
|
|
2009-01-02 10:08:58 -05:00
|
|
|
$('#screen-options-wrap').slideToggle('fast', function(){
|
|
|
|
if ( $(this).hasClass('screen-options-open') ) {
|
2010-11-16 23:52:01 -05:00
|
|
|
$('#show-settings-link').css({'backgroundPosition':'top '+bgx});
|
2009-05-18 01:10:50 -04:00
|
|
|
$('#contextual-help-link-wrap').css('visibility', '');
|
2009-01-02 10:08:58 -05:00
|
|
|
$(this).removeClass('screen-options-open');
|
|
|
|
} else {
|
2010-11-16 23:52:01 -05:00
|
|
|
$('#show-settings-link').css({'backgroundPosition':'bottom '+bgx});
|
2009-01-02 10:08:58 -05:00
|
|
|
$(this).addClass('screen-options-open');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// help tab
|
|
|
|
$('#contextual-help-link').click(function () {
|
2009-08-18 05:53:37 -04:00
|
|
|
if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') )
|
2009-05-18 01:10:50 -04:00
|
|
|
$('#screen-options-link-wrap').css('visibility', 'hidden');
|
2009-08-18 05:53:37 -04:00
|
|
|
|
|
|
|
$('#contextual-help-wrap').slideToggle('fast', function() {
|
2009-01-02 10:08:58 -05:00
|
|
|
if ( $(this).hasClass('contextual-help-open') ) {
|
2010-11-16 23:52:01 -05:00
|
|
|
$('#contextual-help-link').css({'backgroundPosition':'top '+bgx});
|
2009-05-18 01:10:50 -04:00
|
|
|
$('#screen-options-link-wrap').css('visibility', '');
|
2009-01-02 10:08:58 -05:00
|
|
|
$(this).removeClass('contextual-help-open');
|
|
|
|
} else {
|
2010-11-16 23:52:01 -05:00
|
|
|
$('#contextual-help-link').css({'backgroundPosition':'bottom '+bgx});
|
2009-01-02 10:08:58 -05:00
|
|
|
$(this).addClass('contextual-help-open');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// check all checkboxes
|
2009-08-18 05:53:37 -04:00
|
|
|
$('tbody').children().children('.check-column').find(':checkbox').click( function(e) {
|
2009-01-02 10:08:58 -05:00
|
|
|
if ( 'undefined' == e.shiftKey ) { return true; }
|
|
|
|
if ( e.shiftKey ) {
|
|
|
|
if ( !lastClicked ) { return true; }
|
2009-08-18 05:53:37 -04:00
|
|
|
checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' );
|
2009-01-02 10:08:58 -05:00
|
|
|
first = checks.index( lastClicked );
|
|
|
|
last = checks.index( this );
|
|
|
|
checked = $(this).attr('checked');
|
|
|
|
if ( 0 < first && 0 < last && first != last ) {
|
|
|
|
checks.slice( first, last ).attr( 'checked', function(){
|
2009-08-18 05:53:37 -04:00
|
|
|
if ( $(this).closest('tr').is(':visible') )
|
2009-01-02 10:08:58 -05:00
|
|
|
return checked ? 'checked' : '';
|
|
|
|
|
|
|
|
return '';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastClicked = this;
|
|
|
|
return true;
|
2009-08-18 05:53:37 -04:00
|
|
|
});
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2010-10-07 05:53:37 -04:00
|
|
|
$('thead, tfoot').find('.check-column :checkbox').click( function(e) {
|
2009-08-18 05:53:37 -04:00
|
|
|
var c = $(this).attr('checked'),
|
|
|
|
kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard,
|
|
|
|
toggle = e.shiftKey || kbtoggle;
|
2009-12-09 06:27:47 -05:00
|
|
|
|
2009-08-18 05:53:37 -04:00
|
|
|
$(this).closest( 'table' ).children( 'tbody' ).filter(':visible')
|
|
|
|
.children().children('.check-column').find(':checkbox')
|
|
|
|
.attr('checked', function() {
|
|
|
|
if ( $(this).closest('tr').is(':hidden') )
|
2009-01-02 10:08:58 -05:00
|
|
|
return '';
|
|
|
|
if ( toggle )
|
|
|
|
return $(this).attr( 'checked' ) ? '' : 'checked';
|
|
|
|
else if (c)
|
|
|
|
return 'checked';
|
|
|
|
return '';
|
|
|
|
});
|
2009-08-18 05:53:37 -04:00
|
|
|
|
|
|
|
$(this).closest('table').children('thead, tfoot').filter(':visible')
|
|
|
|
.children().children('.check-column').find(':checkbox')
|
|
|
|
.attr('checked', function() {
|
2009-01-02 10:08:58 -05:00
|
|
|
if ( toggle )
|
|
|
|
return '';
|
|
|
|
else if (c)
|
|
|
|
return 'checked';
|
|
|
|
return '';
|
|
|
|
});
|
|
|
|
});
|
2009-08-18 05:53:37 -04:00
|
|
|
|
2009-05-03 13:06:29 -04:00
|
|
|
$('#default-password-nag-no').click( function() {
|
|
|
|
setUserSetting('default_password_nag', 'hide');
|
|
|
|
$('div.default-password-nag').hide();
|
|
|
|
return false;
|
|
|
|
});
|
2010-02-18 00:14:48 -05:00
|
|
|
|
|
|
|
// tab in textareas
|
2010-03-02 06:49:06 -05:00
|
|
|
$('#newcontent').keydown(function(e) {
|
2010-02-18 00:14:48 -05:00
|
|
|
if ( e.keyCode != 9 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
var el = e.target, selStart = el.selectionStart, selEnd = el.selectionEnd, val = el.value, scroll, sel;
|
|
|
|
|
2010-03-02 06:49:06 -05:00
|
|
|
try {
|
|
|
|
this.lastKey = 9; // not a standard DOM property, lastKey is to help stop Opera tab event. See blur handler below.
|
|
|
|
} catch(err) {}
|
2010-02-18 00:14:48 -05:00
|
|
|
|
|
|
|
if ( document.selection ) {
|
|
|
|
el.focus();
|
|
|
|
sel = document.selection.createRange();
|
|
|
|
sel.text = '\t';
|
|
|
|
} else if ( selStart >= 0 ) {
|
|
|
|
scroll = this.scrollTop;
|
|
|
|
el.value = val.substring(0, selStart).concat('\t', val.substring(selEnd) );
|
|
|
|
el.selectionStart = el.selectionEnd = selStart + 1;
|
|
|
|
this.scrollTop = scroll;
|
|
|
|
}
|
2010-03-17 12:27:25 -04:00
|
|
|
|
2010-03-02 06:49:06 -05:00
|
|
|
if ( e.stopPropagation )
|
|
|
|
e.stopPropagation();
|
|
|
|
if ( e.preventDefault )
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
2010-03-17 12:27:25 -04:00
|
|
|
|
2010-03-02 06:49:06 -05:00
|
|
|
$('#newcontent').blur(function(e) {
|
|
|
|
if ( this.lastKey && 9 == this.lastKey )
|
|
|
|
this.focus();
|
2010-02-18 00:14:48 -05:00
|
|
|
});
|
2010-10-07 05:53:37 -04:00
|
|
|
});
|