2 * MediaWiki legacy wikibits
7 ua
= navigator
.userAgent
.toLowerCase(),
12 * User-agent sniffing.
14 * @deprecated since 1.17 Use jquery.client instead
17 msg
= 'Use feature detection or module jquery.client instead.';
19 mw
.log
.deprecate( win
, 'clientPC', ua
, msg
);
21 // Ignored dummy values
22 mw
.log
.deprecate( win
, 'is_gecko', false, msg
);
23 mw
.log
.deprecate( win
, 'is_chrome_mac', false, msg
);
24 mw
.log
.deprecate( win
, 'is_chrome', false, msg
);
25 mw
.log
.deprecate( win
, 'webkit_version', false, msg
);
26 mw
.log
.deprecate( win
, 'is_safari_win', false, msg
);
27 mw
.log
.deprecate( win
, 'is_safari', false, msg
);
28 mw
.log
.deprecate( win
, 'webkit_match', false, msg
);
29 mw
.log
.deprecate( win
, 'is_ff2', false, msg
);
30 mw
.log
.deprecate( win
, 'ff2_bugs', false, msg
);
31 mw
.log
.deprecate( win
, 'is_ff2_win', false, msg
);
32 mw
.log
.deprecate( win
, 'is_ff2_x11', false, msg
);
33 mw
.log
.deprecate( win
, 'opera95_bugs', false, msg
);
34 mw
.log
.deprecate( win
, 'opera7_bugs', false, msg
);
35 mw
.log
.deprecate( win
, 'opera6_bugs', false, msg
);
36 mw
.log
.deprecate( win
, 'is_opera_95', false, msg
);
37 mw
.log
.deprecate( win
, 'is_opera_preseven', false, msg
);
38 mw
.log
.deprecate( win
, 'is_opera', false, msg
);
39 mw
.log
.deprecate( win
, 'ie6_bugs', false, msg
);
42 * DOM utilities for handling of events, text nodes and selecting elements
44 * @deprecated since 1.17 Use jQuery instead
46 msg
= 'Use jQuery instead.';
48 // Ignored dummy values
49 mw
.log
.deprecate( win
, 'doneOnloadHook', undefined, msg
);
50 mw
.log
.deprecate( win
, 'onloadFuncts', [], msg
);
51 mw
.log
.deprecate( win
, 'runOnloadHook', $.noop
, msg
);
52 mw
.log
.deprecate( win
, 'changeText', $.noop
, msg
);
53 mw
.log
.deprecate( win
, 'killEvt', $.noop
, msg
);
54 mw
.log
.deprecate( win
, 'addHandler', $.noop
, msg
);
55 mw
.log
.deprecate( win
, 'hookEvent', $.noop
, msg
);
56 mw
.log
.deprecate( win
, 'addClickHandler', $.noop
, msg
);
57 mw
.log
.deprecate( win
, 'removeHandler', $.noop
, msg
);
58 mw
.log
.deprecate( win
, 'getElementsByClassName', function () { return []; }, msg
);
59 mw
.log
.deprecate( win
, 'getInnerText', function () { return ''; }, msg
);
61 // Run a function after the window onload event is fired
62 mw
.log
.deprecate( win
, 'addOnloadHook', function ( hookFunct
) {
64 onloadFuncts
.push( hookFunct
);
66 // If func queue is gone the event has happened already,
67 // run immediately instead of queueing.
72 $( win
).on( 'load', function () {
76 if ( !onloadFuncts
) {
80 // Deference and clear onloadFuncts before running any
81 // hooks to make sure we don't miss any addOnloadHook
83 functs
= onloadFuncts
.slice();
84 onloadFuncts
= undefined;
86 // Execute the queued functions
87 for ( i
= 0; i
< functs
.length
; i
++ ) {
93 * Toggle checkboxes with shift selection
95 * @deprecated since 1.17 Use jquery.checkboxShiftClick instead
97 msg
= 'Use jquery.checkboxShiftClick instead.';
98 mw
.log
.deprecate( win
, 'checkboxes', [], msg
);
99 mw
.log
.deprecate( win
, 'lastCheckbox', null, msg
);
100 mw
.log
.deprecate( win
, 'setupCheckboxShiftClick', $.noop
, msg
);
101 mw
.log
.deprecate( win
, 'addCheckboxClickHandlers', $.noop
, msg
);
102 mw
.log
.deprecate( win
, 'checkboxClickHandler', $.noop
, msg
);
105 * Add a button to the default editor toolbar
107 * @deprecated since 1.17 Use mw.toolbar instead
109 mw
.log
.deprecate( win
, 'mwEditButtons', [], 'Use mw.toolbar instead.' );
110 mw
.log
.deprecate( win
, 'mwCustomEditButtons', [], 'Use mw.toolbar instead.' );
113 * Spinner creation, injection and removal
115 * @deprecated since 1.18 Use jquery.spinner instead
117 mw
.log
.deprecate( win
, 'injectSpinner', $.noop
, 'Use jquery.spinner instead.' );
118 mw
.log
.deprecate( win
, 'removeSpinner', $.noop
, 'Use jquery.spinner instead.' );
123 * @deprecated since 1.18 Use mw.html instead
125 mw
.log
.deprecate( win
, 'escapeQuotes', $.noop
, 'Use mw.html instead.' );
126 mw
.log
.deprecate( win
, 'escapeQuotesHTML', $.noop
, 'Use mw.html instead.' );
129 * Display a message to the user
131 * @deprecated since 1.17 Use mediawiki.notify instead
132 * @param {string|HTMLElement} message To be put inside the message box
134 mw
.log
.deprecate( win
, 'jsMsg', function ( message
) {
135 if ( !arguments
.length
|| message
=== '' || message
=== null ) {
138 if ( typeof message
!== 'object' ) {
139 message
= $.parseHTML( message
);
141 mw
.notify( message
, { autoHide
: true, tag
: 'legacy' } );
143 }, 'Use mediawiki.notify instead.' );
148 * @deprecated since 1.17 Use mediawiki.util or jquery.accessKeyLabel instead
150 msg
= 'Use mediawiki.util instead.';
151 mw
.log
.deprecate( win
, 'addPortletLink', mw
.util
.addPortletLink
, msg
);
152 mw
.log
.deprecate( win
, 'appendCSS', mw
.util
.addCSS
, msg
);
153 msg
= 'Use jquery.accessKeyLabel instead.';
154 mw
.log
.deprecate( win
, 'tooltipAccessKeyPrefix', 'alt-', msg
);
155 mw
.log
.deprecate( win
, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg
);
156 // mw.util.updateTooltipAccessKeys already generates a deprecation message.
157 win
.updateTooltipAccessKeys = function () {
158 return mw
.util
.updateTooltipAccessKeys
.apply( null, arguments
);
162 * Wikipage import methods
164 * See https://www.mediawiki.org/wiki/ResourceLoader/Legacy_JavaScript#wikibits.js
168 * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
169 * @param {string} url
170 * @return {HTMLElement} Script tag
172 function importScriptURI( url
) {
174 if ( loadedScripts
[ url
] ) {
177 loadedScripts
[ url
] = true;
178 s
= document
.createElement( 'script' );
179 s
.setAttribute( 'src', url
);
180 document
.getElementsByTagName( 'head' )[ 0 ].appendChild( s
);
184 function importScript( page
) {
185 var uri
= mw
.config
.get( 'wgScript' ) + '?title=' +
186 mw
.util
.wikiUrlencode( page
) +
187 '&action=raw&ctype=text/javascript';
188 return importScriptURI( uri
);
192 * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
193 * @param {string} url
194 * @param {string} media
195 * @return {HTMLElement} Link tag
197 function importStylesheetURI( url
, media
) {
198 var l
= document
.createElement( 'link' );
199 l
.rel
= 'stylesheet';
204 document
.getElementsByTagName( 'head' )[ 0 ].appendChild( l
);
208 function importStylesheet( page
) {
209 var uri
= mw
.config
.get( 'wgScript' ) + '?title=' +
210 mw
.util
.wikiUrlencode( page
) +
211 '&action=raw&ctype=text/css';
212 return importStylesheetURI( uri
);
215 msg
= 'Use mw.loader instead.';
216 mw
.log
.deprecate( win
, 'loadedScripts', loadedScripts
, msg
);
217 mw
.log
.deprecate( win
, 'importScriptURI', importScriptURI
, msg
);
218 mw
.log
.deprecate( win
, 'importStylesheetURI', importStylesheetURI
, msg
);
219 // Not quite deprecated yet.
220 win
.importScript
= importScript
;
221 win
.importStylesheet
= importStylesheet
;
223 // Replace document.write/writeln with basic html parsing that appends
224 // to the <body> to avoid blanking pages. Added JavaScript will not run.
225 $.each( [ 'write', 'writeln' ], function ( idx
, method
) {
226 mw
.log
.deprecate( document
, method
, function () {
227 $( 'body' ).append( $.parseHTML( Array
.prototype.join
.call( arguments
, '' ) ) );
228 }, 'Use jQuery or mw.loader.load instead.' );
231 }( mediaWiki
, jQuery
) );