Merge all JS files that always load with common.js

git-svn-id: http://svn.automattic.com/wordpress/trunk@9626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-11-12 00:27:01 +00:00
parent 8edb3ea9bd
commit ef6f5c31d7
6 changed files with 294 additions and 647 deletions

View File

@ -1,25 +1,193 @@
jQuery(document).ready( function() {
wpCookies = {
// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
each : function(o, cb, s) {
var n, l;
if (!o)
return 0;
s = s || o;
if (typeof(o.length) != 'undefined') {
for (n=0, l = o.length; n<l; n++) {
if (cb.call(s, o[n], n, o) === false)
return 0;
}
} else {
for (n in o) {
if (o.hasOwnProperty(n)) {
if (cb.call(s, o[n], n, o) === false)
return 0;
}
}
}
return 1;
},
getHash : function(n) {
var v = this.get(n), h;
if (v) {
this.each(v.split('&'), function(v) {
v = v.split('=');
h = h || {};
h[v[0]] = v[1];
});
}
return h;
},
setHash : function(n, v, e, p, d, s) {
var o = '';
this.each(v, function(v, k) {
o += (!o ? '' : '&') + k + '=' + v;
});
this.set(n, o, e, p, d, s);
},
get : function(n) {
var c = document.cookie, e, p = n + "=", b;
if (!c)
return;
b = c.indexOf("; " + p);
if (b == -1) {
b = c.indexOf(p);
if (b != 0)
return null;
} else
b += 2;
e = c.indexOf(";", b);
if (e == -1)
e = c.length;
return decodeURIComponent(c.substring(b + p.length, e));
},
set : function(n, v, e, p, d, s) {
document.cookie = n + "=" + encodeURIComponent(v) +
((e) ? "; expires=" + e.toGMTString() : "") +
((p) ? "; path=" + p : "") +
((d) ? "; domain=" + d : "") +
((s) ? "; secure" : "");
},
remove : function(n, p) {
var d = new Date();
d.setTime(d.getTime() - 1000);
this.set(n, '', d, p, d);
}
};
// Returns the value as string. Second arg or empty string is returned when value is not set.
function getUserSetting( name, def ) {
var o = getAllUserSettings();
if ( o.hasOwnProperty(name) )
return o[name];
if ( typeof def != 'undefined' )
return def;
return '';
}
// Both name and value must be only ASCII letters, numbers or underscore
// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
function setUserSetting( name, value, del ) {
var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date();
var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
if ( del ) delete o[n];
else o[n] = v;
d.setTime( d.getTime() + 31536000000 );
p = userSettings.url;
wpCookies.setHash(c, o, d, p );
wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
}
function deleteUserSetting( name ) {
setUserSetting( name, '', 1 );
}
// Returns all settings as js object.
function getAllUserSettings() {
return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
}
jQuery(document).ready( function($) {
// pulse // pulse
jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
// show things that should be visible, hide what should be hidden // show things that should be visible, hide what should be hidden
jQuery('.hide-if-no-js').removeClass('hide-if-no-js'); $('.hide-if-no-js').removeClass('hide-if-no-js');
jQuery('.hide-if-js').hide(); $('.hide-if-js').hide();
// Basic form validation // Basic form validation
if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) { if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) {
jQuery('form.validate').submit( function() { return wpAjax.validateForm( jQuery(this) ); } ); $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
} }
// Move .updated and .error alert boxes // Move .updated and .error alert boxes
jQuery('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
jQuery('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first'); $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
// screen settings tab
$('#show-settings-link').click(function () {
if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
$('#contextual-help-link-wrap').addClass('invisible');
}
$('#screen-options-wrap').slideToggle('fast', function(){
if ( $(this).hasClass('screen-options-open') ) {
$('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
$('#contextual-help-link-wrap').removeClass('invisible');
$(this).removeClass('screen-options-open');
} else {
$('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
$(this).addClass('screen-options-open');
}
});
return false;
});
// help tab
$('#contextual-help-link').click(function () {
if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
$('#screen-options-link-wrap').addClass('invisible');
}
$('#contextual-help-wrap').slideToggle('fast', function(){
if ( $(this).hasClass('contextual-help-open') ) {
$('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
$('#screen-options-link-wrap').removeClass('invisible');
$(this).removeClass('contextual-help-open');
} else {
$('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
$(this).addClass('contextual-help-open');
}
});
return false;
});
}); });
// stub for doing better warnings
(function($){ (function($){
showNotice = {
// stub for doing better warnings
showNotice = {
warn : function(text) { warn : function(text) {
if ( confirm(text) ) if ( confirm(text) )
return true; return true;
@ -30,9 +198,101 @@ jQuery(document).ready( function() {
note : function(text) { note : function(text) {
alert(text); alert(text);
} }
};
// sidebar admin menu
adminMenu = {
init : function() {
$('#adminmenu a').attr('tabindex', '10');
$('#adminmenu div.wp-menu-toggle').each( function() {
if ( $(this).siblings('.wp-submenu').length )
$(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
else
$(this).hide();
});
$('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
this.favorites();
$('.wp-menu-separator').click(function(){
if ( $('#adminmenu').hasClass('folded') ) {
adminMenu.fold(1);
setUserSetting( 'mfold', 'o' );
} else {
adminMenu.fold();
setUserSetting( 'mfold', 'f' );
} }
});
if ( 'f' != getUserSetting( 'mfold' ) ) {
this.restoreMenuState();
} else {
this.fold();
}
},
restoreMenuState : function() {
$('#adminmenu li.wp-has-submenu').each(function(i, e) {
var v = getUserSetting( 'm'+i );
if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
if ( 'o' == v ) $(e).addClass('wp-menu-open');
else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
});
},
toggle : function(el) {
el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
$('#adminmenu li.wp-has-submenu').each(function(i, e) {
var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
setUserSetting( 'm'+i, v );
});
return false;
},
fold : function(off) {
if (off) {
$('#adminmenu').removeClass('folded');
$('#adminmenu li.wp-has-submenu').unbind();
} else {
$('#adminmenu').addClass('folded');
$('#adminmenu li.wp-has-submenu').hoverIntent({
over: function(e){
var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o;
if ( (t+h+10) > H ) {
o = (t+h+10) - H;
m.css({'marginTop':'-'+o+'px'});
} else if ( m.css('marginTop') ) {
m.css({'marginTop':''})
}
m.addClass('sub-open');
},
out: function(){ $(this).find('.wp-submenu').removeClass('sub-open'); },
timeout: 220,
sensitivity: 8,
interval: 100
});
}
},
favorites : function() {
$('#favorite-inside').width($('#favorite-actions').width()-4);
$('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } );
$('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } );
}
};
$(document).ready(function(){adminMenu.init();});
})(jQuery); })(jQuery);
/* /*
(function($) { (function($) {
$.fn.tTips = function() { $.fn.tTips = function() {

View File

@ -1,92 +0,0 @@
(function($){
adminMenu = {
init : function() {
$('#adminmenu a').attr('tabindex', '10');
$('#adminmenu div.wp-menu-toggle').each( function() {
if ( $(this).siblings('.wp-submenu').length )
$(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
else
$(this).hide();
});
$('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
this.favorites();
$('.wp-menu-separator').click(function(){
if ( $('#adminmenu').hasClass('folded') ) {
adminMenu.fold(1);
setUserSetting( 'mfold', 'o' );
} else {
adminMenu.fold();
setUserSetting( 'mfold', 'f' );
}
});
if ( 'f' != getUserSetting( 'mfold' ) ) {
this.restoreMenuState();
} else {
this.fold();
}
},
restoreMenuState : function() {
$('#adminmenu li.wp-has-submenu').each(function(i, e) {
var v = getUserSetting( 'm'+i );
if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
if ( 'o' == v ) $(e).addClass('wp-menu-open');
else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
});
},
toggle : function(el) {
el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
$('#adminmenu li.wp-has-submenu').each(function(i, e) {
var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
setUserSetting( 'm'+i, v );
});
return false;
},
fold : function(off) {
if (off) {
$('#adminmenu').removeClass('folded');
$('#adminmenu li.wp-has-submenu').unbind();
} else {
$('#adminmenu').addClass('folded');
$('#adminmenu li.wp-has-submenu').hoverIntent({
over: function(e){
var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o;
if ( (t+h+10) > H ) {
o = (t+h+10) - H;
m.css({'marginTop':'-'+o+'px'});
} else if ( m.css('marginTop') ) {
m.css({'marginTop':''})
}
m.addClass('sub-open');
},
out: function(){ $(this).find('.wp-submenu').removeClass('sub-open'); },
timeout: 220,
sensitivity: 8,
interval: 100
});
}
},
favorites : function() {
$('#favorite-inside').width($('#favorite-actions').width()-4);
$('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } );
$('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } );
}
};
$(document).ready(function(){adminMenu.init();});
})(jQuery);

View File

@ -1,35 +0,0 @@
jQuery(document).ready( function($) {
$('#show-settings-link').click(function () {
if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
$('#contextual-help-link-wrap').addClass('invisible');
}
$('#screen-options-wrap').slideToggle('fast', function(){
if ( $(this).hasClass('screen-options-open') ) {
$('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
$('#contextual-help-link-wrap').removeClass('invisible');
$(this).removeClass('screen-options-open');
} else {
$('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
$(this).addClass('screen-options-open');
}
});
return false;
}).parent();
$('#contextual-help-link').click(function () {
if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
$('#screen-options-link-wrap').addClass('invisible');
}
$('#contextual-help-wrap').slideToggle('fast', function(){
if ( $(this).hasClass('contextual-help-open') ) {
$('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
$('#screen-options-link-wrap').removeClass('invisible');
$(this).removeClass('contextual-help-open');
} else {
$('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
$(this).addClass('contextual-help-open');
}
});
return false;
});
});

View File

@ -1,330 +0,0 @@
jQuery(document).ready( function() {
theFileList = {
currentImage: {ID: 0},
nonce: '',
tab: '',
postID: 0,
// cookie create and read functions adapted from http://www.quirksmode.org/js/cookies.html
createCookie: function(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
},
readCookie: function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
},
assignCookieOnChange: function() {
jQuery(this).bind("change", function(){
theFileList.createCookie(jQuery(this).attr('name'),jQuery(this).attr('id'),365);
});
},
checkCookieSetting: function(name, defaultSetting) {
return this.readCookie(name) ? this.readCookie(name) : defaultSetting;
},
toQueryParams: function( s ) {
var r = {}; if ( !s ) { return r; }
var q = s.split('?'); if ( q[1] ) { s = q[1]; }
var pp = s.split('&');
for ( var i in pp ) {
var p = pp[i].split('=');
r[p[0]] = p[1];
}
return r;
},
toQueryString: function(params) {
var qryStr = '';
for ( var key in params )
qryStr += key + '=' + params[key] + '&';
return qryStr;
},
initializeVars: function() {
this.urlData = document.location.href.split('?');
this.params = this.toQueryParams(this.urlData[1]);
this.postID = this.params['post_id'];
this.tab = this.params['tab'];
this.style = this.params['style'];
this.ID = this.params['ID'];
if ( !this.style )
this.style = 'default';
var nonceEl = jQuery('#nonce-value');
if ( nonceEl )
this.nonce = jQuery(nonceEl).val();
if ( this.ID ) {
this.grabImageData( this.ID );
this.imageView( this.ID );
}
},
initializeLinks: function() {
if ( this.ID )
return;
jQuery('a.file-link').each(function() {
var id = jQuery(this).attr('id').split('-').pop();
jQuery(this).attr('href','javascript:void(0)').click(function(e) {
theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e);
});
});
},
grabImageData: function(id) {
if ( id == this.currentImage.ID )
return;
var thumbEl = jQuery('#attachment-thumb-url-' + id);
if ( thumbEl ) {
this.currentImage.thumb = ( 0 == id ? '' : jQuery(thumbEl).val() );
this.currentImage.thumbBase = ( 0 == id ? '' : jQuery('#attachment-thumb-url-base-' + id).val() );
} else {
this.currentImage.thumb = false;
}
this.currentImage.src = ( 0 == id ? '' : jQuery('#attachment-url-' + id).val() );
this.currentImage.srcBase = ( 0 == id ? '' : jQuery('#attachment-url-base-' + id).val() );
this.currentImage.page = ( 0 == id ? '' : jQuery('#attachment-page-url-' + id).val() );
this.currentImage.title = ( 0 == id ? '' : jQuery('#attachment-title-' + id).val() );
this.currentImage.description = ( 0 == id ? '' : jQuery('#attachment-description-' + id).val() );
var widthEl = jQuery('#attachment-width-' + id);
if ( widthEl ) {
this.currentImage.width = ( 0 == id ? '' : jQuery(widthEl).val() );
this.currentImage.height = ( 0 == id ? '' : jQuery('#attachment-height-' + id).val() );
} else {
this.currentImage.width = false;
this.currentImage.height = false;
}
this.currentImage.isImage = ( 0 == id ? 0 : jQuery('#attachment-is-image-' + id).val() );
this.currentImage.ID = id;
},
imageView: function(id, e) {
this.prepView(id);
var h = '';
h += "<div id='upload-file'>"
if ( this.ID ) {
var params = this.params;
params.ID = '';
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'";
} else {
h += "<a href='#' onclick='return theFileList.cancelView();'";
}
h += " title='" + this.browseTitle + "' class='back'>" + this.back + "</a>";
h += "<div id='file-title'>"
if ( 0 == this.currentImage.isImage )
h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>" + this.currentImage.title + "</a></h2>";
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
h += "<a href='#' onclick='return theFileList.editView(" + id + ");'>" + this.edit + "</a>"
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
if ( 1 == this.currentImage.isImage ) {
h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>";
h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
h += "</a>";
} else
h += '&nbsp;';
h += "</div>";
h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>";
h += "<table>";
var display = [];
var checkedDisplay = 'display-title';
if ( 1 == this.currentImage.isImage ) {
checkedDisplay = 'display-full';
if ( this.currentImage.thumb ) {
display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.thumb + "</label><br />");
checkedDisplay = 'display-thumb';
}
display.push("<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> " + this.full + "</label>");
} else if ( this.currentImage.thumb ) {
display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.icon + "</label>");
}
if ( display.length ) {
display.push("<br /><label for='display-title'><input type='radio' name='display' id='display-title' value='title' /> " + this.title + "</label>");
h += "<tr><th style='padding-bottom:.5em'>" + this.show + "</th><td style='padding-bottom:.5em'>";
jQuery(display).each( function() { h += this; } );
h += "</td></tr>";
}
var checkedLink = 'link-file';
h += "<tr><th>" + this.link + "</th><td>";
h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' /> " + this.file + "</label><br />"; h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />";
h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> " + this.none + "</label>";
h += "</td></tr>";
h += "<tr><td colspan='2'><p class='submit'>";
h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='" + this.editorText + "' />";
h += "</p></td></tr></table>";
h += "</form>";
h += "</div>";
jQuery(h).prependTo('#upload-content');
jQuery("input[@name='display']").each(theFileList.assignCookieOnChange);
jQuery("input[@name='link']").each(theFileList.assignCookieOnChange);
checkedDisplay = this.checkCookieSetting('display', checkedDisplay);
checkedLink = this.checkCookieSetting('link', checkedLink);
jQuery('#' + checkedDisplay).attr('checked','checked');
jQuery('#' + checkedLink).attr('checked','checked');
if (e) return e.stopPropagation();
return false;
},
editView: function(id, e) {
this.prepView(id);
var h = '';
var action = 'upload.php?style=' + this.style + '&amp;tab=upload';
if ( this.postID )
action += '&amp;post_id=' + this.postID;
h += "<form id='upload-file' method='post' action='" + action + "'>";
if ( this.ID ) {
var params = this.params;
params.ID = '';
params.action = '';
h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'";
} else {
h += "<a href='#' onclick='return theFileList.cancelView();'";
}
h += " title='" + this.browseTitle + "' class='back'>" + this.back + "</a>";
h += "<div id='file-title'>"
if ( 0 == this.currentImage.isImage )
h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>" + this.currentImage.title + "</a></h2>";
else
h += "<h2>" + this.currentImage.title + "</h2>";
h += " &#8212; <span>";
h += "<a href='#' onclick='return theFileList.imageView(" + id + ");'>" + this.insert + "</a>";
h += "</span>";
h += '</div>'
h += "<div id='upload-file-view' class='alignleft'>";
if ( 1 == this.currentImage.isImage ) {
h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>";
h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
h += "</a>";
} else
h += '&nbsp;';
h += "</div>";
h += "<table><col /><col class='widefat' /><tr>";
h += "<th scope='row'><label for='url'>" + this.urlText + "</label></th>";
h += "<td><input type='text' id='url' class='readonly' value='" + this.currentImage.srcBase + this.currentImage.src + "' readonly='readonly' /></td>";
h += "</tr><tr>";
h += "<th scope='row'><label for='post_title'>" + this.title + "</label></th>";
h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>";
h += "</tr><tr>";
h += "<th scope='row'><label for='post_content'>" + this.desc + "</label></th>";
h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='" + this.deleteText + "' onclick='theFileList.deleteFile(" + id + ");' />";
h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
h += "<input type='hidden' name='post_parent' value='" + parseInt(this.postID,10) + "' />";
h += "<input type='hidden' name='action' id='action-value' value='save' />";
h += "<input type='hidden' name='ID' value='" + id + "' />";
h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
h += "<div class='submit'><input type='submit' value='" + this.saveText + "' /></div>";
h += "</td></tr></table></form>";
jQuery(h).prependTo('#upload-content');
if (e) e.stopPropagation();
return false;
},
prepView: function(id) {
this.cancelView( true );
var filesEl = jQuery('#upload-files');
if ( filesEl )
filesEl.hide();
var navEl = jQuery('#current-tab-nav');
if ( navEl )
navEl.hide();
this.grabImageData(id);
},
cancelView: function( prep ) {
if ( !prep ) {
var filesEl = jQuery('#upload-files');
if ( filesEl )
jQuery(filesEl).show();
var navEl = jQuery('#current-tab-nav');
if ( navEl )
jQuery(navEl).show();
}
if ( !this.ID )
this.grabImageData(0);
var div = jQuery('#upload-file');
if ( div )
jQuery(div).remove();
return false;
},
sendToEditor: function(id) {
this.grabImageData(id);
var link = '';
var display = '';
var h = '';
link = jQuery('input[@type=radio][@name="link"][@checked]','#uploadoptions').val();
displayEl = jQuery('input[@type=radio][@name="display"][@checked]','#uploadoptions');
if ( displayEl )
display = jQuery(displayEl).val();
else if ( 1 == this.currentImage.isImage )
display = 'full';
if ( 'none' != link )
h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID ) ) + "' title='" + this.currentImage.title + "'>";
if ( display && 'title' != display )
h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
else
h += this.currentImage.title;
if ( 'none' != link )
h += "</a>";
var win = window.opener ? window.opener : window.dialogArguments;
if ( !win )
win = top;
tinyMCE = win.tinyMCE;
if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) {
tinyMCE.selectedInstance.getWin().focus();
tinyMCE.execCommand('mceInsertContent', false, h);
} else
win.edInsertContent(win.edCanvas, h);
if ( !this.ID )
this.cancelView();
return false;
},
deleteFile: function(id) {
if ( confirm( this.confirmText.replace(/%title%/g, this.currentImage.title) ) ) {
jQuery('#action-value').attr('value','delete');
jQuery('#upload-file').submit();
return true;
}
return false;
}
};
for ( var property in uploadL10n )
theFileList[property] = uploadL10n[property];
theFileList.initializeVars();
theFileList.initializeLinks();
} );

View File

@ -1,129 +0,0 @@
wpCookies = {
// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
each : function(o, cb, s) {
var n, l;
if (!o)
return 0;
s = s || o;
if (typeof(o.length) != 'undefined') {
for (n=0, l = o.length; n<l; n++) {
if (cb.call(s, o[n], n, o) === false)
return 0;
}
} else {
for (n in o) {
if (o.hasOwnProperty(n)) {
if (cb.call(s, o[n], n, o) === false)
return 0;
}
}
}
return 1;
},
getHash : function(n) {
var v = this.get(n), h;
if (v) {
this.each(v.split('&'), function(v) {
v = v.split('=');
h = h || {};
h[v[0]] = v[1];
});
}
return h;
},
setHash : function(n, v, e, p, d, s) {
var o = '';
this.each(v, function(v, k) {
o += (!o ? '' : '&') + k + '=' + v;
});
this.set(n, o, e, p, d, s);
},
get : function(n) {
var c = document.cookie, e, p = n + "=", b;
if (!c)
return;
b = c.indexOf("; " + p);
if (b == -1) {
b = c.indexOf(p);
if (b != 0)
return null;
} else
b += 2;
e = c.indexOf(";", b);
if (e == -1)
e = c.length;
return decodeURIComponent(c.substring(b + p.length, e));
},
set : function(n, v, e, p, d, s) {
document.cookie = n + "=" + encodeURIComponent(v) +
((e) ? "; expires=" + e.toGMTString() : "") +
((p) ? "; path=" + p : "") +
((d) ? "; domain=" + d : "") +
((s) ? "; secure" : "");
},
remove : function(n, p) {
var d = new Date();
d.setTime(d.getTime() - 1000);
this.set(n, '', d, p, d);
}
};
// Returns the value as string. Second arg or empty string is returned when value is not set.
function getUserSetting( name, def ) {
var o = getAllUserSettings();
if ( o.hasOwnProperty(name) )
return o[name];
if ( typeof def != 'undefined' )
return def;
return '';
}
// Both name and value must be only ASCII letters, numbers or underscore
// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
function setUserSetting( name, value, del ) {
var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date();
var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
if ( del ) delete o[n];
else o[n] = v;
d.setTime( d.getTime() + 31536000000 );
p = userSettings.url;
wpCookies.setHash(c, o, d, p );
wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
}
function deleteUserSetting( name ) {
setUserSetting( name, '', 1 );
}
// Returns all settings as js object.
function getAllUserSettings() {
return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
}

View File

@ -41,7 +41,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->base_url = $guessurl; $scripts->base_url = $guessurl;
$scripts->default_version = get_bloginfo( 'version' ); $scripts->default_version = get_bloginfo( 'version' );
$scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'user-settings', 'menu'), '20081107' ); $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081111' );
$scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); $scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' );
$scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081103' ); $scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081103' );
@ -145,8 +145,8 @@ function wp_default_scripts( &$scripts ) {
'add' => attribute_escape(__('Add')), 'add' => attribute_escape(__('Add')),
'how' => __('Separate multiple categories with commas.') 'how' => __('Separate multiple categories with commas.')
) ); ) );
$scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns', 'settings-box'), '20080925' ); $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns'), '20080925' );
$scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns', 'settings-box'), '20080925' ); $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20080925' );
$scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' ); $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
$scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081021' ); $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081021' );
$scripts->localize( 'password-strength-meter', 'pwsL10n', array( $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
@ -156,16 +156,15 @@ function wp_default_scripts( &$scripts ) {
'good' => __('Medium'), 'good' => __('Medium'),
'strong' => __('Strong') 'strong' => __('Strong')
) ); ) );
$scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'columns', 'settings-box'), '20081031' ); $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'columns'), '20081031' );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array( $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
'pending' => __('%i% pending'), // must look like: "# blah blah" 'pending' => __('%i% pending'), // must look like: "# blah blah"
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
) ); ) );
$scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists', 'columns', 'settings-box'), '20080925' ); $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists', 'columns'), '20080925' );
$scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729'); $scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729');
$scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
$scripts->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
$scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081109' ); $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081109' );
$scripts->localize( 'postbox', 'postboxL10n', array( $scripts->localize( 'postbox', 'postboxL10n', array(
'requestFile' => admin_url('admin-ajax.php'), 'requestFile' => admin_url('admin-ajax.php'),
@ -176,7 +175,7 @@ function wp_default_scripts( &$scripts ) {
'save' => __('Save'), 'save' => __('Save'),
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
) ); ) );
$scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug', 'settings-box'), '20081107' ); $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081107' );
$scripts->localize( 'post', 'postL10n', array( $scripts->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'), 'tagsUsed' => __('Tags used on this post:'),
'add' => attribute_escape(__('Add')), 'add' => attribute_escape(__('Add')),
@ -195,7 +194,7 @@ function wp_default_scripts( &$scripts ) {
'savePending' => __('Save as Pending'), 'savePending' => __('Save as Pending'),
'saveDraft' => __('Save Draft') 'saveDraft' => __('Save Draft')
) ); ) );
$scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox', 'settings-box'), '20081107' ); $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081107' );
$scripts->localize( 'page', 'postL10n', array( $scripts->localize( 'page', 'postL10n', array(
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
'edit' => __('Edit'), 'edit' => __('Edit'),
@ -210,7 +209,7 @@ function wp_default_scripts( &$scripts ) {
'savePending' => __('Save as Pending'), 'savePending' => __('Save as Pending'),
'saveDraft' => __('Save Draft') 'saveDraft' => __('Save Draft')
) ); ) );
$scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox', 'settings-box'), '20080925' ); $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080925' );
$scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081103' ); $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081103' );
$scripts->localize( 'comment', 'commentL10n', array( $scripts->localize( 'comment', 'commentL10n', array(
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
@ -219,28 +218,7 @@ function wp_default_scripts( &$scripts ) {
) ); ) );
$scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' ); $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' );
$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081031' ); $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081031' );
$scripts->localize( 'upload', 'uploadL10n', array(
'browseTitle' => attribute_escape(__('Browse your files')),
'back' => __('&laquo; Back'),
'directTitle' => attribute_escape(__('Direct link to file')),
'edit' => __('Edit'),
'thumb' => __('Thumbnail'),
'full' => __('Full size'),
'icon' => __('Icon'),
'title' => __('Title'),
'show' => __('Show:'),
'link' => __('Link to:'),
'file' => __('File'),
'page' => __('Page'),
'none' => __('None'),
'editorText' => attribute_escape(__('Send to editor &raquo;')),
'insert' => __('Insert'),
'urlText' => __('URL'),
'desc' => __('Description'),
'deleteText' => attribute_escape(__('Delete File')),
'saveText' => attribute_escape(__('Save &raquo;')),
'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.")
) );
$scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081010' ); $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081010' );
$scripts->localize( 'admin-widgets', 'widgetsL10n', array( $scripts->localize( 'admin-widgets', 'widgetsL10n', array(
'add' => __('Add'), 'add' => __('Add'),
@ -280,24 +258,19 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
$scripts->add( 'user-settings', '/wp-admin/js/user-settings.js', array(), '20080829' ); $scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns'), '20080925' );
$scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns'), '20080925' );
$scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns', 'settings-box'), '20080925' ); $scripts->add( 'links', '/wp-admin/js/links.js', array('columns'), '20080925' );
$scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns', 'settings-box'), '20080925' ); $scripts->add( 'media', '/wp-admin/js/media.js', array('columns'), '20080925' );
$scripts->add( 'links', '/wp-admin/js/links.js', array('columns', 'settings-box'), '20080925' );
$scripts->add( 'media', '/wp-admin/js/media.js', array('columns', 'settings-box'), '20080925' );
$scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' ); $scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' );
$scripts->localize( 'columns', 'columnsL10n', array( $scripts->localize( 'columns', 'columnsL10n', array(
'requestFile' => admin_url('admin-ajax.php'), 'requestFile' => admin_url('admin-ajax.php'),
) ); ) );
$scripts->add( 'settings-box', '/wp-admin/js/settings-box.js', array( 'jquery' ), '20081107' ); $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081016' );
$scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox', 'settings-box' ), '20081016' );
$scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081109' ); $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081109' );
$scripts->add( 'menu', '/wp-admin/js/menu.js', array( 'jquery', 'hoverIntent' ), '20081109' );
} }
} }
@ -400,7 +373,7 @@ function wp_just_in_time_script_localization() {
) ); ) );
$userid = isset($current_user) ? $current_user->ID : 0; $userid = isset($current_user) ? $current_user->ID : 0;
wp_localize_script( 'user-settings', 'userSettings', array( wp_localize_script( 'common', 'userSettings', array(
'url' => SITECOOKIEPATH, 'url' => SITECOOKIEPATH,
'uid' => $userid, 'uid' => $userid,
'time' => time() 'time' => time()