1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6c9848ad6d02/ Changeset: 6c9848ad6d02 User: carlfeberhard Date: 2014-12-09 17:55:24+00:00 Summary: Client build: modularize fa-icon button from ui.js Affected #: 21 files diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 client/galaxy/scripts/jq-plugins/ui/fa-icon-button.js --- /dev/null +++ b/client/galaxy/scripts/jq-plugins/ui/fa-icon-button.js @@ -0,0 +1,48 @@ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define([], factory); + } else { + root.faIconButton = factory(); + } + +}(this, function () { +//============================================================================ + /** Returns a jQuery object containing a clickable font-awesome button. + * options: + * tooltipConfig : option map for bootstrap tool tip + * classes : array of class names (will always be classed as icon-btn) + * disabled : T/F - add the 'disabled' class? + * title : tooltip/title string + * target : optional href target + * href : optional href + * faIcon : which font awesome icon to use + * onclick : function to call when the button is clicked + */ + var faIconButton = function( options ){ + options = options || {}; + options.tooltipConfig = options.tooltipConfig || { placement: 'bottom' }; + + options.classes = [ 'icon-btn' ].concat( options.classes || [] ); + if( options.disabled ){ + options.classes.push( 'disabled' ); + } + + var html = [ + '<a class="', options.classes.join( ' ' ), '"', + (( options.title )?( ' title="' + options.title + '"' ):( '' )), + (( !options.disabled && options.target )? ( ' target="' + options.target + '"' ):( '' )), + ' href="', (( !options.disabled && options.href )?( options.href ):( 'javascript:void(0);' )), '">', + // could go with something less specific here - like 'html' + '<span class="fa ', options.faIcon, '"></span>', + '</a>' + ].join( '' ); + var $button = $( html ).tooltip( options.tooltipConfig ); + if( _.isFunction( options.onclick ) ){ + $button.click( options.onclick ); + } + return $button; + }; + +//============================================================================ + return faIconButton; +})); diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 client/galaxy/scripts/mvc/dataset/dataset-li-edit.js --- a/client/galaxy/scripts/mvc/dataset/dataset-li-edit.js +++ b/client/galaxy/scripts/mvc/dataset/dataset-li-edit.js @@ -3,9 +3,10 @@ "mvc/dataset/dataset-li", "mvc/tags", "mvc/annotations", + "jq-plugins/ui/fa-icon-button", "mvc/base-mvc", "utils/localization" -], function( STATES, DATASET_LI, TAGS, ANNOTATIONS, BASE_MVC, _l ){ +], function( STATES, DATASET_LI, TAGS, ANNOTATIONS, faIconButton, BASE_MVC, _l ){ //============================================================================== var _super = DATASET_LI.DatasetListItemView; /** @class Editing view for DatasetAssociation. diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 client/galaxy/scripts/mvc/dataset/dataset-li.js --- a/client/galaxy/scripts/mvc/dataset/dataset-li.js +++ b/client/galaxy/scripts/mvc/dataset/dataset-li.js @@ -1,9 +1,10 @@ define([ "mvc/list/list-item", "mvc/dataset/states", + "jq-plugins/ui/fa-icon-button", "mvc/base-mvc", "utils/localization" -], function( LIST_ITEM, STATES, BASE_MVC, _l ){ +], function( LIST_ITEM, STATES, faIconButton, BASE_MVC, _l ){ /* global Backbone */ /*============================================================================== TODO: diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 client/galaxy/scripts/mvc/history/hdca-li-edit.js --- a/client/galaxy/scripts/mvc/history/hdca-li-edit.js +++ b/client/galaxy/scripts/mvc/history/hdca-li-edit.js @@ -1,8 +1,9 @@ define([ "mvc/dataset/states", "mvc/history/hdca-li", + "jq-plugins/ui/fa-icon-button", "utils/localization" -], function( STATES, HDCA_LI, _l ){ +], function( STATES, HDCA_LI, faIconButton, _l ){ //============================================================================== var _super = HDCA_LI.HDCAListItemView; /** @class Editing view for HistoryDatasetCollectionAssociation. diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 client/galaxy/scripts/mvc/history/history-panel-edit.js --- a/client/galaxy/scripts/mvc/history/history-panel-edit.js +++ b/client/galaxy/scripts/mvc/history/history-panel-edit.js @@ -7,6 +7,7 @@ "mvc/history/hdca-li-edit", "mvc/tags", "mvc/annotations", + "jq-plugins/ui/fa-icon-button", "utils/localization" ], function( HPANEL, @@ -17,6 +18,7 @@ HDCA_LI_EDIT, TAGS, ANNOTATIONS, + faIconButton, _l ){ /* ============================================================================= diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 client/galaxy/scripts/mvc/history/history-panel.js --- a/client/galaxy/scripts/mvc/history/history-panel.js +++ b/client/galaxy/scripts/mvc/history/history-panel.js @@ -6,6 +6,7 @@ "mvc/history/hdca-li", "mvc/collection/collection-panel", "mvc/user/user-model", + "jq-plugins/ui/fa-icon-button", "mvc/base-mvc", "utils/localization", "jq-plugins/ui/search-input" @@ -17,6 +18,7 @@ HDCA_LI, COLLECTION_PANEL, USER, + faIconButton, BASE_MVC, _l ){ diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 client/galaxy/scripts/mvc/ui.js --- a/client/galaxy/scripts/mvc/ui.js +++ b/client/galaxy/scripts/mvc/ui.js @@ -486,31 +486,3 @@ }); return popupMenusCreated; }; - - -//============================================================================== -var faIconButton = function( options ){ -//TODO: move out of global - options = options || {}; - options.tooltipConfig = options.tooltipConfig || { placement: 'bottom' }; - - options.classes = [ 'icon-btn' ].concat( options.classes || [] ); - if( options.disabled ){ - options.classes.push( 'disabled' ); - } - - var html = [ - '<a class="', options.classes.join( ' ' ), '"', - (( options.title )?( ' title="' + options.title + '"' ):( '' )), - (( !options.disabled && options.target )? ( ' target="' + options.target + '"' ):( '' )), - ' href="', (( !options.disabled && options.href )?( options.href ):( 'javascript:void(0);' )), '">', - // could go with something less specific here - like 'html' - '<span class="fa ', options.faIcon, '"></span>', - '</a>' - ].join( '' ); - var $button = $( html ).tooltip( options.tooltipConfig ); - if( _.isFunction( options.onclick ) ){ - $button.click( options.onclick ); - } - return $button; -}; diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/jq-plugins/ui/fa-icon-button.js --- /dev/null +++ b/static/scripts/jq-plugins/ui/fa-icon-button.js @@ -0,0 +1,48 @@ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define([], factory); + } else { + root.faIconButton = factory(); + } + +}(this, function () { +//============================================================================ + /** Returns a jQuery object containing a clickable font-awesome button. + * options: + * tooltipConfig : option map for bootstrap tool tip + * classes : array of class names (will always be classed as icon-btn) + * disabled : T/F - add the 'disabled' class? + * title : tooltip/title string + * target : optional href target + * href : optional href + * faIcon : which font awesome icon to use + * onclick : function to call when the button is clicked + */ + var faIconButton = function( options ){ + options = options || {}; + options.tooltipConfig = options.tooltipConfig || { placement: 'bottom' }; + + options.classes = [ 'icon-btn' ].concat( options.classes || [] ); + if( options.disabled ){ + options.classes.push( 'disabled' ); + } + + var html = [ + '<a class="', options.classes.join( ' ' ), '"', + (( options.title )?( ' title="' + options.title + '"' ):( '' )), + (( !options.disabled && options.target )? ( ' target="' + options.target + '"' ):( '' )), + ' href="', (( !options.disabled && options.href )?( options.href ):( 'javascript:void(0);' )), '">', + // could go with something less specific here - like 'html' + '<span class="fa ', options.faIcon, '"></span>', + '</a>' + ].join( '' ); + var $button = $( html ).tooltip( options.tooltipConfig ); + if( _.isFunction( options.onclick ) ){ + $button.click( options.onclick ); + } + return $button; + }; + +//============================================================================ + return faIconButton; +})); diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/mvc/dataset/dataset-li-edit.js --- a/static/scripts/mvc/dataset/dataset-li-edit.js +++ b/static/scripts/mvc/dataset/dataset-li-edit.js @@ -3,9 +3,10 @@ "mvc/dataset/dataset-li", "mvc/tags", "mvc/annotations", + "jq-plugins/ui/fa-icon-button", "mvc/base-mvc", "utils/localization" -], function( STATES, DATASET_LI, TAGS, ANNOTATIONS, BASE_MVC, _l ){ +], function( STATES, DATASET_LI, TAGS, ANNOTATIONS, faIconButton, BASE_MVC, _l ){ //============================================================================== var _super = DATASET_LI.DatasetListItemView; /** @class Editing view for DatasetAssociation. diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/mvc/dataset/dataset-li.js --- a/static/scripts/mvc/dataset/dataset-li.js +++ b/static/scripts/mvc/dataset/dataset-li.js @@ -1,9 +1,10 @@ define([ "mvc/list/list-item", "mvc/dataset/states", + "jq-plugins/ui/fa-icon-button", "mvc/base-mvc", "utils/localization" -], function( LIST_ITEM, STATES, BASE_MVC, _l ){ +], function( LIST_ITEM, STATES, faIconButton, BASE_MVC, _l ){ /* global Backbone */ /*============================================================================== TODO: diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/mvc/history/hdca-li-edit.js --- a/static/scripts/mvc/history/hdca-li-edit.js +++ b/static/scripts/mvc/history/hdca-li-edit.js @@ -1,8 +1,9 @@ define([ "mvc/dataset/states", "mvc/history/hdca-li", + "jq-plugins/ui/fa-icon-button", "utils/localization" -], function( STATES, HDCA_LI, _l ){ +], function( STATES, HDCA_LI, faIconButton, _l ){ //============================================================================== var _super = HDCA_LI.HDCAListItemView; /** @class Editing view for HistoryDatasetCollectionAssociation. diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/mvc/history/history-panel-edit.js --- a/static/scripts/mvc/history/history-panel-edit.js +++ b/static/scripts/mvc/history/history-panel-edit.js @@ -7,6 +7,7 @@ "mvc/history/hdca-li-edit", "mvc/tags", "mvc/annotations", + "jq-plugins/ui/fa-icon-button", "utils/localization" ], function( HPANEL, @@ -17,6 +18,7 @@ HDCA_LI_EDIT, TAGS, ANNOTATIONS, + faIconButton, _l ){ /* ============================================================================= diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/mvc/history/history-panel.js --- a/static/scripts/mvc/history/history-panel.js +++ b/static/scripts/mvc/history/history-panel.js @@ -6,6 +6,7 @@ "mvc/history/hdca-li", "mvc/collection/collection-panel", "mvc/user/user-model", + "jq-plugins/ui/fa-icon-button", "mvc/base-mvc", "utils/localization", "jq-plugins/ui/search-input" @@ -17,6 +18,7 @@ HDCA_LI, COLLECTION_PANEL, USER, + faIconButton, BASE_MVC, _l ){ diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/mvc/ui.js --- a/static/scripts/mvc/ui.js +++ b/static/scripts/mvc/ui.js @@ -486,31 +486,3 @@ }); return popupMenusCreated; }; - - -//============================================================================== -var faIconButton = function( options ){ -//TODO: move out of global - options = options || {}; - options.tooltipConfig = options.tooltipConfig || { placement: 'bottom' }; - - options.classes = [ 'icon-btn' ].concat( options.classes || [] ); - if( options.disabled ){ - options.classes.push( 'disabled' ); - } - - var html = [ - '<a class="', options.classes.join( ' ' ), '"', - (( options.title )?( ' title="' + options.title + '"' ):( '' )), - (( !options.disabled && options.target )? ( ' target="' + options.target + '"' ):( '' )), - ' href="', (( !options.disabled && options.href )?( options.href ):( 'javascript:void(0);' )), '">', - // could go with something less specific here - like 'html' - '<span class="fa ', options.faIcon, '"></span>', - '</a>' - ].join( '' ); - var $button = $( html ).tooltip( options.tooltipConfig ); - if( _.isFunction( options.onclick ) ){ - $button.click( options.onclick ); - } - return $button; -}; diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/packed/jq-plugins/ui/fa-icon-button.js --- /dev/null +++ b/static/scripts/packed/jq-plugins/ui/fa-icon-button.js @@ -0,0 +1,1 @@ +(function(a,b){if(typeof define==="function"&&define.amd){define([],b)}else{a.faIconButton=b()}}(this,function(){var a=function(b){b=b||{};b.tooltipConfig=b.tooltipConfig||{placement:"bottom"};b.classes=["icon-btn"].concat(b.classes||[]);if(b.disabled){b.classes.push("disabled")}var c=['<a class="',b.classes.join(" "),'"',((b.title)?(' title="'+b.title+'"'):("")),((!b.disabled&&b.target)?(' target="'+b.target+'"'):("")),' href="',((!b.disabled&&b.href)?(b.href):("javascript:void(0);")),'">','<span class="fa ',b.faIcon,'"></span>',"</a>"].join("");var d=$(c).tooltip(b.tooltipConfig);if(_.isFunction(b.onclick)){d.click(b.onclick)}return d};return a})); \ No newline at end of file diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/packed/mvc/dataset/dataset-li-edit.js --- a/static/scripts/packed/mvc/dataset/dataset-li-edit.js +++ b/static/scripts/packed/mvc/dataset/dataset-li-edit.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/states","mvc/dataset/dataset-li","mvc/tags","mvc/annotations","mvc/base-mvc","utils/localization"],function(b,h,g,e,c,d){var f=h.DatasetListItemView;var a=f.extend({initialize:function(i){f.prototype.initialize.call(this,i);this.hasUser=i.hasUser;this.purgeAllowed=i.purgeAllowed||false;this.tagsEditorShown=i.tagsEditorShown||false;this.annotationEditorShown=i.annotationEditorShown||false},_renderPrimaryActions:function(){var i=f.prototype._renderPrimaryActions.call(this);if(this.model.get("state")===b.NOT_VIEWABLE){return i}return f.prototype._renderPrimaryActions.call(this).concat([this._renderEditButton(),this._renderDeleteButton()])},_renderEditButton:function(){if((this.model.get("state")===b.DISCARDED)||(!this.model.get("accessible"))){return null}var k=this.model.get("purged"),i=this.model.get("deleted"),j={title:d("Edit attributes"),href:this.model.urls.edit,target:this.linkTarget,faIcon:"fa-pencil",classes:"edit-btn"};if(i||k){j.disabled=true;if(k){j.title=d("Cannot edit attributes of datasets removed from disk")}else{if(i){j.title=d("Undelete dataset to edit attributes")}}}else{if(_.contains([b.UPLOAD,b.NEW],this.model.get("state"))){j.disabled=true;j.title=d("This dataset is not yet editable")}}return faIconButton(j)},_renderDeleteButton:function(){if((!this.model.get("accessible"))){return null}var i=this,j=this.model.isDeletedOrPurged();return faIconButton({title:!j?d("Delete"):d("Dataset is already deleted"),disabled:j,faIcon:"fa-times",classes:"delete-btn",onclick:function(){i.$el.find(".icon-btn.delete-btn").trigger("mouseout");i.model["delete"]()}})},_renderDetails:function(){var i=f.prototype._renderDetails.call(this),j=this.model.get("state");if(!this.model.isDeletedOrPurged()&&_.contains([b.OK,b.FAILED_METADATA],j)){this._renderTags(i);this._renderAnnotation(i);this._makeDbkeyEditLink(i)}this._setUpBehaviors(i);return i},_renderSecondaryActions:function(){var i=f.prototype._renderSecondaryActions.call(this);switch(this.model.get("state")){case b.UPLOAD:case b.NEW:case b.NOT_VIEWABLE:return i;case b.ERROR:i.unshift(this._renderErrButton());return i.concat([this._renderRerunButton()]);case b.OK:case b.FAILED_METADATA:return i.concat([this._renderRerunButton(),this._renderVisualizationsButton()])}return i.concat([this._renderRerunButton()])},_renderErrButton:function(){return faIconButton({title:d("View or report this error"),href:this.model.urls.report_error,classes:"report-error-btn",target:this.linkTarget,faIcon:"fa-bug"})},_renderRerunButton:function(){return faIconButton({title:d("Run this job again"),href:this.model.urls.rerun,classes:"rerun-btn",target:this.linkTarget,faIcon:"fa-refresh"})},_renderVisualizationsButton:function(){var i=this.model.get("visualizations");if((this.model.isDeletedOrPurged())||(!this.hasUser)||(!this.model.hasData())||(_.isEmpty(i))){return null}if(!_.isObject(i[0])){this.warn("Visualizations have been switched off");return null}var j=$(this.templates.visualizations(i,this));j.find('[target="galaxy_main"]').attr("target",this.linkTarget);this._addScratchBookFn(j.find(".visualization-link").addBack(".visualization-link"));return j},_addScratchBookFn:function(j){var i=this;j.click(function(k){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Visualization",type:"url",content:$(this).attr("href")});k.preventDefault();k.stopPropagation()}})},_renderTags:function(i){if(!this.hasUser){return}var j=this;this.tagsEditor=new g.TagsEditor({model:this.model,el:i.find(".tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.tagsEditorShown=true},onhide:function(){j.tagsEditorShown=false},$activator:faIconButton({title:d("Edit dataset tags"),classes:"tag-btn",faIcon:"fa-tags"}).appendTo(i.find(".actions .right"))});if(this.tagsEditorShown){this.tagsEditor.toggle(true)}},_renderAnnotation:function(i){if(!this.hasUser){return}var j=this;this.annotationEditor=new e.AnnotationEditor({model:this.model,el:i.find(".annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.annotationEditorShown=true},onhide:function(){j.annotationEditorShown=false},$activator:faIconButton({title:d("Edit dataset annotation"),classes:"annotate-btn",faIcon:"fa-comment"}).appendTo(i.find(".actions .right"))});if(this.annotationEditorShown){this.annotationEditor.toggle(true)}},_makeDbkeyEditLink:function(i){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){var j=$('<a class="value">?</a>').attr("href",this.model.urls.edit).attr("target",this.linkTarget);i.find(".dbkey .value").replaceWith(j)}},events:_.extend(_.clone(f.prototype.events),{"click .undelete-link":"_clickUndeleteLink","click .purge-link":"_clickPurgeLink","click .edit-btn":function(i){this.trigger("edit",this,i)},"click .delete-btn":function(i){this.trigger("delete",this,i)},"click .rerun-btn":function(i){this.trigger("rerun",this,i)},"click .report-err-btn":function(i){this.trigger("report-err",this,i)},"click .visualization-btn":function(i){this.trigger("visualize",this,i)},"click .dbkey a":function(i){this.trigger("edit",this,i)}}),_clickUndeleteLink:function(i){this.model.undelete();return false},_clickPurgeLink:function(i){this.model.purge();return false},toString:function(){var i=(this.model)?(this.model+""):("(no model)");return"HDAEditView("+i+")"}});a.prototype.templates=(function(){var j=_.extend({},f.prototype.templates.warnings,{failed_metadata:c.wrapTemplate(['<% if( dataset.state === "failed_metadata" ){ %>','<div class="failed_metadata-warning warningmessagesmall">',d("An error occurred setting the metadata for this dataset"),'<br /><a href="<%= dataset.urls.edit %>" target="<%= view.linkTarget %>">',d("Set it manually or retry auto-detection"),"</a>","</div>","<% } %>"],"dataset"),deleted:c.wrapTemplate(["<% if( dataset.deleted && !dataset.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',d("This dataset has been deleted"),'<br /><a class="undelete-link" href="javascript:void(0);">',d("Undelete it"),"</a>","<% if( view.purgeAllowed ){ %>",'<br /><a class="purge-link" href="javascript:void(0);">',d("Permanently remove it from disk"),"</a>","<% } %>","</div>","<% } %>"],"dataset")});var i=c.wrapTemplate(["<% if( visualizations.length === 1 ){ %>",'<a class="visualization-btn visualization-link icon-btn" href="<%= visualizations[0].href %>"',' target="<%= visualizations[0].target %>" title="',d("Visualize in"),' <%= visualizations[0].html %>">','<span class="fa fa-bar-chart-o"></span>',"</a>","<% } else { %>",'<div class="visualizations-dropdown dropdown">','<a class="visualization-btn icon-btn" data-toggle="dropdown" title="',d("Visualize"),'">','<span class="fa fa-bar-chart-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu">',"<% _.each( visualizations, function( visualization ){ %>",'<li><a class="visualization-link" href="<%= visualization.href %>"',' target="<%= visualization.target %>">',"<%= visualization.html %>","</a></li>","<% }); %>","</ul>","</div>","<% } %>"],"visualizations");return _.extend({},f.prototype.templates,{warnings:j,visualizations:i})}());return{DatasetListItemEdit:a}}); \ No newline at end of file +define(["mvc/dataset/states","mvc/dataset/dataset-li","mvc/tags","mvc/annotations","jq-plugins/ui/fa-icon-button","mvc/base-mvc","utils/localization"],function(g,d,e,b,a,i,c){var f=d.DatasetListItemView;var h=f.extend({initialize:function(j){f.prototype.initialize.call(this,j);this.hasUser=j.hasUser;this.purgeAllowed=j.purgeAllowed||false;this.tagsEditorShown=j.tagsEditorShown||false;this.annotationEditorShown=j.annotationEditorShown||false},_renderPrimaryActions:function(){var j=f.prototype._renderPrimaryActions.call(this);if(this.model.get("state")===g.NOT_VIEWABLE){return j}return f.prototype._renderPrimaryActions.call(this).concat([this._renderEditButton(),this._renderDeleteButton()])},_renderEditButton:function(){if((this.model.get("state")===g.DISCARDED)||(!this.model.get("accessible"))){return null}var l=this.model.get("purged"),j=this.model.get("deleted"),k={title:c("Edit attributes"),href:this.model.urls.edit,target:this.linkTarget,faIcon:"fa-pencil",classes:"edit-btn"};if(j||l){k.disabled=true;if(l){k.title=c("Cannot edit attributes of datasets removed from disk")}else{if(j){k.title=c("Undelete dataset to edit attributes")}}}else{if(_.contains([g.UPLOAD,g.NEW],this.model.get("state"))){k.disabled=true;k.title=c("This dataset is not yet editable")}}return a(k)},_renderDeleteButton:function(){if((!this.model.get("accessible"))){return null}var j=this,k=this.model.isDeletedOrPurged();return a({title:!k?c("Delete"):c("Dataset is already deleted"),disabled:k,faIcon:"fa-times",classes:"delete-btn",onclick:function(){j.$el.find(".icon-btn.delete-btn").trigger("mouseout");j.model["delete"]()}})},_renderDetails:function(){var j=f.prototype._renderDetails.call(this),k=this.model.get("state");if(!this.model.isDeletedOrPurged()&&_.contains([g.OK,g.FAILED_METADATA],k)){this._renderTags(j);this._renderAnnotation(j);this._makeDbkeyEditLink(j)}this._setUpBehaviors(j);return j},_renderSecondaryActions:function(){var j=f.prototype._renderSecondaryActions.call(this);switch(this.model.get("state")){case g.UPLOAD:case g.NEW:case g.NOT_VIEWABLE:return j;case g.ERROR:j.unshift(this._renderErrButton());return j.concat([this._renderRerunButton()]);case g.OK:case g.FAILED_METADATA:return j.concat([this._renderRerunButton(),this._renderVisualizationsButton()])}return j.concat([this._renderRerunButton()])},_renderErrButton:function(){return a({title:c("View or report this error"),href:this.model.urls.report_error,classes:"report-error-btn",target:this.linkTarget,faIcon:"fa-bug"})},_renderRerunButton:function(){return a({title:c("Run this job again"),href:this.model.urls.rerun,classes:"rerun-btn",target:this.linkTarget,faIcon:"fa-refresh"})},_renderVisualizationsButton:function(){var j=this.model.get("visualizations");if((this.model.isDeletedOrPurged())||(!this.hasUser)||(!this.model.hasData())||(_.isEmpty(j))){return null}if(!_.isObject(j[0])){this.warn("Visualizations have been switched off");return null}var k=$(this.templates.visualizations(j,this));k.find('[target="galaxy_main"]').attr("target",this.linkTarget);this._addScratchBookFn(k.find(".visualization-link").addBack(".visualization-link"));return k},_addScratchBookFn:function(k){var j=this;k.click(function(l){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Visualization",type:"url",content:$(this).attr("href")});l.preventDefault();l.stopPropagation()}})},_renderTags:function(j){if(!this.hasUser){return}var k=this;this.tagsEditor=new e.TagsEditor({model:this.model,el:j.find(".tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){k.tagsEditorShown=true},onhide:function(){k.tagsEditorShown=false},$activator:a({title:c("Edit dataset tags"),classes:"tag-btn",faIcon:"fa-tags"}).appendTo(j.find(".actions .right"))});if(this.tagsEditorShown){this.tagsEditor.toggle(true)}},_renderAnnotation:function(j){if(!this.hasUser){return}var k=this;this.annotationEditor=new b.AnnotationEditor({model:this.model,el:j.find(".annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){k.annotationEditorShown=true},onhide:function(){k.annotationEditorShown=false},$activator:a({title:c("Edit dataset annotation"),classes:"annotate-btn",faIcon:"fa-comment"}).appendTo(j.find(".actions .right"))});if(this.annotationEditorShown){this.annotationEditor.toggle(true)}},_makeDbkeyEditLink:function(j){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){var k=$('<a class="value">?</a>').attr("href",this.model.urls.edit).attr("target",this.linkTarget);j.find(".dbkey .value").replaceWith(k)}},events:_.extend(_.clone(f.prototype.events),{"click .undelete-link":"_clickUndeleteLink","click .purge-link":"_clickPurgeLink","click .edit-btn":function(j){this.trigger("edit",this,j)},"click .delete-btn":function(j){this.trigger("delete",this,j)},"click .rerun-btn":function(j){this.trigger("rerun",this,j)},"click .report-err-btn":function(j){this.trigger("report-err",this,j)},"click .visualization-btn":function(j){this.trigger("visualize",this,j)},"click .dbkey a":function(j){this.trigger("edit",this,j)}}),_clickUndeleteLink:function(j){this.model.undelete();return false},_clickPurgeLink:function(j){this.model.purge();return false},toString:function(){var j=(this.model)?(this.model+""):("(no model)");return"HDAEditView("+j+")"}});h.prototype.templates=(function(){var k=_.extend({},f.prototype.templates.warnings,{failed_metadata:i.wrapTemplate(['<% if( dataset.state === "failed_metadata" ){ %>','<div class="failed_metadata-warning warningmessagesmall">',c("An error occurred setting the metadata for this dataset"),'<br /><a href="<%= dataset.urls.edit %>" target="<%= view.linkTarget %>">',c("Set it manually or retry auto-detection"),"</a>","</div>","<% } %>"],"dataset"),deleted:i.wrapTemplate(["<% if( dataset.deleted && !dataset.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',c("This dataset has been deleted"),'<br /><a class="undelete-link" href="javascript:void(0);">',c("Undelete it"),"</a>","<% if( view.purgeAllowed ){ %>",'<br /><a class="purge-link" href="javascript:void(0);">',c("Permanently remove it from disk"),"</a>","<% } %>","</div>","<% } %>"],"dataset")});var j=i.wrapTemplate(["<% if( visualizations.length === 1 ){ %>",'<a class="visualization-btn visualization-link icon-btn" href="<%= visualizations[0].href %>"',' target="<%= visualizations[0].target %>" title="',c("Visualize in"),' <%= visualizations[0].html %>">','<span class="fa fa-bar-chart-o"></span>',"</a>","<% } else { %>",'<div class="visualizations-dropdown dropdown">','<a class="visualization-btn icon-btn" data-toggle="dropdown" title="',c("Visualize"),'">','<span class="fa fa-bar-chart-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu">',"<% _.each( visualizations, function( visualization ){ %>",'<li><a class="visualization-link" href="<%= visualization.href %>"',' target="<%= visualization.target %>">',"<%= visualization.html %>","</a></li>","<% }); %>","</ul>","</div>","<% } %>"],"visualizations");return _.extend({},f.prototype.templates,{warnings:k,visualizations:j})}());return{DatasetListItemEdit:h}}); \ No newline at end of file diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/packed/mvc/dataset/dataset-li.js --- a/static/scripts/packed/mvc/dataset/dataset-li.js +++ b/static/scripts/packed/mvc/dataset/dataset-li.js @@ -1,1 +1,1 @@ -define(["mvc/list/list-item","mvc/dataset/states","mvc/base-mvc","utils/localization"],function(d,a,b,c){var f=d.ListItemView;var e=f.extend({className:f.prototype.className+" dataset",id:function(){return["dataset",this.model.get("id")].join("-")},initialize:function(g){if(g.logger){this.logger=this.model.logger=g.logger}this.log(this+".initialize:",g);f.prototype.initialize.call(this,g);this.linkTarget=g.linkTarget||"_blank";this._setUpListeners()},_setUpListeners:function(){f.prototype._setUpListeners.call(this);this.model.on("change",function(h,g){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},_fetchModelDetails:function(){var g=this;if(g.model.inReadyState()&&!g.model.hasDetails()){return g.model.fetch({silent:true})}return jQuery.when()},remove:function(h,i){var g=this;h=h||this.fxSpeed;this.$el.fadeOut(h,function(){Backbone.View.prototype.remove.call(g);if(i){i.call(g)}})},render:function(g){return f.prototype.render.call(this,g)},_swapNewRender:function(g){f.prototype._swapNewRender.call(this,g);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_renderPrimaryActions:function(){return[this._renderDisplayButton()]},_renderDisplayButton:function(){var i=this.model.get("state");if((i===a.NOT_VIEWABLE)||(i===a.DISCARDED)||(!this.model.get("accessible"))){return null}var h={target:this.linkTarget,classes:"display-btn"};if(this.model.get("purged")){h.disabled=true;h.title=c("Cannot display datasets removed from disk")}else{if(i===a.UPLOAD){h.disabled=true;h.title=c("This dataset must finish uploading before it can be viewed")}else{if(i===a.NEW){h.disabled=true;h.title=c("This dataset is not yet viewable")}else{h.title=c("View data");h.href=this.model.urls.display;var g=this;h.onclick=function(j){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add_dataset(g.model.get("id"));j.preventDefault()}}}}}h.faIcon="fa-eye";return faIconButton(h)},_renderDetails:function(){if(this.model.get("state")===a.NOT_VIEWABLE){return $(this.templates.noAccess(this.model.toJSON(),this))}var g=f.prototype._renderDetails.call(this);g.find(".actions .left").empty().append(this._renderSecondaryActions());g.find(".summary").html(this._renderSummary()).prepend(this._renderDetailMessages());g.find(".display-applications").html(this._renderDisplayApplications());this._setUpBehaviors(g);return g},_renderSummary:function(){var g=this.model.toJSON(),h=this.templates.summaries[g.state];h=h||this.templates.summaries.unknown;return h(g,this)},_renderDetailMessages:function(){var g=this,i=$('<div class="detail-messages"></div>'),h=g.model.toJSON();_.each(g.templates.detailMessages,function(j){i.append($(j(h,g)))});return i},_renderDisplayApplications:function(){if(this.model.isDeletedOrPurged()){return""}return[this.templates.displayApplications(this.model.get("display_apps"),this),this.templates.displayApplications(this.model.get("display_types"),this)].join("")},_renderSecondaryActions:function(){this.debug("_renderSecondaryActions");switch(this.model.get("state")){case a.NOT_VIEWABLE:return[];case a.OK:case a.FAILED_METADATA:case a.ERROR:return[this._renderDownloadButton(),this._renderShowParamsButton()]}return[this._renderShowParamsButton()]},_renderShowParamsButton:function(){return faIconButton({title:c("View details"),classes:"params-btn",href:this.model.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_renderDownloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}if(!_.isEmpty(this.model.get("meta_files"))){return this._renderMetaFileDownloadButton()}return $(['<a class="download-btn icon-btn" href="',this.model.urls.download,'" title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))},_renderMetaFileDownloadButton:function(){var g=this.model.urls;return $(['<div class="metafile-dropdown dropdown">','<a class="download-btn icon-btn" href="javascript:void(0)" data-toggle="dropdown"',' title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">','<li><a href="'+g.download+'">',c("Download dataset"),"</a></li>",_.map(this.model.get("meta_files"),function(h){return['<li><a href="',g.meta_download+h.file_type,'">',c("Download")," ",h.file_type,"</a></li>"].join("")}).join("\n"),"</ul>","</div>"].join("\n"))},events:_.extend(_.clone(f.prototype.events),{"click .display-btn":function(g){this.trigger("display",this,g)},"click .params-btn":function(g){this.trigger("params",this,g)},"click .download-btn":function(g){this.trigger("download",this,g)}}),toString:function(){var g=(this.model)?(this.model+""):("(no model)");return"DatasetListItemView("+g+")"}});e.prototype.templates=(function(){var i=_.extend({},f.prototype.templates.warnings,{failed_metadata:b.wrapTemplate(['<% if( model.state === "failed_metadata" ){ %>','<div class="warningmessagesmall">',c("An error occurred setting the metadata for this dataset"),"</div>","<% } %>"]),error:b.wrapTemplate(["<% if( model.error ){ %>",'<div class="errormessagesmall">',c("There was an error getting the data for this dataset"),": <%- model.error %>","</div>","<% } %>"]),purged:b.wrapTemplate(["<% if( model.purged ){ %>",'<div class="purged-msg warningmessagesmall">',c("This dataset has been deleted and removed from disk"),"</div>","<% } %>"]),deleted:b.wrapTemplate(["<% if( model.deleted && !model.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',c("This dataset has been deleted"),"</div>","<% } %>"])});var j=b.wrapTemplate(['<div class="details">','<div class="summary"></div>','<div class="actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !dataset.deleted && !dataset.purged ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="display-applications"></div>',"<% if( dataset.peek ){ %>",'<pre class="dataset-peek"><%= dataset.peek %></pre>',"<% } %>","<% } %>","</div>"],"dataset");var h=b.wrapTemplate(['<div class="details">','<div class="summary">',c("You do not have permission to view this dataset"),"</div>","</div>"],"dataset");var k={};k[a.OK]=k[a.FAILED_METADATA]=b.wrapTemplate(["<% if( dataset.misc_blurb ){ %>",'<div class="blurb">','<span class="value"><%- dataset.misc_blurb %></span>',"</div>","<% } %>","<% if( dataset.file_ext ){ %>",'<div class="datatype">','<label class="prompt">',c("format"),"</label>",'<span class="value"><%- dataset.file_ext %></span>',"</div>","<% } %>","<% if( dataset.metadata_dbkey ){ %>",'<div class="dbkey">','<label class="prompt">',c("database"),"</label>",'<span class="value">',"<%- dataset.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( dataset.misc_info ){ %>",'<div class="info">','<span class="value"><%- dataset.misc_info %></span>',"</div>","<% } %>"],"dataset");k[a.NEW]=b.wrapTemplate(["<div>",c("This is a new dataset and not all of its data are available yet"),"</div>"],"dataset");k[a.NOT_VIEWABLE]=b.wrapTemplate(["<div>",c("You do not have permission to view this dataset"),"</div>"],"dataset");k[a.DISCARDED]=b.wrapTemplate(["<div>",c("The job creating this dataset was cancelled before completion"),"</div>"],"dataset");k[a.QUEUED]=b.wrapTemplate(["<div>",c("This job is waiting to run"),"</div>"],"dataset");k[a.RUNNING]=b.wrapTemplate(["<div>",c("This job is currently running"),"</div>"],"dataset");k[a.UPLOAD]=b.wrapTemplate(["<div>",c("This dataset is currently uploading"),"</div>"],"dataset");k[a.SETTING_METADATA]=b.wrapTemplate(["<div>",c("Metadata is being auto-detected"),"</div>"],"dataset");k[a.PAUSED]=b.wrapTemplate(["<div>",c('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume'),"</div>"],"dataset");k[a.ERROR]=b.wrapTemplate(["<% if( !dataset.purged ){ %>","<div><%- dataset.misc_blurb %></div>","<% } %>",'<span class="help-text">',c("An error occurred with this dataset"),":</span>",'<div class="job-error-text"><%- dataset.misc_info %></div>'],"dataset");k[a.EMPTY]=b.wrapTemplate(["<div>",c("No data"),": <i><%- dataset.misc_blurb %></i></div>"],"dataset");k.unknown=b.wrapTemplate(['<div>Error: unknown dataset state: "<%- dataset.state %>"</div>'],"dataset");var l={resubmitted:b.wrapTemplate(["<% if( model.resubmitted ){ %>",'<div class="resubmitted-msg infomessagesmall">',c("The job creating this dataset has been resubmitted"),"</div>","<% } %>"])};var g=b.wrapTemplate(["<% _.each( apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>"],"apps");return _.extend({},f.prototype.templates,{warnings:i,details:j,noAccess:h,summaries:k,detailMessages:l,displayApplications:g})}());return{DatasetListItemView:e}}); \ No newline at end of file +define(["mvc/list/list-item","mvc/dataset/states","jq-plugins/ui/fa-icon-button","mvc/base-mvc","utils/localization"],function(d,a,e,b,c){var g=d.ListItemView;var f=g.extend({className:g.prototype.className+" dataset",id:function(){return["dataset",this.model.get("id")].join("-")},initialize:function(h){if(h.logger){this.logger=this.model.logger=h.logger}this.log(this+".initialize:",h);g.prototype.initialize.call(this,h);this.linkTarget=h.linkTarget||"_blank";this._setUpListeners()},_setUpListeners:function(){g.prototype._setUpListeners.call(this);this.model.on("change",function(i,h){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},_fetchModelDetails:function(){var h=this;if(h.model.inReadyState()&&!h.model.hasDetails()){return h.model.fetch({silent:true})}return jQuery.when()},remove:function(i,j){var h=this;i=i||this.fxSpeed;this.$el.fadeOut(i,function(){Backbone.View.prototype.remove.call(h);if(j){j.call(h)}})},render:function(h){return g.prototype.render.call(this,h)},_swapNewRender:function(h){g.prototype._swapNewRender.call(this,h);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_renderPrimaryActions:function(){return[this._renderDisplayButton()]},_renderDisplayButton:function(){var j=this.model.get("state");if((j===a.NOT_VIEWABLE)||(j===a.DISCARDED)||(!this.model.get("accessible"))){return null}var i={target:this.linkTarget,classes:"display-btn"};if(this.model.get("purged")){i.disabled=true;i.title=c("Cannot display datasets removed from disk")}else{if(j===a.UPLOAD){i.disabled=true;i.title=c("This dataset must finish uploading before it can be viewed")}else{if(j===a.NEW){i.disabled=true;i.title=c("This dataset is not yet viewable")}else{i.title=c("View data");i.href=this.model.urls.display;var h=this;i.onclick=function(k){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add_dataset(h.model.get("id"));k.preventDefault()}}}}}i.faIcon="fa-eye";return e(i)},_renderDetails:function(){if(this.model.get("state")===a.NOT_VIEWABLE){return $(this.templates.noAccess(this.model.toJSON(),this))}var h=g.prototype._renderDetails.call(this);h.find(".actions .left").empty().append(this._renderSecondaryActions());h.find(".summary").html(this._renderSummary()).prepend(this._renderDetailMessages());h.find(".display-applications").html(this._renderDisplayApplications());this._setUpBehaviors(h);return h},_renderSummary:function(){var h=this.model.toJSON(),i=this.templates.summaries[h.state];i=i||this.templates.summaries.unknown;return i(h,this)},_renderDetailMessages:function(){var h=this,j=$('<div class="detail-messages"></div>'),i=h.model.toJSON();_.each(h.templates.detailMessages,function(k){j.append($(k(i,h)))});return j},_renderDisplayApplications:function(){if(this.model.isDeletedOrPurged()){return""}return[this.templates.displayApplications(this.model.get("display_apps"),this),this.templates.displayApplications(this.model.get("display_types"),this)].join("")},_renderSecondaryActions:function(){this.debug("_renderSecondaryActions");switch(this.model.get("state")){case a.NOT_VIEWABLE:return[];case a.OK:case a.FAILED_METADATA:case a.ERROR:return[this._renderDownloadButton(),this._renderShowParamsButton()]}return[this._renderShowParamsButton()]},_renderShowParamsButton:function(){return e({title:c("View details"),classes:"params-btn",href:this.model.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_renderDownloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}if(!_.isEmpty(this.model.get("meta_files"))){return this._renderMetaFileDownloadButton()}return $(['<a class="download-btn icon-btn" href="',this.model.urls.download,'" title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))},_renderMetaFileDownloadButton:function(){var h=this.model.urls;return $(['<div class="metafile-dropdown dropdown">','<a class="download-btn icon-btn" href="javascript:void(0)" data-toggle="dropdown"',' title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">','<li><a href="'+h.download+'">',c("Download dataset"),"</a></li>",_.map(this.model.get("meta_files"),function(i){return['<li><a href="',h.meta_download+i.file_type,'">',c("Download")," ",i.file_type,"</a></li>"].join("")}).join("\n"),"</ul>","</div>"].join("\n"))},events:_.extend(_.clone(g.prototype.events),{"click .display-btn":function(h){this.trigger("display",this,h)},"click .params-btn":function(h){this.trigger("params",this,h)},"click .download-btn":function(h){this.trigger("download",this,h)}}),toString:function(){var h=(this.model)?(this.model+""):("(no model)");return"DatasetListItemView("+h+")"}});f.prototype.templates=(function(){var j=_.extend({},g.prototype.templates.warnings,{failed_metadata:b.wrapTemplate(['<% if( model.state === "failed_metadata" ){ %>','<div class="warningmessagesmall">',c("An error occurred setting the metadata for this dataset"),"</div>","<% } %>"]),error:b.wrapTemplate(["<% if( model.error ){ %>",'<div class="errormessagesmall">',c("There was an error getting the data for this dataset"),": <%- model.error %>","</div>","<% } %>"]),purged:b.wrapTemplate(["<% if( model.purged ){ %>",'<div class="purged-msg warningmessagesmall">',c("This dataset has been deleted and removed from disk"),"</div>","<% } %>"]),deleted:b.wrapTemplate(["<% if( model.deleted && !model.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',c("This dataset has been deleted"),"</div>","<% } %>"])});var k=b.wrapTemplate(['<div class="details">','<div class="summary"></div>','<div class="actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !dataset.deleted && !dataset.purged ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="display-applications"></div>',"<% if( dataset.peek ){ %>",'<pre class="dataset-peek"><%= dataset.peek %></pre>',"<% } %>","<% } %>","</div>"],"dataset");var i=b.wrapTemplate(['<div class="details">','<div class="summary">',c("You do not have permission to view this dataset"),"</div>","</div>"],"dataset");var l={};l[a.OK]=l[a.FAILED_METADATA]=b.wrapTemplate(["<% if( dataset.misc_blurb ){ %>",'<div class="blurb">','<span class="value"><%- dataset.misc_blurb %></span>',"</div>","<% } %>","<% if( dataset.file_ext ){ %>",'<div class="datatype">','<label class="prompt">',c("format"),"</label>",'<span class="value"><%- dataset.file_ext %></span>',"</div>","<% } %>","<% if( dataset.metadata_dbkey ){ %>",'<div class="dbkey">','<label class="prompt">',c("database"),"</label>",'<span class="value">',"<%- dataset.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( dataset.misc_info ){ %>",'<div class="info">','<span class="value"><%- dataset.misc_info %></span>',"</div>","<% } %>"],"dataset");l[a.NEW]=b.wrapTemplate(["<div>",c("This is a new dataset and not all of its data are available yet"),"</div>"],"dataset");l[a.NOT_VIEWABLE]=b.wrapTemplate(["<div>",c("You do not have permission to view this dataset"),"</div>"],"dataset");l[a.DISCARDED]=b.wrapTemplate(["<div>",c("The job creating this dataset was cancelled before completion"),"</div>"],"dataset");l[a.QUEUED]=b.wrapTemplate(["<div>",c("This job is waiting to run"),"</div>"],"dataset");l[a.RUNNING]=b.wrapTemplate(["<div>",c("This job is currently running"),"</div>"],"dataset");l[a.UPLOAD]=b.wrapTemplate(["<div>",c("This dataset is currently uploading"),"</div>"],"dataset");l[a.SETTING_METADATA]=b.wrapTemplate(["<div>",c("Metadata is being auto-detected"),"</div>"],"dataset");l[a.PAUSED]=b.wrapTemplate(["<div>",c('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume'),"</div>"],"dataset");l[a.ERROR]=b.wrapTemplate(["<% if( !dataset.purged ){ %>","<div><%- dataset.misc_blurb %></div>","<% } %>",'<span class="help-text">',c("An error occurred with this dataset"),":</span>",'<div class="job-error-text"><%- dataset.misc_info %></div>'],"dataset");l[a.EMPTY]=b.wrapTemplate(["<div>",c("No data"),": <i><%- dataset.misc_blurb %></i></div>"],"dataset");l.unknown=b.wrapTemplate(['<div>Error: unknown dataset state: "<%- dataset.state %>"</div>'],"dataset");var m={resubmitted:b.wrapTemplate(["<% if( model.resubmitted ){ %>",'<div class="resubmitted-msg infomessagesmall">',c("The job creating this dataset has been resubmitted"),"</div>","<% } %>"])};var h=b.wrapTemplate(["<% _.each( apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>"],"apps");return _.extend({},g.prototype.templates,{warnings:j,details:k,noAccess:i,summaries:l,detailMessages:m,displayApplications:h})}());return{DatasetListItemView:f}}); \ No newline at end of file diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/packed/mvc/history/hdca-li-edit.js --- a/static/scripts/packed/mvc/history/hdca-li-edit.js +++ b/static/scripts/packed/mvc/history/hdca-li-edit.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/states","mvc/history/hdca-li","utils/localization"],function(a,e,b){var c=e.HDCAListItemView;var d=c.extend({_renderPrimaryActions:function(){this.log(this+"._renderPrimaryActions");return c.prototype._renderPrimaryActions.call(this).concat([this._renderDeleteButton()])},_renderDeleteButton:function(){var g=this,f=this.model.get("deleted");return faIconButton({title:f?b("Dataset collection is already deleted"):b("Delete"),classes:"delete-btn",faIcon:"fa-times",disabled:f,onclick:function(){g.$el.find(".icon-btn.delete-btn").trigger("mouseout");g.model["delete"]()}})},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"HDCAListItemEdit("+f+")"}});return{HDCAListItemEdit:d}}); \ No newline at end of file +define(["mvc/dataset/states","mvc/history/hdca-li","jq-plugins/ui/fa-icon-button","utils/localization"],function(a,f,c,b){var d=f.HDCAListItemView;var e=d.extend({_renderPrimaryActions:function(){this.log(this+"._renderPrimaryActions");return d.prototype._renderPrimaryActions.call(this).concat([this._renderDeleteButton()])},_renderDeleteButton:function(){var h=this,g=this.model.get("deleted");return c({title:g?b("Dataset collection is already deleted"):b("Delete"),classes:"delete-btn",faIcon:"fa-times",disabled:g,onclick:function(){h.$el.find(".icon-btn.delete-btn").trigger("mouseout");h.model["delete"]()}})},toString:function(){var g=(this.model)?(this.model+""):("(no model)");return"HDCAListItemEdit("+g+")"}});return{HDCAListItemEdit:e}}); \ No newline at end of file diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/packed/mvc/history/history-panel-edit.js --- a/static/scripts/packed/mvc/history/history-panel-edit.js +++ b/static/scripts/packed/mvc/history/history-panel-edit.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","utils/localization"],function(f,h,k,d,c,g,j,a,b){var i=f.HistoryPanel;var e=i.extend({HDAViewClass:c.HDAListItemEdit,HDCAViewClass:g.HDCAListItemEdit,initialize:function(l){l=l||{};i.prototype.initialize.call(this,l);this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=l.purgeAllowed||false;this.annotationEditorShown=l.annotationEditorShown||false;this.tagsEditorShown=l.tagsEditorShown||false;this.multiselectActions=l.multiselectActions||this._getActions()},_setUpListeners:function(){i.prototype._setUpListeners.call(this);this.on("drop",function(l,m){this.dataDropped(m);this.dropTargetOff()})},_setUpCollectionListeners:function(){i.prototype._setUpCollectionListeners.call(this);this.collection.on("change:deleted",this._handleHdaDeletionChange,this);this.collection.on("change:visible",this._handleHdaVisibleChange,this);this.collection.on("change:purged",function(l){this.model.fetch()},this);return this},_setUpModelListeners:function(){i.prototype._setUpModelListeners.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);return this},_buildNewRender:function(){var l=i.prototype._buildNewRender.call(this);if(!this.model){return l}if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(l);this._renderAnnotation(l)}return l},renderItems:function(m){var l=i.prototype.renderItems.call(this,m);this._renderCounts(m);return l},_renderCounts:function(n){function m(q,r){return['<a class="',q,'" href="javascript:void(0);">',r,"</a>"].join("")}n=n||this.$el;var l=this.collection.where({deleted:true}),p=this.collection.where({visible:false}),o=[];if(this.views.length){o.push([this.views.length,b("shown")].join(" "))}if(l.length){o.push((!this.showDeleted)?([l.length,m("toggle-deleted-link",b("deleted"))].join(" ")):(m("toggle-deleted-link",b("hide deleted"))))}if(p.length){o.push((!this.showHidden)?([p.length,m("toggle-hidden-link",b("hidden"))].join(" ")):(m("toggle-hidden-link",b("hide hidden"))))}return n.find("> .controls .subtitle").html(o.join(", "))},_renderTags:function(l){var m=this;this.tagsEditor=new j.TagsEditor({model:this.model,el:l.find(".controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){m.toggleHDATagEditors(true,m.fxSpeed)},onhide:function(){m.toggleHDATagEditors(false,m.fxSpeed)},$activator:faIconButton({title:b("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(l.find(".controls .actions"))})},_renderAnnotation:function(l){var m=this;this.annotationEditor=new a.AnnotationEditor({model:this.model,el:l.find(".controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){m.toggleHDAAnnotationEditors(true,m.fxSpeed)},onhide:function(){m.toggleHDAAnnotationEditors(false,m.fxSpeed)},$activator:faIconButton({title:b("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(l.find(".controls .actions"))})},_setUpBehaviors:function(l){l=l||this.$el;i.prototype._setUpBehaviors.call(this,l);if(!this.model){return}if(this.multiselectActions.length){this.actionsPopup=new PopupMenu(l.find(".list-action-popup-btn"),this.multiselectActions)}if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var m=this,n=".controls .name";l.find(n).attr("title",b("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(o){var p=m.model.get("name");if(o&&o!==p){m.$el.find(n).text(o);m.model.save({name:o}).fail(function(){m.$el.find(n).text(m.model.previous("name"))})}else{m.$el.find(n).text(p)}}})},_getActions:function(){var l=this,m=[{html:b("Hide datasets"),func:function(){var n=d.HistoryDatasetAssociation.prototype.hide;l.getSelectedModels().ajaxQueue(n)}},{html:b("Unhide datasets"),func:function(){var n=d.HistoryDatasetAssociation.prototype.unhide;l.getSelectedModels().ajaxQueue(n)}},{html:b("Delete datasets"),func:function(){var n=d.HistoryDatasetAssociation.prototype["delete"];l.getSelectedModels().ajaxQueue(n)}},{html:b("Undelete datasets"),func:function(){var n=d.HistoryDatasetAssociation.prototype.undelete;l.getSelectedModels().ajaxQueue(n)}}];if(l.purgeAllowed){m.push({html:b("Permanently delete datasets"),func:function(){if(confirm(b("This will permanently remove the data in your datasets. Are you sure?"))){var n=d.HistoryDatasetAssociation.prototype.purge;l.getSelectedModels().ajaxQueue(n)}}})}m.push({html:b("Build Dataset List"),func:function(){l.getSelectedModels().promoteToHistoryDatasetCollection(l.model,"list")}});m.push({html:b("Build Dataset Pair"),func:function(){l.getSelectedModels().promoteToHistoryDatasetCollection(l.model,"paired")}});m.push({html:b("Build List of Dataset Pairs"),func:_.bind(l._showPairedCollectionModal,l)});return m},_showPairedCollectionModal:function(){var l=this,m=l.getSelectedModels().toJSON().filter(function(n){return n.history_content_type==="dataset"&&n.state===k.OK});if(m.length){require(["mvc/collection/paired-collection-creator"],function(n){window.creator=n.pairedCollectionCreatorModal(m,{historyId:l.model.id})})}else{}},_attachItems:function(l){this.$list(l).append(this.views.reverse().map(function(m){return m.$el}));return this},_attachView:function(m){var l=this;l.views.unshift(m);l.$list().prepend(m.render(0).$el.hide());m.$el.slideDown(l.fxSpeed)},_getItemViewOptions:function(m){var l=i.prototype._getItemViewOptions.call(this,m);_.extend(l,{purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return l},_handleHdaDeletionChange:function(l){if(l.get("deleted")&&!this.showDeleted){this.removeItemView(l)}this._renderCounts()},_handleHdaVisibleChange:function(l){if(l.hidden()&&!this.storage.showHidden){this.removeItemView(l)}this._renderCounts()},toggleHDATagEditors:function(l){var m=Array.prototype.slice.call(arguments,1);_.each(this.views,function(n){if(n.tagsEditor){n.tagsEditor.toggle.apply(n.tagsEditor,m)}})},toggleHDAAnnotationEditors:function(l){var m=Array.prototype.slice.call(arguments,1);_.each(this.views,function(n){if(n.annotationEditor){n.annotationEditor.toggle.apply(n.annotationEditor,m)}})},events:_.extend(_.clone(i.prototype.events),{"click .show-selectors-btn":"toggleSelectors","click .toggle-deleted-link":function(l){this.toggleShowDeleted()},"click .toggle-hidden-link":function(l){this.toggleShowHidden()}}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},dropTargetOn:function(){if(this.dropTarget){return this}this.dropTarget=true;var m={dragenter:_.bind(this.dragenter,this),dragover:_.bind(this.dragover,this),dragleave:_.bind(this.dragleave,this),drop:_.bind(this.drop,this)};var n=this._renderDropTarget();this.$list().before([this._renderDropTargetHelp(),n]);for(var l in m){if(m.hasOwnProperty(l)){n.on(l,m[l])}}return this},_renderDropTarget:function(){return $("<div/>").addClass("history-drop-target").css({height:"64px",margin:"0px 10px 10px 10px",border:"1px dashed black","border-radius":"3px"})},_renderDropTargetHelp:function(){return $("<div/>").addClass("history-drop-target-help").css({margin:"10px 10px 4px 10px",color:"grey","font-size":"80%","font-style":"italic"}).text(b("Drag datasets here to copy them to the current history"))},dropTargetOff:function(){if(!this.dropTarget){return this}this.dropTarget=false;this.$(".history-drop-target").remove();this.$(".history-drop-target-help").remove();return this},dropTargetToggle:function(){if(this.dropTarget){this.dropTargetOff()}else{this.dropTargetOn()}return this},dragenter:function(l){l.preventDefault();l.stopPropagation();this.$(".history-drop-target").css("border","2px solid black")},dragover:function(l){l.preventDefault();l.stopPropagation()},dragleave:function(l){l.preventDefault();l.stopPropagation();this.$(".history-drop-target").css("border","1px dashed black")},drop:function(n){n.preventDefault();n.dataTransfer.dropEffect="move";var l=this,o=n.dataTransfer.getData("text");try{o=JSON.parse(o)}catch(m){this.warn("error parsing JSON from drop:",o)}this.trigger("droptarget:drop",n,o,l);return false},dataDropped:function(m){var l=this;if(_.isObject(m)&&m.model_class==="HistoryDatasetAssociation"&&m.id){return l.model.contents.copy(m.id)}return jQuery.when()},toString:function(){return"HistoryPanelEdit("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanelEdit:e}}); \ No newline at end of file +define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","jq-plugins/ui/fa-icon-button","utils/localization"],function(g,i,l,e,d,h,k,b,a,c){var j=g.HistoryPanel;var f=j.extend({HDAViewClass:d.HDAListItemEdit,HDCAViewClass:h.HDCAListItemEdit,initialize:function(m){m=m||{};j.prototype.initialize.call(this,m);this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=m.purgeAllowed||false;this.annotationEditorShown=m.annotationEditorShown||false;this.tagsEditorShown=m.tagsEditorShown||false;this.multiselectActions=m.multiselectActions||this._getActions()},_setUpListeners:function(){j.prototype._setUpListeners.call(this);this.on("drop",function(m,n){this.dataDropped(n);this.dropTargetOff()})},_setUpCollectionListeners:function(){j.prototype._setUpCollectionListeners.call(this);this.collection.on("change:deleted",this._handleHdaDeletionChange,this);this.collection.on("change:visible",this._handleHdaVisibleChange,this);this.collection.on("change:purged",function(m){this.model.fetch()},this);return this},_setUpModelListeners:function(){j.prototype._setUpModelListeners.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);return this},_buildNewRender:function(){var m=j.prototype._buildNewRender.call(this);if(!this.model){return m}if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(m);this._renderAnnotation(m)}return m},renderItems:function(n){var m=j.prototype.renderItems.call(this,n);this._renderCounts(n);return m},_renderCounts:function(o){function n(r,s){return['<a class="',r,'" href="javascript:void(0);">',s,"</a>"].join("")}o=o||this.$el;var m=this.collection.where({deleted:true}),q=this.collection.where({visible:false}),p=[];if(this.views.length){p.push([this.views.length,c("shown")].join(" "))}if(m.length){p.push((!this.showDeleted)?([m.length,n("toggle-deleted-link",c("deleted"))].join(" ")):(n("toggle-deleted-link",c("hide deleted"))))}if(q.length){p.push((!this.showHidden)?([q.length,n("toggle-hidden-link",c("hidden"))].join(" ")):(n("toggle-hidden-link",c("hide hidden"))))}return o.find("> .controls .subtitle").html(p.join(", "))},_renderTags:function(m){var n=this;this.tagsEditor=new k.TagsEditor({model:this.model,el:m.find(".controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){n.toggleHDATagEditors(true,n.fxSpeed)},onhide:function(){n.toggleHDATagEditors(false,n.fxSpeed)},$activator:a({title:c("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(m.find(".controls .actions"))})},_renderAnnotation:function(m){var n=this;this.annotationEditor=new b.AnnotationEditor({model:this.model,el:m.find(".controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){n.toggleHDAAnnotationEditors(true,n.fxSpeed)},onhide:function(){n.toggleHDAAnnotationEditors(false,n.fxSpeed)},$activator:a({title:c("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(m.find(".controls .actions"))})},_setUpBehaviors:function(m){m=m||this.$el;j.prototype._setUpBehaviors.call(this,m);if(!this.model){return}if(this.multiselectActions.length){this.actionsPopup=new PopupMenu(m.find(".list-action-popup-btn"),this.multiselectActions)}if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var n=this,o=".controls .name";m.find(o).attr("title",c("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(p){var q=n.model.get("name");if(p&&p!==q){n.$el.find(o).text(p);n.model.save({name:p}).fail(function(){n.$el.find(o).text(n.model.previous("name"))})}else{n.$el.find(o).text(q)}}})},_getActions:function(){var m=this,n=[{html:c("Hide datasets"),func:function(){var o=e.HistoryDatasetAssociation.prototype.hide;m.getSelectedModels().ajaxQueue(o)}},{html:c("Unhide datasets"),func:function(){var o=e.HistoryDatasetAssociation.prototype.unhide;m.getSelectedModels().ajaxQueue(o)}},{html:c("Delete datasets"),func:function(){var o=e.HistoryDatasetAssociation.prototype["delete"];m.getSelectedModels().ajaxQueue(o)}},{html:c("Undelete datasets"),func:function(){var o=e.HistoryDatasetAssociation.prototype.undelete;m.getSelectedModels().ajaxQueue(o)}}];if(m.purgeAllowed){n.push({html:c("Permanently delete datasets"),func:function(){if(confirm(c("This will permanently remove the data in your datasets. Are you sure?"))){var o=e.HistoryDatasetAssociation.prototype.purge;m.getSelectedModels().ajaxQueue(o)}}})}n.push({html:c("Build Dataset List"),func:function(){m.getSelectedModels().promoteToHistoryDatasetCollection(m.model,"list")}});n.push({html:c("Build Dataset Pair"),func:function(){m.getSelectedModels().promoteToHistoryDatasetCollection(m.model,"paired")}});n.push({html:c("Build List of Dataset Pairs"),func:_.bind(m._showPairedCollectionModal,m)});return n},_showPairedCollectionModal:function(){var m=this,n=m.getSelectedModels().toJSON().filter(function(o){return o.history_content_type==="dataset"&&o.state===l.OK});if(n.length){require(["mvc/collection/paired-collection-creator"],function(o){window.creator=o.pairedCollectionCreatorModal(n,{historyId:m.model.id})})}else{}},_attachItems:function(m){this.$list(m).append(this.views.reverse().map(function(n){return n.$el}));return this},_attachView:function(n){var m=this;m.views.unshift(n);m.$list().prepend(n.render(0).$el.hide());n.$el.slideDown(m.fxSpeed)},_getItemViewOptions:function(n){var m=j.prototype._getItemViewOptions.call(this,n);_.extend(m,{purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return m},_handleHdaDeletionChange:function(m){if(m.get("deleted")&&!this.showDeleted){this.removeItemView(m)}this._renderCounts()},_handleHdaVisibleChange:function(m){if(m.hidden()&&!this.storage.showHidden){this.removeItemView(m)}this._renderCounts()},toggleHDATagEditors:function(m){var n=Array.prototype.slice.call(arguments,1);_.each(this.views,function(o){if(o.tagsEditor){o.tagsEditor.toggle.apply(o.tagsEditor,n)}})},toggleHDAAnnotationEditors:function(m){var n=Array.prototype.slice.call(arguments,1);_.each(this.views,function(o){if(o.annotationEditor){o.annotationEditor.toggle.apply(o.annotationEditor,n)}})},events:_.extend(_.clone(j.prototype.events),{"click .show-selectors-btn":"toggleSelectors","click .toggle-deleted-link":function(m){this.toggleShowDeleted()},"click .toggle-hidden-link":function(m){this.toggleShowHidden()}}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},dropTargetOn:function(){if(this.dropTarget){return this}this.dropTarget=true;var n={dragenter:_.bind(this.dragenter,this),dragover:_.bind(this.dragover,this),dragleave:_.bind(this.dragleave,this),drop:_.bind(this.drop,this)};var o=this._renderDropTarget();this.$list().before([this._renderDropTargetHelp(),o]);for(var m in n){if(n.hasOwnProperty(m)){o.on(m,n[m])}}return this},_renderDropTarget:function(){return $("<div/>").addClass("history-drop-target").css({height:"64px",margin:"0px 10px 10px 10px",border:"1px dashed black","border-radius":"3px"})},_renderDropTargetHelp:function(){return $("<div/>").addClass("history-drop-target-help").css({margin:"10px 10px 4px 10px",color:"grey","font-size":"80%","font-style":"italic"}).text(c("Drag datasets here to copy them to the current history"))},dropTargetOff:function(){if(!this.dropTarget){return this}this.dropTarget=false;this.$(".history-drop-target").remove();this.$(".history-drop-target-help").remove();return this},dropTargetToggle:function(){if(this.dropTarget){this.dropTargetOff()}else{this.dropTargetOn()}return this},dragenter:function(m){m.preventDefault();m.stopPropagation();this.$(".history-drop-target").css("border","2px solid black")},dragover:function(m){m.preventDefault();m.stopPropagation()},dragleave:function(m){m.preventDefault();m.stopPropagation();this.$(".history-drop-target").css("border","1px dashed black")},drop:function(o){o.preventDefault();o.dataTransfer.dropEffect="move";var m=this,p=o.dataTransfer.getData("text");try{p=JSON.parse(p)}catch(n){this.warn("error parsing JSON from drop:",p)}this.trigger("droptarget:drop",o,p,m);return false},dataDropped:function(n){var m=this;if(_.isObject(n)&&n.model_class==="HistoryDatasetAssociation"&&n.id){return m.model.contents.copy(n.id)}return jQuery.when()},toString:function(){return"HistoryPanelEdit("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanelEdit:f}}); \ No newline at end of file diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/packed/mvc/history/history-panel.js --- a/static/scripts/packed/mvc/history/history-panel.js +++ b/static/scripts/packed/mvc/history/history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/list/list-panel","mvc/history/history-model","mvc/history/history-contents","mvc/history/hda-li","mvc/history/hdca-li","mvc/collection/collection-panel","mvc/user/user-model","mvc/base-mvc","utils/localization","jq-plugins/ui/search-input"],function(d,f,l,b,a,m,g,o,e){var j=o.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:false,show_hidden:false},addExpanded:function(p){var q="expandedIds";this.save(q,_.extend(this.get(q),_.object([p.id],[p.get("id")])))},removeExpanded:function(p){var q="expandedIds";this.save(q,_.omit(this.get(q),p.id))},toString:function(){return"HistoryPrefs("+this.id+")"}});j.storageKeyPrefix="history:";j.historyStorageKey=function h(p){if(!p){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+p)}return(j.storageKeyPrefix+p)};j.get=function c(p){return new j({id:j.historyStorageKey(p)})};j.clearAll=function i(q){for(var p in sessionStorage){if(p.indexOf(j.storageKeyPrefix)===0){sessionStorage.removeItem(p)}}};var n=d.ModelListPanel;var k=n.extend({HDAViewClass:b.HDAListItemView,HDCAViewClass:a.HDCAListItemView,collectionClass:l.HistoryContents,modelCollectionKey:"contents",tagName:"div",className:n.prototype.className+" history-panel",emptyMsg:e("This history is empty"),noneFoundMsg:e("No matching datasets found"),searchPlaceholder:e("search datasets"),initialize:function(p){n.prototype.initialize.call(this,p);this.linkTarget=p.linkTarget||"_blank"},freeModel:function(){n.prototype.freeModel.call(this);if(this.model){this.model.clearUpdateTimeout()}return this},_setUpListeners:function(){n.prototype._setUpListeners.call(this);this.on("error",function(q,t,p,s,r){this.errorHandler(q,t,p,s,r)});this.on("loading-done",function(){if(!this.views.length){this.trigger("empty-history",this)}})},loadHistoryWithDetails:function(s,r,q,t){this.info("loadHistoryWithDetails:",s,r,q,t);var p=function(u){return _.values(j.get(u.id).get("expandedIds"))};return this.loadHistory(s,r,q,t,p)},loadHistory:function(t,s,r,u,p){this.info("loadHistory:",t,s,r,u,p);var q=this;s=s||{};q.trigger("loading",q);var v=f.History.getHistoryData(t,{historyFn:r,contentsFn:u,detailIdsFn:s.initiallyExpanded||p});return q._loadHistoryFromXHR(v,s).fail(function(y,w,x){q.trigger("error",q,y,s,e("An error was encountered while "+w),{historyId:t,history:x||{}})}).always(function(){q.trigger("loading-done",q)})},_loadHistoryFromXHR:function(r,q){var p=this;r.then(function(s,t){p.JSONToModel(s,t,q);p.render()});r.fail(function(t,s){p.render()});return r},refreshContents:function(q,p){if(this.model){return this.model.refresh(q,p)}return $.when()},JSONToModel:function(s,p,q){this.log("JSONToModel:",s,p,q);q=q||{};var r=new f.History(s,p,q);this.setModel(r);return r},setModel:function(q,p){p=p||{};n.prototype.setModel.call(this,q,p);if(this.model){this._setUpWebStorage(p.initiallyExpanded,p.show_deleted,p.show_hidden)}},_setUpWebStorage:function(q,p,r){if(this.storage){this.stopListening(this.storage)}this.storage=new j({id:j.historyStorageKey(this.model.get("id"))});if(_.isObject(q)){this.storage.set("expandedIds",q)}if(_.isBoolean(p)){this.storage.set("show_deleted",p)}if(_.isBoolean(r)){this.storage.set("show_hidden",r)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());this.listenTo(this.storage,{"change:show_deleted":function(s,t){this.showDeleted=t},"change:show_hidden":function(s,t){this.showHidden=t}},this);this.showDeleted=(p!==undefined)?p:this.storage.get("show_deleted");this.showHidden=(r!==undefined)?r:this.storage.get("show_hidden");return this},_buildNewRender:function(){var p=n.prototype._buildNewRender.call(this);if(this.multiselectActions.length){p.find(".controls .actions").prepend(this._renderSelectButton())}return p},_renderSelectButton:function(p){return faIconButton({title:e("Operations on multiple datasets"),classes:"show-selectors-btn",faIcon:"fa-check-square-o"})},_getItemViewClass:function(p){var q=p.get("history_content_type");switch(q){case"dataset":return this.HDAViewClass;case"dataset_collection":return this.HDCAViewClass}throw new TypeError("Unknown history_content_type: "+q)},_filterItem:function(q){var p=this;return(n.prototype._filterItem.call(p,q)&&(!q.hidden()||p.showHidden)&&(!q.isDeletedOrPurged()||p.showDeleted))},_getItemViewOptions:function(q){var p=n.prototype._getItemViewOptions.call(this,q);return _.extend(p,{linkTarget:this.linkTarget,expanded:!!this.storage.get("expandedIds")[q.id],hasUser:this.model.ownedByCurrUser()})},_setUpItemViewListeners:function(q){var p=this;n.prototype._setUpItemViewListeners.call(p,q);q.on("expanded",function(r){p.storage.addExpanded(r.model)});q.on("collapsed",function(r){p.storage.removeExpanded(r.model)});return this},getSelectedModels:function(){var p=n.prototype.getSelectedModels.call(this);p.historyId=this.collection.historyId;return p},events:_.extend(_.clone(n.prototype.events),{"click .show-selectors-btn":"toggleSelectors"}),toggleShowDeleted:function(p,q){p=(p!==undefined)?(p):(!this.showDeleted);q=(q!==undefined)?(q):(true);this.showDeleted=p;if(q){this.storage.set("show_deleted",p)}this.trigger("show-hidden",p);this.renderItems();return this.showDeleted},toggleShowHidden:function(p,q){p=(p!==undefined)?(p):(!this.showHidden);q=(q!==undefined)?(q):(true);this.showHidden=p;if(q){this.storage.set("show_hidden",p)}this.trigger("show-hidden",p);this.renderItems();return this.showHidden},_firstSearch:function(p){var q=this,r=".history-search-input";this.log("onFirstSearch",p);if(q.model.contents.haveDetails()){q.searchItems(p);return}q.$el.find(r).searchInput("toggle-loading");q.model.contents.fetchAllDetails({silent:true}).always(function(){q.$el.find(r).searchInput("toggle-loading")}).done(function(){q.searchItems(p)})},errorHandler:function(r,u,q,t,s){this.error(r,u,q,t,s);if(u&&u.status===0&&u.readyState===0){}else{if(u&&u.status===502){}else{var p=this._parseErrorMessage(r,u,q,t,s);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",p.message,p.details)})}else{this.displayMessage("error",p.message,p.details)}}}},_parseErrorMessage:function(t,w,x,r,p,u){var s=Galaxy.currUser,v={message:this._bePolite(r),details:{message:r,raven:(window.Raven&&_.isFunction(Raven.lastEventId))?(Raven.lastEventId()):(undefined),agent:navigator.userAgent,url:(window.Galaxy)?(Galaxy.lastAjax.url):(undefined),data:(window.Galaxy)?(Galaxy.lastAjax.data):(undefined),options:(w)?(_.omit(x,"xhr")):(x),xhr:w,source:(_.isFunction(t.toJSON))?(t.toJSON()):(t+""),user:(s instanceof g.User)?(s.toJSON()):(s+"")}};_.extend(v.details,p||{});if(w&&_.isFunction(w.getAllResponseHeaders)){var q=w.getAllResponseHeaders();q=_.compact(q.split("\n"));q=_.map(q,function(y){return y.split(": ")});v.details.xhr.responseHeaders=_.object(q)}return v},_bePolite:function(p){p=p||e("An error occurred while getting updates from the server");return p+". "+e("Please contact a Galaxy administrator if the problem persists")+"."},displayMessage:function(u,v,t){var r=this;this.scrollToTop();var s=this.$messages(),p=$("<div/>").addClass(u+"message").html(v);if(!_.isEmpty(t)){var q=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(r._messageToModalOptions(u,v,t));return false});p.append(" ",q)}return s.html(p)},_messageToModalOptions:function(s,v,r){var p=this,q={title:"Details"};if(_.isObject(r)){r=_.omit(r,_.functions(r));var u=JSON.stringify(r,null," "),t=$("<pre/>").text(u);q.body=$("<div/>").append(t)}else{q.body=$("<div/>").html(r)}q.buttons={Ok:function(){Galaxy.modal.hide();p.clearMessages()}};return q},clearMessages:function(p){$(p.currentTarget).fadeOut(this.fxSpeed,function(){$(this).remove()});return this},scrollToHid:function(p){return this.scrollToItem(_.first(this.viewsWhereModel({hid:p})))},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});k.prototype.templates=(function(){var p=o.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= history.name %></div>',"</div>",'<div class="subtitle"></div>','<div class="history-size"><%= history.nice_size %></div>','<div class="actions"></div>','<div class="messages">',"<% if( history.deleted ){ %>",'<div class="deleted-msg warningmessagesmall">',e("This history has been deleted"),"</div>","<% } %>","<% if( history.message ){ %>",'<div class="<%= history.message.level || "info" %>messagesmall">',"<%= history.message.text %>","</div>","<% } %>","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',e("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',e("None"),"</button>","</div>",'<button class="list-action-popup-btn btn btn-default">',e("For all selected"),"...</button>","</div>","</div>"],"history");return _.extend(_.clone(n.prototype.templates),{controls:p})}());return{HistoryPanel:k}}); \ No newline at end of file +define(["mvc/list/list-panel","mvc/history/history-model","mvc/history/history-contents","mvc/history/hda-li","mvc/history/hdca-li","mvc/collection/collection-panel","mvc/user/user-model","jq-plugins/ui/fa-icon-button","mvc/base-mvc","utils/localization","jq-plugins/ui/search-input"],function(e,g,m,c,a,n,h,b,p,f){var k=p.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:false,show_hidden:false},addExpanded:function(q){var r="expandedIds";this.save(r,_.extend(this.get(r),_.object([q.id],[q.get("id")])))},removeExpanded:function(q){var r="expandedIds";this.save(r,_.omit(this.get(r),q.id))},toString:function(){return"HistoryPrefs("+this.id+")"}});k.storageKeyPrefix="history:";k.historyStorageKey=function i(q){if(!q){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+q)}return(k.storageKeyPrefix+q)};k.get=function d(q){return new k({id:k.historyStorageKey(q)})};k.clearAll=function j(r){for(var q in sessionStorage){if(q.indexOf(k.storageKeyPrefix)===0){sessionStorage.removeItem(q)}}};var o=e.ModelListPanel;var l=o.extend({HDAViewClass:c.HDAListItemView,HDCAViewClass:a.HDCAListItemView,collectionClass:m.HistoryContents,modelCollectionKey:"contents",tagName:"div",className:o.prototype.className+" history-panel",emptyMsg:f("This history is empty"),noneFoundMsg:f("No matching datasets found"),searchPlaceholder:f("search datasets"),initialize:function(q){o.prototype.initialize.call(this,q);this.linkTarget=q.linkTarget||"_blank"},freeModel:function(){o.prototype.freeModel.call(this);if(this.model){this.model.clearUpdateTimeout()}return this},_setUpListeners:function(){o.prototype._setUpListeners.call(this);this.on("error",function(r,u,q,t,s){this.errorHandler(r,u,q,t,s)});this.on("loading-done",function(){if(!this.views.length){this.trigger("empty-history",this)}})},loadHistoryWithDetails:function(t,s,r,u){this.info("loadHistoryWithDetails:",t,s,r,u);var q=function(v){return _.values(k.get(v.id).get("expandedIds"))};return this.loadHistory(t,s,r,u,q)},loadHistory:function(u,t,s,v,q){this.info("loadHistory:",u,t,s,v,q);var r=this;t=t||{};r.trigger("loading",r);var w=g.History.getHistoryData(u,{historyFn:s,contentsFn:v,detailIdsFn:t.initiallyExpanded||q});return r._loadHistoryFromXHR(w,t).fail(function(z,x,y){r.trigger("error",r,z,t,f("An error was encountered while "+x),{historyId:u,history:y||{}})}).always(function(){r.trigger("loading-done",r)})},_loadHistoryFromXHR:function(s,r){var q=this;s.then(function(t,u){q.JSONToModel(t,u,r);q.render()});s.fail(function(u,t){q.render()});return s},refreshContents:function(r,q){if(this.model){return this.model.refresh(r,q)}return $.when()},JSONToModel:function(t,q,r){this.log("JSONToModel:",t,q,r);r=r||{};var s=new g.History(t,q,r);this.setModel(s);return s},setModel:function(r,q){q=q||{};o.prototype.setModel.call(this,r,q);if(this.model){this._setUpWebStorage(q.initiallyExpanded,q.show_deleted,q.show_hidden)}},_setUpWebStorage:function(r,q,s){if(this.storage){this.stopListening(this.storage)}this.storage=new k({id:k.historyStorageKey(this.model.get("id"))});if(_.isObject(r)){this.storage.set("expandedIds",r)}if(_.isBoolean(q)){this.storage.set("show_deleted",q)}if(_.isBoolean(s)){this.storage.set("show_hidden",s)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());this.listenTo(this.storage,{"change:show_deleted":function(t,u){this.showDeleted=u},"change:show_hidden":function(t,u){this.showHidden=u}},this);this.showDeleted=(q!==undefined)?q:this.storage.get("show_deleted");this.showHidden=(s!==undefined)?s:this.storage.get("show_hidden");return this},_buildNewRender:function(){var q=o.prototype._buildNewRender.call(this);if(this.multiselectActions.length){q.find(".controls .actions").prepend(this._renderSelectButton())}return q},_renderSelectButton:function(q){return b({title:f("Operations on multiple datasets"),classes:"show-selectors-btn",faIcon:"fa-check-square-o"})},_getItemViewClass:function(q){var r=q.get("history_content_type");switch(r){case"dataset":return this.HDAViewClass;case"dataset_collection":return this.HDCAViewClass}throw new TypeError("Unknown history_content_type: "+r)},_filterItem:function(r){var q=this;return(o.prototype._filterItem.call(q,r)&&(!r.hidden()||q.showHidden)&&(!r.isDeletedOrPurged()||q.showDeleted))},_getItemViewOptions:function(r){var q=o.prototype._getItemViewOptions.call(this,r);return _.extend(q,{linkTarget:this.linkTarget,expanded:!!this.storage.get("expandedIds")[r.id],hasUser:this.model.ownedByCurrUser()})},_setUpItemViewListeners:function(r){var q=this;o.prototype._setUpItemViewListeners.call(q,r);r.on("expanded",function(s){q.storage.addExpanded(s.model)});r.on("collapsed",function(s){q.storage.removeExpanded(s.model)});return this},getSelectedModels:function(){var q=o.prototype.getSelectedModels.call(this);q.historyId=this.collection.historyId;return q},events:_.extend(_.clone(o.prototype.events),{"click .show-selectors-btn":"toggleSelectors"}),toggleShowDeleted:function(q,r){q=(q!==undefined)?(q):(!this.showDeleted);r=(r!==undefined)?(r):(true);this.showDeleted=q;if(r){this.storage.set("show_deleted",q)}this.trigger("show-hidden",q);this.renderItems();return this.showDeleted},toggleShowHidden:function(q,r){q=(q!==undefined)?(q):(!this.showHidden);r=(r!==undefined)?(r):(true);this.showHidden=q;if(r){this.storage.set("show_hidden",q)}this.trigger("show-hidden",q);this.renderItems();return this.showHidden},_firstSearch:function(q){var r=this,s=".history-search-input";this.log("onFirstSearch",q);if(r.model.contents.haveDetails()){r.searchItems(q);return}r.$el.find(s).searchInput("toggle-loading");r.model.contents.fetchAllDetails({silent:true}).always(function(){r.$el.find(s).searchInput("toggle-loading")}).done(function(){r.searchItems(q)})},errorHandler:function(s,v,r,u,t){this.error(s,v,r,u,t);if(v&&v.status===0&&v.readyState===0){}else{if(v&&v.status===502){}else{var q=this._parseErrorMessage(s,v,r,u,t);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",q.message,q.details)})}else{this.displayMessage("error",q.message,q.details)}}}},_parseErrorMessage:function(u,x,y,s,q,v){var t=Galaxy.currUser,w={message:this._bePolite(s),details:{message:s,raven:(window.Raven&&_.isFunction(Raven.lastEventId))?(Raven.lastEventId()):(undefined),agent:navigator.userAgent,url:(window.Galaxy)?(Galaxy.lastAjax.url):(undefined),data:(window.Galaxy)?(Galaxy.lastAjax.data):(undefined),options:(x)?(_.omit(y,"xhr")):(y),xhr:x,source:(_.isFunction(u.toJSON))?(u.toJSON()):(u+""),user:(t instanceof h.User)?(t.toJSON()):(t+"")}};_.extend(w.details,q||{});if(x&&_.isFunction(x.getAllResponseHeaders)){var r=x.getAllResponseHeaders();r=_.compact(r.split("\n"));r=_.map(r,function(z){return z.split(": ")});w.details.xhr.responseHeaders=_.object(r)}return w},_bePolite:function(q){q=q||f("An error occurred while getting updates from the server");return q+". "+f("Please contact a Galaxy administrator if the problem persists")+"."},displayMessage:function(v,w,u){var s=this;this.scrollToTop();var t=this.$messages(),q=$("<div/>").addClass(v+"message").html(w);if(!_.isEmpty(u)){var r=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(s._messageToModalOptions(v,w,u));return false});q.append(" ",r)}return t.html(q)},_messageToModalOptions:function(t,w,s){var q=this,r={title:"Details"};if(_.isObject(s)){s=_.omit(s,_.functions(s));var v=JSON.stringify(s,null," "),u=$("<pre/>").text(v);r.body=$("<div/>").append(u)}else{r.body=$("<div/>").html(s)}r.buttons={Ok:function(){Galaxy.modal.hide();q.clearMessages()}};return r},clearMessages:function(q){$(q.currentTarget).fadeOut(this.fxSpeed,function(){$(this).remove()});return this},scrollToHid:function(q){return this.scrollToItem(_.first(this.viewsWhereModel({hid:q})))},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});l.prototype.templates=(function(){var q=p.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= history.name %></div>',"</div>",'<div class="subtitle"></div>','<div class="history-size"><%= history.nice_size %></div>','<div class="actions"></div>','<div class="messages">',"<% if( history.deleted ){ %>",'<div class="deleted-msg warningmessagesmall">',f("This history has been deleted"),"</div>","<% } %>","<% if( history.message ){ %>",'<div class="<%= history.message.level || "info" %>messagesmall">',"<%= history.message.text %>","</div>","<% } %>","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',f("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',f("None"),"</button>","</div>",'<button class="list-action-popup-btn btn btn-default">',f("For all selected"),"...</button>","</div>","</div>"],"history");return _.extend(_.clone(o.prototype.templates),{controls:q})}());return{HistoryPanel:l}}); \ No newline at end of file diff -r 558cfd39bb3fc40486c894b77b55143785c0a0b6 -r 6c9848ad6d02691c7c68cd8faada68753126b472 static/scripts/packed/mvc/ui.js --- a/static/scripts/packed/mvc/ui.js +++ b/static/scripts/packed/mvc/ui.js @@ -1,1 +1,1 @@ -var IconButton=Backbone.Model.extend({defaults:{title:"",icon_class:"",on_click:null,menu_options:null,is_menu_button:true,id:null,href:null,target:null,enabled:true,visible:true,tooltip_config:{}}});var IconButtonView=Backbone.View.extend({initialize:function(){this.model.attributes.tooltip_config={placement:"bottom"};this.model.bind("change",this.render,this)},render:function(){this.$el.tooltip("hide");var a=this.template(this.model.toJSON());a.tooltip(this.model.get("tooltip_config"));this.$el.replaceWith(a);this.setElement(a);return this},events:{click:"click"},click:function(a){if(_.isFunction(this.model.get("on_click"))){this.model.get("on_click")(a);return false}return true},template:function(b){var a='title="'+b.title+'" class="icon-button';if(b.is_menu_button){a+=" menu-button"}a+=" "+b.icon_class;if(!b.enabled){a+="_disabled"}a+='"';if(b.id){a+=' id="'+b.id+'"'}a+=' href="'+b.href+'"';if(b.target){a+=' target="'+b.target+'"'}if(!b.visible){a+=' style="display: none;"'}if(b.enabled){a="<a "+a+"/>"}else{a="<span "+a+"/>"}return $(a)}});var IconButtonCollection=Backbone.Collection.extend({model:IconButton});var IconButtonMenuView=Backbone.View.extend({tagName:"div",initialize:function(){this.render()},render:function(){var a=this;this.collection.each(function(d){var b=$("<a/>").attr("href","javascript:void(0)").attr("title",d.attributes.title).addClass("icon-button menu-button").addClass(d.attributes.icon_class).appendTo(a.$el).click(d.attributes.on_click);if(d.attributes.tooltip_config){b.tooltip(d.attributes.tooltip_config)}var c=d.get("options");if(c){make_popupmenu(b,c)}});return this}});var create_icon_buttons_menu=function(b,a){if(!a){a={}}var c=new IconButtonCollection(_.map(b,function(d){return new IconButton(_.extend(d,a))}));return new IconButtonMenuView({collection:c})};var Grid=Backbone.Collection.extend({});var GridView=Backbone.View.extend({});var PopupMenu=Backbone.View.extend({initialize:function(b,a){this.$button=b;if(!this.$button.size()){this.$button=$("<div/>")}this.options=a||[];var c=this;this.$button.click(function(d){$(".popmenu-wrapper").remove();c._renderAndShow(d);return false})},_renderAndShow:function(a){this.render();this.$el.appendTo("body").css(this._getShownPosition(a)).show();this._setUpCloseBehavior()},render:function(){this.$el.addClass("popmenu-wrapper").hide().css({position:"absolute"}).html(this.template(this.$button.attr("id"),this.options));if(this.options.length){var a=this;this.$el.find("li").each(function(c,b){var d=a.options[c];if(d.func){$(this).children("a.popupmenu-option").click(function(e){d.func.call(a,e,d)})}})}return this},template:function(b,a){return['<ul id="',b,'-menu" class="dropdown-menu">',this._templateOptions(a),"</ul>"].join("")},_templateOptions:function(a){if(!a.length){return"<li>(no options)</li>"}return _.map(a,function(d){if(d.divider){return'<li class="divider"></li>'}else{if(d.header){return['<li class="head"><a href="javascript:void(0);">',d.html,"</a></li>"].join("")}}var c=d.href||"javascript:void(0);",e=(d.target)?(' target="'+d.target+'"'):(""),b=(d.checked)?('<span class="fa fa-check"></span>'):("");return['<li><a class="popupmenu-option" href="',c,'"',e,">",b,d.html,"</a></li>"].join("")}).join("")},_getShownPosition:function(b){var c=this.$el.width();var a=b.pageX-c/2;a=Math.min(a,$(document).scrollLeft()+$(window).width()-c-5);a=Math.max(a,$(document).scrollLeft()+5);return{top:b.pageY,left:a}},_setUpCloseBehavior:function(){var c=this;function a(e){$(document).off("click.close_popup");if(window.parent!==window){try{$(window.parent.document).off("click.close_popup")}catch(d){}}else{try{$("iframe#galaxy_main").contents().off("click.close_popup")}catch(d){}}c.remove()}$("html").one("click.close_popup",a);if(window.parent!==window){try{$(window.parent.document).find("html").one("click.close_popup",a)}catch(b){}}else{try{$("iframe#galaxy_main").contents().one("click.close_popup",a)}catch(b){}}},addItem:function(b,a){a=(a>=0)?a:this.options.length;this.options.splice(a,0,b);return this},removeItem:function(a){if(a>=0){this.options.splice(a,1)}return this},findIndexByHtml:function(b){for(var a=0;a<this.options.length;a++){if(_.has(this.options[a],"html")&&(this.options[a].html===b)){return a}}return null},findItemByHtml:function(a){return this.options[(this.findIndexByHtml(a))]},toString:function(){return"PopupMenu"}});PopupMenu.create=function _create(b,a){return new PopupMenu(b,a)};PopupMenu.make_popupmenu=function(b,c){var a=[];_.each(c,function(f,d){var e={html:d};if(f===null){e.header=true}else{if(jQuery.type(f)==="function"){e.func=f}}a.push(e)});return new PopupMenu($(b),a)};PopupMenu.convertLinksToOptions=function(c,a){c=$(c);a=a||"a";var b=[];c.find(a).each(function(g,e){var f={},d=$(g);f.html=d.text();if(d.attr("href")){var j=d.attr("href"),k=d.attr("target"),h=d.attr("confirm");f.func=function(){if((h)&&(!confirm(h))){return}switch(k){case"_parent":window.parent.location=j;break;case"_top":window.top.location=j;break;default:window.location=j}}}b.push(f)});return b};PopupMenu.fromExistingDom=function(d,c,a){d=$(d);c=$(c);var b=PopupMenu.convertLinksToOptions(c,a);c.remove();return new PopupMenu(d,b)};PopupMenu.make_popup_menus=function(c,b,d){c=c||document;b=b||"div[popupmenu]";d=d||function(e,f){return"#"+e.attr("popupmenu")};var a=[];$(c).find(b).each(function(){var e=$(this),f=$(c).find(d(e,c));a.push(PopupMenu.fromDom(f,e));f.addClass("popup")});return a};var faIconButton=function(a){a=a||{};a.tooltipConfig=a.tooltipConfig||{placement:"bottom"};a.classes=["icon-btn"].concat(a.classes||[]);if(a.disabled){a.classes.push("disabled")}var b=['<a class="',a.classes.join(" "),'"',((a.title)?(' title="'+a.title+'"'):("")),((!a.disabled&&a.target)?(' target="'+a.target+'"'):("")),' href="',((!a.disabled&&a.href)?(a.href):("javascript:void(0);")),'">','<span class="fa ',a.faIcon,'"></span>',"</a>"].join("");var c=$(b).tooltip(a.tooltipConfig);if(_.isFunction(a.onclick)){c.click(a.onclick)}return c}; \ No newline at end of file +var IconButton=Backbone.Model.extend({defaults:{title:"",icon_class:"",on_click:null,menu_options:null,is_menu_button:true,id:null,href:null,target:null,enabled:true,visible:true,tooltip_config:{}}});var IconButtonView=Backbone.View.extend({initialize:function(){this.model.attributes.tooltip_config={placement:"bottom"};this.model.bind("change",this.render,this)},render:function(){this.$el.tooltip("hide");var a=this.template(this.model.toJSON());a.tooltip(this.model.get("tooltip_config"));this.$el.replaceWith(a);this.setElement(a);return this},events:{click:"click"},click:function(a){if(_.isFunction(this.model.get("on_click"))){this.model.get("on_click")(a);return false}return true},template:function(b){var a='title="'+b.title+'" class="icon-button';if(b.is_menu_button){a+=" menu-button"}a+=" "+b.icon_class;if(!b.enabled){a+="_disabled"}a+='"';if(b.id){a+=' id="'+b.id+'"'}a+=' href="'+b.href+'"';if(b.target){a+=' target="'+b.target+'"'}if(!b.visible){a+=' style="display: none;"'}if(b.enabled){a="<a "+a+"/>"}else{a="<span "+a+"/>"}return $(a)}});var IconButtonCollection=Backbone.Collection.extend({model:IconButton});var IconButtonMenuView=Backbone.View.extend({tagName:"div",initialize:function(){this.render()},render:function(){var a=this;this.collection.each(function(d){var b=$("<a/>").attr("href","javascript:void(0)").attr("title",d.attributes.title).addClass("icon-button menu-button").addClass(d.attributes.icon_class).appendTo(a.$el).click(d.attributes.on_click);if(d.attributes.tooltip_config){b.tooltip(d.attributes.tooltip_config)}var c=d.get("options");if(c){make_popupmenu(b,c)}});return this}});var create_icon_buttons_menu=function(b,a){if(!a){a={}}var c=new IconButtonCollection(_.map(b,function(d){return new IconButton(_.extend(d,a))}));return new IconButtonMenuView({collection:c})};var Grid=Backbone.Collection.extend({});var GridView=Backbone.View.extend({});var PopupMenu=Backbone.View.extend({initialize:function(b,a){this.$button=b;if(!this.$button.size()){this.$button=$("<div/>")}this.options=a||[];var c=this;this.$button.click(function(d){$(".popmenu-wrapper").remove();c._renderAndShow(d);return false})},_renderAndShow:function(a){this.render();this.$el.appendTo("body").css(this._getShownPosition(a)).show();this._setUpCloseBehavior()},render:function(){this.$el.addClass("popmenu-wrapper").hide().css({position:"absolute"}).html(this.template(this.$button.attr("id"),this.options));if(this.options.length){var a=this;this.$el.find("li").each(function(c,b){var d=a.options[c];if(d.func){$(this).children("a.popupmenu-option").click(function(e){d.func.call(a,e,d)})}})}return this},template:function(b,a){return['<ul id="',b,'-menu" class="dropdown-menu">',this._templateOptions(a),"</ul>"].join("")},_templateOptions:function(a){if(!a.length){return"<li>(no options)</li>"}return _.map(a,function(d){if(d.divider){return'<li class="divider"></li>'}else{if(d.header){return['<li class="head"><a href="javascript:void(0);">',d.html,"</a></li>"].join("")}}var c=d.href||"javascript:void(0);",e=(d.target)?(' target="'+d.target+'"'):(""),b=(d.checked)?('<span class="fa fa-check"></span>'):("");return['<li><a class="popupmenu-option" href="',c,'"',e,">",b,d.html,"</a></li>"].join("")}).join("")},_getShownPosition:function(b){var c=this.$el.width();var a=b.pageX-c/2;a=Math.min(a,$(document).scrollLeft()+$(window).width()-c-5);a=Math.max(a,$(document).scrollLeft()+5);return{top:b.pageY,left:a}},_setUpCloseBehavior:function(){var c=this;function a(e){$(document).off("click.close_popup");if(window.parent!==window){try{$(window.parent.document).off("click.close_popup")}catch(d){}}else{try{$("iframe#galaxy_main").contents().off("click.close_popup")}catch(d){}}c.remove()}$("html").one("click.close_popup",a);if(window.parent!==window){try{$(window.parent.document).find("html").one("click.close_popup",a)}catch(b){}}else{try{$("iframe#galaxy_main").contents().one("click.close_popup",a)}catch(b){}}},addItem:function(b,a){a=(a>=0)?a:this.options.length;this.options.splice(a,0,b);return this},removeItem:function(a){if(a>=0){this.options.splice(a,1)}return this},findIndexByHtml:function(b){for(var a=0;a<this.options.length;a++){if(_.has(this.options[a],"html")&&(this.options[a].html===b)){return a}}return null},findItemByHtml:function(a){return this.options[(this.findIndexByHtml(a))]},toString:function(){return"PopupMenu"}});PopupMenu.create=function _create(b,a){return new PopupMenu(b,a)};PopupMenu.make_popupmenu=function(b,c){var a=[];_.each(c,function(f,d){var e={html:d};if(f===null){e.header=true}else{if(jQuery.type(f)==="function"){e.func=f}}a.push(e)});return new PopupMenu($(b),a)};PopupMenu.convertLinksToOptions=function(c,a){c=$(c);a=a||"a";var b=[];c.find(a).each(function(g,e){var f={},d=$(g);f.html=d.text();if(d.attr("href")){var j=d.attr("href"),k=d.attr("target"),h=d.attr("confirm");f.func=function(){if((h)&&(!confirm(h))){return}switch(k){case"_parent":window.parent.location=j;break;case"_top":window.top.location=j;break;default:window.location=j}}}b.push(f)});return b};PopupMenu.fromExistingDom=function(d,c,a){d=$(d);c=$(c);var b=PopupMenu.convertLinksToOptions(c,a);c.remove();return new PopupMenu(d,b)};PopupMenu.make_popup_menus=function(c,b,d){c=c||document;b=b||"div[popupmenu]";d=d||function(e,f){return"#"+e.attr("popupmenu")};var a=[];$(c).find(b).each(function(){var e=$(this),f=$(c).find(d(e,c));a.push(PopupMenu.fromDom(f,e));f.addClass("popup")});return a}; \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.