Merge "Update OOjs UI to v0.20.0"
[lhc/web/wiklou.git] / resources / src / 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.href = location.href;
11 }
12 }
13
14 mw.hook( 'wikipage.content' ).add( function ( $content ) {
15 var $sortable, $collapsible;
16
17 // Run jquery.placeholder polyfill if placeholder is not supported
18 if ( !supportsPlaceholder ) {
19 $content.find( 'input[placeholder]' ).placeholder();
20 }
21
22 $collapsible = $content.find( '.mw-collapsible' );
23 if ( $collapsible.length ) {
24 // Preloaded by Skin::getDefaultModules()
25 mw.loader.using( 'jquery.makeCollapsible', function () {
26 $collapsible.makeCollapsible();
27 } );
28 }
29
30 $sortable = $content.find( 'table.sortable' );
31 if ( $sortable.length ) {
32 // Preloaded by Skin::getDefaultModules()
33 mw.loader.using( 'jquery.tablesorter', function () {
34 $sortable.tablesorter();
35 } );
36 }
37
38 // Run jquery.checkboxShiftClick
39 $content.find( 'input[type="checkbox"]:not(.noshiftselect)' ).checkboxShiftClick();
40 } );
41
42 // Things outside the wikipage content
43 $( function () {
44 var $nodes;
45
46 if ( !supportsPlaceholder ) {
47 // Exclude content to avoid hitting it twice for the (first) wikipage content
48 $( 'input[placeholder]' ).not( '#mw-content-text input' ).placeholder();
49 }
50
51 // Add accesskey hints to the tooltips
52 $( '[accesskey]' ).updateTooltipAccessKeys();
53
54 $nodes = $( '.catlinks[data-mw="interface"]' );
55 if ( $nodes.length ) {
56 /**
57 * Fired when categories are being added to the DOM
58 *
59 * It is encouraged to fire it before the main DOM is changed (when $content
60 * is still detached). However, this order is not defined either way, so you
61 * should only rely on $content itself.
62 *
63 * This includes the ready event on a page load (including post-edit loads)
64 * and when content has been previewed with LivePreview.
65 *
66 * @event wikipage_categories
67 * @member mw.hook
68 * @param {jQuery} $content The most appropriate element containing the content,
69 * such as .catlinks
70 */
71 mw.hook( 'wikipage.categories' ).fire( $nodes );
72 }
73 } );
74
75 }( mediaWiki, jQuery ) );