history panel: fix to js behaviors on late-rendered hda bodies

This commit is contained in:
Carl Eberhard
2012-12-18 13:53:55 -05:00
parent f60c383b02
commit f2e3f9db5f
2 changed files with 24 additions and 8 deletions
+15 -7
View File
@@ -78,16 +78,12 @@ var HDABaseView = BaseView.extend( LoggableMixin ).extend(
itemWrapper.append( this._render_warnings() );
itemWrapper.append( this._render_titleBar() );
//NOTE: only sets behaviors on title and warnings - body will set up it's own
this._setUpBehaviors( itemWrapper );
this.body = $( this._render_body() );
itemWrapper.append( this.body );
//TODO: move to own function: setUpBehaviours
// we can potentially skip this step and call popupmenu directly on the download button
make_popup_menus( itemWrapper );
// set up canned behavior on children (bootstrap, popupmenus, editable_text, etc.)
itemWrapper.find( '.tooltip' ).tooltip({ placement : 'bottom' });
// transition...
this.$el.fadeOut( 'fast', function(){
view.$el.children().remove();
@@ -155,6 +151,17 @@ var HDABaseView = BaseView.extend( LoggableMixin ).extend(
});
},
/** set up js behaviors, event handlers for elements within the given container
* @param {jQuery} $container jq object that contains the elements to process (defaults to this.$el)
*/
_setUpBehaviors : function( $container ){
$container = $container || this.$el;
// set up canned behavior on children (bootstrap, popupmenus, editable_text, etc.)
//TODO: we can potentially skip this step and call popupmenu directly on the download button
make_popup_menus( $container );
$container.find( '.tooltip' ).tooltip({ placement : 'bottom' });
},
// ................................................................................ RENDER titlebar
/** Render any hda warnings including: is deleted, is purged, is hidden.
* (including links to further actions (undelete, etc.))
@@ -389,6 +396,7 @@ var HDABaseView = BaseView.extend( LoggableMixin ).extend(
body.append( $( '<div>Error: unknown dataset state "' + this.model.get( 'state' ) + '".</div>' ) );
}
body.append( '<div style="clear: both"></div>' );
this._setUpBehaviors( body );
},
/** Render inaccessible, not-owned by curr user.
+9 -1
View File
@@ -220,7 +220,15 @@ var HDACollection = Backbone.Collection.extend( LoggableMixin ).extend(
* @returns array of encoded ids
*/
ids : function(){
return this.map( function( item ){ return item.id; });
return this.map( function( hda ){ return hda.id; });
},
/** Get the hda with the given hid
* @param {Int} hid the hid to search for
* @returns {HistoryDatasetAssociation} the hda with the given hid or undefined if not found
*/
getByHid : function( hid ){
return _.first( this.filter( function( hda ){ return hda.get( 'hid' ) === hid; }) );
},
/** If the given hid is in the collection, return it's index. If not, return the insertion point it would need.