1
0
Fork 0

Minor StepUi cleanup

master
Mike Gerwitz 2015-11-30 11:43:28 -05:00
parent 215869e1ea
commit 1c4554dd0d
1 changed files with 31 additions and 14 deletions

View File

@ -288,14 +288,15 @@ module.exports = Class( 'StepUi' )
/**
* Will mark the step as dirty when the content is changed and update the
* staging bucket
* Will mark the step as dirty when the content is changed and update
* the staging bucket
*
* @return undefined
*/
setDirtyTrigger: function()
{
var step = this;
this.$content.bind( 'change.program', function( event )
{
// do nothing if the step is locked
@ -328,19 +329,23 @@ module.exports = Class( 'StepUi' )
{
index = 0;
}
else if ( $element.attr( 'type' ) === 'radio' || $element.attr( 'type' ) === 'checkbox' )
else if ( $element.attr( 'type' ) === 'radio'
|| $element.attr( 'type' ) === 'checkbox'
)
{
// if it's not checked, then this isn't the radio we're
// interested in. Sorry!
if ( !( $element.attr( 'checked' ) ) )
{
$element.attr( 'checked', true )
$element.attr( 'checked', true );
return;
}
// 2 in this instance is the yes/no group length.
var group_length = $element.attr( 'data-question-length' ) ? $element.attr( 'data-question-length' ) : 2;
var group_length = $element.attr( 'data-question-length' )
? $element.attr( 'data-question-length' )
: 2;
index = Math.floor( index / group_length );
}
@ -355,7 +360,15 @@ module.exports = Class( 'StepUi' )
} );
// @note This is a hack. In IE8, checkbox change events don't properly fire.
this.$content.delegate('input[type="checkbox"]', 'click', function () { jQuery(this).change(); } );
this.$content.delegate(
'input[type="checkbox"]',
'click',
function ()
{
// XXX: remove global
jQuery( this ).change();
}
);
},
@ -802,11 +815,15 @@ module.exports = Class( 'StepUi' )
*/
'public getFirstInvalidField': function( cmatch )
{
var $element = this.$content.find( '.invalid_field[data-field-name]:visible:first' );
var $element = this.$content.find(
'.invalid_field[data-field-name]:visible:first'
);
if ( $element.length === 0 )
{
$element = this.$content.find( '.invalid_field[data-field-name]:first' );
$element = this.$content.find(
'.invalid_field[data-field-name]:first'
);
}
var name = $element.attr( 'data-field-name' );