Merge "RCFilters UI: Fix scrolling to item on tag click"
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.edit.js
1 /*!
2 * Scripts for action=edit at domready
3 */
4 ( function ( mw, $ ) {
5 'use strict';
6
7 /**
8 * Fired when the editform is added to the edit page
9 *
10 * Similar to the {@link mw.hook#event-wikipage_content wikipage.content hook}
11 * $editForm can still be detached when this hook is fired.
12 *
13 * @event wikipage_editform
14 * @member mw.hook
15 * @param {jQuery} $editForm The most appropriate element containing the
16 * editform, usually #editform.
17 */
18
19 $( function () {
20 var editBox, scrollTop, $editForm;
21
22 // Make sure edit summary does not exceed byte limit
23 // TODO: Replace with this when $wgOOUIEditPage is removed:
24 // OO.ui.infuse( 'wpSummary' ).$input.byteLimit( 255 );
25 $( 'input#wpSummary, #wpSummary > input' ).byteLimit( 255 );
26
27 // Restore the edit box scroll state following a preview operation,
28 // and set up a form submission handler to remember this state.
29 editBox = document.getElementById( 'wpTextbox1' );
30 scrollTop = document.getElementById( 'wpScrolltop' );
31 $editForm = $( '#editform' );
32 mw.hook( 'wikipage.editform' ).fire( $editForm );
33 if ( $editForm.length && editBox && scrollTop ) {
34 if ( scrollTop.value ) {
35 editBox.scrollTop = scrollTop.value;
36 }
37 $editForm.submit( function () {
38 scrollTop.value = editBox.scrollTop;
39 } );
40 }
41 } );
42 }( mediaWiki, jQuery ) );