2012-05-27 03:56:40 -04:00
|
|
|
var showNotice, adminMenu, columns, validateForm, screenMeta;
|
2009-01-12 08:43:17 -05:00
|
|
|
(function($){
|
2011-10-06 05:18:56 -04:00
|
|
|
// Removed in 3.3.
|
|
|
|
// (perhaps) needed for back-compat
|
2009-01-12 08:43:17 -05:00
|
|
|
adminMenu = {
|
2011-10-06 05:18:56 -04:00
|
|
|
init : function() {},
|
|
|
|
fold : function() {},
|
|
|
|
restoreMenuState : function() {},
|
|
|
|
toggle : function() {},
|
|
|
|
favorites : function() {}
|
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();
|
2011-05-24 21:04:12 -04:00
|
|
|
if ( $t.prop('checked') )
|
2010-11-13 12:21:40 -05:00
|
|
|
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
|
|
|
// 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
|
|
|
|
2011-05-05 15:51:32 -04:00
|
|
|
screenMeta = {
|
2011-09-16 01:01:54 -04:00
|
|
|
element: null, // #screen-meta
|
|
|
|
toggles: null, // .screen-meta-toggle
|
2011-09-16 03:10:04 -04:00
|
|
|
page: null, // #wpcontent
|
2011-09-16 01:01:54 -04:00
|
|
|
|
2011-05-05 15:51:32 -04:00
|
|
|
init: function() {
|
2011-11-03 13:08:12 -04:00
|
|
|
this.element = $('#screen-meta');
|
|
|
|
this.toggles = $('.screen-meta-toggle a');
|
|
|
|
this.page = $('#wpcontent');
|
|
|
|
|
|
|
|
this.toggles.click( this.toggleEvent );
|
2011-05-05 15:51:32 -04:00
|
|
|
},
|
2011-09-16 01:01:54 -04:00
|
|
|
|
2011-05-05 15:51:32 -04:00
|
|
|
toggleEvent: function( e ) {
|
2011-11-03 13:08:12 -04:00
|
|
|
var panel = $( this.href.replace(/.+#/, '#') );
|
2011-05-05 15:51:32 -04:00
|
|
|
e.preventDefault();
|
2009-05-24 19:47:49 -04:00
|
|
|
|
2011-11-03 13:08:12 -04:00
|
|
|
if ( !panel.length )
|
2011-05-05 15:51:32 -04:00
|
|
|
return;
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2011-05-05 15:51:32 -04:00
|
|
|
if ( panel.is(':visible') )
|
|
|
|
screenMeta.close( panel, $(this) );
|
|
|
|
else
|
|
|
|
screenMeta.open( panel, $(this) );
|
|
|
|
},
|
|
|
|
|
2011-11-03 16:26:09 -04:00
|
|
|
open: function( panel, link ) {
|
2011-09-16 01:01:54 -04:00
|
|
|
|
2011-11-03 16:26:09 -04:00
|
|
|
$('.screen-meta-toggle').not( link.parent() ).css('visibility', 'hidden');
|
2011-09-16 01:01:54 -04:00
|
|
|
|
2011-11-03 19:30:55 -04:00
|
|
|
panel.parent().show();
|
2011-11-03 16:26:09 -04:00
|
|
|
panel.slideDown( 'fast', function() {
|
|
|
|
link.addClass('screen-meta-active');
|
|
|
|
});
|
2011-09-27 20:57:56 -04:00
|
|
|
},
|
2011-11-03 16:26:09 -04:00
|
|
|
|
2011-05-05 15:51:32 -04:00
|
|
|
close: function( panel, link ) {
|
2011-11-03 16:26:09 -04:00
|
|
|
panel.slideUp( 'fast', function() {
|
|
|
|
link.removeClass('screen-meta-active');
|
2011-11-06 22:59:00 -05:00
|
|
|
$('.screen-meta-toggle').css('visibility', '');
|
2011-11-03 19:30:55 -04:00
|
|
|
panel.parent().hide();
|
2011-11-03 16:26:09 -04:00
|
|
|
});
|
2011-05-05 15:51:32 -04:00
|
|
|
}
|
|
|
|
};
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2011-09-26 17:03:38 -04:00
|
|
|
/**
|
|
|
|
* Help tabs.
|
|
|
|
*/
|
|
|
|
$('.contextual-help-tabs').delegate('a', 'click focus', function(e) {
|
|
|
|
var link = $(this),
|
2011-10-23 13:55:24 -04:00
|
|
|
panel;
|
2011-09-26 17:03:38 -04:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// Don't do anything if the click is for the tab already showing.
|
|
|
|
if ( link.is('.active a') )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Links
|
|
|
|
$('.contextual-help-tabs .active').removeClass('active');
|
|
|
|
link.parent('li').addClass('active');
|
|
|
|
|
|
|
|
panel = $( link.attr('href') );
|
|
|
|
|
|
|
|
// Panels
|
|
|
|
$('.help-tab-content').not( panel ).removeClass('active').hide();
|
|
|
|
panel.addClass('active').show();
|
|
|
|
});
|
2011-09-16 01:01:54 -04:00
|
|
|
|
2011-05-05 15:51:32 -04:00
|
|
|
$(document).ready( function() {
|
2011-10-06 05:18:56 -04:00
|
|
|
var lastClicked = false, checks, first, last, checked, menu = $('#adminmenu'),
|
2012-05-08 23:56:40 -04:00
|
|
|
pageInput = $('input.current-page'), currentPage = pageInput.val(), refresh;
|
2011-10-06 05:18:56 -04:00
|
|
|
|
|
|
|
// admin menu
|
2011-11-29 21:15:24 -05:00
|
|
|
refresh = function(i, el){ // force the browser to refresh the tabbing index
|
|
|
|
var node = $(el), tab = node.attr('tabindex');
|
|
|
|
if ( tab )
|
|
|
|
node.attr('tabindex', '0').attr('tabindex', tab);
|
|
|
|
};
|
2011-11-30 23:51:35 -05:00
|
|
|
|
2011-10-06 05:18:56 -04:00
|
|
|
$('#collapse-menu', menu).click(function(){
|
|
|
|
var body = $(document.body);
|
|
|
|
|
2012-04-06 17:40:57 -04:00
|
|
|
// reset any compensation for submenus near the bottom of the screen
|
|
|
|
$('#adminmenu div.wp-submenu').css('margin-top', '');
|
|
|
|
|
2011-10-06 05:18:56 -04:00
|
|
|
if ( body.hasClass('folded') ) {
|
|
|
|
body.removeClass('folded');
|
2011-10-29 17:56:27 -04:00
|
|
|
setUserSetting('mfold', 'o');
|
2011-10-06 05:18:56 -04:00
|
|
|
} else {
|
|
|
|
body.addClass('folded');
|
|
|
|
setUserSetting('mfold', 'f');
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('li.wp-has-submenu', menu).hoverIntent({
|
|
|
|
over: function(e){
|
2011-11-29 22:37:15 -05:00
|
|
|
var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop;
|
2011-10-06 05:18:56 -04:00
|
|
|
|
2011-10-11 13:59:51 -04:00
|
|
|
if ( !$(document.body).hasClass('folded') && $(this).hasClass('wp-menu-open') )
|
|
|
|
return;
|
|
|
|
|
2011-11-29 22:37:15 -05:00
|
|
|
menutop = $(this).offset().top;
|
|
|
|
wintop = $(window).scrollTop();
|
|
|
|
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
|
|
|
|
|
|
|
|
b = menutop + m.height() + 1; // Bottom offset of the menu
|
2011-10-06 05:18:56 -04:00
|
|
|
h = $('#wpwrap').height(); // Height of the entire page
|
|
|
|
o = 60 + b - h;
|
2011-11-29 22:37:15 -05:00
|
|
|
f = $(window).height() + wintop - 15; // The fold
|
2011-10-06 05:18:56 -04:00
|
|
|
|
|
|
|
if ( f < (b - o) )
|
|
|
|
o = b - f;
|
|
|
|
|
2011-11-29 22:37:15 -05:00
|
|
|
if ( o > maxtop )
|
|
|
|
o = maxtop;
|
|
|
|
|
2011-10-06 05:18:56 -04:00
|
|
|
if ( o > 1 )
|
2012-04-06 17:40:57 -04:00
|
|
|
m.css('margin-top', '-'+o+'px');
|
|
|
|
else
|
|
|
|
m.css('margin-top', '');
|
2011-10-06 05:18:56 -04:00
|
|
|
|
2012-01-02 16:49:58 -05:00
|
|
|
menu.find('.wp-submenu').removeClass('sub-open');
|
2011-10-06 05:18:56 -04:00
|
|
|
m.addClass('sub-open');
|
|
|
|
},
|
|
|
|
out: function(){
|
|
|
|
$(this).find('.wp-submenu').removeClass('sub-open');
|
|
|
|
},
|
|
|
|
timeout: 200,
|
|
|
|
sensitivity: 7,
|
|
|
|
interval: 90
|
|
|
|
});
|
2009-08-18 05:53:37 -04:00
|
|
|
|
2011-11-29 21:15:24 -05:00
|
|
|
// Tab to select, Enter to open sub, Esc to close sub and focus the top menu
|
|
|
|
$('li.wp-has-submenu > a.wp-not-current-submenu', menu).bind('keydown.adminmenu', function(e){
|
|
|
|
if ( e.which != 13 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
var target = $(e.target);
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
|
2011-11-30 19:43:18 -05:00
|
|
|
menu.find('.wp-submenu').removeClass('sub-open');
|
2011-11-29 21:15:24 -05:00
|
|
|
target.siblings('.wp-submenu').toggleClass('sub-open').find('a[role="menuitem"]').each(refresh);
|
|
|
|
}).each(refresh);
|
|
|
|
|
|
|
|
$('a[role="menuitem"]', menu).bind('keydown.adminmenu', function(e){
|
|
|
|
if ( e.which != 27 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
var target = $(e.target);
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
target.add( target.siblings() ).closest('.sub-open').removeClass('sub-open').siblings('a.wp-not-current-submenu').focus();
|
2011-11-06 22:59:00 -05:00
|
|
|
});
|
|
|
|
|
2011-05-05 15:51:32 -04:00
|
|
|
// Move .updated and .error alert boxes. Don't move boxes designed to be inline.
|
|
|
|
$('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
|
|
|
|
$('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );
|
|
|
|
|
|
|
|
// Init screen meta
|
|
|
|
screenMeta.init();
|
2009-01-02 10:08:58 -05:00
|
|
|
|
|
|
|
// 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 );
|
2011-05-24 21:04:12 -04:00
|
|
|
checked = $(this).prop('checked');
|
2009-01-02 10:08:58 -05:00
|
|
|
if ( 0 < first && 0 < last && first != last ) {
|
2011-05-24 21:04:12 -04:00
|
|
|
checks.slice( first, last ).prop( 'checked', function(){
|
2009-08-18 05:53:37 -04:00
|
|
|
if ( $(this).closest('tr').is(':visible') )
|
2011-05-24 21:04:12 -04:00
|
|
|
return checked;
|
2009-01-02 10:08:58 -05:00
|
|
|
|
2011-05-24 21:04:12 -04:00
|
|
|
return false;
|
2009-01-02 10:08:58 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
2011-05-20 18:47:36 -04:00
|
|
|
var c = $(this).prop('checked'),
|
2009-08-18 05:53:37 -04:00
|
|
|
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')
|
2011-05-20 18:47:36 -04:00
|
|
|
.prop('checked', function() {
|
2009-08-18 05:53:37 -04:00
|
|
|
if ( $(this).closest('tr').is(':hidden') )
|
2011-05-20 18:47:36 -04:00
|
|
|
return false;
|
2009-01-02 10:08:58 -05:00
|
|
|
if ( toggle )
|
2011-05-20 18:47:36 -04:00
|
|
|
return $(this).prop( 'checked' );
|
2009-01-02 10:08:58 -05:00
|
|
|
else if (c)
|
2011-05-20 18:47:36 -04:00
|
|
|
return true;
|
|
|
|
return false;
|
2009-01-02 10:08:58 -05:00
|
|
|
});
|
2009-08-18 05:53:37 -04:00
|
|
|
|
|
|
|
$(this).closest('table').children('thead, tfoot').filter(':visible')
|
|
|
|
.children().children('.check-column').find(':checkbox')
|
2011-05-20 18:47:36 -04:00
|
|
|
.prop('checked', function() {
|
2009-01-02 10:08:58 -05:00
|
|
|
if ( toggle )
|
2011-05-20 18:47:36 -04:00
|
|
|
return false;
|
2009-01-02 10:08:58 -05:00
|
|
|
else if (c)
|
2011-05-20 18:47:36 -04:00
|
|
|
return true;
|
|
|
|
return false;
|
2009-01-02 10:08:58 -05:00
|
|
|
});
|
|
|
|
});
|
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
|
2011-05-20 18:47:36 -04:00
|
|
|
$('#newcontent').bind('keydown.wpevent_InsertTab', 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 {
|
2011-12-13 18:45:31 -05:00
|
|
|
this.lastKey = 9; // not a standard DOM property, lastKey is to help stop Opera tab event. See blur handler below.
|
2010-03-02 06:49:06 -05:00
|
|
|
} 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
|
|
|
|
2011-05-20 18:47:36 -04:00
|
|
|
$('#newcontent').bind('blur.wpevent_InsertTab', function(e) {
|
2010-03-02 06:49:06 -05:00
|
|
|
if ( this.lastKey && 9 == this.lastKey )
|
|
|
|
this.focus();
|
2010-02-18 00:14:48 -05:00
|
|
|
});
|
2011-06-10 15:33:45 -04:00
|
|
|
|
|
|
|
if ( pageInput.length ) {
|
2011-07-11 17:53:29 -04:00
|
|
|
pageInput.closest('form').submit( function(e){
|
|
|
|
|
|
|
|
// Reset paging var for new filters/searches but not for bulk actions. See #17685.
|
|
|
|
if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage )
|
2011-06-10 15:33:45 -04:00
|
|
|
pageInput.val('1');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-10-07 05:53:37 -04:00
|
|
|
});
|
2011-05-05 15:51:32 -04:00
|
|
|
|
2011-05-28 22:04:52 -04:00
|
|
|
// internal use
|
2011-05-29 01:07:32 -04:00
|
|
|
$(document).bind( 'wp_CloseOnEscape', function( e, data ) {
|
2011-05-28 22:04:52 -04:00
|
|
|
if ( typeof(data.cb) != 'function' )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( typeof(data.condition) != 'function' || data.condition() )
|
|
|
|
data.cb();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2011-05-20 18:47:36 -04:00
|
|
|
})(jQuery);
|