2 * MediaWiki legacy wikibits
7 ua
= navigator
.userAgent
.toLowerCase(),
8 isIE6
= ( /msie ([0-9]{1,}[\.0-9]{0,})/.exec( ua
) && parseFloat( RegExp
.$1 ) <= 6.0 ),
9 isGecko
= /gecko/.test( ua
) && !/khtml|spoofer|netscape\/7\.0/.test( ua
),
12 if ( mw
.config
.get( 'wgBreakFrames' ) ) {
13 // Note: In IE < 9 strict comparison to window is non-standard (the standard didn't exist yet)
14 // it works only comparing to window.self or window.window (http://stackoverflow.com/q/4850978/319266)
15 if ( win
.top
!== win
.self
) {
16 // Un-trap us from framesets
17 win
.top
.location
= win
.location
;
22 * Legacy function to scroll to an id while viewing the page over a redirect.
23 * Superseeded by module 'mediawiki.action.view.redirectToFragment' in version 1.23.
24 * Kepted because cache can contain still inline script calls to this function.
25 * Should be removed in version 1.24.
26 * @deprecated since 1.23 Use mediawiki.action.view.redirectToFragment instead
28 mw
.log
.deprecate( win
, 'redirectToFragment', function ( fragment
) {
30 match
= navigator
.userAgent
.match( /AppleWebKit\/(\d+)/ );
32 webKitVersion
= parseInt( match
[1], 10 );
33 if ( webKitVersion
< 420 ) {
34 // Released Safari w/ WebKit 418.9.1 messes up horribly
35 // Nightlies of 420+ are ok
39 if ( !win
.location
.hash
) {
40 win
.location
.hash
= fragment
;
42 // Mozilla needs to wait until after load, otherwise the window doesn't
43 // scroll. See <https://bugzilla.mozilla.org/show_bug.cgi?id=516293>.
44 // There's no obvious way to detect this programmatically, so we use
45 // version-testing. If Firefox fixes the bug, they'll jump twice, but
46 // better twice than not at all, so make the fix hit future versions as
50 if ( win
.location
.hash
=== fragment
) {
51 win
.location
.hash
= fragment
;
56 }, 'Use the module mediawiki.action.view.redirectToFragment instead.' );
59 * User-agent sniffing.
60 * To be removed in MediaWiki 1.23.
62 * @deprecated since 1.17 Use jquery.client instead
65 msg
= 'Use feature detection or module jquery.client instead';
67 mw
.log
.deprecate( win
, 'clientPC', ua
, msg
);
69 // Ignored dummy values
70 mw
.log
.deprecate( win
, 'is_gecko', false, msg
);
71 mw
.log
.deprecate( win
, 'is_chrome_mac', false, msg
);
72 mw
.log
.deprecate( win
, 'is_chrome', false, msg
);
73 mw
.log
.deprecate( win
, 'webkit_version', false, msg
);
74 mw
.log
.deprecate( win
, 'is_safari_win', false, msg
);
75 mw
.log
.deprecate( win
, 'is_safari', false, msg
);
76 mw
.log
.deprecate( win
, 'webkit_match', false, msg
);
77 mw
.log
.deprecate( win
, 'is_ff2', false, msg
);
78 mw
.log
.deprecate( win
, 'ff2_bugs', false, msg
);
79 mw
.log
.deprecate( win
, 'is_ff2_win', false, msg
);
80 mw
.log
.deprecate( win
, 'is_ff2_x11', false, msg
);
81 mw
.log
.deprecate( win
, 'opera95_bugs', false, msg
);
82 mw
.log
.deprecate( win
, 'opera7_bugs', false, msg
);
83 mw
.log
.deprecate( win
, 'opera6_bugs', false, msg
);
84 mw
.log
.deprecate( win
, 'is_opera_95', false, msg
);
85 mw
.log
.deprecate( win
, 'is_opera_preseven', false, msg
);
86 mw
.log
.deprecate( win
, 'is_opera', false, msg
);
87 mw
.log
.deprecate( win
, 'ie6_bugs', false, msg
);
90 * DOM utilities for handling of events, text nodes and selecting elements
92 * To be removed in MediaWiki 1.23.
94 * @deprecated since 1.17 Use jQuery instead
96 msg
= 'Use jQuery instead';
98 // Ignored dummy values
99 mw
.log
.deprecate( win
, 'doneOnloadHook', undefined, msg
);
100 mw
.log
.deprecate( win
, 'onloadFuncts', [], msg
);
101 mw
.log
.deprecate( win
, 'runOnloadHook', $.noop
, msg
);
102 mw
.log
.deprecate( win
, 'changeText', $.noop
, msg
);
103 mw
.log
.deprecate( win
, 'killEvt', $.noop
, msg
);
104 mw
.log
.deprecate( win
, 'addHandler', $.noop
, msg
);
105 mw
.log
.deprecate( win
, 'hookEvent', $.noop
, msg
);
106 mw
.log
.deprecate( win
, 'addClickHandler', $.noop
, msg
);
107 mw
.log
.deprecate( win
, 'removeHandler', $.noop
, msg
);
108 mw
.log
.deprecate( win
, 'getElementsByClassName', function () { return []; }, msg
);
109 mw
.log
.deprecate( win
, 'getInnerText', function () { return ''; }, msg
);
111 // Run a function after the window onload event is fired
112 mw
.log
.deprecate( win
, 'addOnloadHook', function ( hookFunct
) {
113 if ( onloadFuncts
) {
114 onloadFuncts
.push(hookFunct
);
116 // If func queue is gone the event has happened already,
117 // run immediately instead of queueing.
122 $( win
).on( 'load', function () {
126 if ( !onloadFuncts
) {
130 // Deference and clear onloadFuncts before running any
131 // hooks to make sure we don't miss any addOnloadHook
133 functs
= onloadFuncts
.slice();
134 onloadFuncts
= undefined;
136 // Execute the queued functions
137 for ( i
= 0; i
< functs
.length
; i
++ ) {
143 * Toggle checkboxes with shift selection
145 * To be removed in MediaWiki 1.23.
147 * @deprecated since 1.17 Use jquery.checkboxShiftClick instead
149 msg
= 'Use jquery.checkboxShiftClick instead';
150 mw
.log
.deprecate( win
, 'checkboxes', [], msg
);
151 mw
.log
.deprecate( win
, 'lastCheckbox', null, msg
);
152 mw
.log
.deprecate( win
, 'setupCheckboxShiftClick', $.noop
, msg
);
153 mw
.log
.deprecate( win
, 'addCheckboxClickHandlers', $.noop
, msg
);
154 mw
.log
.deprecate( win
, 'checkboxClickHandler', $.noop
, msg
);
157 * Add a button to the default editor toolbar
159 * To be removed in MediaWiki 1.23.
161 * @deprecated since 1.17 Use mw.toolbar instead
163 mw
.log
.deprecate( win
, 'mwEditButtons', [], 'Use mw.toolbar instead' );
164 mw
.log
.deprecate( win
, 'mwCustomEditButtons', [], 'Use mw.toolbar instead' );
167 * Spinner creation, injection and removal
169 * To be removed in MediaWiki 1.23.
171 * @deprecated since 1.18 Use jquery.spinner instead
173 mw
.log
.deprecate( win
, 'injectSpinner', $.noop
, 'Use jquery.spinner instead' );
174 mw
.log
.deprecate( win
, 'removeSpinner', $.noop
, 'Use jquery.spinner instead' );
179 * To be removed in MediaWiki 1.23.
181 * @deprecated since 1.18 Use mw.html instead
183 mw
.log
.deprecate( win
, 'escapeQuotes', $.noop
,'Use mw.html instead' );
184 mw
.log
.deprecate( win
, 'escapeQuotesHTML', $.noop
,'Use mw.html instead' );
187 * Display a message to the user
189 * To be removed in MediaWiki 1.23.
191 * @deprecated since 1.17 Use mediawiki.notify instead
192 * @param {string|HTMLElement} message To be put inside the message box
194 mw
.log
.deprecate( win
, 'jsMsg', mw
.util
.jsMessage
, 'Use mediawiki.notify instead' );
199 * To be removed in MediaWiki 1.23.
201 * @deprecated since 1.17 Use mediawiki.util instead
203 msg
= 'Use mediawiki.util instead';
204 mw
.log
.deprecate( win
, 'tooltipAccessKeyPrefix', 'alt-', msg
);
205 mw
.log
.deprecate( win
, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg
);
206 mw
.log
.deprecate( win
, 'updateTooltipAccessKeys', mw
.util
.updateTooltipAccessKeys
, msg
);
207 mw
.log
.deprecate( win
, 'addPortletLink', mw
.util
.addPortletLink
, msg
);
208 mw
.log
.deprecate( win
, 'appendCSS', mw
.util
.addCSS
, msg
);
211 * Wikipage import methods
214 // included-scripts tracker
215 win
.loadedScripts
= {};
217 win
.importScript = function ( page
) {
218 var uri
= mw
.config
.get( 'wgScript' ) + '?title=' +
219 mw
.util
.wikiUrlencode( page
) +
220 '&action=raw&ctype=text/javascript';
221 return win
.importScriptURI( uri
);
224 win
.importScriptURI = function ( url
) {
225 if ( win
.loadedScripts
[url
] ) {
228 win
.loadedScripts
[url
] = true;
229 var s
= document
.createElement( 'script' );
230 s
.setAttribute( 'src', url
);
231 s
.setAttribute( 'type', 'text/javascript' );
232 document
.getElementsByTagName( 'head' )[0].appendChild( s
);
236 win
.importStylesheet = function ( page
) {
237 var uri
= mw
.config
.get( 'wgScript' ) + '?title=' +
238 mw
.util
.wikiUrlencode( page
) +
239 '&action=raw&ctype=text/css';
240 return win
.importStylesheetURI( uri
);
243 win
.importStylesheetURI = function( url
, media
) {
244 var l
= document
.createElement( 'link' );
245 l
.rel
= 'stylesheet';
250 document
.getElementsByTagName('head')[0].appendChild( l
);
255 win
.importScriptURI( mw
.config
.get( 'stylepath' ) + '/common/IEFixes.js' );
258 }( mediaWiki
, jQuery
) );