diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:31:04 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:58:39 +0200 |
commit | f6d65e533c62f6deb21342d4901ece24497b433e (patch) | |
tree | f28adf0362d14bcd448f7b65a7aaf38650f923aa /resources/src/mediawiki/mediawiki.htmlform.js | |
parent | c27b2e832fe25651ef2410fae85b41072aae7519 (diff) |
Update to MediaWiki 1.25.1
Diffstat (limited to 'resources/src/mediawiki/mediawiki.htmlform.js')
-rw-r--r-- | resources/src/mediawiki/mediawiki.htmlform.js | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/resources/src/mediawiki/mediawiki.htmlform.js b/resources/src/mediawiki/mediawiki.htmlform.js index 594800e1..4a4a97e9 100644 --- a/resources/src/mediawiki/mediawiki.htmlform.js +++ b/resources/src/mediawiki/mediawiki.htmlform.js @@ -237,7 +237,9 @@ } ); function enhance( $root ) { - var $matrixTooltips, $autocomplete; + var $matrixTooltips, $autocomplete, + // cache the separator to avoid object creation on each keypress + colonSeparator = mw.message( 'colon-separator' ).text(); /** * @ignore @@ -261,6 +263,36 @@ handleSelectOrOther.call( this, true ); } ); + // Add a dynamic max length to the reason field of SelectAndOther + // This checks the length together with the value from the select field + // When the reason list is changed and the bytelimit is longer than the allowed, + // nothing is done + $root + .find( '.mw-htmlform-select-and-other-field' ) + .each( function () { + var $this = $( this ), + // find the reason list + $reasonList = $root.find( '#' + $this.data( 'id-select' ) ), + // cache the current selection to avoid expensive lookup + currentValReasonList = $reasonList.val(); + + $reasonList.change( function () { + currentValReasonList = $reasonList.val(); + } ); + + $this.byteLimit( function ( input ) { + // Should be built the same as in HTMLSelectAndOtherField::loadDataFromRequest + var comment = currentValReasonList; + if ( comment === 'other' ) { + comment = input; + } else if ( input !== '' ) { + // Entry from drop down menu + additional comment + comment += colonSeparator + input; + } + return comment; + } ); + } ); + // Set up hide-if elements $root.find( '.mw-htmlform-hide-if' ).each( function () { var v, $fields, test, func, @@ -368,12 +400,12 @@ } // Add/remove cloner clones without having to resubmit the form - $root.find( '.mw-htmlform-cloner-delete-button' ).click( function ( ev ) { + $root.find( '.mw-htmlform-cloner-delete-button' ).filter( ':input' ).click( function ( ev ) { ev.preventDefault(); $( this ).closest( 'li.mw-htmlform-cloner-li' ).remove(); } ); - $root.find( '.mw-htmlform-cloner-create-button' ).click( function ( ev ) { + $root.find( '.mw-htmlform-cloner-create-button' ).filter( ':input' ).click( function ( ev ) { var $ul, $li, html; ev.preventDefault(); |