2014-03-24 06:08:56 +00:00
|
|
|
/**
|
2014-10-19 15:35:43 +00:00
|
|
|
* Disable InputBox submit button when the corresponding text input field is empty.
|
2014-03-24 06:08:56 +00:00
|
|
|
*
|
|
|
|
* @author Tony Thomas
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
|
|
|
|
*/
|
|
|
|
( function ( $, mw ) {
|
|
|
|
'use strict';
|
|
|
|
mw.hook( 'wikipage.content' ).add( function( $content ) {
|
2014-10-19 15:35:43 +00:00
|
|
|
var $input = $content.find( '.createboxInput:not([type=hidden])' ),
|
2014-10-05 12:38:39 +00:00
|
|
|
onChange = function() {
|
2014-03-24 06:08:56 +00:00
|
|
|
var $textbox = $( this ),
|
|
|
|
$submit = $textbox.data( 'form-submit' );
|
|
|
|
|
|
|
|
if ( !$submit ) {
|
|
|
|
$submit = $textbox.nextAll( 'input.createboxButton' ).first();
|
|
|
|
$textbox.data( 'form-submit', $submit );
|
|
|
|
}
|
|
|
|
|
|
|
|
$submit.prop( 'disabled', $textbox.val().length < 1 );
|
2014-10-05 12:38:39 +00:00
|
|
|
}, i;
|
|
|
|
|
|
|
|
for ( i = 0; i < $input.length; i++ ) {
|
|
|
|
onChange.call( $input.get( i ) );
|
|
|
|
}
|
2014-03-24 06:08:56 +00:00
|
|
|
|
2014-10-05 12:38:39 +00:00
|
|
|
$input.on( 'keyup input change', $.debounce( 50, onChange ) );
|
2014-10-19 15:35:43 +00:00
|
|
|
} );
|
2014-10-05 12:38:39 +00:00
|
|
|
}( jQuery, mediaWiki ) );
|