1
0
Fork 0

{Tabbed,}GroupUi now show/hide using FieldStyler

Yes, this is a mess; I'm pretty much out of time now.

* src/ui/group/GroupUi.js (doShowField, doHideField):
Use field styler

* src/ui/group/TabbedGroupUi (doShowField, doHideField):
Defer to supertype
master
Mike Gerwitz 2016-04-05 00:07:26 -04:00
parent d8fc549700
commit 921880cb35
2 changed files with 39 additions and 58 deletions

View File

@ -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 );
},

View File

@ -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 );
},