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;
21 win.redirectToFragment = function ( fragment ) {
23 match = navigator.userAgent.match( /AppleWebKit\/(\d+)/ );
25 webKitVersion = parseInt( match[1], 10 );
26 if ( webKitVersion < 420 ) {
27 // Released Safari w/ WebKit 418.9.1 messes up horribly
28 // Nightlies of 420+ are ok
32 if ( !win.location.hash ) {
33 win.location.hash = fragment;
35 // Mozilla needs to wait until after load, otherwise the window doesn't
36 // scroll. See <https://bugzilla.mozilla.org/show_bug.cgi?id=516293>.
37 // There's no obvious way to detect this programmatically, so we use
38 // version-testing. If Firefox fixes the bug, they'll jump twice, but
39 // better twice than not at all, so make the fix hit future versions as
43 if ( win.location.hash === fragment ) {
44 win.location.hash = fragment;
52 * User-agent sniffing.
53 * To be removed in MediaWiki 1.23.
55 * @deprecated since 1.17 Use jquery.client instead
58 msg = 'Use feature detection or module jquery.client instead';
60 mw.log.deprecate( win, 'clientPC', ua, msg );
62 // Ignored dummy values
63 mw.log.deprecate( win, 'is_gecko', false, msg );
64 mw.log.deprecate( win, 'is_chrome_mac', false, msg );
65 mw.log.deprecate( win, 'is_chrome', false, msg );
66 mw.log.deprecate( win, 'webkit_version', false, msg );
67 mw.log.deprecate( win, 'is_safari_win', false, msg );
68 mw.log.deprecate( win, 'is_safari', false, msg );
69 mw.log.deprecate( win, 'webkit_match', false, msg );
70 mw.log.deprecate( win, 'is_ff2', false, msg );
71 mw.log.deprecate( win, 'ff2_bugs', false, msg );
72 mw.log.deprecate( win, 'is_ff2_win', false, msg );
73 mw.log.deprecate( win, 'is_ff2_x11', false, msg );
74 mw.log.deprecate( win, 'opera95_bugs', false, msg );
75 mw.log.deprecate( win, 'opera7_bugs', false, msg );
76 mw.log.deprecate( win, 'opera6_bugs', false, msg );
77 mw.log.deprecate( win, 'is_opera_95', false, msg );
78 mw.log.deprecate( win, 'is_opera_preseven', false, msg );
79 mw.log.deprecate( win, 'is_opera', false, msg );
80 mw.log.deprecate( win, 'ie6_bugs', false, msg );
83 * DOM utilities for handling of events, text nodes and selecting elements
85 * To be removed in MediaWiki 1.23.
87 * @deprecated since 1.17 Use jQuery instead
89 msg = 'Use jQuery instead';
91 // Ignored dummy values
92 mw.log.deprecate( win, 'doneOnloadHook', undefined, msg );
93 mw.log.deprecate( win, 'onloadFuncts', [], msg );
94 mw.log.deprecate( win, 'runOnloadHook', $.noop, msg );
95 mw.log.deprecate( win, 'changeText', $.noop, msg );
96 mw.log.deprecate( win, 'killEvt', $.noop, msg );
97 mw.log.deprecate( win, 'addHandler', $.noop, msg );
98 mw.log.deprecate( win, 'hookEvent', $.noop, msg );
99 mw.log.deprecate( win, 'addClickHandler', $.noop, msg );
100 mw.log.deprecate( win, 'removeHandler', $.noop, msg );
101 mw.log.deprecate( win, 'getElementsByClassName', function () { return []; }, msg );
102 mw.log.deprecate( win, 'getInnerText', function () { return ''; }, msg );
104 // Run a function after the window onload event is fired
105 mw.log.deprecate( win, 'addOnloadHook', function ( hookFunct ) {
106 if ( onloadFuncts ) {
107 onloadFuncts.push(hookFunct);
109 // If func queue is gone the event has happened already,
110 // run immediately instead of queueing.
115 $( win ).on( 'load', function () {
119 if ( !onloadFuncts ) {
123 // Deference and clear onloadFuncts before running any
124 // hooks to make sure we don't miss any addOnloadHook
126 functs = onloadFuncts.slice();
127 onloadFuncts = undefined;
129 // Execute the queued functions
130 for ( i = 0; i < functs.length; i++ ) {
136 * Toggle checkboxes with shift selection
138 * To be removed in MediaWiki 1.23.
140 * @deprecated since 1.17 Use jquery.checkboxShiftClick instead
142 msg = 'Use jquery.checkboxShiftClick instead';
143 mw.log.deprecate( win, 'checkboxes', [], msg );
144 mw.log.deprecate( win, 'lastCheckbox', null, msg );
145 mw.log.deprecate( win, 'setupCheckboxShiftClick', $.noop, msg );
146 mw.log.deprecate( win, 'addCheckboxClickHandlers', $.noop, msg );
147 mw.log.deprecate( win, 'checkboxClickHandler', $.noop, msg );
150 * Add a button to the default editor toolbar
152 * To be removed in MediaWiki 1.23.
154 * @deprecated since 1.17 Use mw.toolbar instead
156 mw.log.deprecate( win, 'mwEditButtons', [], 'Use mw.toolbar instead' );
157 mw.log.deprecate( win, 'mwCustomEditButtons', [], 'Use mw.toolbar instead' );
160 * Spinner creation, injection and removal
162 * To be removed in MediaWiki 1.23.
164 * @deprecated since 1.18 Use jquery.spinner instead
166 mw.log.deprecate( win, 'injectSpinner', $.noop, 'Use jquery.spinner instead' );
167 mw.log.deprecate( win, 'removeSpinner', $.noop, 'Use jquery.spinner instead' );
172 * To be removed in MediaWiki 1.23.
174 * @deprecated since 1.18 Use mw.html instead
176 mw.log.deprecate( win, 'escapeQuotes', $.noop,'Use mw.html instead' );
177 mw.log.deprecate( win, 'escapeQuotesHTML', $.noop,'Use mw.html instead' );
180 * Display a message to the user
182 * To be removed in MediaWiki 1.23.
184 * @deprecated since 1.17 Use mediawiki.notify instead
185 * @param {string|HTMLElement} message To be put inside the message box
187 mw.log.deprecate( win, 'jsMsg', mw.util.jsMessage, 'Use mediawiki.notify instead' );
192 * To be removed in MediaWiki 1.23.
194 * @deprecated since 1.17 Use mediawiki.util instead
196 msg = 'Use mediawiki.util instead';
197 mw.log.deprecate( win, 'tooltipAccessKeyPrefix', 'alt-', msg );
198 mw.log.deprecate( win, 'tooltipAccessKeyRegexp', /\[(alt-)?(.)\]$/, msg );
199 mw.log.deprecate( win, 'updateTooltipAccessKeys', mw.util.updateTooltipAccessKeys, msg );
200 mw.log.deprecate( win, 'addPortletLink', mw.util.addPortletLink, msg );
201 mw.log.deprecate( win, 'appendCSS', mw.util.addCSS, msg );
204 * Wikipage import methods
207 // included-scripts tracker
208 win.loadedScripts = {};
210 win.importScript = function ( page ) {
211 var uri = mw.config.get( 'wgScript' ) + '?title=' +
212 mw.util.wikiUrlencode( page ) +
213 '&action=raw&ctype=text/javascript';
214 return win.importScriptURI( uri );
217 win.importScriptURI = function ( url ) {
218 if ( win.loadedScripts[url] ) {
221 win.loadedScripts[url] = true;
222 var s = document.createElement( 'script' );
223 s.setAttribute( 'src', url );
224 s.setAttribute( 'type', 'text/javascript' );
225 document.getElementsByTagName( 'head' )[0].appendChild( s );
229 win.importStylesheet = function( page ) {
230 return win.importStylesheetURI( mw.config.get( 'wgScript' ) + '?action=raw&ctype=text/css&title=' + mw.util.wikiUrlencode( page ) );
233 win.importStylesheetURI = function( url, media ) {
234 var l = document.createElement( 'link' );
235 l.rel = 'stylesheet';
240 document.getElementsByTagName('head')[0].appendChild( l );
245 win.importScriptURI( mw.config.get( 'stylepath' ) + '/common/IEFixes.js' );
248 }( mediaWiki, jQuery ) );