diff --git a/wp-admin/cat-js.php b/wp-admin/cat.js similarity index 68% rename from wp-admin/cat-js.php rename to wp-admin/cat.js index 74abc0152..ab94d4ca1 100644 --- a/wp-admin/cat-js.php +++ b/wp-admin/cat.js @@ -1,14 +1,10 @@ - addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;}); addLoadEvent(newCatAddIn); function newCatAddIn() { var jaxcat = $('jaxcat'); if ( !jaxcat ) return false; - Element.update(jaxcat,''); + Element.update(jaxcat,'' + catL10n.how + ''); $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); }; $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); }; } diff --git a/wp-admin/dbx-admin-key-js.php b/wp-admin/dbx-admin-key-js.php deleted file mode 100644 index eb5e1a437..000000000 --- a/wp-admin/dbx-admin-key-js.php +++ /dev/null @@ -1,68 +0,0 @@ - -addLoadEvent( function() {var manager = new dbxManager('');} ); - -addLoadEvent( function() -{ - //create new docking boxes group - var meta = new dbxGroup( - 'grabit', // container ID [/-_a-zA-Z0-9/] - 'vertical', // orientation ['vertical'|'horizontal'] - '10', // drag threshold ['n' pixels] - 'no', // restrict drag movement to container axis ['yes'|'no'] - '10', // animate re-ordering [frames per transition, or '0' for no effect] - 'yes', // include open/close toggle buttons ['yes'|'no'] - 'closed', // default state ['open'|'closed'] - '', // word for "open", as in "open this box" - '', // word for "close", as in "close this box" - '', // sentence for "move this box" by mouse - '', // pattern-match sentence for "(open|close) this box" by mouse - '', // sentence for "move this box" by keyboard - '', // pattern-match sentence-fragment for "(open|close) this box" by keyboard - '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts - ); - - // Boxes are closed by default. Open the Category box if the cookie isn't already set. - var catdiv = document.getElementById('categorydiv'); - if ( catdiv ) { - var button = catdiv.getElementsByTagName('A')[0]; - if ( dbx.cookiestate == null && /dbx\-toggle\-closed/.test(button.className) ) - meta.toggleBoxState(button, true); - } - - var advanced = new dbxGroup( - 'advancedstuff', // container ID [/-_a-zA-Z0-9/] - 'vertical', // orientation ['vertical'|'horizontal'] - '10', // drag threshold ['n' pixels] - 'yes', // restrict drag movement to container axis ['yes'|'no'] - '10', // animate re-ordering [frames per transition, or '0' for no effect] - 'yes', // include open/close toggle buttons ['yes'|'no'] - 'closed', // default state ['open'|'closed'] - '', // word for "open", as in "open this box" - '', // word for "close", as in "close this box" - '', // sentence for "move this box" by mouse - '', // pattern-match sentence for "(open|close) this box" by mouse - '', // sentence for "move this box" by keyboard - '', // pattern-match sentence-fragment for "(open|close) this box" by keyboard - '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts - ); -}); diff --git a/wp-admin/dbx-admin-key.js b/wp-admin/dbx-admin-key.js new file mode 100644 index 000000000..9ea666ca5 --- /dev/null +++ b/wp-admin/dbx-admin-key.js @@ -0,0 +1,47 @@ +addLoadEvent( function() {var manager = new dbxManager( dbxL10n.mananger );} ); + +addLoadEvent( function() +{ + //create new docking boxes group + var meta = new dbxGroup( + 'grabit', // container ID [/-_a-zA-Z0-9/] + 'vertical', // orientation ['vertical'|'horizontal'] + '10', // drag threshold ['n' pixels] + 'no', // restrict drag movement to container axis ['yes'|'no'] + '10', // animate re-ordering [frames per transition, or '0' for no effect] + 'yes', // include open/close toggle buttons ['yes'|'no'] + 'closed', // default state ['open'|'closed'] + dbxL10n.open, // word for "open", as in "open this box" + dbxL10n.close, // word for "close", as in "close this box" + dbxL10n.moveMouse, // sentence for "move this box" by mouse + dbxL10n.toggleMouse, // pattern-match sentence for "(open|close) this box" by mouse + dbxL10n.moveKey, // sentence for "move this box" by keyboard + dbxL10n.toggleKey, // pattern-match sentence-fragment for "(open|close) this box" by keyboard + '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts + ); + + // Boxes are closed by default. Open the Category box if the cookie isn't already set. + var catdiv = document.getElementById('categorydiv'); + if ( catdiv ) { + var button = catdiv.getElementsByTagName('A')[0]; + if ( dbx.cookiestate == null && /dbx\-toggle\-closed/.test(button.className) ) + meta.toggleBoxState(button, true); + } + + var advanced = new dbxGroup( + 'advancedstuff', + 'vertical', + '10', + 'yes', // restrict drag movement to container axis ['yes'|'no'] + '10', + 'yes', + 'closed', + dbxL10n.open, + dbxL10n.close, + dbxL10n.moveMouse, + dbxL10n.toggleMouse, + dbxL10n.moveKey, + dbxL10n.toggleKey, + '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts + ); +}); diff --git a/wp-admin/upload-js.php b/wp-admin/upload.js similarity index 74% rename from wp-admin/upload-js.php rename to wp-admin/upload.js index b406355b8..a77e9d151 100644 --- a/wp-admin/upload-js.php +++ b/wp-admin/upload.js @@ -1,4 +1,3 @@ - addLoadEvent( function() { theFileList = { currentImage: {ID: 0}, @@ -69,22 +68,23 @@ addLoadEvent( function() { var params = $H(this.params); params.ID = ''; params.action = ''; - h += "' class='back'>"; + h += "" + this.back + ""; h += "
" if ( 0 == this.currentImage.isImage ) - h += "

'>" + this.currentImage.title + "

"; + h += "

" + this.currentImage.title + "

"; else h += "

" + this.currentImage.title + "

"; h += " — "; - h += "" + h += "" + this.edit + "" h += ""; h += '
' h += "
"; if ( 1 == this.currentImage.isImage ) { - h += "'>"; + h += ""; h += "" + this.currentImage.title + ""; h += ""; } else @@ -98,28 +98,28 @@ addLoadEvent( function() { if ( 1 == this.currentImage.isImage ) { checked = 'display-full'; if ( this.currentImage.thumb ) { - display.push("
"); + display.push("
"); checked = 'display-thumb'; } - display.push(""); + display.push(""); } else if ( this.currentImage.thumb ) { - display.push(""); + display.push(""); } if ( display.length ) { - display.push("
"); - h += ""; + display.push("
"); + h += "" + this.show + ""; $A(display).each( function(i) { h += i; } ); h += ""; } - h += ""; - h += "
"; - h += "
"; - h += ""; + h += "" + this.link + ""; + h += "
"; + h += "
"; + h += ""; h += ""; h += "

"; - h += "' />"; + h += ""; h += "

"; h += ""; @@ -147,22 +147,23 @@ addLoadEvent( function() { var params = $H(this.params); params.ID = ''; params.action = ''; - h += "' class='back'>"; + h += "" + this.back + ""; h += "
" if ( 0 == this.currentImage.isImage ) - h += "

'>" + this.currentImage.title + "

"; + h += "

" + this.currentImage.title + "

"; else h += "

" + this.currentImage.title + "

"; h += " — "; - h += "" + h += "" + this.insert + ""; h += ""; h += '
' h += "
"; if ( 1 == this.currentImage.isImage ) { - h += "'>"; + h += ""; h += "" + this.currentImage.title + ""; h += ""; } else @@ -170,21 +171,21 @@ addLoadEvent( function() { h += "
"; - h += "" - h += ""; + h += "
"; + h += ""; h += ""; h += ""; - h += ""; + h += ""; h += ""; h += ""; - h += ""; + h += ""; h += ""; - h += "
' onclick='theFileList.deleteFile(" + id + ");' />"; + h += "
"; h += ""; h += ""; h += ""; h += ""; - h += "
' />
"; + h += "
"; h += "
"; new Insertion.Top('upload-content', h); @@ -257,7 +258,7 @@ addLoadEvent( function() { }, deleteFile: function(id) { - if ( confirm("") ) { + if ( confirm( this.confirmText.replace(/%title%/g, this.currentImage.title) ) ) { $('action-value').value = 'delete'; $('upload-file').submit(); return true; @@ -266,6 +267,7 @@ addLoadEvent( function() { } }; + Object.extend( theFileList, uploadL10n ); theFileList.initializeVars(); theFileList.initializeLinks(); } ); diff --git a/wp-includes/js/autosave-js.php b/wp-includes/js/autosave.js similarity index 87% rename from wp-includes/js/autosave-js.php rename to wp-includes/js/autosave.js index caaa16d93..ae2c10545 100644 --- a/wp-includes/js/autosave-js.php +++ b/wp-includes/js/autosave.js @@ -1,6 +1,3 @@ - var autosaveLast = ''; var autosavePeriodical; @@ -8,7 +5,7 @@ function autosave_start_timer() { var form = $('post'); autosaveLast = form.post_title.value+form.content.value; // Keep autosave_interval in sync with edit_post(). - autosavePeriodical = new PeriodicalExecuter(autosave, ); + autosavePeriodical = new PeriodicalExecuter(autosave, autosaveL10n.autosaveInterval); //Disable autosave after the form has been submitted if(form.addEventListener) { form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false); @@ -40,9 +37,9 @@ function autosave_update_post_ID() { var message; if(isNaN(res)) { - message = "" + response; + message = autosaveL10n.errorText.replace(/%response%/g, response); } else { - message = "" + autosave_cur_time(); + message = autosaveL10n.saveText.replace(/%time%/g, autosave_cur_time()); $('post_ID').name = "post_ID"; $('post_ID').value = res; // We need new nonces @@ -52,7 +49,7 @@ function autosave_update_post_ID() { nonceAjax.setVar("post_ID", res); nonceAjax.setVar("cookie", document.cookie); nonceAjax.setVar("post_type", $('post_type').value); - nonceAjax.requestFile = "/wp-admin/admin-ajax.php"; + nonceAjax.requestFile = autosaveL10n.requestFile; nonceAjax.onCompletion = autosave_update_nonce; nonceAjax.method = "POST"; nonceAjax.runAJAX(); @@ -63,7 +60,7 @@ function autosave_update_post_ID() { } function autosave_loading() { - $('autosave').innerHTML = ""; + $('autosave').innerHTML = autosaveL10n.savingText; } function autosave_saved() { @@ -72,9 +69,9 @@ function autosave_saved() { var message; if(isNaN(res)) { - message = "" + response; + message = autosaveL10n.errorText.replace(/%response%/g, response); } else { - message = "" + autosave_cur_time() + "."; + message = autosaveL10n.saveText.replace(/%time%/g, autosave_cur_time()); } $('autosave').innerHTML = message; autosave_enable_buttons(); @@ -148,7 +145,7 @@ function autosave() { autosaveAjax.setVar("content", form.content.value); } - autosaveAjax.requestFile = "/wp-admin/admin-ajax.php"; + autosaveAjax.requestFile = autosaveL10n.requestFile; autosaveAjax.method = "POST"; autosaveAjax.element = null; autosaveAjax.onLoading = autosave_loading; diff --git a/wp-includes/js/list-manipulation.js b/wp-includes/js/list-manipulation.js index d60d9e41d..e522709c2 100644 --- a/wp-includes/js/list-manipulation.js +++ b/wp-includes/js/list-manipulation.js @@ -8,7 +8,7 @@ function deleteSomething( what, id, message, obj ) { if ( !obj ) obj=theList; if ( !message ) - message = obj.delText.replace(/%/g, what); + message = obj.delText.replace(/%thing%/g, what); if( confirm(message) ) return obj.ajaxDelete( what, id ); else return false; @@ -36,8 +36,8 @@ Object.extend(listMan.prototype, { dataStore: null, formStore: null, - jumpText: 'Jump to new item', - delText: 'Are you sure you want to delete this %s?', + jumpText: '', // We get these from listManL10n + delText: '', initialize: function(theListId) { this.theList = $(theListId ? theListId : 'the-list'); diff --git a/wp-includes/js/wp-ajax-js.php b/wp-includes/js/wp-ajax.js similarity index 89% rename from wp-includes/js/wp-ajax-js.php rename to wp-includes/js/wp-ajax.js index f424c0d63..cc3bb5a4b 100644 --- a/wp-includes/js/wp-ajax-js.php +++ b/wp-includes/js/wp-ajax.js @@ -1,9 +1,13 @@ - var WPAjax = Class.create(); Object.extend(WPAjax.prototype, Ajax.Request.prototype); Object.extend(WPAjax.prototype, { WPComplete: false, // onComplete function WPError: false, // onWPError function + defaultUrl: '', // We get these from WPAjaxL10n + permText: '', + strangeText: '', + whoaText: '', + initialize: function(url, responseEl) { var tempObj = this; this.transport = Ajax.getTransport(); @@ -19,7 +23,7 @@ Object.extend(WPAjax.prototype, { tempObj.WPError(transport); } }); - this.url = url ? url : '/wp-admin/admin-ajax.php'; + this.url = url ? url : this.defaultUrl; this.getResponseElement(responseEl); }, addArg: function(key, value) { @@ -52,10 +56,10 @@ Object.extend(WPAjax.prototype, { } var r = parseInt(r,10); if ( -1 == r ) { - Element.update(this.myResponseElement,"

"); + Element.update(this.myResponseElement,"

" + this.permText + "

"); return false; } else if ( 0 == r ) { - Element.update(this.myResponseElement,"

"); + Element.update(this.myResponseElement,"

" + this.strangeText + "

"); return false; } return true; @@ -71,6 +75,8 @@ Object.extend(WPAjax.prototype, { } }); +Event.observe( window, 'load', function() { Object.extend(WPAjax.prototype, WPAjaxL10n); }, false ) + Ajax.activeSendCount = 0; Ajax.Responders.register( { onCreate: function() { @@ -79,7 +85,7 @@ Ajax.Responders.register( { return; wpBeforeUnload = window.onbeforeunload; window.onbeforeunload = function() { - return ""; + return WPAjax.whoaText; } }, onLoading: function() { // Can switch to onLoaded if we lose data diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index f593ea497..31d712251 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -19,12 +19,25 @@ class WP_Scripts { $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070225' ); $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0-0'); - $this->add( 'autosave', '/wp-includes/js/autosave-js.php', array('prototype', 'sack'), '20070116'); - $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '20070118'); - $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070305'); + $this->add( 'autosave', '/wp-includes/js/autosave.js', array('prototype', 'sack'), '20070306'); + $this->localize( 'autosave', 'autosaveL10n', array( + 'autosaveInterval' => apply_filters('autosave_interval', '120'), + 'errorText' => __('Error: %response%'), + 'saveText' => __('Saved at %time%.'), + 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', + 'savingText' => __('Saving Draft...') + ) ); + $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306'); + $this->localize( 'wp-ajax', 'WPAjaxL10n', array( + 'defaultUrl' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', + 'permText' => __("You don't have permission to do that."), + 'strangeText' => __("Something strange happened. Try refreshing the page."), + 'whoaText' => __("Slow down, I'm still sending your data!") + ) ); + $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306'); $this->localize( 'listman', 'listManL10n', array( 'jumpText' => __('Jump to new item'), - 'delText' => __('Are you sure you want to delete this %s?') + 'delText' => __('Are you sure you want to delete this %thing%?') ) ); $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0'); $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0'); @@ -37,14 +50,66 @@ class WP_Scripts { $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.1'); $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.1.1'); if ( is_admin() ) { - $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' ); - $this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '20070118' ); + global $pagenow; + $man = false; + switch ( $pagenow ) : + case 'post.php' : + case 'post-new.php' : + $man = 'postmeta'; + break; + case 'page.php' : + case 'page-new.php' : + $man = 'pagemeta'; + break; + case 'link.php' : + $man = 'linkmeta'; + break; + endswitch; + if ( $man ) { + $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key.js', array('dbx'), '20070306' ); + $this->localize( 'dbx-admin-key', 'dbxL10n', array( + 'manager' => $man, + 'open' => __('open'), + 'close' => __('close'), + 'moveMouse' => __('click-down and drag to move this box'), + 'toggleMouse' => __('click to %toggle% this box'), + 'moveKey' => __('use the arrow keys to move this box'), + 'toggleKey' => __(', or press the enter key to %toggle% it'), + ) ); + } + $this->add( 'ajaxcat', '/wp-admin/cat.js', array('listman'), '20070306' ); + $this->localize( 'ajaxcat', 'catL10n', array( + 'add' => attribute_escape(__('Add')), + 'how' => __('Separate multiple categories with commas.') + ) ); $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' ); $this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' ); $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' ); $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' ); $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' ); - $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '20070118' ); + $this->add( 'upload', '/wp-admin/upload.js', array('prototype'), '20070306' ); + $this->localize( 'upload', 'uploadL10n', array( + 'browseTitle' => attribute_escape(__('Browse your files')), + 'back' => __('« 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 »')), + 'insert' => __('Insert'), + 'urlText' => __('URL'), + 'desc' => __('Description'), + 'deleteText' => attribute_escape(__('Delete File')), + 'saveText' => attribute_escape(__('Save »')), + 'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.") + ) ); } }