"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "resources/src/mediawiki/htmlform/hide-if.js" between
mediawiki-1.31.1.tar.gz and mediawiki-1.32.0.tar.gz

About: MediaWiki is a wiki engine (the collaborative editing software that runs for e.g. Wikipedia, the free encyclopedia).

hide-if.js  (mediawiki-1.31.1):hide-if.js  (mediawiki-1.32.0)
/* /*
* HTMLForm enhancements: * HTMLForm enhancements:
* Set up 'hide-if' behaviors for form fields that have them. * Set up 'hide-if' behaviors for form fields that have them.
*/ */
( function ( mw, $ ) { ( function () {
/** /**
* Helper function for hide-if to find the nearby form field. * Helper function for hide-if to find the nearby form field.
* *
* Find the closest match for the given name, "closest" being the minimum * Find the closest match for the given name, "closest" being the minimum
* level of parents to go to find a form field matching the given name or * level of parents to go to find a form field matching the given name or
* ending in array keys matching the given name (e.g. "baz" matches * ending in array keys matching the given name (e.g. "baz" matches
* "foo[bar][baz]"). * "foo[bar][baz]").
* *
* @ignore * @ignore
skipping to change at line 157 skipping to change at line 157
throw new Error( op + ' takes exactly two parameters' ); throw new Error( op + ' takes exactly two parameters' );
} }
field = hideIfGetField( $el, spec[ 1 ] ); field = hideIfGetField( $el, spec[ 1 ] );
if ( !field ) { if ( !field ) {
return [ [], function () { return [ [], function () {
return false; return false;
} ]; } ];
} }
v = spec[ 2 ]; v = spec[ 2 ];
if ( !( field instanceof jQuery ) ) { if ( !( field instanceof $ ) ) {
// field is a OO.ui.Widget // field is a OO.ui.Widget
if ( field.supports( 'isSelected' ) ) { if ( field.supports( 'isSelected' ) ) {
getVal = function () { getVal = function () {
var selected = field.isSe lected(); var selected = field.isSe lected();
return selected ? field.g etValue() : ''; return selected ? field.g etValue() : '';
}; };
} else { } else {
getVal = function () { getVal = function () {
return field.getValue(); return field.getValue();
}; };
skipping to change at line 255 skipping to change at line 255
fields = v[ 0 ]; fields = v[ 0 ];
test = v[ 1 ]; test = v[ 1 ];
// The .toggle() method works mostly the same for jQuery objects and OO.ui.Widget // The .toggle() method works mostly the same for jQuery objects and OO.ui.Widget
func = function () { func = function () {
var shouldHide = test(); var shouldHide = test();
self.toggle( !shouldHide ); self.toggle( !shouldHide );
// It is impossible to submit a form with hidden fields failing validation, e.g. one that // It is impossible to submit a form with hidden fields failing validation, e.g. one that
// is required. However, validity is not checked for disabled fields, as these are not // is required. However, validity is not checked for disabled fields, as these are not
// submitted with the form. So we should also disable fields when hiding them. // submitted with the form. So we should also disable fields when hiding them.
if ( self instanceof jQuery ) { if ( self instanceof $ ) {
// This also finds elements insid e any nested fields (in case of HTMLFormFieldCloner), // This also finds elements insid e any nested fields (in case of HTMLFormFieldCloner),
// which is problematic. But it w orks because: // which is problematic. But it w orks because:
// * HTMLFormFieldCloner::createF ieldsForKey() copies 'hide-if' rules to nested fields // * HTMLFormFieldCloner::createF ieldsForKey() copies 'hide-if' rules to nested fields
// * jQuery collections like $fie lds are in document order, so we register event // * jQuery collections like $fie lds are in document order, so we register event
// handlers for parents first // handlers for parents first
// * Event handlers are fired in the order they were registered, so even if the handler // * Event handlers are fired in the order they were registered, so even if the handler
// for parent messed up the chi ld, the handle for child will run next and fix it // for parent messed up the chi ld, the handle for child will run next and fix it
self.find( 'input, textarea, sele ct' ).each( function () { self.find( 'input, textarea, sele ct' ).each( function () {
var $this = $( this ); var $this = $( this );
if ( shouldHide ) { if ( shouldHide ) {
skipping to change at line 295 skipping to change at line 295
}; };
for ( i = 0; i < fields.length; i++ ) { for ( i = 0; i < fields.length; i++ ) {
// The .on() method works mostly the same for jQuery objects and OO.ui.Widget // The .on() method works mostly the same for jQuery objects and OO.ui.Widget
fields[ i ].on( 'change', func ); fields[ i ].on( 'change', func );
} }
func(); func();
} ); } );
} ); } );
} ); } );
}( mediaWiki, jQuery ) ); }() );
 End of changes. 4 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)