summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/resources/js/ext.translate.hooks.js
blob: a227b3047c6ed3ad57fbc4887bbcaf945f760118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*!
 * JavaScript hook framework for Translate (since MediaWiki code doesn't
 * yet have one. See hooks.txt in Translate directory for how to use hooks.
 *
 * @author Harry Burt
 * @license GPL-2.0-or-later
 * @since 2012-08-22
 */

( function () {
	'use strict';

	mw.translateHooks = {
		add: function ( name, func ) {
			showDeprecationWarning();

			mw.hook( name ).add( func );
		},

		run: function ( /* infinite list of parameters */ ) {
			var args, name;

			showDeprecationWarning();

			args = Array.prototype.slice.call( arguments );
			name = args.shift();

			mw.hook( name ).fire( args );
		}
	};

	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' );
	}
}() );