1
0
Fork 0

StepUi: Accept and return vanilla DOM content

This encapsulates the use of jQuery which will eventually be entirely
eliminated.
master
Mike Gerwitz 2015-12-01 23:06:32 -05:00
parent 972856225b
commit cc21298297
2 changed files with 16 additions and 9 deletions

View File

@ -25,6 +25,9 @@
* - ElementStyler;
* - BucketDataValidator.
* - Global references (e.g. jQuery) must be removed.
* - jQuery must be eliminated.
* - The public API now accepts and returns vanilla DOM content, so at
* least it's encapsulated now.
* - Checkbox-specific logic must be extracted.
* - This class is doing too much.
* @end needsLove
@ -235,13 +238,14 @@ module.exports = Class( 'StepUi' )
/**
* Sets content to be displayed
*
* @param {jQuery} $content content to display
* @param {HTMLElement} content content to display
*
* @return {StepUi} self
*/
'public setContent': function( $content )
'public setContent': function( content )
{
this.$content = $content;
// TODO: transition away from jQuery
this.$content = $( content );
this._processAnswerFields();
@ -263,11 +267,11 @@ module.exports = Class( 'StepUi' )
/**
* Returns the generated step content as a jQuery object
*
* @return {jQuery} generated step content
* @return {HTMLElement} generated step content
*/
getContent: function()
'virtual getContent': function()
{
return this.$content;
return this.$content[ 0 ];
},

View File

@ -160,10 +160,11 @@ module.exports = Class( 'StepUiBuilder' )
}
// enclose it in a div so that we have a single element we can query,
// making our lives much easier
// making our lives much easier (TODO: this is transitional code
// moving from jQuery to vanilla DOM)
ui.setContent(
$( '<div class="step-groups" />')
.append( $( data.content.html ) )
.append( $( data.content.html ) )[ 0 ]
);
// free the content from memory, as it's no longer needed (we don't need
@ -203,8 +204,10 @@ module.exports = Class( 'StepUiBuilder' )
step = ui.getStep();
var $content = $( ui.getContent() );
// instantiate a group object for each of the groups within this step
var $groups = ( ui.getContent().find( '.stepGroup' ) ).each( function()
var $groups = $content.find( '.stepGroup' ).each( function()
{
group = _self._groupBuilder( $( this ), _self._elementStyler );
group_id = group.getGroupId();