diff --git a/src/ui/group/GroupUi.js b/src/ui/group/GroupUi.js index 986a860..d32cf9e 100644 --- a/src/ui/group/GroupUi.js +++ b/src/ui/group/GroupUi.js @@ -1,7 +1,7 @@ /** * General UI logic for groups * - * Copyright (C) 2015 LoVullo Associates, Inc. + * Copyright (C) 2015, 2016 LoVullo Associates, Inc. * * This file is part of liza. * @@ -144,23 +144,45 @@ module.exports = Class( 'GroupUi' ) */ 'private _rawFieldCount': 0, + /** + * DOM group context + * @type {DomContext} + */ + 'protected context': null, + + /** + * Styler when fields are no longer applicable + * @type {FieldStyler} + */ + 'private _naStyler': null, + /** * Initializes GroupUi * - * @param Group group group to style - * @param jQuery $content the group content - * @param ElementStyler styler styler to use to style elements - * @param jQuery jquery jQuery-compatible object + * @todo three of the below parameters might be able to be removed by + * using context instead; the separate context is transitional + * (refactoring). + * + * @param {Group} group group to style + * @param {jQuery} $content the group content + * @param {ElementStyler} styler styler to use to style elements + * @param {jQuery} jquery jQuery-compatible object + * @param {DomContext} context group context + * @param {FieldStyler} na_styler styler for fields that are N/A * * @return {undefined} */ - 'public __construct': function( group, $content, styler, jquery ) + 'public __construct': function( + group, $content, styler, jquery, context, na_styler + ) { - this.group = group; - this.$content = $content; - this.styler = styler; - this._jquery = jquery; + this.group = group; + this.$content = $content; + this.styler = styler; + this._jquery = jquery; + this.context = context; + this._naStyler = na_styler; }, @@ -787,14 +809,8 @@ module.exports = Class( 'GroupUi' ) 'virtual protected doHideField': function( field, index ) { - var $elements = this.getFieldElements( field, index ); - - $elements.stop( true, true ).slideUp( 500, function() - { - // be sure to remove the display:none added by jQuery so that we can - // perform our own handling of what it means to be "hidden" - $elements.addClass( 'hidden' ).attr( 'style', '' ); - } ); + this.context.getFieldByName( field, index ) + .applyStyle( this._naStyler ); }, @@ -815,12 +831,8 @@ module.exports = Class( 'GroupUi' ) 'virtual protected doShowField': function( field, index ) { - var $elements = this.getFieldElements( field, index ); - - $elements.find( '.hidden' ).andSelf() - .stop( true, true ) - .removeClass( 'hidden' ) - .slideDown( 500 ); + this.context.getFieldByName( field, index ) + .revokeStyle( this._naStyler ); }, diff --git a/src/ui/group/TabbedGroupUi.js b/src/ui/group/TabbedGroupUi.js index 70ff876..d185799 100644 --- a/src/ui/group/TabbedGroupUi.js +++ b/src/ui/group/TabbedGroupUi.js @@ -1,7 +1,7 @@ /** * Group tabbed UI * - * Copyright (C) 2015 LoVullo Associates, Inc. + * Copyright (C) 2015, 2016 LoVullo Associates, Inc. * * This file is part of liza. * @@ -377,21 +377,7 @@ module.exports = Class( 'TabbedGroupUi' ) return; } - var $elements = this.getFieldElements( field, index ); - - $elements.stop( true, true ); - - if ( this.isOnVisibleTab( field, index ) ) - { - $elements.slideUp( 500, function() - { - $( this ).addClass( 'hidden' ); - } ); - } - else - { - $elements.hide().addClass( 'hidden' ); - } + this.__super( field, index ); }, @@ -411,24 +397,7 @@ module.exports = Class( 'TabbedGroupUi' ) return; } - var $elements = this.getFieldElements( field, index ); - - // it's important to stop animations *before* removing the hidden class, - // since forcing its completion may add it - $elements - .stop( true, true ) - .find( '.hidden' ) - .andSelf() - .removeClass( 'hidden' ); - - if ( this.isOnVisibleTab( field, index ) ) - { - $elements.slideDown( 500 ); - } - else - { - $elements.show(); - } + this.__super( field, index ); },