a6ba268b04d2de85004b98f35887ad4414901141
[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 /* Dummy for deprecated function */
374 window.ta = [];
375 window.akeytt = function( doId ) {
376 };
377
378 window.checkboxes = undefined;
379 window.lastCheckbox = undefined;
380
381 window.setupCheckboxShiftClick = function() {
382 checkboxes = [];
383 lastCheckbox = null;
384 var inputs = document.getElementsByTagName( 'input' );
385 addCheckboxClickHandlers( inputs );
386 };
387
388 window.addCheckboxClickHandlers = function( inputs, start ) {
389 if ( !start ) {
390 start = 0;
391 }
392
393 var finish = start + 250;
394 if ( finish > inputs.length ) {
395 finish = inputs.length;
396 }
397
398 for ( var i = start; i < finish; i++ ) {
399 var cb = inputs[i];
400 if ( !cb.type || cb.type.toLowerCase() != 'checkbox' || ( ' ' + cb.className + ' ' ).indexOf( ' noshiftselect ' ) != -1 ) {
401 continue;
402 }
403 var end = checkboxes.length;
404 checkboxes[end] = cb;
405 cb.index = end;
406 addClickHandler( cb, checkboxClickHandler );
407 }
408
409 if ( finish < inputs.length ) {
410 setTimeout( function() {
411 addCheckboxClickHandlers( inputs, finish );
412 }, 200 );
413 }
414 };
415
416 window.checkboxClickHandler = function( e ) {
417 if ( typeof e == 'undefined' ) {
418 e = window.event;
419 }
420 if ( !e.shiftKey || lastCheckbox === null ) {
421 lastCheckbox = this.index;
422 return true;
423 }
424 var endState = this.checked;
425 var start, finish;
426 if ( this.index < lastCheckbox ) {
427 start = this.index + 1;
428 finish = lastCheckbox;
429 } else {
430 start = lastCheckbox;
431 finish = this.index - 1;
432 }
433 for ( var i = start; i <= finish; ++i ) {
434 checkboxes[i].checked = endState;
435 if( i > start && typeof checkboxes[i].onchange == 'function' ) {
436 checkboxes[i].onchange(); // fire triggers
437 }
438 }
439 lastCheckbox = this.index;
440 return true;
441 };
442
443
444 /*
445 Written by Jonathan Snook, http://www.snook.ca/jonathan
446 Add-ons by Robert Nyman, http://www.robertnyman.com
447 Author says "The credit comment is all it takes, no license. Go crazy with it!:-)"
448 From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
449 */
450 window.getElementsByClassName = function( oElm, strTagName, oClassNames ) {
451 var arrReturnElements = [];
452 if ( typeof( oElm.getElementsByClassName ) == 'function' ) {
453 /* Use a native implementation where possible FF3, Saf3.2, Opera 9.5 */
454 var arrNativeReturn = oElm.getElementsByClassName( oClassNames );
455 if ( strTagName == '*' ) {
456 return arrNativeReturn;
457 }
458 for ( var h = 0; h < arrNativeReturn.length; h++ ) {
459 if( arrNativeReturn[h].tagName.toLowerCase() == strTagName.toLowerCase() ) {
460 arrReturnElements[arrReturnElements.length] = arrNativeReturn[h];
461 }
462 }
463 return arrReturnElements;
464 }
465 var arrElements = ( strTagName == '*' && oElm.all ) ? oElm.all : oElm.getElementsByTagName( strTagName );
466 var arrRegExpClassNames = [];
467 if( typeof oClassNames == 'object' ) {
468 for( var i = 0; i < oClassNames.length; i++ ) {
469 arrRegExpClassNames[arrRegExpClassNames.length] =
470 new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)");
471 }
472 } else {
473 arrRegExpClassNames[arrRegExpClassNames.length] =
474 new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)");
475 }
476 var oElement;
477 var bMatchesAll;
478 for( var j = 0; j < arrElements.length; j++ ) {
479 oElement = arrElements[j];
480 bMatchesAll = true;
481 for( var k = 0; k < arrRegExpClassNames.length; k++ ) {
482 if( !arrRegExpClassNames[k].test( oElement.className ) ) {
483 bMatchesAll = false;
484 break;
485 }
486 }
487 if( bMatchesAll ) {
488 arrReturnElements[arrReturnElements.length] = oElement;
489 }
490 }
491 return ( arrReturnElements );
492 };
493
494 window.redirectToFragment = function( fragment ) {
495 var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
496 if ( match ) {
497 var webKitVersion = parseInt( match[1] );
498 if ( webKitVersion < 420 ) {
499 // Released Safari w/ WebKit 418.9.1 messes up horribly
500 // Nightlies of 420+ are ok
501 return;
502 }
503 }
504 if ( window.location.hash == '' ) {
505 window.location.hash = fragment;
506
507 // Mozilla needs to wait until after load, otherwise the window doesn't
508 // scroll. See <https://bugzilla.mozilla.org/show_bug.cgi?id=516293>.
509 // There's no obvious way to detect this programmatically, so we use
510 // version-testing. If Firefox fixes the bug, they'll jump twice, but
511 // better twice than not at all, so make the fix hit future versions as
512 // well.
513 if ( is_gecko ) {
514 addOnloadHook(function() {
515 if ( window.location.hash == fragment ) {
516 window.location.hash = fragment;
517 }
518 });
519 }
520 }
521 };
522
523 /**
524 * Add a cute little box at the top of the screen to inform the user of
525 * something, replacing any preexisting message.
526 *
527 * @param message String -or- Dom Object HTML to be put inside the right div
528 * @param className String Used in adding a class; should be different for each
529 * call to allow CSS/JS to hide different boxes. null = no class used.
530 * @return Boolean True on success, false on failure
531 */
532 window.jsMsg = function( message, className ) {
533 if ( !document.getElementById ) {
534 return false;
535 }
536 // We special-case skin structures provided by the software. Skins that
537 // choose to abandon or significantly modify our formatting can just define
538 // an mw-js-message div to start with.
539 var messageDiv = document.getElementById( 'mw-js-message' );
540 if ( !messageDiv ) {
541 messageDiv = document.createElement( 'div' );
542 if ( document.getElementById( 'column-content' )
543 && document.getElementById( 'content' ) ) {
544 // MonoBook, presumably
545 document.getElementById( 'content' ).insertBefore(
546 messageDiv,
547 document.getElementById( 'content' ).firstChild
548 );
549 } else if ( document.getElementById( 'content' )
550 && document.getElementById( 'article' ) ) {
551 // Non-Monobook but still recognizable (old-style)
552 document.getElementById( 'article').insertBefore(
553 messageDiv,
554 document.getElementById( 'article' ).firstChild
555 );
556 } else {
557 return false;
558 }
559 }
560
561 messageDiv.setAttribute( 'id', 'mw-js-message' );
562 messageDiv.style.display = 'block';
563 if( className ) {
564 messageDiv.setAttribute( 'class', 'mw-js-message-' + className );
565 }
566
567 if ( typeof message === 'object' ) {
568 while ( messageDiv.hasChildNodes() ) { // Remove old content
569 messageDiv.removeChild( messageDiv.firstChild );
570 }
571 messageDiv.appendChild( message ); // Append new content
572 } else {
573 messageDiv.innerHTML = message;
574 }
575 return true;
576 };
577
578 /**
579 * Inject a cute little progress spinner after the specified element
580 *
581 * @param element Element to inject after
582 * @param id Identifier string (for use with removeSpinner(), below)
583 */
584 window.injectSpinner = function( element, id ) {
585 var spinner = document.createElement( 'img' );
586 spinner.id = 'mw-spinner-' + id;
587 spinner.src = mw.config.get( 'stylepath' ) + '/common/images/spinner.gif';
588 spinner.alt = spinner.title = '...';
589 if( element.nextSibling ) {
590 element.parentNode.insertBefore( spinner, element.nextSibling );
591 } else {
592 element.parentNode.appendChild( spinner );
593 }
594 };
595
596 /**
597 * Remove a progress spinner added with injectSpinner()
598 *
599 * @param id Identifier string
600 */
601 window.removeSpinner = function( id ) {
602 var spinner = document.getElementById( 'mw-spinner-' + id );
603 if( spinner ) {
604 spinner.parentNode.removeChild( spinner );
605 }
606 };
607
608 window.runOnloadHook = function() {
609 // don't run anything below this for non-dom browsers
610 if ( doneOnloadHook || !( document.getElementById && document.getElementsByTagName ) ) {
611 return;
612 }
613
614 // set this before running any hooks, since any errors below
615 // might cause the function to terminate prematurely
616 doneOnloadHook = true;
617
618 // Run any added-on functions
619 for ( var i = 0; i < onloadFuncts.length; i++ ) {
620 onloadFuncts[i]();
621 }
622 };
623
624 /**
625 * Add an event handler to an element
626 *
627 * @param element Element to add handler to
628 * @param attach String Event to attach to
629 * @param handler callable Event handler callback
630 */
631 window.addHandler = function( element, attach, handler ) {
632 if( element.addEventListener ) {
633 element.addEventListener( attach, handler, false );
634 } else if( element.attachEvent ) {
635 element.attachEvent( 'on' + attach, handler );
636 }
637 };
638
639 window.hookEvent = function( hookName, hookFunct ) {
640 addHandler( window, hookName, hookFunct );
641 };
642
643 /**
644 * Add a click event handler to an element
645 *
646 * @param element Element to add handler to
647 * @param handler callable Event handler callback
648 */
649 window.addClickHandler = function( element, handler ) {
650 addHandler( element, 'click', handler );
651 };
652
653 /**
654 * Removes an event handler from an element
655 *
656 * @param element Element to remove handler from
657 * @param remove String Event to remove
658 * @param handler callable Event handler callback to remove
659 */
660 window.removeHandler = function( element, remove, handler ) {
661 if( window.removeEventListener ) {
662 element.removeEventListener( remove, handler, false );
663 } else if( window.detachEvent ) {
664 element.detachEvent( 'on' + remove, handler );
665 }
666 };
667 // note: all skins should call runOnloadHook() at the end of html output,
668 // so the below should be redundant. It's there just in case.
669 hookEvent( 'load', runOnloadHook );
670
671 if ( ie6_bugs ) {
672 importScriptURI( mw.config.get( 'stylepath' ) + '/common/IEFixes.js' );
673 }
674
675 })();