a05a054c76047bce27b62c6a28aa1fcd5346597b
[lhc/web/wiklou.git] / resources / src / mediawiki.page / mediawiki.page.ready.js
1 ( function ( mw, $ ) {
2 var supportsPlaceholder = 'placeholder' in document.createElement( 'input' );
3
4 // Break out of framesets
5 if ( mw.config.get( 'wgBreakFrames' ) ) {
6 // Note: In IE < 9 strict comparison to window is non-standard (the standard didn't exist yet)
7 // it works only comparing to window.self or window.window (http://stackoverflow.com/q/4850978/319266)
8 if ( window.top !== window.self ) {
9 // Un-trap us from framesets
10 window.top.location = window.location;
11 }
12 }
13
14 mw.hook( 'wikipage.content' ).add( function ( $content ) {
15 var $sortableTables;
16
17 // Run jquery.placeholder polyfill if placeholder is not supported
18 if ( !supportsPlaceholder ) {
19 $content.find( 'input[placeholder]' ).placeholder();
20 }
21
22 // Run jquery.makeCollapsible
23 $content.find( '.mw-collapsible' ).makeCollapsible();
24
25 // Lazy load jquery.tablesorter
26 $sortableTables = $content.find( 'table.sortable' );
27 if ( $sortableTables.length ) {
28 mw.loader.using( 'jquery.tablesorter', function () {
29 $sortableTables.tablesorter();
30 } );
31 }
32
33 // Run jquery.checkboxShiftClick
34 $content.find( 'input[type="checkbox"]:not(.noshiftselect)' ).checkboxShiftClick();
35 } );
36
37 // Things outside the wikipage content
38 $( function () {
39
40 if ( !supportsPlaceholder ) {
41 // Exclude content to avoid hitting it twice for the (first) wikipage content
42 $( 'input[placeholder]' ).not( '#mw-content-text input' ).placeholder();
43 }
44
45 // Add accesskey hints to the tooltips
46 mw.util.updateTooltipAccessKeys();
47
48 } );
49
50 }( mediaWiki, jQuery ) );