FauxRequest: don’t override getValues()
[lhc/web/wiklou.git] / resources / src / mediawiki.page.ready.js
1 ( function () {
2 mw.hook( 'wikipage.content' ).add( function ( $content ) {
3 var $sortable, $collapsible;
4
5 $collapsible = $content.find( '.mw-collapsible' );
6 if ( $collapsible.length ) {
7 // Preloaded by Skin::getDefaultModules()
8 mw.loader.using( 'jquery.makeCollapsible', function () {
9 $collapsible.makeCollapsible();
10 } );
11 }
12
13 $sortable = $content.find( 'table.sortable' );
14 if ( $sortable.length ) {
15 // Preloaded by Skin::getDefaultModules()
16 mw.loader.using( 'jquery.tablesorter', function () {
17 $sortable.tablesorter();
18 } );
19 }
20
21 // Run jquery.checkboxShiftClick
22 $content.find( 'input[type="checkbox"]:not(.noshiftselect)' ).checkboxShiftClick();
23 } );
24
25 // Things outside the wikipage content
26 $( function () {
27 var $nodes;
28
29 // Add accesskey hints to the tooltips
30 $( '[accesskey]' ).updateTooltipAccessKeys();
31
32 $nodes = $( '.catlinks[data-mw="interface"]' );
33 if ( $nodes.length ) {
34 /**
35 * Fired when categories are being added to the DOM
36 *
37 * It is encouraged to fire it before the main DOM is changed (when $content
38 * is still detached). However, this order is not defined either way, so you
39 * should only rely on $content itself.
40 *
41 * This includes the ready event on a page load (including post-edit loads)
42 * and when content has been previewed with LivePreview.
43 *
44 * @event wikipage_categories
45 * @member mw.hook
46 * @param {jQuery} $content The most appropriate element containing the content,
47 * such as .catlinks
48 */
49 mw.hook( 'wikipage.categories' ).fire( $nodes );
50 }
51
52 $( '#t-print a' ).on( 'click', function ( e ) {
53 window.print();
54 e.preventDefault();
55 } );
56
57 // Turn logout to a POST action
58 $( '#pt-logout a' ).on( 'click', function ( e ) {
59 var api = new mw.Api(),
60 returnUrl = $( '#pt-logout a' ).attr( 'href' );
61 mw.notify(
62 mw.message( 'logging-out-notify' ),
63 { tag: 'logout', autoHide: false }
64 );
65 api.postWithToken( 'csrf', {
66 action: 'logout'
67 } ).then(
68 function () {
69 location.href = returnUrl;
70 },
71 function ( e ) {
72 mw.notify(
73 mw.message( 'logout-failed', e ),
74 { type: 'error', tag: 'logout', autoHide: false }
75 );
76 }
77 );
78 e.preventDefault();
79 } );
80 } );
81
82 }() );