diff --git a/wp-includes/js/list-manipulation-js.php b/wp-includes/js/list-manipulation.js
similarity index 92%
rename from wp-includes/js/list-manipulation-js.php
rename to wp-includes/js/list-manipulation.js
index 459abc29e..d60d9e41d 100644
--- a/wp-includes/js/list-manipulation-js.php
+++ b/wp-includes/js/list-manipulation.js
@@ -1,7 +1,24 @@
-
-addLoadEvent(function(){theList=new listMan();});
-function deleteSomething(what,id,message,obj){if(!obj)obj=theList;if(!message)message="";if(confirm(message))return obj.ajaxDelete(what,id);else return false;}
-function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxDimmer(what,id,dimClass);}
+addLoadEvent( function() {
+ if ( 'undefined' != typeof listManL10n )
+ Object.extend(listMan.prototype, listManL10n);
+ theList = new listMan();
+} );
+
+function deleteSomething( what, id, message, obj ) {
+ if ( !obj )
+ obj=theList;
+ if ( !message )
+ message = obj.delText.replace(/%/g, what);
+ if( confirm(message) )
+ return obj.ajaxDelete( what, id );
+ else return false;
+}
+
+function dimSomething( what, id, dimClass, obj ) {
+ if ( !obj )
+ obj = theList;
+ return obj.ajaxDimmer(what,id,dimClass);
+}
var listMan = Class.create();
Object.extend(listMan.prototype, {
@@ -19,6 +36,9 @@ Object.extend(listMan.prototype, {
dataStore: null,
formStore: null,
+ jumpText: 'Jump to new item',
+ delText: 'Are you sure you want to delete this %s?',
+
initialize: function(theListId) {
this.theList = $(theListId ? theListId : 'the-list');
if ( !this.theList )
@@ -53,7 +73,7 @@ Object.extend(listMan.prototype, {
if ( m )
showLinkMessage += m;
else
- showLinkMessage += "";
+ showLinkMessage += "" + tempObj.jumpText + "";
});
if ( tempObj.showLink && showLinkMessage )
Element.update(ajaxAdd.myResponseElement,"
");
@@ -127,7 +147,7 @@ Object.extend(listMan.prototype, {
Element.cleanWhitespace(this.theList);
var id = this.topAdder ? this.theList.firstChild.id : this.theList.lastChild.id;
if ( this.alt )
- if ( this.theList.childNodes.length % 2 )
+ if ( ( this.theList.childNodes.length + this.altOffset ) % 2 )
Element.addClassName($(id),this.alt);
Fat.fade_element(id);
},
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index 8026973b8..f593ea497 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -21,7 +21,11 @@ class WP_Scripts {
$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.php', array('wp-ajax', 'fat'), '20070118');
+ $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070305');
+ $this->localize( 'listman', 'listManL10n', array(
+ 'jumpText' => __('Jump to new item'),
+ 'delText' => __('Are you sure you want to delete this %s?')
+ ) );
$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');
$this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.0');
@@ -83,12 +87,31 @@ class WP_Scripts {
$src = add_query_arg('ver', $ver, $src);
$src = apply_filters( 'script_loader_src', $src );
echo "\n";
+ $this->print_scripts_l10n( $handle );
}
$this->printed[] = $handle;
}
}
}
+ function print_scripts_l10n( $handle ) {
+ if ( empty($this->scripts[$handle]->l10n_object) || empty($this->scripts[$handle]->l10n) || !is_array($this->scripts[$handle]->l10n) )
+ return;
+
+ $object_name = $this->scripts[$handle]->l10n_object;
+
+ echo "\n";
+ }
/**
* Determines dependencies of scripts
@@ -140,6 +163,22 @@ class WP_Scripts {
return true;
}
+ /**
+ * Localizes a script
+ *
+ * Localizes only if script has already been added
+ *
+ * @param string handle Script name
+ * @param string object_name Name of JS object to hold l10n info
+ * @param array l10n Array of JS var name => localized string
+ * @return bool Successful localization
+ */
+ function localize( $handle, $object_name, $l10n ) {
+ if ( !isset($this->scripts[$handle]) )
+ return false;
+ return $this->scripts[$handle]->localize( $object_name, $l10n );
+ }
+
function remove( $handles ) {
foreach ( (array) $handles as $handle )
unset($this->scripts[$handle]);
@@ -182,7 +221,8 @@ class _WP_Script {
var $src;
var $deps = array();
var $ver = false;
- var $args = false;
+ var $l10n_object = '';
+ var $l10n = array();
function _WP_Script() {
@list($this->handle, $this->src, $this->deps, $this->ver) = func_get_args();
@@ -191,6 +231,14 @@ class _WP_Script {
if ( !$this->ver )
$this->ver = false;
}
+
+ function localize( $object_name, $l10n ) {
+ if ( !$object_name || !is_array($l10n) )
+ return false;
+ $this->l10n_object = $object_name;
+ $this->l10n = $l10n;
+ return true;
+ }
}
/**
@@ -227,6 +275,21 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false ) {
$wp_scripts->add( $handle, $src, $deps, $ver );
}
+/**
+ * Localizes a script
+ *
+ * Localizes only if script has already been added
+ *
+ * @see WP_Script::localize()
+ */
+function wp_localize_script( $handle, $object_name, $l10n ) {
+ global $wp_scripts;
+ if ( !is_a($wp_scripts, 'WP_Scripts') )
+ return false;
+
+ return $wp_scripts->localize( $handle, $object_name, $l10n );
+}
+
function wp_deregister_script( $handle ) {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )