2 * Scripts for action=edit at domready
8 * Fired when the editform is added to the edit page
10 * Similar to the {@link mw.hook#event-wikipage_content wikipage.content hook}
11 * $editForm can still be detached when this hook is fired.
13 * @event wikipage_editform
15 * @param {jQuery} $editForm The most appropriate element containing the
16 * editform, usually #editform.
20 var editBox
, scrollTop
, $editForm
,
21 // TODO T6714: Once this can be adjusted, read this from config.
22 summaryByteLimit
= 255;
24 if ( $( '#editform' ).hasClass( 'mw-editform-ooui' ) ) {
25 mw
.loader
.using( 'oojs-ui-core' ).then( function () {
26 var wpSummary
= OO
.ui
.infuse( $( '#wpSummaryWidget' ) );
28 // Show a byte-counter to users with how many bytes are left for their edit summary.
29 // TODO: This looks a bit weird, as there is no unit in the UI, just numbers; showing
30 // 'bytes' confused users in testing, and showing 'chars' would be a lie. See T42035.
31 mw
.widgets
.visibleByteLimit( wpSummary
, summaryByteLimit
);
34 // Make sure edit summary does not exceed byte limit
35 $( '#wpSummary' ).byteLimit( summaryByteLimit
);
38 // Restore the edit box scroll state following a preview operation,
39 // and set up a form submission handler to remember this state.
40 editBox
= document
.getElementById( 'wpTextbox1' );
41 scrollTop
= document
.getElementById( 'wpScrolltop' );
42 $editForm
= $( '#editform' );
43 mw
.hook( 'wikipage.editform' ).fire( $editForm
);
44 if ( $editForm
.length
&& editBox
&& scrollTop
) {
45 if ( scrollTop
.value
) {
46 editBox
.scrollTop
= scrollTop
.value
;
48 $editForm
.submit( function () {
49 scrollTop
.value
= editBox
.scrollTop
;
53 }( mediaWiki
, jQuery
) );