{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 supertypemaster
parent
d8fc549700
commit
921880cb35
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* General UI logic for groups
|
* General UI logic for groups
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 LoVullo Associates, Inc.
|
* Copyright (C) 2015, 2016 LoVullo Associates, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of liza.
|
* This file is part of liza.
|
||||||
*
|
*
|
||||||
|
@ -144,23 +144,45 @@ module.exports = Class( 'GroupUi' )
|
||||||
*/
|
*/
|
||||||
'private _rawFieldCount': 0,
|
'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
|
* Initializes GroupUi
|
||||||
*
|
*
|
||||||
* @param Group group group to style
|
* @todo three of the below parameters might be able to be removed by
|
||||||
* @param jQuery $content the group content
|
* using context instead; the separate context is transitional
|
||||||
* @param ElementStyler styler styler to use to style elements
|
* (refactoring).
|
||||||
* @param jQuery jquery jQuery-compatible object
|
*
|
||||||
|
* @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}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
'public __construct': function( group, $content, styler, jquery )
|
'public __construct': function(
|
||||||
|
group, $content, styler, jquery, context, na_styler
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.$content = $content;
|
this.$content = $content;
|
||||||
this.styler = styler;
|
this.styler = styler;
|
||||||
this._jquery = jquery;
|
this._jquery = jquery;
|
||||||
|
this.context = context;
|
||||||
|
this._naStyler = na_styler;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -787,14 +809,8 @@ module.exports = Class( 'GroupUi' )
|
||||||
|
|
||||||
'virtual protected doHideField': function( field, index )
|
'virtual protected doHideField': function( field, index )
|
||||||
{
|
{
|
||||||
var $elements = this.getFieldElements( field, index );
|
this.context.getFieldByName( field, index )
|
||||||
|
.applyStyle( this._naStyler );
|
||||||
$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', '' );
|
|
||||||
} );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -815,12 +831,8 @@ module.exports = Class( 'GroupUi' )
|
||||||
|
|
||||||
'virtual protected doShowField': function( field, index )
|
'virtual protected doShowField': function( field, index )
|
||||||
{
|
{
|
||||||
var $elements = this.getFieldElements( field, index );
|
this.context.getFieldByName( field, index )
|
||||||
|
.revokeStyle( this._naStyler );
|
||||||
$elements.find( '.hidden' ).andSelf()
|
|
||||||
.stop( true, true )
|
|
||||||
.removeClass( 'hidden' )
|
|
||||||
.slideDown( 500 );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Group tabbed UI
|
* Group tabbed UI
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 LoVullo Associates, Inc.
|
* Copyright (C) 2015, 2016 LoVullo Associates, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of liza.
|
* This file is part of liza.
|
||||||
*
|
*
|
||||||
|
@ -377,21 +377,7 @@ module.exports = Class( 'TabbedGroupUi' )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $elements = this.getFieldElements( field, index );
|
this.__super( field, index );
|
||||||
|
|
||||||
$elements.stop( true, true );
|
|
||||||
|
|
||||||
if ( this.isOnVisibleTab( field, index ) )
|
|
||||||
{
|
|
||||||
$elements.slideUp( 500, function()
|
|
||||||
{
|
|
||||||
$( this ).addClass( 'hidden' );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$elements.hide().addClass( 'hidden' );
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -411,24 +397,7 @@ module.exports = Class( 'TabbedGroupUi' )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $elements = this.getFieldElements( field, index );
|
this.__super( 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();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue