Merge "mw.widgets.Complex*: Fix setDisabled"
[lhc/web/wiklou.git] / resources / src / mediawiki / page / ready.js
1 ( function ( mw, $ ) {
2 // Break out of framesets
3 if ( mw.config.get( 'wgBreakFrames' ) ) {
4 // Note: In IE < 9 strict comparison to window is non-standard (the standard didn't exist yet)
5 // it works only comparing to window.self or window.window (http://stackoverflow.com/q/4850978/319266)
6 if ( window.top !== window.self ) {
7 // Un-trap us from framesets
8 window.top.location.href = location.href;
9 }
10 }
11
12 mw.hook( 'wikipage.content' ).add( function ( $content ) {
13 var $sortable, $collapsible;
14
15 $collapsible = $content.find( '.mw-collapsible' );
16 if ( $collapsible.length ) {
17 // Preloaded by Skin::getDefaultModules()
18 mw.loader.using( 'jquery.makeCollapsible', function () {
19 $collapsible.makeCollapsible();
20 } );
21 }
22
23 $sortable = $content.find( 'table.sortable' );
24 if ( $sortable.length ) {
25 // Preloaded by Skin::getDefaultModules()
26 mw.loader.using( 'jquery.tablesorter', function () {
27 $sortable.tablesorter();
28 } );
29 }
30
31 // Run jquery.checkboxShiftClick
32 $content.find( 'input[type="checkbox"]:not(.noshiftselect)' ).checkboxShiftClick();
33 } );
34
35 // Things outside the wikipage content
36 $( function () {
37 var $nodes;
38
39 // Add accesskey hints to the tooltips
40 $( '[accesskey]' ).updateTooltipAccessKeys();
41
42 $nodes = $( '.catlinks[data-mw="interface"]' );
43 if ( $nodes.length ) {
44 /**
45 * Fired when categories are being added to the DOM
46 *
47 * It is encouraged to fire it before the main DOM is changed (when $content
48 * is still detached). However, this order is not defined either way, so you
49 * should only rely on $content itself.
50 *
51 * This includes the ready event on a page load (including post-edit loads)
52 * and when content has been previewed with LivePreview.
53 *
54 * @event wikipage_categories
55 * @member mw.hook
56 * @param {jQuery} $content The most appropriate element containing the content,
57 * such as .catlinks
58 */
59 mw.hook( 'wikipage.categories' ).fire( $nodes );
60 }
61 } );
62
63 }( mediaWiki, jQuery ) );