4fb94e682abff3dc5d59ef325285b6c5f44f1fec
[lhc/web/wiklou.git] / skins / common / wikibits.js
1 /**
2 * MediaWiki legacy wikibits
3 */
4 (function(){
5
6 window.clientPC = navigator.userAgent.toLowerCase(); // Get client info
7 window.is_gecko = /gecko/.test( clientPC ) &&
8 !/khtml|spoofer|netscape\/7\.0/.test(clientPC);
9
10 window.is_safari = window.is_safari_win = window.webkit_version =
11 window.is_chrome = window.is_chrome_mac = false;
12 window.webkit_match = clientPC.match(/applewebkit\/(\d+)/);
13 if (webkit_match) {
14 window.is_safari = clientPC.indexOf('applewebkit') != -1 &&
15 clientPC.indexOf('spoofer') == -1;
16 window.is_safari_win = is_safari && clientPC.indexOf('windows') != -1;
17 window.webkit_version = parseInt(webkit_match[1]);
18 // Tests for chrome here, to avoid breaking old scripts safari left alone
19 // This is here for accesskeys
20 window.is_chrome = clientPC.indexOf('chrome') !== -1 &&
21 clientPC.indexOf('spoofer') === -1;
22 window.is_chrome_mac = is_chrome && clientPC.indexOf('mac') !== -1
23 }
24
25 // For accesskeys; note that FF3+ is included here!
26 window.is_ff2 = /firefox\/[2-9]|minefield\/3/.test( clientPC );
27 window.ff2_bugs = /firefox\/2/.test( clientPC );
28 // These aren't used here, but some custom scripts rely on them
29 window.is_ff2_win = is_ff2 && clientPC.indexOf('windows') != -1;
30 window.is_ff2_x11 = is_ff2 && clientPC.indexOf('x11') != -1;
31
32 window.is_opera = window.is_opera_preseven = window.is_opera_95 =
33 window.opera6_bugs = window.opera7_bugs = window.opera95_bugs = false;
34 if (clientPC.indexOf('opera') != -1) {
35 window.is_opera = true;
36 window.is_opera_preseven = window.opera && !document.childNodes;
37 window.is_opera_seven = window.opera && document.childNodes;
38 window.is_opera_95 = /opera\/(9\.[5-9]|[1-9][0-9])/.test( clientPC );
39 window.opera6_bugs = is_opera_preseven;
40 window.opera7_bugs = is_opera_seven && !is_opera_95;
41 window.opera95_bugs = /opera\/(9\.5)/.test( clientPC );
42 }
43 // As recommended by <http://msdn.microsoft.com/en-us/library/ms537509.aspx>,
44 // avoiding false positives from moronic extensions that append to the IE UA
45 // string (bug 23171)
46 window.ie6_bugs = false;
47 if ( /msie ([0-9]{1,}[\.0-9]{0,})/.exec( clientPC ) != null
48 && parseFloat( RegExp.$1 ) <= 6.0 ) {
49 ie6_bugs = true;
50 }
51
52 // Global external objects used by this script.
53 /*extern ta */
54
55 // add any onload functions in this hook (please don't hard-code any events in the xhtml source)
56 window.doneOnloadHook = undefined;
57
58 if (!window.onloadFuncts) {
59 window.onloadFuncts = [];
60 }
61
62 window.addOnloadHook = function( hookFunct ) {
63 // Allows add-on scripts to add onload functions
64 if( !doneOnloadHook ) {
65 onloadFuncts[onloadFuncts.length] = hookFunct;
66 } else {
67 hookFunct(); // bug in MSIE script loading
68 }
69 };
70
71 window.importScript = function( page ) {
72 // TODO: might want to introduce a utility function to match wfUrlencode() in PHP
73 var uri = wgScript + '?title=' +
74 encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
75 '&action=raw&ctype=text/javascript';
76 return importScriptURI( uri );
77 };
78
79 window.loadedScripts = {}; // included-scripts tracker
80 window.importScriptURI = function( url ) {
81 if ( loadedScripts[url] ) {
82 return null;
83 }
84 loadedScripts[url] = true;
85 var s = document.createElement( 'script' );
86 s.setAttribute( 'src', url );
87 s.setAttribute( 'type', 'text/javascript' );
88 document.getElementsByTagName('head')[0].appendChild( s );
89 return s;
90 };
91
92 window.importStylesheet = function( page ) {
93 return importStylesheetURI( wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent( page.replace(/ /g,'_') ) );
94 };
95
96 window.importStylesheetURI = function( url, media ) {
97 var l = document.createElement( 'link' );
98 l.type = 'text/css';
99 l.rel = 'stylesheet';
100 l.href = url;
101 if( media ) {
102 l.media = media;
103 }
104 document.getElementsByTagName('head')[0].appendChild( l );
105 return l;
106 };
107
108 window.appendCSS = function( text ) {
109 var s = document.createElement( 'style' );
110 s.type = 'text/css';
111 s.rel = 'stylesheet';
112 if ( s.styleSheet ) {
113 s.styleSheet.cssText = text; // IE
114 } else {
115 s.appendChild( document.createTextNode( text + '' ) ); // Safari sometimes borks on null
116 }
117 document.getElementsByTagName('head')[0].appendChild( s );
118 return s;
119 };
120
121 // Special stylesheet links for Monobook only (see bug 14717)
122 var skinpath = mw.config.get( 'stylepath' ) + '/' + mw.config.get( 'skin' );
123 if ( mw.config.get( 'skin' ) === 'monobook' ) {
124 if ( opera6_bugs ) {
125 importStylesheetURI( skinpath + '/Opera6Fixes.css' );
126 } else if ( opera7_bugs ) {
127 importStylesheetURI( skinpath + '/Opera7Fixes.css' );
128 } else if ( opera95_bugs ) {
129 importStylesheetURI( skinpath + '/Opera9Fixes.css' );
130 } else if ( ff2_bugs ) {
131 importStylesheetURI( skinpath + '/FF2Fixes.css' );
132 }
133 }
134
135 if ( mw.config.get( 'wgBreakFrames' ) ) {
136 // Un-trap us from framesets
137 if ( window.top != window ) {
138 window.top.location = window.location;
139 }
140 }
141
142 window.changeText = function( el, newText ) {
143 // Safari work around
144 if ( el.innerText ) {
145 el.innerText = newText;
146 } else if ( el.firstChild && el.firstChild.nodeValue ) {
147 el.firstChild.nodeValue = newText;
148 }
149 };
150
151 window.killEvt = function( evt ) {
152 evt = evt || window.event || window.Event; // W3C, IE, Netscape
153 if ( typeof ( evt.preventDefault ) != 'undefined' ) {
154 evt.preventDefault(); // Don't follow the link
155 evt.stopPropagation();
156 } else {
157 evt.cancelBubble = true; // IE
158 }
159 return false; // Don't follow the link (IE)
160 };
161
162 window.mwEditButtons = [];
163 window.mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
164
165 window.escapeQuotes = function( text ) {
166 var re = new RegExp( "'", "g" );
167 text = text.replace( re, "\\'" );
168 re = new RegExp( "\\n", "g" );
169 text = text.replace( re, "\\n" );
170 return escapeQuotesHTML( text );
171 };
172
173 window.escapeQuotesHTML = function( text ) {
174 var re = new RegExp( '&', "g" );
175 text = text.replace( re, "&amp;" );
176 re = new RegExp( '"', "g" );
177 text = text.replace( re, "&quot;" );
178 re = new RegExp( '<', "g" );
179 text = text.replace( re, "&lt;" );
180 re = new RegExp( '>', "g" );
181 text = text.replace( re, "&gt;" );
182 return text;
183 };
184
185 /**
186 * Set the accesskey prefix based on browser detection.
187 */
188 window.tooltipAccessKeyPrefix = 'alt-';
189 if ( is_opera ) {
190 tooltipAccessKeyPrefix = 'shift-esc-';
191 } else if ( is_chrome ) {
192 tooltipAccessKeyPrefix = is_chrome_mac ? 'ctrl-option-' : 'alt-';
193 } else if ( !is_safari_win && is_safari && webkit_version > 526 ) {
194 tooltipAccessKeyPrefix = 'ctrl-alt-';
195 } else if ( !is_safari_win && ( is_safari
196 || clientPC.indexOf('mac') != -1
197 || clientPC.indexOf('konqueror') != -1 ) ) {
198 tooltipAccessKeyPrefix = 'ctrl-';
199 } else if ( is_ff2 ) {
200 tooltipAccessKeyPrefix = 'alt-shift-';
201 }
202 window.tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?(.)\]$/;
203
204 /**
205 * Add the appropriate prefix to the accesskey shown in the tooltip.
206 * If the nodeList parameter is given, only those nodes are updated;
207 * otherwise, all the nodes that will probably have accesskeys by
208 * default are updated.
209 *
210 * @param nodeList Array list of elements to update
211 */
212 window.updateTooltipAccessKeys = function( nodeList ) {
213 if ( !nodeList ) {
214 // Rather than scan all links on the whole page, we can just scan these
215 // containers which contain the relevant links. This is really just an
216 // optimization technique.
217 var linkContainers = [
218 'column-one', // Monobook and Modern
219 'mw-head', 'mw-panel', 'p-logo' // Vector
220 ];
221 for ( var i in linkContainers ) {
222 var linkContainer = document.getElementById( linkContainers[i] );
223 if ( linkContainer ) {
224 updateTooltipAccessKeys( linkContainer.getElementsByTagName( 'a' ) );
225 }
226 }
227 // these are rare enough that no such optimization is needed
228 updateTooltipAccessKeys( document.getElementsByTagName( 'input' ) );
229 updateTooltipAccessKeys( document.getElementsByTagName( 'label' ) );
230 return;
231 }
232
233 for ( var i = 0; i < nodeList.length; i++ ) {
234 var element = nodeList[i];
235 var tip = element.getAttribute( 'title' );
236 if ( tip && tooltipAccessKeyRegexp.exec( tip ) ) {
237 tip = tip.replace(tooltipAccessKeyRegexp,
238 '[' + tooltipAccessKeyPrefix + "$5]");
239 element.setAttribute( 'title', tip );
240 }
241 }
242 };
243
244 /**
245 * Add a link to one of the portlet menus on the page, including:
246 *
247 * p-cactions: Content actions (shown as tabs above the main content in Monobook)
248 * p-personal: Personal tools (shown at the top right of the page in Monobook)
249 * p-navigation: Navigation
250 * p-tb: Toolbox
251 *
252 * This function exists for the convenience of custom JS authors. All
253 * but the first three parameters are optional, though providing at
254 * least an id and a tooltip is recommended.
255 *
256 * By default the new link will be added to the end of the list. To
257 * add the link before a given existing item, pass the DOM node of
258 * that item (easily obtained with document.getElementById()) as the
259 * nextnode parameter; to add the link _after_ an existing item, pass
260 * the node's nextSibling instead.
261 *
262 * @param portlet String id of the target portlet ("p-cactions", "p-personal", "p-navigation" or "p-tb")
263 * @param href String link URL
264 * @param text String link text (will be automatically lowercased by CSS for p-cactions in Monobook)
265 * @param id String id of the new item, should be unique and preferably have the appropriate prefix ("ca-", "pt-", "n-" or "t-")
266 * @param tooltip String text to show when hovering over the link, without accesskey suffix
267 * @param accesskey String accesskey to activate this link (one character, try to avoid conflicts)
268 * @param nextnode Node the DOM node before which the new item should be added, should be another item in the same list
269 *
270 * @return Node -- the DOM node of the new item (an LI element) or null
271 */
272 window.addPortletLink = function( portlet, href, text, id, tooltip, accesskey, nextnode ) {
273 var root = document.getElementById( portlet );
274 if ( !root ) {
275 return null;
276 }
277 var uls = root.getElementsByTagName( 'ul' );
278 var node;
279 if ( uls.length > 0 ) {
280 node = uls[0];
281 } else {
282 node = document.createElement( 'ul' );
283 var lastElementChild = null;
284 for ( var i = 0; i < root.childNodes.length; ++i ) { /* get root.lastElementChild */
285 if ( root.childNodes[i].nodeType == 1 ) {
286 lastElementChild = root.childNodes[i];
287 }
288 }
289 if ( lastElementChild && lastElementChild.nodeName.match( /div/i ) ) {
290 /* Insert into the menu divs */
291 lastElementChild.appendChild( node );
292 } else {
293 root.appendChild( node );
294 }
295 }
296 if ( !node ) {
297 return null;
298 }
299
300 // unhide portlet if it was hidden before
301 root.className = root.className.replace( /(^| )emptyPortlet( |$)/, "$2" );
302
303 var link = document.createElement( 'a' );
304 link.appendChild( document.createTextNode( text ) );
305 link.href = href;
306
307 // Wrap in a span - make it work with vector tabs and has no effect on any other portlets
308 var span = document.createElement( 'span' );
309 span.appendChild( link );
310
311 var item = document.createElement( 'li' );
312 item.appendChild( span );
313 if ( id ) {
314 item.id = id;
315 }
316
317 if ( accesskey ) {
318 link.setAttribute( 'accesskey', accesskey );
319 tooltip += ' [' + accesskey + ']';
320 }
321 if ( tooltip ) {
322 link.setAttribute( 'title', tooltip );
323 }
324 if ( accesskey && tooltip ) {
325 updateTooltipAccessKeys( [link] );
326 }
327
328 if ( nextnode && nextnode.parentNode == node ) {
329 node.insertBefore( item, nextnode );
330 } else {
331 node.appendChild( item ); // IE compatibility (?)
332 }
333
334 return item;
335 };
336
337 window.getInnerText = function( el ) {
338 if ( typeof el == 'string' ) {
339 return el;
340 }
341 if ( typeof el == 'undefined' ) {
342 return el;
343 }
344 // Custom sort value through 'data-sort-value' attribute
345 // (no need to prepend hidden text to change sort value)
346 if ( el.nodeType && el.getAttribute( 'data-sort-value' ) !== null ) {
347 // Make sure it's a valid DOM element (.nodeType) and that the attribute is set (!null)
348 return el.getAttribute( 'data-sort-value' );
349 }
350 if ( el.textContent ) {
351 return el.textContent; // not needed but it is faster
352 }
353 if ( el.innerText ) {
354 return el.innerText; // IE doesn't have textContent
355 }
356 var str = '';
357
358 var cs = el.childNodes;
359 var l = cs.length;
360 for ( var i = 0; i < l; i++ ) {
361 switch ( cs[i].nodeType ) {
362 case 1: // ELEMENT_NODE
363 str += getInnerText( cs[i] );
364 break;
365 case 3: // TEXT_NODE
366 str += cs[i].nodeValue;
367 break;
368 }
369 }
370 return str;
371 };
372
373 window.checkboxes = undefined;
374 window.lastCheckbox = undefined;
375
376 window.setupCheckboxShiftClick = function() {
377 checkboxes = [];
378 lastCheckbox = null;
379 var inputs = document.getElementsByTagName( 'input' );
380 addCheckboxClickHandlers( inputs );
381 };
382
383 window.addCheckboxClickHandlers = function( inputs, start ) {
384 if ( !start ) {
385 start = 0;
386 }
387
388 var finish = start + 250;
389 if ( finish > inputs.length ) {
390 finish = inputs.length;
391 }
392
393 for ( var i = start; i < finish; i++ ) {
394 var cb = inputs[i];
395 if ( !cb.type || cb.type.toLowerCase() != 'checkbox' || ( ' ' + cb.className + ' ' ).indexOf( ' noshiftselect ' ) != -1 ) {
396 continue;
397 }
398 var end = checkboxes.length;
399 checkboxes[end] = cb;
400 cb.index = end;
401 addClickHandler( cb, checkboxClickHandler );
402 }
403
404 if ( finish < inputs.length ) {
405 setTimeout( function() {
406 addCheckboxClickHandlers( inputs, finish );
407 }, 200 );
408 }
409 };
410
411 window.checkboxClickHandler = function( e ) {
412 if ( typeof e == 'undefined' ) {
413 e = window.event;
414 }
415 if ( !e.shiftKey || lastCheckbox === null ) {
416 lastCheckbox = this.index;
417 return true;
418 }
419 var endState = this.checked;
420 var start, finish;
421 if ( this.index < lastCheckbox ) {
422 start = this.index + 1;
423 finish = lastCheckbox;
424 } else {
425 start = lastCheckbox;
426 finish = this.index - 1;
427 }
428 for ( var i = start; i <= finish; ++i ) {
429 checkboxes[i].checked = endState;
430 if( i > start && typeof checkboxes[i].onchange == 'function' ) {
431 checkboxes[i].onchange(); // fire triggers
432 }
433 }
434 lastCheckbox = this.index;
435 return true;
436 };
437
438
439 /*
440 Written by Jonathan Snook, http://www.snook.ca/jonathan
441 Add-ons by Robert Nyman, http://www.robertnyman.com
442 Author says "The credit comment is all it takes, no license. Go crazy with it!:-)"
443 From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
444 */
445 window.getElementsByClassName = function( oElm, strTagName, oClassNames ) {
446 var arrReturnElements = [];
447 if ( typeof( oElm.getElementsByClassName ) == 'function' ) {
448 /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
449 var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
450 if ( strTagName == '*' ) {
451 return arrNativeReturn;
452 }
453 for ( var h = 0; h < arrNativeReturn.length; h++ ) {
454 if( arrNativeReturn[h].tagName.toLowerCase() == strTagName.toLowerCase() ) {
455 arrReturnElements[arrReturnElements.length] = arrNativeReturn[h];
456 }
457 }
458 return arrReturnElements;
459 }
460 var arrElements = ( strTagName == '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName );
461 var arrRegExpClassNames = [];
462 if( typeof oClassNames == 'object' ) {
463 for( var i = 0; i < oClassNames.length; i++ ) {
464 arrRegExpClassNames[arrRegExpClassNames.length] =
465 new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)");
466 }
467 } else {
468 arrRegExpClassNames[arrRegExpClassNames.length] =
469 new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)");
470 }
471 var oElement;
472 var bMatchesAll;
473 for( var j = 0; j < arrElements.length; j++ ) {
474 oElement = arrElements[j];
475 bMatchesAll = true;
476 for( var k = 0; k < arrRegExpClassNames.length; k++ ) {
477 if( !arrRegExpClassNames[k].test( oElement.className ) ) {
478 bMatchesAll = false;
479 break;
480 }
481 }
482 if( bMatchesAll ) {
483 arrReturnElements[arrReturnElements.length] = oElement;
484 }
485 }
486 return ( arrReturnElements );
487 };
488
489 window.redirectToFragment = function( fragment ) {
490 var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
491 if ( match ) {
492 var webKitVersion = parseInt( match[1] );
493 if ( webKitVersion < 420 ) {
494 // Released Safari w/ WebKit 418.9.1 messes up horribly
495 // Nightlies of 420+ are ok
496 return;
497 }
498 }
499 if ( window.location.hash == '' ) {
500 window.location.hash = fragment;
501
502 // Mozilla needs to wait until after load, otherwise the window doesn't
503 // scroll. See <https://bugzilla.mozilla.org/show_bug.cgi?id=516293>.
504 // There's no obvious way to detect this programmatically, so we use
505 // version-testing. If Firefox fixes the bug, they'll jump twice, but
506 // better twice than not at all, so make the fix hit future versions as
507 // well.
508 if ( is_gecko ) {
509 addOnloadHook(function() {
510 if ( window.location.hash == fragment ) {
511 window.location.hash = fragment;
512 }
513 });
514 }
515 }
516 };
517
518 /**
519 * Add a cute little box at the top of the screen to inform the user of
520 * something, replacing any preexisting message.
521 *
522 * @param message String -or- Dom Object HTML to be put inside the right div
523 * @param className String Used in adding a class; should be different for each
524 * call to allow CSS/JS to hide different boxes. null = no class used.
525 * @return Boolean True on success, false on failure
526 */
527 window.jsMsg = function( message, className ) {
528 if ( !document.getElementById ) {
529 return false;
530 }
531 // We special-case skin structures provided by the software. Skins that
532 // choose to abandon or significantly modify our formatting can just define
533 // an mw-js-message div to start with.
534 var messageDiv = document.getElementById( 'mw-js-message' );
535 if ( !messageDiv ) {
536 messageDiv = document.createElement( 'div' );
537 if ( document.getElementById( 'column-content' )
538 && document.getElementById( 'content' ) ) {
539 // MonoBook, presumably
540 document.getElementById( 'content' ).insertBefore(
541 messageDiv,
542 document.getElementById( 'content' ).firstChild
543 );
544 } else if ( document.getElementById( 'content' )
545 && document.getElementById( 'article' ) ) {
546 // Non-Monobook but still recognizable (old-style)
547 document.getElementById( 'article').insertBefore(
548 messageDiv,
549 document.getElementById( 'article' ).firstChild
550 );
551 } else {
552 return false;
553 }
554 }
555
556 messageDiv.setAttribute( 'id', 'mw-js-message' );
557 messageDiv.style.display = 'block';
558 if( className ) {
559 messageDiv.setAttribute( 'class', 'mw-js-message-' + className );
560 }
561
562 if ( typeof message === 'object' ) {
563 while ( messageDiv.hasChildNodes() ) { // Remove old content
564 messageDiv.removeChild( messageDiv.firstChild );
565 }
566 messageDiv.appendChild( message ); // Append new content
567 } else {
568 messageDiv.innerHTML = message;
569 }
570 return true;
571 };
572
573 /**
574 * Inject a cute little progress spinner after the specified element
575 *
576 * @param element Element to inject after
577 * @param id Identifier string (for use with removeSpinner(), below)
578 */
579 window.injectSpinner = function( element, id ) {
580 var spinner = document.createElement( 'img' );
581 spinner.id = 'mw-spinner-' + id;
582 spinner.src = mw.config.get( 'stylepath' ) + '/common/images/spinner.gif';
583 spinner.alt = spinner.title = '...';
584 if( element.nextSibling ) {
585 element.parentNode.insertBefore( spinner, element.nextSibling );
586 } else {
587 element.parentNode.appendChild( spinner );
588 }
589 };
590
591 /**
592 * Remove a progress spinner added with injectSpinner()
593 *
594 * @param id Identifier string
595 */
596 window.removeSpinner = function( id ) {
597 var spinner = document.getElementById( 'mw-spinner-' + id );
598 if( spinner ) {
599 spinner.parentNode.removeChild( spinner );
600 }
601 };
602
603 window.runOnloadHook = function() {
604 // don't run anything below this for non-dom browsers
605 if ( doneOnloadHook || !( document.getElementById && document.getElementsByTagName ) ) {
606 return;
607 }
608
609 // set this before running any hooks, since any errors below
610 // might cause the function to terminate prematurely
611 doneOnloadHook = true;
612
613 // Run any added-on functions
614 for ( var i = 0; i < onloadFuncts.length; i++ ) {
615 onloadFuncts[i]();
616 }
617 };
618
619 /**
620 * Add an event handler to an element
621 *
622 * @param element Element to add handler to
623 * @param attach String Event to attach to
624 * @param handler callable Event handler callback
625 */
626 window.addHandler = function( element, attach, handler ) {
627 if( element.addEventListener ) {
628 element.addEventListener( attach, handler, false );
629 } else if( element.attachEvent ) {
630 element.attachEvent( 'on' + attach, handler );
631 }
632 };
633
634 window.hookEvent = function( hookName, hookFunct ) {
635 addHandler( window, hookName, hookFunct );
636 };
637
638 /**
639 * Add a click event handler to an element
640 *
641 * @param element Element to add handler to
642 * @param handler callable Event handler callback
643 */
644 window.addClickHandler = function( element, handler ) {
645 addHandler( element, 'click', handler );
646 };
647
648 /**
649 * Removes an event handler from an element
650 *
651 * @param element Element to remove handler from
652 * @param remove String Event to remove
653 * @param handler callable Event handler callback to remove
654 */
655 window.removeHandler = function( element, remove, handler ) {
656 if( window.removeEventListener ) {
657 element.removeEventListener( remove, handler, false );
658 } else if( window.detachEvent ) {
659 element.detachEvent( 'on' + remove, handler );
660 }
661 };
662 // note: all skins should call runOnloadHook() at the end of html output,
663 // so the below should be redundant. It's there just in case.
664 hookEvent( 'load', runOnloadHook );
665
666 if ( ie6_bugs ) {
667 importScriptURI( mw.config.get( 'stylepath' ) + '/common/IEFixes.js' );
668 }
669
670 })();