X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fmediawiki.page%2Fmediawiki.page.ready.js;h=ee416d67e899a0dd4bff17bad1409378976e2471;hb=0a54e70cdd2162be4b331aacb79ad5a3926dd2c6;hp=370c3a19c2037df064926455407eb570dac6d779;hpb=0554848efa30783b671836cc5f55c53a8c856109;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/mediawiki.page/mediawiki.page.ready.js b/resources/mediawiki.page/mediawiki.page.ready.js index 370c3a19c2..ee416d67e8 100644 --- a/resources/mediawiki.page/mediawiki.page.ready.js +++ b/resources/mediawiki.page/mediawiki.page.ready.js @@ -1,24 +1,40 @@ -jQuery( document ).ready( function( $ ) { +( function ( mw , $ ) { + var supportsPlaceholder = 'placeholder' in document.createElement( 'input' ); - /* Emulate placeholder if not supported by browser */ - if ( !( 'placeholder' in document.createElement( 'input' ) ) ) { - $( 'input[placeholder]' ).placeholder(); - } + mw.hook( 'wikipage.content' ).add( function ( $content ) { + var $sortableTables; - /* Enable makeCollapsible */ - $( '.mw-collapsible' ).makeCollapsible(); + // Run jquery.placeholder polyfill if placeholder is not supported + if ( !supportsPlaceholder ) { + $content.find( 'input[placeholder]' ).placeholder(); + } - /* Lazy load jquery.tablesorter */ - if ( $( 'table.sortable' ).length ) { - mw.loader.using( 'jquery.tablesorter', function() { - $( 'table.sortable' ).tablesorter(); - }); - } + // Run jquery.makeCollapsible + $content.find( '.mw-collapsible' ).makeCollapsible(); - /* Enable CheckboxShiftClick */ - $( 'input[type=checkbox]:not(.noshiftselect)' ).checkboxShiftClick(); + // Lazy load jquery.tablesorter + $sortableTables = $content.find( 'table.sortable' ); + if ( $sortableTables.length ) { + mw.loader.using( 'jquery.tablesorter', function () { + $sortableTables.tablesorter(); + } ); + } - /* Add accesskey hints to the tooltips */ - mw.util.updateTooltipAccessKeys(); + // Run jquery.checkboxShiftClick + $content.find( 'input[type="checkbox"]:not(.noshiftselect)' ).checkboxShiftClick(); + } ); -} ); + // Things outside the wikipage content + $( function () { + + if ( !supportsPlaceholder ) { + // Exclude content to avoid hitting it twice for the (first) wikipage content + $( 'input[placeholder]' ).not( '#mw-content-text input' ).placeholder(); + } + + // Add accesskey hints to the tooltips + mw.util.updateTooltipAccessKeys(); + + } ); + +}( mediaWiki, jQuery ) );