Changeset 4968
- Timestamp:
- 03/06/2007 12:39:46 AM (18 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/list-manipulation.js
r4966 r4968 1 <?php @require_once('../../wp-config.php'); cache_javascript_headers(); ?> 2 addLoadEvent(function(){theList=new listMan();}); 3 function deleteSomething(what,id,message,obj){if(!obj)obj=theList;if(!message)message="<?php printf(js_escape(__('Are you sure you want to delete this %s?')),"'+what+'"); ?>";if(confirm(message))return obj.ajaxDelete(what,id);else return false;} 4 function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxDimmer(what,id,dimClass);} 1 addLoadEvent( function() { 2 if ( 'undefined' != typeof listManL10n ) 3 Object.extend(listMan.prototype, listManL10n); 4 theList = new listMan(); 5 } ); 6 7 function deleteSomething( what, id, message, obj ) { 8 if ( !obj ) 9 obj=theList; 10 if ( !message ) 11 message = obj.delText.replace(/%/g, what); 12 if( confirm(message) ) 13 return obj.ajaxDelete( what, id ); 14 else return false; 15 } 16 17 function dimSomething( what, id, dimClass, obj ) { 18 if ( !obj ) 19 obj = theList; 20 return obj.ajaxDimmer(what,id,dimClass); 21 } 5 22 6 23 var listMan = Class.create(); … … 19 36 dataStore: null, 20 37 formStore: null, 38 39 jumpText: 'Jump to new item', 40 delText: 'Are you sure you want to delete this %s?', 21 41 22 42 initialize: function(theListId) { … … 54 74 showLinkMessage += m; 55 75 else 56 showLinkMessage += "<a href='#" + what + '-' + id + "'> <?php echo js_escape(__('Jump to new item')); ?>";76 showLinkMessage += "<a href='#" + what + '-' + id + "'>" + tempObj.jumpText + "</a>"; 57 77 }); 58 78 if ( tempObj.showLink && showLinkMessage ) … … 128 148 var id = this.topAdder ? this.theList.firstChild.id : this.theList.lastChild.id; 129 149 if ( this.alt ) 130 if ( this.theList.childNodes.length% 2 )150 if ( ( this.theList.childNodes.length + this.altOffset ) % 2 ) 131 151 Element.addClassName($(id),this.alt); 132 152 Fat.fade_element(id); -
trunk/wp-includes/script-loader.php
r4948 r4968 22 22 $this->add( 'autosave', '/wp-includes/js/autosave-js.php', array('prototype', 'sack'), '20070116'); 23 23 $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '20070118'); 24 $this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '20070118'); 24 $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070305'); 25 $this->localize( 'listman', 'listManL10n', array( 26 'jumpText' => __('Jump to new item'), 27 'delText' => __('Are you sure you want to delete this %s?') 28 ) ); 25 29 $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0'); 26 30 $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0'); … … 84 88 $src = apply_filters( 'script_loader_src', $src ); 85 89 echo "<script type='text/javascript' src='$src'></script>\n"; 90 $this->print_scripts_l10n( $handle ); 86 91 } 87 92 $this->printed[] = $handle; … … 90 95 } 91 96 97 function print_scripts_l10n( $handle ) { 98 if ( empty($this->scripts[$handle]->l10n_object) || empty($this->scripts[$handle]->l10n) || !is_array($this->scripts[$handle]->l10n) ) 99 return; 100 101 $object_name = $this->scripts[$handle]->l10n_object; 102 103 echo "<script type='text/javascript'>\n"; 104 echo "/* <![CDATA[ */\n"; 105 echo "\t$object_name = {\n"; 106 $eol = ''; 107 foreach ( $this->scripts[$handle]->l10n as $var => $val ) { 108 echo "$eol\t\t$var: \"" . js_escape( $val ) . '"'; 109 $eol = ",\n"; 110 } 111 echo "\n\t}\n"; 112 echo "/* ]]> */\n"; 113 echo "</script>\n"; 114 } 92 115 93 116 /** … … 141 164 } 142 165 166 /** 167 * Localizes a script 168 * 169 * Localizes only if script has already been added 170 * 171 * @param string handle Script name 172 * @param string object_name Name of JS object to hold l10n info 173 * @param array l10n Array of JS var name => localized string 174 * @return bool Successful localization 175 */ 176 function localize( $handle, $object_name, $l10n ) { 177 if ( !isset($this->scripts[$handle]) ) 178 return false; 179 return $this->scripts[$handle]->localize( $object_name, $l10n ); 180 } 181 143 182 function remove( $handles ) { 144 183 foreach ( (array) $handles as $handle ) … … 183 222 var $deps = array(); 184 223 var $ver = false; 185 var $args = false; 224 var $l10n_object = ''; 225 var $l10n = array(); 186 226 187 227 function _WP_Script() { … … 192 232 $this->ver = false; 193 233 } 234 235 function localize( $object_name, $l10n ) { 236 if ( !$object_name || !is_array($l10n) ) 237 return false; 238 $this->l10n_object = $object_name; 239 $this->l10n = $l10n; 240 return true; 241 } 194 242 } 195 243 … … 228 276 } 229 277 278 /** 279 * Localizes a script 280 * 281 * Localizes only if script has already been added 282 * 283 * @see WP_Script::localize() 284 */ 285 function wp_localize_script( $handle, $object_name, $l10n ) { 286 global $wp_scripts; 287 if ( !is_a($wp_scripts, 'WP_Scripts') ) 288 return false; 289 290 return $wp_scripts->localize( $handle, $object_name, $l10n ); 291 } 292 230 293 function wp_deregister_script( $handle ) { 231 294 global $wp_scripts;
Note: See TracChangeset
for help on using the changeset viewer.