diff options
Diffstat (limited to 'www/wiki/extensions/Translate/resources/js/ext.translate.hooks.js')
-rw-r--r-- | www/wiki/extensions/Translate/resources/js/ext.translate.hooks.js | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/www/wiki/extensions/Translate/resources/js/ext.translate.hooks.js b/www/wiki/extensions/Translate/resources/js/ext.translate.hooks.js index 7b2628fa..a227b304 100644 --- a/www/wiki/extensions/Translate/resources/js/ext.translate.hooks.js +++ b/www/wiki/extensions/Translate/resources/js/ext.translate.hooks.js @@ -3,36 +3,35 @@ * yet have one. See hooks.txt in Translate directory for how to use hooks. * * @author Harry Burt - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @since 2012-08-22 */ -( function ( mw ) { +( function () { 'use strict'; - var registry = {}; - mw.translateHooks = { add: function ( name, func ) { - if ( !registry[ name ] ) { - registry[ name ] = []; - } - registry[ name ].push( func ); + showDeprecationWarning(); + + mw.hook( name ).add( func ); }, run: function ( /* infinite list of parameters */ ) { - var args, name, length, i; + var args, name; + + showDeprecationWarning(); args = Array.prototype.slice.call( arguments ); name = args.shift(); - if ( registry[ name ] ) { - length = registry[ name ].length; - - for ( i = 0; i < length; i++ ) { - registry[ name ][ i ].apply( null, args ); - } - } + mw.hook( name ).fire( args ); } }; -}( mediaWiki ) ); + + function showDeprecationWarning() { + mw.log.warn( '`mw.translateHooks` has been deprecated and will be removed in the ' + + 'future. Use `mw.hook` instead. See - ' + + 'https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.hook' ); + } +}() ); |