first commit

This commit is contained in:
alazhar
2020-01-02 23:15:16 +07:00
commit eda9661806
3433 changed files with 595883 additions and 0 deletions

5
wp-admin/js/cat.js Normal file
View File

@ -0,0 +1,5 @@
jQuery(document).ready( function($) {
var myConfirm = function() { return '' !== $('#newcat').val(); };
$('#jaxcat').prepend('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" data-wp-lists="add:categorychecklist:jaxcat" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span><span id="cat-ajax-response"></span>');
$('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } );
} );

1
wp-admin/js/cat.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(b){var a=function(){return""!==b("#newcat").val()};b("#jaxcat").prepend('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" data-wp-lists="add:categorychecklist:jaxcat" id="catadd" value="'+catL10n.add+'"/><input type="hidden"/><input type="hidden"/><span id="howto">'+catL10n.how+'</span></span><span id="cat-ajax-response"></span>');b("#categorychecklist").wpList({alt:"",response:"cat-ajax-response",confirm:a})});

34
wp-admin/js/categories.js Normal file
View File

@ -0,0 +1,34 @@
jQuery(document).ready(function($) {
var options = false, addAfter, delBefore, delAfter;
if ( document.forms['addcat'].category_parent )
options = document.forms['addcat'].category_parent.options;
addAfter = function( r, settings ) {
var name, id;
name = $("<span>" + $('name', r).text() + "</span>").text();
id = $('cat', r).attr('id');
options[options.length] = new Option(name, id);
}
delAfter = function( r, settings ) {
var id = $('cat', r).attr('id'), o;
for ( o = 0; o < options.length; o++ )
if ( id == options[o].value )
options[o] = null;
}
delBefore = function(s) {
if ( 'undefined' != showNotice )
return showNotice.warn() ? s : false;
return s;
}
if ( options )
$('#the-list').wpList( { addAfter: addAfter, delBefore: delBefore, delAfter: delAfter } );
else
$('#the-list').wpList({ delBefore: delBefore });
$('.delete a[class^="delete"]').live('click', function(){return false;});
});

1
wp-admin/js/categories.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(d){var b=false,e,c,a;if(document.forms.addcat.category_parent){b=document.forms.addcat.category_parent.options}e=function(h,g){var f,i;f=d("<span>"+d("name",h).text()+"</span>").text();i=d("cat",h).attr("id");b[b.length]=new Option(f,i)};a=function(g,f){var i=d("cat",g).attr("id"),h;for(h=0;h<b.length;h++){if(i==b[h].value){b[h]=null}}};c=function(f){if("undefined"!=showNotice){return showNotice.warn()?f:false}return f};if(b){d("#the-list").wpList({addAfter:e,delBefore:c,delAfter:a})}else{d("#the-list").wpList({delBefore:c})}d('.delete a[class^="delete"]').live("click",function(){return false})});

131
wp-admin/js/color-picker.js Normal file
View File

@ -0,0 +1,131 @@
( function( $, undef ){
// html stuff
var _before = '<a tabindex="0" class="wp-color-result" />',
_after = '<div class="wp-picker-holder" />',
_wrap = '<div class="wp-picker-container" />',
_button = '<input type="button" class="button button-small hidden" />';
// jQuery UI Widget constructor
var ColorPicker = {
options: {
defaultColor: false,
change: false,
clear: false,
hide: true,
palettes: true
},
_create: function() {
// bail early for IE < 8
if ( $.browser.msie && parseInt( $.browser.version, 10 ) < 8 )
return;
var self = this;
var el = self.element;
$.extend( self.options, el.data() );
self.initialValue = el.val();
// Set up HTML structure, hide things
el.addClass( 'wp-color-picker' ).hide().wrap( _wrap );
self.wrap = el.parent();
self.toggler = $( _before ).insertBefore( el ).css( { backgroundColor: self.initialValue } ).attr( "title", wpColorPickerL10n.pick ).attr( "data-current", wpColorPickerL10n.current );
self.pickerContainer = $( _after ).insertAfter( el );
self.button = $( _button );
if ( self.options.defaultColor )
self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString );
else
self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
el.wrap('<span class="wp-picker-input-wrap" />').after(self.button);
el.iris( {
target: self.pickerContainer,
hide: true,
width: 255,
mode: 'hsv',
palettes: self.options.palettes,
change: function( event, ui ) {
self.toggler.css( { backgroundColor: ui.color.toString() } );
// check for a custom cb
if ( $.isFunction( self.options.change ) )
self.options.change.call( this, event, ui );
}
} );
el.val( self.initialValue );
self._addListeners();
if ( ! self.options.hide )
self.toggler.click();
},
_addListeners: function() {
var self = this;
self.toggler.click( function( event ){
event.stopPropagation();
self.element.toggle().iris( 'toggle' );
self.button.toggleClass('hidden');
self.toggler.toggleClass( 'wp-picker-open' );
// close picker when you click outside it
if ( self.toggler.hasClass( 'wp-picker-open' ) )
$( "body" ).on( 'click', { wrap: self.wrap, toggler: self.toggler }, self._bodyListener );
else
$( "body" ).off( 'click', self._bodyListener );
});
self.element.change(function( event ) {
var me = $(this),
val = me.val();
// Empty = clear
if ( val === '' || val === '#' ) {
self.toggler.css('backgroundColor', '');
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
}
});
// open a keyboard-focused closed picker with space or enter
self.toggler.on('keyup', function( e ) {
if ( e.keyCode === 13 || e.keyCode === 32 ) {
e.preventDefault();
self.toggler.trigger('click').next().focus();
}
});
self.button.click( function( event ) {
var me = $(this);
if ( me.hasClass( 'wp-picker-clear' ) ) {
self.element.val( '' );
self.toggler.css('backgroundColor', '');
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
} else if ( me.hasClass( 'wp-picker-default' ) ) {
self.element.val( self.options.defaultColor ).change();
}
});
},
_bodyListener: function( event ) {
if ( ! event.data.wrap.find( event.target ).length )
event.data.toggler.click();
},
// $("#input").wpColorPicker('color') returns the current color
// $("#input").wpColorPicker('color', '#bada55') to set
color: function( newColor ) {
if ( newColor === undef )
return this.element.iris( "option", "color" );
this.element.iris( "option", "color", newColor );
},
//$("#input").wpColorPicker('defaultColor') returns the current default color
//$("#input").wpColorPicker('defaultColor', newDefaultColor) to set
defaultColor: function( newDefaultColor ) {
if ( newDefaultColor === undef )
return this.options.defaultColor;
this.options.defaultColor = newDefaultColor;
}
}
$.widget( 'wp.wpColorPicker', ColorPicker );
}( jQuery ) );

1
wp-admin/js/color-picker.min.js vendored Normal file
View File

@ -0,0 +1 @@
(function(f,e){var a='<a tabindex="0" class="wp-color-result" />',c='<div class="wp-picker-holder" />',b='<div class="wp-picker-container" />',g='<input type="button" class="button button-small hidden" />';var d={options:{defaultColor:false,change:false,clear:false,hide:true,palettes:true},_create:function(){if(f.browser.msie&&parseInt(f.browser.version,10)<8){return}var h=this;var i=h.element;f.extend(h.options,i.data());h.initialValue=i.val();i.addClass("wp-color-picker").hide().wrap(b);h.wrap=i.parent();h.toggler=f(a).insertBefore(i).css({backgroundColor:h.initialValue}).attr("title",wpColorPickerL10n.pick).attr("data-current",wpColorPickerL10n.current);h.pickerContainer=f(c).insertAfter(i);h.button=f(g);if(h.options.defaultColor){h.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString)}else{h.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear)}i.wrap('<span class="wp-picker-input-wrap" />').after(h.button);i.iris({target:h.pickerContainer,hide:true,width:255,mode:"hsv",palettes:h.options.palettes,change:function(j,k){h.toggler.css({backgroundColor:k.color.toString()});if(f.isFunction(h.options.change)){h.options.change.call(this,j,k)}}});i.val(h.initialValue);h._addListeners();if(!h.options.hide){h.toggler.click()}},_addListeners:function(){var h=this;h.toggler.click(function(i){i.stopPropagation();h.element.toggle().iris("toggle");h.button.toggleClass("hidden");h.toggler.toggleClass("wp-picker-open");if(h.toggler.hasClass("wp-picker-open")){f("body").on("click",{wrap:h.wrap,toggler:h.toggler},h._bodyListener)}else{f("body").off("click",h._bodyListener)}});h.element.change(function(j){var i=f(this),k=i.val();if(k===""||k==="#"){h.toggler.css("backgroundColor","");if(f.isFunction(h.options.clear)){h.options.clear.call(this,j)}}});h.toggler.on("keyup",function(i){if(i.keyCode===13||i.keyCode===32){i.preventDefault();h.toggler.trigger("click").next().focus()}});h.button.click(function(j){var i=f(this);if(i.hasClass("wp-picker-clear")){h.element.val("");h.toggler.css("backgroundColor","");if(f.isFunction(h.options.clear)){h.options.clear.call(this,j)}}else{if(i.hasClass("wp-picker-default")){h.element.val(h.options.defaultColor).change()}}})},_bodyListener:function(h){if(!h.data.wrap.find(h.target).length){h.data.toggler.click()}},color:function(h){if(h===e){return this.element.iris("option","color")}this.element.iris("option","color",h)},defaultColor:function(h){if(h===e){return this.options.defaultColor}this.options.defaultColor=h}};f.widget("wp.wpColorPicker",d)}(jQuery));

49
wp-admin/js/comment.js Normal file
View File

@ -0,0 +1,49 @@
jQuery(document).ready( function($) {
postboxes.add_postbox_toggles('comment');
var stamp = $('#timestamp').html();
$('.edit-timestamp').click(function () {
if ($('#timestampdiv').is(":hidden")) {
$('#timestampdiv').slideDown("normal");
$('.edit-timestamp').hide();
}
return false;
});
$('.cancel-timestamp').click(function() {
$('#timestampdiv').slideUp("normal");
$('#mm').val($('#hidden_mm').val());
$('#jj').val($('#hidden_jj').val());
$('#aa').val($('#hidden_aa').val());
$('#hh').val($('#hidden_hh').val());
$('#mn').val($('#hidden_mn').val());
$('#timestamp').html(stamp);
$('.edit-timestamp').show();
return false;
});
$('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
newD = new Date( aa, mm - 1, jj, hh, mn );
if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) {
$('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
return false;
} else {
$('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
}
$('#timestampdiv').slideUp("normal");
$('.edit-timestamp').show();
$('#timestamp').html(
commentL10n.submittedOn + ' <b>' +
$( '#mm option[value="' + mm + '"]' ).text() + ' ' +
jj + ', ' +
aa + ' @ ' +
hh + ':' +
mn + '</b> '
);
return false;
});
});

1
wp-admin/js/comment.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(b){postboxes.add_postbox_toggles("comment");var a=b("#timestamp").html();b(".edit-timestamp").click(function(){if(b("#timestampdiv").is(":hidden")){b("#timestampdiv").slideDown("normal");b(".edit-timestamp").hide()}return false});b(".cancel-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b("#mm").val(b("#hidden_mm").val());b("#jj").val(b("#hidden_jj").val());b("#aa").val(b("#hidden_aa").val());b("#hh").val(b("#hidden_hh").val());b("#mn").val(b("#hidden_mn").val());b("#timestamp").html(a);b(".edit-timestamp").show();return false});b(".save-timestamp").click(function(){var g=b("#aa").val(),h=b("#mm").val(),d=b("#jj").val(),c=b("#hh").val(),f=b("#mn").val(),e=new Date(g,h-1,d,c,f);if(e.getFullYear()!=g||(1+e.getMonth())!=h||e.getDate()!=d||e.getMinutes()!=f){b(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{b(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" <b>"+b('#mm option[value="'+h+'"]').text()+" "+d+", "+g+" @ "+c+":"+f+"</b> ");return false})});

427
wp-admin/js/common.js Normal file
View File

@ -0,0 +1,427 @@
var showNotice, adminMenu, columns, validateForm, screenMeta;
(function($){
// Removed in 3.3.
// (perhaps) needed for back-compat
adminMenu = {
init : function() {},
fold : function() {},
restoreMenuState : function() {},
toggle : function() {},
favorites : function() {}
};
// show/hide/save table columns
columns = {
init : function() {
var that = this;
$('.hide-column-tog', '#adv-settings').click( function() {
var $t = $(this), column = $t.val();
if ( $t.prop('checked') )
that.checked(column);
else
that.unchecked(column);
columns.saveManageColumnsState();
});
},
saveManageColumnsState : function() {
var hidden = this.hidden();
$.post(ajaxurl, {
action: 'hidden-columns',
hidden: hidden,
screenoptionnonce: $('#screenoptionnonce').val(),
page: pagenow
});
},
checked : function(column) {
$('.column-' + column).show();
this.colSpanChange(+1);
},
unchecked : function(column) {
$('.column-' + column).hide();
this.colSpanChange(-1);
},
hidden : function() {
return $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
},
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(',');
};
},
colSpanChange : function(diff) {
var $t = $('table').find('.colspanchange'), n;
if ( !$t.length )
return;
n = parseInt( $t.attr('colspan'), 10 ) + diff;
$t.attr('colspan', n.toString());
}
}
$(document).ready(function(){columns.init();});
validateForm = function( form ) {
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();
}
// stub for doing better warnings
showNotice = {
warn : function() {
var msg = commonL10n.warnDelete || '';
if ( confirm(msg) ) {
return true;
}
return false;
},
note : function(text) {
alert(text);
}
};
screenMeta = {
element: null, // #screen-meta
toggles: null, // .screen-meta-toggle
page: null, // #wpcontent
init: function() {
this.element = $('#screen-meta');
this.toggles = $('.screen-meta-toggle a');
this.page = $('#wpcontent');
this.toggles.click( this.toggleEvent );
},
toggleEvent: function( e ) {
var panel = $( this.href.replace(/.+#/, '#') );
e.preventDefault();
if ( !panel.length )
return;
if ( panel.is(':visible') )
screenMeta.close( panel, $(this) );
else
screenMeta.open( panel, $(this) );
},
open: function( panel, link ) {
$('.screen-meta-toggle').not( link.parent() ).css('visibility', 'hidden');
panel.parent().show();
panel.slideDown( 'fast', function() {
panel.focus();
link.addClass('screen-meta-active').attr('aria-expanded', true);
});
},
close: function( panel, link ) {
panel.slideUp( 'fast', function() {
link.removeClass('screen-meta-active').attr('aria-expanded', false);
$('.screen-meta-toggle').css('visibility', '');
panel.parent().hide();
});
}
};
/**
* Help tabs.
*/
$('.contextual-help-tabs').delegate('a', 'click focus', function(e) {
var link = $(this),
panel;
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();
});
$(document).ready( function() {
var lastClicked = false, checks, first, last, checked, menu = $('#adminmenu'), mobileEvent,
pageInput = $('input.current-page'), currentPage = pageInput.val();
// when the menu is folded, make the fly-out submenu header clickable
menu.on('click.wp-submenu-head', '.wp-submenu-head', function(e){
$(e.target).parent().siblings('a').get(0).click();
});
$('#collapse-menu').on('click.collapse-menu', function(e){
var body = $(document.body);
// reset any compensation for submenus near the bottom of the screen
$('#adminmenu div.wp-submenu').css('margin-top', '');
if ( $(window).width() < 900 ) {
if ( body.hasClass('auto-fold') ) {
body.removeClass('auto-fold');
setUserSetting('unfold', 1);
body.removeClass('folded');
deleteUserSetting('mfold');
} else {
body.addClass('auto-fold');
deleteUserSetting('unfold');
}
} else {
if ( body.hasClass('folded') ) {
body.removeClass('folded');
deleteUserSetting('mfold');
} else {
body.addClass('folded');
setUserSetting('mfold', 'f');
}
}
});
if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
// iOS Safari works with touchstart, the rest work with click
mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click';
// close any open submenus when touch/click is not on the menu
$(document.body).on( mobileEvent+'.wp-mobile-hover', function(e) {
if ( !$(e.target).closest('#adminmenu').length )
menu.find('li.wp-has-submenu.opensub').removeClass('opensub');
});
menu.find('a.wp-has-submenu').on( mobileEvent+'.wp-mobile-hover', function(e) {
var el = $(this), parent = el.parent();
// Show the sub instead of following the link if:
// - the submenu is not open
// - the submenu is not shown inline or the menu is not folded
if ( !parent.hasClass('opensub') && ( !parent.hasClass('wp-menu-open') || parent.width() < 40 ) ) {
e.preventDefault();
menu.find('li.opensub').removeClass('opensub');
parent.addClass('opensub');
}
});
}
menu.find('li.wp-has-submenu').hoverIntent({
over: function(e){
var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 );
if ( isNaN(top) || top > -5 ) // meaning the submenu is visible
return;
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
h = $('#wpwrap').height(); // Height of the entire page
o = 60 + b - h;
f = $(window).height() + wintop - 15; // The fold
if ( f < (b - o) )
o = b - f;
if ( o > maxtop )
o = maxtop;
if ( o > 1 )
m.css('margin-top', '-'+o+'px');
else
m.css('margin-top', '');
menu.find('li.menu-top').removeClass('opensub');
$(this).addClass('opensub');
},
out: function(){
$(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
},
timeout: 200,
sensitivity: 7,
interval: 90
});
menu.on('focus.adminmenu', '.wp-submenu a', function(e){
$(e.target).closest('li.menu-top').addClass('opensub');
}).on('blur.adminmenu', '.wp-submenu a', function(e){
$(e.target).closest('li.menu-top').removeClass('opensub');
});
// 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();
// check all checkboxes
$('tbody').children().children('.check-column').find(':checkbox').click( function(e) {
if ( 'undefined' == e.shiftKey ) { return true; }
if ( e.shiftKey ) {
if ( !lastClicked ) { return true; }
checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' );
first = checks.index( lastClicked );
last = checks.index( this );
checked = $(this).prop('checked');
if ( 0 < first && 0 < last && first != last ) {
checks.slice( first, last ).prop( 'checked', function(){
if ( $(this).closest('tr').is(':visible') )
return checked;
return false;
});
}
}
lastClicked = this;
// toggle "check all" checkboxes
var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible').not(':checked');
$(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() {
return ( 0 == unchecked.length );
});
return true;
});
$('thead, tfoot').find('.check-column :checkbox').click( function(e) {
var c = $(this).prop('checked'),
kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard,
toggle = e.shiftKey || kbtoggle;
$(this).closest( 'table' ).children( 'tbody' ).filter(':visible')
.children().children('.check-column').find(':checkbox')
.prop('checked', function() {
if ( $(this).closest('tr').is(':hidden') )
return false;
if ( toggle )
return $(this).prop( 'checked' );
else if (c)
return true;
return false;
});
$(this).closest('table').children('thead, tfoot').filter(':visible')
.children().children('.check-column').find(':checkbox')
.prop('checked', function() {
if ( toggle )
return false;
else if (c)
return true;
return false;
});
});
$('#default-password-nag-no').click( function() {
setUserSetting('default_password_nag', 'hide');
$('div.default-password-nag').hide();
return false;
});
// tab in textareas
$('#newcontent').bind('keydown.wpevent_InsertTab', function(e) {
var el = e.target, selStart, selEnd, val, scroll, sel;
if ( e.keyCode == 27 ) { // escape key
$(el).data('tab-out', true);
return;
}
if ( e.keyCode != 9 || e.ctrlKey || e.altKey || e.shiftKey ) // tab key
return;
if ( $(el).data('tab-out') ) {
$(el).data('tab-out', false);
return;
}
selStart = el.selectionStart;
selEnd = el.selectionEnd;
val = el.value;
try {
this.lastKey = 9; // not a standard DOM property, lastKey is to help stop Opera tab event. See blur handler below.
} catch(err) {}
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;
}
if ( e.stopPropagation )
e.stopPropagation();
if ( e.preventDefault )
e.preventDefault();
});
$('#newcontent').bind('blur.wpevent_InsertTab', function(e) {
if ( this.lastKey && 9 == this.lastKey )
this.focus();
});
if ( pageInput.length ) {
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 )
pageInput.val('1');
});
}
// Scroll into view when focused
$('#contextual-help-link, #show-settings-link').on( 'focus.scroll-into-view', function(e){
if ( e.target.scrollIntoView )
e.target.scrollIntoView(false);
});
// Disable upload buttons until files are selected
(function(){
var button, input, form = $('form.wp-upload-form');
if ( ! form.length )
return;
button = form.find('input[type="submit"]');
input = form.find('input[type="file"]');
function toggleUploadButton() {
button.prop('disabled', '' === input.map( function() {
return $(this).val();
}).get().join(''));
}
toggleUploadButton();
input.on('change', toggleUploadButton);
})();
});
// internal use
$(document).bind( 'wp_CloseOnEscape', function( e, data ) {
if ( typeof(data.cb) != 'function' )
return;
if ( typeof(data.condition) != 'function' || data.condition() )
data.cb();
return true;
});
})(jQuery);

1
wp-admin/js/common.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,74 @@
(function($) {
$(document).ready(function() {
var bgImage = $("#custom-background-image"),
frame;
$('#background-color').wpColorPicker({
change: function( event, ui ) {
bgImage.css('background-color', ui.color.toString());
},
clear: function() {
bgImage.css('background-color', '');
}
});
$('input[name="background-position-x"]').change(function() {
bgImage.css('background-position', $(this).val() + ' top');
});
$('input[name="background-repeat"]').change(function() {
bgImage.css('background-repeat', $(this).val());
});
$('#choose-from-library-link').click( function( event ) {
var $el = $(this);
event.preventDefault();
// If the media frame already exists, reopen it.
if ( frame ) {
frame.open();
return;
}
// Create the media frame.
frame = wp.media.frames.customBackground = wp.media({
// Set the title of the modal.
title: $el.data('choose'),
// Tell the modal to show only images.
library: {
type: 'image'
},
// Customize the submit button.
button: {
// Set the text of the button.
text: $el.data('update'),
// Tell the button not to close the modal, since we're
// going to refresh the page when the image is selected.
close: false
}
});
// When an image is selected, run a callback.
frame.on( 'select', function() {
// Grab the selected attachment.
var attachment = frame.state().get('selection').first();
// Run an AJAX request to set the background image.
$.post( ajaxurl, {
action: 'set-background-image',
attachment_id: attachment.id,
size: 'full'
}).done( function() {
// When the request completes, reload the window.
window.location.reload();
});
});
// Finally, open the modal.
frame.open();
});
});
})(jQuery);

1
wp-admin/js/custom-background.min.js vendored Normal file
View File

@ -0,0 +1 @@
(function(a){a(document).ready(function(){var b=a("#custom-background-image"),c;a("#background-color").wpColorPicker({change:function(d,e){b.css("background-color",e.color.toString())},clear:function(){b.css("background-color","")}});a('input[name="background-position-x"]').change(function(){b.css("background-position",a(this).val()+" top")});a('input[name="background-repeat"]').change(function(){b.css("background-repeat",a(this).val())});a("#choose-from-library-link").click(function(e){var d=a(this);e.preventDefault();if(c){c.open();return}c=wp.media.frames.customBackground=wp.media({title:d.data("choose"),library:{type:"image"},button:{text:d.data("update"),close:false}});c.on("select",function(){var f=c.state().get("selection").first();a.post(ajaxurl,{action:"set-background-image",attachment_id:f.id,size:"full"}).done(function(){window.location.reload()})});c.open()})})})(jQuery);

View File

@ -0,0 +1,34 @@
jQuery(document).ready( function($) {
var before, addBefore, addAfter, delBefore;
before = function() {
var nonce = $('#newmeta [name="_ajax_nonce"]').val(), postId = $('#post_ID').val();
if ( !nonce || !postId ) { return false; }
return [nonce,postId];
}
addBefore = function( s ) {
var b = before();
if ( !b ) { return false; }
s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1];
return s;
};
addAfter = function( r, s ) {
var postId = $('postid', r).text(), h;
if ( !postId ) { return; }
$('#post_ID').attr( 'name', 'post_ID' ).val( postId );
h = $('#hiddenaction');
if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); }
};
delBefore = function( s ) {
var b = before(); if ( !b ) return false;
s.data._ajax_nonce = b[0]; s.data.post_id = b[1];
return s;
}
$('#the-list')
.wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } )
.find('.updatemeta, .deletemeta').attr( 'type', 'button' );
} );

1
wp-admin/js/custom-fields.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(d){var c,b,e,a;c=function(){var g=d('#newmeta [name="_ajax_nonce"]').val(),f=d("#post_ID").val();if(!g||!f){return false}return[g,f]};b=function(g){var f=c();if(!f){return false}g.data=g.data.replace(/_ajax_nonce=[a-f0-9]+/,"_ajax_nonce="+f[0])+"&post_id="+f[1];return g};e=function(j,i){var f=d("postid",j).text(),g;if(!f){return}d("#post_ID").attr("name","post_ID").val(f);g=d("#hiddenaction");if("post"==g.val()){g.val("postajaxpost")}};a=function(g){var f=c();if(!f){return false}g.data._ajax_nonce=f[0];g.data.post_id=f[1];return g};d("#the-list").wpList({addBefore:b,addAfter:e,delBefore:a}).find(".updatemeta, .deletemeta").attr("type","button")});

View File

@ -0,0 +1,60 @@
(function($) {
var frame;
$( function() {
// Fetch available headers and apply jQuery.masonry
// once the images have loaded.
var $headers = $('.available-headers');
$headers.imagesLoaded( function() {
$headers.masonry({
itemSelector: '.default-header',
isRTL: !! ( 'undefined' != typeof isRtl && isRtl )
});
});
// Build the choose from library frame.
$('#choose-from-library-link').click( function( event ) {
var $el = $(this);
event.preventDefault();
// If the media frame already exists, reopen it.
if ( frame ) {
frame.open();
return;
}
// Create the media frame.
frame = wp.media.frames.customHeader = wp.media({
// Set the title of the modal.
title: $el.data('choose'),
// Tell the modal to show only images.
library: {
type: 'image'
},
// Customize the submit button.
button: {
// Set the text of the button.
text: $el.data('update'),
// Tell the button not to close the modal, since we're
// going to refresh the page when the image is selected.
close: false
}
});
// When an image is selected, run a callback.
frame.on( 'select', function() {
// Grab the selected attachment.
var attachment = frame.state().get('selection').first(),
link = $el.data('updateLink');
// Tell the browser to navigate to the crop step.
window.location = link + '&file=' + attachment.id;
});
frame.open();
});
});
}(jQuery));

File diff suppressed because it is too large Load Diff

1
wp-admin/js/customize-controls.min.js vendored Normal file

File diff suppressed because one or more lines are too long

117
wp-admin/js/dashboard.js Normal file
View File

@ -0,0 +1,117 @@
var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
jQuery(document).ready( function($) {
/* Dashboard Welcome Panel */
var welcomePanel = $('#welcome-panel'),
welcomePanelHide = $('#wp_welcome_panel-hide'),
updateWelcomePanel = function( visible ) {
$.post( ajaxurl, {
action: 'update-welcome-panel',
visible: visible,
welcomepanelnonce: $('#welcomepanelnonce').val()
});
};
if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') )
welcomePanel.removeClass('hidden');
$('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) {
e.preventDefault();
welcomePanel.addClass('hidden');
updateWelcomePanel( 0 );
$('#wp_welcome_panel-hide').prop('checked', false);
});
welcomePanelHide.click( function() {
welcomePanel.toggleClass('hidden', ! this.checked );
updateWelcomePanel( this.checked ? 1 : 0 );
});
// These widgets are sometimes populated via ajax
ajaxWidgets = [
'dashboard_incoming_links',
'dashboard_primary',
'dashboard_secondary',
'dashboard_plugins'
];
ajaxPopulateWidgets = function(el) {
function show(i, id) {
var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
if ( e.length ) {
p = e.parent();
setTimeout( function(){
p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id, '', function() {
p.hide().slideDown('normal', function(){
$(this).css('display', '');
});
});
}, i * 500 );
}
}
if ( el ) {
el = el.toString();
if ( $.inArray(el, ajaxWidgets) != -1 )
show(0, el);
} else {
$.each( ajaxWidgets, show );
}
};
ajaxPopulateWidgets();
postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
/* QuickPress */
quickPressLoad = function() {
var act = $('#quickpost-action'), t;
t = $('#quick-press').submit( function() {
$('#dashboard_quick_press #publishing-action .spinner').show();
$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
if ( 'post' == act.val() ) {
act.val( 'post-quickpress-publish' );
}
$('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
$('#dashboard_quick_press #publishing-action .spinner').hide();
$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', false);
$('#dashboard_quick_press ul').next('p').remove();
$('#dashboard_quick_press ul').find('li').each( function() {
$('#dashboard_recent_drafts ul').prepend( this );
} ).end().remove();
quickPressLoad();
} );
return false;
} );
$('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
$('#title, #tags-input').each( function() {
var input = $(this), prompt = $('#' + this.id + '-prompt-text');
if ( '' === this.value )
prompt.removeClass('screen-reader-text');
prompt.click( function() {
$(this).addClass('screen-reader-text');
input.focus();
});
input.blur( function() {
if ( '' === this.value )
prompt.removeClass('screen-reader-text');
});
input.focus( function() {
prompt.addClass('screen-reader-text');
});
});
$('#quick-press').on( 'click focusin', function() {
wpActiveEditor = 'content';
});
};
quickPressLoad();
} );

1
wp-admin/js/dashboard.min.js vendored Normal file
View File

@ -0,0 +1 @@
var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(c){var d=c("#welcome-panel"),a=c("#wp_welcome_panel-hide"),b=function(e){c.post(ajaxurl,{action:"update-welcome-panel",visible:e,welcomepanelnonce:c("#welcomepanelnonce").val()})};if(d.hasClass("hidden")&&a.prop("checked")){d.removeClass("hidden")}c(".welcome-panel-close, .welcome-panel-dismiss a",d).click(function(f){f.preventDefault();d.addClass("hidden");b(0);c("#wp_welcome_panel-hide").prop("checked",false)});a.click(function(){d.toggleClass("hidden",!this.checked);b(this.checked?1:0)});ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];ajaxPopulateWidgets=function(f){function e(g,k){var j,h=c("#"+k+" div.inside:visible").find(".widget-loading");if(h.length){j=h.parent();setTimeout(function(){j.load(ajaxurl+"?action=dashboard-widgets&widget="+k,"",function(){j.hide().slideDown("normal",function(){c(this).css("display","")})})},g*500)}}if(f){f=f.toString();if(c.inArray(f,ajaxWidgets)!=-1){e(0,f)}}else{c.each(ajaxWidgets,e)}};ajaxPopulateWidgets();postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var e=c("#quickpost-action"),f;f=c("#quick-press").submit(function(){c("#dashboard_quick_press #publishing-action .spinner").show();c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",true);if("post"==e.val()){e.val("post-quickpress-publish")}c("#dashboard_quick_press div.inside").load(f.attr("action"),f.serializeArray(),function(){c("#dashboard_quick_press #publishing-action .spinner").hide();c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",false);c("#dashboard_quick_press ul").next("p").remove();c("#dashboard_quick_press ul").find("li").each(function(){c("#dashboard_recent_drafts ul").prepend(this)}).end().remove();quickPressLoad()});return false});c("#publish").click(function(){e.val("post-quickpress-publish")});c("#title, #tags-input").each(function(){var h=c(this),g=c("#"+this.id+"-prompt-text");if(""===this.value){g.removeClass("screen-reader-text")}g.click(function(){c(this).addClass("screen-reader-text");h.focus()});h.blur(function(){if(""===this.value){g.removeClass("screen-reader-text")}});h.focus(function(){g.addClass("screen-reader-text")})});c("#quick-press").on("click focusin",function(){wpActiveEditor="content"})};quickPressLoad()});

View File

@ -0,0 +1,607 @@
var theList, theExtraList, toggleWithKeyboard = false;
(function($) {
var getCount, updateCount, updatePending, dashboardTotals;
setCommentsList = function() {
var totalInput, perPageInput, pageInput, lastConfidentTime = 0, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList;
totalInput = $('input[name="_total"]', '#comments-form');
perPageInput = $('input[name="_per_page"]', '#comments-form');
pageInput = $('input[name="_page"]', '#comments-form');
dimAfter = function( r, settings ) {
var c = $('#' + settings.element), editRow, replyID, replyButton;
editRow = $('#replyrow');
replyID = $('#comment_ID', editRow).val();
replyButton = $('#replybtn', editRow);
if ( c.is('.unapproved') ) {
if ( settings.data.id == replyID )
replyButton.text(adminCommentsL10n.replyApprove);
c.find('div.comment_status').html('0');
} else {
if ( settings.data.id == replyID )
replyButton.text(adminCommentsL10n.reply);
c.find('div.comment_status').html('1');
}
var diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
updatePending( diff );
};
// Send current total, page, per_page and url
delBefore = function( settings, list ) {
var wpListsData = $(settings.target).attr('data-wp-lists'), id, el, n, h, a, author, action = false;
settings.data._total = totalInput.val() || 0;
settings.data._per_page = perPageInput.val() || 0;
settings.data._page = pageInput.val() || 0;
settings.data._url = document.location.href;
settings.data.comment_status = $('input[name="comment_status"]', '#comments-form').val();
if ( wpListsData.indexOf(':trash=1') != -1 )
action = 'trash';
else if ( wpListsData.indexOf(':spam=1') != -1 )
action = 'spam';
if ( action ) {
id = wpListsData.replace(/.*?comment-([0-9]+).*/, '$1');
el = $('#comment-' + id);
note = $('#' + action + '-undo-holder').html();
el.find('.check-column :checkbox').prop('checked', false); // Uncheck the row so as not to be affected by Bulk Edits.
if ( el.siblings('#replyrow').length && commentReply.cid == id )
commentReply.close();
if ( el.is('tr') ) {
n = el.children(':visible').length;
author = $('.author strong', el).text();
h = $('<tr id="undo-' + id + '" class="undo un' + action + '" style="display:none;"><td colspan="' + n + '">' + note + '</td></tr>');
} else {
author = $('.comment-author', el).text();
h = $('<div id="undo-' + id + '" style="display:none;" class="undo un' + action + '">' + note + '</div>');
}
el.before(h);
$('strong', '#undo-' + id).text(author);
a = $('.undo a', '#undo-' + id);
a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce);
a.attr('data-wp-lists', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1');
a.attr('class', 'vim-z vim-destructive');
$('.avatar', el).clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
a.click(function(){
list.wpList.del(this);
$('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
$(this).remove();
$('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show() });
});
return false;
});
}
return settings;
};
// Updates the current total (stored in the _total input)
updateTotalCount = function( total, time, setConfidentTime ) {
if ( time < lastConfidentTime )
return;
if ( setConfidentTime )
lastConfidentTime = time;
totalInput.val( total.toString() );
};
dashboardTotals = function(n) {
var dash = $('#dashboard_right_now'), total, appr, totalN, apprN;
n = n || 0;
if ( isNaN(n) || !dash.length )
return;
total = $('span.total-count', dash);
appr = $('span.approved-count', dash);
totalN = getCount(total);
totalN = totalN + n;
apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
updateCount(total, totalN);
updateCount(appr, apprN);
};
getCount = function(el) {
var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
if ( isNaN(n) )
return 0;
return n;
};
updateCount = function(el, n) {
var n1 = '';
if ( isNaN(n) )
return;
n = n < 1 ? '0' : n.toString();
if ( n.length > 3 ) {
while ( n.length > 3 ) {
n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
n = n.substr(0, n.length - 3);
}
n = n + n1;
}
el.html(n);
};
updatePending = function( diff ) {
$('span.pending-count').each(function() {
var a = $(this), n = getCount(a) + diff;
if ( n < 1 )
n = 0;
a.closest('.awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
updateCount( a, n );
});
dashboardTotals();
};
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
delAfter = function( r, settings ) {
var total, N, spam, trash, pending,
untrash = $(settings.target).parent().is('span.untrash'),
unspam = $(settings.target).parent().is('span.unspam'),
unapproved = $('#' + settings.element).is('.unapproved');
function getUpdate(s) {
if ( $(settings.target).parent().is('span.' + s) )
return 1;
else if ( $('#' + settings.element).is('.' + s) )
return -1;
return 0;
}
if ( untrash )
trash = -1;
else
trash = getUpdate('trash');
if ( unspam )
spam = -1;
else
spam = getUpdate('spam');
if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) {
// a comment was 'deleted' from another list (e.g. approved, spam, trash) and moved to pending,
// or a trash/spam of a pending comment was undone
pending = 1;
} else if ( unapproved ) {
// a pending comment was trashed/spammed/approved
pending = -1;
}
if ( pending )
updatePending(pending);
$('span.spam-count').each( function() {
var a = $(this), n = getCount(a) + spam;
updateCount(a, n);
});
$('span.trash-count').each( function() {
var a = $(this), n = getCount(a) + trash;
updateCount(a, n);
});
if ( $('#dashboard_right_now').length ) {
N = trash ? -1 * trash : 0;
dashboardTotals(N);
} else {
total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0;
if ( $(settings.target).parent().is('span.undo') )
total++;
else
total--;
if ( total < 0 )
total = 0;
if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || '';
if ( total_items_i18n ) {
$('.displaying-num').text( total_items_i18n );
$('.total-pages').text( settings.parsed.responses[0].supplemental.total_pages_i18n );
$('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', settings.parsed.responses[0].supplemental.total_pages == $('.current-page').val());
}
updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );
} else {
updateTotalCount( total, r, false );
}
}
if ( ! theExtraList || theExtraList.size() == 0 || theExtraList.children().size() == 0 || untrash || unspam ) {
return;
}
theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
refillTheExtraList();
};
refillTheExtraList = function(ev) {
var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name="_per_page"]', '#comments-form').val();
if (! args.paged)
args.paged = 1;
if (args.paged > total_pages) {
return;
}
if (ev) {
theExtraList.empty();
args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php
} else {
args.number = 1;
args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list
}
args.no_placeholder = true;
args.paged ++;
// $.query.get() needs some correction to be sent into an ajax request
if ( true === args.comment_type )
args.comment_type = '';
args = $.extend(args, {
'action': 'fetch-list',
'list_args': list_args,
'_ajax_fetch_list_nonce': $('#_ajax_fetch_list_nonce').val()
});
$.ajax({
url: ajaxurl,
global: false,
dataType: 'json',
data: args,
success: function(response) {
theExtraList.get(0).wpList.add( response.rows );
}
});
};
theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )
.bind('wpListDelEnd', function(e, s){
var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, '');
if ( wpListsData.indexOf(':trash=1') != -1 || wpListsData.indexOf(':spam=1') != -1 )
$('#undo-' + id).fadeIn(300, function(){ $(this).show() });
});
};
commentReply = {
cid : '',
act : '',
init : function() {
var row = $('#replyrow');
$('a.cancel', row).click(function() { return commentReply.revert(); });
$('a.save', row).click(function() { return commentReply.send(); });
$('input#author, input#author-email, input#author-url', row).keypress(function(e){
if ( e.which == 13 ) {
commentReply.send();
e.preventDefault();
return false;
}
});
// add events
$('#the-comment-list .column-comment > p').dblclick(function(){
commentReply.toggle($(this).parent());
});
$('#doaction, #doaction2, #post-query-submit').click(function(e){
if ( $('#the-comment-list #replyrow').length > 0 )
commentReply.close();
});
this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || '';
/* $(listTable).bind('beforeChangePage', function(){
commentReply.close();
}); */
},
addEvents : function(r) {
r.each(function() {
$(this).find('.column-comment > p').dblclick(function(){
commentReply.toggle($(this).parent());
});
});
},
toggle : function(el) {
if ( $(el).css('display') != 'none' )
$(el).find('a.vim-q').click();
},
revert : function() {
if ( $('#the-comment-list #replyrow').length < 1 )
return false;
$('#replyrow').fadeOut('fast', function(){
commentReply.close();
});
return false;
},
close : function() {
var c, replyrow = $('#replyrow');
// replyrow is not showing?
if ( replyrow.parent().is('#com-reply') )
return;
if ( this.cid && this.act == 'edit-comment' ) {
c = $('#comment-' + this.cid);
c.fadeIn(300, function(){ c.show() }).css('backgroundColor', '');
}
// reset the Quicktags buttons
if ( typeof QTags != 'undefined' )
QTags.closeAllTags('replycontent');
$('#add-new-comment').css('display', '');
replyrow.hide();
$('#com-reply').append( replyrow );
$('#replycontent').css('height', '').val('');
$('#edithead input').val('');
$('.error', replyrow).html('').hide();
$('.spinner', replyrow).hide();
this.cid = '';
},
open : function(comment_id, post_id, action) {
var t = this, editRow, rowData, act, c = $('#comment-' + comment_id), h = c.height(), replyButton;
t.close();
t.cid = comment_id;
editRow = $('#replyrow');
rowData = $('#inline-'+comment_id);
action = action || 'replyto';
act = 'edit' == action ? 'edit' : 'replyto';
act = t.act = act + '-comment';
$('#action', editRow).val(act);
$('#comment_post_ID', editRow).val(post_id);
$('#comment_ID', editRow).val(comment_id);
if ( h > 120 )
$('#replycontent', editRow).css('height', (35+h) + 'px');
if ( action == 'edit' ) {
$('#author', editRow).val( $('div.author', rowData).text() );
$('#author-email', editRow).val( $('div.author-email', rowData).text() );
$('#author-url', editRow).val( $('div.author-url', rowData).text() );
$('#status', editRow).val( $('div.comment_status', rowData).text() );
$('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
$('#edithead, #savebtn', editRow).show();
$('#replyhead, #replybtn, #addhead, #addbtn', editRow).hide();
c.after( editRow ).fadeOut('fast', function(){
$('#replyrow').fadeIn(300, function(){ $(this).show() });
});
} else if ( action == 'add' ) {
$('#addhead, #addbtn', editRow).show();
$('#replyhead, #replybtn, #edithead, #editbtn', editRow).hide();
$('#the-comment-list').prepend(editRow);
$('#replyrow').fadeIn(300);
} else {
replyButton = $('#replybtn', editRow);
$('#edithead, #savebtn, #addhead, #addbtn', editRow).hide();
$('#replyhead, #replybtn', editRow).show();
c.after(editRow);
if ( c.hasClass('unapproved') ) {
replyButton.text(adminCommentsL10n.replyApprove);
} else {
replyButton.text(adminCommentsL10n.reply);
}
$('#replyrow').fadeIn(300, function(){ $(this).show() });
}
setTimeout(function() {
var rtop, rbottom, scrollTop, vp, scrollBottom;
rtop = $('#replyrow').offset().top;
rbottom = rtop + $('#replyrow').height();
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
vp = document.documentElement.clientHeight || self.innerHeight || 0;
scrollBottom = scrollTop + vp;
if ( scrollBottom - 20 < rbottom )
window.scroll(0, rbottom - vp + 35);
else if ( rtop - 20 < scrollTop )
window.scroll(0, rtop - 35);
$('#replycontent').focus().keyup(function(e){
if ( e.which == 27 )
commentReply.revert(); // close on Escape
});
}, 600);
return false;
},
send : function() {
var post = {};
$('#replysubmit .error').hide();
$('#replysubmit .spinner').show();
$('#replyrow input').not(':button').each(function() {
var t = $(this);
post[ t.attr('name') ] = t.val();
});
post.content = $('#replycontent').val();
post.id = post.comment_post_ID;
post.comments_listing = this.comments_listing;
post.p = $('[name="p"]').val();
if ( $('#comment-' + $('#comment_ID').val()).hasClass('unapproved') )
post.approve_parent = 1;
$.ajax({
type : 'POST',
url : ajaxurl,
data : post,
success : function(x) { commentReply.show(x); },
error : function(r) { commentReply.error(r); }
});
return false;
},
show : function(xml) {
var t = this, r, c, id, bg, pid;
if ( typeof(xml) == 'string' ) {
t.error({'responseText': xml});
return false;
}
r = wpAjax.parseAjaxResponse(xml);
if ( r.errors ) {
t.error({'responseText': wpAjax.broken});
return false;
}
t.revert();
r = r.responses[0];
c = r.data;
id = '#comment-' + r.id;
if ( 'edit-comment' == t.act )
$(id).remove();
if ( r.supplemental.parent_approved ) {
pid = $('#comment-' + r.supplemental.parent_approved);
updatePending( -1 );
if ( this.comments_listing == 'moderated' ) {
pid.animate( { 'backgroundColor':'#CCEEBB' }, 400, function(){
pid.fadeOut();
});
return;
}
}
$(c).hide()
$('#replyrow').after(c);
id = $(id);
t.addEvents(id);
bg = id.hasClass('unapproved') ? '#FFFFE0' : id.closest('.widefat, .postbox').css('backgroundColor');
id.animate( { 'backgroundColor':'#CCEEBB' }, 300 )
.animate( { 'backgroundColor': bg }, 300, function() {
if ( pid && pid.length ) {
pid.animate( { 'backgroundColor':'#CCEEBB' }, 300 )
.animate( { 'backgroundColor': bg }, 300 )
.removeClass('unapproved').addClass('approved')
.find('div.comment_status').html('1');
}
});
},
error : function(r) {
var er = r.statusText;
$('#replysubmit .spinner').hide();
if ( r.responseText )
er = r.responseText.replace( /<.[^<>]*?>/g, '' );
if ( er )
$('#replysubmit .error').html(er).show();
},
addcomment: function(post_id) {
var t = this;
$('#add-new-comment').fadeOut(200, function(){
t.open(0, post_id, 'add');
$('table.comments-box').css('display', '');
$('#no-comments').remove();
});
}
};
$(document).ready(function(){
var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk;
setCommentsList();
commentReply.init();
$(document).delegate('span.delete a.delete', 'click', function(){return false;});
if ( typeof $.table_hotkeys != 'undefined' ) {
make_hotkeys_redirect = function(which) {
return function() {
var first_last, l;
first_last = 'next' == which? 'first' : 'last';
l = $('.tablenav-pages .'+which+'-page:not(.disabled)');
if (l.length)
window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
}
};
edit_comment = function(event, current_row) {
window.location = $('span.edit a', current_row).attr('href');
};
toggle_all = function() {
toggleWithKeyboard = true;
$('input:checkbox', '#cb').click().prop('checked', false);
toggleWithKeyboard = false;
};
make_bulk = function(value) {
return function() {
var scope = $('select[name="action"]');
$('option[value="' + value + '"]', scope).prop('selected', true);
$('#doaction').click();
}
};
$.table_hotkeys(
$('table.widefat'),
['a', 'u', 's', 'd', 'r', 'q', 'z', ['e', edit_comment], ['shift+x', toggle_all],
['shift+a', make_bulk('approve')], ['shift+s', make_bulk('spam')],
['shift+d', make_bulk('delete')], ['shift+t', make_bulk('trash')],
['shift+z', make_bulk('untrash')], ['shift+u', make_bulk('unapprove')]],
{ highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next') }
);
}
});
})(jQuery);

1
wp-admin/js/edit-comments.min.js vendored Normal file

File diff suppressed because one or more lines are too long

238
wp-admin/js/editor.js Normal file
View File

@ -0,0 +1,238 @@
var switchEditors = {
switchto: function(el) {
var aid = el.id, l = aid.length, id = aid.substr(0, l - 5), mode = aid.substr(l - 4);
this.go(id, mode);
},
go: function(id, mode) { // mode can be 'html', 'tmce', or 'toggle'; 'html' is used for the "Text" editor tab.
id = id || 'content';
mode = mode || 'toggle';
var t = this, ed = tinyMCE.get(id), wrap_id, txtarea_el, dom = tinymce.DOM;
wrap_id = 'wp-'+id+'-wrap';
txtarea_el = dom.get(id);
if ( 'toggle' == mode ) {
if ( ed && !ed.isHidden() )
mode = 'html';
else
mode = 'tmce';
}
if ( 'tmce' == mode || 'tinymce' == mode ) {
if ( ed && ! ed.isHidden() )
return false;
if ( typeof(QTags) != 'undefined' )
QTags.closeAllTags(id);
if ( tinyMCEPreInit.mceInit[id] && tinyMCEPreInit.mceInit[id].wpautop )
txtarea_el.value = t.wpautop( txtarea_el.value );
if ( ed ) {
ed.show();
} else {
ed = new tinymce.Editor(id, tinyMCEPreInit.mceInit[id]);
ed.render();
}
dom.removeClass(wrap_id, 'html-active');
dom.addClass(wrap_id, 'tmce-active');
setUserSetting('editor', 'tinymce');
} else if ( 'html' == mode ) {
if ( ed && ed.isHidden() )
return false;
if ( ed )
ed.hide();
dom.removeClass(wrap_id, 'tmce-active');
dom.addClass(wrap_id, 'html-active');
setUserSetting('editor', 'html');
}
return false;
},
_wp_Nop : function(content) {
var blocklist1, blocklist2, preserve_linebreaks = false, preserve_br = false;
// Protect pre|script tags
if ( content.indexOf('<pre') != -1 || content.indexOf('<script') != -1 ) {
preserve_linebreaks = true;
content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-temp-lb>');
return a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-temp-lb>');
});
}
// keep <br> tags inside captions and remove line breaks
if ( content.indexOf('[caption') != -1 ) {
preserve_br = true;
content = content.replace(/\[caption[\s\S]+?\[\/caption\]/g, function(a) {
return a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>').replace(/[\r\n\t]+/, '');
});
}
// Pretty it up for the source editor
blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset';
content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'g'), '</$1>\n');
content = content.replace(new RegExp('\\s*<((?:'+blocklist1+')(?: [^>]*)?)>', 'g'), '\n<$1>');
// Mark </p> if it has any attributes.
content = content.replace(/(<p [^>]+>.*?)<\/p>/g, '$1</p#>');
// Sepatate <div> containing <p>
content = content.replace(/<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n');
// Remove <p> and <br />
content = content.replace(/\s*<p>/gi, '');
content = content.replace(/\s*<\/p>\s*/gi, '\n\n');
content = content.replace(/\n[\s\u00a0]+\n/g, '\n\n');
content = content.replace(/\s*<br ?\/?>\s*/gi, '\n');
// Fix some block element newline issues
content = content.replace(/\s*<div/g, '\n<div');
content = content.replace(/<\/div>\s*/g, '</div>\n');
content = content.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n');
content = content.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption');
blocklist2 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset';
content = content.replace(new RegExp('\\s*<((?:'+blocklist2+')(?: [^>]*)?)\\s*>', 'g'), '\n<$1>');
content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'g'), '</$1>\n');
content = content.replace(/<li([^>]*)>/g, '\t<li$1>');
if ( content.indexOf('<hr') != -1 ) {
content = content.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
}
if ( content.indexOf('<object') != -1 ) {
content = content.replace(/<object[\s\S]+?<\/object>/g, function(a){
return a.replace(/[\r\n]+/g, '');
});
}
// Unmark special paragraph closing tags
content = content.replace(/<\/p#>/g, '</p>\n');
content = content.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1');
// Trim whitespace
content = content.replace(/^\s+/, '');
content = content.replace(/[\s\u00a0]+$/, '');
// put back the line breaks in pre|script
if ( preserve_linebreaks )
content = content.replace(/<wp-temp-lb>/g, '\n');
// and the <br> tags in captions
if ( preserve_br )
content = content.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
return content;
},
_wp_Autop : function(pee) {
var preserve_linebreaks = false, preserve_br = false,
blocklist = 'table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|noscript|samp|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary';
if ( pee.indexOf('<object') != -1 ) {
pee = pee.replace(/<object[\s\S]+?<\/object>/g, function(a){
return a.replace(/[\r\n]+/g, '');
});
}
pee = pee.replace(/<[^<>]+>/g, function(a){
return a.replace(/[\r\n]+/g, ' ');
});
// Protect pre|script tags
if ( pee.indexOf('<pre') != -1 || pee.indexOf('<script') != -1 ) {
preserve_linebreaks = true;
pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
return a.replace(/(\r\n|\n)/g, '<wp-temp-lb>');
});
}
// keep <br> tags inside captions and convert line breaks
if ( pee.indexOf('[caption') != -1 ) {
preserve_br = true;
pee = pee.replace(/\[caption[\s\S]+?\[\/caption\]/g, function(a) {
// keep existing <br>
a = a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>');
// no line breaks inside HTML tags
a = a.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(b){
return b.replace(/[\r\n\t]+/, ' ');
});
// convert remaining line breaks to <br>
return a.replace(/\s*\n\s*/g, '<wp-temp-br />');
});
}
pee = pee + '\n\n';
pee = pee.replace(/<br \/>\s*<br \/>/gi, '\n\n');
pee = pee.replace(new RegExp('(<(?:'+blocklist+')(?: [^>]*)?>)', 'gi'), '\n$1');
pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), '$1\n\n');
pee = pee.replace(/<hr( [^>]*)?>/gi, '<hr$1>\n\n'); // hr is self closing block element
pee = pee.replace(/\r\n|\r/g, '\n');
pee = pee.replace(/\n\s*\n+/g, '\n\n');
pee = pee.replace(/([\s\S]+?)\n\n/g, '<p>$1</p>\n');
pee = pee.replace(/<p>\s*?<\/p>/gi, '');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')(?: [^>]*)?>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(/<p>(<li.+?)<\/p>/gi, '$1');
pee = pee.replace(/<p>\s*<blockquote([^>]*)>/gi, '<blockquote$1><p>');
pee = pee.replace(/<\/blockquote>\s*<\/p>/gi, '</p></blockquote>');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')(?: [^>]*)?>)', 'gi'), "$1");
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')(?: [^>]*)?>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(/\s*\n/gi, '<br />\n');
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
pee = pee.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi, '$1');
pee = pee.replace(/(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi, '[caption$1[/caption]');
pee = pee.replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g, function(a, b, c) {
if ( c.match(/<p( [^>]*)?>/) )
return a;
return b + '<p>' + c + '</p>';
});
// put back the line breaks in pre|script
if ( preserve_linebreaks )
pee = pee.replace(/<wp-temp-lb>/g, '\n');
if ( preserve_br )
pee = pee.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
return pee;
},
pre_wpautop : function(content) {
var t = this, o = { o: t, data: content, unfiltered: content },
q = typeof(jQuery) != 'undefined';
if ( q )
jQuery('body').trigger('beforePreWpautop', [o]);
o.data = t._wp_Nop(o.data);
if ( q )
jQuery('body').trigger('afterPreWpautop', [o]);
return o.data;
},
wpautop : function(pee) {
var t = this, o = { o: t, data: pee, unfiltered: pee },
q = typeof(jQuery) != 'undefined';
if ( q )
jQuery('body').trigger('beforeWpautop', [o]);
o.data = t._wp_Autop(o.data);
if ( q )
jQuery('body').trigger('afterWpautop', [o]);
return o.data;
}
}

1
wp-admin/js/editor.min.js vendored Normal file

File diff suppressed because one or more lines are too long

276
wp-admin/js/farbtastic.js Normal file
View File

@ -0,0 +1,276 @@
/*!
* Farbtastic: jQuery color picker plug-in v1.3u
*
* Licensed under the GPL license:
* http://www.gnu.org/licenses/gpl.html
*/
(function($) {
$.fn.farbtastic = function (options) {
$.farbtastic(this, options);
return this;
};
$.farbtastic = function (container, callback) {
var container = $(container).get(0);
return container.farbtastic || (container.farbtastic = new $._farbtastic(container, callback));
};
$._farbtastic = function (container, callback) {
// Store farbtastic object
var fb = this;
// Insert markup
$(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
var e = $('.farbtastic', container);
fb.wheel = $('.wheel', container).get(0);
// Dimensions
fb.radius = 84;
fb.square = 100;
fb.width = 194;
// Fix background PNGs in IE6
if (navigator.appVersion.match(/MSIE [0-6]\./)) {
$('*', e).each(function () {
if (this.currentStyle.backgroundImage != 'none') {
var image = this.currentStyle.backgroundImage;
image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
$(this).css({
'backgroundImage': 'none',
'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
});
}
});
}
/**
* Link to the given element(s) or callback.
*/
fb.linkTo = function (callback) {
// Unbind previous nodes
if (typeof fb.callback == 'object') {
$(fb.callback).unbind('keyup', fb.updateValue);
}
// Reset color
fb.color = null;
// Bind callback or elements
if (typeof callback == 'function') {
fb.callback = callback;
}
else if (typeof callback == 'object' || typeof callback == 'string') {
fb.callback = $(callback);
fb.callback.bind('keyup', fb.updateValue);
if (fb.callback.get(0).value) {
fb.setColor(fb.callback.get(0).value);
}
}
return this;
};
fb.updateValue = function (event) {
if (this.value && this.value != fb.color) {
fb.setColor(this.value);
}
};
/**
* Change color with HTML syntax #123456
*/
fb.setColor = function (color) {
var unpack = fb.unpack(color);
if (fb.color != color && unpack) {
fb.color = color;
fb.rgb = unpack;
fb.hsl = fb.RGBToHSL(fb.rgb);
fb.updateDisplay();
}
return this;
};
/**
* Change color with HSL triplet [0..1, 0..1, 0..1]
*/
fb.setHSL = function (hsl) {
fb.hsl = hsl;
fb.rgb = fb.HSLToRGB(hsl);
fb.color = fb.pack(fb.rgb);
fb.updateDisplay();
return this;
};
/////////////////////////////////////////////////////
/**
* Retrieve the coordinates of the given event relative to the center
* of the widget.
*/
fb.widgetCoords = function (event) {
var offset = $(fb.wheel).offset();
return { x: (event.pageX - offset.left) - fb.width / 2, y: (event.pageY - offset.top) - fb.width / 2 };
};
/**
* Mousedown handler
*/
fb.mousedown = function (event) {
// Capture mouse
if (!document.dragging) {
$(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
document.dragging = true;
}
// Check which area is being dragged
var pos = fb.widgetCoords(event);
fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
// Process
fb.mousemove(event);
return false;
};
/**
* Mousemove handler
*/
fb.mousemove = function (event) {
// Get coordinates relative to color picker center
var pos = fb.widgetCoords(event);
// Set new HSL parameters
if (fb.circleDrag) {
var hue = Math.atan2(pos.x, -pos.y) / 6.28;
if (hue < 0) hue += 1;
fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
}
else {
var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
fb.setHSL([fb.hsl[0], sat, lum]);
}
return false;
};
/**
* Mouseup handler
*/
fb.mouseup = function () {
// Uncapture mouse
$(document).unbind('mousemove', fb.mousemove);
$(document).unbind('mouseup', fb.mouseup);
document.dragging = false;
};
/**
* Update the markers and styles
*/
fb.updateDisplay = function () {
// Markers
var angle = fb.hsl[0] * 6.28;
$('.h-marker', e).css({
left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
});
$('.sl-marker', e).css({
left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
});
// Saturation/Luminance gradient
$('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
// Linked elements or callback
if (typeof fb.callback == 'object') {
// Set background/foreground color
$(fb.callback).css({
backgroundColor: fb.color,
color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
});
// Change linked value
$(fb.callback).each(function() {
if (this.value && this.value != fb.color) {
this.value = fb.color;
}
});
}
else if (typeof fb.callback == 'function') {
fb.callback.call(fb, fb.color);
}
};
/* Various color utility functions */
fb.pack = function (rgb) {
var r = Math.round(rgb[0] * 255);
var g = Math.round(rgb[1] * 255);
var b = Math.round(rgb[2] * 255);
return '#' + (r < 16 ? '0' : '') + r.toString(16) +
(g < 16 ? '0' : '') + g.toString(16) +
(b < 16 ? '0' : '') + b.toString(16);
};
fb.unpack = function (color) {
if (color.length == 7) {
return [parseInt('0x' + color.substring(1, 3)) / 255,
parseInt('0x' + color.substring(3, 5)) / 255,
parseInt('0x' + color.substring(5, 7)) / 255];
}
else if (color.length == 4) {
return [parseInt('0x' + color.substring(1, 2)) / 15,
parseInt('0x' + color.substring(2, 3)) / 15,
parseInt('0x' + color.substring(3, 4)) / 15];
}
};
fb.HSLToRGB = function (hsl) {
var m1, m2, r, g, b;
var h = hsl[0], s = hsl[1], l = hsl[2];
m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
m1 = l * 2 - m2;
return [this.hueToRGB(m1, m2, h+0.33333),
this.hueToRGB(m1, m2, h),
this.hueToRGB(m1, m2, h-0.33333)];
};
fb.hueToRGB = function (m1, m2, h) {
h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
if (h * 2 < 1) return m2;
if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
return m1;
};
fb.RGBToHSL = function (rgb) {
var min, max, delta, h, s, l;
var r = rgb[0], g = rgb[1], b = rgb[2];
min = Math.min(r, Math.min(g, b));
max = Math.max(r, Math.max(g, b));
delta = max - min;
l = (min + max) / 2;
s = 0;
if (l > 0 && l < 1) {
s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
}
h = 0;
if (delta > 0) {
if (max == r && max != g) h += (g - b) / delta;
if (max == g && max != b) h += (2 + (b - r) / delta);
if (max == b && max != r) h += (4 + (r - g) / delta);
h /= 6;
}
return [h, s, l];
};
// Install mousedown handler (the others are set on the document on-demand)
$('*', e).mousedown(fb.mousedown);
// Init color
fb.setColor('#000000');
// Set linked elements/callback
if (callback) {
fb.linkTo(callback);
}
};
})(jQuery);

199
wp-admin/js/gallery.js Normal file
View File

@ -0,0 +1,199 @@
jQuery(document).ready(function($) {
var gallerySortable, gallerySortableInit, w, desc = false;
gallerySortableInit = function() {
gallerySortable = $('#media-items').sortable( {
items: 'div.media-item',
placeholder: 'sorthelper',
axis: 'y',
distance: 2,
handle: 'div.filename',
stop: function(e, ui) {
// When an update has occurred, adjust the order for each item
var all = $('#media-items').sortable('toArray'), len = all.length;
$.each(all, function(i, id) {
var order = desc ? (len - i) : (1 + i);
$('#' + id + ' .menu_order input').val(order);
});
}
} );
}
sortIt = function() {
var all = $('.menu_order_input'), len = all.length;
all.each(function(i){
var order = desc ? (len - i) : (1 + i);
$(this).val(order);
});
}
clearAll = function(c) {
c = c || 0;
$('.menu_order_input').each(function(){
if ( this.value == '0' || c ) this.value = '';
});
}
$('#asc').click(function(){desc = false; sortIt(); return false;});
$('#desc').click(function(){desc = true; sortIt(); return false;});
$('#clear').click(function(){clearAll(1); return false;});
$('#showall').click(function(){
$('#sort-buttons span a').toggle();
$('a.describe-toggle-on').hide();
$('a.describe-toggle-off, table.slidetoggle').show();
$('img.pinkynail').toggle(false);
return false;
});
$('#hideall').click(function(){
$('#sort-buttons span a').toggle();
$('a.describe-toggle-on').show();
$('a.describe-toggle-off, table.slidetoggle').hide();
$('img.pinkynail').toggle(true);
return false;
});
// initialize sortable
gallerySortableInit();
clearAll();
if ( $('#media-items>*').length > 1 ) {
w = wpgallery.getWin();
$('#save-all, #gallery-settings').show();
if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
wpgallery.mcemode = true;
wpgallery.init();
} else {
$('#insert-gallery').show();
}
}
});
jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup
/* gallery settings */
var tinymce = null, tinyMCE, wpgallery;
wpgallery = {
mcemode : false,
editor : {},
dom : {},
is_update : false,
el : {},
I : function(e) {
return document.getElementById(e);
},
init: function() {
var t = this, li, q, i, it, w = t.getWin();
if ( ! t.mcemode ) return;
li = ('' + document.location.search).replace(/^\?/, '').split('&');
q = {};
for (i=0; i<li.length; i++) {
it = li[i].split('=');
q[unescape(it[0])] = unescape(it[1]);
}
if (q.mce_rdomain)
document.domain = q.mce_rdomain;
// Find window & API
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.setup();
},
getWin : function() {
return window.dialogArguments || opener || parent || top;
},
setup : function() {
var t = this, a, ed = t.editor, g, columns, link, order, orderby;
if ( ! t.mcemode ) return;
t.el = ed.selection.getNode();
if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
t.el = g[0];
} else {
if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
jQuery('#insert-gallery').show();
return;
}
}
a = ed.dom.getAttrib(t.el, 'title');
a = ed.dom.decode(a);
if ( a ) {
jQuery('#update-gallery').show();
t.is_update = true;
columns = a.match(/columns=['"]([0-9]+)['"]/);
link = a.match(/link=['"]([^'"]+)['"]/i);
order = a.match(/order=['"]([^'"]+)['"]/i);
orderby = a.match(/orderby=['"]([^'"]+)['"]/i);
if ( link && link[1] ) t.I('linkto-file').checked = "checked";
if ( order && order[1] ) t.I('order-desc').checked = "checked";
if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
} else {
jQuery('#insert-gallery').show();
}
},
update : function() {
var t = this, ed = t.editor, all = '', s;
if ( ! t.mcemode || ! t.is_update ) {
s = '[gallery'+t.getSettings()+']';
t.getWin().send_to_editor(s);
return;
}
if (t.el.nodeName != 'IMG') return;
all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
all += t.getSettings();
ed.dom.setAttrib(t.el, 'title', all);
t.getWin().tb_remove();
},
getSettings : function() {
var I = this.I, s = '';
if ( I('linkto-file').checked ) {
s += ' link="file"';
setUserSetting('galfile', '1');
}
if ( I('order-desc').checked ) {
s += ' order="DESC"';
setUserSetting('galdesc', '1');
}
if ( I('columns').value != 3 ) {
s += ' columns="'+I('columns').value+'"';
setUserSetting('galcols', I('columns').value);
}
if ( I('orderby').value != 'menu_order' ) {
s += ' orderby="'+I('orderby').value+'"';
setUserSetting('galord', I('orderby').value);
}
return s;
}
};

1
wp-admin/js/gallery.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(c){var b,e,a,d=false;e=function(){b=c("#media-items").sortable({items:"div.media-item",placeholder:"sorthelper",axis:"y",distance:2,handle:"div.filename",stop:function(i,h){var g=c("#media-items").sortable("toArray"),f=g.length;c.each(g,function(k,l){var j=d?(f-k):(1+k);c("#"+l+" .menu_order input").val(j)})}})};sortIt=function(){var g=c(".menu_order_input"),f=g.length;g.each(function(j){var h=d?(f-j):(1+j);c(this).val(h)})};clearAll=function(f){f=f||0;c(".menu_order_input").each(function(){if(this.value=="0"||f){this.value=""}})};c("#asc").click(function(){d=false;sortIt();return false});c("#desc").click(function(){d=true;sortIt();return false});c("#clear").click(function(){clearAll(1);return false});c("#showall").click(function(){c("#sort-buttons span a").toggle();c("a.describe-toggle-on").hide();c("a.describe-toggle-off, table.slidetoggle").show();c("img.pinkynail").toggle(false);return false});c("#hideall").click(function(){c("#sort-buttons span a").toggle();c("a.describe-toggle-on").show();c("a.describe-toggle-off, table.slidetoggle").hide();c("img.pinkynail").toggle(true);return false});e();clearAll();if(c("#media-items>*").length>1){a=wpgallery.getWin();c("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{c("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.setup()},getWin:function(){return window.dialogArguments||opener||parent||top},setup:function(){var f=this,c,d=f.editor,i,e,h,b,j;if(!f.mcemode){return}f.el=d.selection.getNode();if(f.el.nodeName!="IMG"||!d.dom.hasClass(f.el,"wpGallery")){if((i=d.dom.select("img.wpGallery"))&&i[0]){f.el=i[0]}else{if(getUserSetting("galfile")=="1"){f.I("linkto-file").checked="checked"}if(getUserSetting("galdesc")=="1"){f.I("order-desc").checked="checked"}if(getUserSetting("galcols")){f.I("columns").value=getUserSetting("galcols")}if(getUserSetting("galord")){f.I("orderby").value=getUserSetting("galord")}jQuery("#insert-gallery").show();return}}c=d.dom.getAttrib(f.el,"title");c=d.dom.decode(c);if(c){jQuery("#update-gallery").show();f.is_update=true;e=c.match(/columns=['"]([0-9]+)['"]/);h=c.match(/link=['"]([^'"]+)['"]/i);b=c.match(/order=['"]([^'"]+)['"]/i);j=c.match(/orderby=['"]([^'"]+)['"]/i);if(h&&h[1]){f.I("linkto-file").checked="checked"}if(b&&b[1]){f.I("order-desc").checked="checked"}if(e&&e[1]){f.I("columns").value=""+e[1]}if(j&&j[1]){f.I("orderby").value=j[1]}}else{jQuery("#insert-gallery").show()}},update:function(){var b=this,a=b.editor,d="",c;if(!b.mcemode||!b.is_update){c="[gallery"+b.getSettings()+"]";b.getWin().send_to_editor(c);return}if(b.el.nodeName!="IMG"){return}d=a.dom.decode(a.dom.getAttrib(b.el,"title"));d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,"");d+=b.getSettings();a.dom.setAttrib(b.el,"title",d);b.getWin().tb_remove()},getSettings:function(){var a=this.I,b="";if(a("linkto-file").checked){b+=' link="file"';setUserSetting("galfile","1")}if(a("order-desc").checked){b+=' order="DESC"';setUserSetting("galdesc","1")}if(a("columns").value!=3){b+=' columns="'+a("columns").value+'"';setUserSetting("galcols",a("columns").value)}if(a("orderby").value!="menu_order"){b+=' orderby="'+a("orderby").value+'"';setUserSetting("galord",a("orderby").value)}return b}};

573
wp-admin/js/image-edit.js Normal file
View File

@ -0,0 +1,573 @@
var imageEdit;
(function($) {
imageEdit = {
iasapi : {},
hold : {},
postid : '',
intval : function(f) {
return f | 0;
},
setDisabled : function(el, s) {
if ( s ) {
el.removeClass('disabled');
$('input', el).removeAttr('disabled');
} else {
el.addClass('disabled');
$('input', el).prop('disabled', true);
}
},
init : function(postid, nonce) {
var t = this, old = $('#image-editor-' + t.postid),
x = t.intval( $('#imgedit-x-' + postid).val() ),
y = t.intval( $('#imgedit-y-' + postid).val() );
if ( t.postid != postid && old.length )
t.close(t.postid);
t.hold['w'] = t.hold['ow'] = x;
t.hold['h'] = t.hold['oh'] = y;
t.hold['xy_ratio'] = x / y;
t.hold['sizer'] = parseFloat( $('#imgedit-sizer-' + postid).val() );
t.postid = postid;
$('#imgedit-response-' + postid).empty();
$('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) {
var k = e.keyCode;
if ( 36 < k && k < 41 )
$(this).blur()
if ( 13 == k ) {
e.preventDefault();
e.stopPropagation();
return false;
}
});
},
toggleEditor : function(postid, toggle) {
var wait = $('#imgedit-wait-' + postid);
if ( toggle )
wait.height( $('#imgedit-panel-' + postid).height() ).fadeIn('fast');
else
wait.fadeOut('fast');
},
toggleHelp : function(el) {
$(el).siblings('.imgedit-help').slideToggle('fast');
return false;
},
getTarget : function(postid) {
return $('input[name="imgedit-target-' + postid + '"]:checked', '#imgedit-save-target-' + postid).val() || 'full';
},
scaleChanged : function(postid, x) {
var w = $('#imgedit-scale-width-' + postid), h = $('#imgedit-scale-height-' + postid),
warn = $('#imgedit-scale-warn-' + postid), w1 = '', h1 = '';
if ( x ) {
h1 = (w.val() != '') ? Math.round( w.val() / this.hold['xy_ratio'] ) : '';
h.val( h1 );
} else {
w1 = (h.val() != '') ? Math.round( h.val() * this.hold['xy_ratio'] ) : '';
w.val( w1 );
}
if ( ( h1 && h1 > this.hold['oh'] ) || ( w1 && w1 > this.hold['ow'] ) )
warn.css('visibility', 'visible');
else
warn.css('visibility', 'hidden');
},
getSelRatio : function(postid) {
var x = this.hold['w'], y = this.hold['h'],
X = this.intval( $('#imgedit-crop-width-' + postid).val() ),
Y = this.intval( $('#imgedit-crop-height-' + postid).val() );
if ( X && Y )
return X + ':' + Y;
if ( x && y )
return x + ':' + y;
return '1:1';
},
filterHistory : function(postid, setSize) {
// apply undo state to history
var history = $('#imgedit-history-' + postid).val(), pop, n, o, i, op = [];
if ( history != '' ) {
history = JSON.parse(history);
pop = this.intval( $('#imgedit-undone-' + postid).val() );
if ( pop > 0 ) {
while ( pop > 0 ) {
history.pop();
pop--;
}
}
if ( setSize ) {
if ( !history.length ) {
this.hold['w'] = this.hold['ow'];
this.hold['h'] = this.hold['oh'];
return '';
}
// restore
o = history[history.length - 1];
o = o.c || o.r || o.f || false;
if ( o ) {
this.hold['w'] = o.fw;
this.hold['h'] = o.fh;
}
}
// filter the values
for ( n in history ) {
i = history[n];
if ( i.hasOwnProperty('c') ) {
op[n] = { 'c': { 'x': i.c.x, 'y': i.c.y, 'w': i.c.w, 'h': i.c.h } };
} else if ( i.hasOwnProperty('r') ) {
op[n] = { 'r': i.r.r };
} else if ( i.hasOwnProperty('f') ) {
op[n] = { 'f': i.f.f };
}
}
return JSON.stringify(op);
}
return '';
},
refreshEditor : function(postid, nonce, callback) {
var t = this, data, img;
t.toggleEditor(postid, 1);
data = {
'action': 'imgedit-preview',
'_ajax_nonce': nonce,
'postid': postid,
'history': t.filterHistory(postid, 1),
'rand': t.intval(Math.random() * 1000000)
};
img = $('<img id="image-preview-' + postid + '" />');
img.load( function() {
var max1, max2, parent = $('#imgedit-crop-' + postid), t = imageEdit;
parent.empty().append(img);
// w, h are the new full size dims
max1 = Math.max( t.hold.w, t.hold.h );
max2 = Math.max( $(img).width(), $(img).height() );
t.hold['sizer'] = max1 > max2 ? max2 / max1 : 1;
t.initCrop(postid, img, parent);
t.setCropSelection(postid, 0);
if ( (typeof callback != "unknown") && callback != null )
callback();
if ( $('#imgedit-history-' + postid).val() && $('#imgedit-undone-' + postid).val() == 0 )
$('input.imgedit-submit-btn', '#imgedit-panel-' + postid).removeAttr('disabled');
else
$('input.imgedit-submit-btn', '#imgedit-panel-' + postid).prop('disabled', true);
t.toggleEditor(postid, 0);
}).error(function(){
$('#imgedit-crop-' + postid).empty().append('<div class="error"><p>' + imageEditL10n.error + '</p></div>');
t.toggleEditor(postid, 0);
}).attr('src', ajaxurl + '?' + $.param(data));
},
action : function(postid, nonce, action) {
var t = this, data, w, h, fw, fh;
if ( t.notsaved(postid) )
return false;
data = {
'action': 'image-editor',
'_ajax_nonce': nonce,
'postid': postid
};
if ( 'scale' == action ) {
w = $('#imgedit-scale-width-' + postid),
h = $('#imgedit-scale-height-' + postid),
fw = t.intval(w.val()),
fh = t.intval(h.val());
if ( fw < 1 ) {
w.focus();
return false;
} else if ( fh < 1 ) {
h.focus();
return false;
}
if ( fw == t.hold.ow || fh == t.hold.oh )
return false;
data['do'] = 'scale';
data['fwidth'] = fw;
data['fheight'] = fh;
} else if ( 'restore' == action ) {
data['do'] = 'restore';
} else {
return false;
}
t.toggleEditor(postid, 1);
$.post(ajaxurl, data, function(r) {
$('#image-editor-' + postid).empty().append(r);
t.toggleEditor(postid, 0);
});
},
save : function(postid, nonce) {
var data, target = this.getTarget(postid), history = this.filterHistory(postid, 0);
if ( '' == history )
return false;
this.toggleEditor(postid, 1);
data = {
'action': 'image-editor',
'_ajax_nonce': nonce,
'postid': postid,
'history': history,
'target': target,
'context': $('#image-edit-context').length ? $('#image-edit-context').val() : null,
'do': 'save'
};
$.post(ajaxurl, data, function(r) {
var ret = JSON.parse(r);
if ( ret.error ) {
$('#imgedit-response-' + postid).html('<div class="error"><p>' + ret.error + '</p><div>');
imageEdit.close(postid);
return;
}
if ( ret.fw && ret.fh )
$('#media-dims-' + postid).html( ret.fw + ' &times; ' + ret.fh );
if ( ret.thumbnail )
$('.thumbnail', '#thumbnail-head-' + postid).attr('src', ''+ret.thumbnail);
if ( ret.msg )
$('#imgedit-response-' + postid).html('<div class="updated"><p>' + ret.msg + '</p></div>');
imageEdit.close(postid);
});
},
open : function(postid, nonce) {
var data, elem = $('#image-editor-' + postid), head = $('#media-head-' + postid),
btn = $('#imgedit-open-btn-' + postid), spin = btn.siblings('.spinner');
btn.prop('disabled', true);
spin.show();
data = {
'action': 'image-editor',
'_ajax_nonce': nonce,
'postid': postid,
'do': 'open'
};
elem.load(ajaxurl, data, function() {
elem.fadeIn('fast');
head.fadeOut('fast', function(){
btn.removeAttr('disabled');
spin.hide();
});
});
},
imgLoaded : function(postid) {
var img = $('#image-preview-' + postid), parent = $('#imgedit-crop-' + postid);
this.initCrop(postid, img, parent);
this.setCropSelection(postid, 0);
this.toggleEditor(postid, 0);
},
initCrop : function(postid, image, parent) {
var t = this, selW = $('#imgedit-sel-width-' + postid),
selH = $('#imgedit-sel-height-' + postid);
t.iasapi = $(image).imgAreaSelect({
parent: parent,
instance: true,
handles: true,
keys: true,
minWidth: 3,
minHeight: 3,
onInit: function(img, c) {
parent.children().mousedown(function(e){
var ratio = false, sel, defRatio;
if ( e.shiftKey ) {
sel = t.iasapi.getSelection();
defRatio = t.getSelRatio(postid);
ratio = ( sel && sel.width && sel.height ) ? sel.width + ':' + sel.height : defRatio;
}
t.iasapi.setOptions({
aspectRatio: ratio
});
});
},
onSelectStart: function(img, c) {
imageEdit.setDisabled($('#imgedit-crop-sel-' + postid), 1);
},
onSelectEnd: function(img, c) {
imageEdit.setCropSelection(postid, c);
},
onSelectChange: function(img, c) {
var sizer = imageEdit.hold.sizer;
selW.val( imageEdit.round(c.width / sizer) );
selH.val( imageEdit.round(c.height / sizer) );
}
});
},
setCropSelection : function(postid, c) {
var sel, min = $('#imgedit-minthumb-' + postid).val() || '128:128',
sizer = this.hold['sizer'];
min = min.split(':');
c = c || 0;
if ( !c || ( c.width < 3 && c.height < 3 ) ) {
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
this.setDisabled($('#imgedit-crop-sel-' + postid), 0);
$('#imgedit-sel-width-' + postid).val('');
$('#imgedit-sel-height-' + postid).val('');
$('#imgedit-selection-' + postid).val('');
return false;
}
if ( c.width < (min[0] * sizer) && c.height < (min[1] * sizer) ) {
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
$('#imgedit-selection-' + postid).val('');
return false;
}
sel = { 'x': c.x1, 'y': c.y1, 'w': c.width, 'h': c.height };
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 1);
$('#imgedit-selection-' + postid).val( JSON.stringify(sel) );
},
close : function(postid, warn) {
warn = warn || false;
if ( warn && this.notsaved(postid) )
return false;
this.iasapi = {};
this.hold = {};
$('#image-editor-' + postid).fadeOut('fast', function() {
$('#media-head-' + postid).fadeIn('fast');
$(this).empty();
});
},
notsaved : function(postid) {
var h = $('#imgedit-history-' + postid).val(),
history = (h != '') ? JSON.parse(h) : new Array(),
pop = this.intval( $('#imgedit-undone-' + postid).val() );
if ( pop < history.length ) {
if ( confirm( $('#imgedit-leaving-' + postid).html() ) )
return false;
return true;
}
return false;
},
addStep : function(op, postid, nonce) {
var t = this, elem = $('#imgedit-history-' + postid),
history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array(),
undone = $('#imgedit-undone-' + postid),
pop = t.intval(undone.val());
while ( pop > 0 ) {
history.pop();
pop--;
}
undone.val(0); // reset
history.push(op);
elem.val( JSON.stringify(history) );
t.refreshEditor(postid, nonce, function() {
t.setDisabled($('#image-undo-' + postid), true);
t.setDisabled($('#image-redo-' + postid), false);
});
},
rotate : function(angle, postid, nonce, t) {
if ( $(t).hasClass('disabled') )
return false;
this.addStep({ 'r': { 'r': angle, 'fw': this.hold['h'], 'fh': this.hold['w'] }}, postid, nonce);
},
flip : function (axis, postid, nonce, t) {
if ( $(t).hasClass('disabled') )
return false;
this.addStep({ 'f': { 'f': axis, 'fw': this.hold['w'], 'fh': this.hold['h'] }}, postid, nonce);
},
crop : function (postid, nonce, t) {
var sel = $('#imgedit-selection-' + postid).val(),
w = this.intval( $('#imgedit-sel-width-' + postid).val() ),
h = this.intval( $('#imgedit-sel-height-' + postid).val() );
if ( $(t).hasClass('disabled') || sel == '' )
return false;
sel = JSON.parse(sel);
if ( sel.w > 0 && sel.h > 0 && w > 0 && h > 0 ) {
sel['fw'] = w;
sel['fh'] = h;
this.addStep({ 'c': sel }, postid, nonce);
}
},
undo : function (postid, nonce) {
var t = this, button = $('#image-undo-' + postid), elem = $('#imgedit-undone-' + postid),
pop = t.intval( elem.val() ) + 1;
if ( button.hasClass('disabled') )
return;
elem.val(pop);
t.refreshEditor(postid, nonce, function() {
var elem = $('#imgedit-history-' + postid),
history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array();
t.setDisabled($('#image-redo-' + postid), true);
t.setDisabled(button, pop < history.length);
});
},
redo : function(postid, nonce) {
var t = this, button = $('#image-redo-' + postid), elem = $('#imgedit-undone-' + postid),
pop = t.intval( elem.val() ) - 1;
if ( button.hasClass('disabled') )
return;
elem.val(pop);
t.refreshEditor(postid, nonce, function() {
t.setDisabled($('#image-undo-' + postid), true);
t.setDisabled(button, pop > 0);
});
},
setNumSelection : function(postid) {
var sel, elX = $('#imgedit-sel-width-' + postid), elY = $('#imgedit-sel-height-' + postid),
x = this.intval( elX.val() ), y = this.intval( elY.val() ),
img = $('#image-preview-' + postid), imgh = img.height(), imgw = img.width(),
sizer = this.hold['sizer'], x1, y1, x2, y2, ias = this.iasapi;
if ( x < 1 ) {
elX.val('');
return false;
}
if ( y < 1 ) {
elY.val('');
return false;
}
if ( x && y && ( sel = ias.getSelection() ) ) {
x2 = sel.x1 + Math.round( x * sizer );
y2 = sel.y1 + Math.round( y * sizer );
x1 = sel.x1;
y1 = sel.y1;
if ( x2 > imgw ) {
x1 = 0;
x2 = imgw;
elX.val( Math.round( x2 / sizer ) );
}
if ( y2 > imgh ) {
y1 = 0;
y2 = imgh;
elY.val( Math.round( y2 / sizer ) );
}
ias.setSelection( x1, y1, x2, y2 );
ias.update();
this.setCropSelection(postid, ias.getSelection());
}
},
round : function(num) {
var s;
num = Math.round(num);
if ( this.hold.sizer > 0.6 )
return num;
s = num.toString().slice(-1);
if ( '1' == s )
return num - 1;
else if ( '9' == s )
return num + 1;
return num;
},
setRatioSelection : function(postid, n, el) {
var sel, r, x = this.intval( $('#imgedit-crop-width-' + postid).val() ),
y = this.intval( $('#imgedit-crop-height-' + postid).val() ),
h = $('#image-preview-' + postid).height();
if ( !this.intval( $(el).val() ) ) {
$(el).val('');
return;
}
if ( x && y ) {
this.iasapi.setOptions({
aspectRatio: x + ':' + y
});
if ( sel = this.iasapi.getSelection(true) ) {
r = Math.ceil( sel.y1 + ((sel.x2 - sel.x1) / (x / y)) );
if ( r > h ) {
r = h;
if ( n )
$('#imgedit-crop-height-' + postid).val('');
else
$('#imgedit-crop-width-' + postid).val('');
}
this.iasapi.setSelection( sel.x1, sel.y1, sel.x2, r );
this.iasapi.update();
}
}
}
}
})(jQuery);

1
wp-admin/js/image-edit.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,303 @@
(function($) {
inlineEditPost = {
init : function(){
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
t.what = '#post-';
// prepare the edit rows
qeRow.keyup(function(e){
if (e.which == 27)
return inlineEditPost.revert();
});
bulkRow.keyup(function(e){
if (e.which == 27)
return inlineEditPost.revert();
});
$('a.cancel', qeRow).click(function(){
return inlineEditPost.revert();
});
$('a.save', qeRow).click(function(){
return inlineEditPost.save(this);
});
$('td', qeRow).keydown(function(e){
if ( e.which == 13 )
return inlineEditPost.save(this);
});
$('a.cancel', bulkRow).click(function(){
return inlineEditPost.revert();
});
$('#inline-edit .inline-edit-private input[value="private"]').click( function(){
var pw = $('input.inline-edit-password-input');
if ( $(this).prop('checked') ) {
pw.val('').prop('disabled', true);
} else {
pw.prop('disabled', false);
}
});
// add events
$('a.editinline').live('click', function(){
inlineEditPost.edit(this);
return false;
});
$('#bulk-title-div').parents('fieldset').after(
$('#inline-edit fieldset.inline-edit-categories').clone()
).siblings( 'fieldset:last' ).prepend(
$('#inline-edit label.inline-edit-tags').clone()
);
// hiearchical taxonomies expandable?
$('span.catshow').click(function(){
$(this).hide().next().show().parent().next().addClass("cat-hover");
});
$('span.cathide').click(function(){
$(this).hide().prev().show().parent().next().removeClass("cat-hover");
});
$('select[name="_status"] option[value="future"]', bulkRow).remove();
$('#doaction, #doaction2').click(function(e){
var n = $(this).attr('id').substr(2);
if ( $('select[name="'+n+'"]').val() == 'edit' ) {
e.preventDefault();
t.setBulk();
} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
t.revert();
}
});
$('#post-query-submit').mousedown(function(e){
t.revert();
$('select[name^="action"]').val('-1');
});
},
toggle : function(el){
var t = this;
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
},
setBulk : function(){
var te = '', type = this.type, tax, c = true;
this.revert();
$('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length);
$('table.widefat tbody').prepend( $('#bulk-edit') );
$('#bulk-edit').addClass('inline-editor').show();
$('tbody th.check-column input[type="checkbox"]').each(function(i){
if ( $(this).prop('checked') ) {
c = false;
var id = $(this).val(), theTitle;
theTitle = $('#inline_'+id+' .post_title').html() || inlineEditL10n.notitle;
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
}
});
if ( c )
return this.revert();
$('#bulk-titles').html(te);
$('#bulk-titles a').click(function(){
var id = $(this).attr('id').substr(1);
$('table.widefat input[value="' + id + '"]').prop('checked', false);
$('#ttle'+id).remove();
});
// enable autocomplete for tags
if ( 'post' == type ) {
// support multi taxonomies?
tax = 'post_tag';
$('tr.inline-editor textarea[name="tax_input['+tax+']"]').suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma + ' ' } );
}
$('html, body').animate( { scrollTop: 0 }, 'fast' );
},
edit : function(id) {
var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, cur_format, f;
t.revert();
if ( typeof(id) == 'object' )
id = t.getId(id);
fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order'];
if ( t.type == 'page' )
fields.push('post_parent', 'page_template');
// add the new blank row
editRow = $('#inline-edit').clone(true);
$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
if ( $(t.what+id).hasClass('alternate') )
$(editRow).addClass('alternate');
$(t.what+id).hide().after(editRow);
// populate the data
rowData = $('#inline_'+id);
if ( !$(':input[name="post_author"] option[value="' + $('.post_author', rowData).text() + '"]', editRow).val() ) {
// author no longer has edit caps, so we need to add them to the list of authors
$(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>');
}
if ( $(':input[name="post_author"] option', editRow).length == 1 ) {
$('label.inline-edit-author', editRow).hide();
}
// hide unsupported formats, but leave the current format alone
cur_format = $('.post_format', rowData).text();
$('option.unsupported', editRow).each(function() {
var $this = $(this);
if ( $this.val() != cur_format )
$this.remove();
});
for ( f = 0; f < fields.length; f++ ) {
$(':input[name="' + fields[f] + '"]', editRow).val( $('.'+fields[f], rowData).text() );
}
if ( $('.comment_status', rowData).text() == 'open' )
$('input[name="comment_status"]', editRow).prop("checked", true);
if ( $('.ping_status', rowData).text() == 'open' )
$('input[name="ping_status"]', editRow).prop("checked", true);
if ( $('.sticky', rowData).text() == 'sticky' )
$('input[name="sticky"]', editRow).prop("checked", true);
// hierarchical taxonomies
$('.post_category', rowData).each(function(){
var term_ids = $(this).text();
if ( term_ids ) {
taxname = $(this).attr('id').replace('_'+id, '');
$('ul.'+taxname+'-checklist :checkbox', editRow).val(term_ids.split(','));
}
});
//flat taxonomies
$('.tags_input', rowData).each(function(){
var terms = $(this).text(),
taxname = $(this).attr('id').replace('_' + id, ''),
textarea = $('textarea.tax_input_' + taxname, editRow),
comma = inlineEditL10n.comma;
if ( terms ) {
if ( ',' !== comma )
terms = terms.replace(/,/g, comma);
textarea.val(terms);
}
textarea.suggest( ajaxurl + '?action=ajax-tag-search&tax=' + taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma + ' ' } );
});
// handle the post status
status = $('._status', rowData).text();
if ( 'future' != status )
$('select[name="_status"] option[value="future"]', editRow).remove();
if ( 'private' == status ) {
$('input[name="keep_private"]', editRow).prop("checked", true);
$('input.inline-edit-password-input').val('').prop('disabled', true);
}
// remove the current page and children from the parent dropdown
pageOpt = $('select[name="post_parent"] option[value="' + id + '"]', editRow);
if ( pageOpt.length > 0 ) {
pageLevel = pageOpt[0].className.split('-')[1];
nextPage = pageOpt;
while ( pageLoop ) {
nextPage = nextPage.next('option');
if (nextPage.length == 0) break;
nextLevel = nextPage[0].className.split('-')[1];
if ( nextLevel <= pageLevel ) {
pageLoop = false;
} else {
nextPage.remove();
nextPage = pageOpt;
}
}
pageOpt.remove();
}
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
$('.ptitle', editRow).focus();
return false;
},
save : function(id) {
var params, fields, page = $('.post_status_page').val() || '';
if ( typeof(id) == 'object' )
id = this.getId(id);
$('table.widefat .spinner').show();
params = {
action: 'inline-save',
post_type: typenow,
post_ID: id,
edit_date: 'true',
post_status: page
};
fields = $('#edit-'+id+' :input').serialize();
params = fields + '&' + $.param(params);
// make ajax request
$.post( ajaxurl, params,
function(r) {
$('table.widefat .spinner').hide();
if (r) {
if ( -1 != r.indexOf('<tr') ) {
$(inlineEditPost.what+id).remove();
$('#edit-'+id).before(r).remove();
$(inlineEditPost.what+id).hide().fadeIn();
} else {
r = r.replace( /<.[^<>]*?>/g, '' );
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
}
} else {
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
}
}
, 'html');
return false;
},
revert : function(){
var id = $('table.widefat tr.inline-editor').attr('id');
if ( id ) {
$('table.widefat .spinner').hide();
if ( 'bulk-edit' == id ) {
$('table.widefat #bulk-edit').removeClass('inline-editor').hide();
$('#bulk-titles').html('');
$('#inlineedit').append( $('#bulk-edit') );
} else {
$('#'+id).remove();
id = id.substr( id.lastIndexOf('-') + 1 );
$(this.what+id).show();
}
}
return false;
},
getId : function(o) {
var id = $(o).closest('tr').attr('id'),
parts = id.split('-');
return parts[parts.length - 1];
}
};
$(document).ready(function(){inlineEditPost.init();});
})(jQuery);

1
wp-admin/js/inline-edit-post.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,118 @@
(function($) {
inlineEditTax = {
init : function() {
var t = this, row = $('#inline-edit');
t.type = $('#the-list').attr('data-wp-lists').substr(5);
t.what = '#'+t.type+'-';
$('.editinline').live('click', function(){
inlineEditTax.edit(this);
return false;
});
// prepare the edit row
row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
$('a.cancel', row).click(function() { return inlineEditTax.revert(); });
$('a.save', row).click(function() { return inlineEditTax.save(this); });
$('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
$('#posts-filter input[type="submit"]').mousedown(function(e){
t.revert();
});
},
toggle : function(el) {
var t = this;
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
},
edit : function(id) {
var t = this, editRow;
t.revert();
if ( typeof(id) == 'object' )
id = t.getId(id);
editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
if ( $(t.what+id).hasClass('alternate') )
$(editRow).addClass('alternate');
$(t.what+id).hide().after(editRow);
$(':input[name="name"]', editRow).val( $('.name', rowData).text() );
$(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
$('.ptitle', editRow).eq(0).focus();
return false;
},
save : function(id) {
var params, fields, tax = $('input[name="taxonomy"]').val() || '';
if( typeof(id) == 'object' )
id = this.getId(id);
$('table.widefat .spinner').show();
params = {
action: 'inline-save-tax',
tax_type: this.type,
tax_ID: id,
taxonomy: tax
};
fields = $('#edit-'+id+' :input').serialize();
params = fields + '&' + $.param(params);
// make ajax request
$.post( ajaxurl, params,
function(r) {
var row, new_id;
$('table.widefat .spinner').hide();
if (r) {
if ( -1 != r.indexOf('<tr') ) {
$(inlineEditTax.what+id).remove();
new_id = $(r).attr('id');
$('#edit-'+id).before(r).remove();
row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
row.hide().fadeIn();
} else
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
} else
$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
}
);
return false;
},
revert : function() {
var id = $('table.widefat tr.inline-editor').attr('id');
if ( id ) {
$('table.widefat .spinner').hide();
$('#'+id).remove();
id = id.substr( id.lastIndexOf('-') + 1 );
$(this.what+id).show();
}
return false;
},
getId : function(o) {
var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
return parts[parts.length - 1];
}
};
$(document).ready(function(){inlineEditTax.init();});
})(jQuery);

1
wp-admin/js/inline-edit-tax.min.js vendored Normal file
View File

@ -0,0 +1 @@
(function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("data-wp-lists").substr(5);b.what="#"+b.type+"-";a(".editinline").live("click",function(){inlineEditTax.edit(this);return false});c.keyup(function(d){if(d.which==27){return inlineEditTax.revert()}});a("a.cancel",c).click(function(){return inlineEditTax.revert()});a("a.save",c).click(function(){return inlineEditTax.save(this)});a("input, select",c).keydown(function(d){if(d.which==13){return inlineEditTax.save(this)}});a('#posts-filter input[type="submit"]').mousedown(function(d){b.revert()})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},edit:function(d){var c=this,b;c.revert();if(typeof(d)=="object"){d=c.getId(d)}b=a("#inline-edit").clone(true),rowData=a("#inline_"+d);a("td",b).attr("colspan",a(".widefat:first thead th:visible").length);if(a(c.what+d).hasClass("alternate")){a(b).addClass("alternate")}a(c.what+d).hide().after(b);a(':input[name="name"]',b).val(a(".name",rowData).text());a(':input[name="slug"]',b).val(a(".slug",rowData).text());a(b).attr("id","edit-"+d).addClass("inline-editor").show();a(".ptitle",b).eq(0).focus();return false},save:function(e){var d,b,c=a('input[name="taxonomy"]').val()||"";if(typeof(e)=="object"){e=this.getId(e)}a("table.widefat .spinner").show();d={action:"inline-save-tax",tax_type:this.type,tax_ID:e,taxonomy:c};b=a("#edit-"+e+" :input").serialize();d=b+"&"+a.param(d);a.post(ajaxurl,d,function(g){var h,f;a("table.widefat .spinner").hide();if(g){if(-1!=g.indexOf("<tr")){a(inlineEditTax.what+e).remove();f=a(g).attr("id");a("#edit-"+e).before(g).remove();h=f?a("#"+f):a(inlineEditTax.what+e);h.hide().fadeIn()}else{a("#edit-"+e+" .inline-edit-save .error").html(g).show()}}else{a("#edit-"+e+" .inline-edit-save .error").html(inlineEditL10n.error).show()}});return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .spinner").hide();a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditTax.init()})})(jQuery);

4
wp-admin/js/iris.min.js vendored Normal file

File diff suppressed because one or more lines are too long

67
wp-admin/js/link.js Normal file
View File

@ -0,0 +1,67 @@
jQuery(document).ready( function($) {
var newCat, noSyncChecks = false, syncChecks, catAddAfter;
$('#link_name').focus();
// postboxes
postboxes.add_postbox_toggles('link');
// category tabs
$('#category-tabs a').click(function(){
var t = $(this).attr('href');
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
$('.tabs-panel').hide();
$(t).show();
if ( '#categories-all' == t )
deleteUserSetting('cats');
else
setUserSetting('cats','pop');
return false;
});
if ( getUserSetting('cats') )
$('#category-tabs a[href="#categories-pop"]').click();
// Ajax Cat
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
$('#link-category-add-submit').click( function() { newCat.focus(); } );
syncChecks = function() {
if ( noSyncChecks )
return;
noSyncChecks = true;
var th = $(this), c = th.is(':checked'), id = th.val().toString();
$('#in-link-category-' + id + ', #in-popular-category-' + id).prop( 'checked', c );
noSyncChecks = false;
};
catAddAfter = function( r, s ) {
$(s.what + ' response_data', r).each( function() {
var t = $($(this).text());
t.find( 'label' ).each( function() {
var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
$('#' + id).change( syncChecks );
o = $( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
} );
} );
};
$('#categorychecklist').wpList( {
alt: '',
what: 'link-category',
response: 'category-ajax-response',
addAfter: catAddAfter
} );
$('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
$('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
if ( 'pop' == getUserSetting('cats') )
$('a[href="#categories-pop"]').click();
$('#category-add-toggle').click( function() {
$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
$('#category-tabs a[href="#categories-all"]').click();
$('#newcategory').focus();
return false;
} );
$('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
});

1
wp-admin/js/link.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(c){var b,a=false,d,e;c("#link_name").focus();postboxes.add_postbox_toggles("link");c("#category-tabs a").click(function(){var f=c(this).attr("href");c(this).parent().addClass("tabs").siblings("li").removeClass("tabs");c(".tabs-panel").hide();c(f).show();if("#categories-all"==f){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){c('#category-tabs a[href="#categories-pop"]').click()}b=c("#newcat").one("focus",function(){c(this).val("").removeClass("form-input-tip")});c("#link-category-add-submit").click(function(){b.focus()});d=function(){if(a){return}a=true;var f=c(this),h=f.is(":checked"),g=f.val().toString();c("#in-link-category-"+g+", #in-popular-category-"+g).prop("checked",h);a=false};e=function(g,f){c(f.what+" response_data",g).each(function(){var h=c(c(this).text());h.find("label").each(function(){var j=c(this),l=j.find("input").val(),m=j.find("input")[0].id,i=c.trim(j.text()),k;c("#"+m).change(d);k=c('<option value="'+parseInt(l,10)+'"></option>').text(i)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:e});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");c('#category-tabs a[href="#categories-all"]').click();c("#newcategory").focus();return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});

View File

@ -0,0 +1,25 @@
jQuery(function($){
$( 'body' ).bind( 'click.wp-gallery', function(e){
var target = $( e.target ), id, img_size;
if ( target.hasClass( 'wp-set-header' ) ) {
( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
e.preventDefault();
} else if ( target.hasClass( 'wp-set-background' ) ) {
id = target.data( 'attachment-id' );
img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
jQuery.post(ajaxurl, {
action: 'set-background-image',
attachment_id: id,
size: img_size
}, function(){
var win = window.dialogArguments || opener || parent || top;
win.tb_remove();
win.location.reload();
});
e.preventDefault();
}
});
});

1
wp-admin/js/media-gallery.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(function(a){a("body").bind("click.wp-gallery",function(d){var c=a(d.target),f,b;if(c.hasClass("wp-set-header")){(window.dialogArguments||opener||parent||top).location.href=c.data("location");d.preventDefault()}else{if(c.hasClass("wp-set-background")){f=c.data("attachment-id");b=a('input[name="attachments['+f+'][image-size]"]:checked').val();jQuery.post(ajaxurl,{action:"set-background-image",attachment_id:f,size:b},function(){var e=window.dialogArguments||opener||parent||top;e.tb_remove();e.location.reload()});d.preventDefault()}}})});

View File

@ -0,0 +1,88 @@
// send html to the post editor
var wpActiveEditor;
function send_to_editor(h) {
var ed, mce = typeof(tinymce) != 'undefined', qt = typeof(QTags) != 'undefined';
if ( !wpActiveEditor ) {
if ( mce && tinymce.activeEditor ) {
ed = tinymce.activeEditor;
wpActiveEditor = ed.id;
} else if ( !qt ) {
return false;
}
} else if ( mce ) {
if ( tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
ed = tinymce.activeEditor;
else
ed = tinymce.get(wpActiveEditor);
}
if ( ed && !ed.isHidden() ) {
// restore caret position on IE
if ( tinymce.isIE && ed.windowManager.insertimagebookmark )
ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
if ( h.indexOf('[caption') !== -1 ) {
if ( ed.wpSetImgCaption )
h = ed.wpSetImgCaption(h);
} else if ( h.indexOf('[gallery') !== -1 ) {
if ( ed.plugins.wpgallery )
h = ed.plugins.wpgallery._do_gallery(h);
} else if ( h.indexOf('[embed') === 0 ) {
if ( ed.plugins.wordpress )
h = ed.plugins.wordpress._setEmbed(h);
}
ed.execCommand('mceInsertContent', false, h);
} else if ( qt ) {
QTags.insertContent(h);
} else {
document.getElementById(wpActiveEditor).value += h;
}
try{tb_remove();}catch(e){};
}
// thickbox settings
var tb_position;
(function($) {
tb_position = function() {
var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width, adminbar_height = 0;
if ( $('body.admin-bar').length )
adminbar_height = 28;
if ( tbWindow.size() ) {
tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
if ( typeof document.body.style.maxWidth != 'undefined' )
tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
};
return $('a.thickbox').each( function() {
var href = $(this).attr('href');
if ( ! href ) return;
href = href.replace(/&width=[0-9]+/g, '');
href = href.replace(/&height=[0-9]+/g, '');
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
});
};
$(window).resize(function(){ tb_position(); });
// store caret position in IE
$(document).ready(function($){
$('a.thickbox').click(function(){
var ed;
if ( typeof(tinymce) != 'undefined' && tinymce.isIE && ( ed = tinymce.get(wpActiveEditor) ) && !ed.isHidden() ) {
ed.focus();
ed.windowManager.insertimagebookmark = ed.selection.getBookmark();
}
});
});
})(jQuery);

1
wp-admin/js/media-upload.min.js vendored Normal file
View File

@ -0,0 +1 @@
var wpActiveEditor;function send_to_editor(c){var b,a=typeof(tinymce)!="undefined",f=typeof(QTags)!="undefined";if(!wpActiveEditor){if(a&&tinymce.activeEditor){b=tinymce.activeEditor;wpActiveEditor=b.id}else{if(!f){return false}}}else{if(a){if(tinymce.activeEditor&&(tinymce.activeEditor.id=="mce_fullscreen"||tinymce.activeEditor.id=="wp_mce_fullscreen")){b=tinymce.activeEditor}else{b=tinymce.get(wpActiveEditor)}}}if(b&&!b.isHidden()){if(tinymce.isIE&&b.windowManager.insertimagebookmark){b.selection.moveToBookmark(b.windowManager.insertimagebookmark)}if(c.indexOf("[caption")!==-1){if(b.wpSetImgCaption){c=b.wpSetImgCaption(c)}}else{if(c.indexOf("[gallery")!==-1){if(b.plugins.wpgallery){c=b.plugins.wpgallery._do_gallery(c)}}else{if(c.indexOf("[embed")===0){if(b.plugins.wordpress){c=b.plugins.wordpress._setEmbed(c)}}}}b.execCommand("mceInsertContent",false,c)}else{if(f){QTags.insertContent(c)}else{document.getElementById(wpActiveEditor).value+=c}}try{tb_remove()}catch(d){}}var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).ready(function(b){b("a.thickbox").click(function(){var c;if(typeof(tinymce)!="undefined"&&tinymce.isIE&&(c=tinymce.get(wpActiveEditor))&&!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);

124
wp-admin/js/media.js Normal file
View File

@ -0,0 +1,124 @@
var findPosts;
(function($){
findPosts = {
open : function(af_name, af_val) {
var st = document.documentElement.scrollTop || $(document).scrollTop(),
overlay = $( '.ui-find-overlay' );
if ( overlay.length == 0 ) {
$( 'body' ).append( '<div class="ui-find-overlay"></div>' );
findPosts.overlay();
}
overlay.show();
if ( af_name && af_val ) {
$('#affected').attr('name', af_name).val(af_val);
}
$('#find-posts').show().draggable({
handle: '#find-posts-head'
}).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-328px'});
$('#find-posts-input').focus().keyup(function(e){
if (e.which == 27) { findPosts.close(); } // close on Escape
});
// Pull some results up by default
findPosts.send();
return false;
},
close : function() {
$('#find-posts-response').html('');
$('#find-posts').draggable('destroy').hide();
$( '.ui-find-overlay' ).hide();
},
overlay : function() {
$( '.ui-find-overlay' ).css(
{ 'z-index': '999', 'width': $( document ).width() + 'px', 'height': $( document ).height() + 'px' }
).on('click', function () {
findPosts.close();
});
},
send : function() {
var post = {
ps: $('#find-posts-input').val(),
action: 'find_posts',
_ajax_nonce: $('#_ajax_nonce').val()
},
spinner = $( '.find-box-search .spinner' );
spinner.show();
$.ajax({
type : 'POST',
url : ajaxurl,
data : post,
success : function(x) { findPosts.show(x); spinner.hide(); },
error : function(r) { findPosts.error(r); spinner.hide(); }
});
},
show : function(x) {
if ( typeof(x) == 'string' ) {
this.error({'responseText': x});
return;
}
var r = wpAjax.parseAjaxResponse(x);
if ( r.errors ) {
this.error({'responseText': wpAjax.broken});
}
r = r.responses[0];
$('#find-posts-response').html(r.data);
// Enable whole row to be clicked
$( '.found-posts td' ).on( 'click', function () {
$( this ).parent().find( '.found-radio input' ).prop( 'checked', true );
});
},
error : function(r) {
var er = r.statusText;
if ( r.responseText ) {
er = r.responseText.replace( /<.[^<>]*?>/g, '' );
}
if ( er ) {
$('#find-posts-response').html(er);
}
}
};
$(document).ready(function() {
$('#find-posts-submit').click(function(e) {
if ( '' == $('#find-posts-response').html() )
e.preventDefault();
});
$( '#find-posts .find-box-search :input' ).keypress( function( event ) {
if ( 13 == event.which ) {
findPosts.send();
return false;
}
} );
$( '#find-posts-search' ).click( findPosts.send );
$( '#find-posts-close' ).click( findPosts.close );
$('#doaction, #doaction2').click(function(e){
$('select[name^="action"]').each(function(){
if ( $(this).val() == 'attach' ) {
e.preventDefault();
findPosts.open();
}
});
});
});
$(window).resize(function() {
findPosts.overlay();
});
})(jQuery);

1
wp-admin/js/media.min.js vendored Normal file
View File

@ -0,0 +1 @@
var findPosts;(function(a){findPosts={open:function(e,d){var c=document.documentElement.scrollTop||a(document).scrollTop(),b=a(".ui-find-overlay");if(b.length==0){a("body").append('<div class="ui-find-overlay"></div>');findPosts.overlay()}b.show();if(e&&d){a("#affected").attr("name",e).val(d)}a("#find-posts").show().draggable({handle:"#find-posts-head"}).css({top:c+50+"px",left:"50%",marginLeft:"-328px"});a("#find-posts-input").focus().keyup(function(f){if(f.which==27){findPosts.close()}});findPosts.send();return false},close:function(){a("#find-posts-response").html("");a("#find-posts").draggable("destroy").hide();a(".ui-find-overlay").hide()},overlay:function(){a(".ui-find-overlay").css({"z-index":"999",width:a(document).width()+"px",height:a(document).height()+"px"}).on("click",function(){findPosts.close()})},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()},c=a(".find-box-search .spinner");c.show();a.ajax({type:"POST",url:ajaxurl,data:b,success:function(d){findPosts.show(d);c.hide()},error:function(d){findPosts.error(d);c.hide()}})},show:function(b){if(typeof(b)=="string"){this.error({responseText:b});return}var c=wpAjax.parseAjaxResponse(b);if(c.errors){this.error({responseText:wpAjax.broken})}c=c.responses[0];a("#find-posts-response").html(c.data);a(".found-posts td").on("click",function(){a(this).parent().find(".found-radio input").prop("checked",true)})},error:function(b){var c=b.statusText;if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#find-posts-response").html(c)}}};a(document).ready(function(){a("#find-posts-submit").click(function(b){if(""==a("#find-posts-response").html()){b.preventDefault()}});a("#find-posts .find-box-search :input").keypress(function(b){if(13==b.which){findPosts.send();return false}});a("#find-posts-search").click(findPosts.send);a("#find-posts-close").click(findPosts.close);a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){if(a(this).val()=="attach"){b.preventDefault();findPosts.open()}})})});a(window).resize(function(){findPosts.overlay()})})(jQuery);

965
wp-admin/js/nav-menu.js Normal file
View File

@ -0,0 +1,965 @@
/**
* WordPress Administration Navigation Menu
* Interface JS functions
*
* @version 2.0.0
*
* @package WordPress
* @subpackage Administration
*/
var wpNavMenu;
(function($) {
var api = wpNavMenu = {
options : {
menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead.
globalMaxDepth : 11
},
menuList : undefined, // Set in init.
targetList : undefined, // Set in init.
menusChanged : false,
isRTL: !! ( 'undefined' != typeof isRtl && isRtl ),
negateIfRTL: ( 'undefined' != typeof isRtl && isRtl ) ? -1 : 1,
// Functions that run on init.
init : function() {
api.menuList = $('#menu-to-edit');
api.targetList = api.menuList;
this.jQueryExtensions();
this.attachMenuEditListeners();
this.setupInputWithDefaultTitle();
this.attachQuickSearchListeners();
this.attachThemeLocationsListeners();
this.attachTabsPanelListeners();
this.attachUnsavedChangesListener();
if( api.menuList.length ) // If no menu, we're in the + tab.
this.initSortables();
this.initToggles();
this.initTabManager();
},
jQueryExtensions : function() {
// jQuery extensions
$.fn.extend({
menuItemDepth : function() {
var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left');
return api.pxToDepth( margin && -1 != margin.indexOf('px') ? margin.slice(0, -2) : 0 );
},
updateDepthClass : function(current, prev) {
return this.each(function(){
var t = $(this);
prev = prev || t.menuItemDepth();
$(this).removeClass('menu-item-depth-'+ prev )
.addClass('menu-item-depth-'+ current );
});
},
shiftDepthClass : function(change) {
return this.each(function(){
var t = $(this),
depth = t.menuItemDepth();
$(this).removeClass('menu-item-depth-'+ depth )
.addClass('menu-item-depth-'+ (depth + change) );
});
},
childMenuItems : function() {
var result = $();
this.each(function(){
var t = $(this), depth = t.menuItemDepth(), next = t.next();
while( next.length && next.menuItemDepth() > depth ) {
result = result.add( next );
next = next.next();
}
});
return result;
},
updateParentMenuItemDBId : function() {
return this.each(function(){
var item = $(this),
input = item.find('.menu-item-data-parent-id'),
depth = item.menuItemDepth(),
parent = item.prev();
if( depth == 0 ) { // Item is on the top level, has no parent
input.val(0);
} else { // Find the parent item, and retrieve its object id.
while( ! parent[0] || ! parent[0].className || -1 == parent[0].className.indexOf('menu-item') || ( parent.menuItemDepth() != depth - 1 ) )
parent = parent.prev();
input.val( parent.find('.menu-item-data-db-id').val() );
}
});
},
hideAdvancedMenuItemFields : function() {
return this.each(function(){
var that = $(this);
$('.hide-column-tog').not(':checked').each(function(){
that.find('.field-' + $(this).val() ).addClass('hidden-field');
});
});
},
/**
* Adds selected menu items to the menu.
*
* @param jQuery metabox The metabox jQuery object.
*/
addSelectedToMenu : function(processMethod) {
if ( 0 == $('#menu-to-edit').length ) {
return false;
}
return this.each(function() {
var t = $(this), menuItems = {},
checkboxes = t.find('.tabs-panel-active .categorychecklist li input:checked'),
re = new RegExp('menu-item\\[(\[^\\]\]*)');
processMethod = processMethod || api.addMenuItemToBottom;
// If no items are checked, bail.
if ( !checkboxes.length )
return false;
// Show the ajax spinner
t.find('.spinner').show();
// Retrieve menu item data
$(checkboxes).each(function(){
var t = $(this),
listItemDBIDMatch = re.exec( t.attr('name') ),
listItemDBID = 'undefined' == typeof listItemDBIDMatch[1] ? 0 : parseInt(listItemDBIDMatch[1], 10);
if ( this.className && -1 != this.className.indexOf('add-to-top') )
processMethod = api.addMenuItemToTop;
menuItems[listItemDBID] = t.closest('li').getItemData( 'add-menu-item', listItemDBID );
});
// Add the items
api.addItemToMenu(menuItems, processMethod, function(){
// Deselect the items and hide the ajax spinner
checkboxes.removeAttr('checked');
t.find('.spinner').hide();
});
});
},
getItemData : function( itemType, id ) {
itemType = itemType || 'menu-item';
var itemData = {}, i,
fields = [
'menu-item-db-id',
'menu-item-object-id',
'menu-item-object',
'menu-item-parent-id',
'menu-item-position',
'menu-item-type',
'menu-item-title',
'menu-item-url',
'menu-item-description',
'menu-item-attr-title',
'menu-item-target',
'menu-item-classes',
'menu-item-xfn'
];
if( !id && itemType == 'menu-item' ) {
id = this.find('.menu-item-data-db-id').val();
}
if( !id ) return itemData;
this.find('input').each(function() {
var field;
i = fields.length;
while ( i-- ) {
if( itemType == 'menu-item' )
field = fields[i] + '[' + id + ']';
else if( itemType == 'add-menu-item' )
field = 'menu-item[' + id + '][' + fields[i] + ']';
if (
this.name &&
field == this.name
) {
itemData[fields[i]] = this.value;
}
}
});
return itemData;
},
setItemData : function( itemData, itemType, id ) { // Can take a type, such as 'menu-item', or an id.
itemType = itemType || 'menu-item';
if( !id && itemType == 'menu-item' ) {
id = $('.menu-item-data-db-id', this).val();
}
if( !id ) return this;
this.find('input').each(function() {
var t = $(this), field;
$.each( itemData, function( attr, val ) {
if( itemType == 'menu-item' )
field = attr + '[' + id + ']';
else if( itemType == 'add-menu-item' )
field = 'menu-item[' + id + '][' + attr + ']';
if ( field == t.attr('name') ) {
t.val( val );
}
});
});
return this;
}
});
},
initToggles : function() {
// init postboxes
postboxes.add_postbox_toggles('nav-menus');
// adjust columns functions for menus UI
columns.useCheckboxesForHidden();
columns.checked = function(field) {
$('.field-' + field).removeClass('hidden-field');
}
columns.unchecked = function(field) {
$('.field-' + field).addClass('hidden-field');
}
// hide fields
api.menuList.hideAdvancedMenuItemFields();
},
initSortables : function() {
var currentDepth = 0, originalDepth, minDepth, maxDepth,
prev, next, prevBottom, nextThreshold, helperHeight, transport,
menuEdge = api.menuList.offset().left,
body = $('body'), maxChildDepth,
menuMaxDepth = initialMenuMaxDepth();
// Use the right edge if RTL.
menuEdge += api.isRTL ? api.menuList.width() : 0;
api.menuList.sortable({
handle: '.menu-item-handle',
placeholder: 'sortable-placeholder',
start: function(e, ui) {
var height, width, parent, children, tempHolder;
// handle placement for rtl orientation
if ( api.isRTL )
ui.item[0].style.right = 'auto';
transport = ui.item.children('.menu-item-transport');
// Set depths. currentDepth must be set before children are located.
originalDepth = ui.item.menuItemDepth();
updateCurrentDepth(ui, originalDepth);
// Attach child elements to parent
// Skip the placeholder
parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item;
children = parent.childMenuItems();
transport.append( children );
// Update the height of the placeholder to match the moving item.
height = transport.outerHeight();
// If there are children, account for distance between top of children and parent
height += ( height > 0 ) ? (ui.placeholder.css('margin-top').slice(0, -2) * 1) : 0;
height += ui.helper.outerHeight();
helperHeight = height;
height -= 2; // Subtract 2 for borders
ui.placeholder.height(height);
// Update the width of the placeholder to match the moving item.
maxChildDepth = originalDepth;
children.each(function(){
var depth = $(this).menuItemDepth();
maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth;
});
width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width
width += api.depthToPx(maxChildDepth - originalDepth); // Account for children
width -= 2; // Subtract 2 for borders
ui.placeholder.width(width);
// Update the list of menu items.
tempHolder = ui.placeholder.next();
tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder
ui.placeholder.detach(); // detach or jQuery UI will think the placeholder is a menu item
$(this).sortable( "refresh" ); // The children aren't sortable. We should let jQ UI know.
ui.item.after( ui.placeholder ); // reattach the placeholder.
tempHolder.css('margin-top', 0); // reset the margin
// Now that the element is complete, we can update...
updateSharedVars(ui);
},
stop: function(e, ui) {
var children, depthChange = currentDepth - originalDepth;
// Return child elements to the list
children = transport.children().insertAfter(ui.item);
// Update depth classes
if( depthChange != 0 ) {
ui.item.updateDepthClass( currentDepth );
children.shiftDepthClass( depthChange );
updateMenuMaxDepth( depthChange );
}
// Register a change
api.registerChange();
// Update the item data.
ui.item.updateParentMenuItemDBId();
// address sortable's incorrectly-calculated top in opera
ui.item[0].style.top = 0;
// handle drop placement for rtl orientation
if ( api.isRTL ) {
ui.item[0].style.left = 'auto';
ui.item[0].style.right = 0;
}
// The width of the tab bar might have changed. Just in case.
api.refreshMenuTabs( true );
},
change: function(e, ui) {
// Make sure the placeholder is inside the menu.
// Otherwise fix it, or we're in trouble.
if( ! ui.placeholder.parent().hasClass('menu') )
(prev.length) ? prev.after( ui.placeholder ) : api.menuList.prepend( ui.placeholder );
updateSharedVars(ui);
},
sort: function(e, ui) {
var offset = ui.helper.offset(),
edge = api.isRTL ? offset.left + ui.helper.width() : offset.left,
depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge );
// Check and correct if depth is not within range.
// Also, if the dragged element is dragged upwards over
// an item, shift the placeholder to a child position.
if ( depth > maxDepth || offset.top < prevBottom ) depth = maxDepth;
else if ( depth < minDepth ) depth = minDepth;
if( depth != currentDepth )
updateCurrentDepth(ui, depth);
// If we overlap the next element, manually shift downwards
if( nextThreshold && offset.top + helperHeight > nextThreshold ) {
next.after( ui.placeholder );
updateSharedVars( ui );
$(this).sortable( "refreshPositions" );
}
}
});
function updateSharedVars(ui) {
var depth;
prev = ui.placeholder.prev();
next = ui.placeholder.next();
// Make sure we don't select the moving item.
if( prev[0] == ui.item[0] ) prev = prev.prev();
if( next[0] == ui.item[0] ) next = next.next();
prevBottom = (prev.length) ? prev.offset().top + prev.height() : 0;
nextThreshold = (next.length) ? next.offset().top + next.height() / 3 : 0;
minDepth = (next.length) ? next.menuItemDepth() : 0;
if( prev.length )
maxDepth = ( (depth = prev.menuItemDepth() + 1) > api.options.globalMaxDepth ) ? api.options.globalMaxDepth : depth;
else
maxDepth = 0;
}
function updateCurrentDepth(ui, depth) {
ui.placeholder.updateDepthClass( depth, currentDepth );
currentDepth = depth;
}
function initialMenuMaxDepth() {
if( ! body[0].className ) return 0;
var match = body[0].className.match(/menu-max-depth-(\d+)/);
return match && match[1] ? parseInt(match[1]) : 0;
}
function updateMenuMaxDepth( depthChange ) {
var depth, newDepth = menuMaxDepth;
if ( depthChange === 0 ) {
return;
} else if ( depthChange > 0 ) {
depth = maxChildDepth + depthChange;
if( depth > menuMaxDepth )
newDepth = depth;
} else if ( depthChange < 0 && maxChildDepth == menuMaxDepth ) {
while( ! $('.menu-item-depth-' + newDepth, api.menuList).length && newDepth > 0 )
newDepth--;
}
// Update the depth class.
body.removeClass( 'menu-max-depth-' + menuMaxDepth ).addClass( 'menu-max-depth-' + newDepth );
menuMaxDepth = newDepth;
}
},
attachMenuEditListeners : function() {
var that = this;
$('#update-nav-menu').bind('click', function(e) {
if ( e.target && e.target.className ) {
if ( -1 != e.target.className.indexOf('item-edit') ) {
return that.eventOnClickEditLink(e.target);
} else if ( -1 != e.target.className.indexOf('menu-save') ) {
return that.eventOnClickMenuSave(e.target);
} else if ( -1 != e.target.className.indexOf('menu-delete') ) {
return that.eventOnClickMenuDelete(e.target);
} else if ( -1 != e.target.className.indexOf('item-delete') ) {
return that.eventOnClickMenuItemDelete(e.target);
} else if ( -1 != e.target.className.indexOf('item-cancel') ) {
return that.eventOnClickCancelLink(e.target);
}
}
});
$('#add-custom-links input[type="text"]').keypress(function(e){
if ( e.keyCode === 13 ) {
e.preventDefault();
$("#submit-customlinkdiv").click();
}
});
},
/**
* An interface for managing default values for input elements
* that is both JS and accessibility-friendly.
*
* Input elements that add the class 'input-with-default-title'
* will have their values set to the provided HTML title when empty.
*/
setupInputWithDefaultTitle : function() {
var name = 'input-with-default-title';
$('.' + name).each( function(){
var $t = $(this), title = $t.attr('title'), val = $t.val();
$t.data( name, title );
if( '' == val ) $t.val( title );
else if ( title == val ) return;
else $t.removeClass( name );
}).focus( function(){
var $t = $(this);
if( $t.val() == $t.data(name) )
$t.val('').removeClass( name );
}).blur( function(){
var $t = $(this);
if( '' == $t.val() )
$t.addClass( name ).val( $t.data(name) );
});
},
attachThemeLocationsListeners : function() {
var loc = $('#nav-menu-theme-locations'), params = {};
params['action'] = 'menu-locations-save';
params['menu-settings-column-nonce'] = $('#menu-settings-column-nonce').val();
loc.find('input[type="submit"]').click(function() {
loc.find('select').each(function() {
params[this.name] = $(this).val();
});
loc.find('.spinner').show();
$.post( ajaxurl, params, function(r) {
loc.find('.spinner').hide();
});
return false;
});
},
attachQuickSearchListeners : function() {
var searchTimer;
$('.quick-search').keypress(function(e){
var t = $(this);
if( 13 == e.which ) {
api.updateQuickSearchResults( t );
return false;
}
if( searchTimer ) clearTimeout(searchTimer);
searchTimer = setTimeout(function(){
api.updateQuickSearchResults( t );
}, 400);
}).attr('autocomplete','off');
},
updateQuickSearchResults : function(input) {
var panel, params,
minSearchLength = 2,
q = input.val();
if( q.length < minSearchLength ) return;
panel = input.parents('.tabs-panel');
params = {
'action': 'menu-quick-search',
'response-format': 'markup',
'menu': $('#menu').val(),
'menu-settings-column-nonce': $('#menu-settings-column-nonce').val(),
'q': q,
'type': input.attr('name')
};
$('.spinner', panel).show();
$.post( ajaxurl, params, function(menuMarkup) {
api.processQuickSearchQueryResponse(menuMarkup, params, panel);
});
},
addCustomLink : function( processMethod ) {
var url = $('#custom-menu-item-url').val(),
label = $('#custom-menu-item-name').val();
processMethod = processMethod || api.addMenuItemToBottom;
if ( '' == url || 'http://' == url )
return false;
// Show the ajax spinner
$('.customlinkdiv .spinner').show();
this.addLinkToMenu( url, label, processMethod, function() {
// Remove the ajax spinner
$('.customlinkdiv .spinner').hide();
// Set custom link form back to defaults
$('#custom-menu-item-name').val('').blur();
$('#custom-menu-item-url').val('http://');
});
},
addLinkToMenu : function(url, label, processMethod, callback) {
processMethod = processMethod || api.addMenuItemToBottom;
callback = callback || function(){};
api.addItemToMenu({
'-1': {
'menu-item-type': 'custom',
'menu-item-url': url,
'menu-item-title': label
}
}, processMethod, callback);
},
addItemToMenu : function(menuItem, processMethod, callback) {
var menu = $('#menu').val(),
nonce = $('#menu-settings-column-nonce').val();
processMethod = processMethod || function(){};
callback = callback || function(){};
params = {
'action': 'add-menu-item',
'menu': menu,
'menu-settings-column-nonce': nonce,
'menu-item': menuItem
};
$.post( ajaxurl, params, function(menuMarkup) {
var ins = $('#menu-instructions');
processMethod(menuMarkup, params);
if( ! ins.hasClass('menu-instructions-inactive') && ins.siblings().length )
ins.addClass('menu-instructions-inactive');
callback();
});
},
/**
* Process the add menu item request response into menu list item.
*
* @param string menuMarkup The text server response of menu item markup.
* @param object req The request arguments.
*/
addMenuItemToBottom : function( menuMarkup, req ) {
$(menuMarkup).hideAdvancedMenuItemFields().appendTo( api.targetList );
},
addMenuItemToTop : function( menuMarkup, req ) {
$(menuMarkup).hideAdvancedMenuItemFields().prependTo( api.targetList );
},
attachUnsavedChangesListener : function() {
$('#menu-management input, #menu-management select, #menu-management, #menu-management textarea').change(function(){
api.registerChange();
});
if ( 0 != $('#menu-to-edit').length ) {
window.onbeforeunload = function(){
if ( api.menusChanged )
return navMenuL10n.saveAlert;
};
} else {
// Make the post boxes read-only, as they can't be used yet
$('#menu-settings-column').find('input,select').prop('disabled', true).end().find('a').attr('href', '#').unbind('click');
}
},
registerChange : function() {
api.menusChanged = true;
},
attachTabsPanelListeners : function() {
$('#menu-settings-column').bind('click', function(e) {
var selectAreaMatch, panelId, wrapper, items,
target = $(e.target);
if ( target.hasClass('nav-tab-link') ) {
panelId = /#(.*)$/.exec(e.target.href);
if ( panelId && panelId[1] )
panelId = panelId[1]
else
return false;
wrapper = target.parents('.inside').first();
// upon changing tabs, we want to uncheck all checkboxes
$('input', wrapper).removeAttr('checked');
$('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive');
$('#' + panelId, wrapper).removeClass('tabs-panel-inactive').addClass('tabs-panel-active');
$('.tabs', wrapper).removeClass('tabs');
target.parent().addClass('tabs');
// select the search bar
$('.quick-search', wrapper).focus();
return false;
} else if ( target.hasClass('select-all') ) {
selectAreaMatch = /#(.*)$/.exec(e.target.href);
if ( selectAreaMatch && selectAreaMatch[1] ) {
items = $('#' + selectAreaMatch[1] + ' .tabs-panel-active .menu-item-title input');
if( items.length === items.filter(':checked').length )
items.removeAttr('checked');
else
items.prop('checked', true);
return false;
}
} else if ( target.hasClass('submit-add-to-menu') ) {
api.registerChange();
if ( e.target.id && 'submit-customlinkdiv' == e.target.id )
api.addCustomLink( api.addMenuItemToBottom );
else if ( e.target.id && -1 != e.target.id.indexOf('submit-') )
$('#' + e.target.id.replace(/submit-/, '')).addSelectedToMenu( api.addMenuItemToBottom );
return false;
} else if ( target.hasClass('page-numbers') ) {
$.post( ajaxurl, e.target.href.replace(/.*\?/, '').replace(/action=([^&]*)/, '') + '&action=menu-get-metabox',
function( resp ) {
if ( -1 == resp.indexOf('replace-id') )
return;
var metaBoxData = $.parseJSON(resp),
toReplace = document.getElementById(metaBoxData['replace-id']),
placeholder = document.createElement('div'),
wrap = document.createElement('div');
if ( ! metaBoxData['markup'] || ! toReplace )
return;
wrap.innerHTML = metaBoxData['markup'] ? metaBoxData['markup'] : '';
toReplace.parentNode.insertBefore( placeholder, toReplace );
placeholder.parentNode.removeChild( toReplace );
placeholder.parentNode.insertBefore( wrap, placeholder );
placeholder.parentNode.removeChild( placeholder );
}
);
return false;
}
});
},
initTabManager : function() {
var fixed = $('.nav-tabs-wrapper'),
fluid = fixed.children('.nav-tabs'),
active = fluid.children('.nav-tab-active'),
tabs = fluid.children('.nav-tab'),
tabsWidth = 0,
fixedRight, fixedLeft,
arrowLeft, arrowRight, resizeTimer, css = {},
marginFluid = api.isRTL ? 'margin-right' : 'margin-left',
marginFixed = api.isRTL ? 'margin-left' : 'margin-right',
msPerPx = 2;
/**
* Refreshes the menu tabs.
* Will show and hide arrows where necessary.
* Scrolls to the active tab by default.
*
* @param savePosition {boolean} Optional. Prevents scrolling so
* that the current position is maintained. Default false.
**/
api.refreshMenuTabs = function( savePosition ) {
var fixedWidth = fixed.width(),
margin = 0, css = {};
fixedLeft = fixed.offset().left;
fixedRight = fixedLeft + fixedWidth;
if( !savePosition )
active.makeTabVisible();
// Prevent space from building up next to the last tab if there's more to show
if( tabs.last().isTabVisible() ) {
margin = fixed.width() - tabsWidth;
margin = margin > 0 ? 0 : margin;
css[marginFluid] = margin + 'px';
fluid.animate( css, 100, "linear" );
}
// Show the arrows only when necessary
if( fixedWidth > tabsWidth )
arrowLeft.add( arrowRight ).hide();
else
arrowLeft.add( arrowRight ).show();
}
$.fn.extend({
makeTabVisible : function() {
var t = this.eq(0), left, right, css = {}, shift = 0;
if( ! t.length ) return this;
left = t.offset().left;
right = left + t.outerWidth();
if( right > fixedRight )
shift = fixedRight - right;
else if ( left < fixedLeft )
shift = fixedLeft - left;
if( ! shift ) return this;
css[marginFluid] = "+=" + api.negateIfRTL * shift + 'px';
fluid.animate( css, Math.abs( shift ) * msPerPx, "linear" );
return this;
},
isTabVisible : function() {
var t = this.eq(0),
left = t.offset().left,
right = left + t.outerWidth();
return ( right <= fixedRight && left >= fixedLeft ) ? true : false;
}
});
// Find the width of all tabs
tabs.each(function(){
tabsWidth += $(this).outerWidth(true);
});
// Set up fixed margin for overflow, unset padding
css['padding'] = 0;
css[marginFixed] = (-1 * tabsWidth) + 'px';
fluid.css( css );
// Build tab navigation
arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>&laquo;</a></div>');
arrowRight = $('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>&raquo;</a></div>');
// Attach to the document
fixed.wrap('<div class="nav-tabs-nav"/>').parent().prepend( arrowLeft ).append( arrowRight );
// Set the menu tabs
api.refreshMenuTabs();
// Make sure the tabs reset on resize
$(window).resize(function() {
if( resizeTimer ) clearTimeout(resizeTimer);
resizeTimer = setTimeout( api.refreshMenuTabs, 200);
});
// Build arrow functions
$.each([{
arrow : arrowLeft,
next : "next",
last : "first",
operator : "+="
},{
arrow : arrowRight,
next : "prev",
last : "last",
operator : "-="
}], function(){
var that = this;
this.arrow.mousedown(function(){
var marginFluidVal = Math.abs( parseInt( fluid.css(marginFluid) ) ),
shift = marginFluidVal,
css = {};
if( "-=" == that.operator )
shift = Math.abs( tabsWidth - fixed.width() ) - marginFluidVal;
if( ! shift ) return;
css[marginFluid] = that.operator + shift + 'px';
fluid.animate( css, shift * msPerPx, "linear" );
}).mouseup(function(){
var tab, next;
fluid.stop(true);
tab = tabs[that.last]();
while( (next = tab[that.next]()) && next.length && ! next.isTabVisible() ) {
tab = next;
}
tab.makeTabVisible();
});
});
},
eventOnClickEditLink : function(clickedEl) {
var settings, item,
matchedSection = /#(.*)$/.exec(clickedEl.href);
if ( matchedSection && matchedSection[1] ) {
settings = $('#'+matchedSection[1]);
item = settings.parent();
if( 0 != item.length ) {
if( item.hasClass('menu-item-edit-inactive') ) {
if( ! settings.data('menu-item-data') ) {
settings.data( 'menu-item-data', settings.getItemData() );
}
settings.slideDown('fast');
item.removeClass('menu-item-edit-inactive')
.addClass('menu-item-edit-active');
} else {
settings.slideUp('fast');
item.removeClass('menu-item-edit-active')
.addClass('menu-item-edit-inactive');
}
return false;
}
}
},
eventOnClickCancelLink : function(clickedEl) {
var settings = $(clickedEl).closest('.menu-item-settings');
settings.setItemData( settings.data('menu-item-data') );
return false;
},
eventOnClickMenuSave : function(clickedEl) {
var locs = '',
menuName = $('#menu-name'),
menuNameVal = menuName.val();
// Cancel and warn if invalid menu name
if( !menuNameVal || menuNameVal == menuName.attr('title') || !menuNameVal.replace(/\s+/, '') ) {
menuName.parent().addClass('form-invalid');
return false;
}
// Copy menu theme locations
$('#nav-menu-theme-locations select').each(function() {
locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />';
});
$('#update-nav-menu').append( locs );
// Update menu item position data
api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
window.onbeforeunload = null;
return true;
},
eventOnClickMenuDelete : function(clickedEl) {
// Delete warning AYS
if ( confirm( navMenuL10n.warnDeleteMenu ) ) {
window.onbeforeunload = null;
return true;
}
return false;
},
eventOnClickMenuItemDelete : function(clickedEl) {
var itemID = parseInt(clickedEl.id.replace('delete-', ''), 10);
api.removeMenuItem( $('#menu-item-' + itemID) );
api.registerChange();
return false;
},
/**
* Process the quick search response into a search result
*
* @param string resp The server response to the query.
* @param object req The request arguments.
* @param jQuery panel The tabs panel we're searching in.
*/
processQuickSearchQueryResponse : function(resp, req, panel) {
var matched, newID,
takenIDs = {},
form = document.getElementById('nav-menu-meta'),
pattern = new RegExp('menu-item\\[(\[^\\]\]*)', 'g'),
$items = $('<div>').html(resp).find('li'),
$item;
if( ! $items.length ) {
$('.categorychecklist', panel).html( '<li><p>' + navMenuL10n.noResultsFound + '</p></li>' );
$('.spinner', panel).hide();
return;
}
$items.each(function(){
$item = $(this);
// make a unique DB ID number
matched = pattern.exec($item.html());
if ( matched && matched[1] ) {
newID = matched[1];
while( form.elements['menu-item[' + newID + '][menu-item-type]'] || takenIDs[ newID ] ) {
newID--;
}
takenIDs[newID] = true;
if ( newID != matched[1] ) {
$item.html( $item.html().replace(new RegExp(
'menu-item\\[' + matched[1] + '\\]', 'g'),
'menu-item[' + newID + ']'
) );
}
}
});
$('.categorychecklist', panel).html( $items );
$('.spinner', panel).hide();
},
removeMenuItem : function(el) {
var children = el.childMenuItems();
el.addClass('deleting').animate({
opacity : 0,
height: 0
}, 350, function() {
var ins = $('#menu-instructions');
el.remove();
children.shiftDepthClass(-1).updateParentMenuItemDBId();
if( ! ins.siblings().length )
ins.removeClass('menu-instructions-inactive');
});
},
depthToPx : function(depth) {
return depth * api.options.menuItemDepthPerLevel;
},
pxToDepth : function(px) {
return Math.floor(px / api.options.menuItemDepthPerLevel);
}
};
$(document).ready(function(){ wpNavMenu.init(); });
})(jQuery);

1
wp-admin/js/nav-menu.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
// Password strength meter
function passwordStrength(password1, username, password2) {
var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
// password 1 != password 2
if ( (password1 != password2) && password2.length > 0)
return mismatch
//password < 4
if ( password1.length < 4 )
return shortPass
//password1 == username
if ( password1.toLowerCase() == username.toLowerCase() )
return badPass;
if ( password1.match(/[0-9]/) )
symbolSize +=10;
if ( password1.match(/[a-z]/) )
symbolSize +=26;
if ( password1.match(/[A-Z]/) )
symbolSize +=26;
if ( password1.match(/[^a-zA-Z0-9]/) )
symbolSize +=31;
natLog = Math.log( Math.pow(symbolSize, password1.length) );
score = natLog / Math.LN2;
if (score < 40 )
return badPass
if (score < 56 )
return goodPass
return strongPass;
}

View File

@ -0,0 +1 @@
function passwordStrength(f,i,d){var k=1,h=2,b=3,a=4,c=5,g=0,j,e;if((f!=d)&&d.length>0){return c}if(f.length<4){return k}if(f.toLowerCase()==i.toLowerCase()){return h}if(f.match(/[0-9]/)){g+=10}if(f.match(/[a-z]/)){g+=26}if(f.match(/[A-Z]/)){g+=26}if(f.match(/[^a-zA-Z0-9]/)){g+=31}j=Math.log(Math.pow(g,f.length));e=j/Math.LN2;if(e<40){return h}if(e<56){return b}return a};

View File

@ -0,0 +1,53 @@
/* Plugin Browser Thickbox related JS*/
var tb_position;
jQuery(document).ready(function($) {
tb_position = function() {
var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width, adminbar_height = 0;
if ( $('body.admin-bar').length )
adminbar_height = 28;
if ( tbWindow.size() ) {
tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
if ( typeof document.body.style.maxWidth != 'undefined' )
tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
};
return $('a.thickbox').each( function() {
var href = $(this).attr('href');
if ( ! href )
return;
href = href.replace(/&width=[0-9]+/g, '');
href = href.replace(/&height=[0-9]+/g, '');
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
});
};
$(window).resize(function(){ tb_position(); });
$('#dashboard_plugins a.thickbox, .plugins a.thickbox').click( function() {
tb_click.call(this);
$('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
$('#TB_ajaxWindowTitle').html('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).attr('title') );
return false;
});
/* Plugin install related JS*/
$('#plugin-information #sidemenu a').click( function() {
var tab = $(this).attr('name');
//Flip the tab
$('#plugin-information-header a.current').removeClass('current');
$(this).addClass('current');
//Flip the content.
$('#section-holder div.section').hide(); //Hide 'em all
$('#section-' + tab).show();
return false;
});
$('a.install-now').click( function() {
return confirm( plugininstallL10n.ays );
});
});

1
wp-admin/js/plugin-install.min.js vendored Normal file
View File

@ -0,0 +1 @@
var tb_position;jQuery(document).ready(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a("#dashboard_plugins a.thickbox, .plugins a.thickbox").click(function(){tb_click.call(this);a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});a("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+a(this).attr("title"));return false});a("#plugin-information #sidemenu a").click(function(){var b=a(this).attr("name");a("#plugin-information-header a.current").removeClass("current");a(this).addClass("current");a("#section-holder div.section").hide();a("#section-"+b).show();return false});a("a.install-now").click(function(){return confirm(plugininstallL10n.ays)})});

794
wp-admin/js/post.js Normal file
View File

@ -0,0 +1,794 @@
var tagBox, commentsBox, editPermalink, makeSlugeditClickable, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint;
// return an array with any duplicate, whitespace or values removed
function array_unique_noempty(a) {
var out = [];
jQuery.each( a, function(key, val) {
val = jQuery.trim(val);
if ( val && jQuery.inArray(val, out) == -1 )
out.push(val);
} );
return out;
}
(function($){
tagBox = {
clean : function(tags) {
var comma = postL10n.comma;
if ( ',' !== comma )
tags = tags.replace(new RegExp(comma, 'g'), ',');
tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
if ( ',' !== comma )
tags = tags.replace(/,/g, comma);
return tags;
},
parseTags : function(el) {
var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.tagsdiv'),
thetags = taxbox.find('.the-tags'), comma = postL10n.comma,
current_tags = thetags.val().split(comma), new_tags = [];
delete current_tags[num];
$.each( current_tags, function(key, val) {
val = $.trim(val);
if ( val ) {
new_tags.push(val);
}
});
thetags.val( this.clean( new_tags.join(comma) ) );
this.quickClicks(taxbox);
return false;
},
quickClicks : function(el) {
var thetags = $('.the-tags', el),
tagchecklist = $('.tagchecklist', el),
id = $(el).attr('id'),
current_tags, disabled;
if ( !thetags.length )
return;
disabled = thetags.prop('disabled');
current_tags = thetags.val().split(postL10n.comma);
tagchecklist.empty();
$.each( current_tags, function( key, val ) {
var span, xbutton;
val = $.trim( val );
if ( ! val )
return;
// Create a new span, and ensure the text is properly escaped.
span = $('<span />').text( val );
// If tags editing isn't disabled, create the X button.
if ( ! disabled ) {
xbutton = $( '<a id="' + id + '-check-num-' + key + '" class="ntdelbutton">X</a>' );
xbutton.click( function(){ tagBox.parseTags(this); });
span.prepend('&nbsp;').prepend( xbutton );
}
// Append the span to the tag list.
tagchecklist.append( span );
});
},
flushTags : function(el, a, f) {
a = a || false;
var tags = $('.the-tags', el),
newtag = $('input.newtag', el),
comma = postL10n.comma,
newtags, text;
text = a ? $(a).text() : newtag.val();
tagsval = tags.val();
newtags = tagsval ? tagsval + comma + text : text;
newtags = this.clean( newtags );
newtags = array_unique_noempty( newtags.split(comma) ).join(comma);
tags.val(newtags);
this.quickClicks(el);
if ( !a )
newtag.val('');
if ( 'undefined' == typeof(f) )
newtag.focus();
return false;
},
get : function(id) {
var tax = id.substr(id.indexOf('-')+1);
$.post(ajaxurl, {'action':'get-tagcloud', 'tax':tax}, function(r, stat) {
if ( 0 == r || 'success' != stat )
r = wpAjax.broken;
r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>');
$('a', r).click(function(){
tagBox.flushTags( $(this).closest('.inside').children('.tagsdiv'), this);
return false;
});
$('#'+id).after(r);
});
},
init : function() {
var t = this, ajaxtag = $('div.ajaxtag');
$('.tagsdiv').each( function() {
tagBox.quickClicks(this);
});
$('input.tagadd', ajaxtag).click(function(){
t.flushTags( $(this).closest('.tagsdiv') );
});
$('div.taghint', ajaxtag).click(function(){
$(this).css('visibility', 'hidden').parent().siblings('.newtag').focus();
});
$('input.newtag', ajaxtag).blur(function() {
if ( this.value == '' )
$(this).parent().siblings('.taghint').css('visibility', '');
}).focus(function(){
$(this).parent().siblings('.taghint').css('visibility', 'hidden');
}).keyup(function(e){
if ( 13 == e.which ) {
tagBox.flushTags( $(this).closest('.tagsdiv') );
return false;
}
}).keypress(function(e){
if ( 13 == e.which ) {
e.preventDefault();
return false;
}
}).each(function(){
var tax = $(this).closest('div.tagsdiv').attr('id');
$(this).suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: postL10n.comma + ' ' } );
});
// save tags on post save/publish
$('#post').submit(function(){
$('div.tagsdiv').each( function() {
tagBox.flushTags(this, false, 1);
});
});
// tag cloud
$('a.tagcloud-link').click(function(){
tagBox.get( $(this).attr('id') );
$(this).unbind().click(function(){
$(this).siblings('.the-tagcloud').toggle();
return false;
});
return false;
});
}
};
commentsBox = {
st : 0,
get : function(total, num) {
var st = this.st, data;
if ( ! num )
num = 20;
this.st += num;
this.total = total;
$('#commentsdiv .spinner').show();
data = {
'action' : 'get-comments',
'mode' : 'single',
'_ajax_nonce' : $('#add_comment_nonce').val(),
'p' : $('#post_ID').val(),
'start' : st,
'number' : num
};
$.post(ajaxurl, data,
function(r) {
r = wpAjax.parseAjaxResponse(r);
$('#commentsdiv .widefat').show();
$('#commentsdiv .spinner').hide();
if ( 'object' == typeof r && r.responses[0] ) {
$('#the-comment-list').append( r.responses[0].data );
theList = theExtraList = null;
$("a[className*=':']").unbind();
if ( commentsBox.st > commentsBox.total )
$('#show-comments').hide();
else
$('#show-comments').show().children('a').html(postL10n.showcomm);
return;
} else if ( 1 == r ) {
$('#show-comments').html(postL10n.endcomm);
return;
}
$('#the-comment-list').append('<tr><td colspan="2">'+wpAjax.broken+'</td></tr>');
}
);
return false;
}
};
WPSetThumbnailHTML = function(html){
$('.inside', '#postimagediv').html(html);
};
WPSetThumbnailID = function(id){
var field = $('input[value="_thumbnail_id"]', '#list-table');
if ( field.size() > 0 ) {
$('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id);
}
};
WPRemoveThumbnail = function(nonce){
$.post(ajaxurl, {
action:"set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
}, function(str){
if ( str == '0' ) {
alert( setPostThumbnailL10n.error );
} else {
WPSetThumbnailHTML(str);
}
}
);
};
})(jQuery);
jQuery(document).ready( function($) {
var stamp, visibility, sticky = '', last = 0, co = $('#content');
postboxes.add_postbox_toggles(pagenow);
// multi-taxonomies
if ( $('#tagsdiv-post_tag').length ) {
tagBox.init();
} else {
$('#side-sortables, #normal-sortables, #advanced-sortables').children('div.postbox').each(function(){
if ( this.id.indexOf('tagsdiv-') === 0 ) {
tagBox.init();
return false;
}
});
}
// categories
$('.categorydiv').each( function(){
var this_id = $(this).attr('id'), noSyncChecks = false, syncChecks, catAddAfter, taxonomyParts, taxonomy, settingName;
taxonomyParts = this_id.split('-');
taxonomyParts.shift();
taxonomy = taxonomyParts.join('-');
settingName = taxonomy + '_tab';
if ( taxonomy == 'category' )
settingName = 'cats';
// TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js
$('a', '#' + taxonomy + '-tabs').click( function(){
var t = $(this).attr('href');
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
$('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide();
$(t).show();
if ( '#' + taxonomy + '-all' == t )
deleteUserSetting(settingName);
else
setUserSetting(settingName, 'pop');
return false;
});
if ( getUserSetting(settingName) )
$('a[href="#' + taxonomy + '-pop"]', '#' + taxonomy + '-tabs').click();
// Ajax Cat
$('#new' + taxonomy).one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
$('#new' + taxonomy).keypress( function(event){
if( 13 === event.keyCode ) {
event.preventDefault();
$('#' + taxonomy + '-add-submit').click();
}
});
$('#' + taxonomy + '-add-submit').click( function(){ $('#new' + taxonomy).focus(); });
syncChecks = function() {
if ( noSyncChecks )
return;
noSyncChecks = true;
var th = jQuery(this), c = th.is(':checked'), id = th.val().toString();
$('#in-' + taxonomy + '-' + id + ', #in-' + taxonomy + '-category-' + id).prop( 'checked', c );
noSyncChecks = false;
};
catAddBefore = function( s ) {
if ( !$('#new'+taxonomy).val() )
return false;
s.data += '&' + $( ':checked', '#'+taxonomy+'checklist' ).serialize();
$( '#' + taxonomy + '-add-submit' ).prop( 'disabled', true );
return s;
};
catAddAfter = function( r, s ) {
var sup, drop = $('#new'+taxonomy+'_parent');
$( '#' + taxonomy + '-add-submit' ).prop( 'disabled', false );
if ( 'undefined' != s.parsed.responses[0] && (sup = s.parsed.responses[0].supplemental.newcat_parent) ) {
drop.before(sup);
drop.remove();
}
};
$('#' + taxonomy + 'checklist').wpList({
alt: '',
response: taxonomy + '-ajax-response',
addBefore: catAddBefore,
addAfter: catAddAfter
});
$('#' + taxonomy + '-add-toggle').click( function() {
$('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' );
$('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click();
$('#new'+taxonomy).focus();
return false;
});
$('#' + taxonomy + 'checklist li.popular-category input[type="checkbox"], #' + taxonomy + 'checklist-pop input[type="checkbox"]').live( 'click', function(){
var t = $(this), c = t.is(':checked'), id = t.val();
if ( id && t.parents('#taxonomy-'+taxonomy).length )
$('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c );
});
}); // end cats
// Custom Fields
if ( $('#postcustom').length ) {
$('#the-list').wpList( { addAfter: function( xml, s ) {
$('table#list-table').show();
}, addBefore: function( s ) {
s.data += '&post_id=' + $('#post_ID').val();
return s;
}
});
}
// submitdiv
if ( $('#submitdiv').length ) {
stamp = $('#timestamp').html();
visibility = $('#post-visibility-display').html();
function updateVisibility() {
var pvSelect = $('#post-visibility-select');
if ( $('input:radio:checked', pvSelect).val() != 'public' ) {
$('#sticky').prop('checked', false);
$('#sticky-span').hide();
} else {
$('#sticky-span').show();
}
if ( $('input:radio:checked', pvSelect).val() != 'password' ) {
$('#password-span').hide();
} else {
$('#password-span').show();
}
}
function updateText() {
if ( ! $('#timestampdiv').length )
return true;
var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'),
optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(),
mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val();
attemptedDate = new Date( aa, mm - 1, jj, hh, mn );
originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val() );
currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) {
$('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
return false;
} else {
$('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
}
if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
publishOn = postL10n.publishOnFuture;
$('#publish').val( postL10n.schedule );
} else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
publishOn = postL10n.publishOn;
$('#publish').val( postL10n.publish );
} else {
publishOn = postL10n.publishOnPast;
$('#publish').val( postL10n.update );
}
if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
$('#timestamp').html(stamp);
} else {
$('#timestamp').html(
publishOn + ' <b>' +
$('option[value="' + $('#mm').val() + '"]', '#mm').text() + ' ' +
jj + ', ' +
aa + ' @ ' +
hh + ':' +
mn + '</b> '
);
}
if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) {
$('#publish').val( postL10n.update );
if ( optPublish.length == 0 ) {
postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
} else {
optPublish.html( postL10n.privatelyPublished );
}
$('option[value="publish"]', postStatus).prop('selected', true);
$('.edit-post-status', '#misc-publishing-actions').hide();
} else {
if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
if ( optPublish.length ) {
optPublish.remove();
postStatus.val($('#hidden_post_status').val());
}
} else {
optPublish.html( postL10n.published );
}
if ( postStatus.is(':hidden') )
$('.edit-post-status', '#misc-publishing-actions').show();
}
$('#post-status-display').html($('option:selected', postStatus).text());
if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) {
$('#save-post').hide();
} else {
$('#save-post').show();
if ( $('option:selected', postStatus).val() == 'pending' ) {
$('#save-post').show().val( postL10n.savePending );
} else {
$('#save-post').show().val( postL10n.saveDraft );
}
}
return true;
}
$('.edit-visibility', '#visibility').click(function () {
if ($('#post-visibility-select').is(":hidden")) {
updateVisibility();
$('#post-visibility-select').slideDown('fast');
$(this).hide();
}
return false;
});
$('.cancel-post-visibility', '#post-visibility-select').click(function () {
$('#post-visibility-select').slideUp('fast');
$('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true);
$('#post_password').val($('#hidden_post_password').val());
$('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked'));
$('#post-visibility-display').html(visibility);
$('.edit-visibility', '#visibility').show();
updateText();
return false;
});
$('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels
var pvSelect = $('#post-visibility-select');
pvSelect.slideUp('fast');
$('.edit-visibility', '#visibility').show();
updateText();
if ( $('input:radio:checked', pvSelect).val() != 'public' ) {
$('#sticky').prop('checked', false);
} // WEAPON LOCKED
if ( true == $('#sticky').prop('checked') ) {
sticky = 'Sticky';
} else {
sticky = '';
}
$('#post-visibility-display').html( postL10n[$('input:radio:checked', pvSelect).val() + sticky] );
return false;
});
$('input:radio', '#post-visibility-select').change(function() {
updateVisibility();
});
$('#timestampdiv').siblings('a.edit-timestamp').click(function() {
if ($('#timestampdiv').is(":hidden")) {
$('#timestampdiv').slideDown('fast');
$('#mm').focus();
$(this).hide();
}
return false;
});
$('.cancel-timestamp', '#timestampdiv').click(function() {
$('#timestampdiv').slideUp('fast');
$('#mm').val($('#hidden_mm').val());
$('#jj').val($('#hidden_jj').val());
$('#aa').val($('#hidden_aa').val());
$('#hh').val($('#hidden_hh').val());
$('#mn').val($('#hidden_mn').val());
$('#timestampdiv').siblings('a.edit-timestamp').show();
updateText();
return false;
});
$('.save-timestamp', '#timestampdiv').click(function () { // crazyhorse - multiple ok cancels
if ( updateText() ) {
$('#timestampdiv').slideUp('fast');
$('#timestampdiv').siblings('a.edit-timestamp').show();
}
return false;
});
$('#post').on( 'submit', function(e){
if ( ! updateText() ) {
e.preventDefault();
$('#timestampdiv').show();
$('#publishing-action .spinner').hide();
$('#publish').prop('disabled', false).removeClass('button-primary-disabled');
return false;
}
});
$('#post-status-select').siblings('a.edit-post-status').click(function() {
if ($('#post-status-select').is(":hidden")) {
$('#post-status-select').slideDown('fast');
$(this).hide();
}
return false;
});
$('.save-post-status', '#post-status-select').click(function() {
$('#post-status-select').slideUp('fast');
$('#post-status-select').siblings('a.edit-post-status').show();
updateText();
return false;
});
$('.cancel-post-status', '#post-status-select').click(function() {
$('#post-status-select').slideUp('fast');
$('#post_status').val($('#hidden_post_status').val());
$('#post-status-select').siblings('a.edit-post-status').show();
updateText();
return false;
});
} // end submitdiv
// permalink
if ( $('#edit-slug-box').length ) {
editPermalink = function(post_id) {
var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html();
$('#view-post-btn').hide();
b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
b.children('.save').click(function() {
var new_slug = e.children('input').val();
if ( new_slug == $('#editable-post-name-full').text() ) {
return $('.cancel', '#edit-slug-buttons').click();
}
$.post(ajaxurl, {
action: 'sample-permalink',
post_id: post_id,
new_slug: new_slug,
new_title: $('#title').val(),
samplepermalinknonce: $('#samplepermalinknonce').val()
}, function(data) {
$('#edit-slug-box').html(data);
b.html(revert_b);
real_slug.val(new_slug);
makeSlugeditClickable();
$('#view-post-btn').show();
});
return false;
});
$('.cancel', '#edit-slug-buttons').click(function() {
$('#view-post-btn').show();
e.html(revert_e);
b.html(revert_b);
real_slug.val(revert_slug);
return false;
});
for ( i = 0; i < full.length; ++i ) {
if ( '%' == full.charAt(i) )
c++;
}
slug_value = ( c > full.length / 4 ) ? '' : full;
e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){
var key = e.keyCode || 0;
// on enter, just save the new slug, don't save the post
if ( 13 == key ) {
b.children('.save').click();
return false;
}
if ( 27 == key ) {
b.children('.cancel').click();
return false;
}
real_slug.val(this.value);
}).focus();
}
makeSlugeditClickable = function() {
$('#editable-post-name').click(function() {
$('#edit-slug-buttons').children('.edit-slug').click();
});
}
makeSlugeditClickable();
}
// word count
if ( typeof(wpWordCount) != 'undefined' ) {
$(document).triggerHandler('wpcountwords', [ co.val() ]);
co.keyup( function(e) {
var k = e.keyCode || e.charCode;
if ( k == last )
return true;
if ( 13 == k || 8 == last || 46 == last )
$(document).triggerHandler('wpcountwords', [ co.val() ]);
last = k;
return true;
});
}
wptitlehint = function(id) {
id = id || 'title';
var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text');
if ( title.val() == '' )
titleprompt.removeClass('screen-reader-text');
titleprompt.click(function(){
$(this).addClass('screen-reader-text');
title.focus();
});
title.blur(function(){
if ( this.value == '' )
titleprompt.removeClass('screen-reader-text');
}).focus(function(){
titleprompt.addClass('screen-reader-text');
}).keydown(function(e){
titleprompt.addClass('screen-reader-text');
$(this).unbind(e);
});
}
wptitlehint();
// resizable textarea#content
(function() {
var textarea = $('textarea#content'), offset = null, el;
// No point for touch devices
if ( !textarea.length || 'ontouchstart' in window )
return;
function dragging(e) {
textarea.height( Math.max(50, offset + e.pageY) + 'px' );
return false;
}
function endDrag(e) {
var height;
textarea.focus();
$(document).unbind('mousemove', dragging).unbind('mouseup', endDrag);
height = parseInt( textarea.css('height'), 10 );
// sanity check
if ( height && height > 50 && height < 5000 )
setUserSetting( 'ed_size', height );
}
textarea.css('resize', 'none');
el = $('<div id="content-resize-handle"><br></div>');
$('#wp-content-wrap').append(el);
el.on('mousedown', function(e) {
offset = textarea.height() - e.pageY;
textarea.blur();
$(document).mousemove(dragging).mouseup(endDrag);
return false;
});
})();
if ( typeof(tinymce) != 'undefined' ) {
tinymce.onAddEditor.add(function(mce, ed){
// iOS expands the iframe to full height and the user cannot adjust it.
if ( ed.id != 'content' || tinymce.isIOS5 )
return;
function getHeight() {
var height, node = document.getElementById('content_ifr'),
ifr_height = node ? parseInt( node.style.height, 10 ) : 0,
tb_height = $('#content_tbl tr.mceFirst').height();
if ( !ifr_height || !tb_height )
return false;
// total height including toolbar and statusbar
height = ifr_height + tb_height + 21;
// textarea height = total height - 33px toolbar
height -= 33;
return height;
}
// resize TinyMCE to match the textarea height when switching Text -> Visual
ed.onLoadContent.add( function(ed, o) {
var ifr_height, node = document.getElementById('content'),
height = node ? parseInt( node.style.height, 10 ) : 0,
tb_height = $('#content_tbl tr.mceFirst').height() || 33;
// height cannot be under 50 or over 5000
if ( !height || height < 50 || height > 5000 )
height = 360; // default height for the main editor
if ( getUserSetting( 'ed_size' ) > 5000 )
setUserSetting( 'ed_size', 360 );
// compensate for padding and toolbars
ifr_height = ( height - tb_height ) + 12;
// sanity check
if ( ifr_height > 50 && ifr_height < 5000 ) {
$('#content_tbl').css('height', '' );
$('#content_ifr').css('height', ifr_height + 'px' );
}
});
// resize the textarea to match TinyMCE's height when switching Visual -> Text
ed.onSaveContent.add( function(ed, o) {
var height = getHeight();
if ( !height || height < 50 || height > 5000 )
return;
$('textarea#content').css( 'height', height + 'px' );
});
// save on resizing TinyMCE
ed.onPostRender.add(function() {
$('#content_resize').on('mousedown.wp-mce-resize', function(e){
$(document).on('mouseup.wp-mce-resize', function(e){
var height;
$(document).off('mouseup.wp-mce-resize');
height = getHeight();
// sanity check
if ( height && height > 50 && height < 5000 )
setUserSetting( 'ed_size', height );
});
});
});
});
}
});

1
wp-admin/js/post.min.js vendored Normal file

File diff suppressed because one or more lines are too long

186
wp-admin/js/postbox.js Normal file
View File

@ -0,0 +1,186 @@
var postboxes;
(function($) {
postboxes = {
add_postbox_toggles : function(page, args) {
var self = this;
self.init(page, args);
$('.postbox h3, .postbox .handlediv').bind('click.postboxes', function() {
var p = $(this).parent('.postbox'), id = p.attr('id');
if ( 'dashboard_browser_nag' == id )
return;
p.toggleClass('closed');
if ( page != 'press-this' )
self.save_state(page);
if ( id ) {
if ( !p.hasClass('closed') && $.isFunction(postboxes.pbshow) )
self.pbshow(id);
else if ( p.hasClass('closed') && $.isFunction(postboxes.pbhide) )
self.pbhide(id);
}
});
$('.postbox h3 a').click( function(e) {
e.stopPropagation();
});
$('.postbox a.dismiss').bind('click.postboxes', function(e) {
var hide_id = $(this).parents('.postbox').attr('id') + '-hide';
$( '#' + hide_id ).prop('checked', false).triggerHandler('click');
return false;
});
$('.hide-postbox-tog').bind('click.postboxes', function() {
var box = $(this).val();
if ( $(this).prop('checked') ) {
$('#' + box).show();
if ( $.isFunction( postboxes.pbshow ) )
self.pbshow( box );
} else {
$('#' + box).hide();
if ( $.isFunction( postboxes.pbhide ) )
self.pbhide( box );
}
self.save_state(page);
self._mark_area();
});
$('.columns-prefs input[type="radio"]').bind('click.postboxes', function(){
var n = parseInt($(this).val(), 10);
if ( n ) {
self._pb_edit(n);
self.save_order(page);
}
});
},
init : function(page, args) {
var isMobile = $(document.body).hasClass('mobile');
$.extend( this, args || {} );
$('#wpbody-content').css('overflow','hidden');
$('.meta-box-sortables').sortable({
placeholder: 'sortable-placeholder',
connectWith: '.meta-box-sortables',
items: '.postbox',
handle: '.hndle',
cursor: 'move',
delay: ( isMobile ? 200 : 0 ),
distance: 2,
tolerance: 'pointer',
forcePlaceholderSize: true,
helper: 'clone',
opacity: 0.65,
stop: function(e,ui) {
if ( $(this).find('#dashboard_browser_nag').is(':visible') && 'dashboard_browser_nag' != this.firstChild.id ) {
$(this).sortable('cancel');
return;
}
postboxes.save_order(page);
},
receive: function(e,ui) {
if ( 'dashboard_browser_nag' == ui.item[0].id )
$(ui.sender).sortable('cancel');
postboxes._mark_area();
}
});
if ( isMobile ) {
$(document.body).bind('orientationchange.postboxes', function(){ postboxes._pb_change(); });
this._pb_change();
}
this._mark_area();
},
save_state : function(page) {
var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','),
hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
$.post(ajaxurl, {
action: 'closed-postboxes',
closed: closed,
hidden: hidden,
closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
page: page
});
},
save_order : function(page) {
var postVars, page_columns = $('.columns-prefs input:checked').val() || 0;
postVars = {
action: 'meta-box-order',
_ajax_nonce: $('#meta-box-order-nonce').val(),
page_columns: page_columns,
page: page
}
$('.meta-box-sortables').each( function() {
postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(',');
} );
$.post( ajaxurl, postVars );
},
_mark_area : function() {
var visible = $('div.postbox:visible').length, side = $('#post-body #side-sortables');
$('#dashboard-widgets .meta-box-sortables:visible').each(function(n, el){
var t = $(this);
if ( visible == 1 || t.children('.postbox:visible').length )
t.removeClass('empty-container');
else
t.addClass('empty-container');
});
if ( side.length ) {
if ( side.children('.postbox:visible').length )
side.removeClass('empty-container');
else if ( $('#postbox-container-1').css('width') == '280px' )
side.addClass('empty-container');
}
},
_pb_edit : function(n) {
var el = $('.metabox-holder').get(0);
el.className = el.className.replace(/columns-\d+/, 'columns-' + n);
},
_pb_change : function() {
var check = $( 'label.columns-prefs-1 input[type="radio"]' );
switch ( window.orientation ) {
case 90:
case -90:
if ( !check.length || !check.is(':checked') )
this._pb_edit(2);
break;
case 0:
case 180:
if ( $('#poststuff').length ) {
this._pb_edit(1);
} else {
if ( !check.length || !check.is(':checked') )
this._pb_edit(2);
}
break;
}
},
/* Callbacks */
pbshow : false,
pbhide : false
};
}(jQuery));

1
wp-admin/js/postbox.min.js vendored Normal file
View File

@ -0,0 +1 @@
var postboxes;(function(a){postboxes={add_postbox_toggles:function(d,c){var b=this;b.init(d,c);a(".postbox h3, .postbox .handlediv").bind("click.postboxes",function(){var e=a(this).parent(".postbox"),f=e.attr("id");if("dashboard_browser_nag"==f){return}e.toggleClass("closed");if(d!="press-this"){b.save_state(d)}if(f){if(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)){b.pbshow(f)}else{if(e.hasClass("closed")&&a.isFunction(postboxes.pbhide)){b.pbhide(f)}}}});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".postbox a.dismiss").bind("click.postboxes",function(g){var f=a(this).parents(".postbox").attr("id")+"-hide";a("#"+f).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").bind("click.postboxes",function(){var e=a(this).val();if(a(this).prop("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){b.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){b.pbhide(e)}}b.save_state(d);b._mark_area()});a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var e=parseInt(a(this).val(),10);if(e){b._pb_edit(e);b.save_order(d)}})},init:function(d,c){var b=a(document.body).hasClass("mobile");a.extend(this,c||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",delay:(b?200:0),distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,stop:function(g,f){if(a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id){a(this).sortable("cancel");return}postboxes.save_order(d)},receive:function(g,f){if("dashboard_browser_nag"==f.item[0].id){a(f.sender).sortable("cancel")}postboxes._mark_area()}});if(b){a(document.body).bind("orientationchange.postboxes",function(){postboxes._pb_change()});this._pb_change()}this._mark_area()},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},_mark_area:function(){var c=a("div.postbox:visible").length,b=a("#post-body #side-sortables");a("#dashboard-widgets .meta-box-sortables:visible").each(function(f,e){var d=a(this);if(c==1||d.children(".postbox:visible").length){d.removeClass("empty-container")}else{d.addClass("empty-container")}});if(b.length){if(b.children(".postbox:visible").length){b.removeClass("empty-container")}else{if(a("#postbox-container-1").css("width")=="280px"){b.addClass("empty-container")}}}},_pb_edit:function(c){var b=a(".metabox-holder").get(0);b.className=b.className.replace(/columns-\d+/,"columns-"+c)},_pb_change:function(){var b=a('label.columns-prefs-1 input[type="radio"]');switch(window.orientation){case 90:case -90:if(!b.length||!b.is(":checked")){this._pb_edit(2)}break;case 0:case 180:if(a("#poststuff").length){this._pb_edit(1)}else{if(!b.length||!b.is(":checked")){this._pb_edit(2)}}break}},pbshow:false,pbhide:false}}(jQuery));

View File

@ -0,0 +1,39 @@
<?php
// The JS here is purposefully obfuscated to preserve mystery and romance.
// If you want to see behind the curtain, visit http://core.trac.wordpress.org/ticket/15262
if ( !defined( 'ABSPATH' ) )
exit;
/** @ignore */
function dvortr( $str ) {
return strtr(
$str,
'\',.pyfgcrl/=\\aoeuidhtns-;qjkxbmwvz"<>PYFGCRL?+|AOEUIDHTNS_:QJKXBMWVZ[]',
'qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?-='
);
}
$j = esc_url( site_url( '/wp-includes/js/jquery/jquery.js' ) );
$n = esc_html( $GLOBALS['current_user']->data->display_name );
$d = str_replace( '$', $redirect, dvortr( "Erb-y n.y ydco dall.b aiacbv Wa ce]-irxajt- dp.u]-$-VIr XajtWzaVv" ) );
wp_die( <<<EOEE
<style type="text/css">
html body { font-family: courier, monospace; }
#hal { text-decoration: blink; }
</style>
<script type="text/javascript" src="$j"></script>
<script type="text/javascript">
/* <![CDATA[ */
var n = '$n';
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('6(4(){2 e=6(\\'#Q\\').v();2 i=\\'\\\\\\',.R/=\\\\\\\\S-;T"<>U?+|V:W[]X{}\\'.u(\\'\\');2 o=\\'Y[]\\\\\\\\Z;\\\\\\'10,./11{}|12:"13<>?-=14+\\'.u(\\'\\');2 5=4(s){r=\\'\\';6.15(s.u(\\'\\'),4(){2 t=16.D();2 c=6.17(t,i);r+=\\'\$\\'==t?n:(-1==c?t:o[c])});j r};2 a=[\\'O.E[18 e.y.19.1a\\',\\'1b 1c. 1d .1e.,1f 1g\\',\\'O.E e.1h 1i 8\\',\\'9\\',\\'0\\'];2 b=[\\'<1j. 1k \$1l\\',\\'1m. 1n 1o 1p\\',\\'1q, 1r. ,1s. 1t\\'];2 w=[];2 h=6(5(\\'#1u\\'));6(5(\\'1v\\')).1w(4(e){7(1x!==e.1y){j}7(x&&x.F){x.F();j G}1z.1A=6(5(\\'#1B\\')).1C(\\'1D\\');j G});2 k=4(){2 l=a.H();7(\\'I\\'==J l){7(m){2 c={};c[5(\\'1E\\')]=5(\\'1F\\');c[5(\\'1G\\')]=5(\\'1H..b\\');6(5(\\'1I 1J\\')).1K(c);p();h.v().1L({1M:1},z,\\'1N\\',4(){h.K()});d(m,L)}j}w=5(l).u(\\'\\');A()};2 A=4(){B=w.H();7(\\'I\\'==J B){7(m){h.M(5(\\'1O 1P\\'));d(k,C)}N{7(a.P){d(p,C);d(k,z)}N{d(4(){p();h.v()},C);d(4(){e.K()},L)}}j}h.M(B.D());d(A,1Q)};2 m=4(){a=b;m=1R;k()};p=4(){2 f=6(\\'p\\').1S(0);2 g=6.1T(f.q).1U();1V(2 g=f.q.P;g>0;g--){7(3==f.q[g-1].1W||\\'1X\\'==f.q[g-1].1Y.1Z()){f.20(f.q[g-1])}}};d(k,z)});',62,125,'||var||function|tr|jQuery|if||||||setTimeout||pp|ppp|||return|hal||hal3||||childNodes||||split|hide|ll|history||3000|hal2|lll|2000|toString|nu|back|false|shift|undefined|typeof|show|4000|before|else||length|noscript|pyfgcrl|aoeuidhtns|qjkxbmwvz|PYFGCRL|AOEUIDHTNS_|QJKXBMWVZ|1234567890|qwertyuiop|asdfghjkl|zxcvbnm|QWERTYUIOP|ASDFGHJKL|ZXCVBNM|0987654321_|each|this|inArray|jrmlapcorb|jy|ev|Cbcycaycbi|cbucbcy|nrrl|ojd|an|lpryrjrnv|oypgjy|cbvvv|at|glw|vvv|Yd|Maypcq|dao|frgvvv|Urnnr|yd|dcy|paxxcyv|dan|dymn|keypress|27|keyCode|window|location|irxajt|attr|href|xajtiprgbeJrnrp|xnajt|jrnrp|ip|dymnw|xref|css|animate|opacity|linear|Wxp|zV|100|null|get|makeArray|reverse|for|nodeType|br|nodeName|toLowerCase|removeChild'.split('|'),0,{}))
/* ]]> */
</script>
<span id="noscript">$d</span>
<blink id="hal">&#x258c;</blink>
EOEE
,
dvortr( 'Eabi.p!' )
);

View File

@ -0,0 +1,21 @@
function WPSetAsThumbnail(id, nonce){
var $link = jQuery('a#wp-post-thumbnail-' + id);
$link.text( setPostThumbnailL10n.saving );
jQuery.post(ajaxurl, {
action:"set-post-thumbnail", post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
}, function(str){
var win = window.dialogArguments || opener || parent || top;
$link.text( setPostThumbnailL10n.setThumbnail );
if ( str == '0' ) {
alert( setPostThumbnailL10n.error );
} else {
jQuery('a.wp-post-thumbnail').show();
$link.text( setPostThumbnailL10n.done );
$link.fadeOut( 2000 );
win.WPSetThumbnailID(id);
win.WPSetThumbnailHTML(str);
}
}
);
}

1
wp-admin/js/set-post-thumbnail.min.js vendored Normal file
View File

@ -0,0 +1 @@
function WPSetAsThumbnail(c,b){var a=jQuery("a#wp-post-thumbnail-"+c);a.text(setPostThumbnailL10n.saving);jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:c,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(e){var d=window.dialogArguments||opener||parent||top;a.text(setPostThumbnailL10n.setThumbnail);if(e=="0"){alert(setPostThumbnailL10n.error)}else{jQuery("a.wp-post-thumbnail").show();a.text(setPostThumbnailL10n.done);a.fadeOut(2000);d.WPSetThumbnailID(c);d.WPSetThumbnailHTML(e)}})};

68
wp-admin/js/tags.js Normal file
View File

@ -0,0 +1,68 @@
jQuery(document).ready(function($) {
$('.delete-tag').live('click', function(e){
var t = $(this), tr = t.parents('tr'), r = true, data;
if ( 'undefined' != showNotice )
r = showNotice.warn();
if ( r ) {
data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag');
$.post(ajaxurl, data, function(r){
if ( '1' == r ) {
$('#ajax-response').empty();
tr.fadeOut('normal', function(){ tr.remove(); });
// Remove the term from the parent box and tag cloud
$('select#parent option[value="' + data.match(/tag_ID=(\d+)/)[1] + '"]').remove();
$('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove();
} else if ( '-1' == r ) {
$('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>');
tr.children().css('backgroundColor', '');
} else {
$('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.broken + '</p></div>');
tr.children().css('backgroundColor', '');
}
});
tr.children().css('backgroundColor', '#f33');
}
return false;
});
$('#submit').click(function(){
var form = $(this).parents('form');
if ( !validateForm( form ) )
return false;
$.post(ajaxurl, $('#addtag').serialize(), function(r){
$('#ajax-response').empty();
var res = wpAjax.parseAjaxResponse(r, 'ajax-response');
if ( ! res || res.errors )
return;
var parent = form.find('select#parent').val();
if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list.
$('.tags #tag-' + parent).after( res.responses[0].supplemental['noparents'] ); // As the parent exists, Insert the version with - - - prefixed
else
$('.tags').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
$('.tags .no-items').remove();
if ( form.find('select#parent') ) {
// Parents field exists, Add new term to the list.
var term = res.responses[1].supplemental;
// Create an indent for the Parent field
var indent = '';
for ( var i = 0; i < res.responses[1].position; i++ )
indent += '&nbsp;&nbsp;&nbsp;';
form.find('select#parent option:selected').after('<option value="' + term['term_id'] + '">' + indent + term['name'] + '</option>');
}
$('input[type="text"]:visible, textarea:visible', form).val('');
});
return false;
});
});

1
wp-admin/js/tags.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(a){a(".delete-tag").live("click",function(g){var b=a(this),f=b.parents("tr"),c=true,d;if("undefined"!=showNotice){c=showNotice.warn()}if(c){d=b.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag");a.post(ajaxurl,d,function(e){if("1"==e){a("#ajax-response").empty();f.fadeOut("normal",function(){f.remove()});a('select#parent option[value="'+d.match(/tag_ID=(\d+)/)[1]+'"]').remove();a("a.tag-link-"+d.match(/tag_ID=(\d+)/)[1]).remove()}else{if("-1"==e){a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>");f.children().css("backgroundColor","")}else{a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>");f.children().css("backgroundColor","")}}});f.children().css("backgroundColor","#f33")}return false});a("#submit").click(function(){var b=a(this).parents("form");if(!validateForm(b)){return false}a.post(ajaxurl,a("#addtag").serialize(),function(h){a("#ajax-response").empty();var f=wpAjax.parseAjaxResponse(h,"ajax-response");if(!f||f.errors){return}var g=b.find("select#parent").val();if(g>0&&a("#tag-"+g).length>0){a(".tags #tag-"+g).after(f.responses[0].supplemental.noparents)}else{a(".tags").prepend(f.responses[0].supplemental.parents)}a(".tags .no-items").remove();if(b.find("select#parent")){var e=f.responses[1].supplemental;var c="";for(var d=0;d<f.responses[1].position;d++){c+="&nbsp;&nbsp;&nbsp;"}b.find("select#parent option:selected").after('<option value="'+e.term_id+'">'+c+e.name+"</option>")}a('input[type="text"]:visible, textarea:visible',b).val("")});return false})});

View File

@ -0,0 +1,56 @@
var thickDims, tbWidth, tbHeight;
jQuery(document).ready(function($) {
thickDims = function() {
var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h;
w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 90;
h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 60;
if ( tbWindow.size() ) {
tbWindow.width(w).height(h);
$('#TB_iframeContent').width(w).height(h - 27);
tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'});
if ( typeof document.body.style.maxWidth != 'undefined' )
tbWindow.css({'top':'30px','margin-top':'0'});
}
};
thickDims();
$(window).resize( function() { thickDims() } );
$('a.thickbox-preview').click( function() {
tb_click.call(this);
var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text;
if ( tbWidth = href.match(/&tbWidth=[0-9]+/) )
tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10);
else
tbWidth = $(window).width() - 90;
if ( tbHeight = href.match(/&tbHeight=[0-9]+/) )
tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10);
else
tbHeight = $(window).height() - 60;
if ( alink.length ) {
url = alink.attr('href') || '';
text = alink.attr('title') || '';
link = '&nbsp; <a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>';
} else {
text = $(this).attr('title') || '';
link = '&nbsp; <span class="tb-theme-preview-link">' + text + '</span>';
}
$('#TB_title').css({'background-color':'#222','color':'#dfdfdf'});
$('#TB_closeAjaxWindow').css({'float':'left'});
$('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);
$('#TB_iframeContent').width('100%');
thickDims();
return false;
} );
});

1
wp-admin/js/theme-preview.min.js vendored Normal file
View File

@ -0,0 +1 @@
var thickDims,tbWidth,tbHeight;jQuery(document).ready(function(a){thickDims=function(){var f=a("#TB_window"),d=a(window).height(),b=a(window).width(),c,e;c=(tbWidth&&tbWidth<b-90)?tbWidth:b-90;e=(tbHeight&&tbHeight<d-60)?tbHeight:d-60;if(f.size()){f.width(c).height(e);a("#TB_iframeContent").width(c).height(e-27);f.css({"margin-left":"-"+parseInt((c/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:"30px","margin-top":"0"})}}};thickDims();a(window).resize(function(){thickDims()});a("a.thickbox-preview").click(function(){tb_click.call(this);var d=a(this).parents(".available-theme").find(".activatelink"),e="",b=a(this).attr("href"),c,f;if(tbWidth=b.match(/&tbWidth=[0-9]+/)){tbWidth=parseInt(tbWidth[0].replace(/[^0-9]+/g,""),10)}else{tbWidth=a(window).width()-90}if(tbHeight=b.match(/&tbHeight=[0-9]+/)){tbHeight=parseInt(tbHeight[0].replace(/[^0-9]+/g,""),10)}else{tbHeight=a(window).height()-60}if(d.length){c=d.attr("href")||"";f=d.attr("title")||"";e='&nbsp; <a href="'+c+'" target="_top" class="tb-theme-preview-link">'+f+"</a>"}else{f=a(this).attr("title")||"";e='&nbsp; <span class="tb-theme-preview-link">'+f+"</span>"}a("#TB_title").css({"background-color":"#222",color:"#dfdfdf"});a("#TB_closeAjaxWindow").css({"float":"left"});a("#TB_ajaxWindowTitle").css({"float":"right"}).html(e);a("#TB_iframeContent").width("100%");thickDims();return false})});

254
wp-admin/js/theme.js Normal file
View File

@ -0,0 +1,254 @@
/**
* Theme Browsing
*
* Controls visibility of theme details on manage and install themes pages.
*/
jQuery( function($) {
$('#availablethemes').on( 'click', '.theme-detail', function (event) {
var theme = $(this).closest('.available-theme'),
details = theme.find('.themedetaildiv');
if ( ! details.length ) {
details = theme.find('.install-theme-info .theme-details');
details = details.clone().addClass('themedetaildiv').appendTo( theme ).hide();
}
details.toggle();
event.preventDefault();
});
});
/**
* Theme Install
*
* Displays theme previews on theme install pages.
*/
jQuery( function($) {
if( ! window.postMessage )
return;
var preview = $('#theme-installer'),
info = preview.find('.install-theme-info'),
panel = preview.find('.wp-full-overlay-main'),
body = $( document.body );
preview.on( 'click', '.close-full-overlay', function( event ) {
preview.fadeOut( 200, function() {
panel.empty();
body.removeClass('theme-installer-active full-overlay-active');
});
event.preventDefault();
});
preview.on( 'click', '.collapse-sidebar', function( event ) {
preview.toggleClass( 'collapsed' ).toggleClass( 'expanded' );
event.preventDefault();
});
$('#availablethemes').on( 'click', '.install-theme-preview', function( event ) {
var src;
info.html( $(this).closest('.installable-theme').find('.install-theme-info').html() );
src = info.find( '.theme-preview-url' ).val();
panel.html( '<iframe src="' + src + '" />');
preview.fadeIn( 200, function() {
body.addClass('theme-installer-active full-overlay-active');
});
event.preventDefault();
});
});
var ThemeViewer;
(function($){
ThemeViewer = function( args ) {
function init() {
$( '#filter-click, #mini-filter-click' ).unbind( 'click' ).click( function() {
$( '#filter-click' ).toggleClass( 'current' );
$( '#filter-box' ).slideToggle();
$( '#current-theme' ).slideToggle( 300 );
return false;
});
$( '#filter-box :checkbox' ).unbind( 'click' ).click( function() {
var count = $( '#filter-box :checked' ).length,
text = $( '#filter-click' ).text();
if ( text.indexOf( '(' ) != -1 )
text = text.substr( 0, text.indexOf( '(' ) );
if ( count == 0 )
$( '#filter-click' ).text( text );
else
$( '#filter-click' ).text( text + ' (' + count + ')' );
});
/* $('#filter-box :submit').unbind( 'click' ).click(function() {
var features = [];
$('#filter-box :checked').each(function() {
features.push($(this).val());
});
listTable.update_rows({'features': features}, true, function() {
$( '#filter-click' ).toggleClass( 'current' );
$( '#filter-box' ).slideToggle();
$( '#current-theme' ).slideToggle( 300 );
});
return false;
}); */
}
// These are the functions we expose
var api = {
init: init
};
return api;
}
})(jQuery);
jQuery( document ).ready( function($) {
theme_viewer = new ThemeViewer();
theme_viewer.init();
});
/**
* Class that provides infinite scroll for Themes admin screens
*
* @since 3.4
*
* @uses ajaxurl
* @uses list_args
* @uses theme_list_args
* @uses $('#_ajax_fetch_list_nonce').val()
* */
var ThemeScroller;
(function($){
ThemeScroller = {
querying: false,
scrollPollingDelay: 500,
failedRetryDelay: 4000,
outListBottomThreshold: 300,
/**
* Initializer
*
* @since 3.4
* @access private
*/
init: function() {
var self = this;
// Get out early if we don't have the required arguments.
if ( typeof ajaxurl === 'undefined' ||
typeof list_args === 'undefined' ||
typeof theme_list_args === 'undefined' ) {
$('.pagination-links').show();
return;
}
// Handle inputs
this.nonce = $('#_ajax_fetch_list_nonce').val();
this.nextPage = ( theme_list_args.paged + 1 );
// Cache jQuery selectors
this.$outList = $('#availablethemes');
this.$spinner = $('div.tablenav.bottom').children( '.spinner' );
this.$window = $(window);
this.$document = $(document);
/**
* If there are more pages to query, then start polling to track
* when user hits the bottom of the current page
*/
if ( theme_list_args.total_pages >= this.nextPage )
this.pollInterval =
setInterval( function() {
return self.poll();
}, this.scrollPollingDelay );
},
/**
* Checks to see if user has scrolled to bottom of page.
* If so, requests another page of content from self.ajax().
*
* @since 3.4
* @access private
*/
poll: function() {
var bottom = this.$document.scrollTop() + this.$window.innerHeight();
if ( this.querying ||
( bottom < this.$outList.height() - this.outListBottomThreshold ) )
return;
this.ajax();
},
/**
* Applies results passed from this.ajax() to $outList
*
* @since 3.4
* @access private
*
* @param results Array with results from this.ajax() query.
*/
process: function( results ) {
if ( results === undefined ) {
clearInterval( this.pollInterval );
return;
}
if ( this.nextPage > theme_list_args.total_pages )
clearInterval( this.pollInterval );
if ( this.nextPage <= ( theme_list_args.total_pages + 1 ) )
this.$outList.append( results.rows );
},
/**
* Queries next page of themes
*
* @since 3.4
* @access private
*/
ajax: function() {
var self = this;
this.querying = true;
var query = {
action: 'fetch-list',
paged: this.nextPage,
s: theme_list_args.search,
tab: theme_list_args.tab,
type: theme_list_args.type,
_ajax_fetch_list_nonce: this.nonce,
'features[]': theme_list_args.features,
'list_args': list_args
};
this.$spinner.show();
$.getJSON( ajaxurl, query )
.done( function( response ) {
self.nextPage++;
self.process( response );
self.$spinner.hide();
self.querying = false;
})
.fail( function() {
self.$spinner.hide();
self.querying = false;
setTimeout( function() { self.ajax(); }, self.failedRetryDelay );
});
}
}
$(document).ready( function($) {
ThemeScroller.init();
});
})(jQuery);

1
wp-admin/js/theme.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(function(a){a("#availablethemes").on("click",".theme-detail",function(c){var d=a(this).closest(".available-theme"),b=d.find(".themedetaildiv");if(!b.length){b=d.find(".install-theme-info .theme-details");b=b.clone().addClass("themedetaildiv").appendTo(d).hide()}b.toggle();c.preventDefault()})});jQuery(function(c){if(!window.postMessage){return}var e=c("#theme-installer"),d=e.find(".install-theme-info"),b=e.find(".wp-full-overlay-main"),a=c(document.body);e.on("click",".close-full-overlay",function(f){e.fadeOut(200,function(){b.empty();a.removeClass("theme-installer-active full-overlay-active")});f.preventDefault()});e.on("click",".collapse-sidebar",function(f){e.toggleClass("collapsed").toggleClass("expanded");f.preventDefault()});c("#availablethemes").on("click",".install-theme-preview",function(f){var g;d.html(c(this).closest(".installable-theme").find(".install-theme-info").html());g=d.find(".theme-preview-url").val();b.html('<iframe src="'+g+'" />');e.fadeIn(200,function(){a.addClass("theme-installer-active full-overlay-active")});f.preventDefault()})});var ThemeViewer;(function(a){ThemeViewer=function(b){function d(){a("#filter-click, #mini-filter-click").unbind("click").click(function(){a("#filter-click").toggleClass("current");a("#filter-box").slideToggle();a("#current-theme").slideToggle(300);return false});a("#filter-box :checkbox").unbind("click").click(function(){var e=a("#filter-box :checked").length,f=a("#filter-click").text();if(f.indexOf("(")!=-1){f=f.substr(0,f.indexOf("("))}if(e==0){a("#filter-click").text(f)}else{a("#filter-click").text(f+" ("+e+")")}})}var c={init:d};return c}})(jQuery);jQuery(document).ready(function(a){theme_viewer=new ThemeViewer();theme_viewer.init()});var ThemeScroller;(function(a){ThemeScroller={querying:false,scrollPollingDelay:500,failedRetryDelay:4000,outListBottomThreshold:300,init:function(){var b=this;if(typeof ajaxurl==="undefined"||typeof list_args==="undefined"||typeof theme_list_args==="undefined"){a(".pagination-links").show();return}this.nonce=a("#_ajax_fetch_list_nonce").val();this.nextPage=(theme_list_args.paged+1);this.$outList=a("#availablethemes");this.$spinner=a("div.tablenav.bottom").children(".spinner");this.$window=a(window);this.$document=a(document);if(theme_list_args.total_pages>=this.nextPage){this.pollInterval=setInterval(function(){return b.poll()},this.scrollPollingDelay)}},poll:function(){var b=this.$document.scrollTop()+this.$window.innerHeight();if(this.querying||(b<this.$outList.height()-this.outListBottomThreshold)){return}this.ajax()},process:function(b){if(b===undefined){clearInterval(this.pollInterval);return}if(this.nextPage>theme_list_args.total_pages){clearInterval(this.pollInterval)}if(this.nextPage<=(theme_list_args.total_pages+1)){this.$outList.append(b.rows)}},ajax:function(){var b=this;this.querying=true;var c={action:"fetch-list",paged:this.nextPage,s:theme_list_args.search,tab:theme_list_args.tab,type:theme_list_args.type,_ajax_fetch_list_nonce:this.nonce,"features[]":theme_list_args.features,list_args:list_args};this.$spinner.show();a.getJSON(ajaxurl,c).done(function(d){b.nextPage++;b.process(d);b.$spinner.hide();b.querying=false}).fail(function(){b.$spinner.hide();b.querying=false;setTimeout(function(){b.ajax()},b.failedRetryDelay)})}};a(document).ready(function(b){ThemeScroller.init()})})(jQuery);

View File

@ -0,0 +1,78 @@
(function($){
function check_pass_strength() {
var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
$('#pass-strength-result').removeClass('short bad good strong');
if ( ! pass1 ) {
$('#pass-strength-result').html( pwsL10n.empty );
return;
}
strength = passwordStrength(pass1, user, pass2);
switch ( strength ) {
case 2:
$('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
break;
case 3:
$('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
break;
case 4:
$('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
break;
case 5:
$('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
break;
default:
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
}
}
$(document).ready( function() {
var select = $('#display_name');
$('#pass1').val('').keyup( check_pass_strength );
$('#pass2').val('').keyup( check_pass_strength );
$('#pass-strength-result').show();
$('.color-palette').click( function() {
$(this).siblings('input[name="admin_color"]').prop('checked', true);
});
if ( select.length ) {
$('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
var dub = [],
inputs = {
display_nickname : $('#nickname').val() || '',
display_username : $('#user_login').val() || '',
display_firstname : $('#first_name').val() || '',
display_lastname : $('#last_name').val() || ''
};
if ( inputs.display_firstname && inputs.display_lastname ) {
inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname;
inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname;
}
$.each( $('option', select), function( i, el ){
dub.push( el.value );
});
$.each(inputs, function( id, value ) {
if ( ! value )
return;
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
if ( inputs[id].length && $.inArray( val, dub ) == -1 ) {
dub.push(val);
$('<option />', {
'text': val
}).appendTo( select );
}
});
});
}
});
})(jQuery);

1
wp-admin/js/user-profile.min.js vendored Normal file
View File

@ -0,0 +1 @@
(function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){var c=a("#display_name");a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",true)});if(c.length){a("#first_name, #last_name, #nickname").bind("blur.user_profile",function(){var e=[],d={display_nickname:a("#nickname").val()||"",display_username:a("#user_login").val()||"",display_firstname:a("#first_name").val()||"",display_lastname:a("#last_name").val()||""};if(d.display_firstname&&d.display_lastname){d.display_firstlast=d.display_firstname+" "+d.display_lastname;d.display_lastfirst=d.display_lastname+" "+d.display_firstname}a.each(a("option",c),function(f,g){e.push(g.value)});a.each(d,function(h,f){if(!f){return}var g=f.replace(/<\/?[a-z][^>]*>/gi,"");if(d[h].length&&a.inArray(g,e)==-1){e.push(g);a("<option />",{text:g}).appendTo(c)}})})}})})(jQuery);

View File

@ -0,0 +1,13 @@
(function($) {
var id = 'undefined' !== typeof current_site_id ? '&site_id=' + current_site_id : '';
$(document).ready( function() {
$( '.wp-suggest-user' ).autocomplete({
source: ajaxurl + '?action=autocomplete-user&autocomplete_type=add' + id,
delay: 500,
minLength: 2,
position: ( 'undefined' !== typeof isRtl && isRtl ) ? { my: 'right top', at: 'right bottom', offset: '0, -1' } : { offset: '0, -1' },
open: function() { $(this).addClass('open'); },
close: function() { $(this).removeClass('open'); }
});
});
})(jQuery);

1
wp-admin/js/user-suggest.min.js vendored Normal file
View File

@ -0,0 +1 @@
(function(a){var b="undefined"!==typeof current_site_id?"&site_id="+current_site_id:"";a(document).ready(function(){a(".wp-suggest-user").autocomplete({source:ajaxurl+"?action=autocomplete-user&autocomplete_type=add"+b,delay:500,minLength:2,position:("undefined"!==typeof isRtl&&isRtl)?{my:"right top",at:"right bottom",offset:"0, -1"}:{offset:"0, -1"},open:function(){a(this).addClass("open")},close:function(){a(this).removeClass("open")}})})})(jQuery);

289
wp-admin/js/widgets.js Normal file
View File

@ -0,0 +1,289 @@
var wpWidgets;
(function($) {
wpWidgets = {
init : function() {
var rem, sidebars = $('div.widgets-sortables'), isRTL = !! ( 'undefined' != typeof isRtl && isRtl ),
margin = ( isRtl ? 'marginRight' : 'marginLeft' ), the_id;
$('#widgets-right').children('.widgets-holder-wrap').children('.sidebar-name').click(function(){
var c = $(this).siblings('.widgets-sortables'), p = $(this).parent();
if ( !p.hasClass('closed') ) {
c.sortable('disable');
p.addClass('closed');
} else {
p.removeClass('closed');
c.sortable('enable').sortable('refresh');
}
});
$('#widgets-left').children('.widgets-holder-wrap').children('.sidebar-name').click(function() {
$(this).parent().toggleClass('closed');
});
sidebars.each(function(){
if ( $(this).parent().hasClass('inactive') )
return true;
var h = 50, H = $(this).children('.widget').length;
h = h + parseInt(H * 48, 10);
$(this).css( 'minHeight', h + 'px' );
});
$(document.body).bind('click.widgets-toggle', function(e){
var target = $(e.target), css = {}, widget, inside, w;
if ( target.parents('.widget-top').length && ! target.parents('#available-widgets').length ) {
widget = target.closest('div.widget');
inside = widget.children('.widget-inside');
w = parseInt( widget.find('input.widget-width').val(), 10 );
if ( inside.is(':hidden') ) {
if ( w > 250 && inside.closest('div.widgets-sortables').length ) {
css['width'] = w + 30 + 'px';
if ( inside.closest('div.widget-liquid-right').length )
css[margin] = 235 - w + 'px';
widget.css(css);
}
wpWidgets.fixLabels(widget);
inside.slideDown('fast');
} else {
inside.slideUp('fast', function() {
widget.css({'width':'', margin:''});
});
}
e.preventDefault();
} else if ( target.hasClass('widget-control-save') ) {
wpWidgets.save( target.closest('div.widget'), 0, 1, 0 );
e.preventDefault();
} else if ( target.hasClass('widget-control-remove') ) {
wpWidgets.save( target.closest('div.widget'), 1, 1, 0 );
e.preventDefault();
} else if ( target.hasClass('widget-control-close') ) {
wpWidgets.close( target.closest('div.widget') );
e.preventDefault();
}
});
sidebars.children('.widget').each(function() {
wpWidgets.appendTitle(this);
if ( $('p.widget-error', this).length )
$('a.widget-action', this).click();
});
$('#widget-list').children('.widget').draggable({
connectToSortable: 'div.widgets-sortables',
handle: '> .widget-top > .widget-title',
distance: 2,
helper: 'clone',
zIndex: 100,
containment: 'document',
start: function(e,ui) {
ui.helper.find('div.widget-description').hide();
the_id = this.id;
},
stop: function(e,ui) {
if ( rem )
$(rem).hide();
rem = '';
}
});
sidebars.sortable({
placeholder: 'widget-placeholder',
items: '> .widget',
handle: '> .widget-top > .widget-title',
cursor: 'move',
distance: 2,
containment: 'document',
start: function(e,ui) {
ui.item.children('.widget-inside').hide();
ui.item.css({margin:'', 'width':''});
},
stop: function(e,ui) {
if ( ui.item.hasClass('ui-draggable') && ui.item.data('draggable') )
ui.item.draggable('destroy');
if ( ui.item.hasClass('deleting') ) {
wpWidgets.save( ui.item, 1, 0, 1 ); // delete widget
ui.item.remove();
return;
}
var add = ui.item.find('input.add_new').val(),
n = ui.item.find('input.multi_number').val(),
id = the_id,
sb = $(this).attr('id');
ui.item.css({margin:'', 'width':''});
the_id = '';
if ( add ) {
if ( 'multi' == add ) {
ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) );
ui.item.attr( 'id', id.replace('__i__', n) );
n++;
$('div#' + id).find('input.multi_number').val(n);
} else if ( 'single' == add ) {
ui.item.attr( 'id', 'new-' + id );
rem = 'div#' + id;
}
wpWidgets.save( ui.item, 0, 0, 1 );
ui.item.find('input.add_new').val('');
ui.item.find('a.widget-action').click();
return;
}
wpWidgets.saveOrder(sb);
},
receive: function(e, ui) {
var sender = $(ui.sender);
if ( !$(this).is(':visible') || this.id.indexOf('orphaned_widgets') != -1 )
sender.sortable('cancel');
if ( sender.attr('id').indexOf('orphaned_widgets') != -1 && !sender.children('.widget').length ) {
sender.parents('.orphan-sidebar').slideUp(400, function(){ $(this).remove(); });
}
}
}).sortable('option', 'connectWith', 'div.widgets-sortables').parent().filter('.closed').children('.widgets-sortables').sortable('disable');
$('#available-widgets').droppable({
tolerance: 'pointer',
accept: function(o){
return $(o).parent().attr('id') != 'widget-list';
},
drop: function(e,ui) {
ui.draggable.addClass('deleting');
$('#removing-widget').hide().children('span').html('');
},
over: function(e,ui) {
ui.draggable.addClass('deleting');
$('div.widget-placeholder').hide();
if ( ui.draggable.hasClass('ui-sortable-helper') )
$('#removing-widget').show().children('span')
.html( ui.draggable.find('div.widget-title').children('h4').html() );
},
out: function(e,ui) {
ui.draggable.removeClass('deleting');
$('div.widget-placeholder').show();
$('#removing-widget').hide().children('span').html('');
}
});
},
saveOrder : function(sb) {
if ( sb )
$('#' + sb).closest('div.widgets-holder-wrap').find('.spinner').css('display', 'inline-block');
var a = {
action: 'widgets-order',
savewidgets: $('#_wpnonce_widgets').val(),
sidebars: []
};
$('div.widgets-sortables').each( function() {
if ( $(this).sortable )
a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(',');
});
$.post( ajaxurl, a, function() {
$('.spinner').hide();
});
this.resize();
},
save : function(widget, del, animate, order) {
var sb = widget.closest('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a;
widget = $(widget);
$('.spinner', widget).show();
a = {
action: 'save-widget',
savewidgets: $('#_wpnonce_widgets').val(),
sidebar: sb
};
if ( del )
a['delete_widget'] = 1;
data += '&' + $.param(a);
$.post( ajaxurl, data, function(r){
var id;
if ( del ) {
if ( !$('input.widget_number', widget).val() ) {
id = $('input.widget-id', widget).val();
$('#available-widgets').find('input.widget-id').each(function(){
if ( $(this).val() == id )
$(this).closest('div.widget').show();
});
}
if ( animate ) {
order = 0;
widget.slideUp('fast', function(){
$(this).remove();
wpWidgets.saveOrder();
});
} else {
widget.remove();
wpWidgets.resize();
}
} else {
$('.spinner').hide();
if ( r && r.length > 2 ) {
$('div.widget-content', widget).html(r);
wpWidgets.appendTitle(widget);
wpWidgets.fixLabels(widget);
}
}
if ( order )
wpWidgets.saveOrder();
});
},
appendTitle : function(widget) {
var title = $('input[id*="-title"]', widget).val() || '';
if ( title )
title = ': ' + title.replace(/<[^<>]+>/g, '').replace(/</g, '&lt;').replace(/>/g, '&gt;');
$(widget).children('.widget-top').children('.widget-title').children()
.children('.in-widget-title').html(title);
},
resize : function() {
$('div.widgets-sortables').each(function(){
if ( $(this).parent().hasClass('inactive') )
return true;
var h = 50, H = $(this).children('.widget').length;
h = h + parseInt(H * 48, 10);
$(this).css( 'minHeight', h + 'px' );
});
},
fixLabels : function(widget) {
widget.children('.widget-inside').find('label').each(function(){
var f = $(this).attr('for');
if ( f && f == $('input', this).attr('id') )
$(this).removeAttr('for');
});
},
close : function(widget) {
widget.children('.widget-inside').slideUp('fast', function(){
widget.css({'width':'', margin:''});
});
}
};
$(document).ready(function($){ wpWidgets.init(); });
})(jQuery);

1
wp-admin/js/widgets.min.js vendored Normal file

File diff suppressed because one or more lines are too long

42
wp-admin/js/word-count.js Normal file
View File

@ -0,0 +1,42 @@
(function($,undefined) {
wpWordCount = {
settings : {
strip : /<[a-zA-Z\/][^<>]*>/g, // strip HTML tags
clean : /[0-9.(),;:!?%#$¿'"_+=\\/-]+/g, // regexp to remove punctuation, etc.
w : /\S\s+/g, // word-counting regexp
c : /\S/g // char-counting regexp for asian languages
},
block : 0,
wc : function(tx, type) {
var t = this, w = $('.word-count'), tc = 0;
if ( type === undefined )
type = wordCountL10n.type;
if ( type !== 'w' && type !== 'c' )
type = 'w';
if ( t.block )
return;
t.block = 1;
setTimeout( function() {
if ( tx ) {
tx = tx.replace( t.settings.strip, ' ' ).replace( /&nbsp;|&#160;/gi, ' ' );
tx = tx.replace( t.settings.clean, '' );
tx.replace( t.settings[type], function(){tc++;} );
}
w.html(tc.toString());
setTimeout( function() { t.block = 0; }, 2000 );
}, 1 );
}
}
$(document).bind( 'wpcountwords', function(e, txt) {
wpWordCount.wc(txt);
});
}(jQuery));

1
wp-admin/js/word-count.min.js vendored Normal file
View File

@ -0,0 +1 @@
(function(a,b){wpWordCount={settings:{strip:/<[a-zA-Z\/][^<>]*>/g,clean:/[0-9.(),;:!?%#$¿'"_+=\\/-]+/g,w:/\S\s+/g,c:/\S/g},block:0,wc:function(e,g){var f=this,d=a(".word-count"),c=0;if(g===b){g=wordCountL10n.type}if(g!=="w"&&g!=="c"){g="w"}if(f.block){return}f.block=1;setTimeout(function(){if(e){e=e.replace(f.settings.strip," ").replace(/&nbsp;|&#160;/gi," ");e=e.replace(f.settings.clean,"");e.replace(f.settings[g],function(){c++})}d.html(c.toString());setTimeout(function(){f.block=0},2000)},1)}};a(document).bind("wpcountwords",function(d,c){wpWordCount.wc(c)})}(jQuery));

View File

@ -0,0 +1,725 @@
/**
* PubSub
*
* A lightweight publish/subscribe implementation.
* Private use only!
*/
var PubSub, fullscreen, wptitlehint;
PubSub = function() {
this.topics = {};
};
PubSub.prototype.subscribe = function( topic, callback ) {
if ( ! this.topics[ topic ] )
this.topics[ topic ] = [];
this.topics[ topic ].push( callback );
return callback;
};
PubSub.prototype.unsubscribe = function( topic, callback ) {
var i, l,
topics = this.topics[ topic ];
if ( ! topics )
return callback || [];
// Clear matching callbacks
if ( callback ) {
for ( i = 0, l = topics.length; i < l; i++ ) {
if ( callback == topics[i] )
topics.splice( i, 1 );
}
return callback;
// Clear all callbacks
} else {
this.topics[ topic ] = [];
return topics;
}
};
PubSub.prototype.publish = function( topic, args ) {
var i, l, broken,
topics = this.topics[ topic ];
if ( ! topics )
return;
args = args || [];
for ( i = 0, l = topics.length; i < l; i++ ) {
broken = ( topics[i].apply( null, args ) === false || broken );
}
return ! broken;
};
/**
* Distraction Free Writing
* (wp-fullscreen)
*
* Access the API globally using the fullscreen variable.
*/
(function($){
var api, ps, bounder, s;
// Initialize the fullscreen/api object
fullscreen = api = {};
// Create the PubSub (publish/subscribe) interface.
ps = api.pubsub = new PubSub();
timer = 0;
block = false;
s = api.settings = { // Settings
visible : false,
mode : 'tinymce',
editor_id : 'content',
title_id : '',
timer : 0,
toolbar_shown : false
}
/**
* Bounder
*
* Creates a function that publishes start/stop topics.
* Used to throttle events.
*/
bounder = api.bounder = function( start, stop, delay, e ) {
var y, top;
delay = delay || 1250;
if ( e ) {
y = e.pageY || e.clientY || e.offsetY;
top = $(document).scrollTop();
if ( !e.isDefaultPrevented ) // test if e ic jQuery normalized
y = 135 + y;
if ( y - top > 120 )
return;
}
if ( block )
return;
block = true;
setTimeout( function() {
block = false;
}, 400 );
if ( s.timer )
clearTimeout( s.timer );
else
ps.publish( start );
function timed() {
ps.publish( stop );
s.timer = 0;
}
s.timer = setTimeout( timed, delay );
};
/**
* on()
*
* Turns fullscreen on.
*
* @param string mode Optional. Switch to the given mode before opening.
*/
api.on = function() {
if ( s.visible )
return;
// Settings can be added or changed by defining "wp_fullscreen_settings" JS object.
if ( typeof(wp_fullscreen_settings) == 'object' )
$.extend( s, wp_fullscreen_settings );
s.editor_id = wpActiveEditor || 'content';
if ( $('input#title').length && s.editor_id == 'content' )
s.title_id = 'title';
else if ( $('input#' + s.editor_id + '-title').length ) // the title input field should have [editor_id]-title HTML ID to be auto detected
s.title_id = s.editor_id + '-title';
else
$('#wp-fullscreen-title, #wp-fullscreen-title-prompt-text').hide();
s.mode = $('#' + s.editor_id).is(':hidden') ? 'tinymce' : 'html';
s.qt_canvas = $('#' + s.editor_id).get(0);
if ( ! s.element )
api.ui.init();
s.is_mce_on = s.has_tinymce && typeof( tinyMCE.get(s.editor_id) ) != 'undefined';
api.ui.fade( 'show', 'showing', 'shown' );
};
/**
* off()
*
* Turns fullscreen off.
*/
api.off = function() {
if ( ! s.visible )
return;
api.ui.fade( 'hide', 'hiding', 'hidden' );
};
/**
* switchmode()
*
* @return string - The current mode.
*
* @param string to - The fullscreen mode to switch to.
* @event switchMode
* @eventparam string to - The new mode.
* @eventparam string from - The old mode.
*/
api.switchmode = function( to ) {
var from = s.mode;
if ( ! to || ! s.visible || ! s.has_tinymce )
return from;
// Don't switch if the mode is the same.
if ( from == to )
return from;
ps.publish( 'switchMode', [ from, to ] );
s.mode = to;
ps.publish( 'switchedMode', [ from, to ] );
return to;
};
/**
* General
*/
api.save = function() {
var hidden = $('#hiddenaction'), old = hidden.val(), spinner = $('#wp-fullscreen-save .spinner'),
message = $('#wp-fullscreen-save span');
spinner.show();
api.savecontent();
hidden.val('wp-fullscreen-save-post');
$.post( ajaxurl, $('form#post').serialize(), function(r){
spinner.hide();
message.show();
setTimeout( function(){
message.fadeOut(1000);
}, 3000 );
if ( r.last_edited )
$('#wp-fullscreen-save input').attr( 'title', r.last_edited );
}, 'json');
hidden.val(old);
}
api.savecontent = function() {
var ed, content;
if ( s.title_id )
$('#' + s.title_id).val( $('#wp-fullscreen-title').val() );
if ( s.mode === 'tinymce' && (ed = tinyMCE.get('wp_mce_fullscreen')) ) {
content = ed.save();
} else {
content = $('#wp_mce_fullscreen').val();
}
$('#' + s.editor_id).val( content );
$(document).triggerHandler('wpcountwords', [ content ]);
}
set_title_hint = function( title ) {
if ( ! title.val().length )
title.siblings('label').css( 'visibility', '' );
else
title.siblings('label').css( 'visibility', 'hidden' );
}
api.dfw_width = function(n) {
var el = $('#wp-fullscreen-wrap'), w = el.width();
if ( !n ) { // reset to theme width
el.width( $('#wp-fullscreen-central-toolbar').width() );
deleteUserSetting('dfw_width');
return;
}
w = n + w;
if ( w < 200 || w > 1200 ) // sanity check
return;
el.width( w );
setUserSetting('dfw_width', w);
}
ps.subscribe( 'showToolbar', function() {
s.toolbars.removeClass('fade-1000').addClass('fade-300');
api.fade.In( s.toolbars, 300, function(){ ps.publish('toolbarShown'); }, true );
$('#wp-fullscreen-body').addClass('wp-fullscreen-focus');
s.toolbar_shown = true;
});
ps.subscribe( 'hideToolbar', function() {
s.toolbars.removeClass('fade-300').addClass('fade-1000');
api.fade.Out( s.toolbars, 1000, function(){ ps.publish('toolbarHidden'); }, true );
$('#wp-fullscreen-body').removeClass('wp-fullscreen-focus');
});
ps.subscribe( 'toolbarShown', function() {
s.toolbars.removeClass('fade-300');
});
ps.subscribe( 'toolbarHidden', function() {
s.toolbars.removeClass('fade-1000');
s.toolbar_shown = false;
});
ps.subscribe( 'show', function() { // This event occurs before the overlay blocks the UI.
var title;
if ( s.title_id ) {
title = $('#wp-fullscreen-title').val( $('#' + s.title_id).val() );
set_title_hint( title );
}
$('#wp-fullscreen-save input').attr( 'title', $('#last-edit').text() );
s.textarea_obj.value = s.qt_canvas.value;
if ( s.has_tinymce && s.mode === 'tinymce' )
tinyMCE.execCommand('wpFullScreenInit');
s.orig_y = $(window).scrollTop();
});
ps.subscribe( 'showing', function() { // This event occurs while the DFW overlay blocks the UI.
$( document.body ).addClass( 'fullscreen-active' );
api.refresh_buttons();
$( document ).bind( 'mousemove.fullscreen', function(e) { bounder( 'showToolbar', 'hideToolbar', 2000, e ); } );
bounder( 'showToolbar', 'hideToolbar', 2000 );
api.bind_resize();
setTimeout( api.resize_textarea, 200 );
// scroll to top so the user is not disoriented
scrollTo(0, 0);
// needed it for IE7 and compat mode
$('#wpadminbar').hide();
});
ps.subscribe( 'shown', function() { // This event occurs after the DFW overlay is shown
var interim_init;
s.visible = true;
// init the standard TinyMCE instance if missing
if ( s.has_tinymce && ! s.is_mce_on ) {
interim_init = function(mce, ed) {
var el = ed.getElement(), old_val = el.value, settings = tinyMCEPreInit.mceInit[s.editor_id];
if ( settings && settings.wpautop && typeof(switchEditors) != 'undefined' )
el.value = switchEditors.wpautop( el.value );
ed.onInit.add(function(ed) {
ed.hide();
ed.getElement().value = old_val;
tinymce.onAddEditor.remove(interim_init);
});
};
tinymce.onAddEditor.add(interim_init);
tinyMCE.init(tinyMCEPreInit.mceInit[s.editor_id]);
s.is_mce_on = true;
}
wpActiveEditor = 'wp_mce_fullscreen';
});
ps.subscribe( 'hide', function() { // This event occurs before the overlay blocks DFW.
var htmled_is_hidden = $('#' + s.editor_id).is(':hidden');
// Make sure the correct editor is displaying.
if ( s.has_tinymce && s.mode === 'tinymce' && !htmled_is_hidden ) {
switchEditors.go(s.editor_id, 'tmce');
} else if ( s.mode === 'html' && htmled_is_hidden ) {
switchEditors.go(s.editor_id, 'html');
}
// Save content must be after switchEditors or content will be overwritten. See #17229.
api.savecontent();
$( document ).unbind( '.fullscreen' );
$(s.textarea_obj).unbind('.grow');
if ( s.has_tinymce && s.mode === 'tinymce' )
tinyMCE.execCommand('wpFullScreenSave');
if ( s.title_id )
set_title_hint( $('#' + s.title_id) );
s.qt_canvas.value = s.textarea_obj.value;
});
ps.subscribe( 'hiding', function() { // This event occurs while the overlay blocks the DFW UI.
$( document.body ).removeClass( 'fullscreen-active' );
scrollTo(0, s.orig_y);
$('#wpadminbar').show();
});
ps.subscribe( 'hidden', function() { // This event occurs after DFW is removed.
s.visible = false;
$('#wp_mce_fullscreen, #wp-fullscreen-title').removeAttr('style');
if ( s.has_tinymce && s.is_mce_on )
tinyMCE.execCommand('wpFullScreenClose');
s.textarea_obj.value = '';
api.oldheight = 0;
wpActiveEditor = s.editor_id;
});
ps.subscribe( 'switchMode', function( from, to ) {
var ed;
if ( !s.has_tinymce || !s.is_mce_on )
return;
ed = tinyMCE.get('wp_mce_fullscreen');
if ( from === 'html' && to === 'tinymce' ) {
if ( tinyMCE.get(s.editor_id).getParam('wpautop') && typeof(switchEditors) != 'undefined' )
s.textarea_obj.value = switchEditors.wpautop( s.textarea_obj.value );
if ( 'undefined' == typeof(ed) )
tinyMCE.execCommand('wpFullScreenInit');
else
ed.show();
} else if ( from === 'tinymce' && to === 'html' ) {
if ( ed )
ed.hide();
}
});
ps.subscribe( 'switchedMode', function( from, to ) {
api.refresh_buttons(true);
if ( to === 'html' )
setTimeout( api.resize_textarea, 200 );
});
/**
* Buttons
*/
api.b = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Bold');
}
api.i = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Italic');
}
api.ul = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertUnorderedList');
}
api.ol = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertOrderedList');
}
api.link = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('WP_Link');
else
wpLink.open();
}
api.unlink = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('unlink');
}
api.atd = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('mceWritingImprovementTool');
}
api.help = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('WP_Help');
}
api.blockquote = function() {
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('mceBlockQuote');
}
api.medialib = function() {
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor )
wp.media.editor.open(s.editor_id);
}
api.refresh_buttons = function( fade ) {
fade = fade || false;
if ( s.mode === 'html' ) {
$('#wp-fullscreen-mode-bar').removeClass('wp-tmce-mode').addClass('wp-html-mode');
if ( fade )
$('#wp-fullscreen-button-bar').fadeOut( 150, function(){
$(this).addClass('wp-html-mode').fadeIn( 150 );
});
else
$('#wp-fullscreen-button-bar').addClass('wp-html-mode');
} else if ( s.mode === 'tinymce' ) {
$('#wp-fullscreen-mode-bar').removeClass('wp-html-mode').addClass('wp-tmce-mode');
if ( fade )
$('#wp-fullscreen-button-bar').fadeOut( 150, function(){
$(this).removeClass('wp-html-mode').fadeIn( 150 );
});
else
$('#wp-fullscreen-button-bar').removeClass('wp-html-mode');
}
}
/**
* UI Elements
*
* Used for transitioning between states.
*/
api.ui = {
init: function() {
var topbar = $('#fullscreen-topbar'), txtarea = $('#wp_mce_fullscreen'), last = 0;
s.toolbars = topbar.add( $('#wp-fullscreen-status') );
s.element = $('#fullscreen-fader');
s.textarea_obj = txtarea[0];
s.has_tinymce = typeof(tinymce) != 'undefined';
if ( !s.has_tinymce )
$('#wp-fullscreen-mode-bar').hide();
if ( wptitlehint && $('#wp-fullscreen-title').length )
wptitlehint('wp-fullscreen-title');
$(document).keyup(function(e){
var c = e.keyCode || e.charCode, a, data;
if ( !fullscreen.settings.visible )
return true;
if ( navigator.platform && navigator.platform.indexOf('Mac') != -1 )
a = e.ctrlKey; // Ctrl key for Mac
else
a = e.altKey; // Alt key for Win & Linux
if ( 27 == c ) { // Esc
data = {
event: e,
what: 'dfw',
cb: fullscreen.off,
condition: function(){
if ( $('#TB_window').is(':visible') || $('.wp-dialog').is(':visible') )
return false;
return true;
}
};
if ( ! jQuery(document).triggerHandler( 'wp_CloseOnEscape', [data] ) )
fullscreen.off();
}
if ( a && (61 == c || 107 == c || 187 == c) ) // +
api.dfw_width(25);
if ( a && (45 == c || 109 == c || 189 == c) ) // -
api.dfw_width(-25);
if ( a && 48 == c ) // 0
api.dfw_width(0);
return false;
});
// word count in Text mode
if ( typeof(wpWordCount) != 'undefined' ) {
txtarea.keyup( function(e) {
var k = e.keyCode || e.charCode;
if ( k == last )
return true;
if ( 13 == k || 8 == last || 46 == last )
$(document).triggerHandler('wpcountwords', [ txtarea.val() ]);
last = k;
return true;
});
}
topbar.mouseenter(function(e){
s.toolbars.addClass('fullscreen-make-sticky');
$( document ).unbind( '.fullscreen' );
clearTimeout( s.timer );
s.timer = 0;
}).mouseleave(function(e){
s.toolbars.removeClass('fullscreen-make-sticky');
if ( s.visible )
$( document ).bind( 'mousemove.fullscreen', function(e) { bounder( 'showToolbar', 'hideToolbar', 2000, e ); } );
});
},
fade: function( before, during, after ) {
if ( ! s.element )
api.ui.init();
// If any callback bound to before returns false, bail.
if ( before && ! ps.publish( before ) )
return;
api.fade.In( s.element, 600, function() {
if ( during )
ps.publish( during );
api.fade.Out( s.element, 600, function() {
if ( after )
ps.publish( after );
})
});
}
};
api.fade = {
transitionend: 'transitionend webkitTransitionEnd oTransitionEnd',
// Sensitivity to allow browsers to render the blank element before animating.
sensitivity: 100,
In: function( element, speed, callback, stop ) {
callback = callback || $.noop;
speed = speed || 400;
stop = stop || false;
if ( api.fade.transitions ) {
if ( element.is(':visible') ) {
element.addClass( 'fade-trigger' );
return element;
}
element.show();
element.first().one( this.transitionend, function() {
callback();
});
setTimeout( function() { element.addClass( 'fade-trigger' ); }, this.sensitivity );
} else {
if ( stop )
element.stop();
element.css( 'opacity', 1 );
element.first().fadeIn( speed, callback );
if ( element.length > 1 )
element.not(':first').fadeIn( speed );
}
return element;
},
Out: function( element, speed, callback, stop ) {
callback = callback || $.noop;
speed = speed || 400;
stop = stop || false;
if ( ! element.is(':visible') )
return element;
if ( api.fade.transitions ) {
element.first().one( api.fade.transitionend, function() {
if ( element.hasClass('fade-trigger') )
return;
element.hide();
callback();
});
setTimeout( function() { element.removeClass( 'fade-trigger' ); }, this.sensitivity );
} else {
if ( stop )
element.stop();
element.first().fadeOut( speed, callback );
if ( element.length > 1 )
element.not(':first').fadeOut( speed );
}
return element;
},
transitions: (function() { // Check if the browser supports CSS 3.0 transitions
var s = document.documentElement.style;
return ( typeof ( s.WebkitTransition ) == 'string' ||
typeof ( s.MozTransition ) == 'string' ||
typeof ( s.OTransition ) == 'string' ||
typeof ( s.transition ) == 'string' );
})()
};
/**
* Resize API
*
* Automatically updates textarea height.
*/
api.bind_resize = function() {
$(s.textarea_obj).bind('keypress.grow click.grow paste.grow', function(){
setTimeout( api.resize_textarea, 200 );
});
}
api.oldheight = 0;
api.resize_textarea = function() {
var txt = s.textarea_obj, newheight;
newheight = txt.scrollHeight > 300 ? txt.scrollHeight : 300;
if ( newheight != api.oldheight ) {
txt.style.height = newheight + 'px';
api.oldheight = newheight;
}
};
})(jQuery);

1
wp-admin/js/wp-fullscreen.min.js vendored Normal file

File diff suppressed because one or more lines are too long

16
wp-admin/js/xfn.js Normal file
View File

@ -0,0 +1,16 @@
jQuery(document).ready( function($) {
$('#link_rel').prop('readonly', true);
$('#linkxfndiv input').bind('click keyup', function() {
var isMe = $('#me').is(':checked'), inputs = '';
$('input.valinp').each( function() {
if (isMe) {
$(this).prop('disabled', true).parent().addClass('disabled');
} else {
$(this).removeAttr('disabled').parent().removeClass('disabled');
if ( $(this).is(':checked') && $(this).val() != '')
inputs += $(this).val() + ' ';
}
});
$('#link_rel').val( (isMe) ? 'me' : inputs.substr(0,inputs.length - 1) );
});
});

1
wp-admin/js/xfn.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready(function(a){a("#link_rel").prop("readonly",true);a("#linkxfndiv input").bind("click keyup",function(){var c=a("#me").is(":checked"),b="";a("input.valinp").each(function(){if(c){a(this).prop("disabled",true).parent().addClass("disabled")}else{a(this).removeAttr("disabled").parent().removeClass("disabled");if(a(this).is(":checked")&&a(this).val()!=""){b+=a(this).val()+" "}}});a("#link_rel").val((c)?"me":b.substr(0,b.length-1))})});