galaxy-commits
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
September 2014
- 2 participants
- 236 discussions
commit/galaxy-central: guerler: Upload: Minor fix, wait for history in show function
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/3e6c63c296e4/
Changeset: 3e6c63c296e4
User: guerler
Date: 2014-09-29 18:24:21+00:00
Summary: Upload: Minor fix, wait for history in show function
Affected #: 3 files
diff -r b8efe7496a7e591450722765cdca0307ffad957f -r 3e6c63c296e43c0dfbb43c8070365a5b2b2ac3a1 client/galaxy/scripts/mvc/upload/upload-view.js
--- a/client/galaxy/scripts/mvc/upload/upload-view.js
+++ b/client/galaxy/scripts/mvc/upload/upload-view.js
@@ -83,12 +83,6 @@
this.options = _.defaults(options, this.options);
}
- // wait for galaxy history panel (workaround due to the use of iframes)
- if (!Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model) {
- window.setTimeout(function() { self.initialize() }, 500)
- return;
- }
-
// create model
this.ui_button = new UploadButton.Model({
icon : 'fa-upload',
@@ -173,6 +167,13 @@
// show/hide upload frame
show: function () {
+ // wait for galaxy history panel
+ var self = this;
+ if (!Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model) {
+ window.setTimeout(function() { self.show() }, 500)
+ return;
+ }
+
// create modal
if (!this.modal) {
// make modal
diff -r b8efe7496a7e591450722765cdca0307ffad957f -r 3e6c63c296e43c0dfbb43c8070365a5b2b2ac3a1 static/scripts/mvc/upload/upload-view.js
--- a/static/scripts/mvc/upload/upload-view.js
+++ b/static/scripts/mvc/upload/upload-view.js
@@ -83,12 +83,6 @@
this.options = _.defaults(options, this.options);
}
- // wait for galaxy history panel (workaround due to the use of iframes)
- if (!Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model) {
- window.setTimeout(function() { self.initialize() }, 500)
- return;
- }
-
// create model
this.ui_button = new UploadButton.Model({
icon : 'fa-upload',
@@ -173,6 +167,13 @@
// show/hide upload frame
show: function () {
+ // wait for galaxy history panel
+ var self = this;
+ if (!Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model) {
+ window.setTimeout(function() { self.show() }, 500)
+ return;
+ }
+
// create modal
if (!this.modal) {
// make modal
diff -r b8efe7496a7e591450722765cdca0307ffad957f -r 3e6c63c296e43c0dfbb43c8070365a5b2b2ac3a1 static/scripts/packed/mvc/upload/upload-view.js
--- a/static/scripts/packed/mvc/upload/upload-view.js
+++ b/static/scripts/packed/mvc/upload/upload-view.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/upload/upload-button","mvc/upload/upload-model","mvc/upload/upload-row","mvc/upload/upload-ftp","mvc/ui/ui-popover","mvc/ui/ui-modal","mvc/ui","utils/uploadbox"],function(f,e,c,b,g,d,a){return Backbone.View.extend({options:{nginx_upload_path:""},modal:null,ui_button:null,uploadbox:null,current_history:null,upload_size:0,list_extensions:[],list_genomes:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},collection:new c.Collection(),ftp:null,counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},initialize:function(i){var h=this;if(i){this.options=_.defaults(i,this.options)}if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){h.initialize()},500);return}this.ui_button=new e.Model({icon:"fa-upload",tooltip:"Download from URL or upload files from disk",label:"Load Data",onclick:function(j){if(j){j.preventDefault();h.show()}},onunload:function(){if(h.counter.running>0){return"Several uploads are still processing."}}});$("#left .unified-panel-header-inner").append((new e.View(this.ui_button)).$el);var h=this;f.get(galaxy_config.root+"api/datatypes?extension_only=False",function(j){for(key in j){h.list_extensions.push({id:j[key].extension,text:j[key].extension,description:j[key].description,description_url:j[key].description_url})}h.list_extensions.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0});if(!h.options.datatypes_disable_auto){h.list_extensions.unshift(h.auto)}});f.get(galaxy_config.root+"api/genomes",function(j){for(key in j){h.list_genomes.push({id:j[key][1],text:j[key][0]})}h.list_genomes.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0})});this.collection.on("remove",function(j){h._eventRemove(j)});this.collection.on("change:genome",function(k){var j=k.get("genome");h.collection.each(function(l){if(l.get("status")=="init"&&l.get("genome")=="?"){l.set("genome",j)}})})},show:function(){if(!this.modal){var h=this;this.modal=new a.View({title:"Download data directly from web or upload files from your disk",body:this._template("upload-box","upload-info"),buttons:{"Choose local file":function(){h.uploadbox.select()},"Choose FTP file":function(){h._eventFtp()},"Paste/Fetch data":function(){h._eventCreate()},Start:function(){h._eventStart()},Pause:function(){h._eventStop()},Reset:function(){h._eventReset()},Close:function(){h.modal.hide()},},height:"400",width:"900",closing_events:true});this.setElement("#upload-box");var h=this;this.uploadbox=this.$el.uploadbox({announce:function(j,k,l){h._eventAnnounce(j,k,l)},initialize:function(j,k,l){return h._eventInitialize(j,k,l)},progress:function(j,k,l){h._eventProgress(j,k,l)},success:function(j,k,l){h._eventSuccess(j,k,l)},error:function(j,k,l){h._eventError(j,k,l)},complete:function(){h._eventComplete()}});var i=this.modal.getButton("Choose FTP file");this.ftp=new d.View({title:"FTP files",container:i})}this.modal.show();this._updateUser();this._updateScreen()},_eventRemove:function(i){var h=i.get("status");if(h=="success"){this.counter.success--}else{if(h=="error"){this.counter.error--}else{this.counter.announce--}}this._updateScreen();this.uploadbox.remove(i.id)},_eventAnnounce:function(h,i,k){this.counter.announce++;this._updateScreen();var j=new b(this,{id:h,file_name:i.name,file_size:i.size,file_mode:i.mode,file_path:i.path});this.collection.add(j.model);$(this.el).find("tbody:first").append(j.$el);j.render()},_eventInitialize:function(m,j,s){var k=this.collection.get(m);k.set("status","running");var o=k.get("file_name");var n=k.get("file_path");var h=k.get("file_mode");var p=k.get("extension");var r=k.get("genome");var q=k.get("url_paste");var l=k.get("space_to_tabs");var i=k.get("to_posix_lines");if(!q&&!(j.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path});if(h=="local"){this.uploadbox.configure({paramname:"files_0|file_data"})}else{this.uploadbox.configure({paramname:null})}tool_input={};if(h=="new"){tool_input["files_0|url_paste"]=q}if(h=="ftp"){tool_input["files_0|ftp_files"]=n}tool_input.dbkey=r;tool_input.file_type=p;tool_input["files_0|type"]="upload_dataset";tool_input.space_to_tabs=l;tool_input.to_posix_lines=i;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},_eventProgress:function(i,j,h){var k=this.collection.get(i);k.set("percentage",h);this.ui_button.set("percentage",this._upload_percentage(h,j.size))},_eventSuccess:function(i,j,l){var k=this.collection.get(i);k.set("percentage",100);k.set("status","success");var h=k.get("file_size");this.ui_button.set("percentage",this._upload_percentage(100,h));this.upload_completed+=h*100;this.counter.announce--;this.counter.success++;this._updateScreen();Galaxy.currHistoryPanel.refreshContents()},_eventError:function(h,i,k){var j=this.collection.get(h);j.set("percentage",100);j.set("status","error");j.set("info",k);this.ui_button.set("percentage",this._upload_percentage(100,i.size));this.ui_button.set("status","danger");this.upload_completed+=i.size*100;this.counter.announce--;this.counter.error++;this._updateScreen()},_eventComplete:function(){this.collection.each(function(h){if(h.get("status")=="queued"){h.set("status","init")}});this.counter.running=0;this._updateScreen()},_eventFtp:function(){if(!this.ftp.visible){this.ftp.empty();this.ftp.append((new g(this)).$el);this.ftp.show()}else{this.ftp.hide()}},_eventCreate:function(){this.uploadbox.add([{name:"New File",size:0,mode:"new"}])},_eventStart:function(){if(this.counter.announce==0||this.counter.running>0){return}var h=this;this.upload_size=0;this.upload_completed=0;this.collection.each(function(i){if(i.get("status")=="init"){i.set("status","queued");h.upload_size+=i.get("file_size")}});this.ui_button.set("percentage",0);this.ui_button.set("status","success");this.counter.running=this.counter.announce;this._updateScreen();this.uploadbox.start()},_eventStop:function(){if(this.counter.running==0){return}this.ui_button.set("status","info");this.uploadbox.stop();$("#upload-info").html("Queue will pause after completing the current file...")},_eventReset:function(){if(this.counter.running==0){this.collection.reset();this.counter.reset();this._updateScreen();this.uploadbox.reset();this.ui_button.set("percentage",0)}},_updateUser:function(){this.current_user=Galaxy.currUser.get("id");this.current_history=null;if(this.current_user){this.current_history=Galaxy.currHistoryPanel.model.get("id")}},_updateScreen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible()){message="You can Drag & Drop files into this box."}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Some supported browsers are: Firefox 4+, Chrome 7+, IE 10+, Opera 12+ or Safari 6+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Start' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Start")}else{this.modal.disableButton("Start")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Choose local file");this.modal.enableButton("Choose FTP file");this.modal.enableButton("Paste/Fetch data")}else{this.modal.disableButton("Choose local file");this.modal.disableButton("Choose FTP file");this.modal.disableButton("Paste/Fetch data")}if(this.current_user&&this.options.ftp_upload_dir&&this.options.ftp_upload_site){this.modal.showButton("Choose FTP file")}else{this.modal.hideButton("Choose FTP file")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("#upload-table").show()}else{$(this.el).find("#upload-table").hide()}},_upload_percentage:function(h,i){return(this.upload_completed+(h*i))/this.upload_size},_template:function(i,h){return'<div id="'+i+'" class="upload-box"><table id="upload-table" class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Genome</th><th>Settings</th><th>Status</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+h+'" class="upload-info"></h6>'}})});
\ No newline at end of file
+define(["utils/utils","mvc/upload/upload-button","mvc/upload/upload-model","mvc/upload/upload-row","mvc/upload/upload-ftp","mvc/ui/ui-popover","mvc/ui/ui-modal","mvc/ui","utils/uploadbox"],function(f,e,c,b,g,d,a){return Backbone.View.extend({options:{nginx_upload_path:""},modal:null,ui_button:null,uploadbox:null,current_history:null,upload_size:0,list_extensions:[],list_genomes:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},collection:new c.Collection(),ftp:null,counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},initialize:function(i){var h=this;if(i){this.options=_.defaults(i,this.options)}this.ui_button=new e.Model({icon:"fa-upload",tooltip:"Download from URL or upload files from disk",label:"Load Data",onclick:function(j){if(j){j.preventDefault();h.show()}},onunload:function(){if(h.counter.running>0){return"Several uploads are still processing."}}});$("#left .unified-panel-header-inner").append((new e.View(this.ui_button)).$el);var h=this;f.get(galaxy_config.root+"api/datatypes?extension_only=False",function(j){for(key in j){h.list_extensions.push({id:j[key].extension,text:j[key].extension,description:j[key].description,description_url:j[key].description_url})}h.list_extensions.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0});if(!h.options.datatypes_disable_auto){h.list_extensions.unshift(h.auto)}});f.get(galaxy_config.root+"api/genomes",function(j){for(key in j){h.list_genomes.push({id:j[key][1],text:j[key][0]})}h.list_genomes.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0})});this.collection.on("remove",function(j){h._eventRemove(j)});this.collection.on("change:genome",function(k){var j=k.get("genome");h.collection.each(function(l){if(l.get("status")=="init"&&l.get("genome")=="?"){l.set("genome",j)}})})},show:function(){var h=this;if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){h.show()},500);return}if(!this.modal){var h=this;this.modal=new a.View({title:"Download data directly from web or upload files from your disk",body:this._template("upload-box","upload-info"),buttons:{"Choose local file":function(){h.uploadbox.select()},"Choose FTP file":function(){h._eventFtp()},"Paste/Fetch data":function(){h._eventCreate()},Start:function(){h._eventStart()},Pause:function(){h._eventStop()},Reset:function(){h._eventReset()},Close:function(){h.modal.hide()},},height:"400",width:"900",closing_events:true});this.setElement("#upload-box");var h=this;this.uploadbox=this.$el.uploadbox({announce:function(j,k,l){h._eventAnnounce(j,k,l)},initialize:function(j,k,l){return h._eventInitialize(j,k,l)},progress:function(j,k,l){h._eventProgress(j,k,l)},success:function(j,k,l){h._eventSuccess(j,k,l)},error:function(j,k,l){h._eventError(j,k,l)},complete:function(){h._eventComplete()}});var i=this.modal.getButton("Choose FTP file");this.ftp=new d.View({title:"FTP files",container:i})}this.modal.show();this._updateUser();this._updateScreen()},_eventRemove:function(i){var h=i.get("status");if(h=="success"){this.counter.success--}else{if(h=="error"){this.counter.error--}else{this.counter.announce--}}this._updateScreen();this.uploadbox.remove(i.id)},_eventAnnounce:function(h,i,k){this.counter.announce++;this._updateScreen();var j=new b(this,{id:h,file_name:i.name,file_size:i.size,file_mode:i.mode,file_path:i.path});this.collection.add(j.model);$(this.el).find("tbody:first").append(j.$el);j.render()},_eventInitialize:function(m,j,s){var k=this.collection.get(m);k.set("status","running");var o=k.get("file_name");var n=k.get("file_path");var h=k.get("file_mode");var p=k.get("extension");var r=k.get("genome");var q=k.get("url_paste");var l=k.get("space_to_tabs");var i=k.get("to_posix_lines");if(!q&&!(j.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path});if(h=="local"){this.uploadbox.configure({paramname:"files_0|file_data"})}else{this.uploadbox.configure({paramname:null})}tool_input={};if(h=="new"){tool_input["files_0|url_paste"]=q}if(h=="ftp"){tool_input["files_0|ftp_files"]=n}tool_input.dbkey=r;tool_input.file_type=p;tool_input["files_0|type"]="upload_dataset";tool_input.space_to_tabs=l;tool_input.to_posix_lines=i;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},_eventProgress:function(i,j,h){var k=this.collection.get(i);k.set("percentage",h);this.ui_button.set("percentage",this._upload_percentage(h,j.size))},_eventSuccess:function(i,j,l){var k=this.collection.get(i);k.set("percentage",100);k.set("status","success");var h=k.get("file_size");this.ui_button.set("percentage",this._upload_percentage(100,h));this.upload_completed+=h*100;this.counter.announce--;this.counter.success++;this._updateScreen();Galaxy.currHistoryPanel.refreshContents()},_eventError:function(h,i,k){var j=this.collection.get(h);j.set("percentage",100);j.set("status","error");j.set("info",k);this.ui_button.set("percentage",this._upload_percentage(100,i.size));this.ui_button.set("status","danger");this.upload_completed+=i.size*100;this.counter.announce--;this.counter.error++;this._updateScreen()},_eventComplete:function(){this.collection.each(function(h){if(h.get("status")=="queued"){h.set("status","init")}});this.counter.running=0;this._updateScreen()},_eventFtp:function(){if(!this.ftp.visible){this.ftp.empty();this.ftp.append((new g(this)).$el);this.ftp.show()}else{this.ftp.hide()}},_eventCreate:function(){this.uploadbox.add([{name:"New File",size:0,mode:"new"}])},_eventStart:function(){if(this.counter.announce==0||this.counter.running>0){return}var h=this;this.upload_size=0;this.upload_completed=0;this.collection.each(function(i){if(i.get("status")=="init"){i.set("status","queued");h.upload_size+=i.get("file_size")}});this.ui_button.set("percentage",0);this.ui_button.set("status","success");this.counter.running=this.counter.announce;this._updateScreen();this.uploadbox.start()},_eventStop:function(){if(this.counter.running==0){return}this.ui_button.set("status","info");this.uploadbox.stop();$("#upload-info").html("Queue will pause after completing the current file...")},_eventReset:function(){if(this.counter.running==0){this.collection.reset();this.counter.reset();this._updateScreen();this.uploadbox.reset();this.ui_button.set("percentage",0)}},_updateUser:function(){this.current_user=Galaxy.currUser.get("id");this.current_history=null;if(this.current_user){this.current_history=Galaxy.currHistoryPanel.model.get("id")}},_updateScreen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible()){message="You can Drag & Drop files into this box."}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Some supported browsers are: Firefox 4+, Chrome 7+, IE 10+, Opera 12+ or Safari 6+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Start' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Start")}else{this.modal.disableButton("Start")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Choose local file");this.modal.enableButton("Choose FTP file");this.modal.enableButton("Paste/Fetch data")}else{this.modal.disableButton("Choose local file");this.modal.disableButton("Choose FTP file");this.modal.disableButton("Paste/Fetch data")}if(this.current_user&&this.options.ftp_upload_dir&&this.options.ftp_upload_site){this.modal.showButton("Choose FTP file")}else{this.modal.hideButton("Choose FTP file")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("#upload-table").show()}else{$(this.el).find("#upload-table").hide()}},_upload_percentage:function(h,i){return(this.upload_completed+(h*i))/this.upload_size},_template:function(i,h){return'<div id="'+i+'" class="upload-box"><table id="upload-table" class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Genome</th><th>Settings</th><th>Status</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+h+'" class="upload-info"></h6>'}})});
\ 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.
1
0
commit/galaxy-central: guerler: Ui: Open the upload modal if the upload tool is selected from the tool panel, fix code style for masthead and menu views
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/b8efe7496a7e/
Changeset: b8efe7496a7e
User: guerler
Date: 2014-09-29 18:10:42+00:00
Summary: Ui: Open the upload modal if the upload tool is selected from the tool panel, fix code style for masthead and menu views
Affected #: 12 files
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f client/galaxy/scripts/galaxy.frame.js
--- a/client/galaxy/scripts/galaxy.frame.js
+++ b/client/galaxy/scripts/galaxy.frame.js
@@ -1,9 +1,8 @@
// dependencies
define(["galaxy.masthead", "mvc/ui/ui-frames"], function(mod_masthead, Frames) {
-// frame manager
-var GalaxyFrame = Backbone.View.extend(
-{
+/** Frame manager uses the ui-frames to create the scratch book masthead icon and functionality **/
+var GalaxyFrame = Backbone.View.extend({
// base element
el_main: 'body',
@@ -17,8 +16,7 @@
button_load : null,
// initialize
- initialize : function(options)
- {
+ initialize : function(options) {
// add to masthead menu
var self = this;
@@ -28,8 +26,7 @@
});
// add activate icon
- this.button_active = new mod_masthead.GalaxyMastheadIcon (
- {
+ this.button_active = new mod_masthead.GalaxyMastheadIcon({
icon : 'fa-th',
tooltip : 'Enable/Disable Scratchbook',
onclick : function() { self._activate(); },
@@ -44,8 +41,7 @@
Galaxy.masthead.append(this.button_active);
// add load icon
- this.button_load = new mod_masthead.GalaxyMastheadIcon (
- {
+ this.button_load = new mod_masthead.GalaxyMastheadIcon({
icon : 'fa-eye',
tooltip : 'Show/Hide Scratchbook',
onclick : function(e) {
@@ -126,31 +122,25 @@
/**
* Add and display a new frame/window based on options.
*/
- add: function(options)
- {
+ add: function(options){
// open new tab
- if (options.target == '_blank')
- {
+ if (options.target == '_blank'){
window.open(options.content);
return;
}
// reload entire window
- if (options.target == '_top' || options.target == '_parent' || options.target == '_self')
- {
+ if (options.target == '_top' || options.target == '_parent' || options.target == '_self'){
window.location = options.content;
return;
}
// validate
- if (!this.active)
- {
+ if (!this.active){
// fix url if main frame is unavailable
var $galaxy_main = $(window.parent.document).find('#galaxy_main');
- if (options.target == 'galaxy_main' || options.target == 'center')
- {
- if ($galaxy_main.length === 0)
- {
+ if (options.target == 'galaxy_main' || options.target == 'center'){
+ if ($galaxy_main.length === 0){
var href = options.content;
if (href.indexOf('?') == -1)
href += '?';
@@ -173,11 +163,9 @@
},
// activate/disable panel
- _activate: function ()
- {
+ _activate: function (){
// check
- if (this.active)
- {
+ if (this.active){
// disable
this.active = false;
@@ -196,8 +184,7 @@
},
// update frame counter
- _refresh: function()
- {
+ _refresh: function(){
// update on screen counter
this.button_load.number(this.frames.length());
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f client/galaxy/scripts/galaxy.masthead.js
--- a/client/galaxy/scripts/galaxy.masthead.js
+++ b/client/galaxy/scripts/galaxy.masthead.js
@@ -1,9 +1,8 @@
// dependencies
define([], function() {
-// masthead
-var GalaxyMasthead = Backbone.View.extend(
-{
+/** Masthead **/
+var GalaxyMasthead = Backbone.View.extend({
// base element
el_masthead: '#everything',
@@ -17,8 +16,7 @@
list: [],
// initialize
- initialize : function(options)
- {
+ initialize : function(options) {
// update options
this.options = options;
@@ -51,27 +49,23 @@
},
// configure events
- events:
- {
+ events: {
'click' : '_click',
'mousedown' : function(e) { e.preventDefault() }
},
// adds a new item to the masthead
- append : function(item)
- {
+ append : function(item) {
return this._add(item, true);
},
// adds a new item to the masthead
- prepend : function(item)
- {
+ prepend : function(item) {
return this._add(item, false);
},
// activate
- highlight: function(id)
- {
+ highlight: function(id) {
var current = $(this.el).find('#' + id + '> li');
if (current) {
current.addClass('active');
@@ -79,11 +73,9 @@
},
// adds a new item to the masthead
- _add : function(item, append)
- {
+ _add : function(item, append) {
var $loc = $(this.el).find('#' + item.location);
- if ($loc)
- {
+ if ($loc){
// create frame for new item
var $current = $(item.el);
@@ -106,8 +98,7 @@
},
// handle click event
- _click: function(e)
- {
+ _click: function(e) {
// close all popups
var $all = $(this.el).find('.popup');
if ($all) {
@@ -129,8 +120,7 @@
*/
// fill template
- _template: function(options)
- {
+ _template: function(options) {
var brand_text = options.brand ? ("/ " + options.brand) : "" ;
return '<div><div id="masthead" class="navbar navbar-fixed-top navbar-inverse">' +
'<div style="position: relative; right: -50%; float: left;">' +
@@ -150,12 +140,10 @@
}
});
-// icon
-var GalaxyMastheadIcon = Backbone.View.extend(
-{
+/** Masthead icon **/
+var GalaxyMastheadIcon = Backbone.View.extend({
// icon options
- options:
- {
+ options:{
id : '',
icon : 'fa-cog',
tooltip : '',
@@ -169,8 +157,7 @@
location: 'iconbar',
// initialize
- initialize: function (options)
- {
+ initialize: function (options){
// read in defaults
if (options)
this.options = _.defaults(options, this.options);
@@ -189,20 +176,17 @@
},
// show
- show: function()
- {
+ show: function(){
$(this.el).css({visibility : 'visible'});
},
// show
- hide: function()
- {
+ hide: function(){
$(this.el).css({visibility : 'hidden'});
},
// switch icon
- icon: function (new_icon)
- {
+ icon: function (new_icon){
// update icon class
$(this.el).find('.icon').removeClass(this.options.icon)
.addClass(new_icon);
@@ -212,26 +196,22 @@
},
// toggle
- toggle: function()
- {
+ toggle: function(){
$(this.el).addClass('toggle');
},
// untoggle
- untoggle: function()
- {
+ untoggle: function(){
$(this.el).removeClass('toggle');
},
// set/get number
- number: function(new_number)
- {
+ number: function(new_number){
$(this.el).find('.number').text(new_number);
},
// fill template icon
- _template: function (options)
- {
+ _template: function (options){
var tmpl = '<div id="' + options.id + '" class="symbol">' +
'<div class="icon fa fa-2x ' + options.icon + '"></div>';
if (options.with_number)
@@ -243,12 +223,10 @@
}
});
-// tab
-var GalaxyMastheadTab = Backbone.View.extend(
-{
+/** Masthead tab **/
+var GalaxyMastheadTab = Backbone.View.extend({
// main options
- options:
- {
+ options:{
id : '',
title : '',
target : '_parent',
@@ -268,14 +246,12 @@
$menu: null,
// events
- events:
- {
+ events:{
'click .head' : '_head'
},
// initialize
- initialize: function (options)
- {
+ initialize: function (options){
// read in defaults
if (options)
this.options = _.defaults(options, this.options);
@@ -300,20 +276,17 @@
},
// show
- show: function()
- {
+ show: function(){
$(this.el).css({visibility : 'visible'});
},
// show
- hide: function()
- {
+ hide: function(){
$(this.el).css({visibility : 'hidden'});
},
// add menu item
- add: function (options)
- {
+ add: function (options){
// menu option defaults
var menuOptions = {
title : 'Title',
@@ -333,8 +306,7 @@
menuOptions.content = galaxy_config.root + menuOptions.content;
// check if submenu element is available
- if (!this.$menu)
- {
+ if (!this.$menu){
// insert submenu element into root
$(this.el).find('.root').append(this._templateMenu());
@@ -353,8 +325,7 @@
// add events
var self = this;
- $item.on('click', function(e)
- {
+ $item.on('click', function(e){
// prevent default
e.preventDefault();
@@ -372,8 +343,7 @@
},
// show menu on header click
- _head: function(e)
- {
+ _head: function(e){
// prevent default
e.preventDefault();
@@ -387,8 +357,7 @@
}
},
- _attachPopover : function()
- {
+ _attachPopover : function(){
var $popover_element = $(this.el).find('.head');
$popover_element.popover({
html: true,
@@ -402,25 +371,21 @@
},
// fill template header
- _templateMenuItem: function (options)
- {
+ _templateMenuItem: function (options){
return '<li><a href="' + options.content + '" target="' + options.target + '">' + options.title + '</a></li>';
},
// fill template header
- _templateMenu: function ()
- {
+ _templateMenu: function (){
return '<ul class="popup dropdown-menu"></ul>';
},
- _templateDivider: function()
- {
+ _templateDivider: function(){
return '<li class="divider"></li>';
},
// fill template
- _template: function (options)
- {
+ _template: function (options){
// start template
var tmpl = '<ul id="' + options.id + '" class="nav navbar-nav" border="0" cellspacing="0">' +
'<li class="root dropdown" style="">' +
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f client/galaxy/scripts/galaxy.menu.js
--- a/client/galaxy/scripts/galaxy.menu.js
+++ b/client/galaxy/scripts/galaxy.menu.js
@@ -1,13 +1,8 @@
-/*
- galaxy menu
-*/
-
// dependencies
define(["galaxy.masthead"], function(mod_masthead) {
-// frame manager
-var GalaxyMenu = Backbone.Model.extend(
-{
+/** GalaxyMenu uses the GalaxyMasthead class in order to add menu items and icons to the Masthead **/
+var GalaxyMenu = Backbone.Model.extend({
// options
options: null,
@@ -15,16 +10,14 @@
masthead: null,
// initialize
- initialize: function(options)
- {
+ initialize: function(options) {
this.options = options.config;
this.masthead = options.masthead;
this.create();
},
// default menu
- create: function()
- {
+ create: function(){
//
// Analyze data tab.
//
@@ -137,8 +130,7 @@
var tab_visualization = new mod_masthead.GalaxyMastheadTab(visualization_options);
- if (this.options.user.valid) //add submenu only when user is logged in
- {
+ if (this.options.user.valid){ //add submenu only when user is logged in
tab_visualization.add({
title : "New Track Browser",
content : "visualization/trackster",
@@ -155,8 +147,7 @@
//
// Cloud menu.
//
- if (this.options.enable_cloud_launch)
- {
+ if (this.options.enable_cloud_launch){
var tab_cloud = new mod_masthead.GalaxyMastheadTab({
id : "cloud",
title : "Cloud",
@@ -172,8 +163,7 @@
//
// Admin.
//
- if (this.options.is_admin_user)
- {
+ if (this.options.is_admin_user) {
var tab_admin = new mod_masthead.GalaxyMastheadTab({
id : "admin",
title : "Admin",
@@ -192,8 +182,7 @@
title : "Help",
title_attribute : 'Support, contact, and community hubs'
});
- if (this.options.biostar_url)
- {
+ if (this.options.biostar_url){
tab_help.add({
title : "Galaxy Biostar",
content : this.options.biostar_url_redirect,
@@ -235,8 +224,7 @@
content : this.options.citation_url,
target : "_blank"
});
- if (this.options.terms_url)
- {
+ if (this.options.terms_url){
tab_help.add({
title : "Terms and Conditions",
content : this.options.terms_url,
@@ -248,8 +236,7 @@
//
// User tab.
//
- if (!this.options.user.valid)
- {
+ if (!this.options.user.valid){
var tab_user = new mod_masthead.GalaxyMastheadTab({
id : "user",
title : "User",
@@ -265,8 +252,7 @@
});
// register
- if (this.options.allow_user_creation)
- {
+ if (this.options.allow_user_creation){
tab_user.add({
title : "Register",
content : "user/create",
@@ -331,8 +317,7 @@
target : "galaxy_main"
});
- if (this.options.use_remote_user)
- {
+ if (this.options.use_remote_user){
tab_user.add({
title : "Public Name",
content : "user/edit_username?cntrller=user",
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f client/galaxy/scripts/mvc/tools.js
--- a/client/galaxy/scripts/mvc/tools.js
+++ b/client/galaxy/scripts/mvc/tools.js
@@ -506,7 +506,19 @@
tagName: 'div',
render: function() {
- this.$el.append( Handlebars.templates.tool_link(this.model.toJSON()) );
+ // create element
+ var $link = $(Handlebars.templates.tool_link(this.model.toJSON()));
+
+ // open upload dialog for upload tool
+ if (this.model.id === 'upload1') {
+ $link.on('click', function(e) {
+ e.preventDefault();
+ Galaxy.upload.show();
+ });
+ }
+
+ // add element
+ this.$el.append($link);
return this;
}
});
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f client/galaxy/scripts/mvc/upload/upload-view.js
--- a/client/galaxy/scripts/mvc/upload/upload-view.js
+++ b/client/galaxy/scripts/mvc/upload/upload-view.js
@@ -96,7 +96,11 @@
label : 'Load Data',
onclick : function(e) {
if (e) {
- self._eventShow(e)
+ // prevent default
+ e.preventDefault();
+
+ // show
+ self.show()
}
},
onunload : function() {
@@ -168,10 +172,7 @@
//
// show/hide upload frame
- _eventShow : function (e) {
- // prevent default
- e.preventDefault();
-
+ show: function () {
// create modal
if (!this.modal) {
// make modal
@@ -437,8 +438,7 @@
},
// create a new file
- _eventCreate : function ()
- {
+ _eventCreate : function (){
this.uploadbox.add([{
name : 'New File',
size : 0,
@@ -497,8 +497,7 @@
// remove all
_eventReset : function() {
// make sure queue is not running
- if (this.counter.running == 0)
- {
+ if (this.counter.running == 0){
// reset collection
this.collection.reset();
@@ -533,8 +532,7 @@
*/
// check default message
- if(this.counter.announce == 0)
- {
+ if(this.counter.announce == 0){
if (this.uploadbox.compatible())
message = 'You can Drag & Drop files into this box.';
else
@@ -572,8 +570,7 @@
this.modal.disableButton('Pause');
// select upload button
- if (this.counter.running == 0)
- {
+ if (this.counter.running == 0){
this.modal.enableButton('Choose local file');
this.modal.enableButton('Choose FTP file');
this.modal.enableButton('Paste/Fetch data');
@@ -591,10 +588,11 @@
}
// table visibility
- if (this.counter.announce + this.counter.success + this.counter.error > 0)
+ if (this.counter.announce + this.counter.success + this.counter.error > 0) {
$(this.el).find('#upload-table').show();
- else
+ } else {
$(this.el).find('#upload-table').hide();
+ }
},
// calculate percentage of all queued uploads
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f static/scripts/galaxy.frame.js
--- a/static/scripts/galaxy.frame.js
+++ b/static/scripts/galaxy.frame.js
@@ -1,9 +1,8 @@
// dependencies
define(["galaxy.masthead", "mvc/ui/ui-frames"], function(mod_masthead, Frames) {
-// frame manager
-var GalaxyFrame = Backbone.View.extend(
-{
+/** Frame manager uses the ui-frames to create the scratch book masthead icon and functionality **/
+var GalaxyFrame = Backbone.View.extend({
// base element
el_main: 'body',
@@ -17,8 +16,7 @@
button_load : null,
// initialize
- initialize : function(options)
- {
+ initialize : function(options) {
// add to masthead menu
var self = this;
@@ -28,8 +26,7 @@
});
// add activate icon
- this.button_active = new mod_masthead.GalaxyMastheadIcon (
- {
+ this.button_active = new mod_masthead.GalaxyMastheadIcon({
icon : 'fa-th',
tooltip : 'Enable/Disable Scratchbook',
onclick : function() { self._activate(); },
@@ -44,8 +41,7 @@
Galaxy.masthead.append(this.button_active);
// add load icon
- this.button_load = new mod_masthead.GalaxyMastheadIcon (
- {
+ this.button_load = new mod_masthead.GalaxyMastheadIcon({
icon : 'fa-eye',
tooltip : 'Show/Hide Scratchbook',
onclick : function(e) {
@@ -126,31 +122,25 @@
/**
* Add and display a new frame/window based on options.
*/
- add: function(options)
- {
+ add: function(options){
// open new tab
- if (options.target == '_blank')
- {
+ if (options.target == '_blank'){
window.open(options.content);
return;
}
// reload entire window
- if (options.target == '_top' || options.target == '_parent' || options.target == '_self')
- {
+ if (options.target == '_top' || options.target == '_parent' || options.target == '_self'){
window.location = options.content;
return;
}
// validate
- if (!this.active)
- {
+ if (!this.active){
// fix url if main frame is unavailable
var $galaxy_main = $(window.parent.document).find('#galaxy_main');
- if (options.target == 'galaxy_main' || options.target == 'center')
- {
- if ($galaxy_main.length === 0)
- {
+ if (options.target == 'galaxy_main' || options.target == 'center'){
+ if ($galaxy_main.length === 0){
var href = options.content;
if (href.indexOf('?') == -1)
href += '?';
@@ -173,11 +163,9 @@
},
// activate/disable panel
- _activate: function ()
- {
+ _activate: function (){
// check
- if (this.active)
- {
+ if (this.active){
// disable
this.active = false;
@@ -196,8 +184,7 @@
},
// update frame counter
- _refresh: function()
- {
+ _refresh: function(){
// update on screen counter
this.button_load.number(this.frames.length());
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f static/scripts/galaxy.masthead.js
--- a/static/scripts/galaxy.masthead.js
+++ b/static/scripts/galaxy.masthead.js
@@ -1,9 +1,8 @@
// dependencies
define([], function() {
-// masthead
-var GalaxyMasthead = Backbone.View.extend(
-{
+/** Masthead **/
+var GalaxyMasthead = Backbone.View.extend({
// base element
el_masthead: '#everything',
@@ -17,8 +16,7 @@
list: [],
// initialize
- initialize : function(options)
- {
+ initialize : function(options) {
// update options
this.options = options;
@@ -51,27 +49,23 @@
},
// configure events
- events:
- {
+ events: {
'click' : '_click',
'mousedown' : function(e) { e.preventDefault() }
},
// adds a new item to the masthead
- append : function(item)
- {
+ append : function(item) {
return this._add(item, true);
},
// adds a new item to the masthead
- prepend : function(item)
- {
+ prepend : function(item) {
return this._add(item, false);
},
// activate
- highlight: function(id)
- {
+ highlight: function(id) {
var current = $(this.el).find('#' + id + '> li');
if (current) {
current.addClass('active');
@@ -79,11 +73,9 @@
},
// adds a new item to the masthead
- _add : function(item, append)
- {
+ _add : function(item, append) {
var $loc = $(this.el).find('#' + item.location);
- if ($loc)
- {
+ if ($loc){
// create frame for new item
var $current = $(item.el);
@@ -106,8 +98,7 @@
},
// handle click event
- _click: function(e)
- {
+ _click: function(e) {
// close all popups
var $all = $(this.el).find('.popup');
if ($all) {
@@ -129,8 +120,7 @@
*/
// fill template
- _template: function(options)
- {
+ _template: function(options) {
var brand_text = options.brand ? ("/ " + options.brand) : "" ;
return '<div><div id="masthead" class="navbar navbar-fixed-top navbar-inverse">' +
'<div style="position: relative; right: -50%; float: left;">' +
@@ -150,12 +140,10 @@
}
});
-// icon
-var GalaxyMastheadIcon = Backbone.View.extend(
-{
+/** Masthead icon **/
+var GalaxyMastheadIcon = Backbone.View.extend({
// icon options
- options:
- {
+ options:{
id : '',
icon : 'fa-cog',
tooltip : '',
@@ -169,8 +157,7 @@
location: 'iconbar',
// initialize
- initialize: function (options)
- {
+ initialize: function (options){
// read in defaults
if (options)
this.options = _.defaults(options, this.options);
@@ -189,20 +176,17 @@
},
// show
- show: function()
- {
+ show: function(){
$(this.el).css({visibility : 'visible'});
},
// show
- hide: function()
- {
+ hide: function(){
$(this.el).css({visibility : 'hidden'});
},
// switch icon
- icon: function (new_icon)
- {
+ icon: function (new_icon){
// update icon class
$(this.el).find('.icon').removeClass(this.options.icon)
.addClass(new_icon);
@@ -212,26 +196,22 @@
},
// toggle
- toggle: function()
- {
+ toggle: function(){
$(this.el).addClass('toggle');
},
// untoggle
- untoggle: function()
- {
+ untoggle: function(){
$(this.el).removeClass('toggle');
},
// set/get number
- number: function(new_number)
- {
+ number: function(new_number){
$(this.el).find('.number').text(new_number);
},
// fill template icon
- _template: function (options)
- {
+ _template: function (options){
var tmpl = '<div id="' + options.id + '" class="symbol">' +
'<div class="icon fa fa-2x ' + options.icon + '"></div>';
if (options.with_number)
@@ -243,12 +223,10 @@
}
});
-// tab
-var GalaxyMastheadTab = Backbone.View.extend(
-{
+/** Masthead tab **/
+var GalaxyMastheadTab = Backbone.View.extend({
// main options
- options:
- {
+ options:{
id : '',
title : '',
target : '_parent',
@@ -268,14 +246,12 @@
$menu: null,
// events
- events:
- {
+ events:{
'click .head' : '_head'
},
// initialize
- initialize: function (options)
- {
+ initialize: function (options){
// read in defaults
if (options)
this.options = _.defaults(options, this.options);
@@ -300,20 +276,17 @@
},
// show
- show: function()
- {
+ show: function(){
$(this.el).css({visibility : 'visible'});
},
// show
- hide: function()
- {
+ hide: function(){
$(this.el).css({visibility : 'hidden'});
},
// add menu item
- add: function (options)
- {
+ add: function (options){
// menu option defaults
var menuOptions = {
title : 'Title',
@@ -333,8 +306,7 @@
menuOptions.content = galaxy_config.root + menuOptions.content;
// check if submenu element is available
- if (!this.$menu)
- {
+ if (!this.$menu){
// insert submenu element into root
$(this.el).find('.root').append(this._templateMenu());
@@ -353,8 +325,7 @@
// add events
var self = this;
- $item.on('click', function(e)
- {
+ $item.on('click', function(e){
// prevent default
e.preventDefault();
@@ -372,8 +343,7 @@
},
// show menu on header click
- _head: function(e)
- {
+ _head: function(e){
// prevent default
e.preventDefault();
@@ -387,8 +357,7 @@
}
},
- _attachPopover : function()
- {
+ _attachPopover : function(){
var $popover_element = $(this.el).find('.head');
$popover_element.popover({
html: true,
@@ -402,25 +371,21 @@
},
// fill template header
- _templateMenuItem: function (options)
- {
+ _templateMenuItem: function (options){
return '<li><a href="' + options.content + '" target="' + options.target + '">' + options.title + '</a></li>';
},
// fill template header
- _templateMenu: function ()
- {
+ _templateMenu: function (){
return '<ul class="popup dropdown-menu"></ul>';
},
- _templateDivider: function()
- {
+ _templateDivider: function(){
return '<li class="divider"></li>';
},
// fill template
- _template: function (options)
- {
+ _template: function (options){
// start template
var tmpl = '<ul id="' + options.id + '" class="nav navbar-nav" border="0" cellspacing="0">' +
'<li class="root dropdown" style="">' +
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f static/scripts/galaxy.menu.js
--- a/static/scripts/galaxy.menu.js
+++ b/static/scripts/galaxy.menu.js
@@ -1,13 +1,8 @@
-/*
- galaxy menu
-*/
-
// dependencies
define(["galaxy.masthead"], function(mod_masthead) {
-// frame manager
-var GalaxyMenu = Backbone.Model.extend(
-{
+/** GalaxyMenu uses the GalaxyMasthead class in order to add menu items and icons to the Masthead **/
+var GalaxyMenu = Backbone.Model.extend({
// options
options: null,
@@ -15,16 +10,14 @@
masthead: null,
// initialize
- initialize: function(options)
- {
+ initialize: function(options) {
this.options = options.config;
this.masthead = options.masthead;
this.create();
},
// default menu
- create: function()
- {
+ create: function(){
//
// Analyze data tab.
//
@@ -137,8 +130,7 @@
var tab_visualization = new mod_masthead.GalaxyMastheadTab(visualization_options);
- if (this.options.user.valid) //add submenu only when user is logged in
- {
+ if (this.options.user.valid){ //add submenu only when user is logged in
tab_visualization.add({
title : "New Track Browser",
content : "visualization/trackster",
@@ -155,8 +147,7 @@
//
// Cloud menu.
//
- if (this.options.enable_cloud_launch)
- {
+ if (this.options.enable_cloud_launch){
var tab_cloud = new mod_masthead.GalaxyMastheadTab({
id : "cloud",
title : "Cloud",
@@ -172,8 +163,7 @@
//
// Admin.
//
- if (this.options.is_admin_user)
- {
+ if (this.options.is_admin_user) {
var tab_admin = new mod_masthead.GalaxyMastheadTab({
id : "admin",
title : "Admin",
@@ -192,8 +182,7 @@
title : "Help",
title_attribute : 'Support, contact, and community hubs'
});
- if (this.options.biostar_url)
- {
+ if (this.options.biostar_url){
tab_help.add({
title : "Galaxy Biostar",
content : this.options.biostar_url_redirect,
@@ -235,8 +224,7 @@
content : this.options.citation_url,
target : "_blank"
});
- if (this.options.terms_url)
- {
+ if (this.options.terms_url){
tab_help.add({
title : "Terms and Conditions",
content : this.options.terms_url,
@@ -248,8 +236,7 @@
//
// User tab.
//
- if (!this.options.user.valid)
- {
+ if (!this.options.user.valid){
var tab_user = new mod_masthead.GalaxyMastheadTab({
id : "user",
title : "User",
@@ -265,8 +252,7 @@
});
// register
- if (this.options.allow_user_creation)
- {
+ if (this.options.allow_user_creation){
tab_user.add({
title : "Register",
content : "user/create",
@@ -331,8 +317,7 @@
target : "galaxy_main"
});
- if (this.options.use_remote_user)
- {
+ if (this.options.use_remote_user){
tab_user.add({
title : "Public Name",
content : "user/edit_username?cntrller=user",
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f static/scripts/mvc/tools.js
--- a/static/scripts/mvc/tools.js
+++ b/static/scripts/mvc/tools.js
@@ -506,7 +506,19 @@
tagName: 'div',
render: function() {
- this.$el.append( Handlebars.templates.tool_link(this.model.toJSON()) );
+ // create element
+ var $link = $(Handlebars.templates.tool_link(this.model.toJSON()));
+
+ // open upload dialog for upload tool
+ if (this.model.id === 'upload1') {
+ $link.on('click', function(e) {
+ e.preventDefault();
+ Galaxy.upload.show();
+ });
+ }
+
+ // add element
+ this.$el.append($link);
return this;
}
});
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f static/scripts/mvc/upload/upload-view.js
--- a/static/scripts/mvc/upload/upload-view.js
+++ b/static/scripts/mvc/upload/upload-view.js
@@ -96,7 +96,11 @@
label : 'Load Data',
onclick : function(e) {
if (e) {
- self._eventShow(e)
+ // prevent default
+ e.preventDefault();
+
+ // show
+ self.show()
}
},
onunload : function() {
@@ -168,10 +172,7 @@
//
// show/hide upload frame
- _eventShow : function (e) {
- // prevent default
- e.preventDefault();
-
+ show: function () {
// create modal
if (!this.modal) {
// make modal
@@ -437,8 +438,7 @@
},
// create a new file
- _eventCreate : function ()
- {
+ _eventCreate : function (){
this.uploadbox.add([{
name : 'New File',
size : 0,
@@ -497,8 +497,7 @@
// remove all
_eventReset : function() {
// make sure queue is not running
- if (this.counter.running == 0)
- {
+ if (this.counter.running == 0){
// reset collection
this.collection.reset();
@@ -533,8 +532,7 @@
*/
// check default message
- if(this.counter.announce == 0)
- {
+ if(this.counter.announce == 0){
if (this.uploadbox.compatible())
message = 'You can Drag & Drop files into this box.';
else
@@ -572,8 +570,7 @@
this.modal.disableButton('Pause');
// select upload button
- if (this.counter.running == 0)
- {
+ if (this.counter.running == 0){
this.modal.enableButton('Choose local file');
this.modal.enableButton('Choose FTP file');
this.modal.enableButton('Paste/Fetch data');
@@ -591,10 +588,11 @@
}
// table visibility
- if (this.counter.announce + this.counter.success + this.counter.error > 0)
+ if (this.counter.announce + this.counter.success + this.counter.error > 0) {
$(this.el).find('#upload-table').show();
- else
+ } else {
$(this.el).find('#upload-table').hide();
+ }
},
// calculate percentage of all queued uploads
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f static/scripts/packed/mvc/tools.js
--- a/static/scripts/packed/mvc/tools.js
+++ b/static/scripts/packed/mvc/tools.js
@@ -1,1 +1,1 @@
-define(["libs/underscore","viz/trackster/util","mvc/data"],function(x,a,y){var g={hidden:false,show:function(){this.set("hidden",false)},hide:function(){this.set("hidden",true)},toggle:function(){this.set("hidden",!this.get("hidden"))},is_visible:function(){return !this.attributes.hidden}};var e=Backbone.Model.extend({defaults:{name:null,label:null,type:null,value:null,html:null,num_samples:5},initialize:function(z){this.attributes.html=unescape(this.attributes.html)},copy:function(){return new e(this.toJSON())},set_value:function(z){this.set("value",z||"")}});var i=Backbone.Collection.extend({model:e});var k=e.extend({});var d=e.extend({set_value:function(z){this.set("value",parseInt(z,10))},get_samples:function(){return d3.scale.linear().domain([this.get("min"),this.get("max")]).ticks(this.get("num_samples"))}});var f=d.extend({set_value:function(z){this.set("value",parseFloat(z))}});var t=e.extend({get_samples:function(){return x.map(this.get("options"),function(z){return z[0]})}});e.subModelTypes={integer:d,"float":f,data:k,select:t};var j=Backbone.Model.extend({defaults:{id:null,name:null,description:null,target:null,inputs:[],outputs:[]},urlRoot:galaxy_config.root+"api/tools",initialize:function(z){this.set("inputs",new i(x.map(z.inputs,function(A){var B=e.subModelTypes[A.type]||e;return new B(A)})))},toJSON:function(){var z=Backbone.Model.prototype.toJSON.call(this);z.inputs=this.get("inputs").map(function(A){return A.toJSON()});return z},remove_inputs:function(A){var z=this,B=z.get("inputs").filter(function(C){return(A.indexOf(C.get("type"))!==-1)});z.get("inputs").remove(B)},copy:function(A){var B=new j(this.toJSON());if(A){var z=new Backbone.Collection();B.get("inputs").each(function(C){if(C.get_samples()){z.push(C)}});B.set("inputs",z)}return B},apply_search_results:function(z){(x.indexOf(z,this.attributes.id)!==-1?this.show():this.hide());return this.is_visible()},set_input_value:function(z,A){this.get("inputs").find(function(B){return B.get("name")===z}).set("value",A)},set_input_values:function(A){var z=this;x.each(x.keys(A),function(B){z.set_input_value(B,A[B])})},run:function(){return this._run()},rerun:function(A,z){return this._run({action:"rerun",target_dataset_id:A.id,regions:z})},get_inputs_dict:function(){var z={};this.get("inputs").each(function(A){z[A.get("name")]=A.get("value")});return z},_run:function(B){var C=x.extend({tool_id:this.id,inputs:this.get_inputs_dict()},B);var A=$.Deferred(),z=new a.ServerStateDeferred({ajax_settings:{url:this.urlRoot,data:JSON.stringify(C),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(D){return D!=="pending"}});$.when(z.go()).then(function(D){A.resolve(new y.DatasetCollection().reset(D))});return A}});x.extend(j.prototype,g);var q=Backbone.View.extend({});var n=Backbone.Collection.extend({model:j});var v=Backbone.Model.extend(g);var l=Backbone.Model.extend({defaults:{elems:[],open:false},clear_search_results:function(){x.each(this.attributes.elems,function(z){z.show()});this.show();this.set("open",false)},apply_search_results:function(A){var B=true,z;x.each(this.attributes.elems,function(C){if(C instanceof v){z=C;z.hide()}else{if(C instanceof j){if(C.apply_search_results(A)){B=false;if(z){z.show()}}}}});if(B){this.hide()}else{this.show();this.set("open",true)}}});x.extend(l.prototype,g);var c=Backbone.Model.extend({defaults:{search_hint_string:"search tools",min_chars_for_search:3,spinner_url:"",clear_btn_url:"",search_url:"",visible:true,query:"",results:null,clear_key:27},initialize:function(){this.on("change:query",this.do_search)},do_search:function(){var B=this.attributes.query;if(B.length<this.attributes.min_chars_for_search){this.set("results",null);return}var A=B+"*";if(this.timer){clearTimeout(this.timer)}$("#search-clear-btn").hide();$("#search-spinner").show();var z=this;this.timer=setTimeout(function(){$.get(z.attributes.search_url,{query:A},function(C){z.set("results",C);$("#search-spinner").hide();$("#search-clear-btn").show()},"json")},200)},clear_search:function(){this.set("query","");this.set("results",null)}});x.extend(c.prototype,g);var o=Backbone.Model.extend({initialize:function(z){this.attributes.tool_search=z.tool_search;this.attributes.tool_search.on("change:results",this.apply_search_results,this);this.attributes.tools=z.tools;this.attributes.layout=new Backbone.Collection(this.parse(z.layout))},parse:function(A){var z=this,B=function(E){var D=E.model_class;if(D.indexOf("Tool")===D.length-4){return z.attributes.tools.get(E.id)}else{if(D==="ToolSection"){var C=x.map(E.elems,B);E.elems=C;return new l(E)}else{if(D==="ToolSectionLabel"){return new v(E)}}}};return x.map(A,B)},clear_search_results:function(){this.get("layout").each(function(z){if(z instanceof l){z.clear_search_results()}else{z.show()}})},apply_search_results:function(){var A=this.get("tool_search").get("results");if(A===null){this.clear_search_results();return}var z=null;this.get("layout").each(function(B){if(B instanceof v){z=B;z.hide()}else{if(B instanceof j){if(B.apply_search_results(A)){if(z){z.show()}}}else{z=null;B.apply_search_results(A)}}})}});var s=Backbone.View.extend({initialize:function(){this.model.on("change:hidden",this.update_visible,this);this.update_visible()},update_visible:function(){(this.model.attributes.hidden?this.$el.hide():this.$el.show())}});var m=s.extend({tagName:"div",render:function(){this.$el.append(Handlebars.templates.tool_link(this.model.toJSON()));return this}});var b=s.extend({tagName:"div",className:"toolPanelLabel",render:function(){this.$el.append($("<span/>").text(this.model.attributes.text));return this}});var r=s.extend({tagName:"div",className:"toolSectionWrapper",initialize:function(){s.prototype.initialize.call(this);this.model.on("change:open",this.update_open,this)},render:function(){this.$el.append(Handlebars.templates.panel_section(this.model.toJSON()));var z=this.$el.find(".toolSectionBody");x.each(this.model.attributes.elems,function(A){if(A instanceof j){var B=new m({model:A,className:"toolTitle"});B.render();z.append(B.$el)}else{if(A instanceof v){var C=new b({model:A});C.render();z.append(C.$el)}else{}}});return this},events:{"click .toolSectionTitle > a":"toggle"},toggle:function(){this.model.set("open",!this.model.attributes.open)},update_open:function(){(this.model.attributes.open?this.$el.children(".toolSectionBody").slideDown("fast"):this.$el.children(".toolSectionBody").slideUp("fast"))}});var p=Backbone.View.extend({tagName:"div",id:"tool-search",className:"bar",events:{click:"focus_and_select","keyup :input":"query_changed","click #search-clear-btn":"clear"},render:function(){this.$el.append(Handlebars.templates.tool_search(this.model.toJSON()));if(!this.model.is_visible()){this.$el.hide()}this.$el.find("[title]").tooltip();return this},focus_and_select:function(){this.$el.find(":input").focus().select()},clear:function(){this.model.clear_search();this.$el.find(":input").val(this.model.attributes.search_hint_string);this.focus_and_select();return false},query_changed:function(z){if((this.model.attributes.clear_key)&&(this.model.attributes.clear_key===z.which)){this.clear();return false}this.model.set("query",this.$el.find(":input").val())}});var w=Backbone.View.extend({tagName:"div",className:"toolMenu",initialize:function(){this.model.get("tool_search").on("change:results",this.handle_search_results,this)},render:function(){var z=this;var A=new p({model:this.model.get("tool_search")});A.render();z.$el.append(A.$el);this.model.get("layout").each(function(C){if(C instanceof l){var B=new r({model:C});B.render();z.$el.append(B.$el)}else{if(C instanceof j){var D=new m({model:C,className:"toolTitleNoSection"});D.render();z.$el.append(D.$el)}else{if(C instanceof v){var E=new b({model:C});E.render();z.$el.append(E.$el)}}}});z.$el.find("a.tool-link").click(function(D){var C=$(this).attr("class").split(/\s+/)[0],B=z.model.get("tools").get(C);z.trigger("tool_link_click",D,B)});return this},handle_search_results:function(){var z=this.model.get("tool_search").get("results");if(z&&z.length===0){$("#search-no-results").show()}else{$("#search-no-results").hide()}}});var u=Backbone.View.extend({className:"toolForm",render:function(){this.$el.children().remove();this.$el.append(Handlebars.templates.tool_form(this.model.toJSON()))}});var h=Backbone.View.extend({className:"toolMenuAndView",initialize:function(){this.tool_panel_view=new w({collection:this.collection});this.tool_form_view=new u()},render:function(){this.tool_panel_view.render();this.tool_panel_view.$el.css("float","left");this.$el.append(this.tool_panel_view.$el);this.tool_form_view.$el.hide();this.$el.append(this.tool_form_view.$el);var z=this;this.tool_panel_view.on("tool_link_click",function(B,A){B.preventDefault();z.show_tool(A)})},show_tool:function(A){var z=this;A.fetch().done(function(){z.tool_form_view.model=A;z.tool_form_view.render();z.tool_form_view.$el.show();$("#left").width("650px")})}});return{ToolParameter:e,IntegerToolParameter:d,SelectToolParameter:t,Tool:j,ToolCollection:n,ToolSearch:c,ToolPanel:o,ToolPanelView:w,ToolFormView:u}});
\ No newline at end of file
+define(["libs/underscore","viz/trackster/util","mvc/data"],function(x,a,y){var g={hidden:false,show:function(){this.set("hidden",false)},hide:function(){this.set("hidden",true)},toggle:function(){this.set("hidden",!this.get("hidden"))},is_visible:function(){return !this.attributes.hidden}};var e=Backbone.Model.extend({defaults:{name:null,label:null,type:null,value:null,html:null,num_samples:5},initialize:function(z){this.attributes.html=unescape(this.attributes.html)},copy:function(){return new e(this.toJSON())},set_value:function(z){this.set("value",z||"")}});var i=Backbone.Collection.extend({model:e});var k=e.extend({});var d=e.extend({set_value:function(z){this.set("value",parseInt(z,10))},get_samples:function(){return d3.scale.linear().domain([this.get("min"),this.get("max")]).ticks(this.get("num_samples"))}});var f=d.extend({set_value:function(z){this.set("value",parseFloat(z))}});var t=e.extend({get_samples:function(){return x.map(this.get("options"),function(z){return z[0]})}});e.subModelTypes={integer:d,"float":f,data:k,select:t};var j=Backbone.Model.extend({defaults:{id:null,name:null,description:null,target:null,inputs:[],outputs:[]},urlRoot:galaxy_config.root+"api/tools",initialize:function(z){this.set("inputs",new i(x.map(z.inputs,function(A){var B=e.subModelTypes[A.type]||e;return new B(A)})))},toJSON:function(){var z=Backbone.Model.prototype.toJSON.call(this);z.inputs=this.get("inputs").map(function(A){return A.toJSON()});return z},remove_inputs:function(A){var z=this,B=z.get("inputs").filter(function(C){return(A.indexOf(C.get("type"))!==-1)});z.get("inputs").remove(B)},copy:function(A){var B=new j(this.toJSON());if(A){var z=new Backbone.Collection();B.get("inputs").each(function(C){if(C.get_samples()){z.push(C)}});B.set("inputs",z)}return B},apply_search_results:function(z){(x.indexOf(z,this.attributes.id)!==-1?this.show():this.hide());return this.is_visible()},set_input_value:function(z,A){this.get("inputs").find(function(B){return B.get("name")===z}).set("value",A)},set_input_values:function(A){var z=this;x.each(x.keys(A),function(B){z.set_input_value(B,A[B])})},run:function(){return this._run()},rerun:function(A,z){return this._run({action:"rerun",target_dataset_id:A.id,regions:z})},get_inputs_dict:function(){var z={};this.get("inputs").each(function(A){z[A.get("name")]=A.get("value")});return z},_run:function(B){var C=x.extend({tool_id:this.id,inputs:this.get_inputs_dict()},B);var A=$.Deferred(),z=new a.ServerStateDeferred({ajax_settings:{url:this.urlRoot,data:JSON.stringify(C),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(D){return D!=="pending"}});$.when(z.go()).then(function(D){A.resolve(new y.DatasetCollection().reset(D))});return A}});x.extend(j.prototype,g);var q=Backbone.View.extend({});var n=Backbone.Collection.extend({model:j});var v=Backbone.Model.extend(g);var l=Backbone.Model.extend({defaults:{elems:[],open:false},clear_search_results:function(){x.each(this.attributes.elems,function(z){z.show()});this.show();this.set("open",false)},apply_search_results:function(A){var B=true,z;x.each(this.attributes.elems,function(C){if(C instanceof v){z=C;z.hide()}else{if(C instanceof j){if(C.apply_search_results(A)){B=false;if(z){z.show()}}}}});if(B){this.hide()}else{this.show();this.set("open",true)}}});x.extend(l.prototype,g);var c=Backbone.Model.extend({defaults:{search_hint_string:"search tools",min_chars_for_search:3,spinner_url:"",clear_btn_url:"",search_url:"",visible:true,query:"",results:null,clear_key:27},initialize:function(){this.on("change:query",this.do_search)},do_search:function(){var B=this.attributes.query;if(B.length<this.attributes.min_chars_for_search){this.set("results",null);return}var A=B+"*";if(this.timer){clearTimeout(this.timer)}$("#search-clear-btn").hide();$("#search-spinner").show();var z=this;this.timer=setTimeout(function(){$.get(z.attributes.search_url,{query:A},function(C){z.set("results",C);$("#search-spinner").hide();$("#search-clear-btn").show()},"json")},200)},clear_search:function(){this.set("query","");this.set("results",null)}});x.extend(c.prototype,g);var o=Backbone.Model.extend({initialize:function(z){this.attributes.tool_search=z.tool_search;this.attributes.tool_search.on("change:results",this.apply_search_results,this);this.attributes.tools=z.tools;this.attributes.layout=new Backbone.Collection(this.parse(z.layout))},parse:function(A){var z=this,B=function(E){var D=E.model_class;if(D.indexOf("Tool")===D.length-4){return z.attributes.tools.get(E.id)}else{if(D==="ToolSection"){var C=x.map(E.elems,B);E.elems=C;return new l(E)}else{if(D==="ToolSectionLabel"){return new v(E)}}}};return x.map(A,B)},clear_search_results:function(){this.get("layout").each(function(z){if(z instanceof l){z.clear_search_results()}else{z.show()}})},apply_search_results:function(){var A=this.get("tool_search").get("results");if(A===null){this.clear_search_results();return}var z=null;this.get("layout").each(function(B){if(B instanceof v){z=B;z.hide()}else{if(B instanceof j){if(B.apply_search_results(A)){if(z){z.show()}}}else{z=null;B.apply_search_results(A)}}})}});var s=Backbone.View.extend({initialize:function(){this.model.on("change:hidden",this.update_visible,this);this.update_visible()},update_visible:function(){(this.model.attributes.hidden?this.$el.hide():this.$el.show())}});var m=s.extend({tagName:"div",render:function(){var z=$(Handlebars.templates.tool_link(this.model.toJSON()));if(this.model.id==="upload1"){z.on("click",function(A){A.preventDefault();Galaxy.upload.show()})}this.$el.append(z);return this}});var b=s.extend({tagName:"div",className:"toolPanelLabel",render:function(){this.$el.append($("<span/>").text(this.model.attributes.text));return this}});var r=s.extend({tagName:"div",className:"toolSectionWrapper",initialize:function(){s.prototype.initialize.call(this);this.model.on("change:open",this.update_open,this)},render:function(){this.$el.append(Handlebars.templates.panel_section(this.model.toJSON()));var z=this.$el.find(".toolSectionBody");x.each(this.model.attributes.elems,function(A){if(A instanceof j){var B=new m({model:A,className:"toolTitle"});B.render();z.append(B.$el)}else{if(A instanceof v){var C=new b({model:A});C.render();z.append(C.$el)}else{}}});return this},events:{"click .toolSectionTitle > a":"toggle"},toggle:function(){this.model.set("open",!this.model.attributes.open)},update_open:function(){(this.model.attributes.open?this.$el.children(".toolSectionBody").slideDown("fast"):this.$el.children(".toolSectionBody").slideUp("fast"))}});var p=Backbone.View.extend({tagName:"div",id:"tool-search",className:"bar",events:{click:"focus_and_select","keyup :input":"query_changed","click #search-clear-btn":"clear"},render:function(){this.$el.append(Handlebars.templates.tool_search(this.model.toJSON()));if(!this.model.is_visible()){this.$el.hide()}this.$el.find("[title]").tooltip();return this},focus_and_select:function(){this.$el.find(":input").focus().select()},clear:function(){this.model.clear_search();this.$el.find(":input").val(this.model.attributes.search_hint_string);this.focus_and_select();return false},query_changed:function(z){if((this.model.attributes.clear_key)&&(this.model.attributes.clear_key===z.which)){this.clear();return false}this.model.set("query",this.$el.find(":input").val())}});var w=Backbone.View.extend({tagName:"div",className:"toolMenu",initialize:function(){this.model.get("tool_search").on("change:results",this.handle_search_results,this)},render:function(){var z=this;var A=new p({model:this.model.get("tool_search")});A.render();z.$el.append(A.$el);this.model.get("layout").each(function(C){if(C instanceof l){var B=new r({model:C});B.render();z.$el.append(B.$el)}else{if(C instanceof j){var D=new m({model:C,className:"toolTitleNoSection"});D.render();z.$el.append(D.$el)}else{if(C instanceof v){var E=new b({model:C});E.render();z.$el.append(E.$el)}}}});z.$el.find("a.tool-link").click(function(D){var C=$(this).attr("class").split(/\s+/)[0],B=z.model.get("tools").get(C);z.trigger("tool_link_click",D,B)});return this},handle_search_results:function(){var z=this.model.get("tool_search").get("results");if(z&&z.length===0){$("#search-no-results").show()}else{$("#search-no-results").hide()}}});var u=Backbone.View.extend({className:"toolForm",render:function(){this.$el.children().remove();this.$el.append(Handlebars.templates.tool_form(this.model.toJSON()))}});var h=Backbone.View.extend({className:"toolMenuAndView",initialize:function(){this.tool_panel_view=new w({collection:this.collection});this.tool_form_view=new u()},render:function(){this.tool_panel_view.render();this.tool_panel_view.$el.css("float","left");this.$el.append(this.tool_panel_view.$el);this.tool_form_view.$el.hide();this.$el.append(this.tool_form_view.$el);var z=this;this.tool_panel_view.on("tool_link_click",function(B,A){B.preventDefault();z.show_tool(A)})},show_tool:function(A){var z=this;A.fetch().done(function(){z.tool_form_view.model=A;z.tool_form_view.render();z.tool_form_view.$el.show();$("#left").width("650px")})}});return{ToolParameter:e,IntegerToolParameter:d,SelectToolParameter:t,Tool:j,ToolCollection:n,ToolSearch:c,ToolPanel:o,ToolPanelView:w,ToolFormView:u}});
\ No newline at end of file
diff -r cf1550da899848378f9c5e5ca00818c029c3a1bb -r b8efe7496a7e591450722765cdca0307ffad957f static/scripts/packed/mvc/upload/upload-view.js
--- a/static/scripts/packed/mvc/upload/upload-view.js
+++ b/static/scripts/packed/mvc/upload/upload-view.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/upload/upload-button","mvc/upload/upload-model","mvc/upload/upload-row","mvc/upload/upload-ftp","mvc/ui/ui-popover","mvc/ui/ui-modal","mvc/ui","utils/uploadbox"],function(f,e,c,b,g,d,a){return Backbone.View.extend({options:{nginx_upload_path:""},modal:null,ui_button:null,uploadbox:null,current_history:null,upload_size:0,list_extensions:[],list_genomes:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},collection:new c.Collection(),ftp:null,counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},initialize:function(i){var h=this;if(i){this.options=_.defaults(i,this.options)}if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){h.initialize()},500);return}this.ui_button=new e.Model({icon:"fa-upload",tooltip:"Download from URL or upload files from disk",label:"Load Data",onclick:function(j){if(j){h._eventShow(j)}},onunload:function(){if(h.counter.running>0){return"Several uploads are still processing."}}});$("#left .unified-panel-header-inner").append((new e.View(this.ui_button)).$el);var h=this;f.get(galaxy_config.root+"api/datatypes?extension_only=False",function(j){for(key in j){h.list_extensions.push({id:j[key].extension,text:j[key].extension,description:j[key].description,description_url:j[key].description_url})}h.list_extensions.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0});if(!h.options.datatypes_disable_auto){h.list_extensions.unshift(h.auto)}});f.get(galaxy_config.root+"api/genomes",function(j){for(key in j){h.list_genomes.push({id:j[key][1],text:j[key][0]})}h.list_genomes.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0})});this.collection.on("remove",function(j){h._eventRemove(j)});this.collection.on("change:genome",function(k){var j=k.get("genome");h.collection.each(function(l){if(l.get("status")=="init"&&l.get("genome")=="?"){l.set("genome",j)}})})},_eventShow:function(j){j.preventDefault();if(!this.modal){var h=this;this.modal=new a.View({title:"Download data directly from web or upload files from your disk",body:this._template("upload-box","upload-info"),buttons:{"Choose local file":function(){h.uploadbox.select()},"Choose FTP file":function(){h._eventFtp()},"Paste/Fetch data":function(){h._eventCreate()},Start:function(){h._eventStart()},Pause:function(){h._eventStop()},Reset:function(){h._eventReset()},Close:function(){h.modal.hide()},},height:"400",width:"900",closing_events:true});this.setElement("#upload-box");var h=this;this.uploadbox=this.$el.uploadbox({announce:function(k,l,m){h._eventAnnounce(k,l,m)},initialize:function(k,l,m){return h._eventInitialize(k,l,m)},progress:function(k,l,m){h._eventProgress(k,l,m)},success:function(k,l,m){h._eventSuccess(k,l,m)},error:function(k,l,m){h._eventError(k,l,m)},complete:function(){h._eventComplete()}});var i=this.modal.getButton("Choose FTP file");this.ftp=new d.View({title:"FTP files",container:i})}this.modal.show();this._updateUser();this._updateScreen()},_eventRemove:function(i){var h=i.get("status");if(h=="success"){this.counter.success--}else{if(h=="error"){this.counter.error--}else{this.counter.announce--}}this._updateScreen();this.uploadbox.remove(i.id)},_eventAnnounce:function(h,i,k){this.counter.announce++;this._updateScreen();var j=new b(this,{id:h,file_name:i.name,file_size:i.size,file_mode:i.mode,file_path:i.path});this.collection.add(j.model);$(this.el).find("tbody:first").append(j.$el);j.render()},_eventInitialize:function(m,j,s){var k=this.collection.get(m);k.set("status","running");var o=k.get("file_name");var n=k.get("file_path");var h=k.get("file_mode");var p=k.get("extension");var r=k.get("genome");var q=k.get("url_paste");var l=k.get("space_to_tabs");var i=k.get("to_posix_lines");if(!q&&!(j.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path});if(h=="local"){this.uploadbox.configure({paramname:"files_0|file_data"})}else{this.uploadbox.configure({paramname:null})}tool_input={};if(h=="new"){tool_input["files_0|url_paste"]=q}if(h=="ftp"){tool_input["files_0|ftp_files"]=n}tool_input.dbkey=r;tool_input.file_type=p;tool_input["files_0|type"]="upload_dataset";tool_input.space_to_tabs=l;tool_input.to_posix_lines=i;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},_eventProgress:function(i,j,h){var k=this.collection.get(i);k.set("percentage",h);this.ui_button.set("percentage",this._upload_percentage(h,j.size))},_eventSuccess:function(i,j,l){var k=this.collection.get(i);k.set("percentage",100);k.set("status","success");var h=k.get("file_size");this.ui_button.set("percentage",this._upload_percentage(100,h));this.upload_completed+=h*100;this.counter.announce--;this.counter.success++;this._updateScreen();Galaxy.currHistoryPanel.refreshContents()},_eventError:function(h,i,k){var j=this.collection.get(h);j.set("percentage",100);j.set("status","error");j.set("info",k);this.ui_button.set("percentage",this._upload_percentage(100,i.size));this.ui_button.set("status","danger");this.upload_completed+=i.size*100;this.counter.announce--;this.counter.error++;this._updateScreen()},_eventComplete:function(){this.collection.each(function(h){if(h.get("status")=="queued"){h.set("status","init")}});this.counter.running=0;this._updateScreen()},_eventFtp:function(){if(!this.ftp.visible){this.ftp.empty();this.ftp.append((new g(this)).$el);this.ftp.show()}else{this.ftp.hide()}},_eventCreate:function(){this.uploadbox.add([{name:"New File",size:0,mode:"new"}])},_eventStart:function(){if(this.counter.announce==0||this.counter.running>0){return}var h=this;this.upload_size=0;this.upload_completed=0;this.collection.each(function(i){if(i.get("status")=="init"){i.set("status","queued");h.upload_size+=i.get("file_size")}});this.ui_button.set("percentage",0);this.ui_button.set("status","success");this.counter.running=this.counter.announce;this._updateScreen();this.uploadbox.start()},_eventStop:function(){if(this.counter.running==0){return}this.ui_button.set("status","info");this.uploadbox.stop();$("#upload-info").html("Queue will pause after completing the current file...")},_eventReset:function(){if(this.counter.running==0){this.collection.reset();this.counter.reset();this._updateScreen();this.uploadbox.reset();this.ui_button.set("percentage",0)}},_updateUser:function(){this.current_user=Galaxy.currUser.get("id");this.current_history=null;if(this.current_user){this.current_history=Galaxy.currHistoryPanel.model.get("id")}},_updateScreen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible()){message="You can Drag & Drop files into this box."}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Some supported browsers are: Firefox 4+, Chrome 7+, IE 10+, Opera 12+ or Safari 6+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Start' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Start")}else{this.modal.disableButton("Start")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Choose local file");this.modal.enableButton("Choose FTP file");this.modal.enableButton("Paste/Fetch data")}else{this.modal.disableButton("Choose local file");this.modal.disableButton("Choose FTP file");this.modal.disableButton("Paste/Fetch data")}if(this.current_user&&this.options.ftp_upload_dir&&this.options.ftp_upload_site){this.modal.showButton("Choose FTP file")}else{this.modal.hideButton("Choose FTP file")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("#upload-table").show()}else{$(this.el).find("#upload-table").hide()}},_upload_percentage:function(h,i){return(this.upload_completed+(h*i))/this.upload_size},_template:function(i,h){return'<div id="'+i+'" class="upload-box"><table id="upload-table" class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Genome</th><th>Settings</th><th>Status</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+h+'" class="upload-info"></h6>'}})});
\ No newline at end of file
+define(["utils/utils","mvc/upload/upload-button","mvc/upload/upload-model","mvc/upload/upload-row","mvc/upload/upload-ftp","mvc/ui/ui-popover","mvc/ui/ui-modal","mvc/ui","utils/uploadbox"],function(f,e,c,b,g,d,a){return Backbone.View.extend({options:{nginx_upload_path:""},modal:null,ui_button:null,uploadbox:null,current_history:null,upload_size:0,list_extensions:[],list_genomes:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},collection:new c.Collection(),ftp:null,counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},initialize:function(i){var h=this;if(i){this.options=_.defaults(i,this.options)}if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){h.initialize()},500);return}this.ui_button=new e.Model({icon:"fa-upload",tooltip:"Download from URL or upload files from disk",label:"Load Data",onclick:function(j){if(j){j.preventDefault();h.show()}},onunload:function(){if(h.counter.running>0){return"Several uploads are still processing."}}});$("#left .unified-panel-header-inner").append((new e.View(this.ui_button)).$el);var h=this;f.get(galaxy_config.root+"api/datatypes?extension_only=False",function(j){for(key in j){h.list_extensions.push({id:j[key].extension,text:j[key].extension,description:j[key].description,description_url:j[key].description_url})}h.list_extensions.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0});if(!h.options.datatypes_disable_auto){h.list_extensions.unshift(h.auto)}});f.get(galaxy_config.root+"api/genomes",function(j){for(key in j){h.list_genomes.push({id:j[key][1],text:j[key][0]})}h.list_genomes.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0})});this.collection.on("remove",function(j){h._eventRemove(j)});this.collection.on("change:genome",function(k){var j=k.get("genome");h.collection.each(function(l){if(l.get("status")=="init"&&l.get("genome")=="?"){l.set("genome",j)}})})},show:function(){if(!this.modal){var h=this;this.modal=new a.View({title:"Download data directly from web or upload files from your disk",body:this._template("upload-box","upload-info"),buttons:{"Choose local file":function(){h.uploadbox.select()},"Choose FTP file":function(){h._eventFtp()},"Paste/Fetch data":function(){h._eventCreate()},Start:function(){h._eventStart()},Pause:function(){h._eventStop()},Reset:function(){h._eventReset()},Close:function(){h.modal.hide()},},height:"400",width:"900",closing_events:true});this.setElement("#upload-box");var h=this;this.uploadbox=this.$el.uploadbox({announce:function(j,k,l){h._eventAnnounce(j,k,l)},initialize:function(j,k,l){return h._eventInitialize(j,k,l)},progress:function(j,k,l){h._eventProgress(j,k,l)},success:function(j,k,l){h._eventSuccess(j,k,l)},error:function(j,k,l){h._eventError(j,k,l)},complete:function(){h._eventComplete()}});var i=this.modal.getButton("Choose FTP file");this.ftp=new d.View({title:"FTP files",container:i})}this.modal.show();this._updateUser();this._updateScreen()},_eventRemove:function(i){var h=i.get("status");if(h=="success"){this.counter.success--}else{if(h=="error"){this.counter.error--}else{this.counter.announce--}}this._updateScreen();this.uploadbox.remove(i.id)},_eventAnnounce:function(h,i,k){this.counter.announce++;this._updateScreen();var j=new b(this,{id:h,file_name:i.name,file_size:i.size,file_mode:i.mode,file_path:i.path});this.collection.add(j.model);$(this.el).find("tbody:first").append(j.$el);j.render()},_eventInitialize:function(m,j,s){var k=this.collection.get(m);k.set("status","running");var o=k.get("file_name");var n=k.get("file_path");var h=k.get("file_mode");var p=k.get("extension");var r=k.get("genome");var q=k.get("url_paste");var l=k.get("space_to_tabs");var i=k.get("to_posix_lines");if(!q&&!(j.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path});if(h=="local"){this.uploadbox.configure({paramname:"files_0|file_data"})}else{this.uploadbox.configure({paramname:null})}tool_input={};if(h=="new"){tool_input["files_0|url_paste"]=q}if(h=="ftp"){tool_input["files_0|ftp_files"]=n}tool_input.dbkey=r;tool_input.file_type=p;tool_input["files_0|type"]="upload_dataset";tool_input.space_to_tabs=l;tool_input.to_posix_lines=i;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},_eventProgress:function(i,j,h){var k=this.collection.get(i);k.set("percentage",h);this.ui_button.set("percentage",this._upload_percentage(h,j.size))},_eventSuccess:function(i,j,l){var k=this.collection.get(i);k.set("percentage",100);k.set("status","success");var h=k.get("file_size");this.ui_button.set("percentage",this._upload_percentage(100,h));this.upload_completed+=h*100;this.counter.announce--;this.counter.success++;this._updateScreen();Galaxy.currHistoryPanel.refreshContents()},_eventError:function(h,i,k){var j=this.collection.get(h);j.set("percentage",100);j.set("status","error");j.set("info",k);this.ui_button.set("percentage",this._upload_percentage(100,i.size));this.ui_button.set("status","danger");this.upload_completed+=i.size*100;this.counter.announce--;this.counter.error++;this._updateScreen()},_eventComplete:function(){this.collection.each(function(h){if(h.get("status")=="queued"){h.set("status","init")}});this.counter.running=0;this._updateScreen()},_eventFtp:function(){if(!this.ftp.visible){this.ftp.empty();this.ftp.append((new g(this)).$el);this.ftp.show()}else{this.ftp.hide()}},_eventCreate:function(){this.uploadbox.add([{name:"New File",size:0,mode:"new"}])},_eventStart:function(){if(this.counter.announce==0||this.counter.running>0){return}var h=this;this.upload_size=0;this.upload_completed=0;this.collection.each(function(i){if(i.get("status")=="init"){i.set("status","queued");h.upload_size+=i.get("file_size")}});this.ui_button.set("percentage",0);this.ui_button.set("status","success");this.counter.running=this.counter.announce;this._updateScreen();this.uploadbox.start()},_eventStop:function(){if(this.counter.running==0){return}this.ui_button.set("status","info");this.uploadbox.stop();$("#upload-info").html("Queue will pause after completing the current file...")},_eventReset:function(){if(this.counter.running==0){this.collection.reset();this.counter.reset();this._updateScreen();this.uploadbox.reset();this.ui_button.set("percentage",0)}},_updateUser:function(){this.current_user=Galaxy.currUser.get("id");this.current_history=null;if(this.current_user){this.current_history=Galaxy.currHistoryPanel.model.get("id")}},_updateScreen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible()){message="You can Drag & Drop files into this box."}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Some supported browsers are: Firefox 4+, Chrome 7+, IE 10+, Opera 12+ or Safari 6+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Start' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Start")}else{this.modal.disableButton("Start")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Choose local file");this.modal.enableButton("Choose FTP file");this.modal.enableButton("Paste/Fetch data")}else{this.modal.disableButton("Choose local file");this.modal.disableButton("Choose FTP file");this.modal.disableButton("Paste/Fetch data")}if(this.current_user&&this.options.ftp_upload_dir&&this.options.ftp_upload_site){this.modal.showButton("Choose FTP file")}else{this.modal.hideButton("Choose FTP file")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("#upload-table").show()}else{$(this.el).find("#upload-table").hide()}},_upload_percentage:function(h,i){return(this.upload_completed+(h*i))/this.upload_size},_template:function(i,h){return'<div id="'+i+'" class="upload-box"><table id="upload-table" class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Genome</th><th>Settings</th><th>Status</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+h+'" class="upload-info"></h6>'}})});
\ 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.
1
0
commit/galaxy-central: carlfeberhard: List panel, history panels: allow keyboard shortcut for selection of sub-view: ALT+clicking the title bar of history contents will not expand the details but select the content and show the multiselect controls
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/cf1550da8998/
Changeset: cf1550da8998
User: carlfeberhard
Date: 2014-09-29 16:36:20+00:00
Summary: List panel, history panels: allow keyboard shortcut for selection of sub-view: ALT+clicking the title bar of history contents will not expand the details but select the content and show the multiselect controls
Affected #: 6 files
diff -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 -r cf1550da899848378f9c5e5ca00818c029c3a1bb client/galaxy/scripts/mvc/list/list-item.js
--- a/client/galaxy/scripts/mvc/list/list-item.js
+++ b/client/galaxy/scripts/mvc/list/list-item.js
@@ -261,7 +261,14 @@
/** expand when the title bar is clicked */
_clickTitleBar : function( event ){
event.stopPropagation();
- this.toggleExpanded();
+ if( event.altKey ){
+ this.toggleSelect( event );
+ if( !this.selectable ){
+ this.showSelector();
+ }
+ } else {
+ this.toggleExpanded();
+ }
},
/** expand when the title bar is in focus and enter or space is pressed */
diff -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 -r cf1550da899848378f9c5e5ca00818c029c3a1bb client/galaxy/scripts/mvc/list/list-panel.js
--- a/client/galaxy/scripts/mvc/list/list-panel.js
+++ b/client/galaxy/scripts/mvc/list/list-panel.js
@@ -191,6 +191,8 @@
if( lastSelectedView ){
this.selectRange( view, lastSelectedView );
}
+ } else if( ev && ev.altKey && !this.selecting ){
+ this.showSelectors();
}
this.selected.push( view.model.id );
this.lastSelected = view.model.id;
diff -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 -r cf1550da899848378f9c5e5ca00818c029c3a1bb static/scripts/mvc/list/list-item.js
--- a/static/scripts/mvc/list/list-item.js
+++ b/static/scripts/mvc/list/list-item.js
@@ -261,7 +261,14 @@
/** expand when the title bar is clicked */
_clickTitleBar : function( event ){
event.stopPropagation();
- this.toggleExpanded();
+ if( event.altKey ){
+ this.toggleSelect( event );
+ if( !this.selectable ){
+ this.showSelector();
+ }
+ } else {
+ this.toggleExpanded();
+ }
},
/** expand when the title bar is in focus and enter or space is pressed */
diff -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 -r cf1550da899848378f9c5e5ca00818c029c3a1bb static/scripts/mvc/list/list-panel.js
--- a/static/scripts/mvc/list/list-panel.js
+++ b/static/scripts/mvc/list/list-panel.js
@@ -191,6 +191,8 @@
if( lastSelectedView ){
this.selectRange( view, lastSelectedView );
}
+ } else if( ev && ev.altKey && !this.selecting ){
+ this.showSelectors();
}
this.selected.push( view.model.id );
this.lastSelected = view.model.id;
diff -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 -r cf1550da899848378f9c5e5ca00818c029c3a1bb static/scripts/packed/mvc/list/list-item.js
--- a/static/scripts/packed/mvc/list/list-item.js
+++ b/static/scripts/packed/mvc/list/list-item.js
@@ -1,1 +1,1 @@
-define(["mvc/base-mvc","utils/localization"],function(b,d){var e=Backbone.View.extend(b.LoggableMixin).extend({initialize:function(f){this.expanded=f.expanded||false;this.fxSpeed=f.fxSpeed||this.fxSpeed},fxSpeed:"fast",render:function(g){var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){var f=$(this.templates.el(this.model.toJSON(),this));if(this.expanded){this.$details(f).replaceWith(this._renderDetails().show())}return f},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){this.trigger("rendered",f);i()}])},_swapNewRender:function(f){return this.$el.empty().attr("class",this.className).append(f.children())},_setUpBehaviors:function(f){f=f||this.$el;f.find("[title]").tooltip({placement:"bottom"})},$details:function(f){f=f||this.$el;return f.find("> .details")},_renderDetails:function(){var f=$(this.templates.details(this.model.toJSON(),this));this._setUpBehaviors(f);return f},toggleExpanded:function(f){f=(f===undefined)?(!this.expanded):(f);if(f){this.expand()}else{this.collapse()}return this},expand:function(){var f=this;return f._fetchModelDetails().always(function(){var g=f._renderDetails();f.$details().replaceWith(g);f.expanded=true;f.$details().slideDown(f.fxSpeed,function(){f.trigger("expanded",f)})})},_fetchModelDetails:function(){if(!this.model.hasDetails()){return this.model.fetch()}return jQuery.when()},collapse:function(){this.debug(this+"(ExpandableView).collapse");var f=this;f.expanded=false;this.$details().slideUp(f.fxSpeed,function(){f.trigger("collapsed",f)})}});var a=e.extend(b.mixin(b.SelectableViewMixin,b.DraggableViewMixin,{tagName:"div",className:"list-item",initialize:function(f){e.prototype.initialize.call(this,f);b.SelectableViewMixin.initialize.call(this,f);b.DraggableViewMixin.initialize.call(this,f);this._setUpListeners()},_setUpListeners:function(){this.on("selectable",function(f){if(f){this.$(".primary-actions").hide()}else{this.$(".primary-actions").show()}},this);return this},_buildNewRender:function(){var f=e.prototype._buildNewRender.call(this);f.children(".warnings").replaceWith(this._renderWarnings());f.children(".title-bar").replaceWith(this._renderTitleBar());f.children(".primary-actions").append(this._renderPrimaryActions());f.find(".title-bar .subtitle").replaceWith(this._renderSubtitle());return f},_swapNewRender:function(f){e.prototype._swapNewRender.call(this,f);if(this.selectable){this.showSelector(0)}if(this.draggable){this.draggableOn()}return this.$el},_renderWarnings:function(){var f=this,h=$('<div class="warnings"></div>'),g=f.model.toJSON();_.each(f.templates.warnings,function(i){h.append($(i(g,f)))});return h},_renderTitleBar:function(){return $(this.templates.titleBar(this.model.toJSON(),this))},_renderPrimaryActions:function(){return[]},_renderSubtitle:function(){return $(this.templates.subtitle(this.model.toJSON(),this))},events:{"click .title-bar":"_clickTitleBar","keydown .title-bar":"_keyDownTitleBar","click .selector":"toggleSelect"},_clickTitleBar:function(f){f.stopPropagation();this.toggleExpanded()},_keyDownTitleBar:function(h){var f=32,g=13;if(h&&(h.type==="keydown")&&(h.keyCode===f||h.keyCode===g)){this.toggleExpanded();h.stopPropagation();return false}return true},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"ListItemView("+f+")"}}));a.prototype.templates=(function(){var h=b.wrapTemplate(['<div class="list-element">','<div class="warnings"></div>','<div class="selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="primary-actions"></div>','<div class="title-bar"></div>','<div class="details"></div>',"</div>"]);var f={};var i=b.wrapTemplate(['<div class="title-bar clear" tabindex="0">','<span class="state-icon"></span>','<div class="title">','<span class="name"><%- element.name %></span>',"</div>",'<div class="subtitle"></div>',"</div>"],"element");var j=b.wrapTemplate(['<div class="subtitle"></div>']);var g=b.wrapTemplate(['<div class="details"></div>']);return{el:h,warnings:f,titleBar:i,subtitle:j,details:g}}());var c=a.extend({foldoutStyle:"foldout",foldoutPanelClass:null,initialize:function(f){a.prototype.initialize.call(this,f);if(this.foldoutStyle==="drilldown"){this.expanded=false}this.foldoutStyle=f.foldoutStyle||this.foldoutStyle;this.foldoutPanelClass=f.foldoutPanelClass||this.foldoutPanelClass},_renderDetails:function(){if(this.foldoutStyle==="drilldown"){return $()}var f=a.prototype._renderDetails.call(this);return this._attachFoldout(this._createFoldoutPanel(),f)},_createFoldoutPanel:function(){var h=this.model;var i=this._getFoldoutPanelClass(h),g=this._getFoldoutPanelOptions(h),f=new i(_.extend(g,{model:h}));return f},_getFoldoutPanelClass:function(){return this.foldoutPanelClass},_getFoldoutPanelOptions:function(){return{foldoutStyle:this.foldoutStyle}},_attachFoldout:function(f,g){g=g||this.$("> .details");this.foldout=f.render(0);f.$("> .controls").hide();return g.append(f.$el)},expand:function(){var f=this;return f._fetchModelDetails().always(function(){if(f.foldoutStyle==="foldout"){f._expandByFoldout()}else{if(f.foldoutStyle==="drilldown"){f._expandByDrilldown()}}})},_expandByFoldout:function(){var f=this;var g=f._renderDetails();f.$details().replaceWith(g);f.expanded=true;f.$details().slideDown(f.fxSpeed,function(){f.trigger("expanded",f)})},_expandByDrilldown:function(){var f=this;f.foldout=this._createFoldoutPanel();f.foldout.on("close",function(){f.trigger("collapsed:drilldown",f,f.foldout)});f.trigger("expanded:drilldown",f,f.foldout)}});c.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="details">',"</div>"],"collection");return _.extend({},a.prototype.templates,{details:f})}());return{ExpandableView:e,ListItemView:a,FoldoutListItemView:c}});
\ No newline at end of file
+define(["mvc/base-mvc","utils/localization"],function(b,d){var e=Backbone.View.extend(b.LoggableMixin).extend({initialize:function(f){this.expanded=f.expanded||false;this.fxSpeed=f.fxSpeed||this.fxSpeed},fxSpeed:"fast",render:function(g){var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){var f=$(this.templates.el(this.model.toJSON(),this));if(this.expanded){this.$details(f).replaceWith(this._renderDetails().show())}return f},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){this.trigger("rendered",f);i()}])},_swapNewRender:function(f){return this.$el.empty().attr("class",this.className).append(f.children())},_setUpBehaviors:function(f){f=f||this.$el;f.find("[title]").tooltip({placement:"bottom"})},$details:function(f){f=f||this.$el;return f.find("> .details")},_renderDetails:function(){var f=$(this.templates.details(this.model.toJSON(),this));this._setUpBehaviors(f);return f},toggleExpanded:function(f){f=(f===undefined)?(!this.expanded):(f);if(f){this.expand()}else{this.collapse()}return this},expand:function(){var f=this;return f._fetchModelDetails().always(function(){var g=f._renderDetails();f.$details().replaceWith(g);f.expanded=true;f.$details().slideDown(f.fxSpeed,function(){f.trigger("expanded",f)})})},_fetchModelDetails:function(){if(!this.model.hasDetails()){return this.model.fetch()}return jQuery.when()},collapse:function(){this.debug(this+"(ExpandableView).collapse");var f=this;f.expanded=false;this.$details().slideUp(f.fxSpeed,function(){f.trigger("collapsed",f)})}});var a=e.extend(b.mixin(b.SelectableViewMixin,b.DraggableViewMixin,{tagName:"div",className:"list-item",initialize:function(f){e.prototype.initialize.call(this,f);b.SelectableViewMixin.initialize.call(this,f);b.DraggableViewMixin.initialize.call(this,f);this._setUpListeners()},_setUpListeners:function(){this.on("selectable",function(f){if(f){this.$(".primary-actions").hide()}else{this.$(".primary-actions").show()}},this);return this},_buildNewRender:function(){var f=e.prototype._buildNewRender.call(this);f.children(".warnings").replaceWith(this._renderWarnings());f.children(".title-bar").replaceWith(this._renderTitleBar());f.children(".primary-actions").append(this._renderPrimaryActions());f.find(".title-bar .subtitle").replaceWith(this._renderSubtitle());return f},_swapNewRender:function(f){e.prototype._swapNewRender.call(this,f);if(this.selectable){this.showSelector(0)}if(this.draggable){this.draggableOn()}return this.$el},_renderWarnings:function(){var f=this,h=$('<div class="warnings"></div>'),g=f.model.toJSON();_.each(f.templates.warnings,function(i){h.append($(i(g,f)))});return h},_renderTitleBar:function(){return $(this.templates.titleBar(this.model.toJSON(),this))},_renderPrimaryActions:function(){return[]},_renderSubtitle:function(){return $(this.templates.subtitle(this.model.toJSON(),this))},events:{"click .title-bar":"_clickTitleBar","keydown .title-bar":"_keyDownTitleBar","click .selector":"toggleSelect"},_clickTitleBar:function(f){f.stopPropagation();if(f.altKey){this.toggleSelect(f);if(!this.selectable){this.showSelector()}}else{this.toggleExpanded()}},_keyDownTitleBar:function(h){var f=32,g=13;if(h&&(h.type==="keydown")&&(h.keyCode===f||h.keyCode===g)){this.toggleExpanded();h.stopPropagation();return false}return true},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"ListItemView("+f+")"}}));a.prototype.templates=(function(){var h=b.wrapTemplate(['<div class="list-element">','<div class="warnings"></div>','<div class="selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="primary-actions"></div>','<div class="title-bar"></div>','<div class="details"></div>',"</div>"]);var f={};var i=b.wrapTemplate(['<div class="title-bar clear" tabindex="0">','<span class="state-icon"></span>','<div class="title">','<span class="name"><%- element.name %></span>',"</div>",'<div class="subtitle"></div>',"</div>"],"element");var j=b.wrapTemplate(['<div class="subtitle"></div>']);var g=b.wrapTemplate(['<div class="details"></div>']);return{el:h,warnings:f,titleBar:i,subtitle:j,details:g}}());var c=a.extend({foldoutStyle:"foldout",foldoutPanelClass:null,initialize:function(f){a.prototype.initialize.call(this,f);if(this.foldoutStyle==="drilldown"){this.expanded=false}this.foldoutStyle=f.foldoutStyle||this.foldoutStyle;this.foldoutPanelClass=f.foldoutPanelClass||this.foldoutPanelClass},_renderDetails:function(){if(this.foldoutStyle==="drilldown"){return $()}var f=a.prototype._renderDetails.call(this);return this._attachFoldout(this._createFoldoutPanel(),f)},_createFoldoutPanel:function(){var h=this.model;var i=this._getFoldoutPanelClass(h),g=this._getFoldoutPanelOptions(h),f=new i(_.extend(g,{model:h}));return f},_getFoldoutPanelClass:function(){return this.foldoutPanelClass},_getFoldoutPanelOptions:function(){return{foldoutStyle:this.foldoutStyle}},_attachFoldout:function(f,g){g=g||this.$("> .details");this.foldout=f.render(0);f.$("> .controls").hide();return g.append(f.$el)},expand:function(){var f=this;return f._fetchModelDetails().always(function(){if(f.foldoutStyle==="foldout"){f._expandByFoldout()}else{if(f.foldoutStyle==="drilldown"){f._expandByDrilldown()}}})},_expandByFoldout:function(){var f=this;var g=f._renderDetails();f.$details().replaceWith(g);f.expanded=true;f.$details().slideDown(f.fxSpeed,function(){f.trigger("expanded",f)})},_expandByDrilldown:function(){var f=this;f.foldout=this._createFoldoutPanel();f.foldout.on("close",function(){f.trigger("collapsed:drilldown",f,f.foldout)});f.trigger("expanded:drilldown",f,f.foldout)}});c.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="details">',"</div>"],"collection");return _.extend({},a.prototype.templates,{details:f})}());return{ExpandableView:e,ListItemView:a,FoldoutListItemView:c}});
\ No newline at end of file
diff -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 -r cf1550da899848378f9c5e5ca00818c029c3a1bb static/scripts/packed/mvc/list/list-panel.js
--- a/static/scripts/packed/mvc/list/list-panel.js
+++ b/static/scripts/packed/mvc/list/list-panel.js
@@ -1,1 +1,1 @@
-define(["mvc/list/list-item","mvc/base-mvc","utils/localization"],function(d,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),multiselectActions:[],initialize:function(f,g){f=f||{};if(f.logger){this.logger=f.logger}this.log(this+".initialize:",f);this.fxSpeed=_.has(f,"fxSpeed")?(f.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=f.searchFor||"";this.indicator=new LoadingIndicator(this.$el);this.selecting=(f.selecting!==undefined)?f.selecting:true;this.selected=f.selected||[];this.lastSelected=null;this.dragItems=f.dragItems||false;this.viewClass=f.viewClass||this.viewClass;this.views=[];this.collection=f.collection||(new this.collectionClass([]));this.filters=f.filters||[];this.$scrollContainer=f.$scrollContainer||this.$scrollContainer;this.title=f.title||"";this.subtitle=f.subtitle||"";this.multiselectActions=f.multiselectActions||this.multiselectActions;this.actionsPopup=null;this._setUpListeners()},freeViews:function(){_.each(this.views,function(f){f.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(g,j,f,i,h){console.error(g,j,f,i,h)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(f){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(g,j,f,i,h){this.trigger("error",g,j,f,i,h)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(f){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(f,g){if(g&&g.shiftKey&&this.lastSelected){var h=this.viewFromModelId(this.lastSelected);if(h){this.selectRange(f,h)}}this.selected.push(f.model.id);this.lastSelected=f.model.id},this);this.on("view:de-selected",function(f,g){this.selected=_.without(this.selected,f.model.id)},this)},render:function(g){this.log(this+".render",g);var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var f=$(this.templates.el({},this));this._renderControls(f);this._renderTitle(f);this._renderSubtitle(f);this._renderSearch(f);this.renderItems(f);return f},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var f=$(this.templates.controls({},this));g.find(".controls").replaceWith(f);return f},_renderTitle:function(f){},_renderSubtitle:function(f){},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;f.log("_queueNewRender:",g,h);$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){f.trigger("rendered",f);i()}])},_swapNewRender:function(f){this.$el.empty().attr("class",this.className).append(f.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(f){f=f||this.$el;f.find(".controls [title]").tooltip({placement:"bottom"});return this},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(f){return(f||this.$el).find("> .list-items")},$messages:function(f){return(f||this.$el).find("> .controls .messages")},$emptyMessage:function(f){return(f||this.$el).find("> .empty-message")},renderItems:function(h){h=h||this.$el;var f=this;f.log(this+".renderItems",h);var g=f.$list(h);f.views=f._filterCollection().map(function(i){return f._createItemView(i).render(0)});g.empty();if(f.views.length){f._attachItems(h);f.$emptyMessage(h).hide()}else{f._renderEmptyMessage(h).show()}return f.views},_filterCollection:function(){var f=this;return f.collection.filter(_.bind(f._filterItem,f))},_filterItem:function(g){var f=this;return(_.every(f.filters.map(function(h){return h.call(g)})))&&(!f.searchFor||g.matchesAll(f.searchFor))},_createItemView:function(h){var i=this._getItemViewClass(h),g=_.extend(this._getItemViewOptions(h),{model:h}),f=new i(g);this._setUpItemViewListeners(f);return f},_getItemViewClass:function(f){return this.viewClass},_getItemViewOptions:function(f){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,f.id),draggable:this.dragItems}},_setUpItemViewListeners:function(g){var f=this;g.on("all",function(){var h=Array.prototype.slice.call(arguments,0);h[0]="view:"+h[0];f.trigger.apply(f,h)});g.on("draggable:dragstart",function(k,h){var i={},j=this.getSelectedModels();if(j.length){i=j.toJSON()}else{i=[h.model.toJSON()]}k.dataTransfer.setData("text",JSON.stringify(i))},this);return f},_attachItems:function(f){this.$list(f).append(this.views.map(function(g){return g.$el}));return this},_renderEmptyMessage:function(f){this.debug("_renderEmptyMessage",f,this.searchFor);var g=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(f).text(g)},expandAll:function(){_.each(this.views,function(f){f.expand()})},collapseAll:function(){_.each(this.views,function(f){f.collapse()})},addItemView:function(i,j,h){this.log(this+".addItemView:",i);var g=this;if(!g._filterItem(i)){return undefined}var f=g._createItemView(i);$(f).queue("fx",[function(k){g.$emptyMessage().fadeOut(g.fxSpeed,k)},function(k){g._attachView(f);k()}]);return f},_attachView:function(g){var f=this;f.views.push(g);f.$list().append(g.render(0).$el.hide());g.$el.slideDown(f.fxSpeed)},removeItemView:function(i,j,h){this.log(this+".removeItemView:",i);var g=this,f=g.viewFromModel(i);if(!f){return undefined}$({}).queue("fx",[function(k){f.$el.fadeOut(g.fxSpeed,k)},function(k){g.views=_.without(g.views,f);f.remove();if(!g.views.length){g._renderEmptyMessage().fadeIn(g.fxSpeed,k)}else{k()}}]);return f},viewFromModelId:function(g){for(var f=0;f<this.views.length;f++){if(this.views[f].model.id===g){return this.views[f]}}return undefined},viewFromModel:function(f){return this.viewFromModelId(f.id)},viewsWhereModel:function(f){return this.views.filter(function(g){var i=g.model.toJSON();for(var h in f){if(f.hasOwnProperty(h)){if(i[h]!==g.model.get(h)){return false}}}return true})},viewRange:function(i,h){if(i===h){return(i)?([i]):([])}var g=this.views.indexOf(i),f=this.views.indexOf(h);if(g===-1||f===-1){if(g===f){return[]}return(g===-1)?([h]):([i])}return(g<f)?this.views.slice(g,f+1):this.views.slice(f,g+1)},_renderSearch:function(f){f.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return f},_firstSearch:function(f){this.log("onFirstSearch",f);return this.searchItems(f)},searchItems:function(f){this.searchFor=f;this.trigger("search:searching",f,this);this.renderItems();this.$("> .controls .search-query").val(f);return this},clearSearch:function(f){this.searchFor="";this.trigger("search:clear",this);this.renderItems();this.$("> .controls .search-query").val("");return this},showSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(f);_.each(this.views,function(g){g.showSelector(f)})},hideSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(f);_.each(this.views,function(g){g.hideSelector(f)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(f){_.each(this.views,function(g){g.select(f)})},deselectAll:function(f){this.lastSelected=null;_.each(this.views,function(g){g.deselect(f)})},selectRange:function(h,g){var f=this.viewRange(h,g);_.each(f,function(i){i.select()});return f},getSelectedViews:function(){return _.filter(this.views,function(f){return f.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(f){return f.model}))},_showLoadingIndicator:function(g,f,h){this.debug("_showLoadingIndicator",this.indicator,g,f,h);f=(f!==undefined)?(f):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,h)}else{this.$el.fadeOut(f);this.indicator.show(g,f,h)}},_hideLoadingIndicator:function(f,g){this.debug("_hideLoadingIndicator",this.indicator,f,g);f=(f!==undefined)?(f):(this.fxSpeed);if(this.indicator){this.indicator.hide(f,g)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(g,f){f=f||0;this.$scrollContainer().animate({scrollTop:g},f);return this},scrollToTop:function(f){return this.scrollTo(0,f)},scrollToItem:function(f,h){if(!f){return this}var g=f.$el.position().top;return this.scrollTo(g,h)},scrollToId:function(g,f){return this.scrollToItem(this.viewFromModelId(g),f)},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var g=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></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">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return{el:g,controls:f}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(f){e.prototype.initialize.call(this,f);this.selecting=(f.selecting!==undefined)?f.selecting:false;this.setModel(this.model,f)},setModel:function(g,f){f=f||{};this.debug(this+".setModel:",g,f);this.freeModel();this.freeViews();if(g){var h=this.model?this.model.get("id"):null;this.model=g;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(f.collection||(new this.collectionClass([])));this._setUpCollectionListeners();if(h&&g.get("id")!==h){this.trigger("new-model",this)}}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){this.trigger.apply(panel,arguments)},this);return this},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var h=this.model?this.model.toJSON():{},f=$(this.templates.controls(h,this));g.find(".controls").replaceWith(f);return f},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></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">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:f})}());return{ListPanel:e,ModelListPanel:a}});
\ No newline at end of file
+define(["mvc/list/list-item","mvc/base-mvc","utils/localization"],function(d,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),multiselectActions:[],initialize:function(f,g){f=f||{};if(f.logger){this.logger=f.logger}this.log(this+".initialize:",f);this.fxSpeed=_.has(f,"fxSpeed")?(f.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=f.searchFor||"";this.indicator=new LoadingIndicator(this.$el);this.selecting=(f.selecting!==undefined)?f.selecting:true;this.selected=f.selected||[];this.lastSelected=null;this.dragItems=f.dragItems||false;this.viewClass=f.viewClass||this.viewClass;this.views=[];this.collection=f.collection||(new this.collectionClass([]));this.filters=f.filters||[];this.$scrollContainer=f.$scrollContainer||this.$scrollContainer;this.title=f.title||"";this.subtitle=f.subtitle||"";this.multiselectActions=f.multiselectActions||this.multiselectActions;this.actionsPopup=null;this._setUpListeners()},freeViews:function(){_.each(this.views,function(f){f.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(g,j,f,i,h){console.error(g,j,f,i,h)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(f){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(g,j,f,i,h){this.trigger("error",g,j,f,i,h)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(f){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(f,g){if(g&&g.shiftKey&&this.lastSelected){var h=this.viewFromModelId(this.lastSelected);if(h){this.selectRange(f,h)}}else{if(g&&g.altKey&&!this.selecting){this.showSelectors()}}this.selected.push(f.model.id);this.lastSelected=f.model.id},this);this.on("view:de-selected",function(f,g){this.selected=_.without(this.selected,f.model.id)},this)},render:function(g){this.log(this+".render",g);var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var f=$(this.templates.el({},this));this._renderControls(f);this._renderTitle(f);this._renderSubtitle(f);this._renderSearch(f);this.renderItems(f);return f},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var f=$(this.templates.controls({},this));g.find(".controls").replaceWith(f);return f},_renderTitle:function(f){},_renderSubtitle:function(f){},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;f.log("_queueNewRender:",g,h);$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){f.trigger("rendered",f);i()}])},_swapNewRender:function(f){this.$el.empty().attr("class",this.className).append(f.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(f){f=f||this.$el;f.find(".controls [title]").tooltip({placement:"bottom"});return this},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(f){return(f||this.$el).find("> .list-items")},$messages:function(f){return(f||this.$el).find("> .controls .messages")},$emptyMessage:function(f){return(f||this.$el).find("> .empty-message")},renderItems:function(h){h=h||this.$el;var f=this;f.log(this+".renderItems",h);var g=f.$list(h);f.views=f._filterCollection().map(function(i){return f._createItemView(i).render(0)});g.empty();if(f.views.length){f._attachItems(h);f.$emptyMessage(h).hide()}else{f._renderEmptyMessage(h).show()}return f.views},_filterCollection:function(){var f=this;return f.collection.filter(_.bind(f._filterItem,f))},_filterItem:function(g){var f=this;return(_.every(f.filters.map(function(h){return h.call(g)})))&&(!f.searchFor||g.matchesAll(f.searchFor))},_createItemView:function(h){var i=this._getItemViewClass(h),g=_.extend(this._getItemViewOptions(h),{model:h}),f=new i(g);this._setUpItemViewListeners(f);return f},_getItemViewClass:function(f){return this.viewClass},_getItemViewOptions:function(f){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,f.id),draggable:this.dragItems}},_setUpItemViewListeners:function(g){var f=this;g.on("all",function(){var h=Array.prototype.slice.call(arguments,0);h[0]="view:"+h[0];f.trigger.apply(f,h)});g.on("draggable:dragstart",function(k,h){var i={},j=this.getSelectedModels();if(j.length){i=j.toJSON()}else{i=[h.model.toJSON()]}k.dataTransfer.setData("text",JSON.stringify(i))},this);return f},_attachItems:function(f){this.$list(f).append(this.views.map(function(g){return g.$el}));return this},_renderEmptyMessage:function(f){this.debug("_renderEmptyMessage",f,this.searchFor);var g=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(f).text(g)},expandAll:function(){_.each(this.views,function(f){f.expand()})},collapseAll:function(){_.each(this.views,function(f){f.collapse()})},addItemView:function(i,j,h){this.log(this+".addItemView:",i);var g=this;if(!g._filterItem(i)){return undefined}var f=g._createItemView(i);$(f).queue("fx",[function(k){g.$emptyMessage().fadeOut(g.fxSpeed,k)},function(k){g._attachView(f);k()}]);return f},_attachView:function(g){var f=this;f.views.push(g);f.$list().append(g.render(0).$el.hide());g.$el.slideDown(f.fxSpeed)},removeItemView:function(i,j,h){this.log(this+".removeItemView:",i);var g=this,f=g.viewFromModel(i);if(!f){return undefined}$({}).queue("fx",[function(k){f.$el.fadeOut(g.fxSpeed,k)},function(k){g.views=_.without(g.views,f);f.remove();if(!g.views.length){g._renderEmptyMessage().fadeIn(g.fxSpeed,k)}else{k()}}]);return f},viewFromModelId:function(g){for(var f=0;f<this.views.length;f++){if(this.views[f].model.id===g){return this.views[f]}}return undefined},viewFromModel:function(f){return this.viewFromModelId(f.id)},viewsWhereModel:function(f){return this.views.filter(function(g){var i=g.model.toJSON();for(var h in f){if(f.hasOwnProperty(h)){if(i[h]!==g.model.get(h)){return false}}}return true})},viewRange:function(i,h){if(i===h){return(i)?([i]):([])}var g=this.views.indexOf(i),f=this.views.indexOf(h);if(g===-1||f===-1){if(g===f){return[]}return(g===-1)?([h]):([i])}return(g<f)?this.views.slice(g,f+1):this.views.slice(f,g+1)},_renderSearch:function(f){f.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return f},_firstSearch:function(f){this.log("onFirstSearch",f);return this.searchItems(f)},searchItems:function(f){this.searchFor=f;this.trigger("search:searching",f,this);this.renderItems();this.$("> .controls .search-query").val(f);return this},clearSearch:function(f){this.searchFor="";this.trigger("search:clear",this);this.renderItems();this.$("> .controls .search-query").val("");return this},showSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(f);_.each(this.views,function(g){g.showSelector(f)})},hideSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(f);_.each(this.views,function(g){g.hideSelector(f)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(f){_.each(this.views,function(g){g.select(f)})},deselectAll:function(f){this.lastSelected=null;_.each(this.views,function(g){g.deselect(f)})},selectRange:function(h,g){var f=this.viewRange(h,g);_.each(f,function(i){i.select()});return f},getSelectedViews:function(){return _.filter(this.views,function(f){return f.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(f){return f.model}))},_showLoadingIndicator:function(g,f,h){this.debug("_showLoadingIndicator",this.indicator,g,f,h);f=(f!==undefined)?(f):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,h)}else{this.$el.fadeOut(f);this.indicator.show(g,f,h)}},_hideLoadingIndicator:function(f,g){this.debug("_hideLoadingIndicator",this.indicator,f,g);f=(f!==undefined)?(f):(this.fxSpeed);if(this.indicator){this.indicator.hide(f,g)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(g,f){f=f||0;this.$scrollContainer().animate({scrollTop:g},f);return this},scrollToTop:function(f){return this.scrollTo(0,f)},scrollToItem:function(f,h){if(!f){return this}var g=f.$el.position().top;return this.scrollTo(g,h)},scrollToId:function(g,f){return this.scrollToItem(this.viewFromModelId(g),f)},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var g=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></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">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return{el:g,controls:f}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(f){e.prototype.initialize.call(this,f);this.selecting=(f.selecting!==undefined)?f.selecting:false;this.setModel(this.model,f)},setModel:function(g,f){f=f||{};this.debug(this+".setModel:",g,f);this.freeModel();this.freeViews();if(g){var h=this.model?this.model.get("id"):null;this.model=g;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(f.collection||(new this.collectionClass([])));this._setUpCollectionListeners();if(h&&g.get("id")!==h){this.trigger("new-model",this)}}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){this.trigger.apply(panel,arguments)},this);return this},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var h=this.model?this.model.toJSON():{},f=$(this.templates.controls(h,this));g.find(".controls").replaceWith(f);return f},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></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">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:f})}());return{ListPanel:e,ModelListPanel: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.
1
0
commit/galaxy-central: jgoecks: Remove references to global var.
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/31a059dcc381/
Changeset: 31a059dcc381
User: jgoecks
Date: 2014-09-29 16:24:51+00:00
Summary: Remove references to global var.
Affected #: 3 files
diff -r 991cd029642f477f3596ca6035d0830fd2c117ed -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 client/galaxy/scripts/viz/trackster/tracks.js
--- a/client/galaxy/scripts/viz/trackster/tracks.js
+++ b/client/galaxy/scripts/viz/trackster/tracks.js
@@ -1152,9 +1152,9 @@
// Update location. Only update when there is a valid chrom; when loading vis, there may
// not be a valid chrom.
- var chrom = view.chrom_select.val();
+ var chrom = this.chrom_select.val();
if (chrom !== "") {
- this.trigger_navigate(chrom, view.low, view.high, true);
+ this.trigger_navigate(chrom, this.low, this.high, true);
}
},
diff -r 991cd029642f477f3596ca6035d0830fd2c117ed -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 static/scripts/packed/viz/trackster/tracks.js
--- a/static/scripts/packed/viz/trackster/tracks.js
+++ b/static/scripts/packed/viz/trackster/tracks.js
@@ -1,1 +1,1 @@
-define(["libs/underscore","viz/visualization","viz/viz_views","viz/trackster/util","viz/trackster/slotting","viz/trackster/painters","viz/trackster/filters","mvc/data","mvc/tools","utils/config"],function(ab,w,V,j,s,J,h,X,P,R){var o=ab.extend;var l={};var i=function(ac,ad){l[ac.attr("id")]=ad};var k=function(ac,ad,af,ae){af=".group";l[ac.attr("id")]=ae;ac.bind("drag",{handle:"."+ad,relative:true},function(an,ao){var am=$(this),ar=$(this).parent(),aj=ar.children(".track,.group"),al=l[$(this).attr("id")],ai,ah,ap,ag,ak;ah=$(this).parents(af);if(ah.length!==0){ap=ah.position().top;ag=ap+ah.outerHeight();var aq=l[ah.attr("id")];if(ao.offsetY<ap){$(this).insertBefore(ah);aq.remove_drawable(al);aq.container.add_drawable_before(al,aq);return}else{if(ao.offsetY>ag){$(this).insertAfter(ah);aq.remove_drawable(al);aq.container.add_drawable(al);return}}}ah=null;for(ak=0;ak<aj.length;ak++){ai=$(aj.get(ak));ap=ai.position().top;ag=ap+ai.outerHeight();if(ai.is(af)&&this!==ai.get(0)&&ao.offsetY>=ap&&ao.offsetY<=ag){if(ao.offsetY-ap<ag-ao.offsetY){ai.find(".content-div").prepend(this)}else{ai.find(".content-div").append(this)}if(al.container){al.container.remove_drawable(al)}l[ai.attr("id")].add_drawable(al);return}}for(ak=0;ak<aj.length;ak++){ai=$(aj.get(ak));if(ao.offsetY<ai.position().top&&!(ai.hasClass("reference-track")||ai.hasClass("intro"))){break}}if(ak===aj.length){if(this!==aj.get(ak-1)){ar.append(this);l[ar.attr("id")].move_drawable(al,ak)}}else{if(this!==aj.get(ak)){$(this).insertBefore(aj.get(ak));l[ar.attr("id")].move_drawable(al,(ao.deltaY>0?ak-1:ak))}}}).bind("dragstart",function(){$(this).addClass("dragging")}).bind("dragend",function(){$(this).removeClass("dragging")})};var D=20,z=100,G=12000,Q=400,I=5000,v=100,m="Cannot display dataset due to an error. ",H="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",E="No data for this chrom/contig.",u="Preparing data. This can take a while for a large dataset. If the visualization is saved and closed, preparation will continue in the background.",x="Tool cannot be rerun: ",a="Loading data...",T="Ready for display",O=10,F=20,A=["Histogram","Line","Filled","Intensity"];function U(ad,ac){if(!ac){ac=0}var ae=Math.pow(10,ac);return Math.round(ad*ae)/ae}var p=function(ad,ac,ag){if(!p.id_counter){p.id_counter=0}this.id=p.id_counter++;this.view=ad;this.container=ac;this.drag_handle_class=ag.drag_handle_class;this.is_overview=false;this.action_icons={};this.config=R.ConfigSettingCollection.from_models_and_saved_values(this.config_params,ag.prefs);if(!this.config.get_value("name")){this.config.set_value("name",ag.name)}if(this.config_onchange){this.config.on("change",this.config_onchange,this)}this.container_div=this.build_container_div();this.header_div=null;if(ag.header!==false){var ae=new V.TrackHeaderView({model:this,id:this.id});this.header_div=ae.$el;this.container_div.append(this.header_div);var af=ae.icons_div;this.action_icons=ae.action_icons;this.container_div.hover(function(){af.show()},function(){af.hide()})}};p.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(ac){if(ac.config.get_value("content_visible")){ac.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");ac.hide_contents();ac.config.set_value("content_visible",false)}else{ac.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");ac.config.set_value("content_visible",true);ac.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"gear",on_click_fn:function(ad){var ac=new R.ConfigSettingCollectionView({collection:ad.config});ac.render_in_modal("Configure Track")}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(ac){$(".tooltip").remove();ac.remove()}}];o(p.prototype,{config_params:[{key:"name",label:"Name",type:"text",default_value:""},{key:"content_visible",type:"bool",default_value:true,hidden:true}],config_onchange:function(){},init:function(){},changed:function(){this.view.changed()},can_draw:function(){if(this.enabled&&this.config.get_value("content_visible")){return true}return false},request_draw:function(){},_draw:function(ac){},to_dict:function(){},set_name:function(ac){this.old_name=this.config.get_value("name");this.config.set_value("name",ac)},revert_name:function(){if(this.old_name){this.config.set_value("name",this.old_name)}},remove:function(){this.changed();this.container.remove_drawable(this);var ac=this.view;this.container_div.hide(0,function(){$(this).remove();ac.update_intro_div()})},build_container_div:function(){},update_icons:function(){},hide_contents:function(){},show_contents:function(){},get_drawables:function(){}});var y=function(ad,ac,ae){p.call(this,ad,ac,ae);this.obj_type=ae.obj_type;this.drawables=[]};o(y.prototype,p.prototype,{unpack_drawables:function(ae){this.drawables=[];var ad;for(var ac=0;ac<ae.length;ac++){ad=n(ae[ac],this.view,this);this.add_drawable(ad)}},init:function(){for(var ac=0;ac<this.drawables.length;ac++){this.drawables[ac].init()}},_draw:function(ac){for(var ad=0;ad<this.drawables.length;ad++){this.drawables[ad]._draw(ac)}},to_dict:function(){var ad=[];for(var ac=0;ac<this.drawables.length;ac++){ad.push(this.drawables[ac].to_dict())}return{prefs:this.config.to_key_value_dict(),obj_type:this.obj_type,drawables:ad}},add_drawable:function(ac){this.drawables.push(ac);ac.container=this;this.changed()},add_drawable_before:function(ae,ac){this.changed();var ad=this.drawables.indexOf(ac);if(ad!==-1){this.drawables.splice(ad,0,ae);return true}return false},replace_drawable:function(ae,ac,ad){var af=this.drawables.indexOf(ae);if(af!==-1){this.drawables[af]=ac;if(ad){ae.container_div.replaceWith(ac.container_div)}this.changed()}return af},remove_drawable:function(ad){var ac=this.drawables.indexOf(ad);if(ac!==-1){this.drawables.splice(ac,1);ad.container=null;this.changed();return true}return false},move_drawable:function(ad,ae){var ac=this.drawables.indexOf(ad);if(ac!==-1){this.drawables.splice(ac,1);this.drawables.splice(ae,0,ad);this.changed();return true}return false},get_drawables:function(){return this.drawables},get_tracks:function(af){var ac=this.drawables.slice(0),ad=[],ae;while(ac.length!==0){ae=ac.shift();if(ae instanceof af){ad.push(ae)}else{if(ae.drawables){ac=ac.concat(ae.drawables)}}}return ad}});var N=function(ad,ac,af){o(af,{obj_type:"DrawableGroup",drag_handle_class:"group-handle"});y.call(this,ad,ac,af);this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);i(this.container_div,this);i(this.content_div,this);k(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new h.FiltersManager(this);this.header_div.after(this.filters_manager.parent_div);this.filters_manager.parent_div.after($("<div style='clear: both'/>"));this.saved_filters_managers=[];if("drawables" in af){this.unpack_drawables(af.drawables)}if("filters" in af){var ae=this.filters_manager;this.filters_manager=new h.FiltersManager(this,af.filters);ae.parent_div.replaceWith(this.filters_manager.parent_div);if(af.filters.visible){this.setup_multitrack_filtering()}}};o(N.prototype,p.prototype,y.prototype,{action_icons_def:[p.prototype.action_icons_def[0],p.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(ac){$(".tooltip").remove();ac.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"ui-slider-050",on_click_fn:function(ac){if(ac.filters_manager.visible()){ac.filters_manager.clear_filters();ac._restore_filter_managers()}else{ac.setup_multitrack_filtering();ac.request_draw({clear_tile_cache:true})}ac.filters_manager.toggle()}},p.prototype.action_icons_def[2]],build_container_div:function(){var ac=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(ac)}return ac},hide_contents:function(){this.tiles_div.hide()},show_contents:function(){this.tiles_div.show();this.request_draw()},update_icons:function(){var ae=this.drawables.length;if(ae===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(ae===1){this.action_icons.composite_icon.toggle(this.drawables[0] instanceof e);this.action_icons.filters_icon.hide()}else{var al,ak,ai,ao=true,ag=this.drawables[0].get_type(),ac=0;for(al=0;al<ae;al++){ai=this.drawables[al];if(ai.get_type()!==ag){can_composite=false;break}if(ai instanceof c){ac++}}if(ao&&this.drawables[0] instanceof g){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tooltip").remove()}if(ac>1&&ac===this.drawables.length){var ap={},ad;ai=this.drawables[0];for(ak=0;ak<ai.filters_manager.filters.length;ak++){ad=ai.filters_manager.filters[ak];ap[ad.name]=[ad]}for(al=1;al<this.drawables.length;al++){ai=this.drawables[al];for(ak=0;ak<ai.filters_manager.filters.length;ak++){ad=ai.filters_manager.filters[ak];if(ad.name in ap){ap[ad.name].push(ad)}}}this.filters_manager.remove_all();var af,ah,aj,am;for(var an in ap){af=ap[an];if(af.length===ac){ah=new h.NumberFilter({name:af[0].name,index:af[0].index});this.filters_manager.add_filter(ah)}}this.action_icons.filters_icon.toggle(this.filters_manager.filters.length>0)}else{this.action_icons.filters_icon.hide()}}}},_restore_filter_managers:function(){for(var ac=0;ac<this.drawables.length;ac++){this.drawables[ac].filters_manager=this.saved_filters_managers[ac]}this.saved_filters_managers=[]},setup_multitrack_filtering:function(){if(this.filters_manager.filters.length>0){this.saved_filters_managers=[];for(var ac=0;ac<this.drawables.length;ac++){drawable=this.drawables[ac];this.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=this.filters_manager}}this.filters_manager.init_filters()},show_composite_track:function(){var ad=new e(this.view,this.view,{name:this.config.get_value("name"),drawables:this.drawables});var ac=this.container.replace_drawable(this,ad,true);ad.request_draw()},add_drawable:function(ac){y.prototype.add_drawable.call(this,ac);this.update_icons()},remove_drawable:function(ac){y.prototype.remove_drawable.call(this,ac);this.update_icons()},to_dict:function(){if(this.filters_manager.visible()){this._restore_filter_managers()}var ac=o(y.prototype.to_dict.call(this),{filters:this.filters_manager.to_dict()});if(this.filters_manager.visible()){this.setup_multitrack_filtering()}return ac},request_draw:function(ac){ab.each(this.drawables,function(ad){ad.request_draw(ac)})}});var Y=Backbone.View.extend({initialize:function(ac){o(ac,{obj_type:"View"});y.call(this,"View",ac.container,ac);this.chrom=null;this.vis_id=ac.vis_id;this.dbkey=ac.dbkey;this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.load_chroms_deferred=null;this.render();this.canvas_manager=new w.CanvasManager(this.container.get(0).ownerDocument);this.reset();this.config=R.ConfigSettingCollection.from_models_and_saved_values([{key:"name",label:"Name",type:"text",default_value:""},{key:"a_color",label:"A Color",type:"color",default_value:"#FF0000"},{key:"c_color",label:"C Color",type:"color",default_value:"#00FF00"},{key:"g_color",label:"G Color",type:"color",default_value:"#0000FF"},{key:"t_color",label:"T Color",type:"color",default_value:"#FF00FF"},{key:"n_color",label:"N Color",type:"color",default_value:"#AAAAAA"}],{name:ac.name})},render:function(){this.requested_redraw=false;var ae=this.container,ac=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ae);this.browser_content_div=$("<div/>").addClass("content").appendTo(ae);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ae);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;i(this.viewport_container,ac);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container);var af=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){w.select_datasets(galaxy_config.root+"visualization/list_current_history_datasets",galaxy_config.root+"api/datasets",{"f-dbkey":ac.dbkey},function(ag){ab.each(ag,function(ah){ac.add_drawable(n(ah,ac,ac))})})});this.nav_container=$("<div/>").addClass("trackster-nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("trackster-nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a/>").attr("title","Close overview").addClass("icon-button overview-close tooltip").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_select=$("<select/>").attr({name:"chrom"}).addClass("chrom-nav").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var ad=function(ag){if(ag.type==="focusout"||(ag.keyCode||ag.which)===13||(ag.keyCode||ag.which)===27){if((ag.keyCode||ag.which)!==27){ac.go_to($(this).val())}$(this).hide();$(this).val("");ac.location_span.show();ac.chrom_select.show()}ag.stopPropagation()};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",ad).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("title","Click to change location").tooltip({placement:"bottom"}).appendTo(this.nav_controls);this.location_span.click(function(){ac.location_span.hide();ac.chrom_select.hide();ac.nav_input.val(ac.chrom+":"+ac.low+"-"+ac.high);ac.nav_input.css("display","inline-block");ac.nav_input.select();ac.nav_input.focus();ac.nav_input.autocomplete({source:function(ai,ag){var aj=[],ah=$.map(ac.get_tracks(c),function(ak){return ak.data_manager.search_features(ai.term).success(function(al){aj=aj.concat(al)})});$.when.apply($,ah).done(function(){ag($.map(aj,function(ak){return{label:ak[0],value:ak[1]}}))})},minLength:2})});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a/>").attr("id","zoom-out").attr("title","Zoom out").tooltip({placement:"bottom"}).click(function(){ac.zoom_out()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tooltip({placement:"bottom"}).click(function(){ac.zoom_in()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){ac.change_chrom(ac.chrom_select.val())});this.browser_content_div.click(function(ag){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ag){ac.zoom_in(ag.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ag,ah){this.current_x=ah.offsetX}).bind("drag",function(ag,ai){var aj=ai.offsetX-this.current_x;this.current_x=ai.offsetX;var ah=Math.round(aj/ac.viewport_container.width()*(ac.max_high-ac.max_low));ac.move_delta(-ah)});this.overview_close.click(function(){ac.reset_overview()});this.viewport_container.bind("draginit",function(ag,ah){if(ag.clientX>ac.viewport_container.width()-16){return false}}).bind("dragstart",function(ag,ah){ah.original_low=ac.low;ah.current_height=ag.clientY;ah.current_x=ah.offsetX}).bind("drag",function(ai,ak){var ag=$(this);var al=ak.offsetX-ak.current_x;var ah=ag.scrollTop()-(ai.clientY-ak.current_height);ag.scrollTop(ah);ak.current_height=ai.clientY;ak.current_x=ak.offsetX;var aj=Math.round(al/ac.viewport_container.width()*(ac.high-ac.low));ac.move_delta(aj)});this.top_labeltrack.bind("dragstart",function(ag,ah){return $("<div/>").addClass("zoom-area").css("height",ac.browser_content_div.height()+ac.top_labeltrack.height()+1).appendTo($(this))}).bind("drag",function(ak,al){$(al.proxy).css({left:Math.min(ak.pageX,al.startX)-ac.container.offset().left,width:Math.abs(ak.pageX-al.startX)});var ah=Math.min(ak.pageX,al.startX)-ac.container.offset().left,ag=Math.max(ak.pageX,al.startX)-ac.container.offset().left,aj=(ac.high-ac.low),ai=ac.viewport_container.width();ac.update_location(Math.round(ah/ai*aj)+ac.low,Math.round(ag/ai*aj)+ac.low)}).bind("dragend",function(al,am){var ah=Math.min(al.pageX,am.startX),ag=Math.max(al.pageX,am.startX),aj=(ac.high-ac.low),ai=ac.viewport_container.width(),ak=ac.low;ac.low=Math.round(ah/ai*aj)+ak;ac.high=Math.round(ag/ai*aj)+ak;$(am.proxy).remove();ac.request_redraw()});this.add_label_track(new W(this,{content_div:this.top_labeltrack}));$(window).bind("resize",function(){if(this.resize_timer){clearTimeout(this.resize_timer)}this.resize_timer=setTimeout(function(){ac.resize_window()},500)});$(document).bind("redraw",function(){ac.redraw()});this.reset();$(window).trigger("resize")},get_base_color:function(ac){return this.config.get_value(ac.toLowerCase()+"_color")||this.config.get_value("n_color")}});o(Y.prototype,y.prototype,{changed:function(){this.has_changes=true},update_intro_div:function(){this.intro_div.toggle(this.drawables.length===0)},trigger_navigate:function(ad,af,ac,ag){if(this.timer){clearTimeout(this.timer)}if(ag){var ae=this;this.timer=setTimeout(function(){ae.trigger("navigate",ad+":"+af+"-"+ac)},500)}else{view.trigger("navigate",ad+":"+af+"-"+ac)}},update_location:function(ac,ae){this.location_span.text(commatize(ac)+" - "+commatize(ae));this.nav_input.val(this.chrom+":"+commatize(ac)+"-"+commatize(ae));var ad=view.chrom_select.val();if(ad!==""){this.trigger_navigate(ad,view.low,view.high,true)}},load_chroms:function(ae){ae.num=v;var ac=this,ad=$.Deferred();$.ajax({url:galaxy_config.root+"api/genomes/"+this.dbkey,data:ae,dataType:"json",success:function(ag){if(ag.chrom_info.length===0){return}if(ag.reference){var ah=new B(ac);ac.add_label_track(ah);ac.reference_track=ah}ac.chrom_data=ag.chrom_info;var ak='<option value="">Select Chrom/Contig</option>';for(var aj=0,af=ac.chrom_data.length;aj<af;aj++){var ai=ac.chrom_data[aj].chrom;ak+='<option value="'+ai+'">'+ai+"</option>"}if(ag.prev_chroms){ak+='<option value="previous">Previous '+v+"</option>"}if(ag.next_chroms){ak+='<option value="next">Next '+v+"</option>"}ac.chrom_select.html(ak);ac.chrom_start_index=ag.start_index;ad.resolve(ag.chrom_info)},error:function(){alert("Could not load chroms for this dbkey: "+ac.dbkey)}});return ad},change_chrom:function(ah,ad,aj){var ae=this;if(!ae.chrom_data){ae.load_chroms_deferred.then(function(){ae.change_chrom(ah,ad,aj)});return}if(!ah||ah==="None"){return}if(ah==="previous"){ae.load_chroms({low:this.chrom_start_index-v});return}if(ah==="next"){ae.load_chroms({low:this.chrom_start_index+v});return}var ai=$.grep(ae.chrom_data,function(ak,al){return ak.chrom===ah})[0];if(ai===undefined){ae.load_chroms({chrom:ah},function(){ae.change_chrom(ah,ad,aj)});return}else{if(ah!==ae.chrom){ae.chrom=ah;ae.chrom_select.val(ae.chrom);ae.max_high=ai.len-1;ae.reset();for(var ag=0,ac=ae.drawables.length;ag<ac;ag++){var af=ae.drawables[ag];if(af.init){af.init()}}if(ae.reference_track){ae.reference_track.init()}}if(ad===undefined&&aj===undefined){ae.low=0;ae.high=ae.max_high}else{ae.low=(ad!==undefined?Math.max(ad,0):0);if(aj===undefined){ae.low=Math.max(ae.low-15,0);ae.high=ae.low+30}else{ae.high=Math.min(aj,ae.max_high)}}ae.request_redraw()}},go_to:function(ag){ag=ag.replace(/,/g,"");ag=ag.replace(/:|\-/g," ");var ad=ag.split(/\s+/),af=ad[0],ae=(ad[1]?parseInt(ad[1],10):undefined),ac=(ad[2]?parseInt(ad[2],10):undefined);this.change_chrom(af,ae,ac)},move_fraction:function(ae){var ac=this;var ad=ac.high-ac.low;this.move_delta(ae*ad)},move_delta:function(af){var ac=this;var ae=ac.high-ac.low;if(ac.low-af<ac.max_low){ac.low=ac.max_low;ac.high=ac.max_low+ae}else{if(ac.high-af>ac.max_high){ac.high=ac.max_high;ac.low=ac.max_high-ae}else{ac.high-=af;ac.low-=af}}ac.request_redraw({data_fetch:false});if(this.redraw_on_move_fn){clearTimeout(this.redraw_on_move_fn)}this.redraw_on_move_fn=setTimeout(function(){ac.request_redraw()},200);var ad=ac.chrom_select.val();this.trigger_navigate(ad,ac.low,ac.high,true)},add_drawable:function(ad){y.prototype.add_drawable.call(this,ad);ad.init();this.changed();this.update_intro_div();var ac=this;ad.config.on("change",function(){ac.changed()})},add_label_track:function(ac){ac.view=this;ac.init();this.label_tracks.push(ac)},remove_drawable:function(ae,ad){y.prototype.remove_drawable.call(this,ae);if(ad){var ac=this;ae.container_div.hide(0,function(){$(this).remove();ac.update_intro_div()})}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(ad,ae){var ac=this,af=(ae?[ae]:ac.drawables);ab.each(af,function(ag){var ah=ab.find(ac.tracks_to_be_redrawn,function(ai){return ai[0]===ag});if(ah){ah[1]=ad}else{ac.tracks_to_be_redrawn.push([ag,ad])}});if(!this.requested_redraw){requestAnimationFrame(function(){ac._redraw()});this.requested_redraw=true}},_redraw:function(){this.requested_redraw=false;var ac=this.low,ag=this.high;if(ac<this.max_low){ac=this.max_low}if(ag>this.max_high){ag=this.max_high}var ad=this.high-this.low;if(this.high!==0&&ad<this.min_separation){ag=ac+this.min_separation}this.low=Math.floor(ac);this.high=Math.ceil(ag);this.update_location(this.low,this.high);this.resolution_px_b=this.viewport_container.width()/(this.high-this.low);var af=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ah=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ae=13;this.overview_box.css({left:af,width:Math.max(ae,ah)}).show();if(ah<ae){this.overview_box.css("left",af-(ae-ah)/2)}if(this.overview_highlight){this.overview_highlight.css({left:af,width:ah})}ab.each(this.tracks_to_be_redrawn,function(ak){var ai=ak[0],aj=ak[1];if(ai){ai._draw(aj)}});this.tracks_to_be_redrawn=[];ab.each(this.label_tracks,function(ai){ai._draw()})},zoom_in:function(ad,ae){if(this.max_high===0||this.high-this.low<=this.min_separation){return}var af=this.high-this.low,ag=af/2+this.low,ac=(af/this.zoom_factor)/2;if(ad){ag=ad/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ag-ac);this.high=Math.round(ag+ac);this.changed();this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var ad=this.high-this.low,ae=ad/2+this.low,ac=(ad*this.zoom_factor)/2;this.low=Math.round(ae-ac);this.high=Math.round(ae+ac);this.changed();this.request_redraw()},resize_viewport:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height())},resize_window:function(){this.resize_viewport();this.request_redraw()},set_overview:function(ae){if(this.overview_drawable){if(this.overview_drawable.dataset.id===ae.dataset.id){return}this.overview_viewport.find(".track").remove()}var ad=ae.copy({content_div:this.overview_viewport}),ac=this;ad.header_div.hide();ad.is_overview=true;ac.overview_drawable=ad;this.overview_drawable.postdraw_actions=function(){ac.overview_highlight.show().height(ac.overview_drawable.content_div.height());ac.overview_viewport.height(ac.overview_drawable.content_div.height()+ac.overview_box.outerHeight());ac.overview_close.show();ac.resize_window()};ac.overview_drawable.request_draw();this.changed()},reset_overview:function(){$(".tooltip").remove();this.overview_viewport.find(".track-tile").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide();view.resize_window();view.overview_drawable=null}});var q=P.Tool.extend({defaults:{track:null},initialize:function(ac){P.Tool.prototype.initialize.call(this,ac);var ad=true;if(ac.tool_state!==undefined&&ac.tool_state.hidden!==undefined){ad=ac.tool_state.hidden}this.set("hidden",ad);this.remove_inputs(["data","hidden_data","conditional"])},state_dict:function(ac){return ab.extend(this.get_inputs_dict(),{hidden:!this.is_visible()})}});var t=Backbone.View.extend({events:{"change :input":"update_value"},render:function(){var ae=this.$el.addClass("param-row"),af=this.model;var ac=$("<div>").addClass("param-label").text(af.get("label")).appendTo(ae);var ad=$("<div/>").addClass("param-input").html(af.get("html")).appendTo(ae);ad.find(":input").val(af.get("value"));$("<div style='clear: both;'/>").appendTo(ae)},update_value:function(ac){this.model.set_value($(ac.target).val())}});var aa=Backbone.View.extend({initialize:function(ac){this.model.on("change:hidden",this.set_visible,this)},render:function(){var ad=this;tool=this.model,parent_div=this.$el.addClass("dynamic-tool").hide();parent_div.bind("drag",function(ah){ah.stopPropagation()}).click(function(ah){ah.stopPropagation()}).bind("dblclick",function(ah){ah.stopPropagation()}).keydown(function(ah){ah.stopPropagation()});var ae=$("<div class='tool-name'>").appendTo(parent_div).text(tool.get("name"));tool.get("inputs").each(function(ai){var ah=new t({model:ai});ah.render();parent_div.append(ah.$el)});parent_div.find("input").click(function(){$(this).select()});var af=$("<div>").addClass("param-row").appendTo(parent_div);var ag=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(af);var ac=$("<input type='submit'>").attr("value","Run on visible region").appendTo(af);ac.click(function(){ad.run_on_region()});ag.click(function(){ad.run_on_dataset()});if(tool.is_visible()){this.$el.show()}},set_visible:function(){this.$el.toggle(this.model.is_visible())},update_params:function(){for(var ac=0;ac<this.params.length;ac++){this.params[ac].update_value()}},run_on_dataset:function(){var ac=this.model;this.run({target_dataset_id:this.model.get("track").dataset.id,action:"rerun",tool_id:ac.id},null,function(ad){Galaxy.modal.show({title:ac.get("name")+" is Running",body:ac.get("name")+" is running on the complete dataset. Tool outputs are in dataset's history.",buttons:{Close:function(){Galaxy.modal.hide()}}})})},run_on_region:function(){var ad=this.model.get("track"),ag=this.model,ai=new w.GenomeRegion({chrom:ad.view.chrom,start:ad.view.low,end:ad.view.high}),aj={target_dataset_id:ad.dataset.id,action:"rerun",tool_id:ag.id,regions:[ai.toJSON()]},ah=ad,al=ag.get("name")+ah.tool_region_and_parameters_str(ai),ac;if(ah.container===view){var ak=new N(view,view,{name:ad.config.get_value("name")});var af=ah.container.replace_drawable(ah,ak,false);ak.container_div.insertBefore(ah.view.content_div.children()[af]);ak.add_drawable(ah);ah.container_div.appendTo(ak.content_div);ac=ak}else{ac=ah.container}var ae=new ah.constructor(view,ac,{name:al,hda_ldda:"hda"});ae.init_for_tool_data();ae.change_mode(ah.mode);ae.set_filters_manager(ah.filters_manager.copy(ae));ae.update_icons();ac.add_drawable(ae);ae.tiles_div.text("Starting job.");this.run(aj,ae,function(am){ae.set_dataset(new X.Dataset(am));ae.tiles_div.text("Running job.");ae.init()})},run:function(ac,ae,af){ac.inputs=this.model.get_inputs_dict();var ad=new j.ServerStateDeferred({ajax_settings:{url:galaxy_config.root+"api/tools",data:JSON.stringify(ac),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(ag){return ag!=="pending"}});$.when(ad.go()).then(function(ag){if(ag==="no converter"){ae.container_div.addClass("error");ae.content_div.text(H)}else{if(ag.error){ae.container_div.addClass("error");ae.content_div.text(x+ag.message)}else{af(ag)}}})}});var C=function(ac,ad){J.Scaler.call(this,ad);this.filter=ac};C.prototype.gen_val=function(ac){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(ac[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var b=function(ac,af,ag,ad,ae){this.track=ac;this.region=af;this.low=af.get("start");this.high=af.get("end");this.w_scale=ag;this.canvas=ad;this.html_elt=$("<div class='track-tile'/>").append(ad);this.data=ae;this.stale=false};b.prototype.predisplay_actions=function(){};var K=function(ac,af,ag,ad,ae){b.call(this,ac,af,ag,ad,ae)};K.prototype.predisplay_actions=function(){};var M=function(ae,aj,al,ad,ag,ah,am,ac,ai,af,ak){b.call(this,ae,aj,al,ad,ag);this.mode=ah;this.all_slotted=ac;this.feature_mapper=ai;this.has_icons=false;this.incomplete_features=af;this.other_tiles_features_drawn={};this.seq_data=ak};o(M.prototype,b.prototype);M.prototype.predisplay_actions=function(){};var f=function(ad,ac,ae){o(ae,{drag_handle_class:"draghandle"});p.call(this,ad,ac,ae);this.dataset=null;if(ae.dataset){this.dataset=(ae.dataset instanceof Backbone.Model?ae.dataset:new X.Dataset(ae.dataset))}this.dataset_check_type="converted_datasets_state";this.data_url_extra_params={};this.data_query_wait=("data_query_wait" in ae?ae.data_query_wait:I);this.data_manager=("data_manager" in ae?ae.data_manager:new w.GenomeDataManager({dataset:this.dataset,genome:new w.Genome({key:ad.dbkey,chroms_info:{chrom_info:ad.chrom_data}}),data_mode_compatible:this.data_and_mode_compatible,can_subset:this.can_subset}));this.min_height_px=16;this.max_height_px=800;this.visible_height_px=this.config.get_value("height");this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div);if(!("resize" in ae)||ae.resize){this.add_resize_handle()}}};o(f.prototype,p.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},p.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"application-dock-270",on_click_fn:function(ac){ac.view.set_overview(ac)}},p.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"ui-slider-050",on_click_fn:function(ac){if(ac.filters_manager.visible()){ac.filters_manager.clear_filters()}else{ac.filters_manager.init_filters()}ac.filters_manager.toggle()}},{name:"tools_icon",title:"Tool",css_class:"hammer",on_click_fn:function(ac){ac.tool.toggle();if(ac.tool.is_visible()){ac.set_name(ac.config.get_value("name")+ac.tool_region_and_parameters_str())}else{ac.revert_name()}$(".tooltip").remove()}},{name:"param_space_viz_icon",title:"Tool parameter space visualization",css_class:"arrow-split",on_click_fn:function(ac){var af='<strong>Tool</strong>: <%= track.tool.get("name") %><br/><strong>Dataset</strong>: <%= track.config.get_value("name") %><br/><strong>Region(s)</strong>: <select name="regions"><option value="cur">current viewing area</option><option value="bookmarks">bookmarks</option><option value="both">current viewing area and bookmarks</option></select>',ae=ab.template(af,{track:ac});var ah=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},ad=function(){var aj=$('select[name="regions"] option:selected').val(),al,ai=new w.GenomeRegion({chrom:view.chrom,start:view.low,end:view.high}),ak=ab.map($(".bookmark"),function(am){return new w.GenomeRegion({from_str:$(am).children(".position").text()})});if(aj==="cur"){al=[ai]}else{if(aj==="bookmarks"){al=ak}else{al=[ai].concat(ak)}}Galaxy.modal.hide();window.location.href=galaxy_config.root+"visualization/sweepster?"+$.param({dataset_id:ac.dataset.id,hda_ldda:ac.dataset.get("hda_ldda"),regions:JSON.stringify(new Backbone.Collection(al).toJSON())})},ag=function(ai){if((ai.keyCode||ai.which)===27){ah()}else{if((ai.keyCode||ai.which)===13){ad()}}};Galaxy.modal.show({title:"Visualize tool parameter space and output from different parameter settings?",body:ae,buttons:{No:ah,Yes:ad}})}},p.prototype.action_icons_def[2]],can_draw:function(){return this.dataset&&p.prototype.can_draw.call(this)},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id)},set_dataset:function(ac){this.dataset=ac;this.data_manager.set("dataset",ac)},on_resize:function(){this.request_draw({clear_tile_cache:true})},add_resize_handle:function(){var ac=this;var af=false;var ae=false;var ad=$("<div class='track-resize'>");$(ac.container_div).hover(function(){if(ac.config.get_value("content_visible")){af=true;ad.show()}},function(){af=false;if(!ae){ad.hide()}});ad.hide().bind("dragstart",function(ag,ah){ae=true;ah.original_height=$(ac.content_div).height()}).bind("drag",function(ah,ai){var ag=Math.min(Math.max(ai.original_height+ai.deltaY,ac.min_height_px),ac.max_height_px);$(ac.tiles_div).css("height",ag);ac.visible_height_px=(ac.max_height_px===ag?0:ag);ac.on_resize()}).bind("dragend",function(ag,ah){ac.tile_cache.clear();ae=false;if(!af){ad.hide()}ac.config.set_value("height",ac.visible_height_px);ac.changed()}).appendTo(ac.container_div)},hide_contents:function(){this.tiles_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.tiles_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof W){return"LabelTrack"}else{if(this instanceof B){return"ReferenceTrack"}else{if(this instanceof g){return"LineTrack"}else{if(this instanceof S){return"ReadTrack"}else{if(this instanceof Z){return"VariantTrack"}else{if(this instanceof e){return"CompositeTrack"}else{if(this instanceof c){return"FeatureTrack"}}}}}}}return""},show_message:function(ac){this.tiles_div.remove();return $("<span/>").addClass("message").html(ac).appendTo(this.content_div)},init:function(ae){var ad=this;ad.enabled=false;ad.tile_cache.clear();ad.data_manager.clear();ad.content_div.children().remove();ad.container_div.removeClass("nodata error pending");ad.tiles_div=$("<div/>").addClass("tiles").appendTo(ad.content_div);if(!ad.dataset.id){return}var ac=$.Deferred(),af={hda_ldda:ad.dataset.get("hda_ldda"),data_type:this.dataset_check_type,chrom:ad.view.chrom,retry:ae};$.getJSON(this.dataset.url(),af,function(ag){if(!ag||ag==="error"||ag.kind==="error"){ad.container_div.addClass("error");var ah=ad.show_message(m);if(ag.message){ah.append($("<a href='javascript:void(0);'></a>").text("View error").click(function(){Galaxy.modal.show({title:"Trackster Error",body:"<pre>"+ag.message+"</pre>",buttons:{Close:function(){Galaxy.modal.hide()}}})}));ah.append($("<span/>").text(" "));ah.append($("<a href='javascript:void(0);'></a>").text("Try again").click(function(){ad.init(true)}))}}else{if(ag==="no converter"){ad.container_div.addClass("error");ad.show_message(H)}else{if(ag==="no data"||(ag.data!==undefined&&(ag.data===null||ag.data.length===0))){ad.container_div.addClass("nodata");ad.show_message(E)}else{if(ag==="pending"){ad.container_div.addClass("pending");ad.show_message(u);setTimeout(function(){ad.init()},ad.data_query_wait)}else{if(ag==="data"||ag.status==="data"){if(ag.valid_chroms){ad.valid_chroms=ag.valid_chroms;ad.update_icons()}ad.tiles_div.text(T);if(ad.view.chrom){ad.tiles_div.text("");ad.tiles_div.css("height",ad.visible_height_px+"px");ad.enabled=true;$.when.apply($,ad.predraw_init()).done(function(){ac.resolve();ad.container_div.removeClass("nodata error pending");ad.request_draw()})}else{ac.resolve()}}}}}}});this.update_icons();return ac},predraw_init:function(){var ac=this;return $.getJSON(ac.dataset.url(),{data_type:"data",stats:true,chrom:ac.view.chrom,low:0,high:ac.view.max_high,hda_ldda:ac.dataset.get("hda_ldda")},function(ad){var af=ad.data;if(af&&af.min&&af.max){var ae=af.min,ag=af.max;ae=Math.floor(Math.min(0,Math.max(ae,af.mean-2*af.sd)));ag=Math.ceil(Math.max(0,Math.min(ag,af.mean+2*af.sd)));ac.config.set_default_value("min_value",ae);ac.config.set_default_value("max_value",ag);ac.config.set_value("min_value",ae);ac.config.set_value("max_value",ag)}})},get_drawables:function(){return this}});var L=function(ae,ad,ag){f.call(this,ae,ad,ag);var ac=this;k(ac.container_div,ac.drag_handle_class,".group",ac);this.filters_manager=new h.FiltersManager(this,("filters" in ag?ag.filters:null));this.data_manager.set("filters_manager",this.filters_manager);this.filters_available=false;this.tool=(ag.tool?new q(ab.extend(ag.tool,{track:this,tool_state:ag.tool_state})):null);this.tile_cache=new w.Cache(O);this.left_offset=0;if(this.header_div){this.set_filters_manager(this.filters_manager);if(this.tool){var af=new aa({model:this.tool});af.render();this.dynamic_tool_div=af.$el;this.header_div.after(this.dynamic_tool_div)}}this.tiles_div=$("<div/>").addClass("tiles").appendTo(this.content_div);if(!this.config.get_value("content_visible")){this.tiles_div.hide()}this.overlay_div=$("<div/>").addClass("overlay").appendTo(this.content_div);if(ag.mode){this.change_mode(ag.mode)}};o(L.prototype,p.prototype,f.prototype,{action_icons_def:f.prototype.action_icons_def.concat([{name:"show_more_rows_icon",title:"To minimize track height, not all feature rows are displayed. Click to display more rows.",css_class:"exclamation",on_click_fn:function(ac){$(".tooltip").remove();ac.slotters[ac.view.resolution_px_b].max_rows*=2;ac.request_draw({clear_tile_cache:true})},hide:true}]),copy:function(ac){var ad=this.to_dict();o(ad,{data_manager:this.data_manager});var ae=new this.constructor(this.view,ac,ad);ae.change_mode(this.mode);ae.enabled=this.enabled;return ae},set_filters_manager:function(ac){this.filters_manager=ac;this.header_div.after(this.filters_manager.parent_div)},to_dict:function(){return{track_type:this.get_type(),dataset:{id:this.dataset.id,hda_ldda:this.dataset.get("hda_ldda")},prefs:this.config.to_key_value_dict(),mode:this.mode,filters:this.filters_manager.to_dict(),tool_state:(this.tool?this.tool.state_dict():{})}},set_min_max:function(){var ac=this;return $.getJSON(ac.dataset.url(),{data_type:"data",stats:true,chrom:ac.view.chrom,low:0,high:ac.view.max_high,hda_ldda:ac.dataset.get("hda_ldda")},function(ad){var af=ad.data;if(isNaN(parseFloat(ac.config.get_value("min_value")))||isNaN(parseFloat(ac.config.get_value("max_value")))){var ae=af.min,ag=af.max;ae=Math.floor(Math.min(0,Math.max(ae,af.mean-2*af.sd)));ag=Math.ceil(Math.max(0,Math.min(ag,af.mean+2*af.sd)));ac.config.set_value("min_value",ae);ac.config.set_value("max_value",ag)}})},change_mode:function(ad){var ac=this;ac.mode=ad;ac.config.set_value("mode",ad);if(ad==="Auto"){this.data_manager.clear()}ac.request_draw({clear_tile_cache:true});this.action_icons.mode_icon.attr("title","Set display mode (now: "+ac.mode+")");return ac},update_icons:function(){var ac=this;ac.action_icons.filters_icon.toggle(ac.filters_available);ac.action_icons.tools_icon.toggle(ac.tool!==null);ac.action_icons.param_space_viz_icon.toggle(ac.tool!==null)},_gen_tile_cache_key:function(ad,ac){return ad+"_"+ac},request_draw:function(ac){if(ac&&ac.clear_tile_cache){this.tile_cache.clear()}this.view.request_redraw(ac,this)},before_draw:function(){this.max_height_px=0},_draw:function(aq){if(!this.can_draw()){return}var an=aq&&aq.clear_after,al=this.view.low,ag=this.view.high,aj=ag-al,ad=this.view.container.width(),ap=this.view.resolution_px_b,af=1/ap;if(this.is_overview){al=this.view.max_low;ag=this.view.max_high;ap=ad/(view.max_high-view.max_low);af=1/ap}this.before_draw();this.tiles_div.children().addClass("remove");var ak=Math.floor(Q*af),ac=Math.floor(al/ak),am,ah,ai=[],ao=[];while((ac*ak)<ag){am=new w.GenomeRegion({chrom:this.view.chrom,start:ac*ak,end:Math.min((ac+1)*ak,this.view.max_high)});ah=this.draw_helper(am,ap,aq);ai.push(ah);$.when(ah).then(function(ar){ao.push(ar)});ac+=1}if(!an){this.tiles_div.children(".remove").removeClass("remove").remove()}var ae=this;$.when.apply($,ai).then(function(){ae.tiles_div.children(".remove").remove();ao=ab.filter(ao,function(ar){return ar!==null});if(ao.length!==0){ae.postdraw_actions(ao,ad,ap,an)}})},_add_yaxis_label:function(af,ah){var ad=this,ag=(af==="max"?"top":"bottom"),ai=(af==="max"?"max":"min"),ac=(af==="max"?"max_value":"min_value"),ae=this.container_div.find(".yaxislabel."+ag);ah=ah||function(){ad.request_draw({clear_tile_cache:true})};if(ae.length!==0){ae.text(ad.config.get_value(ac))}else{ae=$("<div/>").text(ad.config.get_value(ac)).make_text_editable({num_cols:12,on_finish:function(aj){$(".tooltip").remove();ad.config.set_value(ac,aj);ah()},help_text:"Set "+ai+" value"}).addClass("yaxislabel "+ag).css("color",this.config.get_value("label_color"));this.container_div.prepend(ae)}},postdraw_actions:function(af,ag,ai,ac){var ae=ab.filter(af,function(aj){return(aj instanceof K)});if(ae.length>0){this.max_height_px=0;var ad=this;ab.each(af,function(aj){if(!(aj instanceof K)){aj.html_elt.remove();ad.draw_helper(aj.region,ai,{force:true,mode:"Coverage"})}});ad._add_yaxis_label("max")}else{this.container_div.find(".yaxislabel").remove();var ah=ab.find(af,function(aj){return aj.has_icons});if(ah){ab.each(af,function(aj){if(!aj.has_icons){aj.html_elt.css("padding-top",D)}})}}},get_mode:function(ac){return this.mode},update_auto_mode:function(ac){},_get_drawables:function(){return[this]},draw_helper:function(al,an,ao){if(!ao){ao={}}var ad=ao.force,ai=ao.mode||this.mode,af=1/an,ae=this,ag=this._get_drawables(),am=this._gen_tile_cache_key(an,al),ah=function(ap){return(ap&&"track" in ap)};var aj=(ad?undefined:ae.tile_cache.get_elt(am));if(aj){if(ah(aj)){ae.show_tile(aj,an)}return aj}if(ao.data_fetch===false){return null}var ak=function(){var ap=(ab.find(A,function(ar){return ar===ai})?"Coverage":ai);var aq=ab.map(ag,function(ar){return ar.data_manager.get_data(al,ap,af,ae.data_url_extra_params)});if(view.reference_track){aq.push(view.reference_track.data_manager.get_data(al,ai,af,view.reference_track.data_url_extra_params))}return aq};var ac=$.Deferred();ae.tile_cache.set_elt(am,ac);$.when.apply($,ak()).then(function(){var ap=ak(),av=ap,aB;if(ab.find(ap,function(aD){return j.is_deferred(aD)})){ae.tile_cache.set_elt(am,undefined);$.when(ae.draw_helper(al,an,ao)).then(function(aD){ac.resolve(aD)});return}if(view.reference_track){aB=view.reference_track.data_manager.subset_entry(ap.pop(),al)}var aw=[],at=[];ab.each(ag,function(aG,aD){var aF=aG.mode,aE=av[aD];if(aF==="Auto"){aF=aG.get_mode(aE);aG.update_auto_mode(aF)}aw.push(aF);at.push(aG.get_canvas_height(aE,aF,an,aq))});var au=ae.view.canvas_manager.new_canvas(),ax=al.get("start"),aC=al.get("end"),ar=0,aq=Math.ceil((aC-ax)*an)+ae.left_offset,az=ab.max(at),ay;au.width=aq;au.height=(ao.height||az);var aA=au.getContext("2d");aA.translate(ae.left_offset,0);if(ag.length>1){aA.globalAlpha=0.5;aA.globalCompositeOperation="source-over"}ab.each(ag,function(aE,aD){ay=aE.draw_tile(av[aD],aA,aw[aD],al,an,aB)});if(ay!==undefined){ae.tile_cache.set_elt(am,ay);ae.show_tile(ay,an)}ac.resolve(ay)});return ac},get_canvas_height:function(ac,ae,af,ad){return this.visible_height_px},_draw_line_track_tile:function(ac,ae,ah,ag,ai){var af=ae.canvas,ad=new J.LinePainter(ac.data,ag.get("start"),ag.get("end"),this.config.to_key_value_dict(),ah);ad.draw(ae,af.width,af.height,ai);return new K(this,ag,ai,af,ac.data)},draw_tile:function(ac,ad,ag,af,ah,ae){},show_tile:function(ae,ah){var ad=this,ac=ae.html_elt;ae.predisplay_actions();var ag=Math.round((ae.low-(this.is_overview?this.view.max_low:this.view.low))*ah);if(this.left_offset){ag-=this.left_offset}ac.css("left",ag);if(ac.hasClass("remove")){ac.removeClass("remove")}else{this.tiles_div.append(ac)}ac.css("height","auto");this.max_height_px=Math.max(this.max_height_px,ac.height()-2);ac.parent().children().css("height",this.max_height_px+"px");var af=this.max_height_px;if(this.visible_height_px!==0){af=Math.min(this.max_height_px,this.visible_height_px)}this.tiles_div.css("height",af+"px")},tool_region_and_parameters_str:function(af){var ac=this,ae=(af!==undefined?af.toString():"all"),ad=ab.values(ac.tool.get_inputs_dict()).join(", ");return" - region=["+ae+"], parameters=["+ad+"]"},data_and_mode_compatible:function(ac,ad){if(ad==="Auto"){return true}else{if(ad==="Coverage"){return ac.dataset_type==="bigwig"}else{if(ac.dataset_type==="bigwig"||ac.extra_info==="no_detail"){return false}else{return true}}}},can_subset:function(ac){if(ac.message||ac.extra_info==="no_detail"){return false}else{if(ac.dataset_type==="bigwig"){return(ac.data[1][0]-ac.data[0][0]===1)}}return true},init_for_tool_data:function(){this.data_manager.set("data_type","raw_data");this.data_query_wait=1000;this.dataset_check_type="state"}});var W=function(ad,ac){f.call(this,ad,ac,{resize:false,header:false});this.container_div.addClass("label-track")};o(W.prototype,f.prototype,{init:function(){this.enabled=true},predraw_init:function(){},_draw:function(ag){var ae=this.view,af=ae.high-ae.low,aj=Math.floor(Math.pow(10,Math.floor(Math.log(af)/Math.log(10)))),ac=Math.floor(ae.low/aj)*aj,ah=this.view.container.width(),ad=$("<div/>").addClass("label-container");while(ac<ae.high){var ai=Math.floor((ac-ae.low)/af*ah);ad.append($("<div/>").addClass("label").text(commatize(ac)).css({left:ai}));ac+=aj}this.content_div.children(":first").remove();this.content_div.append(ad)}});var e=function(ad,ac,ag){L.call(this,ad,ac,ag);this.drawables=[];if("drawables" in ag){var af;for(var ae=0;ae<ag.drawables.length;ae++){af=ag.drawables[ae];this.drawables[ae]=n(af,ad,null);if(af.left_offset>this.left_offset){this.left_offset=af.left_offset}}this.enabled=true}ab.each(this.drawables,function(ah){if(ah instanceof c||ah instanceof S){ah.change_mode("Coverage")}});this.update_icons();this.obj_type="CompositeTrack"};o(e.prototype,L.prototype,{display_modes:A,config_params:ab.union(p.prototype.config_params,[{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:30,hidden:true}]),action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(ac){$(".tooltip").remove();ac.show_group()}}].concat(L.prototype.action_icons_def),to_dict:y.prototype.to_dict,add_drawable:y.prototype.add_drawable,unpack_drawables:y.prototype.unpack_drawables,config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},on_resize:function(){var ac=this.visible_height_px;ab.each(this.drawables,function(ad){ad.visible_height_px=ac});f.prototype.on_resize.call(this)},change_mode:function(ac){L.prototype.change_mode.call(this,ac);for(var ad=0;ad<this.drawables.length;ad++){this.drawables[ad].change_mode(ac)}},init:function(){var ae=[];for(var ad=0;ad<this.drawables.length;ad++){ae.push(this.drawables[ad].init())}var ac=this;$.when.apply($,ae).then(function(){ac.enabled=true;ac.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide();this.action_icons.param_space_viz_icon.hide()},can_draw:p.prototype.can_draw,_get_drawables:function(){return this.drawables},show_group:function(){var af=new N(this.view,this.container,{name:this.config.get_value("name")}),ac;for(var ae=0;ae<this.drawables.length;ae++){ac=this.drawables[ae];ac.update_icons();af.add_drawable(ac);ac.container=af;af.content_div.append(ac.container_div)}var ad=this.container.replace_drawable(this,af,true);af.request_draw({clear_tile_cache:true})},before_draw:function(){var ad=ab.min(ab.map(this.drawables,function(ae){return ae.config.get_value("min_value")})),ac=ab.max(ab.map(this.drawables,function(ae){return ae.config.get_value("max_value")}));this.config.set_value("min_value",ad);this.config.set_value("max_value",ac);ab.each(this.drawables,function(ae){ae.config.set_value("min_value",ad);ae.config.set_value("max_value",ac)})},update_all_min_max:function(){var ad=this,ac=this.config.get_value("min_value"),ae=this.config.get_value("max_value");ab.each(this.drawables,function(af){af.config.set_value("min_value",ac);af.config.set_value("max_value",ae)});this.request_draw({clear_tile_cache:true})},postdraw_actions:function(ai,ac,al,ah){var ag=-1,ae;for(ae=0;ae<ai.length;ae++){var aj=ai[ae].html_elt.find("canvas").height();if(aj>ag){ag=aj}}for(ae=0;ae<ai.length;ae++){var af=ai[ae];if(af.html_elt.find("canvas").height()!==ag){this.draw_helper(af.region,al,{force:true,height:ag});af.html_elt.remove()}}var ad=this,ak=function(){ad.update_all_min_max()};this._add_yaxis_label("min",ak);this._add_yaxis_label("max",ak)}});var B=function(ac){L.call(this,ac,{content_div:ac.top_labeltrack},{resize:false,header:false});this.left_offset=ac.canvas_manager.char_width_px;this.container_div.addClass("reference-track");this.data_url=galaxy_config.root+"api/genomes/"+this.view.dbkey;this.data_url_extra_params={reference:true};this.data_manager=new w.GenomeReferenceDataManager({data_url:this.data_url,can_subset:this.can_subset});this.hide_contents()};o(B.prototype,p.prototype,L.prototype,{config_params:ab.union(p.prototype.config_params,[{key:"height",type:"int",default_value:13,hidden:true}]),init:function(){this.data_manager.clear();this.enabled=true},predraw_init:function(){},can_draw:p.prototype.can_draw,draw_helper:function(af,ah,ad){var ac=this.tiles_div.is(":visible"),ag,ae=null;if(ah>this.view.canvas_manager.char_width_px){this.tiles_div.show();ag=true;ae=L.prototype.draw_helper.call(this,af,ah,ad)}else{ag=false;this.tiles_div.hide()}if(ac!==ag){this.view.resize_viewport()}return ae},can_subset:function(ac){return true},draw_tile:function(ae,ak,af,ah,al){var ad=this.data_manager.subset_entry(ae,ah),aj=ad.data;var ac=ak.canvas;ak.font=ak.canvas.manager.default_font;ak.textAlign="center";for(var ag=0,ai=aj.length;ag<ai;ag++){ak.fillStyle=this.view.get_base_color(aj[ag]);ak.fillText(aj[ag],Math.floor(ag*al),10)}return new b(this,ah,al,ac,ad)}});var g=function(ad,ac,ae){this.mode="Histogram";L.call(this,ad,ac,ae)};o(g.prototype,p.prototype,L.prototype,{display_modes:A,config_params:ab.union(p.prototype.config_params,[{key:"color",label:"Color",type:"color"},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:30,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},before_draw:function(){},draw_tile:function(ac,ad,af,ae,ag){return this._draw_line_track_tile(ac,ad,af,ae,ag)},can_subset:function(ac){return(ac.data[1][0]-ac.data[0][0]===1)},postdraw_actions:function(ad,ae,af,ac){this._add_yaxis_label("max");this._add_yaxis_label("min")}});var r=function(ad,ac,ae){this.mode="Heatmap";L.call(this,ad,ac,ae)};o(r.prototype,p.prototype,L.prototype,{display_modes:["Heatmap"],config_params:ab.union(p.prototype.config_params,[{key:"pos_color",label:"Positive Color",type:"color",default_value:"#FF8C00"},{key:"neg_color",label:"Negative Color",type:"color",default_value:"#4169E1"},{key:"min_value",label:"Min Value",type:"float",default_value:-1},{key:"max_value",label:"Max Value",type:"float",default_value:1},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:500,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},draw_tile:function(ac,ae,ah,ag,ai){var af=ae.canvas,ad=new J.DiagonalHeatmapPainter(ac.data,ag.get("start"),ag.get("end"),this.config.to_key_value_dict(),ah);ad.draw(ae,af.width,af.height,ai);return new b(this,ag,ai,af,ac.data)}});var c=function(ad,ac,ae){L.call(this,ad,ac,ae);this.container_div.addClass("feature-track");this.summary_draw_height=30;this.slotters={};this.start_end_dct={};this.left_offset=200;this.set_painter_from_config()};o(c.prototype,p.prototype,L.prototype,{display_modes:["Auto","Coverage","Dense","Squish","Pack"],config_params:ab.union(p.prototype.config_params,[{key:"block_color",label:"Block color",type:"color"},{key:"reverse_strand_color",label:"Antisense strand color",type:"color"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{key:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"connector_style",label:"Connector style",type:"select",default_value:"fishbones",options:[{label:"Line with arrows",value:"fishbone"},{label:"Arcs",value:"arcs"}]},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:0,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.set_painter_from_config();this.request_draw({clear_tile_cache:true})},set_painter_from_config:function(){if(this.config.get_value("connector_style")==="arcs"){this.painter=J.ArcLinkedFeaturePainter}else{this.painter=J.LinkedFeaturePainter}},postdraw_actions:function(ao,af,aq,an){L.prototype.postdraw_actions.call(this,ao,af,aq,an);var ah=this,ai,am=ab.filter(ao,function(ar){return(ar instanceof K)});if(am.length===0){var ac={};ab.each(ab.pluck(ao,"incomplete_features"),function(ar){ab.each(ar,function(at){ac[at[0]]=at})});var ap=this;ab.each(ao,function(av){var aw=ab.omit(ac,ab.map(av.incomplete_features,function(ay){return ay[0]}));aw=ab.omit(aw,ab.keys(av.other_tiles_features_drawn));if(ab.size(aw)!==0){var at={data:ab.values(aw)},au=ap.view.canvas_manager.new_canvas(),ar=au.getContext("2d");au.height=Math.max(av.canvas.height,ap.get_canvas_height(at,av.mode,av.w_scale,100));au.width=av.canvas.width;ar.drawImage(av.canvas,0,0);ar.translate(ah.left_offset,0);var ax=ap.draw_tile(at,ar,av.mode,av.region,av.w_scale,av.seq_data);$(av.canvas).replaceWith($(ax.canvas));av.canvas=au;ab.extend(av.other_tiles_features_drawn,ac)}})}if(ah.filters_manager){var ag=ah.filters_manager.filters,ak;for(ak=0;ak<ag.length;ak++){ag[ak].update_ui_elt()}var aj=false,al,ae;for(ai=0;ai<ao.length;ai++){if(ao[ai].data.length){al=ao[ai].data[0];for(ak=0;ak<ag.length;ak++){ae=ag[ak];if(ae.applies_to(al)&&ae.min!==ae.max){aj=true;break}}}}if(ah.filters_available!==aj){ah.filters_available=aj;if(!ah.filters_available){ah.filters_manager.hide()}ah.update_icons()}}if(ao[0] instanceof M){var ad=true;for(ai=0;ai<ao.length;ai++){if(!ao[ai].all_slotted){ad=false;break}}this.action_icons.show_more_rows_icon.toggle(!ad)}else{this.action_icons.show_more_rows_icon.hide()}},update_auto_mode:function(ac){if(this.mode==="Auto"){if(ac==="no_detail"){ac="feature spans"}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+ac+")")}},incremental_slots:function(ag,ac,af){var ad=this.view.canvas_manager.dummy_context,ae=this.slotters[ag];if(!ae||(ae.mode!==af)){ae=new (s.FeatureSlotter)(ag,af,z,function(ah){return ad.measureText(ah)});this.slotters[ag]=ae}return ae.slot_features(ac)},get_mode:function(ac){if(ac.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>G){mode="Squish"}else{mode="Pack"}}return mode},get_canvas_height:function(ac,ag,ah,ad){if(ag==="Coverage"||ac.dataset_type==="bigwig"){return this.summary_draw_height}else{var af=this.incremental_slots(ah,ac.data,ag);var ae=new (this.painter)(null,null,null,this.config.to_key_value_dict(),ag);return Math.max(this.min_height_px,ae.get_required_height(af,ad))}},draw_tile:function(an,at,aq,ag,ak,af,ao){var ar=this,ae=at.canvas,az=ag.get("start"),ad=ag.get("end"),ah=this.left_offset;if(an.dataset_type==="bigwig"){return this._draw_line_track_tile(an,at,aq,ag,ak)}var aj=[],ap=this.slotters[ak].slots;all_slotted=true;if(an.data){var al=this.filters_manager.filters;for(var au=0,aw=an.data.length;au<aw;au++){var ai=an.data[au];var av=false;var am;for(var ay=0,aD=al.length;ay<aD;ay++){am=al[ay];am.update_attrs(ai);if(!am.keep(ai)){av=true;break}}if(!av){aj.push(ai);if(!(ai[0] in ap)){all_slotted=false}}}}var aC=(this.filters_manager.alpha_filter?new C(this.filters_manager.alpha_filter):null),aA=(this.filters_manager.height_filter?new C(this.filters_manager.height_filter):null),aB=new (this.painter)(aj,az,ad,this.config.to_key_value_dict(),aq,aC,aA,af,function(aE){return ar.view.get_base_color(aE)});var ax=null;at.fillStyle=this.config.get_value("block_color");at.font=at.canvas.manager.default_font;at.textAlign="right";if(an.data){var ac=aB.draw(at,ae.width,ae.height,ak,ap);ax=ac.feature_mapper;incomplete_features=ac.incomplete_features;ax.translation=-ah}if(!ao){return new M(ar,ag,ak,ae,an.data,aq,an.message,all_slotted,ax,incomplete_features,af)}}});var Z=function(ad,ac,ae){L.call(this,ad,ac,ae);this.painter=J.VariantPainter;this.summary_draw_height=30;this.left_offset=30};o(Z.prototype,p.prototype,L.prototype,{display_modes:["Auto","Coverage","Dense","Squish","Pack"],config_params:ab.union(p.prototype.config_params,[{key:"color",label:"Histogram color",type:"color"},{key:"show_sample_data",label:"Show sample data",type:"bool",default_value:true},{key:"show_labels",label:"Show summary and sample labels",type:"bool",default_value:true},{key:"summary_height",label:"Locus summary height",type:"float",default_value:20},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:0,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},draw_tile:function(ac,af,ah,ag,ai){if(ac.dataset_type==="bigwig"){return this._draw_line_track_tile(ac,af,"Histogram",ag,ai)}else{var ae=this.view,ad=new (this.painter)(ac.data,ag.get("start"),ag.get("end"),this.config.to_key_value_dict(),ah,function(aj){return ae.get_base_color(aj)});ad.draw(af,af.canvas.width,af.canvas.height,ai);return new b(this,ag,ai,af.canvas,ac.data)}},get_canvas_height:function(ac,ag,ah,ae){if(ac.dataset_type==="bigwig"){return this.summary_draw_height}else{var ad=(this.dataset.get_metadata("sample_names")?this.dataset.get_metadata("sample_names").length:0);if(ad===0&&ac.data.length!==0){ad=ac.data[0][7].match(/,/g);if(ad===null){ad=1}else{ad=ad.length+1}}var af=new (this.painter)(null,null,null,this.config.to_key_value_dict(),ag);return af.get_required_height(ad)}},predraw_init:function(){var ac=[f.prototype.predraw_init.call(this)];if(!this.dataset.get_metadata("sample_names")){ac.push(this.dataset.fetch())}return ac},postdraw_actions:function(ag,ah,aj,ad){L.prototype.postdraw_actions.call(this,ag,ah,aj,ad);var af=ab.filter(ag,function(ak){return(ak instanceof K)});var ae=this.dataset.get_metadata("sample_names");if(af.length===0&&this.config.get_value("show_labels")&&ae&&ae.length>1){var ac;if(this.container_div.find(".yaxislabel.variant").length===0){ac=this.config.get_value("summary_height")/2;this.tiles_div.prepend($("<div/>").text("Summary").addClass("yaxislabel variant top").css({"font-size":ac+"px",top:(this.config.get_value("summary_height")-ac)/2+"px"}));if(this.config.get_value("show_sample_data")){var ai=ae.join("<br/>");this.tiles_div.prepend($("<div/>").html(ai).addClass("yaxislabel variant top sample").css({top:this.config.get_value("summary_height")}))}}ac=(this.mode==="Squish"?5:10)+"px";$(this.tiles_div).find(".sample").css({"font-size":ac,"line-height":ac});$(this.tiles_div).find(".yaxislabel").css("color",this.config.get_value("label_color"))}else{this.container_div.find(".yaxislabel.variant").remove()}}});var S=function(ad,ac,ae){c.call(this,ad,ac,ae);this.painter=J.ReadPainter;this.update_icons()};o(S.prototype,p.prototype,L.prototype,c.prototype,{config_params:ab.union(p.prototype.config_params,[{key:"block_color",label:"Histogram color",type:"color"},{key:"detail_block_color",label:"Sense strand block color",type:"color",default_value:"#AAAAAA"},{key:"reverse_strand_color",label:"Antisense strand block color",type:"color",default_value:"#DDDDDD"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"height",type:"int",default_value:0,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})}});var d={CompositeTrack:e,DrawableGroup:N,DiagonalHeatmapTrack:r,FeatureTrack:c,LineTrack:g,ReadTrack:S,VariantTrack:Z,VcfTrack:Z};var n=function(ae,ad,ac){if("copy" in ae){return ae.copy(ac)}else{var af=ae.obj_type;if(!af){af=ae.track_type}return new d[af](ad,ac,ae)}};return{TracksterView:Y,DrawableGroup:N,LineTrack:g,FeatureTrack:c,DiagonalHeatmapTrack:r,ReadTrack:S,VariantTrack:Z,CompositeTrack:e,object_from_template:n}});
\ No newline at end of file
+define(["libs/underscore","viz/visualization","viz/viz_views","viz/trackster/util","viz/trackster/slotting","viz/trackster/painters","viz/trackster/filters","mvc/data","mvc/tools","utils/config"],function(ab,w,V,j,s,J,h,X,P,R){var o=ab.extend;var l={};var i=function(ac,ad){l[ac.attr("id")]=ad};var k=function(ac,ad,af,ae){af=".group";l[ac.attr("id")]=ae;ac.bind("drag",{handle:"."+ad,relative:true},function(an,ao){var am=$(this),ar=$(this).parent(),aj=ar.children(".track,.group"),al=l[$(this).attr("id")],ai,ah,ap,ag,ak;ah=$(this).parents(af);if(ah.length!==0){ap=ah.position().top;ag=ap+ah.outerHeight();var aq=l[ah.attr("id")];if(ao.offsetY<ap){$(this).insertBefore(ah);aq.remove_drawable(al);aq.container.add_drawable_before(al,aq);return}else{if(ao.offsetY>ag){$(this).insertAfter(ah);aq.remove_drawable(al);aq.container.add_drawable(al);return}}}ah=null;for(ak=0;ak<aj.length;ak++){ai=$(aj.get(ak));ap=ai.position().top;ag=ap+ai.outerHeight();if(ai.is(af)&&this!==ai.get(0)&&ao.offsetY>=ap&&ao.offsetY<=ag){if(ao.offsetY-ap<ag-ao.offsetY){ai.find(".content-div").prepend(this)}else{ai.find(".content-div").append(this)}if(al.container){al.container.remove_drawable(al)}l[ai.attr("id")].add_drawable(al);return}}for(ak=0;ak<aj.length;ak++){ai=$(aj.get(ak));if(ao.offsetY<ai.position().top&&!(ai.hasClass("reference-track")||ai.hasClass("intro"))){break}}if(ak===aj.length){if(this!==aj.get(ak-1)){ar.append(this);l[ar.attr("id")].move_drawable(al,ak)}}else{if(this!==aj.get(ak)){$(this).insertBefore(aj.get(ak));l[ar.attr("id")].move_drawable(al,(ao.deltaY>0?ak-1:ak))}}}).bind("dragstart",function(){$(this).addClass("dragging")}).bind("dragend",function(){$(this).removeClass("dragging")})};var D=20,z=100,G=12000,Q=400,I=5000,v=100,m="Cannot display dataset due to an error. ",H="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",E="No data for this chrom/contig.",u="Preparing data. This can take a while for a large dataset. If the visualization is saved and closed, preparation will continue in the background.",x="Tool cannot be rerun: ",a="Loading data...",T="Ready for display",O=10,F=20,A=["Histogram","Line","Filled","Intensity"];function U(ad,ac){if(!ac){ac=0}var ae=Math.pow(10,ac);return Math.round(ad*ae)/ae}var p=function(ad,ac,ag){if(!p.id_counter){p.id_counter=0}this.id=p.id_counter++;this.view=ad;this.container=ac;this.drag_handle_class=ag.drag_handle_class;this.is_overview=false;this.action_icons={};this.config=R.ConfigSettingCollection.from_models_and_saved_values(this.config_params,ag.prefs);if(!this.config.get_value("name")){this.config.set_value("name",ag.name)}if(this.config_onchange){this.config.on("change",this.config_onchange,this)}this.container_div=this.build_container_div();this.header_div=null;if(ag.header!==false){var ae=new V.TrackHeaderView({model:this,id:this.id});this.header_div=ae.$el;this.container_div.append(this.header_div);var af=ae.icons_div;this.action_icons=ae.action_icons;this.container_div.hover(function(){af.show()},function(){af.hide()})}};p.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(ac){if(ac.config.get_value("content_visible")){ac.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");ac.hide_contents();ac.config.set_value("content_visible",false)}else{ac.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");ac.config.set_value("content_visible",true);ac.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"gear",on_click_fn:function(ad){var ac=new R.ConfigSettingCollectionView({collection:ad.config});ac.render_in_modal("Configure Track")}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(ac){$(".tooltip").remove();ac.remove()}}];o(p.prototype,{config_params:[{key:"name",label:"Name",type:"text",default_value:""},{key:"content_visible",type:"bool",default_value:true,hidden:true}],config_onchange:function(){},init:function(){},changed:function(){this.view.changed()},can_draw:function(){if(this.enabled&&this.config.get_value("content_visible")){return true}return false},request_draw:function(){},_draw:function(ac){},to_dict:function(){},set_name:function(ac){this.old_name=this.config.get_value("name");this.config.set_value("name",ac)},revert_name:function(){if(this.old_name){this.config.set_value("name",this.old_name)}},remove:function(){this.changed();this.container.remove_drawable(this);var ac=this.view;this.container_div.hide(0,function(){$(this).remove();ac.update_intro_div()})},build_container_div:function(){},update_icons:function(){},hide_contents:function(){},show_contents:function(){},get_drawables:function(){}});var y=function(ad,ac,ae){p.call(this,ad,ac,ae);this.obj_type=ae.obj_type;this.drawables=[]};o(y.prototype,p.prototype,{unpack_drawables:function(ae){this.drawables=[];var ad;for(var ac=0;ac<ae.length;ac++){ad=n(ae[ac],this.view,this);this.add_drawable(ad)}},init:function(){for(var ac=0;ac<this.drawables.length;ac++){this.drawables[ac].init()}},_draw:function(ac){for(var ad=0;ad<this.drawables.length;ad++){this.drawables[ad]._draw(ac)}},to_dict:function(){var ad=[];for(var ac=0;ac<this.drawables.length;ac++){ad.push(this.drawables[ac].to_dict())}return{prefs:this.config.to_key_value_dict(),obj_type:this.obj_type,drawables:ad}},add_drawable:function(ac){this.drawables.push(ac);ac.container=this;this.changed()},add_drawable_before:function(ae,ac){this.changed();var ad=this.drawables.indexOf(ac);if(ad!==-1){this.drawables.splice(ad,0,ae);return true}return false},replace_drawable:function(ae,ac,ad){var af=this.drawables.indexOf(ae);if(af!==-1){this.drawables[af]=ac;if(ad){ae.container_div.replaceWith(ac.container_div)}this.changed()}return af},remove_drawable:function(ad){var ac=this.drawables.indexOf(ad);if(ac!==-1){this.drawables.splice(ac,1);ad.container=null;this.changed();return true}return false},move_drawable:function(ad,ae){var ac=this.drawables.indexOf(ad);if(ac!==-1){this.drawables.splice(ac,1);this.drawables.splice(ae,0,ad);this.changed();return true}return false},get_drawables:function(){return this.drawables},get_tracks:function(af){var ac=this.drawables.slice(0),ad=[],ae;while(ac.length!==0){ae=ac.shift();if(ae instanceof af){ad.push(ae)}else{if(ae.drawables){ac=ac.concat(ae.drawables)}}}return ad}});var N=function(ad,ac,af){o(af,{obj_type:"DrawableGroup",drag_handle_class:"group-handle"});y.call(this,ad,ac,af);this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);i(this.container_div,this);i(this.content_div,this);k(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new h.FiltersManager(this);this.header_div.after(this.filters_manager.parent_div);this.filters_manager.parent_div.after($("<div style='clear: both'/>"));this.saved_filters_managers=[];if("drawables" in af){this.unpack_drawables(af.drawables)}if("filters" in af){var ae=this.filters_manager;this.filters_manager=new h.FiltersManager(this,af.filters);ae.parent_div.replaceWith(this.filters_manager.parent_div);if(af.filters.visible){this.setup_multitrack_filtering()}}};o(N.prototype,p.prototype,y.prototype,{action_icons_def:[p.prototype.action_icons_def[0],p.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(ac){$(".tooltip").remove();ac.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"ui-slider-050",on_click_fn:function(ac){if(ac.filters_manager.visible()){ac.filters_manager.clear_filters();ac._restore_filter_managers()}else{ac.setup_multitrack_filtering();ac.request_draw({clear_tile_cache:true})}ac.filters_manager.toggle()}},p.prototype.action_icons_def[2]],build_container_div:function(){var ac=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(ac)}return ac},hide_contents:function(){this.tiles_div.hide()},show_contents:function(){this.tiles_div.show();this.request_draw()},update_icons:function(){var ae=this.drawables.length;if(ae===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(ae===1){this.action_icons.composite_icon.toggle(this.drawables[0] instanceof e);this.action_icons.filters_icon.hide()}else{var al,ak,ai,ao=true,ag=this.drawables[0].get_type(),ac=0;for(al=0;al<ae;al++){ai=this.drawables[al];if(ai.get_type()!==ag){can_composite=false;break}if(ai instanceof c){ac++}}if(ao&&this.drawables[0] instanceof g){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tooltip").remove()}if(ac>1&&ac===this.drawables.length){var ap={},ad;ai=this.drawables[0];for(ak=0;ak<ai.filters_manager.filters.length;ak++){ad=ai.filters_manager.filters[ak];ap[ad.name]=[ad]}for(al=1;al<this.drawables.length;al++){ai=this.drawables[al];for(ak=0;ak<ai.filters_manager.filters.length;ak++){ad=ai.filters_manager.filters[ak];if(ad.name in ap){ap[ad.name].push(ad)}}}this.filters_manager.remove_all();var af,ah,aj,am;for(var an in ap){af=ap[an];if(af.length===ac){ah=new h.NumberFilter({name:af[0].name,index:af[0].index});this.filters_manager.add_filter(ah)}}this.action_icons.filters_icon.toggle(this.filters_manager.filters.length>0)}else{this.action_icons.filters_icon.hide()}}}},_restore_filter_managers:function(){for(var ac=0;ac<this.drawables.length;ac++){this.drawables[ac].filters_manager=this.saved_filters_managers[ac]}this.saved_filters_managers=[]},setup_multitrack_filtering:function(){if(this.filters_manager.filters.length>0){this.saved_filters_managers=[];for(var ac=0;ac<this.drawables.length;ac++){drawable=this.drawables[ac];this.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=this.filters_manager}}this.filters_manager.init_filters()},show_composite_track:function(){var ad=new e(this.view,this.view,{name:this.config.get_value("name"),drawables:this.drawables});var ac=this.container.replace_drawable(this,ad,true);ad.request_draw()},add_drawable:function(ac){y.prototype.add_drawable.call(this,ac);this.update_icons()},remove_drawable:function(ac){y.prototype.remove_drawable.call(this,ac);this.update_icons()},to_dict:function(){if(this.filters_manager.visible()){this._restore_filter_managers()}var ac=o(y.prototype.to_dict.call(this),{filters:this.filters_manager.to_dict()});if(this.filters_manager.visible()){this.setup_multitrack_filtering()}return ac},request_draw:function(ac){ab.each(this.drawables,function(ad){ad.request_draw(ac)})}});var Y=Backbone.View.extend({initialize:function(ac){o(ac,{obj_type:"View"});y.call(this,"View",ac.container,ac);this.chrom=null;this.vis_id=ac.vis_id;this.dbkey=ac.dbkey;this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.load_chroms_deferred=null;this.render();this.canvas_manager=new w.CanvasManager(this.container.get(0).ownerDocument);this.reset();this.config=R.ConfigSettingCollection.from_models_and_saved_values([{key:"name",label:"Name",type:"text",default_value:""},{key:"a_color",label:"A Color",type:"color",default_value:"#FF0000"},{key:"c_color",label:"C Color",type:"color",default_value:"#00FF00"},{key:"g_color",label:"G Color",type:"color",default_value:"#0000FF"},{key:"t_color",label:"T Color",type:"color",default_value:"#FF00FF"},{key:"n_color",label:"N Color",type:"color",default_value:"#AAAAAA"}],{name:ac.name})},render:function(){this.requested_redraw=false;var ae=this.container,ac=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ae);this.browser_content_div=$("<div/>").addClass("content").appendTo(ae);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ae);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;i(this.viewport_container,ac);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container);var af=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){w.select_datasets(galaxy_config.root+"visualization/list_current_history_datasets",galaxy_config.root+"api/datasets",{"f-dbkey":ac.dbkey},function(ag){ab.each(ag,function(ah){ac.add_drawable(n(ah,ac,ac))})})});this.nav_container=$("<div/>").addClass("trackster-nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("trackster-nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a/>").attr("title","Close overview").addClass("icon-button overview-close tooltip").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_select=$("<select/>").attr({name:"chrom"}).addClass("chrom-nav").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var ad=function(ag){if(ag.type==="focusout"||(ag.keyCode||ag.which)===13||(ag.keyCode||ag.which)===27){if((ag.keyCode||ag.which)!==27){ac.go_to($(this).val())}$(this).hide();$(this).val("");ac.location_span.show();ac.chrom_select.show()}ag.stopPropagation()};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",ad).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("title","Click to change location").tooltip({placement:"bottom"}).appendTo(this.nav_controls);this.location_span.click(function(){ac.location_span.hide();ac.chrom_select.hide();ac.nav_input.val(ac.chrom+":"+ac.low+"-"+ac.high);ac.nav_input.css("display","inline-block");ac.nav_input.select();ac.nav_input.focus();ac.nav_input.autocomplete({source:function(ai,ag){var aj=[],ah=$.map(ac.get_tracks(c),function(ak){return ak.data_manager.search_features(ai.term).success(function(al){aj=aj.concat(al)})});$.when.apply($,ah).done(function(){ag($.map(aj,function(ak){return{label:ak[0],value:ak[1]}}))})},minLength:2})});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a/>").attr("id","zoom-out").attr("title","Zoom out").tooltip({placement:"bottom"}).click(function(){ac.zoom_out()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tooltip({placement:"bottom"}).click(function(){ac.zoom_in()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){ac.change_chrom(ac.chrom_select.val())});this.browser_content_div.click(function(ag){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ag){ac.zoom_in(ag.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ag,ah){this.current_x=ah.offsetX}).bind("drag",function(ag,ai){var aj=ai.offsetX-this.current_x;this.current_x=ai.offsetX;var ah=Math.round(aj/ac.viewport_container.width()*(ac.max_high-ac.max_low));ac.move_delta(-ah)});this.overview_close.click(function(){ac.reset_overview()});this.viewport_container.bind("draginit",function(ag,ah){if(ag.clientX>ac.viewport_container.width()-16){return false}}).bind("dragstart",function(ag,ah){ah.original_low=ac.low;ah.current_height=ag.clientY;ah.current_x=ah.offsetX}).bind("drag",function(ai,ak){var ag=$(this);var al=ak.offsetX-ak.current_x;var ah=ag.scrollTop()-(ai.clientY-ak.current_height);ag.scrollTop(ah);ak.current_height=ai.clientY;ak.current_x=ak.offsetX;var aj=Math.round(al/ac.viewport_container.width()*(ac.high-ac.low));ac.move_delta(aj)});this.top_labeltrack.bind("dragstart",function(ag,ah){return $("<div/>").addClass("zoom-area").css("height",ac.browser_content_div.height()+ac.top_labeltrack.height()+1).appendTo($(this))}).bind("drag",function(ak,al){$(al.proxy).css({left:Math.min(ak.pageX,al.startX)-ac.container.offset().left,width:Math.abs(ak.pageX-al.startX)});var ah=Math.min(ak.pageX,al.startX)-ac.container.offset().left,ag=Math.max(ak.pageX,al.startX)-ac.container.offset().left,aj=(ac.high-ac.low),ai=ac.viewport_container.width();ac.update_location(Math.round(ah/ai*aj)+ac.low,Math.round(ag/ai*aj)+ac.low)}).bind("dragend",function(al,am){var ah=Math.min(al.pageX,am.startX),ag=Math.max(al.pageX,am.startX),aj=(ac.high-ac.low),ai=ac.viewport_container.width(),ak=ac.low;ac.low=Math.round(ah/ai*aj)+ak;ac.high=Math.round(ag/ai*aj)+ak;$(am.proxy).remove();ac.request_redraw()});this.add_label_track(new W(this,{content_div:this.top_labeltrack}));$(window).bind("resize",function(){if(this.resize_timer){clearTimeout(this.resize_timer)}this.resize_timer=setTimeout(function(){ac.resize_window()},500)});$(document).bind("redraw",function(){ac.redraw()});this.reset();$(window).trigger("resize")},get_base_color:function(ac){return this.config.get_value(ac.toLowerCase()+"_color")||this.config.get_value("n_color")}});o(Y.prototype,y.prototype,{changed:function(){this.has_changes=true},update_intro_div:function(){this.intro_div.toggle(this.drawables.length===0)},trigger_navigate:function(ad,af,ac,ag){if(this.timer){clearTimeout(this.timer)}if(ag){var ae=this;this.timer=setTimeout(function(){ae.trigger("navigate",ad+":"+af+"-"+ac)},500)}else{view.trigger("navigate",ad+":"+af+"-"+ac)}},update_location:function(ac,ae){this.location_span.text(commatize(ac)+" - "+commatize(ae));this.nav_input.val(this.chrom+":"+commatize(ac)+"-"+commatize(ae));var ad=this.chrom_select.val();if(ad!==""){this.trigger_navigate(ad,this.low,this.high,true)}},load_chroms:function(ae){ae.num=v;var ac=this,ad=$.Deferred();$.ajax({url:galaxy_config.root+"api/genomes/"+this.dbkey,data:ae,dataType:"json",success:function(ag){if(ag.chrom_info.length===0){return}if(ag.reference){var ah=new B(ac);ac.add_label_track(ah);ac.reference_track=ah}ac.chrom_data=ag.chrom_info;var ak='<option value="">Select Chrom/Contig</option>';for(var aj=0,af=ac.chrom_data.length;aj<af;aj++){var ai=ac.chrom_data[aj].chrom;ak+='<option value="'+ai+'">'+ai+"</option>"}if(ag.prev_chroms){ak+='<option value="previous">Previous '+v+"</option>"}if(ag.next_chroms){ak+='<option value="next">Next '+v+"</option>"}ac.chrom_select.html(ak);ac.chrom_start_index=ag.start_index;ad.resolve(ag.chrom_info)},error:function(){alert("Could not load chroms for this dbkey: "+ac.dbkey)}});return ad},change_chrom:function(ah,ad,aj){var ae=this;if(!ae.chrom_data){ae.load_chroms_deferred.then(function(){ae.change_chrom(ah,ad,aj)});return}if(!ah||ah==="None"){return}if(ah==="previous"){ae.load_chroms({low:this.chrom_start_index-v});return}if(ah==="next"){ae.load_chroms({low:this.chrom_start_index+v});return}var ai=$.grep(ae.chrom_data,function(ak,al){return ak.chrom===ah})[0];if(ai===undefined){ae.load_chroms({chrom:ah},function(){ae.change_chrom(ah,ad,aj)});return}else{if(ah!==ae.chrom){ae.chrom=ah;ae.chrom_select.val(ae.chrom);ae.max_high=ai.len-1;ae.reset();for(var ag=0,ac=ae.drawables.length;ag<ac;ag++){var af=ae.drawables[ag];if(af.init){af.init()}}if(ae.reference_track){ae.reference_track.init()}}if(ad===undefined&&aj===undefined){ae.low=0;ae.high=ae.max_high}else{ae.low=(ad!==undefined?Math.max(ad,0):0);if(aj===undefined){ae.low=Math.max(ae.low-15,0);ae.high=ae.low+30}else{ae.high=Math.min(aj,ae.max_high)}}ae.request_redraw()}},go_to:function(ag){ag=ag.replace(/,/g,"");ag=ag.replace(/:|\-/g," ");var ad=ag.split(/\s+/),af=ad[0],ae=(ad[1]?parseInt(ad[1],10):undefined),ac=(ad[2]?parseInt(ad[2],10):undefined);this.change_chrom(af,ae,ac)},move_fraction:function(ae){var ac=this;var ad=ac.high-ac.low;this.move_delta(ae*ad)},move_delta:function(af){var ac=this;var ae=ac.high-ac.low;if(ac.low-af<ac.max_low){ac.low=ac.max_low;ac.high=ac.max_low+ae}else{if(ac.high-af>ac.max_high){ac.high=ac.max_high;ac.low=ac.max_high-ae}else{ac.high-=af;ac.low-=af}}ac.request_redraw({data_fetch:false});if(this.redraw_on_move_fn){clearTimeout(this.redraw_on_move_fn)}this.redraw_on_move_fn=setTimeout(function(){ac.request_redraw()},200);var ad=ac.chrom_select.val();this.trigger_navigate(ad,ac.low,ac.high,true)},add_drawable:function(ad){y.prototype.add_drawable.call(this,ad);ad.init();this.changed();this.update_intro_div();var ac=this;ad.config.on("change",function(){ac.changed()})},add_label_track:function(ac){ac.view=this;ac.init();this.label_tracks.push(ac)},remove_drawable:function(ae,ad){y.prototype.remove_drawable.call(this,ae);if(ad){var ac=this;ae.container_div.hide(0,function(){$(this).remove();ac.update_intro_div()})}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(ad,ae){var ac=this,af=(ae?[ae]:ac.drawables);ab.each(af,function(ag){var ah=ab.find(ac.tracks_to_be_redrawn,function(ai){return ai[0]===ag});if(ah){ah[1]=ad}else{ac.tracks_to_be_redrawn.push([ag,ad])}});if(!this.requested_redraw){requestAnimationFrame(function(){ac._redraw()});this.requested_redraw=true}},_redraw:function(){this.requested_redraw=false;var ac=this.low,ag=this.high;if(ac<this.max_low){ac=this.max_low}if(ag>this.max_high){ag=this.max_high}var ad=this.high-this.low;if(this.high!==0&&ad<this.min_separation){ag=ac+this.min_separation}this.low=Math.floor(ac);this.high=Math.ceil(ag);this.update_location(this.low,this.high);this.resolution_px_b=this.viewport_container.width()/(this.high-this.low);var af=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ah=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ae=13;this.overview_box.css({left:af,width:Math.max(ae,ah)}).show();if(ah<ae){this.overview_box.css("left",af-(ae-ah)/2)}if(this.overview_highlight){this.overview_highlight.css({left:af,width:ah})}ab.each(this.tracks_to_be_redrawn,function(ak){var ai=ak[0],aj=ak[1];if(ai){ai._draw(aj)}});this.tracks_to_be_redrawn=[];ab.each(this.label_tracks,function(ai){ai._draw()})},zoom_in:function(ad,ae){if(this.max_high===0||this.high-this.low<=this.min_separation){return}var af=this.high-this.low,ag=af/2+this.low,ac=(af/this.zoom_factor)/2;if(ad){ag=ad/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ag-ac);this.high=Math.round(ag+ac);this.changed();this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var ad=this.high-this.low,ae=ad/2+this.low,ac=(ad*this.zoom_factor)/2;this.low=Math.round(ae-ac);this.high=Math.round(ae+ac);this.changed();this.request_redraw()},resize_viewport:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height())},resize_window:function(){this.resize_viewport();this.request_redraw()},set_overview:function(ae){if(this.overview_drawable){if(this.overview_drawable.dataset.id===ae.dataset.id){return}this.overview_viewport.find(".track").remove()}var ad=ae.copy({content_div:this.overview_viewport}),ac=this;ad.header_div.hide();ad.is_overview=true;ac.overview_drawable=ad;this.overview_drawable.postdraw_actions=function(){ac.overview_highlight.show().height(ac.overview_drawable.content_div.height());ac.overview_viewport.height(ac.overview_drawable.content_div.height()+ac.overview_box.outerHeight());ac.overview_close.show();ac.resize_window()};ac.overview_drawable.request_draw();this.changed()},reset_overview:function(){$(".tooltip").remove();this.overview_viewport.find(".track-tile").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide();view.resize_window();view.overview_drawable=null}});var q=P.Tool.extend({defaults:{track:null},initialize:function(ac){P.Tool.prototype.initialize.call(this,ac);var ad=true;if(ac.tool_state!==undefined&&ac.tool_state.hidden!==undefined){ad=ac.tool_state.hidden}this.set("hidden",ad);this.remove_inputs(["data","hidden_data","conditional"])},state_dict:function(ac){return ab.extend(this.get_inputs_dict(),{hidden:!this.is_visible()})}});var t=Backbone.View.extend({events:{"change :input":"update_value"},render:function(){var ae=this.$el.addClass("param-row"),af=this.model;var ac=$("<div>").addClass("param-label").text(af.get("label")).appendTo(ae);var ad=$("<div/>").addClass("param-input").html(af.get("html")).appendTo(ae);ad.find(":input").val(af.get("value"));$("<div style='clear: both;'/>").appendTo(ae)},update_value:function(ac){this.model.set_value($(ac.target).val())}});var aa=Backbone.View.extend({initialize:function(ac){this.model.on("change:hidden",this.set_visible,this)},render:function(){var ad=this;tool=this.model,parent_div=this.$el.addClass("dynamic-tool").hide();parent_div.bind("drag",function(ah){ah.stopPropagation()}).click(function(ah){ah.stopPropagation()}).bind("dblclick",function(ah){ah.stopPropagation()}).keydown(function(ah){ah.stopPropagation()});var ae=$("<div class='tool-name'>").appendTo(parent_div).text(tool.get("name"));tool.get("inputs").each(function(ai){var ah=new t({model:ai});ah.render();parent_div.append(ah.$el)});parent_div.find("input").click(function(){$(this).select()});var af=$("<div>").addClass("param-row").appendTo(parent_div);var ag=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(af);var ac=$("<input type='submit'>").attr("value","Run on visible region").appendTo(af);ac.click(function(){ad.run_on_region()});ag.click(function(){ad.run_on_dataset()});if(tool.is_visible()){this.$el.show()}},set_visible:function(){this.$el.toggle(this.model.is_visible())},update_params:function(){for(var ac=0;ac<this.params.length;ac++){this.params[ac].update_value()}},run_on_dataset:function(){var ac=this.model;this.run({target_dataset_id:this.model.get("track").dataset.id,action:"rerun",tool_id:ac.id},null,function(ad){Galaxy.modal.show({title:ac.get("name")+" is Running",body:ac.get("name")+" is running on the complete dataset. Tool outputs are in dataset's history.",buttons:{Close:function(){Galaxy.modal.hide()}}})})},run_on_region:function(){var ad=this.model.get("track"),ag=this.model,ai=new w.GenomeRegion({chrom:ad.view.chrom,start:ad.view.low,end:ad.view.high}),aj={target_dataset_id:ad.dataset.id,action:"rerun",tool_id:ag.id,regions:[ai.toJSON()]},ah=ad,al=ag.get("name")+ah.tool_region_and_parameters_str(ai),ac;if(ah.container===view){var ak=new N(view,view,{name:ad.config.get_value("name")});var af=ah.container.replace_drawable(ah,ak,false);ak.container_div.insertBefore(ah.view.content_div.children()[af]);ak.add_drawable(ah);ah.container_div.appendTo(ak.content_div);ac=ak}else{ac=ah.container}var ae=new ah.constructor(view,ac,{name:al,hda_ldda:"hda"});ae.init_for_tool_data();ae.change_mode(ah.mode);ae.set_filters_manager(ah.filters_manager.copy(ae));ae.update_icons();ac.add_drawable(ae);ae.tiles_div.text("Starting job.");this.run(aj,ae,function(am){ae.set_dataset(new X.Dataset(am));ae.tiles_div.text("Running job.");ae.init()})},run:function(ac,ae,af){ac.inputs=this.model.get_inputs_dict();var ad=new j.ServerStateDeferred({ajax_settings:{url:galaxy_config.root+"api/tools",data:JSON.stringify(ac),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(ag){return ag!=="pending"}});$.when(ad.go()).then(function(ag){if(ag==="no converter"){ae.container_div.addClass("error");ae.content_div.text(H)}else{if(ag.error){ae.container_div.addClass("error");ae.content_div.text(x+ag.message)}else{af(ag)}}})}});var C=function(ac,ad){J.Scaler.call(this,ad);this.filter=ac};C.prototype.gen_val=function(ac){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(ac[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var b=function(ac,af,ag,ad,ae){this.track=ac;this.region=af;this.low=af.get("start");this.high=af.get("end");this.w_scale=ag;this.canvas=ad;this.html_elt=$("<div class='track-tile'/>").append(ad);this.data=ae;this.stale=false};b.prototype.predisplay_actions=function(){};var K=function(ac,af,ag,ad,ae){b.call(this,ac,af,ag,ad,ae)};K.prototype.predisplay_actions=function(){};var M=function(ae,aj,al,ad,ag,ah,am,ac,ai,af,ak){b.call(this,ae,aj,al,ad,ag);this.mode=ah;this.all_slotted=ac;this.feature_mapper=ai;this.has_icons=false;this.incomplete_features=af;this.other_tiles_features_drawn={};this.seq_data=ak};o(M.prototype,b.prototype);M.prototype.predisplay_actions=function(){};var f=function(ad,ac,ae){o(ae,{drag_handle_class:"draghandle"});p.call(this,ad,ac,ae);this.dataset=null;if(ae.dataset){this.dataset=(ae.dataset instanceof Backbone.Model?ae.dataset:new X.Dataset(ae.dataset))}this.dataset_check_type="converted_datasets_state";this.data_url_extra_params={};this.data_query_wait=("data_query_wait" in ae?ae.data_query_wait:I);this.data_manager=("data_manager" in ae?ae.data_manager:new w.GenomeDataManager({dataset:this.dataset,genome:new w.Genome({key:ad.dbkey,chroms_info:{chrom_info:ad.chrom_data}}),data_mode_compatible:this.data_and_mode_compatible,can_subset:this.can_subset}));this.min_height_px=16;this.max_height_px=800;this.visible_height_px=this.config.get_value("height");this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div);if(!("resize" in ae)||ae.resize){this.add_resize_handle()}}};o(f.prototype,p.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},p.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"application-dock-270",on_click_fn:function(ac){ac.view.set_overview(ac)}},p.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"ui-slider-050",on_click_fn:function(ac){if(ac.filters_manager.visible()){ac.filters_manager.clear_filters()}else{ac.filters_manager.init_filters()}ac.filters_manager.toggle()}},{name:"tools_icon",title:"Tool",css_class:"hammer",on_click_fn:function(ac){ac.tool.toggle();if(ac.tool.is_visible()){ac.set_name(ac.config.get_value("name")+ac.tool_region_and_parameters_str())}else{ac.revert_name()}$(".tooltip").remove()}},{name:"param_space_viz_icon",title:"Tool parameter space visualization",css_class:"arrow-split",on_click_fn:function(ac){var af='<strong>Tool</strong>: <%= track.tool.get("name") %><br/><strong>Dataset</strong>: <%= track.config.get_value("name") %><br/><strong>Region(s)</strong>: <select name="regions"><option value="cur">current viewing area</option><option value="bookmarks">bookmarks</option><option value="both">current viewing area and bookmarks</option></select>',ae=ab.template(af,{track:ac});var ah=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},ad=function(){var aj=$('select[name="regions"] option:selected').val(),al,ai=new w.GenomeRegion({chrom:view.chrom,start:view.low,end:view.high}),ak=ab.map($(".bookmark"),function(am){return new w.GenomeRegion({from_str:$(am).children(".position").text()})});if(aj==="cur"){al=[ai]}else{if(aj==="bookmarks"){al=ak}else{al=[ai].concat(ak)}}Galaxy.modal.hide();window.location.href=galaxy_config.root+"visualization/sweepster?"+$.param({dataset_id:ac.dataset.id,hda_ldda:ac.dataset.get("hda_ldda"),regions:JSON.stringify(new Backbone.Collection(al).toJSON())})},ag=function(ai){if((ai.keyCode||ai.which)===27){ah()}else{if((ai.keyCode||ai.which)===13){ad()}}};Galaxy.modal.show({title:"Visualize tool parameter space and output from different parameter settings?",body:ae,buttons:{No:ah,Yes:ad}})}},p.prototype.action_icons_def[2]],can_draw:function(){return this.dataset&&p.prototype.can_draw.call(this)},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id)},set_dataset:function(ac){this.dataset=ac;this.data_manager.set("dataset",ac)},on_resize:function(){this.request_draw({clear_tile_cache:true})},add_resize_handle:function(){var ac=this;var af=false;var ae=false;var ad=$("<div class='track-resize'>");$(ac.container_div).hover(function(){if(ac.config.get_value("content_visible")){af=true;ad.show()}},function(){af=false;if(!ae){ad.hide()}});ad.hide().bind("dragstart",function(ag,ah){ae=true;ah.original_height=$(ac.content_div).height()}).bind("drag",function(ah,ai){var ag=Math.min(Math.max(ai.original_height+ai.deltaY,ac.min_height_px),ac.max_height_px);$(ac.tiles_div).css("height",ag);ac.visible_height_px=(ac.max_height_px===ag?0:ag);ac.on_resize()}).bind("dragend",function(ag,ah){ac.tile_cache.clear();ae=false;if(!af){ad.hide()}ac.config.set_value("height",ac.visible_height_px);ac.changed()}).appendTo(ac.container_div)},hide_contents:function(){this.tiles_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.tiles_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof W){return"LabelTrack"}else{if(this instanceof B){return"ReferenceTrack"}else{if(this instanceof g){return"LineTrack"}else{if(this instanceof S){return"ReadTrack"}else{if(this instanceof Z){return"VariantTrack"}else{if(this instanceof e){return"CompositeTrack"}else{if(this instanceof c){return"FeatureTrack"}}}}}}}return""},show_message:function(ac){this.tiles_div.remove();return $("<span/>").addClass("message").html(ac).appendTo(this.content_div)},init:function(ae){var ad=this;ad.enabled=false;ad.tile_cache.clear();ad.data_manager.clear();ad.content_div.children().remove();ad.container_div.removeClass("nodata error pending");ad.tiles_div=$("<div/>").addClass("tiles").appendTo(ad.content_div);if(!ad.dataset.id){return}var ac=$.Deferred(),af={hda_ldda:ad.dataset.get("hda_ldda"),data_type:this.dataset_check_type,chrom:ad.view.chrom,retry:ae};$.getJSON(this.dataset.url(),af,function(ag){if(!ag||ag==="error"||ag.kind==="error"){ad.container_div.addClass("error");var ah=ad.show_message(m);if(ag.message){ah.append($("<a href='javascript:void(0);'></a>").text("View error").click(function(){Galaxy.modal.show({title:"Trackster Error",body:"<pre>"+ag.message+"</pre>",buttons:{Close:function(){Galaxy.modal.hide()}}})}));ah.append($("<span/>").text(" "));ah.append($("<a href='javascript:void(0);'></a>").text("Try again").click(function(){ad.init(true)}))}}else{if(ag==="no converter"){ad.container_div.addClass("error");ad.show_message(H)}else{if(ag==="no data"||(ag.data!==undefined&&(ag.data===null||ag.data.length===0))){ad.container_div.addClass("nodata");ad.show_message(E)}else{if(ag==="pending"){ad.container_div.addClass("pending");ad.show_message(u);setTimeout(function(){ad.init()},ad.data_query_wait)}else{if(ag==="data"||ag.status==="data"){if(ag.valid_chroms){ad.valid_chroms=ag.valid_chroms;ad.update_icons()}ad.tiles_div.text(T);if(ad.view.chrom){ad.tiles_div.text("");ad.tiles_div.css("height",ad.visible_height_px+"px");ad.enabled=true;$.when.apply($,ad.predraw_init()).done(function(){ac.resolve();ad.container_div.removeClass("nodata error pending");ad.request_draw()})}else{ac.resolve()}}}}}}});this.update_icons();return ac},predraw_init:function(){var ac=this;return $.getJSON(ac.dataset.url(),{data_type:"data",stats:true,chrom:ac.view.chrom,low:0,high:ac.view.max_high,hda_ldda:ac.dataset.get("hda_ldda")},function(ad){var af=ad.data;if(af&&af.min&&af.max){var ae=af.min,ag=af.max;ae=Math.floor(Math.min(0,Math.max(ae,af.mean-2*af.sd)));ag=Math.ceil(Math.max(0,Math.min(ag,af.mean+2*af.sd)));ac.config.set_default_value("min_value",ae);ac.config.set_default_value("max_value",ag);ac.config.set_value("min_value",ae);ac.config.set_value("max_value",ag)}})},get_drawables:function(){return this}});var L=function(ae,ad,ag){f.call(this,ae,ad,ag);var ac=this;k(ac.container_div,ac.drag_handle_class,".group",ac);this.filters_manager=new h.FiltersManager(this,("filters" in ag?ag.filters:null));this.data_manager.set("filters_manager",this.filters_manager);this.filters_available=false;this.tool=(ag.tool?new q(ab.extend(ag.tool,{track:this,tool_state:ag.tool_state})):null);this.tile_cache=new w.Cache(O);this.left_offset=0;if(this.header_div){this.set_filters_manager(this.filters_manager);if(this.tool){var af=new aa({model:this.tool});af.render();this.dynamic_tool_div=af.$el;this.header_div.after(this.dynamic_tool_div)}}this.tiles_div=$("<div/>").addClass("tiles").appendTo(this.content_div);if(!this.config.get_value("content_visible")){this.tiles_div.hide()}this.overlay_div=$("<div/>").addClass("overlay").appendTo(this.content_div);if(ag.mode){this.change_mode(ag.mode)}};o(L.prototype,p.prototype,f.prototype,{action_icons_def:f.prototype.action_icons_def.concat([{name:"show_more_rows_icon",title:"To minimize track height, not all feature rows are displayed. Click to display more rows.",css_class:"exclamation",on_click_fn:function(ac){$(".tooltip").remove();ac.slotters[ac.view.resolution_px_b].max_rows*=2;ac.request_draw({clear_tile_cache:true})},hide:true}]),copy:function(ac){var ad=this.to_dict();o(ad,{data_manager:this.data_manager});var ae=new this.constructor(this.view,ac,ad);ae.change_mode(this.mode);ae.enabled=this.enabled;return ae},set_filters_manager:function(ac){this.filters_manager=ac;this.header_div.after(this.filters_manager.parent_div)},to_dict:function(){return{track_type:this.get_type(),dataset:{id:this.dataset.id,hda_ldda:this.dataset.get("hda_ldda")},prefs:this.config.to_key_value_dict(),mode:this.mode,filters:this.filters_manager.to_dict(),tool_state:(this.tool?this.tool.state_dict():{})}},set_min_max:function(){var ac=this;return $.getJSON(ac.dataset.url(),{data_type:"data",stats:true,chrom:ac.view.chrom,low:0,high:ac.view.max_high,hda_ldda:ac.dataset.get("hda_ldda")},function(ad){var af=ad.data;if(isNaN(parseFloat(ac.config.get_value("min_value")))||isNaN(parseFloat(ac.config.get_value("max_value")))){var ae=af.min,ag=af.max;ae=Math.floor(Math.min(0,Math.max(ae,af.mean-2*af.sd)));ag=Math.ceil(Math.max(0,Math.min(ag,af.mean+2*af.sd)));ac.config.set_value("min_value",ae);ac.config.set_value("max_value",ag)}})},change_mode:function(ad){var ac=this;ac.mode=ad;ac.config.set_value("mode",ad);if(ad==="Auto"){this.data_manager.clear()}ac.request_draw({clear_tile_cache:true});this.action_icons.mode_icon.attr("title","Set display mode (now: "+ac.mode+")");return ac},update_icons:function(){var ac=this;ac.action_icons.filters_icon.toggle(ac.filters_available);ac.action_icons.tools_icon.toggle(ac.tool!==null);ac.action_icons.param_space_viz_icon.toggle(ac.tool!==null)},_gen_tile_cache_key:function(ad,ac){return ad+"_"+ac},request_draw:function(ac){if(ac&&ac.clear_tile_cache){this.tile_cache.clear()}this.view.request_redraw(ac,this)},before_draw:function(){this.max_height_px=0},_draw:function(aq){if(!this.can_draw()){return}var an=aq&&aq.clear_after,al=this.view.low,ag=this.view.high,aj=ag-al,ad=this.view.container.width(),ap=this.view.resolution_px_b,af=1/ap;if(this.is_overview){al=this.view.max_low;ag=this.view.max_high;ap=ad/(view.max_high-view.max_low);af=1/ap}this.before_draw();this.tiles_div.children().addClass("remove");var ak=Math.floor(Q*af),ac=Math.floor(al/ak),am,ah,ai=[],ao=[];while((ac*ak)<ag){am=new w.GenomeRegion({chrom:this.view.chrom,start:ac*ak,end:Math.min((ac+1)*ak,this.view.max_high)});ah=this.draw_helper(am,ap,aq);ai.push(ah);$.when(ah).then(function(ar){ao.push(ar)});ac+=1}if(!an){this.tiles_div.children(".remove").removeClass("remove").remove()}var ae=this;$.when.apply($,ai).then(function(){ae.tiles_div.children(".remove").remove();ao=ab.filter(ao,function(ar){return ar!==null});if(ao.length!==0){ae.postdraw_actions(ao,ad,ap,an)}})},_add_yaxis_label:function(af,ah){var ad=this,ag=(af==="max"?"top":"bottom"),ai=(af==="max"?"max":"min"),ac=(af==="max"?"max_value":"min_value"),ae=this.container_div.find(".yaxislabel."+ag);ah=ah||function(){ad.request_draw({clear_tile_cache:true})};if(ae.length!==0){ae.text(ad.config.get_value(ac))}else{ae=$("<div/>").text(ad.config.get_value(ac)).make_text_editable({num_cols:12,on_finish:function(aj){$(".tooltip").remove();ad.config.set_value(ac,aj);ah()},help_text:"Set "+ai+" value"}).addClass("yaxislabel "+ag).css("color",this.config.get_value("label_color"));this.container_div.prepend(ae)}},postdraw_actions:function(af,ag,ai,ac){var ae=ab.filter(af,function(aj){return(aj instanceof K)});if(ae.length>0){this.max_height_px=0;var ad=this;ab.each(af,function(aj){if(!(aj instanceof K)){aj.html_elt.remove();ad.draw_helper(aj.region,ai,{force:true,mode:"Coverage"})}});ad._add_yaxis_label("max")}else{this.container_div.find(".yaxislabel").remove();var ah=ab.find(af,function(aj){return aj.has_icons});if(ah){ab.each(af,function(aj){if(!aj.has_icons){aj.html_elt.css("padding-top",D)}})}}},get_mode:function(ac){return this.mode},update_auto_mode:function(ac){},_get_drawables:function(){return[this]},draw_helper:function(al,an,ao){if(!ao){ao={}}var ad=ao.force,ai=ao.mode||this.mode,af=1/an,ae=this,ag=this._get_drawables(),am=this._gen_tile_cache_key(an,al),ah=function(ap){return(ap&&"track" in ap)};var aj=(ad?undefined:ae.tile_cache.get_elt(am));if(aj){if(ah(aj)){ae.show_tile(aj,an)}return aj}if(ao.data_fetch===false){return null}var ak=function(){var ap=(ab.find(A,function(ar){return ar===ai})?"Coverage":ai);var aq=ab.map(ag,function(ar){return ar.data_manager.get_data(al,ap,af,ae.data_url_extra_params)});if(view.reference_track){aq.push(view.reference_track.data_manager.get_data(al,ai,af,view.reference_track.data_url_extra_params))}return aq};var ac=$.Deferred();ae.tile_cache.set_elt(am,ac);$.when.apply($,ak()).then(function(){var ap=ak(),av=ap,aB;if(ab.find(ap,function(aD){return j.is_deferred(aD)})){ae.tile_cache.set_elt(am,undefined);$.when(ae.draw_helper(al,an,ao)).then(function(aD){ac.resolve(aD)});return}if(view.reference_track){aB=view.reference_track.data_manager.subset_entry(ap.pop(),al)}var aw=[],at=[];ab.each(ag,function(aG,aD){var aF=aG.mode,aE=av[aD];if(aF==="Auto"){aF=aG.get_mode(aE);aG.update_auto_mode(aF)}aw.push(aF);at.push(aG.get_canvas_height(aE,aF,an,aq))});var au=ae.view.canvas_manager.new_canvas(),ax=al.get("start"),aC=al.get("end"),ar=0,aq=Math.ceil((aC-ax)*an)+ae.left_offset,az=ab.max(at),ay;au.width=aq;au.height=(ao.height||az);var aA=au.getContext("2d");aA.translate(ae.left_offset,0);if(ag.length>1){aA.globalAlpha=0.5;aA.globalCompositeOperation="source-over"}ab.each(ag,function(aE,aD){ay=aE.draw_tile(av[aD],aA,aw[aD],al,an,aB)});if(ay!==undefined){ae.tile_cache.set_elt(am,ay);ae.show_tile(ay,an)}ac.resolve(ay)});return ac},get_canvas_height:function(ac,ae,af,ad){return this.visible_height_px},_draw_line_track_tile:function(ac,ae,ah,ag,ai){var af=ae.canvas,ad=new J.LinePainter(ac.data,ag.get("start"),ag.get("end"),this.config.to_key_value_dict(),ah);ad.draw(ae,af.width,af.height,ai);return new K(this,ag,ai,af,ac.data)},draw_tile:function(ac,ad,ag,af,ah,ae){},show_tile:function(ae,ah){var ad=this,ac=ae.html_elt;ae.predisplay_actions();var ag=Math.round((ae.low-(this.is_overview?this.view.max_low:this.view.low))*ah);if(this.left_offset){ag-=this.left_offset}ac.css("left",ag);if(ac.hasClass("remove")){ac.removeClass("remove")}else{this.tiles_div.append(ac)}ac.css("height","auto");this.max_height_px=Math.max(this.max_height_px,ac.height()-2);ac.parent().children().css("height",this.max_height_px+"px");var af=this.max_height_px;if(this.visible_height_px!==0){af=Math.min(this.max_height_px,this.visible_height_px)}this.tiles_div.css("height",af+"px")},tool_region_and_parameters_str:function(af){var ac=this,ae=(af!==undefined?af.toString():"all"),ad=ab.values(ac.tool.get_inputs_dict()).join(", ");return" - region=["+ae+"], parameters=["+ad+"]"},data_and_mode_compatible:function(ac,ad){if(ad==="Auto"){return true}else{if(ad==="Coverage"){return ac.dataset_type==="bigwig"}else{if(ac.dataset_type==="bigwig"||ac.extra_info==="no_detail"){return false}else{return true}}}},can_subset:function(ac){if(ac.message||ac.extra_info==="no_detail"){return false}else{if(ac.dataset_type==="bigwig"){return(ac.data[1][0]-ac.data[0][0]===1)}}return true},init_for_tool_data:function(){this.data_manager.set("data_type","raw_data");this.data_query_wait=1000;this.dataset_check_type="state"}});var W=function(ad,ac){f.call(this,ad,ac,{resize:false,header:false});this.container_div.addClass("label-track")};o(W.prototype,f.prototype,{init:function(){this.enabled=true},predraw_init:function(){},_draw:function(ag){var ae=this.view,af=ae.high-ae.low,aj=Math.floor(Math.pow(10,Math.floor(Math.log(af)/Math.log(10)))),ac=Math.floor(ae.low/aj)*aj,ah=this.view.container.width(),ad=$("<div/>").addClass("label-container");while(ac<ae.high){var ai=Math.floor((ac-ae.low)/af*ah);ad.append($("<div/>").addClass("label").text(commatize(ac)).css({left:ai}));ac+=aj}this.content_div.children(":first").remove();this.content_div.append(ad)}});var e=function(ad,ac,ag){L.call(this,ad,ac,ag);this.drawables=[];if("drawables" in ag){var af;for(var ae=0;ae<ag.drawables.length;ae++){af=ag.drawables[ae];this.drawables[ae]=n(af,ad,null);if(af.left_offset>this.left_offset){this.left_offset=af.left_offset}}this.enabled=true}ab.each(this.drawables,function(ah){if(ah instanceof c||ah instanceof S){ah.change_mode("Coverage")}});this.update_icons();this.obj_type="CompositeTrack"};o(e.prototype,L.prototype,{display_modes:A,config_params:ab.union(p.prototype.config_params,[{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:30,hidden:true}]),action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(ac){$(".tooltip").remove();ac.show_group()}}].concat(L.prototype.action_icons_def),to_dict:y.prototype.to_dict,add_drawable:y.prototype.add_drawable,unpack_drawables:y.prototype.unpack_drawables,config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},on_resize:function(){var ac=this.visible_height_px;ab.each(this.drawables,function(ad){ad.visible_height_px=ac});f.prototype.on_resize.call(this)},change_mode:function(ac){L.prototype.change_mode.call(this,ac);for(var ad=0;ad<this.drawables.length;ad++){this.drawables[ad].change_mode(ac)}},init:function(){var ae=[];for(var ad=0;ad<this.drawables.length;ad++){ae.push(this.drawables[ad].init())}var ac=this;$.when.apply($,ae).then(function(){ac.enabled=true;ac.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide();this.action_icons.param_space_viz_icon.hide()},can_draw:p.prototype.can_draw,_get_drawables:function(){return this.drawables},show_group:function(){var af=new N(this.view,this.container,{name:this.config.get_value("name")}),ac;for(var ae=0;ae<this.drawables.length;ae++){ac=this.drawables[ae];ac.update_icons();af.add_drawable(ac);ac.container=af;af.content_div.append(ac.container_div)}var ad=this.container.replace_drawable(this,af,true);af.request_draw({clear_tile_cache:true})},before_draw:function(){var ad=ab.min(ab.map(this.drawables,function(ae){return ae.config.get_value("min_value")})),ac=ab.max(ab.map(this.drawables,function(ae){return ae.config.get_value("max_value")}));this.config.set_value("min_value",ad);this.config.set_value("max_value",ac);ab.each(this.drawables,function(ae){ae.config.set_value("min_value",ad);ae.config.set_value("max_value",ac)})},update_all_min_max:function(){var ad=this,ac=this.config.get_value("min_value"),ae=this.config.get_value("max_value");ab.each(this.drawables,function(af){af.config.set_value("min_value",ac);af.config.set_value("max_value",ae)});this.request_draw({clear_tile_cache:true})},postdraw_actions:function(ai,ac,al,ah){var ag=-1,ae;for(ae=0;ae<ai.length;ae++){var aj=ai[ae].html_elt.find("canvas").height();if(aj>ag){ag=aj}}for(ae=0;ae<ai.length;ae++){var af=ai[ae];if(af.html_elt.find("canvas").height()!==ag){this.draw_helper(af.region,al,{force:true,height:ag});af.html_elt.remove()}}var ad=this,ak=function(){ad.update_all_min_max()};this._add_yaxis_label("min",ak);this._add_yaxis_label("max",ak)}});var B=function(ac){L.call(this,ac,{content_div:ac.top_labeltrack},{resize:false,header:false});this.left_offset=ac.canvas_manager.char_width_px;this.container_div.addClass("reference-track");this.data_url=galaxy_config.root+"api/genomes/"+this.view.dbkey;this.data_url_extra_params={reference:true};this.data_manager=new w.GenomeReferenceDataManager({data_url:this.data_url,can_subset:this.can_subset});this.hide_contents()};o(B.prototype,p.prototype,L.prototype,{config_params:ab.union(p.prototype.config_params,[{key:"height",type:"int",default_value:13,hidden:true}]),init:function(){this.data_manager.clear();this.enabled=true},predraw_init:function(){},can_draw:p.prototype.can_draw,draw_helper:function(af,ah,ad){var ac=this.tiles_div.is(":visible"),ag,ae=null;if(ah>this.view.canvas_manager.char_width_px){this.tiles_div.show();ag=true;ae=L.prototype.draw_helper.call(this,af,ah,ad)}else{ag=false;this.tiles_div.hide()}if(ac!==ag){this.view.resize_viewport()}return ae},can_subset:function(ac){return true},draw_tile:function(ae,ak,af,ah,al){var ad=this.data_manager.subset_entry(ae,ah),aj=ad.data;var ac=ak.canvas;ak.font=ak.canvas.manager.default_font;ak.textAlign="center";for(var ag=0,ai=aj.length;ag<ai;ag++){ak.fillStyle=this.view.get_base_color(aj[ag]);ak.fillText(aj[ag],Math.floor(ag*al),10)}return new b(this,ah,al,ac,ad)}});var g=function(ad,ac,ae){this.mode="Histogram";L.call(this,ad,ac,ae)};o(g.prototype,p.prototype,L.prototype,{display_modes:A,config_params:ab.union(p.prototype.config_params,[{key:"color",label:"Color",type:"color"},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:30,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},before_draw:function(){},draw_tile:function(ac,ad,af,ae,ag){return this._draw_line_track_tile(ac,ad,af,ae,ag)},can_subset:function(ac){return(ac.data[1][0]-ac.data[0][0]===1)},postdraw_actions:function(ad,ae,af,ac){this._add_yaxis_label("max");this._add_yaxis_label("min")}});var r=function(ad,ac,ae){this.mode="Heatmap";L.call(this,ad,ac,ae)};o(r.prototype,p.prototype,L.prototype,{display_modes:["Heatmap"],config_params:ab.union(p.prototype.config_params,[{key:"pos_color",label:"Positive Color",type:"color",default_value:"#FF8C00"},{key:"neg_color",label:"Negative Color",type:"color",default_value:"#4169E1"},{key:"min_value",label:"Min Value",type:"float",default_value:-1},{key:"max_value",label:"Max Value",type:"float",default_value:1},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:500,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},draw_tile:function(ac,ae,ah,ag,ai){var af=ae.canvas,ad=new J.DiagonalHeatmapPainter(ac.data,ag.get("start"),ag.get("end"),this.config.to_key_value_dict(),ah);ad.draw(ae,af.width,af.height,ai);return new b(this,ag,ai,af,ac.data)}});var c=function(ad,ac,ae){L.call(this,ad,ac,ae);this.container_div.addClass("feature-track");this.summary_draw_height=30;this.slotters={};this.start_end_dct={};this.left_offset=200;this.set_painter_from_config()};o(c.prototype,p.prototype,L.prototype,{display_modes:["Auto","Coverage","Dense","Squish","Pack"],config_params:ab.union(p.prototype.config_params,[{key:"block_color",label:"Block color",type:"color"},{key:"reverse_strand_color",label:"Antisense strand color",type:"color"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{key:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"connector_style",label:"Connector style",type:"select",default_value:"fishbones",options:[{label:"Line with arrows",value:"fishbone"},{label:"Arcs",value:"arcs"}]},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:0,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.set_painter_from_config();this.request_draw({clear_tile_cache:true})},set_painter_from_config:function(){if(this.config.get_value("connector_style")==="arcs"){this.painter=J.ArcLinkedFeaturePainter}else{this.painter=J.LinkedFeaturePainter}},postdraw_actions:function(ao,af,aq,an){L.prototype.postdraw_actions.call(this,ao,af,aq,an);var ah=this,ai,am=ab.filter(ao,function(ar){return(ar instanceof K)});if(am.length===0){var ac={};ab.each(ab.pluck(ao,"incomplete_features"),function(ar){ab.each(ar,function(at){ac[at[0]]=at})});var ap=this;ab.each(ao,function(av){var aw=ab.omit(ac,ab.map(av.incomplete_features,function(ay){return ay[0]}));aw=ab.omit(aw,ab.keys(av.other_tiles_features_drawn));if(ab.size(aw)!==0){var at={data:ab.values(aw)},au=ap.view.canvas_manager.new_canvas(),ar=au.getContext("2d");au.height=Math.max(av.canvas.height,ap.get_canvas_height(at,av.mode,av.w_scale,100));au.width=av.canvas.width;ar.drawImage(av.canvas,0,0);ar.translate(ah.left_offset,0);var ax=ap.draw_tile(at,ar,av.mode,av.region,av.w_scale,av.seq_data);$(av.canvas).replaceWith($(ax.canvas));av.canvas=au;ab.extend(av.other_tiles_features_drawn,ac)}})}if(ah.filters_manager){var ag=ah.filters_manager.filters,ak;for(ak=0;ak<ag.length;ak++){ag[ak].update_ui_elt()}var aj=false,al,ae;for(ai=0;ai<ao.length;ai++){if(ao[ai].data.length){al=ao[ai].data[0];for(ak=0;ak<ag.length;ak++){ae=ag[ak];if(ae.applies_to(al)&&ae.min!==ae.max){aj=true;break}}}}if(ah.filters_available!==aj){ah.filters_available=aj;if(!ah.filters_available){ah.filters_manager.hide()}ah.update_icons()}}if(ao[0] instanceof M){var ad=true;for(ai=0;ai<ao.length;ai++){if(!ao[ai].all_slotted){ad=false;break}}this.action_icons.show_more_rows_icon.toggle(!ad)}else{this.action_icons.show_more_rows_icon.hide()}},update_auto_mode:function(ac){if(this.mode==="Auto"){if(ac==="no_detail"){ac="feature spans"}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+ac+")")}},incremental_slots:function(ag,ac,af){var ad=this.view.canvas_manager.dummy_context,ae=this.slotters[ag];if(!ae||(ae.mode!==af)){ae=new (s.FeatureSlotter)(ag,af,z,function(ah){return ad.measureText(ah)});this.slotters[ag]=ae}return ae.slot_features(ac)},get_mode:function(ac){if(ac.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>G){mode="Squish"}else{mode="Pack"}}return mode},get_canvas_height:function(ac,ag,ah,ad){if(ag==="Coverage"||ac.dataset_type==="bigwig"){return this.summary_draw_height}else{var af=this.incremental_slots(ah,ac.data,ag);var ae=new (this.painter)(null,null,null,this.config.to_key_value_dict(),ag);return Math.max(this.min_height_px,ae.get_required_height(af,ad))}},draw_tile:function(an,at,aq,ag,ak,af,ao){var ar=this,ae=at.canvas,az=ag.get("start"),ad=ag.get("end"),ah=this.left_offset;if(an.dataset_type==="bigwig"){return this._draw_line_track_tile(an,at,aq,ag,ak)}var aj=[],ap=this.slotters[ak].slots;all_slotted=true;if(an.data){var al=this.filters_manager.filters;for(var au=0,aw=an.data.length;au<aw;au++){var ai=an.data[au];var av=false;var am;for(var ay=0,aD=al.length;ay<aD;ay++){am=al[ay];am.update_attrs(ai);if(!am.keep(ai)){av=true;break}}if(!av){aj.push(ai);if(!(ai[0] in ap)){all_slotted=false}}}}var aC=(this.filters_manager.alpha_filter?new C(this.filters_manager.alpha_filter):null),aA=(this.filters_manager.height_filter?new C(this.filters_manager.height_filter):null),aB=new (this.painter)(aj,az,ad,this.config.to_key_value_dict(),aq,aC,aA,af,function(aE){return ar.view.get_base_color(aE)});var ax=null;at.fillStyle=this.config.get_value("block_color");at.font=at.canvas.manager.default_font;at.textAlign="right";if(an.data){var ac=aB.draw(at,ae.width,ae.height,ak,ap);ax=ac.feature_mapper;incomplete_features=ac.incomplete_features;ax.translation=-ah}if(!ao){return new M(ar,ag,ak,ae,an.data,aq,an.message,all_slotted,ax,incomplete_features,af)}}});var Z=function(ad,ac,ae){L.call(this,ad,ac,ae);this.painter=J.VariantPainter;this.summary_draw_height=30;this.left_offset=30};o(Z.prototype,p.prototype,L.prototype,{display_modes:["Auto","Coverage","Dense","Squish","Pack"],config_params:ab.union(p.prototype.config_params,[{key:"color",label:"Histogram color",type:"color"},{key:"show_sample_data",label:"Show sample data",type:"bool",default_value:true},{key:"show_labels",label:"Show summary and sample labels",type:"bool",default_value:true},{key:"summary_height",label:"Locus summary height",type:"float",default_value:20},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:0,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})},draw_tile:function(ac,af,ah,ag,ai){if(ac.dataset_type==="bigwig"){return this._draw_line_track_tile(ac,af,"Histogram",ag,ai)}else{var ae=this.view,ad=new (this.painter)(ac.data,ag.get("start"),ag.get("end"),this.config.to_key_value_dict(),ah,function(aj){return ae.get_base_color(aj)});ad.draw(af,af.canvas.width,af.canvas.height,ai);return new b(this,ag,ai,af.canvas,ac.data)}},get_canvas_height:function(ac,ag,ah,ae){if(ac.dataset_type==="bigwig"){return this.summary_draw_height}else{var ad=(this.dataset.get_metadata("sample_names")?this.dataset.get_metadata("sample_names").length:0);if(ad===0&&ac.data.length!==0){ad=ac.data[0][7].match(/,/g);if(ad===null){ad=1}else{ad=ad.length+1}}var af=new (this.painter)(null,null,null,this.config.to_key_value_dict(),ag);return af.get_required_height(ad)}},predraw_init:function(){var ac=[f.prototype.predraw_init.call(this)];if(!this.dataset.get_metadata("sample_names")){ac.push(this.dataset.fetch())}return ac},postdraw_actions:function(ag,ah,aj,ad){L.prototype.postdraw_actions.call(this,ag,ah,aj,ad);var af=ab.filter(ag,function(ak){return(ak instanceof K)});var ae=this.dataset.get_metadata("sample_names");if(af.length===0&&this.config.get_value("show_labels")&&ae&&ae.length>1){var ac;if(this.container_div.find(".yaxislabel.variant").length===0){ac=this.config.get_value("summary_height")/2;this.tiles_div.prepend($("<div/>").text("Summary").addClass("yaxislabel variant top").css({"font-size":ac+"px",top:(this.config.get_value("summary_height")-ac)/2+"px"}));if(this.config.get_value("show_sample_data")){var ai=ae.join("<br/>");this.tiles_div.prepend($("<div/>").html(ai).addClass("yaxislabel variant top sample").css({top:this.config.get_value("summary_height")}))}}ac=(this.mode==="Squish"?5:10)+"px";$(this.tiles_div).find(".sample").css({"font-size":ac,"line-height":ac});$(this.tiles_div).find(".yaxislabel").css("color",this.config.get_value("label_color"))}else{this.container_div.find(".yaxislabel.variant").remove()}}});var S=function(ad,ac,ae){c.call(this,ad,ac,ae);this.painter=J.ReadPainter;this.update_icons()};o(S.prototype,p.prototype,L.prototype,c.prototype,{config_params:ab.union(p.prototype.config_params,[{key:"block_color",label:"Histogram color",type:"color"},{key:"detail_block_color",label:"Sense strand block color",type:"color",default_value:"#AAAAAA"},{key:"reverse_strand_color",label:"Antisense strand block color",type:"color",default_value:"#DDDDDD"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"height",type:"int",default_value:0,hidden:true}]),config_onchange:function(){this.set_name(this.config.get_value("name"));this.request_draw({clear_tile_cache:true})}});var d={CompositeTrack:e,DrawableGroup:N,DiagonalHeatmapTrack:r,FeatureTrack:c,LineTrack:g,ReadTrack:S,VariantTrack:Z,VcfTrack:Z};var n=function(ae,ad,ac){if("copy" in ae){return ae.copy(ac)}else{var af=ae.obj_type;if(!af){af=ae.track_type}return new d[af](ad,ac,ae)}};return{TracksterView:Y,DrawableGroup:N,LineTrack:g,FeatureTrack:c,DiagonalHeatmapTrack:r,ReadTrack:S,VariantTrack:Z,CompositeTrack:e,object_from_template:n}});
\ No newline at end of file
diff -r 991cd029642f477f3596ca6035d0830fd2c117ed -r 31a059dcc3814365a8dd3b5a56fc0d38de4f6d59 static/scripts/viz/trackster/tracks.js
--- a/static/scripts/viz/trackster/tracks.js
+++ b/static/scripts/viz/trackster/tracks.js
@@ -1152,9 +1152,9 @@
// Update location. Only update when there is a valid chrom; when loading vis, there may
// not be a valid chrom.
- var chrom = view.chrom_select.val();
+ var chrom = this.chrom_select.val();
if (chrom !== "") {
- this.trigger_navigate(chrom, view.low, view.high, true);
+ this.trigger_navigate(chrom, this.low, this.high, true);
}
},
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.
1
0
commit/galaxy-central: carlfeberhard: History multi-view, Histories: allow searching/filtering of histories by low-level adv. search (name, tags, annotation), remove delay on column render
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/991cd029642f/
Changeset: 991cd029642f
User: carlfeberhard
Date: 2014-09-29 16:16:00+00:00
Summary: History multi-view, Histories: allow searching/filtering of histories by low-level adv. search (name, tags, annotation), remove delay on column render
Affected #: 9 files
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed client/galaxy/scripts/mvc/history/history-model.js
--- a/client/galaxy/scripts/mvc/history/history-model.js
+++ b/client/galaxy/scripts/mvc/history/history-model.js
@@ -14,7 +14,7 @@
* @constructs
*/
var History = Backbone.Model.extend( BASE_MVC.LoggableMixin ).extend(
-/** @lends History.prototype */{
+ BASE_MVC.mixin( BASE_MVC.SearchableModelMixin, /** @lends History.prototype */{
/** logger used to record this.log messages, commonly set to console */
//logger : console,
@@ -117,6 +117,18 @@
return _.reduce( _.values( this.get( 'state_details' ) ), function( memo, num ){ return memo + num; }, 0 );
},
+ // ........................................................................ search
+ /** What model fields to search with */
+ searchAttributes : [
+ 'name', 'annotation', 'tags'
+ ],
+
+ /** Adding title and singular tag */
+ searchAliases : {
+ title : 'name',
+ tag : 'tags'
+ },
+
// ........................................................................ updates
/** does the contents collection indicate they're still running and need to be updated later?
* delay + update if needed
@@ -252,7 +264,7 @@
toString : function(){
return 'History(' + this.get( 'id' ) + ',' + this.get( 'name' ) + ')';
}
-});
+}));
//------------------------------------------------------------------------------ CLASS VARS
/** When the history has running hdas,
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed client/galaxy/scripts/mvc/history/multi-panel.js
--- a/client/galaxy/scripts/mvc/history/multi-panel.js
+++ b/client/galaxy/scripts/mvc/history/multi-panel.js
@@ -69,13 +69,14 @@
/* ==============================================================================
TODO:
+ rendering/delayed rendering is a mess
+ may not need to render columns in renderColumns (just moving them/attaching them may be enough)
copy places old current in wrong location
sort by size is confusing (but correct) - nice_size shows actual disk usage, !== size
handle delete current
currently manual by user - delete then create new - make one step
render
move all columns over as one (agg. then html())
- loading indicator on startup
performance
rendering columns could be better
lazy load history list (for large numbers)
@@ -808,7 +809,11 @@
/** Render a single column using the non-blocking setTimeout( 0 ) pattern */
renderColumn : function( column, speed ){
speed = speed !== undefined? speed: this.fxSpeed;
- return _.delay( function(){ return column.render( speed ); }, 0 );
+ return column.render( speed );
+ //TODO: causes weirdness
+ //return _.delay( function(){
+ // return column.render( speed );
+ //}, 0 );
},
//TODO: combine the following two more sensibly
@@ -922,12 +927,13 @@
onsearch : function( searchFor ){
multipanel.searchFor = searchFor;
multipanel.filters = [ function(){
- return this.model.get( 'name' ).indexOf( multipanel.searchFor ) !== -1;
+ return this.model.matchesAll( multipanel.searchFor );
}];
multipanel.renderColumns( 0 );
},
onclear : function( searchFor ){
multipanel.searchFor = null;
+//TODO: remove specifically not just reset
multipanel.filters = [];
multipanel.renderColumns( 0 );
}
@@ -949,7 +955,7 @@
});
multipanel.hdaQueue.progress( function( progress ){
multipanel.renderInfo([
- _l( 'loading' ), ( progress.curr + 1 ), _l( 'of' ), progress.total
+ _l( 'searching' ), ( progress.curr + 1 ), _l( 'of' ), progress.total
].join( ' ' ));
});
multipanel.hdaQueue.deferred.done( function(){
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed client/galaxy/scripts/mvc/ui.js
--- a/client/galaxy/scripts/mvc/ui.js
+++ b/client/galaxy/scripts/mvc/ui.js
@@ -692,7 +692,6 @@
}
})
.on( 'change', function( event ){
- console.info( 'changed', $( this ), event );
search.call( this, event, $( this ).val() );
})
.val( options.initialVal );
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed static/scripts/mvc/history/history-model.js
--- a/static/scripts/mvc/history/history-model.js
+++ b/static/scripts/mvc/history/history-model.js
@@ -14,7 +14,7 @@
* @constructs
*/
var History = Backbone.Model.extend( BASE_MVC.LoggableMixin ).extend(
-/** @lends History.prototype */{
+ BASE_MVC.mixin( BASE_MVC.SearchableModelMixin, /** @lends History.prototype */{
/** logger used to record this.log messages, commonly set to console */
//logger : console,
@@ -117,6 +117,18 @@
return _.reduce( _.values( this.get( 'state_details' ) ), function( memo, num ){ return memo + num; }, 0 );
},
+ // ........................................................................ search
+ /** What model fields to search with */
+ searchAttributes : [
+ 'name', 'annotation', 'tags'
+ ],
+
+ /** Adding title and singular tag */
+ searchAliases : {
+ title : 'name',
+ tag : 'tags'
+ },
+
// ........................................................................ updates
/** does the contents collection indicate they're still running and need to be updated later?
* delay + update if needed
@@ -252,7 +264,7 @@
toString : function(){
return 'History(' + this.get( 'id' ) + ',' + this.get( 'name' ) + ')';
}
-});
+}));
//------------------------------------------------------------------------------ CLASS VARS
/** When the history has running hdas,
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed static/scripts/mvc/history/multi-panel.js
--- a/static/scripts/mvc/history/multi-panel.js
+++ b/static/scripts/mvc/history/multi-panel.js
@@ -69,13 +69,14 @@
/* ==============================================================================
TODO:
+ rendering/delayed rendering is a mess
+ may not need to render columns in renderColumns (just moving them/attaching them may be enough)
copy places old current in wrong location
sort by size is confusing (but correct) - nice_size shows actual disk usage, !== size
handle delete current
currently manual by user - delete then create new - make one step
render
move all columns over as one (agg. then html())
- loading indicator on startup
performance
rendering columns could be better
lazy load history list (for large numbers)
@@ -808,7 +809,11 @@
/** Render a single column using the non-blocking setTimeout( 0 ) pattern */
renderColumn : function( column, speed ){
speed = speed !== undefined? speed: this.fxSpeed;
- return _.delay( function(){ return column.render( speed ); }, 0 );
+ return column.render( speed );
+ //TODO: causes weirdness
+ //return _.delay( function(){
+ // return column.render( speed );
+ //}, 0 );
},
//TODO: combine the following two more sensibly
@@ -922,12 +927,13 @@
onsearch : function( searchFor ){
multipanel.searchFor = searchFor;
multipanel.filters = [ function(){
- return this.model.get( 'name' ).indexOf( multipanel.searchFor ) !== -1;
+ return this.model.matchesAll( multipanel.searchFor );
}];
multipanel.renderColumns( 0 );
},
onclear : function( searchFor ){
multipanel.searchFor = null;
+//TODO: remove specifically not just reset
multipanel.filters = [];
multipanel.renderColumns( 0 );
}
@@ -949,7 +955,7 @@
});
multipanel.hdaQueue.progress( function( progress ){
multipanel.renderInfo([
- _l( 'loading' ), ( progress.curr + 1 ), _l( 'of' ), progress.total
+ _l( 'searching' ), ( progress.curr + 1 ), _l( 'of' ), progress.total
].join( ' ' ));
});
multipanel.hdaQueue.deferred.done( function(){
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed static/scripts/mvc/ui.js
--- a/static/scripts/mvc/ui.js
+++ b/static/scripts/mvc/ui.js
@@ -692,7 +692,6 @@
}
})
.on( 'change', function( event ){
- console.info( 'changed', $( this ), event );
search.call( this, event, $( this ).val() );
})
.val( options.initialVal );
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed static/scripts/packed/mvc/history/history-model.js
--- a/static/scripts/packed/mvc/history/history-model.js
+++ b/static/scripts/packed/mvc/history/history-model.js
@@ -1,1 +1,1 @@
-define(["mvc/history/history-contents","mvc/base-mvc","utils/localization"],function(h,i,d){var e=Backbone.Model.extend(i.LoggableMixin).extend({defaults:{model_class:"History",id:null,name:"Unnamed History",state:"new",diskSize:0,deleted:false},urlRoot:galaxy_config.root+"api/histories",initialize:function(k,l,j){j=j||{};this.logger=j.logger||null;this.log(this+".initialize:",k,l,j);this.log("creating history contents:",l);this.contents=new h.HistoryContents(l||[],{historyId:this.get("id")});this._setUpListeners();this.updateTimeoutId=null},_setUpListeners:function(){this.on("error",function(k,n,j,m,l){this.errorHandler(k,n,j,m,l)});if(this.contents){this.listenTo(this.contents,"error",function(){this.trigger.apply(this,["error:contents"].concat(jQuery.makeArray(arguments)))})}this.on("change:id",function(k,j){if(this.contents){this.contents.historyId=j}},this)},errorHandler:function(k,n,j,m,l){this.clearUpdateTimeout()},ownedByCurrUser:function(){if(!Galaxy||!Galaxy.currUser){return false}if(Galaxy.currUser.isAnonymous()||Galaxy.currUser.id!==this.get("user_id")){return false}return true},contentsCount:function(){return _.reduce(_.values(this.get("state_details")),function(j,k){return j+k},0)},checkForUpdates:function(j){if(this.contents.running().length){this.setUpdateTimeout()}else{this.trigger("ready");if(_.isFunction(j)){j.call(this)}}return this},setUpdateTimeout:function(j){j=j||e.UPDATE_DELAY;var k=this;this.clearUpdateTimeout();this.updateTimeoutId=setTimeout(function(){k.refresh()},j);return this.updateTimeoutId},clearUpdateTimeout:function(){if(this.updateTimeoutId){clearTimeout(this.updateTimeoutId);this.updateTimeoutId=null}},refresh:function(k,j){k=k||[];j=j||{};var l=this;j.data=j.data||{};if(k.length){j.data.details=k.join(",")}var m=this.contents.fetch(j);m.done(function(n){l.checkForUpdates(function(){this.fetch()})});return m},_delete:function(j){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},j)},undelete:function(j){if(!this.get("deleted")){return jQuery.when()}return this.save({deleted:false},j)},copy:function(m,k){m=(m!==undefined)?(m):(true);if(!this.id){throw new Error("You must set the history ID before copying it.")}var j={history_id:this.id};if(m){j.current=true}if(k){j.name=k}var l=this,n=jQuery.post(this.urlRoot,j);if(m){return n.then(function(o){var p=new e(o);return p.setAsCurrent().done(function(){l.trigger("copied",l,o)})})}return n.done(function(o){l.trigger("copied",l,o)})},setAsCurrent:function(){var j=this,k=jQuery.getJSON("/history/set_as_current?id="+this.id);k.done(function(){j.trigger("set-as-current",j)});return k},toString:function(){return"History("+this.get("id")+","+this.get("name")+")"}});e.UPDATE_DELAY=4000;e.getHistoryData=function c(j,v){v=v||{};var r=v.detailIdsFn||[];var m=v.hdcaDetailIds||[];var s=jQuery.Deferred(),p=null;function k(w){if(j==="current"){return jQuery.getJSON(galaxy_config.root+"history/current_history_json")}return jQuery.ajax(galaxy_config.root+"api/histories/"+j)}function o(w){return w&&w.empty}function q(x){if(o(x)){return[]}if(_.isFunction(r)){r=r(x)}if(_.isFunction(m)){m=m(x)}var w={};if(r.length){w.dataset_details=r.join(",")}if(m.length){w.dataset_collection_details=m.join(",")}return jQuery.ajax(galaxy_config.root+"api/histories/"+x.id+"/contents",{data:w})}var t=v.historyFn||k,u=v.contentsFn||q;var n=t(j);n.done(function(w){p=w;s.notify({status:"history data retrieved",historyJSON:p})});n.fail(function(y,w,x){s.reject(y,"loading the history")});var l=n.then(u);l.then(function(w){s.notify({status:"contents data retrieved",historyJSON:p,contentsJSON:w});s.resolve(p,w)});l.fail(function(y,w,x){s.reject(y,"loading the contents",{history:p})});return s};var f=Backbone.Collection.extend(i.LoggableMixin).extend({model:e,urlRoot:(window.galaxy_config?galaxy_config.root:"/")+"api/histories",initialize:function(k,j){j=j||{};this.log("HistoryCollection.initialize",arguments);this.includeDeleted=j.includeDeleted||false;this.setUpListeners()},setUpListeners:function a(){var j=this;this.on("change:deleted",function(k){this.debug("change:deleted",j.includeDeleted,k.get("deleted"));if(!j.includeDeleted&&k.get("deleted")){j.remove(k)}});this.on("copied",function(k,l){this.unshift(new e(l,[]))})},create:function g(m,k,j,l){var o=this,n=jQuery.getJSON(galaxy_config.root+"history/create_new_current");return n.done(function(p){var q=new e(p,[],j||{});o.unshift(q);o.trigger("new-current")})},toString:function b(){return"HistoryCollection("+this.length+")"}});return{History:e,HistoryCollection:f}});
\ No newline at end of file
+define(["mvc/history/history-contents","mvc/base-mvc","utils/localization"],function(h,i,d){var e=Backbone.Model.extend(i.LoggableMixin).extend(i.mixin(i.SearchableModelMixin,{defaults:{model_class:"History",id:null,name:"Unnamed History",state:"new",diskSize:0,deleted:false},urlRoot:galaxy_config.root+"api/histories",initialize:function(k,l,j){j=j||{};this.logger=j.logger||null;this.log(this+".initialize:",k,l,j);this.log("creating history contents:",l);this.contents=new h.HistoryContents(l||[],{historyId:this.get("id")});this._setUpListeners();this.updateTimeoutId=null},_setUpListeners:function(){this.on("error",function(k,n,j,m,l){this.errorHandler(k,n,j,m,l)});if(this.contents){this.listenTo(this.contents,"error",function(){this.trigger.apply(this,["error:contents"].concat(jQuery.makeArray(arguments)))})}this.on("change:id",function(k,j){if(this.contents){this.contents.historyId=j}},this)},errorHandler:function(k,n,j,m,l){this.clearUpdateTimeout()},ownedByCurrUser:function(){if(!Galaxy||!Galaxy.currUser){return false}if(Galaxy.currUser.isAnonymous()||Galaxy.currUser.id!==this.get("user_id")){return false}return true},contentsCount:function(){return _.reduce(_.values(this.get("state_details")),function(j,k){return j+k},0)},searchAttributes:["name","annotation","tags"],searchAliases:{title:"name",tag:"tags"},checkForUpdates:function(j){if(this.contents.running().length){this.setUpdateTimeout()}else{this.trigger("ready");if(_.isFunction(j)){j.call(this)}}return this},setUpdateTimeout:function(j){j=j||e.UPDATE_DELAY;var k=this;this.clearUpdateTimeout();this.updateTimeoutId=setTimeout(function(){k.refresh()},j);return this.updateTimeoutId},clearUpdateTimeout:function(){if(this.updateTimeoutId){clearTimeout(this.updateTimeoutId);this.updateTimeoutId=null}},refresh:function(k,j){k=k||[];j=j||{};var l=this;j.data=j.data||{};if(k.length){j.data.details=k.join(",")}var m=this.contents.fetch(j);m.done(function(n){l.checkForUpdates(function(){this.fetch()})});return m},_delete:function(j){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},j)},undelete:function(j){if(!this.get("deleted")){return jQuery.when()}return this.save({deleted:false},j)},copy:function(m,k){m=(m!==undefined)?(m):(true);if(!this.id){throw new Error("You must set the history ID before copying it.")}var j={history_id:this.id};if(m){j.current=true}if(k){j.name=k}var l=this,n=jQuery.post(this.urlRoot,j);if(m){return n.then(function(o){var p=new e(o);return p.setAsCurrent().done(function(){l.trigger("copied",l,o)})})}return n.done(function(o){l.trigger("copied",l,o)})},setAsCurrent:function(){var j=this,k=jQuery.getJSON("/history/set_as_current?id="+this.id);k.done(function(){j.trigger("set-as-current",j)});return k},toString:function(){return"History("+this.get("id")+","+this.get("name")+")"}}));e.UPDATE_DELAY=4000;e.getHistoryData=function c(j,v){v=v||{};var r=v.detailIdsFn||[];var m=v.hdcaDetailIds||[];var s=jQuery.Deferred(),p=null;function k(w){if(j==="current"){return jQuery.getJSON(galaxy_config.root+"history/current_history_json")}return jQuery.ajax(galaxy_config.root+"api/histories/"+j)}function o(w){return w&&w.empty}function q(x){if(o(x)){return[]}if(_.isFunction(r)){r=r(x)}if(_.isFunction(m)){m=m(x)}var w={};if(r.length){w.dataset_details=r.join(",")}if(m.length){w.dataset_collection_details=m.join(",")}return jQuery.ajax(galaxy_config.root+"api/histories/"+x.id+"/contents",{data:w})}var t=v.historyFn||k,u=v.contentsFn||q;var n=t(j);n.done(function(w){p=w;s.notify({status:"history data retrieved",historyJSON:p})});n.fail(function(y,w,x){s.reject(y,"loading the history")});var l=n.then(u);l.then(function(w){s.notify({status:"contents data retrieved",historyJSON:p,contentsJSON:w});s.resolve(p,w)});l.fail(function(y,w,x){s.reject(y,"loading the contents",{history:p})});return s};var f=Backbone.Collection.extend(i.LoggableMixin).extend({model:e,urlRoot:(window.galaxy_config?galaxy_config.root:"/")+"api/histories",initialize:function(k,j){j=j||{};this.log("HistoryCollection.initialize",arguments);this.includeDeleted=j.includeDeleted||false;this.setUpListeners()},setUpListeners:function a(){var j=this;this.on("change:deleted",function(k){this.debug("change:deleted",j.includeDeleted,k.get("deleted"));if(!j.includeDeleted&&k.get("deleted")){j.remove(k)}});this.on("copied",function(k,l){this.unshift(new e(l,[]))})},create:function g(m,k,j,l){var o=this,n=jQuery.getJSON(galaxy_config.root+"history/create_new_current");return n.done(function(p){var q=new e(p,[],j||{});o.unshift(q);o.trigger("new-current")})},toString:function b(){return"HistoryCollection("+this.length+")"}});return{History:e,HistoryCollection:f}});
\ No newline at end of file
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed static/scripts/packed/mvc/history/multi-panel.js
--- a/static/scripts/packed/mvc/history/multi-panel.js
+++ b/static/scripts/packed/mvc/history/multi-panel.js
@@ -1,1 +1,1 @@
-define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue"],function(d,l,z,a){window.HISTORY_MODEL=d;function g(H,E){E=E||{};if(!(Galaxy&&Galaxy.modal)){return H.copy()}var F=H.get("name"),C="Copy of '"+F+"'";function D(J){if(!J){if(!Galaxy.modal.$("#invalid-title").size()){var I=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(I)}return false}return J}function G(I){var J=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(J);H.copy(true,I).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+F+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',C,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:function(){var I=Galaxy.modal.$("#copy-modal-title").val();if(!D(I)){return}G(I)}}},E));$("#copy-modal-title").focus().select()}var B=Backbone.View.extend(z.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function q(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(C){C=C||{};this.panel=C.panel||this.createPanel(C);this.setUpListeners()},createPanel:function u(D){D=_.extend({model:this.model,dragItems:true},D);var C=new l.HistoryPanelEdit(D);C._renderEmptyMessage=this.__patch_renderEmptyMessage;return C},__patch_renderEmptyMessage:function(E){var D=this,F=_.chain(this.model.get("state_ids")).values().flatten().value().length,C=D.$emptyMessage(E);if(!_.isEmpty(D.hdaViews)){C.hide()}else{if(F&&!this.model.contents.length){C.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(D.searchFor){C.text(D.noneFoundMsg).show()}else{C.text(D.emptyMsg).show()}}}return C},setUpListeners:function f(){var C=this;this.once("rendered",function(){C.trigger("rendered:initial",C)});this.setUpPanelListeners()},setUpPanelListeners:function k(){var C=this;this.listenTo(this.panel,{rendered:function(){C.trigger("rendered",C)}},this)},inView:function(C,D){var F=this.$el.offset().left,E=F+this.$el.width();if(E<C){return false}if(F>D){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function A(D){D=(D!==undefined)?(D):("fast");var C=this.model?this.model.toJSON():{};this.$el.html(this.template(C));this.renderPanel(D);this.setUpBehaviors();return this},setUpBehaviors:function v(){},template:function w(D){D=D||{};var C=['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate(),'<div class="pull-right">','<button class="delete-history btn btn-default">',D.deleted?_l("Undelete"):_l("Delete"),"</button>",'<button class="copy-history btn btn-default">',_l("Copy"),"</button>","</div>","</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',D.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join("");return $(C)},controlsLeftTemplate:function(){return(this.currentHistory)?['<div class="pull-left">','<button class="create-new btn btn-default">',_l("Create new"),"</button> ","</div>"].join(""):['<div class="pull-left">','<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","</div>"].join("")},renderPanel:function h(C){C=(C!==undefined)?(C):("fast");this.panel.setElement(this.$panel()).render(C);return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history.btn":function(){var C=this,D;if(this.model.get("deleted")){D=this.model.undelete()}else{D=this.model._delete()}D.fail(function(G,E,F){alert(_l("Could not delete the history")+":\n"+F)}).done(function(E){C.render()})},"click .copy-history.btn":"copy"},copy:function s(){g(this.model)},toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var m=Backbone.View.extend(z.LoggableMixin).extend({initialize:function c(C){C=C||{};this.log(this+".init",C);if(!C.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=C.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=C.order||"update";this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(C.histories||[]);this.columnMap={};this.createColumns(C.columnOptions);this.setUpListeners()},setUpListeners:function f(){},setCollection:function y(D){var C=this;C.stopListening(C.collection);C.collection=D;C.sortCollection(C.order,{silent:true});C.setUpCollectionListeners();C.trigger("new-collection",C);return C},setUpCollectionListeners:function(){var C=this,D=C.collection;C.listenTo(D,{add:C.addAsCurrentColumn,"set-as-current":C.setCurrentHistory,"change:deleted":C.handleDeletedHistory,sort:function(){C.renderColumns(0)}})},setCurrentHistory:function p(D){var C=this.columnMap[this.currentHistoryId];if(C){C.currentHistory=false;C.$el.height("")}this.currentHistoryId=D.id;var E=this.columnMap[this.currentHistoryId];E.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return E},handleDeletedHistory:function b(D){if(D.get("deleted")){this.log("handleDeletedHistory",this.collection.includeDeleted,D);var C=this;column=C.columnMap[D.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!C.collection.includeDeleted){C.removeColumn(column)}}}},sortCollection:function(C,D){C=C||this.order;var E=this.currentHistoryId;switch(C){case"name":this.collection.comparator=function(F){return[F.id!==E,F.get("name").toLowerCase()]};break;case"size":this.collection.comparator=function(F){return[F.id!==E,F.get("size")]};break;default:this.collection.comparator=function(F){return[F.id!==E,Date(F.get("update_time"))]}}this.collection.sort(D);return this.collection},setOrder:function(C){if(["update","name","size"].indexOf(C)===-1){C="update"}this.order=C;this.sortCollection();return this},create:function(C){return this.collection.create({current:true})},createColumns:function r(D){D=D||{};var C=this;this.columnMap={};C.collection.each(function(E,F){var G=C.createColumn(E,D);C.columnMap[E.id]=G})},createColumn:function t(E,C){C=_.extend({},C,{model:E});var D=new B(C);if(E.id===this.currentHistoryId){D.currentHistory=true}this.setUpColumnListeners(D);return D},sortedFilteredColumns:function(C){C=C||this.filters;if(!C||!C.length){return this.sortedColumns()}var D=this;return D.sortedColumns().filter(function(G,F){var E=G.currentHistory||_.every(C.map(function(H){return H.call(G)}));return E})},sortedColumns:function(){var D=this;var C=this.collection.map(function(F,E){return D.columnMap[F.id]});return C},addColumn:function o(E,C){C=C!==undefined?C:true;var D=this.createColumn(E);this.columnMap[E.id]=D;if(C){this.renderColumns()}return D},addAsCurrentColumn:function o(E){var D=this,C=this.addColumn(E,false);this.setCurrentHistory(E);C.once("rendered",function(){D.queueHdaFetch(C)});return C},removeColumn:function x(E,D){D=D!==undefined?D:true;this.log("removeColumn",E);if(!E){return}var F=this,C=this.options.columnWidth+this.options.columnGap;E.$el.fadeOut("fast",function(){if(D){$(this).remove();F.$(".middle").width(F.$(".middle").width()-C);F.checkColumnsInView();F._recalcFirstColumnHeight()}F.stopListening(E.panel);F.stopListening(E);delete F.columnMap[E.model.id];E.remove()})},setUpColumnListeners:function n(C){var D=this;D.listenTo(C,{"in-view":D.queueHdaFetch});D.listenTo(C.panel,{"view:draggable:dragstart":function(H,F,E,G){D._dropData=JSON.parse(H.dataTransfer.getData("text"));D.currentColumnDropTargetOn()},"view:draggable:dragend":function(H,F,E,G){D._dropData=null;D.currentColumnDropTargetOff()},"droptarget:drop":function(G,H,F){var I=D._dropData.filter(function(J){return(_.isObject(J)&&J.id&&J.model_class==="HistoryDatasetAssociation")});D._dropData=null;var E=new a.NamedAjaxQueue();I.forEach(function(J){E.add({name:"copy-"+J.id,fn:function(){return F.model.contents.copy(J.id)}})});E.start();E.done(function(J){F.model.fetch()})}})},columnMapLength:function(){return Object.keys(this.columnMap).length},render:function A(D){D=D!==undefined?D:this.fxSpeed;var C=this;C.log(C+".render");C.$el.html(C.template(C.options));C.renderColumns(D);C.setUpBehaviors();C.trigger("rendered",C);return C},template:function w(C){C=C||{};var D=[];if(this.options.headerHeight){D=D.concat(['<div class="loading-overlay flex-row"><div class="loading-overlay-message">loading...</div></div>','<div class="header flex-column-container">','<div class="header-control header-control-left flex-column">','<button class="done btn btn-default">',_l("Done"),"</button>",'<button class="include-deleted btn btn-default"></button>','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+'... <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="javascript:void(0);" class="order-update">',_l("Time of last update"),"</a></li>",'<li><a href="javascript:void(0);" class="order-name">',_l("Name"),"</a></li>",'<li><a href="javascript:void(0);" class="order-size">',_l("Size"),"</a></li>","</ul>","</div>",'<div id="search-histories" class="header-search"></div>',"</div>",'<div class="header-control header-control-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="header-control header-control-right flex-column">','<div id="search-datasets" class="header-search"></div>','<button id="toggle-deleted" class="btn btn-default">',_l("Include deleted datasets"),"</button>",'<button id="toggle-hidden" class="btn btn-default">',_l("Include hidden datasets"),"</button>","</div>","</div>"])}D=D.concat(['<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"]);return $(D.join(""))},renderColumns:function j(F){F=F!==undefined?F:this.fxSpeed;var E=this,C=E.sortedFilteredColumns();E.$(".middle").width(C.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var D=E.$(".middle");D.empty();C.forEach(function(H,G){H.$el.appendTo(D);H.delegateEvents();E.renderColumn(H,F)});if(this.searchFor&&C.length<=1){}else{E.checkColumnsInView();this._recalcFirstColumnHeight()}return C},renderColumn:function(C,D){D=D!==undefined?D:this.fxSpeed;return _.delay(function(){return C.render(D)},0)},queueHdaFetch:function i(E){if(E.model.contents.length===0&&!E.model.get("empty")){var C={},D=_.values(E.panel.storage.get("expandedIds")).join();if(D){C.dataset_details=D}this.hdaQueue.add({name:E.model.id,fn:function(){var F=E.model.contents.fetch({data:C,silent:true});return F.done(function(G){E.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(C){if((C.model.contents.length===0&&!C.model.get("empty"))||(!C.model.contents.haveDetails())){this.hdaQueue.add({name:C.model.id,fn:function(){var D=C.model.contents.fetch({data:{details:"all"},silent:true});return D.done(function(E){C.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},renderInfo:function(C){this.$(".header .header-info").text(C)},events:{"click .done.btn":function(){window.location="/"},"click .create-new.btn":"create","click .order .order-update":function(C){this.setOrder("update")},"click .order .order-name":function(C){this.setOrder("name")},"click .order .order-size":function(C){this.setOrder("size")}},includeDeletedHistories:function(){window.location+=(/\?/.test(window.location.toString()))?("&"):("?")+"include_deleted_histories=True"},excludeDeletedHistories:function(){window.location=window.location.toString().replace(/[&\?]include_deleted_histories=True/g,"")},setUpBehaviors:function(){var D=this;D.$(".include-deleted").modeButton({initialMode:this.collection.includeDeleted?"exclude":"include",switchModesOnClick:false,modes:[{mode:"include",html:_l("Include deleted histories"),onclick:_.bind(D.includeDeletedHistories,D)},{mode:"exclude",html:_l("Exclude deleted histories"),onclick:_.bind(D.excludeDeletedHistories,D)}]});D.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(E){D.searchFor=E;D.filters=[function(){return this.model.get("name").indexOf(D.searchFor)!==-1}];D.renderColumns(0)},onclear:function(E){D.searchFor=null;D.filters=[];D.renderColumns(0)}});D.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(E){D.hdaQueue.clear();D.$("#search-datasets").searchInput("toggle-loading");D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E);D.queueHdaFetchDetails(F)});D.hdaQueue.progress(function(F){D.renderInfo([_l("loading"),(F.curr+1),_l("of"),F.total].join(" "))});D.hdaQueue.deferred.done(function(){D.renderInfo("");D.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(E){D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E)})},onclear:function(E){D.searchFor=null;D.sortedFilteredColumns().forEach(function(F){F.panel.clearSearch()})}});D.$("#toggle-deleted").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude deleted datasets")},{mode:"include",html:_l("Include deleted datasets")}]}).click(function(){var E=$(this).modeButton("getMode").mode==="exclude";D.sortedFilteredColumns().forEach(function(G,F){_.delay(function(){G.panel.toggleShowDeleted(E,false)},F*200)})});D.$("#toggle-hidden").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude hidden datasets")},{mode:"include",html:_l("Include hidden datasets")}]}).click(function(){var E=$(this).modeButton("getMode").mode==="exclude";D.sortedFilteredColumns().forEach(function(G,F){_.delay(function(){G.panel.toggleShowHidden(E,false)},F*200)})});$(window).resize(function(){D._recalcFirstColumnHeight()});var C=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(C)},_recalcFirstColumnHeight:function(){var C=this.$(".history-column").first(),E=this.$(".middle").height(),D=C.find(".panel-controls").height();C.height(E).find(".inner").height(E-D)},_viewport:function(){var C=this.$(".middle").parent().offset().left;return{left:C,right:C+this.$(".middle").parent().width()}},columnsInView:function(){var C=this._viewport();return this.sortedFilteredColumns().filter(function(D){return D.currentHistory||D.inView(C.left,C.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(C){C.trigger("in-view",C)})},currentColumnDropTargetOn:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=function(D){};C.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=l.HistoryPanelEdit.prototype.dataDrop;C.panel.dropTargetOff()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"}});return{MultiPanelColumns:m}});
\ No newline at end of file
+define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue"],function(d,l,z,a){window.HISTORY_MODEL=d;function g(H,E){E=E||{};if(!(Galaxy&&Galaxy.modal)){return H.copy()}var F=H.get("name"),C="Copy of '"+F+"'";function D(J){if(!J){if(!Galaxy.modal.$("#invalid-title").size()){var I=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(I)}return false}return J}function G(I){var J=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(J);H.copy(true,I).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+F+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',C,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:function(){var I=Galaxy.modal.$("#copy-modal-title").val();if(!D(I)){return}G(I)}}},E));$("#copy-modal-title").focus().select()}var B=Backbone.View.extend(z.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function q(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(C){C=C||{};this.panel=C.panel||this.createPanel(C);this.setUpListeners()},createPanel:function u(D){D=_.extend({model:this.model,dragItems:true},D);var C=new l.HistoryPanelEdit(D);C._renderEmptyMessage=this.__patch_renderEmptyMessage;return C},__patch_renderEmptyMessage:function(E){var D=this,F=_.chain(this.model.get("state_ids")).values().flatten().value().length,C=D.$emptyMessage(E);if(!_.isEmpty(D.hdaViews)){C.hide()}else{if(F&&!this.model.contents.length){C.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(D.searchFor){C.text(D.noneFoundMsg).show()}else{C.text(D.emptyMsg).show()}}}return C},setUpListeners:function f(){var C=this;this.once("rendered",function(){C.trigger("rendered:initial",C)});this.setUpPanelListeners()},setUpPanelListeners:function k(){var C=this;this.listenTo(this.panel,{rendered:function(){C.trigger("rendered",C)}},this)},inView:function(C,D){var F=this.$el.offset().left,E=F+this.$el.width();if(E<C){return false}if(F>D){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function A(D){D=(D!==undefined)?(D):("fast");var C=this.model?this.model.toJSON():{};this.$el.html(this.template(C));this.renderPanel(D);this.setUpBehaviors();return this},setUpBehaviors:function v(){},template:function w(D){D=D||{};var C=['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate(),'<div class="pull-right">','<button class="delete-history btn btn-default">',D.deleted?_l("Undelete"):_l("Delete"),"</button>",'<button class="copy-history btn btn-default">',_l("Copy"),"</button>","</div>","</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',D.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join("");return $(C)},controlsLeftTemplate:function(){return(this.currentHistory)?['<div class="pull-left">','<button class="create-new btn btn-default">',_l("Create new"),"</button> ","</div>"].join(""):['<div class="pull-left">','<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","</div>"].join("")},renderPanel:function h(C){C=(C!==undefined)?(C):("fast");this.panel.setElement(this.$panel()).render(C);return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history.btn":function(){var C=this,D;if(this.model.get("deleted")){D=this.model.undelete()}else{D=this.model._delete()}D.fail(function(G,E,F){alert(_l("Could not delete the history")+":\n"+F)}).done(function(E){C.render()})},"click .copy-history.btn":"copy"},copy:function s(){g(this.model)},toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var m=Backbone.View.extend(z.LoggableMixin).extend({initialize:function c(C){C=C||{};this.log(this+".init",C);if(!C.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=C.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=C.order||"update";this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(C.histories||[]);this.columnMap={};this.createColumns(C.columnOptions);this.setUpListeners()},setUpListeners:function f(){},setCollection:function y(D){var C=this;C.stopListening(C.collection);C.collection=D;C.sortCollection(C.order,{silent:true});C.setUpCollectionListeners();C.trigger("new-collection",C);return C},setUpCollectionListeners:function(){var C=this,D=C.collection;C.listenTo(D,{add:C.addAsCurrentColumn,"set-as-current":C.setCurrentHistory,"change:deleted":C.handleDeletedHistory,sort:function(){C.renderColumns(0)}})},setCurrentHistory:function p(D){var C=this.columnMap[this.currentHistoryId];if(C){C.currentHistory=false;C.$el.height("")}this.currentHistoryId=D.id;var E=this.columnMap[this.currentHistoryId];E.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return E},handleDeletedHistory:function b(D){if(D.get("deleted")){this.log("handleDeletedHistory",this.collection.includeDeleted,D);var C=this;column=C.columnMap[D.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!C.collection.includeDeleted){C.removeColumn(column)}}}},sortCollection:function(C,D){C=C||this.order;var E=this.currentHistoryId;switch(C){case"name":this.collection.comparator=function(F){return[F.id!==E,F.get("name").toLowerCase()]};break;case"size":this.collection.comparator=function(F){return[F.id!==E,F.get("size")]};break;default:this.collection.comparator=function(F){return[F.id!==E,Date(F.get("update_time"))]}}this.collection.sort(D);return this.collection},setOrder:function(C){if(["update","name","size"].indexOf(C)===-1){C="update"}this.order=C;this.sortCollection();return this},create:function(C){return this.collection.create({current:true})},createColumns:function r(D){D=D||{};var C=this;this.columnMap={};C.collection.each(function(E,F){var G=C.createColumn(E,D);C.columnMap[E.id]=G})},createColumn:function t(E,C){C=_.extend({},C,{model:E});var D=new B(C);if(E.id===this.currentHistoryId){D.currentHistory=true}this.setUpColumnListeners(D);return D},sortedFilteredColumns:function(C){C=C||this.filters;if(!C||!C.length){return this.sortedColumns()}var D=this;return D.sortedColumns().filter(function(G,F){var E=G.currentHistory||_.every(C.map(function(H){return H.call(G)}));return E})},sortedColumns:function(){var D=this;var C=this.collection.map(function(F,E){return D.columnMap[F.id]});return C},addColumn:function o(E,C){C=C!==undefined?C:true;var D=this.createColumn(E);this.columnMap[E.id]=D;if(C){this.renderColumns()}return D},addAsCurrentColumn:function o(E){var D=this,C=this.addColumn(E,false);this.setCurrentHistory(E);C.once("rendered",function(){D.queueHdaFetch(C)});return C},removeColumn:function x(E,D){D=D!==undefined?D:true;this.log("removeColumn",E);if(!E){return}var F=this,C=this.options.columnWidth+this.options.columnGap;E.$el.fadeOut("fast",function(){if(D){$(this).remove();F.$(".middle").width(F.$(".middle").width()-C);F.checkColumnsInView();F._recalcFirstColumnHeight()}F.stopListening(E.panel);F.stopListening(E);delete F.columnMap[E.model.id];E.remove()})},setUpColumnListeners:function n(C){var D=this;D.listenTo(C,{"in-view":D.queueHdaFetch});D.listenTo(C.panel,{"view:draggable:dragstart":function(H,F,E,G){D._dropData=JSON.parse(H.dataTransfer.getData("text"));D.currentColumnDropTargetOn()},"view:draggable:dragend":function(H,F,E,G){D._dropData=null;D.currentColumnDropTargetOff()},"droptarget:drop":function(G,H,F){var I=D._dropData.filter(function(J){return(_.isObject(J)&&J.id&&J.model_class==="HistoryDatasetAssociation")});D._dropData=null;var E=new a.NamedAjaxQueue();I.forEach(function(J){E.add({name:"copy-"+J.id,fn:function(){return F.model.contents.copy(J.id)}})});E.start();E.done(function(J){F.model.fetch()})}})},columnMapLength:function(){return Object.keys(this.columnMap).length},render:function A(D){D=D!==undefined?D:this.fxSpeed;var C=this;C.log(C+".render");C.$el.html(C.template(C.options));C.renderColumns(D);C.setUpBehaviors();C.trigger("rendered",C);return C},template:function w(C){C=C||{};var D=[];if(this.options.headerHeight){D=D.concat(['<div class="loading-overlay flex-row"><div class="loading-overlay-message">loading...</div></div>','<div class="header flex-column-container">','<div class="header-control header-control-left flex-column">','<button class="done btn btn-default">',_l("Done"),"</button>",'<button class="include-deleted btn btn-default"></button>','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+'... <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="javascript:void(0);" class="order-update">',_l("Time of last update"),"</a></li>",'<li><a href="javascript:void(0);" class="order-name">',_l("Name"),"</a></li>",'<li><a href="javascript:void(0);" class="order-size">',_l("Size"),"</a></li>","</ul>","</div>",'<div id="search-histories" class="header-search"></div>',"</div>",'<div class="header-control header-control-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="header-control header-control-right flex-column">','<div id="search-datasets" class="header-search"></div>','<button id="toggle-deleted" class="btn btn-default">',_l("Include deleted datasets"),"</button>",'<button id="toggle-hidden" class="btn btn-default">',_l("Include hidden datasets"),"</button>","</div>","</div>"])}D=D.concat(['<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"]);return $(D.join(""))},renderColumns:function j(F){F=F!==undefined?F:this.fxSpeed;var E=this,C=E.sortedFilteredColumns();E.$(".middle").width(C.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var D=E.$(".middle");D.empty();C.forEach(function(H,G){H.$el.appendTo(D);H.delegateEvents();E.renderColumn(H,F)});if(this.searchFor&&C.length<=1){}else{E.checkColumnsInView();this._recalcFirstColumnHeight()}return C},renderColumn:function(C,D){D=D!==undefined?D:this.fxSpeed;return C.render(D)},queueHdaFetch:function i(E){if(E.model.contents.length===0&&!E.model.get("empty")){var C={},D=_.values(E.panel.storage.get("expandedIds")).join();if(D){C.dataset_details=D}this.hdaQueue.add({name:E.model.id,fn:function(){var F=E.model.contents.fetch({data:C,silent:true});return F.done(function(G){E.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(C){if((C.model.contents.length===0&&!C.model.get("empty"))||(!C.model.contents.haveDetails())){this.hdaQueue.add({name:C.model.id,fn:function(){var D=C.model.contents.fetch({data:{details:"all"},silent:true});return D.done(function(E){C.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},renderInfo:function(C){this.$(".header .header-info").text(C)},events:{"click .done.btn":function(){window.location="/"},"click .create-new.btn":"create","click .order .order-update":function(C){this.setOrder("update")},"click .order .order-name":function(C){this.setOrder("name")},"click .order .order-size":function(C){this.setOrder("size")}},includeDeletedHistories:function(){window.location+=(/\?/.test(window.location.toString()))?("&"):("?")+"include_deleted_histories=True"},excludeDeletedHistories:function(){window.location=window.location.toString().replace(/[&\?]include_deleted_histories=True/g,"")},setUpBehaviors:function(){var D=this;D.$(".include-deleted").modeButton({initialMode:this.collection.includeDeleted?"exclude":"include",switchModesOnClick:false,modes:[{mode:"include",html:_l("Include deleted histories"),onclick:_.bind(D.includeDeletedHistories,D)},{mode:"exclude",html:_l("Exclude deleted histories"),onclick:_.bind(D.excludeDeletedHistories,D)}]});D.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(E){D.searchFor=E;D.filters=[function(){return this.model.matchesAll(D.searchFor)}];D.renderColumns(0)},onclear:function(E){D.searchFor=null;D.filters=[];D.renderColumns(0)}});D.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(E){D.hdaQueue.clear();D.$("#search-datasets").searchInput("toggle-loading");D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E);D.queueHdaFetchDetails(F)});D.hdaQueue.progress(function(F){D.renderInfo([_l("searching"),(F.curr+1),_l("of"),F.total].join(" "))});D.hdaQueue.deferred.done(function(){D.renderInfo("");D.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(E){D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E)})},onclear:function(E){D.searchFor=null;D.sortedFilteredColumns().forEach(function(F){F.panel.clearSearch()})}});D.$("#toggle-deleted").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude deleted datasets")},{mode:"include",html:_l("Include deleted datasets")}]}).click(function(){var E=$(this).modeButton("getMode").mode==="exclude";D.sortedFilteredColumns().forEach(function(G,F){_.delay(function(){G.panel.toggleShowDeleted(E,false)},F*200)})});D.$("#toggle-hidden").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude hidden datasets")},{mode:"include",html:_l("Include hidden datasets")}]}).click(function(){var E=$(this).modeButton("getMode").mode==="exclude";D.sortedFilteredColumns().forEach(function(G,F){_.delay(function(){G.panel.toggleShowHidden(E,false)},F*200)})});$(window).resize(function(){D._recalcFirstColumnHeight()});var C=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(C)},_recalcFirstColumnHeight:function(){var C=this.$(".history-column").first(),E=this.$(".middle").height(),D=C.find(".panel-controls").height();C.height(E).find(".inner").height(E-D)},_viewport:function(){var C=this.$(".middle").parent().offset().left;return{left:C,right:C+this.$(".middle").parent().width()}},columnsInView:function(){var C=this._viewport();return this.sortedFilteredColumns().filter(function(D){return D.currentHistory||D.inView(C.left,C.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(C){C.trigger("in-view",C)})},currentColumnDropTargetOn:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=function(D){};C.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=l.HistoryPanelEdit.prototype.dataDrop;C.panel.dropTargetOff()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"}});return{MultiPanelColumns:m}});
\ No newline at end of file
diff -r ff5d57faf17d38d345105300097fc7d196f3527e -r 991cd029642f477f3596ca6035d0830fd2c117ed 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};function LoadingIndicator(a,c){var b=this;c=jQuery.extend({cover:false},c||{});function d(){var e=['<div class="loading-indicator">','<div class="loading-indicator-text">','<span class="fa fa-spinner fa-spin fa-lg"></span>','<span class="loading-indicator-message">loading...</span>',"</div>","</div>"].join("\n");var g=$(e).hide().css(c.css||{position:"fixed"}),f=g.children(".loading-indicator-text");if(c.cover){g.css({"z-index":2,top:a.css("top"),bottom:a.css("bottom"),left:a.css("left"),right:a.css("right"),opacity:0.5,"background-color":"white","text-align":"center"});f=g.children(".loading-indicator-text").css({"margin-top":"20px"})}else{f=g.children(".loading-indicator-text").css({margin:"12px 0px 0px 10px",opacity:"0.85",color:"grey"});f.children(".loading-indicator-message").css({margin:"0px 8px 0px 0px","font-style":"italic"})}return g}b.show=function(f,e,g){f=f||"loading...";e=e||"fast";a.parent().find(".loading-indicator").remove();b.$indicator=d().insertBefore(a);b.message(f);b.$indicator.fadeIn(e,g);return b};b.message=function(e){b.$indicator.find("i").text(e)};b.hide=function(e,f){e=e||"fast";if(b.$indicator&&b.$indicator.size()){b.$indicator.fadeOut(e,function(){b.$indicator.remove();if(f){f()}})}else{if(f){f()}}return b};return b}(function(){var b=window._l||function(d){return d};function a(k,q){var e=27,n=13,d=$(k),f=true,h={initialVal:"",name:"search",placeholder:"search",classes:"",onclear:function(){},onfirstsearch:null,onsearch:function(r){},minSearchLen:0,escWillClear:true,oninit:function(){}};function j(r){var s=$(this).parent().children("input");s.focus().val("").trigger("clear:searchInput");q.onclear()}function p(s,r){$(this).trigger("search:searchInput",r);if(typeof q.onfirstsearch==="function"&&f){f=false;q.onfirstsearch(r)}else{q.onsearch(r)}}function g(){return['<input type="text" name="',q.name,'" placeholder="',q.placeholder,'" ','class="search-query ',q.classes,'" ',"/>"].join("")}function m(){return $(g()).focus(function(r){$(this).select()}).keyup(function(s){s.preventDefault();s.stopPropagation();if(!$(this).val()){$(this).blur()}if(s.which===e&&q.escWillClear){j.call(this,s)}else{var r=$(this).val();if((s.which===n)||(q.minSearchLen&&r.length>=q.minSearchLen)){p.call(this,s,r)}else{if(!r.length){j.call(this,s)}}}}).on("change",function(r){console.info("changed",$(this),r);p.call(this,r,$(this).val())}).val(q.initialVal)}function l(){return $(['<span class="search-clear fa fa-times-circle" ','title="',b("clear search (esc)"),'"></span>'].join("")).tooltip({placement:"bottom"}).click(function(r){j.call(this,r)})}function o(){return $(['<span class="search-loading fa fa-spinner fa-spin" ','title="',b("loading..."),'"></span>'].join("")).hide().tooltip({placement:"bottom"})}function i(){d.find(".search-loading").toggle();d.find(".search-clear").toggle()}if(jQuery.type(q)==="string"){if(q==="toggle-loading"){i()}return d}if(jQuery.type(q)==="object"){q=jQuery.extend(true,{},h,q)}return d.addClass("search-input").prepend([m(),l(),o()])}jQuery.fn.extend({searchInput:function c(d){return this.each(function(){return a(this,d)})}})}());(function(){function c(o,n){this.currModeIndex=0;return this._init(o,n)}c.prototype.DATA_KEY="mode-button";c.prototype.defaults={switchModesOnClick:true};c.prototype._init=function j(o,n){n=n||{};this.$element=$(o);this.options=jQuery.extend(true,{},this.defaults,n);if(!n.modes){throw new Error('ModeButton requires a "modes" array')}var q=this;this.$element.click(function p(r){q.callModeFn();if(q.options.switchModesOnClick){q._incModeIndex()}$(this).html(q.options.modes[q.currModeIndex].html)});return this.reset()};c.prototype._incModeIndex=function l(){this.currModeIndex+=1;if(this.currModeIndex>=this.options.modes.length){this.currModeIndex=0}return this};c.prototype._getModeIndex=function f(n){for(var o=0;o<this.options.modes.length;o+=1){if(this.options.modes[o].mode===n){return o}}throw new Error("mode not found: "+n)};c.prototype._setModeByIndex=function m(n){var o=this.options.modes[n];if(!o){throw new Error("mode index not found: "+n)}this.currModeIndex=n;if(o.html){this.$element.html(o.html)}return this};c.prototype.currentMode=function d(){return this.options.modes[this.currModeIndex]};c.prototype.current=function i(){return this.currentMode().mode};c.prototype.getMode=function g(n){if(!n){return this.currentMode()}return this.options.modes[(this._getModeIndex(n))]};c.prototype.hasMode=function b(n){try{return !!this.getMode(n)}catch(o){}return false};c.prototype.setMode=function a(n){return this._setModeByIndex(this._getModeIndex(n))};c.prototype.reset=function h(){this.currModeIndex=0;if(this.options.initialMode){this.currModeIndex=this._getModeIndex(this.options.initialMode)}return this._setModeByIndex(this.currModeIndex)};c.prototype.callModeFn=function e(n){var o=this.getMode(n).onclick;if(o&&jQuery.type(o==="function")){return o.call(this.$element.get(0))}return undefined};jQuery.fn.extend({modeButton:function k(n){if(!this.size()){return this}if(jQuery.type(n)==="object"){return this.map(function(){var r=$(this);r.data("mode-button",new c(r,n));return this})}var p=$(this[0]),o=p.data("mode-button");if(!o){throw new Error("modeButton needs an options object or string name of a function")}if(o&&jQuery.type(n)==="string"){var q=n;if(o&&jQuery.type(o[q])==="function"){return o[q].apply(o,jQuery.makeArray(arguments).slice(1))}}return o}})}());function dropDownSelect(b,c){c=c||((!_.isEmpty(b))?(b[0]):(""));var a=$(['<div class="dropdown-select btn-group">','<button type="button" class="btn btn-default">','<span class="dropdown-select-selected">'+c+"</span>","</button>","</div>"].join("\n"));if(b&&b.length>1){a.find("button").addClass("dropdown-toggle").attr("data-toggle","dropdown").append(' <span class="caret"></span>');a.append(['<ul class="dropdown-menu" role="menu">',_.map(b,function(e){return['<li><a href="javascript:void(0)">',e,"</a></li>"].join("")}).join("\n"),"</ul>"].join("\n"))}function d(g){var h=$(this),f=h.parents(".dropdown-select"),e=h.text();f.find(".dropdown-select-selected").text(e);f.trigger("change.dropdown-select",e)}a.find("a").click(d);return a}(function(){function e(k,j){return this.init(k,j)}e.prototype.DATA_KEY="filter-control";e.prototype.init=function g(k,j){j=j||{filters:[]};this.$element=$(k).addClass("filter-control btn-group");this.options=jQuery.extend(true,{},this.defaults,j);this.currFilter=this.options.filters[0];return this.render()};e.prototype.render=function d(){this.$element.empty().append([this._renderKeySelect(),this._renderOpSelect(),this._renderValueInput()]);return this};e.prototype._renderKeySelect=function a(){var j=this;var k=this.options.filters.map(function(l){return l.key});this.$keySelect=dropDownSelect(k,this.currFilter.key).addClass("filter-control-key").on("change.dropdown-select",function(m,l){j.currFilter=_.findWhere(j.options.filters,{key:l});j.render()._triggerChange()});return this.$keySelect};e.prototype._renderOpSelect=function i(){var j=this,k=this.currFilter.ops;this.$opSelect=dropDownSelect(k,k[0]).addClass("filter-control-op").on("change.dropdown-select",function(m,l){j._triggerChange()});return this.$opSelect};e.prototype._renderValueInput=function c(){var j=this;if(this.currFilter.values){this.$valueSelect=dropDownSelect(this.currFilter.values,this.currFilter.values[0]).on("change.dropdown-select",function(l,k){j._triggerChange()})}else{this.$valueSelect=$("<input/>").addClass("form-control").on("change",function(k,l){j._triggerChange()})}this.$valueSelect.addClass("filter-control-value");return this.$valueSelect};e.prototype.val=function b(){var k=this.$element.find(".filter-control-key .dropdown-select-selected").text(),m=this.$element.find(".filter-control-op .dropdown-select-selected").text(),j=this.$element.find(".filter-control-value"),l=(j.hasClass("dropdown-select"))?(j.find(".dropdown-select-selected").text()):(j.val());return{key:k,op:m,value:l}};e.prototype._triggerChange=function h(){this.$element.trigger("change.filter-control",this.val())};jQuery.fn.extend({filterControl:function f(k){var j=jQuery.makeArray(arguments).slice(1);return this.map(function(){var n=$(this),m=n.data(e.prototype.DATA_KEY);if(jQuery.type(k)==="object"){m=new e(n,k);n.data(e.prototype.DATA_KEY,m)}if(m&&jQuery.type(k)==="string"){var l=m[k];if(jQuery.type(l)==="function"){return l.apply(m,j)}}return this})}})}());(function(){function i(o,n){this.numPages=null;this.currPage=0;return this.init(o,n)}i.prototype.DATA_KEY="pagination";i.prototype.defaults={startingPage:0,perPage:20,totalDataSize:null,currDataSize:null};i.prototype.init=function g(n,o){o=o||{};this.$element=n;this.options=jQuery.extend(true,{},this.defaults,o);this.currPage=this.options.startingPage;if(this.options.totalDataSize!==null){this.numPages=Math.ceil(this.options.totalDataSize/this.options.perPage);if(this.currPage>=this.numPages){this.currPage=this.numPages-1}}this.$element.data(i.prototype.DATA_KEY,this);this._render();return this};function m(n){return $(['<li><a href="javascript:void(0);">',n,"</a></li>"].join(""))}i.prototype._render=function e(){if(this.options.totalDataSize===0){return this}if(this.numPages===1){return this}if(this.numPages>0){this._renderPages();this._scrollToActivePage()}else{this._renderPrevNext()}return this};i.prototype._renderPrevNext=function b(){var o=this,p=m("Prev"),n=m("Next"),q=$("<ul/>").addClass("pagination pagination-prev-next");if(this.currPage===0){p.addClass("disabled")}else{p.click(function(){o.prevPage()})}if((this.numPages&&this.currPage===(this.numPages-1))||(this.options.currDataSize&&this.options.currDataSize<this.options.perPage)){n.addClass("disabled")}else{n.click(function(){o.nextPage()})}this.$element.html(q.append([p,n]));return this.$element};i.prototype._renderPages=function a(){var n=this,q=$("<div>").addClass("pagination-scroll-container"),s=$("<ul/>").addClass("pagination pagination-page-list"),r=function(t){n.goToPage($(this).data("page"))};for(var o=0;o<this.numPages;o+=1){var p=m(o+1).attr("data-page",o).click(r);if(o===this.currPage){p.addClass("active")}s.append(p)}return this.$element.html(q.html(s))};i.prototype._scrollToActivePage=function l(){var p=this.$element.find(".pagination-scroll-container");if(!p.size()){return this}var o=this.$element.find("li.active"),n=p.width()/2;p.scrollLeft(p.scrollLeft()+o.position().left-n);return this};i.prototype.goToPage=function j(n){if(n<=0){n=0}if(this.numPages&&n>=this.numPages){n=this.numPages-1}if(n===this.currPage){return this}this.currPage=n;this.$element.trigger("pagination.page-change",this.currPage);this._render();return this};i.prototype.prevPage=function c(){return this.goToPage(this.currPage-1)};i.prototype.nextPage=function h(){return this.goToPage(this.currPage+1)};i.prototype.page=function f(){return this.currPage};i.create=function k(n,o){return new i(n,o)};jQuery.fn.extend({pagination:function d(o){var n=jQuery.makeArray(arguments).slice(1);if(jQuery.type(o)==="object"){return this.map(function(){i.create($(this),o);return this})}var q=$(this[0]),r=q.data(i.prototype.DATA_KEY);if(r){if(jQuery.type(o)==="string"){var p=r[o];if(jQuery.type(p)==="function"){return p.apply(r,n)}}else{return r}}return undefined}})}());(function(){var g={renameColumns:false,columnNames:[],commentChar:"#",hideCommentRows:false,includePrompts:true,topLeftContent:"Columns:"},s="peek-control.change",t="peek-control.rename",l="peek-control",v="control",f="control-prompt",c="selected",n="disabled",u="button",q="renamable-header",p="column-index",a="column-name";function i(w){if(w.disabled&&jQuery.type(w.disabled)!=="array"){throw new Error('"disabled" must be defined as an array of indeces: '+JSON.stringify(w))}if(w.multiselect&&w.selected&&jQuery.type(w.selected)!=="array"){throw new Error('Mulitselect rows need an array for "selected": '+JSON.stringify(w))}if(!w.label||!w.id){throw new Error("Peek controls need a label and id for each control row: "+JSON.stringify(w))}if(w.disabled&&w.disabled.indexOf(w.selected)!==-1){throw new Error("Selected column is in the list of disabled columns: "+JSON.stringify(w))}return w}function o(x,w){return $("<div/>").addClass(u).text(x.label)}function k(x,w){var y=$("<td/>").html(o(x,w)).attr("data-"+p,w);if(x.disabled&&x.disabled.indexOf(w)!==-1){y.addClass(n)}return y}function e(y,z,w){var x=y.children("."+u);if(y.hasClass(c)){x.html((z.selectedText!==undefined)?(z.selectedText):(z.label))}else{x.html((z.unselectedText!==undefined)?(z.unselectedText):(z.label))}}function h(z,x){var y=k(z,x);if(z.selected===x){y.addClass(c)}e(y,z,x);if(!y.hasClass(n)){y.click(function w(D){var E=$(this);if(!E.hasClass(c)){var A=E.parent().children("."+c).removeClass(c);A.each(function(){e($(this),z,x)});E.addClass(c);e(E,z,x);var C={},B=E.parent().attr("id"),F=E.data(p);C[B]=F;E.parents(".peek").trigger(s,C)}})}return y}function m(z,x){var y=k(z,x);if(z.selected&&z.selected.indexOf(x)!==-1){y.addClass(c)}e(y,z,x);if(!y.hasClass(n)){y.click(function w(D){var E=$(this);E.toggleClass(c);e(E,z,x);var C=E.parent().find("."+c).map(function(G,H){return $(H).data(p)});var B={},A=E.parent().attr("id"),F=jQuery.makeArray(C);B[A]=F;E.parents(".peek").trigger(s,B)})}return y}function j(y,z){var w=[];for(var x=0;x<y;x+=1){w.push(z.multiselect?m(z,x):h(z,x))}return w}function r(y,z,x){var A=$("<tr/>").attr("id",z.id).addClass(v);if(x){var w=$("<td/>").addClass(f).text(z.label+":");A.append(w)}A.append(j(y,z));return A}function b(E){E=jQuery.extend(true,{},g,E);var D=$(this).addClass(l),A=D.find("table"),z=A.find("th").size(),C=A.find("tr").size(),w=A.find("td[colspan]").map(function(H,F){var G=$(this);if(G.text()&&G.text().match(new RegExp("^"+E.commentChar))){return $(this).css("color","grey").parent().get(0)}return null});if(E.hideCommentRows){w.hide();C-=w.size()}if(E.includePrompts){var y=$("<th/>").addClass("top-left").text(E.topLeftContent).attr("rowspan",C);A.find("tr").first().prepend(y)}var B=A.find("th:not(.top-left)").each(function(G,I){var H=$(this),J=H.text().replace(/^\d+\.*/,""),F=E.columnNames[G]||J;H.attr("data-"+a,F).text((G+1)+((F)?("."+F):("")))});if(E.renameColumns){B.addClass(q).click(function x(){var G=$(this),F=G.index()+(E.includePrompts?0:1),I=G.data(a),H=prompt("New column name:",I);if(H!==null&&H!==I){G.text(F+(H?("."+H):"")).data(a,H).attr("data-",a,H);var J=jQuery.makeArray(G.parent().children("th:not(.top-left)").map(function(){return $(this).data(a)}));G.parents(".peek").trigger(t,J)}})}E.controls.forEach(function(G,F){i(G);var H=r(z,G,E.includePrompts);A.find("tbody").append(H)});return this}jQuery.fn.extend({peekControl:function d(w){return this.map(function(){return b.call(this,w)})}})}());
\ 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};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};function LoadingIndicator(a,c){var b=this;c=jQuery.extend({cover:false},c||{});function d(){var e=['<div class="loading-indicator">','<div class="loading-indicator-text">','<span class="fa fa-spinner fa-spin fa-lg"></span>','<span class="loading-indicator-message">loading...</span>',"</div>","</div>"].join("\n");var g=$(e).hide().css(c.css||{position:"fixed"}),f=g.children(".loading-indicator-text");if(c.cover){g.css({"z-index":2,top:a.css("top"),bottom:a.css("bottom"),left:a.css("left"),right:a.css("right"),opacity:0.5,"background-color":"white","text-align":"center"});f=g.children(".loading-indicator-text").css({"margin-top":"20px"})}else{f=g.children(".loading-indicator-text").css({margin:"12px 0px 0px 10px",opacity:"0.85",color:"grey"});f.children(".loading-indicator-message").css({margin:"0px 8px 0px 0px","font-style":"italic"})}return g}b.show=function(f,e,g){f=f||"loading...";e=e||"fast";a.parent().find(".loading-indicator").remove();b.$indicator=d().insertBefore(a);b.message(f);b.$indicator.fadeIn(e,g);return b};b.message=function(e){b.$indicator.find("i").text(e)};b.hide=function(e,f){e=e||"fast";if(b.$indicator&&b.$indicator.size()){b.$indicator.fadeOut(e,function(){b.$indicator.remove();if(f){f()}})}else{if(f){f()}}return b};return b}(function(){var b=window._l||function(d){return d};function a(k,q){var e=27,n=13,d=$(k),f=true,h={initialVal:"",name:"search",placeholder:"search",classes:"",onclear:function(){},onfirstsearch:null,onsearch:function(r){},minSearchLen:0,escWillClear:true,oninit:function(){}};function j(r){var s=$(this).parent().children("input");s.focus().val("").trigger("clear:searchInput");q.onclear()}function p(s,r){$(this).trigger("search:searchInput",r);if(typeof q.onfirstsearch==="function"&&f){f=false;q.onfirstsearch(r)}else{q.onsearch(r)}}function g(){return['<input type="text" name="',q.name,'" placeholder="',q.placeholder,'" ','class="search-query ',q.classes,'" ',"/>"].join("")}function m(){return $(g()).focus(function(r){$(this).select()}).keyup(function(s){s.preventDefault();s.stopPropagation();if(!$(this).val()){$(this).blur()}if(s.which===e&&q.escWillClear){j.call(this,s)}else{var r=$(this).val();if((s.which===n)||(q.minSearchLen&&r.length>=q.minSearchLen)){p.call(this,s,r)}else{if(!r.length){j.call(this,s)}}}}).on("change",function(r){p.call(this,r,$(this).val())}).val(q.initialVal)}function l(){return $(['<span class="search-clear fa fa-times-circle" ','title="',b("clear search (esc)"),'"></span>'].join("")).tooltip({placement:"bottom"}).click(function(r){j.call(this,r)})}function o(){return $(['<span class="search-loading fa fa-spinner fa-spin" ','title="',b("loading..."),'"></span>'].join("")).hide().tooltip({placement:"bottom"})}function i(){d.find(".search-loading").toggle();d.find(".search-clear").toggle()}if(jQuery.type(q)==="string"){if(q==="toggle-loading"){i()}return d}if(jQuery.type(q)==="object"){q=jQuery.extend(true,{},h,q)}return d.addClass("search-input").prepend([m(),l(),o()])}jQuery.fn.extend({searchInput:function c(d){return this.each(function(){return a(this,d)})}})}());(function(){function c(o,n){this.currModeIndex=0;return this._init(o,n)}c.prototype.DATA_KEY="mode-button";c.prototype.defaults={switchModesOnClick:true};c.prototype._init=function j(o,n){n=n||{};this.$element=$(o);this.options=jQuery.extend(true,{},this.defaults,n);if(!n.modes){throw new Error('ModeButton requires a "modes" array')}var q=this;this.$element.click(function p(r){q.callModeFn();if(q.options.switchModesOnClick){q._incModeIndex()}$(this).html(q.options.modes[q.currModeIndex].html)});return this.reset()};c.prototype._incModeIndex=function l(){this.currModeIndex+=1;if(this.currModeIndex>=this.options.modes.length){this.currModeIndex=0}return this};c.prototype._getModeIndex=function f(n){for(var o=0;o<this.options.modes.length;o+=1){if(this.options.modes[o].mode===n){return o}}throw new Error("mode not found: "+n)};c.prototype._setModeByIndex=function m(n){var o=this.options.modes[n];if(!o){throw new Error("mode index not found: "+n)}this.currModeIndex=n;if(o.html){this.$element.html(o.html)}return this};c.prototype.currentMode=function d(){return this.options.modes[this.currModeIndex]};c.prototype.current=function i(){return this.currentMode().mode};c.prototype.getMode=function g(n){if(!n){return this.currentMode()}return this.options.modes[(this._getModeIndex(n))]};c.prototype.hasMode=function b(n){try{return !!this.getMode(n)}catch(o){}return false};c.prototype.setMode=function a(n){return this._setModeByIndex(this._getModeIndex(n))};c.prototype.reset=function h(){this.currModeIndex=0;if(this.options.initialMode){this.currModeIndex=this._getModeIndex(this.options.initialMode)}return this._setModeByIndex(this.currModeIndex)};c.prototype.callModeFn=function e(n){var o=this.getMode(n).onclick;if(o&&jQuery.type(o==="function")){return o.call(this.$element.get(0))}return undefined};jQuery.fn.extend({modeButton:function k(n){if(!this.size()){return this}if(jQuery.type(n)==="object"){return this.map(function(){var r=$(this);r.data("mode-button",new c(r,n));return this})}var p=$(this[0]),o=p.data("mode-button");if(!o){throw new Error("modeButton needs an options object or string name of a function")}if(o&&jQuery.type(n)==="string"){var q=n;if(o&&jQuery.type(o[q])==="function"){return o[q].apply(o,jQuery.makeArray(arguments).slice(1))}}return o}})}());function dropDownSelect(b,c){c=c||((!_.isEmpty(b))?(b[0]):(""));var a=$(['<div class="dropdown-select btn-group">','<button type="button" class="btn btn-default">','<span class="dropdown-select-selected">'+c+"</span>","</button>","</div>"].join("\n"));if(b&&b.length>1){a.find("button").addClass("dropdown-toggle").attr("data-toggle","dropdown").append(' <span class="caret"></span>');a.append(['<ul class="dropdown-menu" role="menu">',_.map(b,function(e){return['<li><a href="javascript:void(0)">',e,"</a></li>"].join("")}).join("\n"),"</ul>"].join("\n"))}function d(g){var h=$(this),f=h.parents(".dropdown-select"),e=h.text();f.find(".dropdown-select-selected").text(e);f.trigger("change.dropdown-select",e)}a.find("a").click(d);return a}(function(){function e(k,j){return this.init(k,j)}e.prototype.DATA_KEY="filter-control";e.prototype.init=function g(k,j){j=j||{filters:[]};this.$element=$(k).addClass("filter-control btn-group");this.options=jQuery.extend(true,{},this.defaults,j);this.currFilter=this.options.filters[0];return this.render()};e.prototype.render=function d(){this.$element.empty().append([this._renderKeySelect(),this._renderOpSelect(),this._renderValueInput()]);return this};e.prototype._renderKeySelect=function a(){var j=this;var k=this.options.filters.map(function(l){return l.key});this.$keySelect=dropDownSelect(k,this.currFilter.key).addClass("filter-control-key").on("change.dropdown-select",function(m,l){j.currFilter=_.findWhere(j.options.filters,{key:l});j.render()._triggerChange()});return this.$keySelect};e.prototype._renderOpSelect=function i(){var j=this,k=this.currFilter.ops;this.$opSelect=dropDownSelect(k,k[0]).addClass("filter-control-op").on("change.dropdown-select",function(m,l){j._triggerChange()});return this.$opSelect};e.prototype._renderValueInput=function c(){var j=this;if(this.currFilter.values){this.$valueSelect=dropDownSelect(this.currFilter.values,this.currFilter.values[0]).on("change.dropdown-select",function(l,k){j._triggerChange()})}else{this.$valueSelect=$("<input/>").addClass("form-control").on("change",function(k,l){j._triggerChange()})}this.$valueSelect.addClass("filter-control-value");return this.$valueSelect};e.prototype.val=function b(){var k=this.$element.find(".filter-control-key .dropdown-select-selected").text(),m=this.$element.find(".filter-control-op .dropdown-select-selected").text(),j=this.$element.find(".filter-control-value"),l=(j.hasClass("dropdown-select"))?(j.find(".dropdown-select-selected").text()):(j.val());return{key:k,op:m,value:l}};e.prototype._triggerChange=function h(){this.$element.trigger("change.filter-control",this.val())};jQuery.fn.extend({filterControl:function f(k){var j=jQuery.makeArray(arguments).slice(1);return this.map(function(){var n=$(this),m=n.data(e.prototype.DATA_KEY);if(jQuery.type(k)==="object"){m=new e(n,k);n.data(e.prototype.DATA_KEY,m)}if(m&&jQuery.type(k)==="string"){var l=m[k];if(jQuery.type(l)==="function"){return l.apply(m,j)}}return this})}})}());(function(){function i(o,n){this.numPages=null;this.currPage=0;return this.init(o,n)}i.prototype.DATA_KEY="pagination";i.prototype.defaults={startingPage:0,perPage:20,totalDataSize:null,currDataSize:null};i.prototype.init=function g(n,o){o=o||{};this.$element=n;this.options=jQuery.extend(true,{},this.defaults,o);this.currPage=this.options.startingPage;if(this.options.totalDataSize!==null){this.numPages=Math.ceil(this.options.totalDataSize/this.options.perPage);if(this.currPage>=this.numPages){this.currPage=this.numPages-1}}this.$element.data(i.prototype.DATA_KEY,this);this._render();return this};function m(n){return $(['<li><a href="javascript:void(0);">',n,"</a></li>"].join(""))}i.prototype._render=function e(){if(this.options.totalDataSize===0){return this}if(this.numPages===1){return this}if(this.numPages>0){this._renderPages();this._scrollToActivePage()}else{this._renderPrevNext()}return this};i.prototype._renderPrevNext=function b(){var o=this,p=m("Prev"),n=m("Next"),q=$("<ul/>").addClass("pagination pagination-prev-next");if(this.currPage===0){p.addClass("disabled")}else{p.click(function(){o.prevPage()})}if((this.numPages&&this.currPage===(this.numPages-1))||(this.options.currDataSize&&this.options.currDataSize<this.options.perPage)){n.addClass("disabled")}else{n.click(function(){o.nextPage()})}this.$element.html(q.append([p,n]));return this.$element};i.prototype._renderPages=function a(){var n=this,q=$("<div>").addClass("pagination-scroll-container"),s=$("<ul/>").addClass("pagination pagination-page-list"),r=function(t){n.goToPage($(this).data("page"))};for(var o=0;o<this.numPages;o+=1){var p=m(o+1).attr("data-page",o).click(r);if(o===this.currPage){p.addClass("active")}s.append(p)}return this.$element.html(q.html(s))};i.prototype._scrollToActivePage=function l(){var p=this.$element.find(".pagination-scroll-container");if(!p.size()){return this}var o=this.$element.find("li.active"),n=p.width()/2;p.scrollLeft(p.scrollLeft()+o.position().left-n);return this};i.prototype.goToPage=function j(n){if(n<=0){n=0}if(this.numPages&&n>=this.numPages){n=this.numPages-1}if(n===this.currPage){return this}this.currPage=n;this.$element.trigger("pagination.page-change",this.currPage);this._render();return this};i.prototype.prevPage=function c(){return this.goToPage(this.currPage-1)};i.prototype.nextPage=function h(){return this.goToPage(this.currPage+1)};i.prototype.page=function f(){return this.currPage};i.create=function k(n,o){return new i(n,o)};jQuery.fn.extend({pagination:function d(o){var n=jQuery.makeArray(arguments).slice(1);if(jQuery.type(o)==="object"){return this.map(function(){i.create($(this),o);return this})}var q=$(this[0]),r=q.data(i.prototype.DATA_KEY);if(r){if(jQuery.type(o)==="string"){var p=r[o];if(jQuery.type(p)==="function"){return p.apply(r,n)}}else{return r}}return undefined}})}());(function(){var g={renameColumns:false,columnNames:[],commentChar:"#",hideCommentRows:false,includePrompts:true,topLeftContent:"Columns:"},s="peek-control.change",t="peek-control.rename",l="peek-control",v="control",f="control-prompt",c="selected",n="disabled",u="button",q="renamable-header",p="column-index",a="column-name";function i(w){if(w.disabled&&jQuery.type(w.disabled)!=="array"){throw new Error('"disabled" must be defined as an array of indeces: '+JSON.stringify(w))}if(w.multiselect&&w.selected&&jQuery.type(w.selected)!=="array"){throw new Error('Mulitselect rows need an array for "selected": '+JSON.stringify(w))}if(!w.label||!w.id){throw new Error("Peek controls need a label and id for each control row: "+JSON.stringify(w))}if(w.disabled&&w.disabled.indexOf(w.selected)!==-1){throw new Error("Selected column is in the list of disabled columns: "+JSON.stringify(w))}return w}function o(x,w){return $("<div/>").addClass(u).text(x.label)}function k(x,w){var y=$("<td/>").html(o(x,w)).attr("data-"+p,w);if(x.disabled&&x.disabled.indexOf(w)!==-1){y.addClass(n)}return y}function e(y,z,w){var x=y.children("."+u);if(y.hasClass(c)){x.html((z.selectedText!==undefined)?(z.selectedText):(z.label))}else{x.html((z.unselectedText!==undefined)?(z.unselectedText):(z.label))}}function h(z,x){var y=k(z,x);if(z.selected===x){y.addClass(c)}e(y,z,x);if(!y.hasClass(n)){y.click(function w(D){var E=$(this);if(!E.hasClass(c)){var A=E.parent().children("."+c).removeClass(c);A.each(function(){e($(this),z,x)});E.addClass(c);e(E,z,x);var C={},B=E.parent().attr("id"),F=E.data(p);C[B]=F;E.parents(".peek").trigger(s,C)}})}return y}function m(z,x){var y=k(z,x);if(z.selected&&z.selected.indexOf(x)!==-1){y.addClass(c)}e(y,z,x);if(!y.hasClass(n)){y.click(function w(D){var E=$(this);E.toggleClass(c);e(E,z,x);var C=E.parent().find("."+c).map(function(G,H){return $(H).data(p)});var B={},A=E.parent().attr("id"),F=jQuery.makeArray(C);B[A]=F;E.parents(".peek").trigger(s,B)})}return y}function j(y,z){var w=[];for(var x=0;x<y;x+=1){w.push(z.multiselect?m(z,x):h(z,x))}return w}function r(y,z,x){var A=$("<tr/>").attr("id",z.id).addClass(v);if(x){var w=$("<td/>").addClass(f).text(z.label+":");A.append(w)}A.append(j(y,z));return A}function b(E){E=jQuery.extend(true,{},g,E);var D=$(this).addClass(l),A=D.find("table"),z=A.find("th").size(),C=A.find("tr").size(),w=A.find("td[colspan]").map(function(H,F){var G=$(this);if(G.text()&&G.text().match(new RegExp("^"+E.commentChar))){return $(this).css("color","grey").parent().get(0)}return null});if(E.hideCommentRows){w.hide();C-=w.size()}if(E.includePrompts){var y=$("<th/>").addClass("top-left").text(E.topLeftContent).attr("rowspan",C);A.find("tr").first().prepend(y)}var B=A.find("th:not(.top-left)").each(function(G,I){var H=$(this),J=H.text().replace(/^\d+\.*/,""),F=E.columnNames[G]||J;H.attr("data-"+a,F).text((G+1)+((F)?("."+F):("")))});if(E.renameColumns){B.addClass(q).click(function x(){var G=$(this),F=G.index()+(E.includePrompts?0:1),I=G.data(a),H=prompt("New column name:",I);if(H!==null&&H!==I){G.text(F+(H?("."+H):"")).data(a,H).attr("data-",a,H);var J=jQuery.makeArray(G.parent().children("th:not(.top-left)").map(function(){return $(this).data(a)}));G.parents(".peek").trigger(t,J)}})}E.controls.forEach(function(G,F){i(G);var H=r(z,G,E.includePrompts);A.find("tbody").append(H)});return this}jQuery.fn.extend({peekControl:function d(w){return this.map(function(){return b.call(this,w)})}})}());
\ 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.
1
0
commit/galaxy-central: carlfeberhard: History multi-view: documentation and some cleanup
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/ff5d57faf17d/
Changeset: ff5d57faf17d
User: carlfeberhard
Date: 2014-09-29 14:54:01+00:00
Summary: History multi-view: documentation and some cleanup
Affected #: 3 files
diff -r 633b4212806d850135a28966d9759da3157b22e8 -r ff5d57faf17d38d345105300097fc7d196f3527e client/galaxy/scripts/mvc/history/multi-panel.js
--- a/client/galaxy/scripts/mvc/history/multi-panel.js
+++ b/client/galaxy/scripts/mvc/history/multi-panel.js
@@ -30,6 +30,7 @@
}
return name;
}
+
function copyHistory( name ){
var $copyIndicator = $( '<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>' )
.css( 'margin-top', '8px' );
@@ -69,21 +70,16 @@
/* ==============================================================================
TODO:
copy places old current in wrong location
- size not updating on dnd
- sort by size is broken
+ sort by size is confusing (but correct) - nice_size shows actual disk usage, !== size
handle delete current
currently manual by user - delete then create new - make one step
render
move all columns over as one (agg. then html())
loading indicator on startup
- loading indicators on histories (while queueHdaLoading)
- __panelPatchRenderEmptyMsg
performance
- page load takes a while
- renders where blocking each other - used _.delay( 0 )
- sort takes a while
rendering columns could be better
- lazy load history list
+ lazy load history list (for large numbers)
+ req. API limit/offset
move in-view from pubsub
handle errors
@@ -103,10 +99,11 @@
privatize non-interface fns
search for and drag and drop - should reset after dataset is loaded (or alt. clear search)
- better ajax error handling
?columns should be a panel, not have a panel
============================================================================== */
+/** @class A container for a history panel that renders controls for that history (delete, copy, etc.)
+ */
var HistoryPanelColumn = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
//TODO: extend from panel? (instead of aggregating)
@@ -120,7 +117,7 @@
},
// ------------------------------------------------------------------------ set up
- /** */
+ /** set up passed-in panel (if any) and listeners */
initialize : function initialize( options ){
options = options || {};
@@ -132,7 +129,7 @@
this.setUpListeners();
},
- /** */
+ /** create a history panel for this column */
createPanel : function createPanel( panelOptions ){
panelOptions = _.extend({
model : this.model,
@@ -148,7 +145,8 @@
},
//TODO: needs work
- /** */
+//TODO: move to stub-class to avoid monkey-patching
+ /** the function monkey-patched into panels to show contents loading state */
__patch_renderEmptyMessage : function( $whereTo ){
var panel = this,
hdaCount = _.chain( this.model.get( 'state_ids' ) ).values().flatten().value().length,
@@ -170,7 +168,7 @@
return $emptyMsg;
},
- /** */
+ /** set up reflexive listeners */
setUpListeners : function setUpListeners(){
var column = this;
//this.log( 'setUpListeners', this );
@@ -180,7 +178,7 @@
this.setUpPanelListeners();
},
- /** */
+ /** set listeners needed for panel */
setUpPanelListeners : function setUpPanelListeners(){
var column = this;
this.listenTo( this.panel, {
@@ -193,7 +191,7 @@
}, this );
},
- /** */
+ /** do the dimensions of this column overlap the given (horizontal) browser coords? */
inView : function( viewLeft, viewRight ){
//TODO: offset is expensive
var columnLeft = this.$el.offset().left,
@@ -203,13 +201,13 @@
return true;
},
- /** */
+ /** shortcut to the panel */
$panel : function $panel(){
return this.$( '.history-panel' );
},
// ------------------------------------------------------------------------ render
- /** */
+ /** render ths column, its panel, and set up plugins */
render : function render( speed ){
speed = ( speed !== undefined )?( speed ):( 'fast' );
//this.log( this + '.render', this.$el, this.el );
@@ -225,14 +223,14 @@
return this;
},
- /** */
+ /** set up plugins */
setUpBehaviors : function setUpBehaviors(){
//this.log( 'setUpBehaviors:', this );
//var column = this;
// on panel size change, ...
},
- /** */
+ /** column body template with inner div for panel based on data (model json) */
template : function template( data ){
data = data || {};
var html = [
@@ -253,6 +251,7 @@
return $( html );
},
+ /** controls template displaying controls above the panel based on this.currentHistory */
controlsLeftTemplate : function(){
return ( this.currentHistory )?
[
@@ -267,7 +266,7 @@
].join( '' );
},
- /** */
+ /** render the panel contained in the column using speed for fx speed */
renderPanel : function renderPanel( speed ){
speed = ( speed !== undefined )?( speed ):( 'fast' );
this.panel.setElement( this.$panel() ).render( speed );
@@ -275,9 +274,11 @@
},
// ------------------------------------------------------------------------ behaviors and events
- /** */
+ /** event map */
events : {
+ // will make this the current history
'click .switch-to.btn' : function(){ this.model.setAsCurrent(); },
+ // toggles deleted here and on the server and re-renders
'click .delete-history.btn' : function(){
var column = this,
xhr;
@@ -294,17 +295,18 @@
column.render();
});
},
+ // will copy this history and make the copy the current history
'click .copy-history.btn' : 'copy'
},
// ------------------------------------------------------------------------ non-current controls
- /** */
+ /** Open a modal to get a new history name, copy it (if not canceled), and makes the copy current */
copy : function copy(){
historyCopyDialog( this.model );
},
// ------------------------------------------------------------------------ misc
- /** */
+ /** String rep */
toString : function(){
return 'HistoryPanelColumn(' + ( this.panel? this.panel : '' ) + ')';
}
@@ -312,13 +314,14 @@
//==============================================================================
-// a multi-history view that displays histories in full
+/** @class A view of a HistoryCollection and displays histories similarly to the current history panel.
+ */
var MultiPanelColumns = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
//logger : console,
// ------------------------------------------------------------------------ set up
- /** */
+ /** Set up internals, history collection, and columns to display the history */
initialize : function initialize( options ){
options = options || {};
this.log( this + '.init', options );
@@ -352,8 +355,6 @@
this.collection = null;
this.setCollection( options.histories || [] );
- ///** the column views of histories */
- //this.columns = [];
/** model id to column map */
this.columnMap = {};
//TODO: why create here?
@@ -362,14 +363,16 @@
this.setUpListeners();
},
- /** */
+ /** Set up reflexive listeners */
setUpListeners : function setUpListeners(){
//var multipanel = this;
//multipanel.log( 'setUpListeners', multipanel );
},
// ------------------------------------------------------------------------ collection
- /** */
+ /** Set up a (new) history collection, sorting and adding listeners
+ * @fires 'new-collection' when set with this view as the arg
+ */
setCollection : function setCollection( models ){
var multipanel = this;
multipanel.stopListening( multipanel.collection );
@@ -383,6 +386,7 @@
return multipanel;
},
+ /** Set up listeners for the collection - handling: added histories, change of current, deletion, and sorting */
setUpCollectionListeners : function(){
var multipanel = this,
collection = multipanel.collection;
@@ -394,15 +398,16 @@
// handle deleting a history (depends on whether panels is including deleted or not)
'change:deleted': multipanel.handleDeletedHistory,
- 'sort' : function(){ multipanel.renderColumns( 0 ); },
+ 'sort' : function(){ multipanel.renderColumns( 0 ); }
+ // debugging
//'all' : function(){
// console.info( 'collection:', arguments );
//}
});
},
- /** */
+ /** Re-render and set currentHistoryId to reflect a new current history */
setCurrentHistory : function setCurrentHistory( history ){
var oldCurrentColumn = this.columnMap[ this.currentHistoryId ];
if( oldCurrentColumn ){
@@ -425,7 +430,9 @@
return newCurrentColumn;
},
- /** */
+ /** Either remove a deleted history or re-render it to show the deleted message
+ * based on collection.includeDeleted
+ */
handleDeletedHistory : function handleDeletedHistory( history ){
if( history.get( 'deleted' ) ){
this.log( 'handleDeletedHistory', this.collection.includeDeleted, history );
@@ -446,7 +453,9 @@
}
},
- /** */
+ /** Sort this collection based on order (defaulting to this.order) a string key
+ * (sorting the collection will re-render the panel)
+ */
sortCollection : function( order, options ){
order = order || this.order;
var currentHistoryId = this.currentHistoryId;
@@ -477,7 +486,7 @@
return this.collection;
},
- /** */
+ /** Set the sort order and re-sort */
setOrder : function( order ){
if( [ 'update', 'name', 'size' ].indexOf( order ) === -1 ){
order = 'update';
@@ -487,12 +496,12 @@
return this;
},
- /** */
+ /** create a new history and set it to current */
create : function( ev ){
return this.collection.create({ current: true });
},
- ///** */
+ ///** delete the current history */
//deleteCurrent : function deleteCurrent(){
// var multipanel = this,
// currentColumn = multipanel.columnMap[ multipanel.currentHistoryId ];
@@ -515,7 +524,7 @@
});
},
- /** */
+ /** create a column and its panel and set up any listeners to them */
createColumn : function createColumn( history, options ){
// options passed can be re-used, so extend them before adding the model to prevent pollution for the next
options = _.extend( {}, options, { model: history });
@@ -525,10 +534,6 @@
return column;
},
- columnMapLength : function(){
- return Object.keys( this.columnMap ).length;
- },
-
sortedFilteredColumns : function( filters ){
filters = filters || this.filters;
if( !filters || !filters.length ){
@@ -598,7 +603,7 @@
});
},
- /** */
+ /** set up listeners for a column and it's panel - handling: hda lazy-loading, drag and drop */
setUpColumnListeners : function setUpColumnListeners( column ){
var multipanel = this;
multipanel.listenTo( column, {
@@ -641,8 +646,13 @@
},
+ /** conv. fn to count the columns in columnMap */
+ columnMapLength : function(){
+ return Object.keys( this.columnMap ).length;
+ },
+
// ------------------------------------------------------------------------ render
- /** */
+ /** Render this view, columns, and set up view plugins */
render : function render( speed ){
speed = speed !== undefined? speed: this.fxSpeed;
var multipanel = this;
@@ -660,14 +670,16 @@
return multipanel;
},
- /** */
+ /** Template - overall structure relies on flex-boxes and is 3 components: header, middle, footer */
template : function template( options ){
options = options || {};
var html = [];
if( this.options.headerHeight ){
html = html.concat([
+ // a loading overlay
'<div class="loading-overlay flex-row"><div class="loading-overlay-message">loading...</div></div>',
'<div class="header flex-column-container">',
+ // page & history controls
'<div class="header-control header-control-left flex-column">',
'<button class="done btn btn-default">', _l( 'Done' ), '</button>',
'<button class="include-deleted btn btn-default"></button>',
@@ -689,10 +701,12 @@
'</div>',
'<div id="search-histories" class="header-search"></div>',
'</div>',
+ // feedback
'<div class="header-control header-control-center flex-column">',
'<div class="header-info">',
'</div>',
'</div>',
+ // dataset controls
'<div class="header-control header-control-right flex-column">',
'<div id="search-datasets" class="header-search"></div>',
'<button id="toggle-deleted" class="btn btn-default">',
@@ -707,15 +721,17 @@
}
html = html.concat([
+ // middle - where the columns go
'<div class="outer-middle flex-row flex-row-container">',
'<div class="middle flex-column-container flex-row"></div>',
'</div>',
+ // footer
'<div class="footer flex-column-container">','</div>'
]);
return $( html.join( '' ) );
},
- /** */
+ /** Render the columns and panels */
renderColumns : function renderColumns( speed ){
speed = speed !== undefined? speed: this.fxSpeed;
//this.log( 'renderColumns:', speed );
@@ -780,14 +796,16 @@
if( this.searchFor && sortedAndFiltered.length <= 1 ){
} else {
+ // check for in-view, hda lazy-loading if so
multipanel.checkColumnsInView();
+ // the first, current column has position: fixed and flex css will not apply - adjust height manually
this._recalcFirstColumnHeight();
}
return sortedAndFiltered;
},
- /** */
+ /** Render a single column using the non-blocking setTimeout( 0 ) pattern */
renderColumn : function( column, speed ){
speed = speed !== undefined? speed: this.fxSpeed;
return _.delay( function(){ return column.render( speed ); }, 0 );
@@ -796,7 +814,9 @@
//TODO: combine the following two more sensibly
//TODO: could have HistoryContents.haveDetails return false
// if column.model.contents.length === 0 && !column.model.get( 'empty' ) then just check that
- /** */
+ /** Get the *summary* contents of a column's history (and details on any expanded contents),
+ * queueing the ajax call and using a named queue to prevent the call being sent twice
+ */
queueHdaFetch : function queueHdaFetch( column ){
//this.log( 'queueHdaFetch:', column );
// if the history model says it has hdas but none are present, queue an ajax req for them
@@ -822,7 +842,7 @@
}
},
- /** */
+ /** Get the *detailed* json for *all* of a column's history's contents - req'd for searching */
queueHdaFetchDetails : function( column ){
if( ( column.model.contents.length === 0 && !column.model.get( 'empty' ) )
|| ( !column.model.contents.haveDetails() ) ){
@@ -841,11 +861,7 @@
}
},
- /** */
- allColumns : function allColumns(){
- return [ this.currentColumn ].concat( this.columns );
- },
-
+ /** put a text msg in the header */
renderInfo : function( msg ){
this.$( '.header .header-info' ).text( msg );
},
@@ -853,9 +869,13 @@
// ------------------------------------------------------------------------ events/behaviors
/** */
events : {
+ // will move to the server root (gen. Analyze data)
'click .done.btn' : function(){ window.location = '/'; },
+ //TODO:?? could just go back - but that's not always correct/desired behav.
//'click .done.btn' : function(){ window.history.back(); },
+ // creates a new empty history and makes it current
'click .create-new.btn' : 'create',
+ // these change the collection and column sort order
'click .order .order-update' : function( e ){ this.setOrder( 'update' ); },
'click .order .order-name' : function( e ){ this.setOrder( 'name' ); },
'click .order .order-size' : function( e ){ this.setOrder( 'size' ); }
@@ -863,22 +883,25 @@
//'dragstart .list-item .title-bar' : function( e ){ console.debug( 'ok' ); }
},
+ /** Include deleted histories in the collection */
includeDeletedHistories : function(){
//TODO: better through API/limit+offset
window.location += ( /\?/.test( window.location.toString() ) )?( '&' ):( '?' )
+ 'include_deleted_histories=True';
},
+ /** Show only non-deleted histories */
excludeDeletedHistories : function(){
//TODO: better through API/limit+offset
window.location = window.location.toString().replace( /[&\?]include_deleted_histories=True/g, '' );
},
- /** */
+ /** Set up any view plugins */
setUpBehaviors : function(){
var multipanel = this;
//TODO: currently doesn't need to be a mode button
+ // toggle button for include deleted
multipanel.$( '.include-deleted' ).modeButton({
initialMode : this.collection.includeDeleted? 'exclude' : 'include',
switchModesOnClick : false,
@@ -949,6 +972,7 @@
});
//TODO: each panel stores the hidden/deleted state - and that isn't reflected in the buttons
+ // toggle button for showing deleted history contents
multipanel.$( '#toggle-deleted' ).modeButton({
initialMode : 'include',
modes: [
@@ -964,6 +988,7 @@
});
});
+ // toggle button for showing hidden history contents
multipanel.$( '#toggle-hidden' ).modeButton({
initialMode : 'include',
modes: [
@@ -990,33 +1015,26 @@
this.$( '.middle' ).parent().scroll( debouncedInView );
},
+ ///** Put the in-view columns then the other columns in a queue, rendering each one at a time */
//panelRenderQueue : function( columns, fn, args, renderEventName ){
//},
+ /** Adjust the height of the first, current column since flex-boxes won't work with fixed postiion elements */
_recalcFirstColumnHeight : function(){
- //var currentColumn = this.columnMap[ this.currentHistoryId ];
- //if( !currentColumn ){ return; }
var $firstColumn = this.$( '.history-column' ).first(),
middleHeight = this.$( '.middle' ).height(),
controlHeight = $firstColumn.find( '.panel-controls' ).height();
$firstColumn.height( middleHeight )
.find( '.inner' ).height( middleHeight - controlHeight );
-
-//console.debug( '$firstColumn:', $firstColumn );
- //var currentColumn = this.columnMap[ this.currentHistoryId ];
- //if( !currentColumn ){ return; }
- //var middleHeight = this.$( '.middle' ).height(),
- // controlHeight = currentColumn.$( '.panel-controls' ).height();
- //currentColumn.$el.height( middleHeight )
- // .find( '.inner' ).height( middleHeight - controlHeight );
},
+ /** Get the left and right pixel coords of the middle element */
_viewport : function(){
var viewLeft = this.$( '.middle' ).parent().offset().left;
return { left: viewLeft, right: viewLeft + this.$( '.middle' ).parent().width() };
},
- /** */
+ /** returns the columns currently in the viewport */
columnsInView : function(){
//TODO: uses offset which is render intensive
//TODO: 2N - could use arg filter (sortedFilteredColumns( filter )) instead
@@ -1027,15 +1045,16 @@
},
//TODO: sortByInView - return cols in view, then others
- /** */
+ /** trigger in-view from columns in-view */
checkColumnsInView : function(){
+//TODO: assbackward
//console.debug( 'checking columns in view', this.columnsInView() );
this.columnsInView().forEach( function( column ){
column.trigger( 'in-view', column );
});
},
- /** */
+ /** Show and enable the current columns drop target */
currentColumnDropTargetOn : function(){
var currentColumn = this.columnMap[ this.currentHistoryId ];
if( !currentColumn ){ return; }
@@ -1044,7 +1063,7 @@
currentColumn.panel.dropTargetOn();
},
- /** */
+ /** Hide and disable the current columns drop target */
currentColumnDropTargetOff : function(){
var currentColumn = this.columnMap[ this.currentHistoryId ];
if( !currentColumn ){ return; }
@@ -1053,7 +1072,7 @@
},
// ------------------------------------------------------------------------ misc
- /** */
+ /** String rep */
toString : function(){
return 'MultiPanelColumns(' + ( this.columns? this.columns.length : 0 ) + ')';
}
diff -r 633b4212806d850135a28966d9759da3157b22e8 -r ff5d57faf17d38d345105300097fc7d196f3527e static/scripts/mvc/history/multi-panel.js
--- a/static/scripts/mvc/history/multi-panel.js
+++ b/static/scripts/mvc/history/multi-panel.js
@@ -30,6 +30,7 @@
}
return name;
}
+
function copyHistory( name ){
var $copyIndicator = $( '<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>' )
.css( 'margin-top', '8px' );
@@ -69,21 +70,16 @@
/* ==============================================================================
TODO:
copy places old current in wrong location
- size not updating on dnd
- sort by size is broken
+ sort by size is confusing (but correct) - nice_size shows actual disk usage, !== size
handle delete current
currently manual by user - delete then create new - make one step
render
move all columns over as one (agg. then html())
loading indicator on startup
- loading indicators on histories (while queueHdaLoading)
- __panelPatchRenderEmptyMsg
performance
- page load takes a while
- renders where blocking each other - used _.delay( 0 )
- sort takes a while
rendering columns could be better
- lazy load history list
+ lazy load history list (for large numbers)
+ req. API limit/offset
move in-view from pubsub
handle errors
@@ -103,10 +99,11 @@
privatize non-interface fns
search for and drag and drop - should reset after dataset is loaded (or alt. clear search)
- better ajax error handling
?columns should be a panel, not have a panel
============================================================================== */
+/** @class A container for a history panel that renders controls for that history (delete, copy, etc.)
+ */
var HistoryPanelColumn = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
//TODO: extend from panel? (instead of aggregating)
@@ -120,7 +117,7 @@
},
// ------------------------------------------------------------------------ set up
- /** */
+ /** set up passed-in panel (if any) and listeners */
initialize : function initialize( options ){
options = options || {};
@@ -132,7 +129,7 @@
this.setUpListeners();
},
- /** */
+ /** create a history panel for this column */
createPanel : function createPanel( panelOptions ){
panelOptions = _.extend({
model : this.model,
@@ -148,7 +145,8 @@
},
//TODO: needs work
- /** */
+//TODO: move to stub-class to avoid monkey-patching
+ /** the function monkey-patched into panels to show contents loading state */
__patch_renderEmptyMessage : function( $whereTo ){
var panel = this,
hdaCount = _.chain( this.model.get( 'state_ids' ) ).values().flatten().value().length,
@@ -170,7 +168,7 @@
return $emptyMsg;
},
- /** */
+ /** set up reflexive listeners */
setUpListeners : function setUpListeners(){
var column = this;
//this.log( 'setUpListeners', this );
@@ -180,7 +178,7 @@
this.setUpPanelListeners();
},
- /** */
+ /** set listeners needed for panel */
setUpPanelListeners : function setUpPanelListeners(){
var column = this;
this.listenTo( this.panel, {
@@ -193,7 +191,7 @@
}, this );
},
- /** */
+ /** do the dimensions of this column overlap the given (horizontal) browser coords? */
inView : function( viewLeft, viewRight ){
//TODO: offset is expensive
var columnLeft = this.$el.offset().left,
@@ -203,13 +201,13 @@
return true;
},
- /** */
+ /** shortcut to the panel */
$panel : function $panel(){
return this.$( '.history-panel' );
},
// ------------------------------------------------------------------------ render
- /** */
+ /** render ths column, its panel, and set up plugins */
render : function render( speed ){
speed = ( speed !== undefined )?( speed ):( 'fast' );
//this.log( this + '.render', this.$el, this.el );
@@ -225,14 +223,14 @@
return this;
},
- /** */
+ /** set up plugins */
setUpBehaviors : function setUpBehaviors(){
//this.log( 'setUpBehaviors:', this );
//var column = this;
// on panel size change, ...
},
- /** */
+ /** column body template with inner div for panel based on data (model json) */
template : function template( data ){
data = data || {};
var html = [
@@ -253,6 +251,7 @@
return $( html );
},
+ /** controls template displaying controls above the panel based on this.currentHistory */
controlsLeftTemplate : function(){
return ( this.currentHistory )?
[
@@ -267,7 +266,7 @@
].join( '' );
},
- /** */
+ /** render the panel contained in the column using speed for fx speed */
renderPanel : function renderPanel( speed ){
speed = ( speed !== undefined )?( speed ):( 'fast' );
this.panel.setElement( this.$panel() ).render( speed );
@@ -275,9 +274,11 @@
},
// ------------------------------------------------------------------------ behaviors and events
- /** */
+ /** event map */
events : {
+ // will make this the current history
'click .switch-to.btn' : function(){ this.model.setAsCurrent(); },
+ // toggles deleted here and on the server and re-renders
'click .delete-history.btn' : function(){
var column = this,
xhr;
@@ -294,17 +295,18 @@
column.render();
});
},
+ // will copy this history and make the copy the current history
'click .copy-history.btn' : 'copy'
},
// ------------------------------------------------------------------------ non-current controls
- /** */
+ /** Open a modal to get a new history name, copy it (if not canceled), and makes the copy current */
copy : function copy(){
historyCopyDialog( this.model );
},
// ------------------------------------------------------------------------ misc
- /** */
+ /** String rep */
toString : function(){
return 'HistoryPanelColumn(' + ( this.panel? this.panel : '' ) + ')';
}
@@ -312,13 +314,14 @@
//==============================================================================
-// a multi-history view that displays histories in full
+/** @class A view of a HistoryCollection and displays histories similarly to the current history panel.
+ */
var MultiPanelColumns = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
//logger : console,
// ------------------------------------------------------------------------ set up
- /** */
+ /** Set up internals, history collection, and columns to display the history */
initialize : function initialize( options ){
options = options || {};
this.log( this + '.init', options );
@@ -352,8 +355,6 @@
this.collection = null;
this.setCollection( options.histories || [] );
- ///** the column views of histories */
- //this.columns = [];
/** model id to column map */
this.columnMap = {};
//TODO: why create here?
@@ -362,14 +363,16 @@
this.setUpListeners();
},
- /** */
+ /** Set up reflexive listeners */
setUpListeners : function setUpListeners(){
//var multipanel = this;
//multipanel.log( 'setUpListeners', multipanel );
},
// ------------------------------------------------------------------------ collection
- /** */
+ /** Set up a (new) history collection, sorting and adding listeners
+ * @fires 'new-collection' when set with this view as the arg
+ */
setCollection : function setCollection( models ){
var multipanel = this;
multipanel.stopListening( multipanel.collection );
@@ -383,6 +386,7 @@
return multipanel;
},
+ /** Set up listeners for the collection - handling: added histories, change of current, deletion, and sorting */
setUpCollectionListeners : function(){
var multipanel = this,
collection = multipanel.collection;
@@ -394,15 +398,16 @@
// handle deleting a history (depends on whether panels is including deleted or not)
'change:deleted': multipanel.handleDeletedHistory,
- 'sort' : function(){ multipanel.renderColumns( 0 ); },
+ 'sort' : function(){ multipanel.renderColumns( 0 ); }
+ // debugging
//'all' : function(){
// console.info( 'collection:', arguments );
//}
});
},
- /** */
+ /** Re-render and set currentHistoryId to reflect a new current history */
setCurrentHistory : function setCurrentHistory( history ){
var oldCurrentColumn = this.columnMap[ this.currentHistoryId ];
if( oldCurrentColumn ){
@@ -425,7 +430,9 @@
return newCurrentColumn;
},
- /** */
+ /** Either remove a deleted history or re-render it to show the deleted message
+ * based on collection.includeDeleted
+ */
handleDeletedHistory : function handleDeletedHistory( history ){
if( history.get( 'deleted' ) ){
this.log( 'handleDeletedHistory', this.collection.includeDeleted, history );
@@ -446,7 +453,9 @@
}
},
- /** */
+ /** Sort this collection based on order (defaulting to this.order) a string key
+ * (sorting the collection will re-render the panel)
+ */
sortCollection : function( order, options ){
order = order || this.order;
var currentHistoryId = this.currentHistoryId;
@@ -477,7 +486,7 @@
return this.collection;
},
- /** */
+ /** Set the sort order and re-sort */
setOrder : function( order ){
if( [ 'update', 'name', 'size' ].indexOf( order ) === -1 ){
order = 'update';
@@ -487,12 +496,12 @@
return this;
},
- /** */
+ /** create a new history and set it to current */
create : function( ev ){
return this.collection.create({ current: true });
},
- ///** */
+ ///** delete the current history */
//deleteCurrent : function deleteCurrent(){
// var multipanel = this,
// currentColumn = multipanel.columnMap[ multipanel.currentHistoryId ];
@@ -515,7 +524,7 @@
});
},
- /** */
+ /** create a column and its panel and set up any listeners to them */
createColumn : function createColumn( history, options ){
// options passed can be re-used, so extend them before adding the model to prevent pollution for the next
options = _.extend( {}, options, { model: history });
@@ -525,10 +534,6 @@
return column;
},
- columnMapLength : function(){
- return Object.keys( this.columnMap ).length;
- },
-
sortedFilteredColumns : function( filters ){
filters = filters || this.filters;
if( !filters || !filters.length ){
@@ -598,7 +603,7 @@
});
},
- /** */
+ /** set up listeners for a column and it's panel - handling: hda lazy-loading, drag and drop */
setUpColumnListeners : function setUpColumnListeners( column ){
var multipanel = this;
multipanel.listenTo( column, {
@@ -641,8 +646,13 @@
},
+ /** conv. fn to count the columns in columnMap */
+ columnMapLength : function(){
+ return Object.keys( this.columnMap ).length;
+ },
+
// ------------------------------------------------------------------------ render
- /** */
+ /** Render this view, columns, and set up view plugins */
render : function render( speed ){
speed = speed !== undefined? speed: this.fxSpeed;
var multipanel = this;
@@ -660,14 +670,16 @@
return multipanel;
},
- /** */
+ /** Template - overall structure relies on flex-boxes and is 3 components: header, middle, footer */
template : function template( options ){
options = options || {};
var html = [];
if( this.options.headerHeight ){
html = html.concat([
+ // a loading overlay
'<div class="loading-overlay flex-row"><div class="loading-overlay-message">loading...</div></div>',
'<div class="header flex-column-container">',
+ // page & history controls
'<div class="header-control header-control-left flex-column">',
'<button class="done btn btn-default">', _l( 'Done' ), '</button>',
'<button class="include-deleted btn btn-default"></button>',
@@ -689,10 +701,12 @@
'</div>',
'<div id="search-histories" class="header-search"></div>',
'</div>',
+ // feedback
'<div class="header-control header-control-center flex-column">',
'<div class="header-info">',
'</div>',
'</div>',
+ // dataset controls
'<div class="header-control header-control-right flex-column">',
'<div id="search-datasets" class="header-search"></div>',
'<button id="toggle-deleted" class="btn btn-default">',
@@ -707,15 +721,17 @@
}
html = html.concat([
+ // middle - where the columns go
'<div class="outer-middle flex-row flex-row-container">',
'<div class="middle flex-column-container flex-row"></div>',
'</div>',
+ // footer
'<div class="footer flex-column-container">','</div>'
]);
return $( html.join( '' ) );
},
- /** */
+ /** Render the columns and panels */
renderColumns : function renderColumns( speed ){
speed = speed !== undefined? speed: this.fxSpeed;
//this.log( 'renderColumns:', speed );
@@ -780,14 +796,16 @@
if( this.searchFor && sortedAndFiltered.length <= 1 ){
} else {
+ // check for in-view, hda lazy-loading if so
multipanel.checkColumnsInView();
+ // the first, current column has position: fixed and flex css will not apply - adjust height manually
this._recalcFirstColumnHeight();
}
return sortedAndFiltered;
},
- /** */
+ /** Render a single column using the non-blocking setTimeout( 0 ) pattern */
renderColumn : function( column, speed ){
speed = speed !== undefined? speed: this.fxSpeed;
return _.delay( function(){ return column.render( speed ); }, 0 );
@@ -796,7 +814,9 @@
//TODO: combine the following two more sensibly
//TODO: could have HistoryContents.haveDetails return false
// if column.model.contents.length === 0 && !column.model.get( 'empty' ) then just check that
- /** */
+ /** Get the *summary* contents of a column's history (and details on any expanded contents),
+ * queueing the ajax call and using a named queue to prevent the call being sent twice
+ */
queueHdaFetch : function queueHdaFetch( column ){
//this.log( 'queueHdaFetch:', column );
// if the history model says it has hdas but none are present, queue an ajax req for them
@@ -822,7 +842,7 @@
}
},
- /** */
+ /** Get the *detailed* json for *all* of a column's history's contents - req'd for searching */
queueHdaFetchDetails : function( column ){
if( ( column.model.contents.length === 0 && !column.model.get( 'empty' ) )
|| ( !column.model.contents.haveDetails() ) ){
@@ -841,11 +861,7 @@
}
},
- /** */
- allColumns : function allColumns(){
- return [ this.currentColumn ].concat( this.columns );
- },
-
+ /** put a text msg in the header */
renderInfo : function( msg ){
this.$( '.header .header-info' ).text( msg );
},
@@ -853,9 +869,13 @@
// ------------------------------------------------------------------------ events/behaviors
/** */
events : {
+ // will move to the server root (gen. Analyze data)
'click .done.btn' : function(){ window.location = '/'; },
+ //TODO:?? could just go back - but that's not always correct/desired behav.
//'click .done.btn' : function(){ window.history.back(); },
+ // creates a new empty history and makes it current
'click .create-new.btn' : 'create',
+ // these change the collection and column sort order
'click .order .order-update' : function( e ){ this.setOrder( 'update' ); },
'click .order .order-name' : function( e ){ this.setOrder( 'name' ); },
'click .order .order-size' : function( e ){ this.setOrder( 'size' ); }
@@ -863,22 +883,25 @@
//'dragstart .list-item .title-bar' : function( e ){ console.debug( 'ok' ); }
},
+ /** Include deleted histories in the collection */
includeDeletedHistories : function(){
//TODO: better through API/limit+offset
window.location += ( /\?/.test( window.location.toString() ) )?( '&' ):( '?' )
+ 'include_deleted_histories=True';
},
+ /** Show only non-deleted histories */
excludeDeletedHistories : function(){
//TODO: better through API/limit+offset
window.location = window.location.toString().replace( /[&\?]include_deleted_histories=True/g, '' );
},
- /** */
+ /** Set up any view plugins */
setUpBehaviors : function(){
var multipanel = this;
//TODO: currently doesn't need to be a mode button
+ // toggle button for include deleted
multipanel.$( '.include-deleted' ).modeButton({
initialMode : this.collection.includeDeleted? 'exclude' : 'include',
switchModesOnClick : false,
@@ -949,6 +972,7 @@
});
//TODO: each panel stores the hidden/deleted state - and that isn't reflected in the buttons
+ // toggle button for showing deleted history contents
multipanel.$( '#toggle-deleted' ).modeButton({
initialMode : 'include',
modes: [
@@ -964,6 +988,7 @@
});
});
+ // toggle button for showing hidden history contents
multipanel.$( '#toggle-hidden' ).modeButton({
initialMode : 'include',
modes: [
@@ -990,33 +1015,26 @@
this.$( '.middle' ).parent().scroll( debouncedInView );
},
+ ///** Put the in-view columns then the other columns in a queue, rendering each one at a time */
//panelRenderQueue : function( columns, fn, args, renderEventName ){
//},
+ /** Adjust the height of the first, current column since flex-boxes won't work with fixed postiion elements */
_recalcFirstColumnHeight : function(){
- //var currentColumn = this.columnMap[ this.currentHistoryId ];
- //if( !currentColumn ){ return; }
var $firstColumn = this.$( '.history-column' ).first(),
middleHeight = this.$( '.middle' ).height(),
controlHeight = $firstColumn.find( '.panel-controls' ).height();
$firstColumn.height( middleHeight )
.find( '.inner' ).height( middleHeight - controlHeight );
-
-//console.debug( '$firstColumn:', $firstColumn );
- //var currentColumn = this.columnMap[ this.currentHistoryId ];
- //if( !currentColumn ){ return; }
- //var middleHeight = this.$( '.middle' ).height(),
- // controlHeight = currentColumn.$( '.panel-controls' ).height();
- //currentColumn.$el.height( middleHeight )
- // .find( '.inner' ).height( middleHeight - controlHeight );
},
+ /** Get the left and right pixel coords of the middle element */
_viewport : function(){
var viewLeft = this.$( '.middle' ).parent().offset().left;
return { left: viewLeft, right: viewLeft + this.$( '.middle' ).parent().width() };
},
- /** */
+ /** returns the columns currently in the viewport */
columnsInView : function(){
//TODO: uses offset which is render intensive
//TODO: 2N - could use arg filter (sortedFilteredColumns( filter )) instead
@@ -1027,15 +1045,16 @@
},
//TODO: sortByInView - return cols in view, then others
- /** */
+ /** trigger in-view from columns in-view */
checkColumnsInView : function(){
+//TODO: assbackward
//console.debug( 'checking columns in view', this.columnsInView() );
this.columnsInView().forEach( function( column ){
column.trigger( 'in-view', column );
});
},
- /** */
+ /** Show and enable the current columns drop target */
currentColumnDropTargetOn : function(){
var currentColumn = this.columnMap[ this.currentHistoryId ];
if( !currentColumn ){ return; }
@@ -1044,7 +1063,7 @@
currentColumn.panel.dropTargetOn();
},
- /** */
+ /** Hide and disable the current columns drop target */
currentColumnDropTargetOff : function(){
var currentColumn = this.columnMap[ this.currentHistoryId ];
if( !currentColumn ){ return; }
@@ -1053,7 +1072,7 @@
},
// ------------------------------------------------------------------------ misc
- /** */
+ /** String rep */
toString : function(){
return 'MultiPanelColumns(' + ( this.columns? this.columns.length : 0 ) + ')';
}
diff -r 633b4212806d850135a28966d9759da3157b22e8 -r ff5d57faf17d38d345105300097fc7d196f3527e static/scripts/packed/mvc/history/multi-panel.js
--- a/static/scripts/packed/mvc/history/multi-panel.js
+++ b/static/scripts/packed/mvc/history/multi-panel.js
@@ -1,1 +1,1 @@
-define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue"],function(d,m,A,a){window.HISTORY_MODEL=d;function g(I,F){F=F||{};if(!(Galaxy&&Galaxy.modal)){return I.copy()}var G=I.get("name"),D="Copy of '"+G+"'";function E(K){if(!K){if(!Galaxy.modal.$("#invalid-title").size()){var J=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(J)}return false}return K}function H(J){var K=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(K);I.copy(true,J).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+G+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',D,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:function(){var J=Galaxy.modal.$("#copy-modal-title").val();if(!E(J)){return}H(J)}}},F));$("#copy-modal-title").focus().select()}var C=Backbone.View.extend(A.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function r(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(D){D=D||{};this.panel=D.panel||this.createPanel(D);this.setUpListeners()},createPanel:function v(E){E=_.extend({model:this.model,dragItems:true},E);var D=new m.HistoryPanelEdit(E);D._renderEmptyMessage=this.__patch_renderEmptyMessage;return D},__patch_renderEmptyMessage:function(F){var E=this,G=_.chain(this.model.get("state_ids")).values().flatten().value().length,D=E.$emptyMessage(F);if(!_.isEmpty(E.hdaViews)){D.hide()}else{if(G&&!this.model.contents.length){D.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(E.searchFor){D.text(E.noneFoundMsg).show()}else{D.text(E.emptyMsg).show()}}}return D},setUpListeners:function f(){var D=this;this.once("rendered",function(){D.trigger("rendered:initial",D)});this.setUpPanelListeners()},setUpPanelListeners:function l(){var D=this;this.listenTo(this.panel,{rendered:function(){D.trigger("rendered",D)}},this)},inView:function(D,E){var G=this.$el.offset().left,F=G+this.$el.width();if(F<D){return false}if(G>E){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function B(E){E=(E!==undefined)?(E):("fast");var D=this.model?this.model.toJSON():{};this.$el.html(this.template(D));this.renderPanel(E);this.setUpBehaviors();return this},setUpBehaviors:function w(){},template:function x(E){E=E||{};var D=['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate(),'<div class="pull-right">','<button class="delete-history btn btn-default">',E.deleted?_l("Undelete"):_l("Delete"),"</button>",'<button class="copy-history btn btn-default">',_l("Copy"),"</button>","</div>","</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',E.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join("");return $(D)},controlsLeftTemplate:function(){return(this.currentHistory)?['<div class="pull-left">','<button class="create-new btn btn-default">',_l("Create new"),"</button> ","</div>"].join(""):['<div class="pull-left">','<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","</div>"].join("")},renderPanel:function i(D){D=(D!==undefined)?(D):("fast");this.panel.setElement(this.$panel()).render(D);return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history.btn":function(){var D=this,E;if(this.model.get("deleted")){E=this.model.undelete()}else{E=this.model._delete()}E.fail(function(H,F,G){alert(_l("Could not delete the history")+":\n"+G)}).done(function(F){D.render()})},"click .copy-history.btn":"copy"},copy:function t(){g(this.model)},toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var n=Backbone.View.extend(A.LoggableMixin).extend({initialize:function c(D){D=D||{};this.log(this+".init",D);if(!D.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=D.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=D.order||"update";this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(D.histories||[]);this.columnMap={};this.createColumns(D.columnOptions);this.setUpListeners()},setUpListeners:function f(){},setCollection:function z(E){var D=this;D.stopListening(D.collection);D.collection=E;D.sortCollection(D.order,{silent:true});D.setUpCollectionListeners();D.trigger("new-collection",D);return D},setUpCollectionListeners:function(){var D=this,E=D.collection;D.listenTo(E,{add:D.addAsCurrentColumn,"set-as-current":D.setCurrentHistory,"change:deleted":D.handleDeletedHistory,sort:function(){D.renderColumns(0)},})},setCurrentHistory:function q(E){var D=this.columnMap[this.currentHistoryId];if(D){D.currentHistory=false;D.$el.height("")}this.currentHistoryId=E.id;var F=this.columnMap[this.currentHistoryId];F.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return F},handleDeletedHistory:function b(E){if(E.get("deleted")){this.log("handleDeletedHistory",this.collection.includeDeleted,E);var D=this;column=D.columnMap[E.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!D.collection.includeDeleted){D.removeColumn(column)}}}},sortCollection:function(D,E){D=D||this.order;var F=this.currentHistoryId;switch(D){case"name":this.collection.comparator=function(G){return[G.id!==F,G.get("name").toLowerCase()]};break;case"size":this.collection.comparator=function(G){return[G.id!==F,G.get("size")]};break;default:this.collection.comparator=function(G){return[G.id!==F,Date(G.get("update_time"))]}}this.collection.sort(E);return this.collection},setOrder:function(D){if(["update","name","size"].indexOf(D)===-1){D="update"}this.order=D;this.sortCollection();return this},create:function(D){return this.collection.create({current:true})},createColumns:function s(E){E=E||{};var D=this;this.columnMap={};D.collection.each(function(F,G){var H=D.createColumn(F,E);D.columnMap[F.id]=H})},createColumn:function u(F,D){D=_.extend({},D,{model:F});var E=new C(D);if(F.id===this.currentHistoryId){E.currentHistory=true}this.setUpColumnListeners(E);return E},columnMapLength:function(){return Object.keys(this.columnMap).length},sortedFilteredColumns:function(D){D=D||this.filters;if(!D||!D.length){return this.sortedColumns()}var E=this;return E.sortedColumns().filter(function(H,G){var F=H.currentHistory||_.every(D.map(function(I){return I.call(H)}));return F})},sortedColumns:function(){var E=this;var D=this.collection.map(function(G,F){return E.columnMap[G.id]});return D},addColumn:function p(F,D){D=D!==undefined?D:true;var E=this.createColumn(F);this.columnMap[F.id]=E;if(D){this.renderColumns()}return E},addAsCurrentColumn:function p(F){var E=this,D=this.addColumn(F,false);this.setCurrentHistory(F);D.once("rendered",function(){E.queueHdaFetch(D)});return D},removeColumn:function y(F,E){E=E!==undefined?E:true;this.log("removeColumn",F);if(!F){return}var G=this,D=this.options.columnWidth+this.options.columnGap;F.$el.fadeOut("fast",function(){if(E){$(this).remove();G.$(".middle").width(G.$(".middle").width()-D);G.checkColumnsInView();G._recalcFirstColumnHeight()}G.stopListening(F.panel);G.stopListening(F);delete G.columnMap[F.model.id];F.remove()})},setUpColumnListeners:function o(D){var E=this;E.listenTo(D,{"in-view":E.queueHdaFetch});E.listenTo(D.panel,{"view:draggable:dragstart":function(I,G,F,H){E._dropData=JSON.parse(I.dataTransfer.getData("text"));E.currentColumnDropTargetOn()},"view:draggable:dragend":function(I,G,F,H){E._dropData=null;E.currentColumnDropTargetOff()},"droptarget:drop":function(H,I,G){var J=E._dropData.filter(function(K){return(_.isObject(K)&&K.id&&K.model_class==="HistoryDatasetAssociation")});E._dropData=null;var F=new a.NamedAjaxQueue();J.forEach(function(K){F.add({name:"copy-"+K.id,fn:function(){return G.model.contents.copy(K.id)}})});F.start();F.done(function(K){G.model.fetch()})}})},render:function B(E){E=E!==undefined?E:this.fxSpeed;var D=this;D.log(D+".render");D.$el.html(D.template(D.options));D.renderColumns(E);D.setUpBehaviors();D.trigger("rendered",D);return D},template:function x(D){D=D||{};var E=[];if(this.options.headerHeight){E=E.concat(['<div class="loading-overlay flex-row"><div class="loading-overlay-message">loading...</div></div>','<div class="header flex-column-container">','<div class="header-control header-control-left flex-column">','<button class="done btn btn-default">',_l("Done"),"</button>",'<button class="include-deleted btn btn-default"></button>','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+'... <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="javascript:void(0);" class="order-update">',_l("Time of last update"),"</a></li>",'<li><a href="javascript:void(0);" class="order-name">',_l("Name"),"</a></li>",'<li><a href="javascript:void(0);" class="order-size">',_l("Size"),"</a></li>","</ul>","</div>",'<div id="search-histories" class="header-search"></div>',"</div>",'<div class="header-control header-control-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="header-control header-control-right flex-column">','<div id="search-datasets" class="header-search"></div>','<button id="toggle-deleted" class="btn btn-default">',_l("Include deleted datasets"),"</button>",'<button id="toggle-hidden" class="btn btn-default">',_l("Include hidden datasets"),"</button>","</div>","</div>"])}E=E.concat(['<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"]);return $(E.join(""))},renderColumns:function k(G){G=G!==undefined?G:this.fxSpeed;var F=this,D=F.sortedFilteredColumns();F.$(".middle").width(D.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var E=F.$(".middle");E.empty();D.forEach(function(I,H){I.$el.appendTo(E);I.delegateEvents();F.renderColumn(I,G)});if(this.searchFor&&D.length<=1){}else{F.checkColumnsInView();this._recalcFirstColumnHeight()}return D},renderColumn:function(D,E){E=E!==undefined?E:this.fxSpeed;return _.delay(function(){return D.render(E)},0)},queueHdaFetch:function j(F){if(F.model.contents.length===0&&!F.model.get("empty")){var D={},E=_.values(F.panel.storage.get("expandedIds")).join();if(E){D.dataset_details=E}this.hdaQueue.add({name:F.model.id,fn:function(){var G=F.model.contents.fetch({data:D,silent:true});return G.done(function(H){F.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(D){if((D.model.contents.length===0&&!D.model.get("empty"))||(!D.model.contents.haveDetails())){this.hdaQueue.add({name:D.model.id,fn:function(){var E=D.model.contents.fetch({data:{details:"all"},silent:true});return E.done(function(F){D.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},allColumns:function h(){return[this.currentColumn].concat(this.columns)},renderInfo:function(D){this.$(".header .header-info").text(D)},events:{"click .done.btn":function(){window.location="/"},"click .create-new.btn":"create","click .order .order-update":function(D){this.setOrder("update")},"click .order .order-name":function(D){this.setOrder("name")},"click .order .order-size":function(D){this.setOrder("size")}},includeDeletedHistories:function(){window.location+=(/\?/.test(window.location.toString()))?("&"):("?")+"include_deleted_histories=True"},excludeDeletedHistories:function(){window.location=window.location.toString().replace(/[&\?]include_deleted_histories=True/g,"")},setUpBehaviors:function(){var E=this;E.$(".include-deleted").modeButton({initialMode:this.collection.includeDeleted?"exclude":"include",switchModesOnClick:false,modes:[{mode:"include",html:_l("Include deleted histories"),onclick:_.bind(E.includeDeletedHistories,E)},{mode:"exclude",html:_l("Exclude deleted histories"),onclick:_.bind(E.excludeDeletedHistories,E)}]});E.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(F){E.searchFor=F;E.filters=[function(){return this.model.get("name").indexOf(E.searchFor)!==-1}];E.renderColumns(0)},onclear:function(F){E.searchFor=null;E.filters=[];E.renderColumns(0)}});E.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(F){E.hdaQueue.clear();E.$("#search-datasets").searchInput("toggle-loading");E.searchFor=F;E.sortedFilteredColumns().forEach(function(G){G.panel.searchItems(F);E.queueHdaFetchDetails(G)});E.hdaQueue.progress(function(G){E.renderInfo([_l("loading"),(G.curr+1),_l("of"),G.total].join(" "))});E.hdaQueue.deferred.done(function(){E.renderInfo("");E.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(F){E.searchFor=F;E.sortedFilteredColumns().forEach(function(G){G.panel.searchItems(F)})},onclear:function(F){E.searchFor=null;E.sortedFilteredColumns().forEach(function(G){G.panel.clearSearch()})}});E.$("#toggle-deleted").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude deleted datasets")},{mode:"include",html:_l("Include deleted datasets")}]}).click(function(){var F=$(this).modeButton("getMode").mode==="exclude";E.sortedFilteredColumns().forEach(function(H,G){_.delay(function(){H.panel.toggleShowDeleted(F,false)},G*200)})});E.$("#toggle-hidden").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude hidden datasets")},{mode:"include",html:_l("Include hidden datasets")}]}).click(function(){var F=$(this).modeButton("getMode").mode==="exclude";E.sortedFilteredColumns().forEach(function(H,G){_.delay(function(){H.panel.toggleShowHidden(F,false)},G*200)})});$(window).resize(function(){E._recalcFirstColumnHeight()});var D=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(D)},_recalcFirstColumnHeight:function(){var D=this.$(".history-column").first(),F=this.$(".middle").height(),E=D.find(".panel-controls").height();D.height(F).find(".inner").height(F-E)},_viewport:function(){var D=this.$(".middle").parent().offset().left;return{left:D,right:D+this.$(".middle").parent().width()}},columnsInView:function(){var D=this._viewport();return this.sortedFilteredColumns().filter(function(E){return E.currentHistory||E.inView(D.left,D.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(D){D.trigger("in-view",D)})},currentColumnDropTargetOn:function(){var D=this.columnMap[this.currentHistoryId];if(!D){return}D.panel.dataDropped=function(E){};D.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var D=this.columnMap[this.currentHistoryId];if(!D){return}D.panel.dataDropped=m.HistoryPanelEdit.prototype.dataDrop;D.panel.dropTargetOff()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"}});return{MultiPanelColumns:n}});
\ No newline at end of file
+define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue"],function(d,l,z,a){window.HISTORY_MODEL=d;function g(H,E){E=E||{};if(!(Galaxy&&Galaxy.modal)){return H.copy()}var F=H.get("name"),C="Copy of '"+F+"'";function D(J){if(!J){if(!Galaxy.modal.$("#invalid-title").size()){var I=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(I)}return false}return J}function G(I){var J=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(J);H.copy(true,I).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+F+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',C,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:function(){var I=Galaxy.modal.$("#copy-modal-title").val();if(!D(I)){return}G(I)}}},E));$("#copy-modal-title").focus().select()}var B=Backbone.View.extend(z.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function q(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(C){C=C||{};this.panel=C.panel||this.createPanel(C);this.setUpListeners()},createPanel:function u(D){D=_.extend({model:this.model,dragItems:true},D);var C=new l.HistoryPanelEdit(D);C._renderEmptyMessage=this.__patch_renderEmptyMessage;return C},__patch_renderEmptyMessage:function(E){var D=this,F=_.chain(this.model.get("state_ids")).values().flatten().value().length,C=D.$emptyMessage(E);if(!_.isEmpty(D.hdaViews)){C.hide()}else{if(F&&!this.model.contents.length){C.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(D.searchFor){C.text(D.noneFoundMsg).show()}else{C.text(D.emptyMsg).show()}}}return C},setUpListeners:function f(){var C=this;this.once("rendered",function(){C.trigger("rendered:initial",C)});this.setUpPanelListeners()},setUpPanelListeners:function k(){var C=this;this.listenTo(this.panel,{rendered:function(){C.trigger("rendered",C)}},this)},inView:function(C,D){var F=this.$el.offset().left,E=F+this.$el.width();if(E<C){return false}if(F>D){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function A(D){D=(D!==undefined)?(D):("fast");var C=this.model?this.model.toJSON():{};this.$el.html(this.template(C));this.renderPanel(D);this.setUpBehaviors();return this},setUpBehaviors:function v(){},template:function w(D){D=D||{};var C=['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate(),'<div class="pull-right">','<button class="delete-history btn btn-default">',D.deleted?_l("Undelete"):_l("Delete"),"</button>",'<button class="copy-history btn btn-default">',_l("Copy"),"</button>","</div>","</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',D.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join("");return $(C)},controlsLeftTemplate:function(){return(this.currentHistory)?['<div class="pull-left">','<button class="create-new btn btn-default">',_l("Create new"),"</button> ","</div>"].join(""):['<div class="pull-left">','<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","</div>"].join("")},renderPanel:function h(C){C=(C!==undefined)?(C):("fast");this.panel.setElement(this.$panel()).render(C);return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history.btn":function(){var C=this,D;if(this.model.get("deleted")){D=this.model.undelete()}else{D=this.model._delete()}D.fail(function(G,E,F){alert(_l("Could not delete the history")+":\n"+F)}).done(function(E){C.render()})},"click .copy-history.btn":"copy"},copy:function s(){g(this.model)},toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var m=Backbone.View.extend(z.LoggableMixin).extend({initialize:function c(C){C=C||{};this.log(this+".init",C);if(!C.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=C.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=C.order||"update";this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(C.histories||[]);this.columnMap={};this.createColumns(C.columnOptions);this.setUpListeners()},setUpListeners:function f(){},setCollection:function y(D){var C=this;C.stopListening(C.collection);C.collection=D;C.sortCollection(C.order,{silent:true});C.setUpCollectionListeners();C.trigger("new-collection",C);return C},setUpCollectionListeners:function(){var C=this,D=C.collection;C.listenTo(D,{add:C.addAsCurrentColumn,"set-as-current":C.setCurrentHistory,"change:deleted":C.handleDeletedHistory,sort:function(){C.renderColumns(0)}})},setCurrentHistory:function p(D){var C=this.columnMap[this.currentHistoryId];if(C){C.currentHistory=false;C.$el.height("")}this.currentHistoryId=D.id;var E=this.columnMap[this.currentHistoryId];E.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return E},handleDeletedHistory:function b(D){if(D.get("deleted")){this.log("handleDeletedHistory",this.collection.includeDeleted,D);var C=this;column=C.columnMap[D.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!C.collection.includeDeleted){C.removeColumn(column)}}}},sortCollection:function(C,D){C=C||this.order;var E=this.currentHistoryId;switch(C){case"name":this.collection.comparator=function(F){return[F.id!==E,F.get("name").toLowerCase()]};break;case"size":this.collection.comparator=function(F){return[F.id!==E,F.get("size")]};break;default:this.collection.comparator=function(F){return[F.id!==E,Date(F.get("update_time"))]}}this.collection.sort(D);return this.collection},setOrder:function(C){if(["update","name","size"].indexOf(C)===-1){C="update"}this.order=C;this.sortCollection();return this},create:function(C){return this.collection.create({current:true})},createColumns:function r(D){D=D||{};var C=this;this.columnMap={};C.collection.each(function(E,F){var G=C.createColumn(E,D);C.columnMap[E.id]=G})},createColumn:function t(E,C){C=_.extend({},C,{model:E});var D=new B(C);if(E.id===this.currentHistoryId){D.currentHistory=true}this.setUpColumnListeners(D);return D},sortedFilteredColumns:function(C){C=C||this.filters;if(!C||!C.length){return this.sortedColumns()}var D=this;return D.sortedColumns().filter(function(G,F){var E=G.currentHistory||_.every(C.map(function(H){return H.call(G)}));return E})},sortedColumns:function(){var D=this;var C=this.collection.map(function(F,E){return D.columnMap[F.id]});return C},addColumn:function o(E,C){C=C!==undefined?C:true;var D=this.createColumn(E);this.columnMap[E.id]=D;if(C){this.renderColumns()}return D},addAsCurrentColumn:function o(E){var D=this,C=this.addColumn(E,false);this.setCurrentHistory(E);C.once("rendered",function(){D.queueHdaFetch(C)});return C},removeColumn:function x(E,D){D=D!==undefined?D:true;this.log("removeColumn",E);if(!E){return}var F=this,C=this.options.columnWidth+this.options.columnGap;E.$el.fadeOut("fast",function(){if(D){$(this).remove();F.$(".middle").width(F.$(".middle").width()-C);F.checkColumnsInView();F._recalcFirstColumnHeight()}F.stopListening(E.panel);F.stopListening(E);delete F.columnMap[E.model.id];E.remove()})},setUpColumnListeners:function n(C){var D=this;D.listenTo(C,{"in-view":D.queueHdaFetch});D.listenTo(C.panel,{"view:draggable:dragstart":function(H,F,E,G){D._dropData=JSON.parse(H.dataTransfer.getData("text"));D.currentColumnDropTargetOn()},"view:draggable:dragend":function(H,F,E,G){D._dropData=null;D.currentColumnDropTargetOff()},"droptarget:drop":function(G,H,F){var I=D._dropData.filter(function(J){return(_.isObject(J)&&J.id&&J.model_class==="HistoryDatasetAssociation")});D._dropData=null;var E=new a.NamedAjaxQueue();I.forEach(function(J){E.add({name:"copy-"+J.id,fn:function(){return F.model.contents.copy(J.id)}})});E.start();E.done(function(J){F.model.fetch()})}})},columnMapLength:function(){return Object.keys(this.columnMap).length},render:function A(D){D=D!==undefined?D:this.fxSpeed;var C=this;C.log(C+".render");C.$el.html(C.template(C.options));C.renderColumns(D);C.setUpBehaviors();C.trigger("rendered",C);return C},template:function w(C){C=C||{};var D=[];if(this.options.headerHeight){D=D.concat(['<div class="loading-overlay flex-row"><div class="loading-overlay-message">loading...</div></div>','<div class="header flex-column-container">','<div class="header-control header-control-left flex-column">','<button class="done btn btn-default">',_l("Done"),"</button>",'<button class="include-deleted btn btn-default"></button>','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+'... <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="javascript:void(0);" class="order-update">',_l("Time of last update"),"</a></li>",'<li><a href="javascript:void(0);" class="order-name">',_l("Name"),"</a></li>",'<li><a href="javascript:void(0);" class="order-size">',_l("Size"),"</a></li>","</ul>","</div>",'<div id="search-histories" class="header-search"></div>',"</div>",'<div class="header-control header-control-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="header-control header-control-right flex-column">','<div id="search-datasets" class="header-search"></div>','<button id="toggle-deleted" class="btn btn-default">',_l("Include deleted datasets"),"</button>",'<button id="toggle-hidden" class="btn btn-default">',_l("Include hidden datasets"),"</button>","</div>","</div>"])}D=D.concat(['<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"]);return $(D.join(""))},renderColumns:function j(F){F=F!==undefined?F:this.fxSpeed;var E=this,C=E.sortedFilteredColumns();E.$(".middle").width(C.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var D=E.$(".middle");D.empty();C.forEach(function(H,G){H.$el.appendTo(D);H.delegateEvents();E.renderColumn(H,F)});if(this.searchFor&&C.length<=1){}else{E.checkColumnsInView();this._recalcFirstColumnHeight()}return C},renderColumn:function(C,D){D=D!==undefined?D:this.fxSpeed;return _.delay(function(){return C.render(D)},0)},queueHdaFetch:function i(E){if(E.model.contents.length===0&&!E.model.get("empty")){var C={},D=_.values(E.panel.storage.get("expandedIds")).join();if(D){C.dataset_details=D}this.hdaQueue.add({name:E.model.id,fn:function(){var F=E.model.contents.fetch({data:C,silent:true});return F.done(function(G){E.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(C){if((C.model.contents.length===0&&!C.model.get("empty"))||(!C.model.contents.haveDetails())){this.hdaQueue.add({name:C.model.id,fn:function(){var D=C.model.contents.fetch({data:{details:"all"},silent:true});return D.done(function(E){C.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},renderInfo:function(C){this.$(".header .header-info").text(C)},events:{"click .done.btn":function(){window.location="/"},"click .create-new.btn":"create","click .order .order-update":function(C){this.setOrder("update")},"click .order .order-name":function(C){this.setOrder("name")},"click .order .order-size":function(C){this.setOrder("size")}},includeDeletedHistories:function(){window.location+=(/\?/.test(window.location.toString()))?("&"):("?")+"include_deleted_histories=True"},excludeDeletedHistories:function(){window.location=window.location.toString().replace(/[&\?]include_deleted_histories=True/g,"")},setUpBehaviors:function(){var D=this;D.$(".include-deleted").modeButton({initialMode:this.collection.includeDeleted?"exclude":"include",switchModesOnClick:false,modes:[{mode:"include",html:_l("Include deleted histories"),onclick:_.bind(D.includeDeletedHistories,D)},{mode:"exclude",html:_l("Exclude deleted histories"),onclick:_.bind(D.excludeDeletedHistories,D)}]});D.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(E){D.searchFor=E;D.filters=[function(){return this.model.get("name").indexOf(D.searchFor)!==-1}];D.renderColumns(0)},onclear:function(E){D.searchFor=null;D.filters=[];D.renderColumns(0)}});D.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(E){D.hdaQueue.clear();D.$("#search-datasets").searchInput("toggle-loading");D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E);D.queueHdaFetchDetails(F)});D.hdaQueue.progress(function(F){D.renderInfo([_l("loading"),(F.curr+1),_l("of"),F.total].join(" "))});D.hdaQueue.deferred.done(function(){D.renderInfo("");D.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(E){D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E)})},onclear:function(E){D.searchFor=null;D.sortedFilteredColumns().forEach(function(F){F.panel.clearSearch()})}});D.$("#toggle-deleted").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude deleted datasets")},{mode:"include",html:_l("Include deleted datasets")}]}).click(function(){var E=$(this).modeButton("getMode").mode==="exclude";D.sortedFilteredColumns().forEach(function(G,F){_.delay(function(){G.panel.toggleShowDeleted(E,false)},F*200)})});D.$("#toggle-hidden").modeButton({initialMode:"include",modes:[{mode:"exclude",html:_l("Exclude hidden datasets")},{mode:"include",html:_l("Include hidden datasets")}]}).click(function(){var E=$(this).modeButton("getMode").mode==="exclude";D.sortedFilteredColumns().forEach(function(G,F){_.delay(function(){G.panel.toggleShowHidden(E,false)},F*200)})});$(window).resize(function(){D._recalcFirstColumnHeight()});var C=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(C)},_recalcFirstColumnHeight:function(){var C=this.$(".history-column").first(),E=this.$(".middle").height(),D=C.find(".panel-controls").height();C.height(E).find(".inner").height(E-D)},_viewport:function(){var C=this.$(".middle").parent().offset().left;return{left:C,right:C+this.$(".middle").parent().width()}},columnsInView:function(){var C=this._viewport();return this.sortedFilteredColumns().filter(function(D){return D.currentHistory||D.inView(C.left,C.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(C){C.trigger("in-view",C)})},currentColumnDropTargetOn:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=function(D){};C.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=l.HistoryPanelEdit.prototype.dataDrop;C.panel.dropTargetOff()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"}});return{MultiPanelColumns:m}});
\ 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.
1
0
commit/galaxy-central: carlfeberhard: History multi-view: initial commit of page to show all user histories in panel form (the page is currently orphaned/unwired - go to <root>/history/view_multiple to see the page)
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/633b4212806d/
Changeset: 633b4212806d
User: carlfeberhard
Date: 2014-09-29 13:47:18+00:00
Summary: History multi-view: initial commit of page to show all user histories in panel form (the page is currently orphaned/unwired - go to <root>/history/view_multiple to see the page)
Affected #: 30 files
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/mvc/base-mvc.js
--- a/client/galaxy/scripts/mvc/base-mvc.js
+++ b/client/galaxy/scripts/mvc/base-mvc.js
@@ -380,11 +380,6 @@
/** allow the view to be dragged, set up event handlers */
draggableOn : function(){
this.draggable = true;
- //TODO: I have no idea why this doesn't work with the events hash or jq.on()...
- //this.$el.find( '.title-bar' )
- // .attr( 'draggable', true )
- // .bind( 'dragstart', this.dragStartHandler, false )
- // .bind( 'dragend', this.dragEndHandler, false );
this.dragStartHandler = _.bind( this._dragStartHandler, this );
this.dragEndHandler = _.bind( this._dragEndHandler, this );
@@ -402,23 +397,22 @@
},
/** sets the dataTransfer data to the model's toJSON
- * @fires dragstart (bbone event) which is passed this view
+ * @fires draggable:dragstart (bbone event) which is passed the event and this view
*/
_dragStartHandler : function( event ){
- //this.debug( 'dragStartHandler:', this, event, arguments )
- this.trigger( 'dragstart', this );
event.dataTransfer.effectAllowed = 'move';
+ //ASSUMES: this.model
//TODO: all except IE: should be 'application/json', IE: must be 'text'
event.dataTransfer.setData( 'text', JSON.stringify( this.model.toJSON() ) );
+ this.trigger( 'draggable:dragstart', event, this );
return false;
},
/** handle the dragend
- * @fires dragend (bbone event) which is passed this view
+ * @fires draggable:dragend (bbone event) which is passed the event and this view
*/
_dragEndHandler : function( event ){
- this.trigger( 'dragend', this );
- //this.debug( 'dragEndHandler:', event )
+ this.trigger( 'draggable:dragend', event, this );
return false;
}
};
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 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
@@ -181,6 +181,8 @@
}
var $visualizations = $( this.templates.visualizations( visualizations, this ) );
+ //HACK: need to re-write those directed at galaxy_main with linkTarget
+ $visualizations.find( '[target="galaxy_main"]').attr( 'target', this.linkTarget );
// use addBack here to include the root $visualizations elem (for the case of 1 visualization)
this._addScratchBookFn( $visualizations.find( '.visualization-link' ).addBack( '.visualization-link' ) );
return $visualizations;
@@ -188,6 +190,7 @@
/** add scratchbook functionality to visualization links */
_addScratchBookFn : function( $links ){
+ var li = this;
$links.click( function( ev ){
if( Galaxy.frame && Galaxy.frame.active ){
Galaxy.frame.add({
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/mvc/dataset/dataset-model.js
--- a/client/galaxy/scripts/mvc/dataset/dataset-model.js
+++ b/client/galaxy/scripts/mvc/dataset/dataset-model.js
@@ -359,74 +359,11 @@
Backbone.Collection.prototype.set.call( this, models, options );
},
-// /** Convert this ad-hoc collection of hdas to a formal collection tracked
-// by the server.
-// **/
-// promoteToHistoryDatasetCollection : function _promote( history, collection_type, options ){
-////TODO: seems like this would be better in mvc/collections
-// options = options || {};
-// options.url = this.url();
-// options.type = "POST";
-// var full_collection_type = collection_type;
-// var element_identifiers = [],
-// name = null;
-//
-// // This mechanism is rough - no error handling, allows invalid selections, no way
-// // for user to pick/override element identifiers. This is only really meant
-// if( collection_type === "list" ) {
-// this.chain().each( function( hda ) {
-// // TODO: Handle duplicate names.
-// var name = hda.attributes.name;
-// var id = hda.get('id');
-// var content_type = hda.attributes.history_content_type;
-// if( content_type === "dataset" ) {
-// if( full_collection_type !== "list" ) {
-// this.log( "Invalid collection type" );
-// }
-// element_identifiers.push( { name: name, src: "hda", id: id } );
-// } else {
-// if( full_collection_type === "list" ) {
-// full_collection_type = "list:" + hda.attributes.collection_type;
-// } else {
-// if( full_collection_type !== "list:" + hda.attributes.collection_type ) {
-// this.log( "Invalid collection type" );
-// }
-// }
-// element_identifiers.push( { name: name, src: "hdca", id: id } );
-// }
-// });
-// name = "New Dataset List";
-// } else if( collection_type === "paired" ) {
-// var ids = this.ids();
-// if( ids.length !== 2 ){
-// // TODO: Do something...
-// }
-// element_identifiers.push( { name: "forward", src: "hda", id: ids[ 0 ] } );
-// element_identifiers.push( { name: "reverse", src: "hda", id: ids[ 1 ] } );
-// name = "New Dataset Pair";
-// }
-// options.data = {
-// type: "dataset_collection",
-// name: name,
-// collection_type: full_collection_type,
-// element_identifiers: JSON.stringify( element_identifiers )
-// };
-//
-// var xhr = jQuery.ajax( options );
-// xhr.done( function( message, status, responseObj ){
-// history.refresh( );
-// });
-// xhr.fail( function( xhr, status, message ){
-// if( xhr.responseJSON && xhr.responseJSON.error ){
-// error = xhr.responseJSON.error;
-// } else {
-// error = xhr.responseJSON;
-// }
-// xhr.responseText = error;
-// // Do something?
-// });
-// return xhr;
-// },
+ ///** Convert this ad-hoc collection of hdas to a formal collection tracked
+ // by the server.
+ //**/
+ //promoteToHistoryDatasetCollection : function _promote( history, collection_type, options ){
+ //},
/** String representation. */
toString : function(){
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/mvc/history/history-contents.js
--- a/client/galaxy/scripts/mvc/history/history-contents.js
+++ b/client/galaxy/scripts/mvc/history/history-contents.js
@@ -187,6 +187,7 @@
/** copy an existing, accessible hda into this collection */
copy : function( id ){
+//TODO: incorp collections
var collection = this,
xhr = jQuery.post( this.url(), {
source : 'hda',
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/mvc/history/history-model.js
--- a/client/galaxy/scripts/mvc/history/history-model.js
+++ b/client/galaxy/scripts/mvc/history/history-model.js
@@ -117,7 +117,7 @@
return _.reduce( _.values( this.get( 'state_details' ) ), function( memo, num ){ return memo + num; }, 0 );
},
- // ........................................................................ ajax
+ // ........................................................................ updates
/** does the contents collection indicate they're still running and need to be updated later?
* delay + update if needed
* @param {Function} onReadyCallback function to run when all contents are in the ready state
@@ -187,6 +187,18 @@
return xhr;
},
+ // ........................................................................ ajax
+ /** save this history, _Mark_ing it as deleted (just a flag) */
+ _delete : function( options ){
+ if( this.get( 'deleted' ) ){ return jQuery.when(); }
+ return this.save( { deleted: true }, options );
+ },
+ /** save this history, _Mark_ing it as undeleted */
+ undelete : function( options ){
+ if( !this.get( 'deleted' ) ){ return jQuery.when(); }
+ return this.save( { deleted: false }, options );
+ },
+
/** Make a copy of this history on the server
* @param {Boolean} current if true, set the copy as the new current history (default: true)
* @param {String} name name of new history (default: none - server sets to: Copy of <current name>)
@@ -210,9 +222,28 @@
//TODO:?? all datasets?
var history = this,
- xhr = jQuery.post( this.urlRoot, postData );
- xhr.done( function( newData ){
- history.trigger( 'copied', history, newData );
+ copy = jQuery.post( this.urlRoot, postData );
+ // if current - queue to setAsCurrent before firing 'copied'
+ if( current ){
+ return copy.then( function( response ){
+ var newHistory = new History( response );
+ return newHistory.setAsCurrent()
+ .done( function(){
+ history.trigger( 'copied', history, response );
+ });
+ });
+ }
+ return copy.done( function( response ){
+ history.trigger( 'copied', history, response );
+ });
+ },
+
+ setAsCurrent : function(){
+ var history = this,
+ xhr = jQuery.getJSON( '/history/set_as_current?id=' + this.id );
+
+ xhr.done( function(){
+ history.trigger( 'set-as-current', history );
});
return xhr;
},
@@ -351,12 +382,15 @@
create : function create( data, hdas, historyOptions, xhrOptions ){
var collection = this,
- history = new History( data || {}, hdas || [], historyOptions || {} );
- return history.save( xhrOptions ).done( function( newData ){
+ xhr = jQuery.getJSON( galaxy_config.root + 'history/create_new_current' );
+ return xhr.done( function( newData ){
+ var history = new History( newData, [], historyOptions || {} );
// new histories go in the front
//TODO: (implicit ordering by update time...)
collection.unshift( history );
+ collection.trigger( 'new-current' );
});
+//TODO: move back to using history.save (via Deferred.then w/ set_as_current)
},
toString: function toString(){
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 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
@@ -69,6 +69,17 @@
this.multiselectActions = attributes.multiselectActions || this._getActions();
},
+ /** Override to handle history as drag-drop target */
+ _setUpListeners : function(){
+ _super.prototype._setUpListeners.call( this );
+
+ this.on( 'drop', function( ev, data ){
+ this.dataDropped( data );
+ // remove the drop target
+ this.dropTargetOff();
+ });
+ },
+
// ------------------------------------------------------------------------ listeners
/** listening for collection events */
_setUpCollectionListeners : function(){
@@ -296,6 +307,13 @@
return options;
},
+ ///** Override to alter data in drag based on multiselection */
+ //_setUpItemViewListeners : function( view ){
+ // var panel = this;
+ // _super.prototype._setUpItemViewListeners.call( panel, view );
+ //
+ //},
+
/** If this item is deleted and we're not showing deleted items, remove the view
* @param {Model} the item model to check
*/
@@ -346,6 +364,132 @@
this.$el.find( '.history-size' ).text( this.model.get( 'nice_size' ) );
},
+ // ------------------------------------------------------------------------ as drop target
+ /** */
+ dropTargetOn : function(){
+ if( this.dropTarget ){ return this; }
+ this.dropTarget = true;
+
+ //TODO: to init
+ var dropHandlers = {
+ 'dragenter' : _.bind( this.dragenter, this ),
+ 'dragover' : _.bind( this.dragover, this ),
+ 'dragleave' : _.bind( this.dragleave, this ),
+ 'drop' : _.bind( this.drop, this )
+ };
+//TODO: scroll to top
+ var $dropTarget = this._renderDropTarget();
+ this.$list().before([ this._renderDropTargetHelp(), $dropTarget ]);
+ for( var evName in dropHandlers ){
+ if( dropHandlers.hasOwnProperty( evName ) ){
+ //console.debug( evName, dropHandlers[ evName ] );
+ $dropTarget.on( evName, dropHandlers[ evName ] );
+ }
+ }
+ 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( _l( 'Drag datasets here to copy them to the current history' ) );
+ },
+
+ /** */
+ dropTargetOff : function(){
+ if( !this.dropTarget ){ return this; }
+ //this.log( 'dropTargetOff' );
+ this.dropTarget = false;
+ //
+ //var dropTarget = this.$( '.history-drop-target' ).get(0);
+ //for( var evName in this._dropHandlers ){
+ // if( this._dropHandlers.hasOwnProperty( evName ) ){
+ // console.debug( evName, this._dropHandlers[ evName ] );
+ // dropTarget.off( evName, this._dropHandlers[ evName ] );
+ // }
+ //}
+ 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( ev ){
+ //console.debug( 'dragenter:', this, ev );
+ ev.preventDefault();
+ ev.stopPropagation();
+ this.$( '.history-drop-target' ).css( 'border', '2px solid black' );
+ },
+ /** */
+ dragover : function( ev ){
+ ev.preventDefault();
+ ev.stopPropagation();
+ },
+ /** */
+ dragleave : function( ev ){
+ //console.debug( 'dragleave:', this, ev );
+ ev.preventDefault();
+ ev.stopPropagation();
+ this.$( '.history-drop-target' ).css( 'border', '1px dashed black' );
+ },
+ /** */
+ drop : function( ev ){
+ //console.warn( 'dataTransfer:', ev.dataTransfer.getData( 'text' ) );
+ //console.warn( 'dataTransfer:', ev.originalEvent.dataTransfer.getData( 'text' ) );
+ ev.preventDefault();
+ //ev.stopPropagation();
+ ev.dataTransfer.dropEffect = 'move';
+
+ //console.debug( 'ev.dataTransfer:', ev.dataTransfer );
+
+ var panel = this,
+ data = ev.dataTransfer.getData( "text" );
+ try {
+ data = JSON.parse( data );
+
+ } catch( err ){
+ this.warn( 'error parsing JSON from drop:', data );
+ }
+ this.trigger( 'droptarget:drop', ev, data, panel );
+ return false;
+ },
+
+ /** */
+ dataDropped : function( data ){
+ var panel = this;
+ // HDA: dropping will copy it to the history
+ if( _.isObject( data ) && data.model_class === 'HistoryDatasetAssociation' && data.id ){
+ return panel.model.contents.copy( data.id );
+ }
+ return jQuery.when();
+ },
+
// ........................................................................ misc
/** Return a string rep of the history */
toString : function(){
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/mvc/history/multi-panel.js
--- /dev/null
+++ b/client/galaxy/scripts/mvc/history/multi-panel.js
@@ -0,0 +1,1067 @@
+define([
+ "mvc/history/history-model",
+ "mvc/history/history-panel-edit",
+ "mvc/base-mvc",
+ "utils/ajax-queue"
+], function( HISTORY_MODEL, HPANEL_EDIT, baseMVC, ajaxQueue ){
+window.HISTORY_MODEL = HISTORY_MODEL;
+//==============================================================================
+/** */
+function historyCopyDialog( history, options ){
+ options = options || {};
+ // fall back to un-notifying copy
+ if( !( Galaxy && Galaxy.modal ) ){
+ return history.copy();
+ }
+
+ // maybe better as multiselect dialog?
+ var historyName = history.get( 'name' ),
+ defaultCopyName = "Copy of '" + historyName + "'";
+
+ function validateName( name ){
+ if( !name ){
+ if( !Galaxy.modal.$( '#invalid-title' ).size() ){
+ var $invalidTitle = $( '<p/>' ).attr( 'id', 'invalid-title' )
+ .css({ color: 'red', 'margin-top': '8px' })
+ .addClass( 'bg-danger' ).text( _l( 'Please enter a valid history title' ) );
+ Galaxy.modal.$( '.modal-body' ).append( $invalidTitle );
+ }
+ return false;
+ }
+ return name;
+ }
+ function copyHistory( name ){
+ var $copyIndicator = $( '<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>' )
+ .css( 'margin-top', '8px' );
+ Galaxy.modal.$( '.modal-body' ).append( $copyIndicator );
+ history.copy( true, name )
+//TODO: make this unneccessary with pub-sub error
+ .fail( function(){
+ alert( _l( 'History could not be copied. Please contact a Galaxy administrator' ) );
+ })
+ .always( function(){
+ Galaxy.modal.hide();
+ });
+ }
+
+ Galaxy.modal.show( _.extend({
+ title : _l( 'Copying history' ) + ' "' + historyName + '"',
+ body : $([
+ '<label for="copy-modal-title">',
+ _l( 'Enter a title for the copied history' ), ':',
+ '</label><br />',
+ '<input id="copy-modal-title" class="form-control" style="width: 100%" value="',
+ defaultCopyName, '" />'
+ ].join('')),
+ buttons : {
+ 'Cancel' : function(){ Galaxy.modal.hide(); },
+ 'Copy' : function(){
+ var name = Galaxy.modal.$( '#copy-modal-title' ).val();
+ if( !validateName( name ) ){ return; }
+ copyHistory( name );
+ }
+ }
+ }, options ));
+ $( '#copy-modal-title' ).focus().select();
+}
+
+
+/* ==============================================================================
+TODO:
+ copy places old current in wrong location
+ size not updating on dnd
+ sort by size is broken
+ handle delete current
+ currently manual by user - delete then create new - make one step
+ render
+ move all columns over as one (agg. then html())
+ loading indicator on startup
+ loading indicators on histories (while queueHdaLoading)
+ __panelPatchRenderEmptyMsg
+ performance
+ page load takes a while
+ renders where blocking each other - used _.delay( 0 )
+ sort takes a while
+ rendering columns could be better
+ lazy load history list
+ move in-view from pubsub
+
+ handle errors
+ handle no histories
+ handle no histories found
+
+ handle anon
+ no button
+ error message on loading url direct
+ include hidden/deleted
+ allow toggling w/o setting in storage
+ reloading with expanded collections doesn't get details of that collection
+
+ change includeDeleted to an ajax call
+
+ better narrowing
+
+ privatize non-interface fns
+ search for and drag and drop - should reset after dataset is loaded (or alt. clear search)
+ better ajax error handling
+ ?columns should be a panel, not have a panel
+
+============================================================================== */
+var HistoryPanelColumn = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
+//TODO: extend from panel? (instead of aggregating)
+
+ //logger : console,
+
+ tagName : 'div',
+ className : 'history-column flex-column flex-row-container',
+ id : function id(){
+ if( !this.model ){ return ''; }
+ return 'history-column-' + this.model.get( 'id' );
+ },
+
+ // ------------------------------------------------------------------------ set up
+ /** */
+ initialize : function initialize( options ){
+ options = options || {};
+
+ //this.log( this + '.init', options );
+ // if model, set up model
+ // create panel sub-view
+//TODO: use current-history-panel for current
+ this.panel = options.panel || this.createPanel( options );
+ this.setUpListeners();
+ },
+
+ /** */
+ createPanel : function createPanel( panelOptions ){
+ panelOptions = _.extend({
+ model : this.model,
+ //el : this.$panel(),
+ // non-current panels should set their hdas to draggable
+ dragItems : true
+ }, panelOptions );
+ //this.log( 'panelOptions:', panelOptions );
+//TODO: use current-history-panel for current
+ var panel = new HPANEL_EDIT.HistoryPanelEdit( panelOptions );
+ panel._renderEmptyMessage = this.__patch_renderEmptyMessage;
+ return panel;
+ },
+
+//TODO: needs work
+ /** */
+ __patch_renderEmptyMessage : function( $whereTo ){
+ var panel = this,
+ hdaCount = _.chain( this.model.get( 'state_ids' ) ).values().flatten().value().length,
+ $emptyMsg = panel.$emptyMessage( $whereTo );
+
+ if( !_.isEmpty( panel.hdaViews ) ){
+ $emptyMsg.hide();
+
+ } else if( hdaCount && !this.model.contents.length ){
+ $emptyMsg.empty()
+ .append( $( '<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>' ) ).show();
+
+ } else if( panel.searchFor ){
+ $emptyMsg.text( panel.noneFoundMsg ).show();
+
+ } else {
+ $emptyMsg.text( panel.emptyMsg ).show();
+ }
+ return $emptyMsg;
+ },
+
+ /** */
+ setUpListeners : function setUpListeners(){
+ var column = this;
+ //this.log( 'setUpListeners', this );
+ this.once( 'rendered', function(){
+ column.trigger( 'rendered:initial', column );
+ });
+ this.setUpPanelListeners();
+ },
+
+ /** */
+ setUpPanelListeners : function setUpPanelListeners(){
+ var column = this;
+ this.listenTo( this.panel, {
+ //'all': function(){ console.info( 'panel of ' + this, arguments ); },
+
+ // assumes panel will take the longest to render
+ 'rendered': function(){
+ column.trigger( 'rendered', column );
+ }
+ }, this );
+ },
+
+ /** */
+ inView : function( viewLeft, viewRight ){
+//TODO: offset is expensive
+ var columnLeft = this.$el.offset().left,
+ columnRight = columnLeft + this.$el.width();
+ if( columnRight < viewLeft ){ return false; }
+ if( columnLeft > viewRight ){ return false; }
+ return true;
+ },
+
+ /** */
+ $panel : function $panel(){
+ return this.$( '.history-panel' );
+ },
+
+ // ------------------------------------------------------------------------ render
+ /** */
+ render : function render( speed ){
+ speed = ( speed !== undefined )?( speed ):( 'fast' );
+ //this.log( this + '.render', this.$el, this.el );
+//TODO: not needed
+ var modelData = this.model? this.model.toJSON(): {};
+ this.$el.html( this.template( modelData ) );
+ this.renderPanel( speed );
+ // if model and not children
+ // template
+ // render controls
+ this.setUpBehaviors();
+ // add panel
+ return this;
+ },
+
+ /** */
+ setUpBehaviors : function setUpBehaviors(){
+ //this.log( 'setUpBehaviors:', this );
+ //var column = this;
+ // on panel size change, ...
+ },
+
+ /** */
+ template : function template( data ){
+ data = data || {};
+ var html = [
+ '<div class="panel-controls clear flex-row">',
+ this.controlsLeftTemplate(),
+ //'<button class="btn btn-default">Herp</button>',
+ '<div class="pull-right">',
+ '<button class="delete-history btn btn-default">',
+ data.deleted? _l( 'Undelete' ): _l( 'Delete' ),
+ '</button>',
+ '<button class="copy-history btn btn-default">', _l( 'Copy' ), '</button>',
+ '</div>',
+ '</div>',
+ '<div class="inner flex-row flex-column-container">',
+ '<div id="history-', data.id, '" class="history-column history-panel flex-column"></div>',
+ '</div>'
+ ].join( '' );
+ return $( html );
+ },
+
+ controlsLeftTemplate : function(){
+ return ( this.currentHistory )?
+ [
+ '<div class="pull-left">',
+ '<button class="create-new btn btn-default">', _l( 'Create new' ), '</button> ',
+ '</div>'
+ ].join( '' )
+ :[
+ '<div class="pull-left">',
+ '<button class="switch-to btn btn-default">', _l( 'Switch to' ), '</button>',
+ '</div>'
+ ].join( '' );
+ },
+
+ /** */
+ renderPanel : function renderPanel( speed ){
+ speed = ( speed !== undefined )?( speed ):( 'fast' );
+ this.panel.setElement( this.$panel() ).render( speed );
+ return this;
+ },
+
+ // ------------------------------------------------------------------------ behaviors and events
+ /** */
+ events : {
+ 'click .switch-to.btn' : function(){ this.model.setAsCurrent(); },
+ 'click .delete-history.btn' : function(){
+ var column = this,
+ xhr;
+ if( this.model.get( 'deleted' ) ){
+ xhr = this.model.undelete();
+ } else {
+ xhr = this.model._delete();
+ }
+//TODO: better error handler
+ xhr.fail( function( xhr, status, error ){
+ alert( _l( 'Could not delete the history' ) + ':\n' + error );
+ })
+ .done( function( data ){
+ column.render();
+ });
+ },
+ 'click .copy-history.btn' : 'copy'
+ },
+
+ // ------------------------------------------------------------------------ non-current controls
+ /** */
+ copy : function copy(){
+ historyCopyDialog( this.model );
+ },
+
+ // ------------------------------------------------------------------------ misc
+ /** */
+ toString : function(){
+ return 'HistoryPanelColumn(' + ( this.panel? this.panel : '' ) + ')';
+ }
+});
+
+
+//==============================================================================
+// a multi-history view that displays histories in full
+var MultiPanelColumns = Backbone.View.extend( baseMVC.LoggableMixin ).extend({
+
+ //logger : console,
+
+ // ------------------------------------------------------------------------ set up
+ /** */
+ initialize : function initialize( options ){
+ options = options || {};
+ this.log( this + '.init', options );
+
+ // --- instance vars
+ if( !options.currentHistoryId ){
+ throw new Error( this + ' requires a currentHistoryId in the options' );
+ }
+ this.currentHistoryId = options.currentHistoryId;
+
+//TODO: move these to some defaults
+ this.options = {
+ columnWidth : 312,
+ borderWidth : 1,
+ columnGap : 8,
+
+ headerHeight : 29,
+ footerHeight : 0,
+
+ controlsHeight : 20
+ };
+
+ /** the order that the collection is rendered in */
+ this.order = options.order || 'update';
+
+ /** named ajax queue for loading hdas */
+ this.hdaQueue = new ajaxQueue.NamedAjaxQueue( [], false );
+
+ // --- set up models, sub-views, and listeners
+ /** the original unfiltered and unordered collection of histories */
+ this.collection = null;
+ this.setCollection( options.histories || [] );
+
+ ///** the column views of histories */
+ //this.columns = [];
+ /** model id to column map */
+ this.columnMap = {};
+//TODO: why create here?
+ this.createColumns( options.columnOptions );
+
+ this.setUpListeners();
+ },
+
+ /** */
+ setUpListeners : function setUpListeners(){
+ //var multipanel = this;
+ //multipanel.log( 'setUpListeners', multipanel );
+ },
+
+ // ------------------------------------------------------------------------ collection
+ /** */
+ setCollection : function setCollection( models ){
+ var multipanel = this;
+ multipanel.stopListening( multipanel.collection );
+ multipanel.collection = models;
+//TODO: slow... esp. on start up
+ //if( multipanel.order !== 'update' ){
+ multipanel.sortCollection( multipanel.order, { silent: true });
+ //}
+ multipanel.setUpCollectionListeners();
+ multipanel.trigger( 'new-collection', multipanel );
+ return multipanel;
+ },
+
+ setUpCollectionListeners : function(){
+ var multipanel = this,
+ collection = multipanel.collection;
+ multipanel.listenTo( collection, {
+ // handle addition of histories, triggered by column copy and create new
+ 'add': multipanel.addAsCurrentColumn,
+ // handle setting a history as current, triggered by history.setAsCurrent
+ 'set-as-current': multipanel.setCurrentHistory,
+ // handle deleting a history (depends on whether panels is including deleted or not)
+ 'change:deleted': multipanel.handleDeletedHistory,
+
+ 'sort' : function(){ multipanel.renderColumns( 0 ); },
+
+ //'all' : function(){
+ // console.info( 'collection:', arguments );
+ //}
+ });
+ },
+
+ /** */
+ setCurrentHistory : function setCurrentHistory( history ){
+ var oldCurrentColumn = this.columnMap[ this.currentHistoryId ];
+ if( oldCurrentColumn ){
+ oldCurrentColumn.currentHistory = false;
+ oldCurrentColumn.$el.height( '' );
+ }
+
+ this.currentHistoryId = history.id;
+ var newCurrentColumn = this.columnMap[ this.currentHistoryId ];
+ newCurrentColumn.currentHistory = true;
+
+ this.sortCollection();
+
+////TODO: this actually means these render twice (1st from setCollection) - good enough for now
+ //if( oldCurrentColumn ){ oldCurrentColumn.render().delegateEvents(); }
+ //TODO:?? this occasionally causes race with hdaQueue
+ //newCurrentColumn.panel.render( 'fast' ).delegateEvents();
+
+ multipanel._recalcFirstColumnHeight();
+ return newCurrentColumn;
+ },
+
+ /** */
+ handleDeletedHistory : function handleDeletedHistory( history ){
+ if( history.get( 'deleted' ) ){
+ this.log( 'handleDeletedHistory', this.collection.includeDeleted, history );
+ var multipanel = this;
+ column = multipanel.columnMap[ history.id ];
+ if( !column ){ return; }
+
+ // if it's the current column, create a new, empty history as the new current
+ if( column.model.id === this.currentHistoryId ){
+//TODO: figuring out the order of async here is tricky - for now let the user handle the two step process
+ //multipanel.collection.create().done( function(){
+ // if( !multipanel.collection.includeDeleted ){ multipanel.removeColumn( column, false ); }
+ //});
+ } else if( !multipanel.collection.includeDeleted ){
+ multipanel.removeColumn( column );
+ }
+//TODO: prob. be done better
+ }
+ },
+
+ /** */
+ sortCollection : function( order, options ){
+ order = order || this.order;
+ var currentHistoryId = this.currentHistoryId;
+
+ //note: h.id !== currentHistoryId allows the sort to put the current history first
+ switch( order ){
+ case 'name':
+ //TODO: we can use a 2 arg version and return 1/0/-1
+ //this.collection.comparator = function( h1, h2 ){
+ this.collection.comparator = function( h ){
+//TODO: this won't do reverse order well
+ return [ h.id !== currentHistoryId, h.get( 'name' ).toLowerCase() ];
+ };
+ break;
+ case 'size':
+ this.collection.comparator = function( h ){
+//console.debug( 'name sort', arguments )
+ return [ h.id !== currentHistoryId, h.get( 'size' ) ];
+ };
+ break;
+ default:
+ this.collection.comparator = function( h ){
+ return [ h.id !== currentHistoryId, Date( h.get( 'update_time' ) ) ];
+ };
+ }
+ //NOTE: auto fires 'sort' from collection
+ this.collection.sort( options );
+ return this.collection;
+ },
+
+ /** */
+ setOrder : function( order ){
+ if( [ 'update', 'name', 'size' ].indexOf( order ) === -1 ){
+ order = 'update';
+ }
+ this.order = order;
+ this.sortCollection();
+ return this;
+ },
+
+ /** */
+ create : function( ev ){
+ return this.collection.create({ current: true });
+ },
+
+ ///** */
+ //deleteCurrent : function deleteCurrent(){
+ // var multipanel = this,
+ // currentColumn = multipanel.columnMap[ multipanel.currentHistoryId ];
+ // currentColumn.model._delete()
+ // .done( function(){
+ // multipanel.create();
+ // });
+ //},
+
+ // ------------------------------------------------------------------------ columns
+ /** create columns from collection */
+ createColumns : function createColumns( columnOptions ){
+ columnOptions = columnOptions || {};
+ var multipanel = this;
+ // clear column map
+ this.columnMap = {};
+ multipanel.collection.each( function( model, i ){
+ var column = multipanel.createColumn( model, columnOptions );
+ multipanel.columnMap[ model.id ] = column;
+ });
+ },
+
+ /** */
+ createColumn : function createColumn( history, options ){
+ // options passed can be re-used, so extend them before adding the model to prevent pollution for the next
+ options = _.extend( {}, options, { model: history });
+ var column = new HistoryPanelColumn( options );
+ if( history.id === this.currentHistoryId ){ column.currentHistory = true; }
+ this.setUpColumnListeners( column );
+ return column;
+ },
+
+ columnMapLength : function(){
+ return Object.keys( this.columnMap ).length;
+ },
+
+ sortedFilteredColumns : function( filters ){
+ filters = filters || this.filters;
+ if( !filters || !filters.length ){
+ return this.sortedColumns();
+ }
+ var multipanel = this;
+ return multipanel.sortedColumns().filter( function( column, index ){
+ var filtered = column.currentHistory || _.every( filters.map( function( filter ){
+ return filter.call( column );
+ }));
+ return filtered;
+ });
+ },
+
+ sortedColumns : function(){
+ var multipanel = this;
+ var sorted = this.collection.map( function( history, index ){
+ return multipanel.columnMap[ history.id ];
+ });
+ return sorted;
+ },
+
+ /** */
+ addColumn : function add( history, render ){
+//console.debug( 'adding column for:', history );
+ render = render !== undefined? render: true;
+ var newColumn = this.createColumn( history );
+ this.columnMap[ history.id ] = newColumn;
+ if( render ){
+ this.renderColumns();
+ }
+ return newColumn;
+ },
+
+ /** */
+ addAsCurrentColumn : function add( history ){
+//console.log( 'adding current column for:', history );
+ var multipanel = this,
+ newColumn = this.addColumn( history, false );
+ this.setCurrentHistory( history );
+ newColumn.once( 'rendered', function(){
+ multipanel.queueHdaFetch( newColumn );
+ });
+ return newColumn;
+ },
+
+ /** */
+ removeColumn : function remove( column, render ){
+ render = render !== undefined? render : true;
+ this.log( 'removeColumn', column );
+ if( !column ){ return; }
+ var multipanel = this,
+ widthToRemove = this.options.columnWidth + this.options.columnGap;
+ column.$el.fadeOut( 'fast', function(){
+ if( render ){
+ $( this ).remove();
+ multipanel.$( '.middle' ).width( multipanel.$( '.middle' ).width() - widthToRemove );
+ multipanel.checkColumnsInView();
+ multipanel._recalcFirstColumnHeight();
+ }
+
+//TODO: to freeColumn (where Columns have freePanel)
+ multipanel.stopListening( column.panel );
+ multipanel.stopListening( column );
+ delete multipanel.columnMap[ column.model.id ];
+ column.remove();
+ });
+ },
+
+ /** */
+ setUpColumnListeners : function setUpColumnListeners( column ){
+ var multipanel = this;
+ multipanel.listenTo( column, {
+ //'all': function(){ console.info( 'column ' + column + ':', arguments ) },
+ 'in-view': multipanel.queueHdaFetch
+ });
+
+ multipanel.listenTo( column.panel, {
+ //'all': function(){ console.info( 'panel ' + column.panel + ':', arguments ) },
+
+ 'view:draggable:dragstart': function( ev, view, panel, column ){
+ multipanel._dropData = JSON.parse( ev.dataTransfer.getData( 'text' ) );
+ multipanel.currentColumnDropTargetOn();
+ },
+ 'view:draggable:dragend': function( ev, view, panel, column ){
+ multipanel._dropData = null;
+ multipanel.currentColumnDropTargetOff();
+ },
+ 'droptarget:drop': function( ev, data, panel ){
+ var toCopy = multipanel._dropData.filter( function( json ){
+ return ( _.isObject( json ) && json.id && json.model_class === 'HistoryDatasetAssociation' );
+ });
+ multipanel._dropData = null;
+
+ var queue = new ajaxQueue.NamedAjaxQueue();
+ toCopy.forEach( function( hda ){
+ queue.add({
+ name : 'copy-' + hda.id,
+ fn : function(){
+ return panel.model.contents.copy( hda.id );
+ }
+ });
+ });
+ queue.start();
+ queue.done( function( responses ){
+ panel.model.fetch();
+ });
+ }
+ });
+
+ },
+
+ // ------------------------------------------------------------------------ render
+ /** */
+ render : function render( speed ){
+ speed = speed !== undefined? speed: this.fxSpeed;
+ var multipanel = this;
+
+ multipanel.log( multipanel + '.render' );
+ multipanel.$el.html( multipanel.template( multipanel.options ) );
+ //console.debug( multipanel.$( '.loading-overlay' ).fadeIn( 0 ) );
+ multipanel.renderColumns( speed );
+ //console.debug( multipanel.$( '.loading-overlay' ).fadeOut( 'fast' ) );
+
+ // set the columns to full height allowed and set up behaviors for thie multipanel
+ multipanel.setUpBehaviors();
+//TODO: wrong - has to wait for columns to render
+ multipanel.trigger( 'rendered', multipanel );
+ return multipanel;
+ },
+
+ /** */
+ template : function template( options ){
+ options = options || {};
+ var html = [];
+ if( this.options.headerHeight ){
+ html = html.concat([
+ '<div class="loading-overlay flex-row"><div class="loading-overlay-message">loading...</div></div>',
+ '<div class="header flex-column-container">',
+ '<div class="header-control header-control-left flex-column">',
+ '<button class="done btn btn-default">', _l( 'Done' ), '</button>',
+ '<button class="include-deleted btn btn-default"></button>',
+ '<div class="order btn-group">',
+ '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',
+ _l( 'Order histories by' ) + '... <span class="caret"></span>',
+ '</button>',
+ '<ul class="dropdown-menu" role="menu">',
+ '<li><a href="javascript:void(0);" class="order-update">',
+ _l( 'Time of last update' ),
+ '</a></li>',
+ '<li><a href="javascript:void(0);" class="order-name">',
+ _l( 'Name' ),
+ '</a></li>',
+ '<li><a href="javascript:void(0);" class="order-size">',
+ _l( 'Size' ),
+ '</a></li>',
+ '</ul>',
+ '</div>',
+ '<div id="search-histories" class="header-search"></div>',
+ '</div>',
+ '<div class="header-control header-control-center flex-column">',
+ '<div class="header-info">',
+ '</div>',
+ '</div>',
+ '<div class="header-control header-control-right flex-column">',
+ '<div id="search-datasets" class="header-search"></div>',
+ '<button id="toggle-deleted" class="btn btn-default">',
+ _l( 'Include deleted datasets' ),
+ '</button>',
+ '<button id="toggle-hidden" class="btn btn-default">',
+ _l( 'Include hidden datasets' ),
+ '</button>',
+ '</div>',
+ '</div>'
+ ]);
+ }
+
+ html = html.concat([
+ '<div class="outer-middle flex-row flex-row-container">',
+ '<div class="middle flex-column-container flex-row"></div>',
+ '</div>',
+ '<div class="footer flex-column-container">','</div>'
+ ]);
+ return $( html.join( '' ) );
+ },
+
+ /** */
+ renderColumns : function renderColumns( speed ){
+ speed = speed !== undefined? speed: this.fxSpeed;
+ //this.log( 'renderColumns:', speed );
+ // render columns and track the total number rendered, firing an event when all are rendered
+ var multipanel = this,
+ sortedAndFiltered = multipanel.sortedFilteredColumns();
+//console.log( '\t columnMapLength:', this.columnMapLength(), this.columnMap );
+ //this.log( '\t sortedAndFiltered:', sortedAndFiltered );
+
+ // set up width based on collection size
+//console.debug( '(render) width before:', multipanel.$( '.middle' ).width() )
+ multipanel.$( '.middle' ).width( sortedAndFiltered.length
+ //TODO: magic number 16 === the amount that safely prevents stacking of columns when adding a new one
+ * ( this.options.columnWidth + this.options.columnGap ) + this.options.columnGap + 16 );
+//console.debug( '(render) width now:', multipanel.$( '.middle' ).width() )
+
+//console.debug( 'sortedAndFiltered:', sortedAndFiltered )
+ //multipanel.$( '.middle' ).empty();
+
+// this.$( '.middle' ).html( sortedAndFiltered.map( function( column, i ){
+// return column.$el.hide();
+// }));
+// sortedAndFiltered.forEach( function( column, i ){
+////console.debug( 'rendering:', column, i )
+// //multipanel.$( '.middle' ).append( column.$el.hide() );
+// column.delegateEvents();
+////TODO: current column in-view is never fired
+// multipanel.renderColumn( column, speed ).$el.show();
+// });
+
+// var $els = sortedAndFiltered.map( function( column, i ){
+////console.debug( 'rendering:', column, i )
+// multipanel.renderColumn( column, speed );
+// return column.$el;
+// });
+//// this breaks the event map
+// //this.$( '.middle' ).html( $els );
+//// this doesn't
+// this.$( '.middle' ).append( $els );
+
+ var $middle = multipanel.$( '.middle' );
+ $middle.empty();
+ sortedAndFiltered.forEach( function( column, i ){
+//console.debug( 'rendering:', column, i, column.panel )
+
+ column.$el.appendTo( $middle );
+ column.delegateEvents();
+ multipanel.renderColumn( column, speed );
+
+ //column.$el.hide().appendTo( $middle );
+ //multipanel.renderColumn( column, speed );
+ // //.panel.on( 'all', function(){
+ // // console.debug( 'column rendered:', arguments );
+ // //});
+ //// this won't work until we checkColumnsInView after the render
+ ////column.$el.fadeIn( speed );
+ //column.$el.show();
+ });
+ //this.log( 'column rendering done' );
+
+//TODO: event columns-rendered
+
+ if( this.searchFor && sortedAndFiltered.length <= 1 ){
+ } else {
+ multipanel.checkColumnsInView();
+ this._recalcFirstColumnHeight();
+ }
+
+ return sortedAndFiltered;
+ },
+
+ /** */
+ renderColumn : function( column, speed ){
+ speed = speed !== undefined? speed: this.fxSpeed;
+ return _.delay( function(){ return column.render( speed ); }, 0 );
+ },
+
+//TODO: combine the following two more sensibly
+//TODO: could have HistoryContents.haveDetails return false
+// if column.model.contents.length === 0 && !column.model.get( 'empty' ) then just check that
+ /** */
+ queueHdaFetch : function queueHdaFetch( column ){
+ //this.log( 'queueHdaFetch:', column );
+ // if the history model says it has hdas but none are present, queue an ajax req for them
+ if( column.model.contents.length === 0 && !column.model.get( 'empty' ) ){
+ //this.log( '\t fetch needed:', column );
+ var xhrData = {},
+ ids = _.values( column.panel.storage.get( 'expandedIds' ) ).join();
+ if( ids ){
+ xhrData.dataset_details = ids;
+ }
+ // this uses a 'named' queue so that duplicate requests are ignored
+ this.hdaQueue.add({
+ name : column.model.id,
+ fn : function(){
+ var xhr = column.model.contents.fetch({ data: xhrData, silent: true });
+ return xhr.done( function( response ){
+ column.panel.renderItems();
+ });
+ }
+ });
+ // the queue is re-used, so if it's not processing requests - start it again
+ if( !this.hdaQueue.running ){ this.hdaQueue.start(); }
+ }
+ },
+
+ /** */
+ queueHdaFetchDetails : function( column ){
+ if( ( column.model.contents.length === 0 && !column.model.get( 'empty' ) )
+ || ( !column.model.contents.haveDetails() ) ){
+ // this uses a 'named' queue so that duplicate requests are ignored
+ this.hdaQueue.add({
+ name : column.model.id,
+ fn : function(){
+ var xhr = column.model.contents.fetch({ data: { details: 'all' }, silent: true });
+ return xhr.done( function( response ){
+ column.panel.renderItems();
+ });
+ }
+ });
+ // the queue is re-used, so if it's not processing requests - start it again
+ if( !this.hdaQueue.running ){ this.hdaQueue.start(); }
+ }
+ },
+
+ /** */
+ allColumns : function allColumns(){
+ return [ this.currentColumn ].concat( this.columns );
+ },
+
+ renderInfo : function( msg ){
+ this.$( '.header .header-info' ).text( msg );
+ },
+
+ // ------------------------------------------------------------------------ events/behaviors
+ /** */
+ events : {
+ 'click .done.btn' : function(){ window.location = '/'; },
+ //'click .done.btn' : function(){ window.history.back(); },
+ 'click .create-new.btn' : 'create',
+ 'click .order .order-update' : function( e ){ this.setOrder( 'update' ); },
+ 'click .order .order-name' : function( e ){ this.setOrder( 'name' ); },
+ 'click .order .order-size' : function( e ){ this.setOrder( 'size' ); }
+
+ //'dragstart .list-item .title-bar' : function( e ){ console.debug( 'ok' ); }
+ },
+
+ includeDeletedHistories : function(){
+ //TODO: better through API/limit+offset
+ window.location += ( /\?/.test( window.location.toString() ) )?( '&' ):( '?' )
+ + 'include_deleted_histories=True';
+ },
+
+ excludeDeletedHistories : function(){
+ //TODO: better through API/limit+offset
+ window.location = window.location.toString().replace( /[&\?]include_deleted_histories=True/g, '' );
+ },
+
+ /** */
+ setUpBehaviors : function(){
+ var multipanel = this;
+
+//TODO: currently doesn't need to be a mode button
+ multipanel.$( '.include-deleted' ).modeButton({
+ initialMode : this.collection.includeDeleted? 'exclude' : 'include',
+ switchModesOnClick : false,
+ modes: [
+ { mode: 'include', html: _l( 'Include deleted histories' ),
+ onclick: _.bind( multipanel.includeDeletedHistories, multipanel )
+ },
+ { mode: 'exclude', html: _l( 'Exclude deleted histories' ),
+ onclick: _.bind( multipanel.excludeDeletedHistories, multipanel )
+ }
+ ]
+ });
+
+ // input to search histories
+ multipanel.$( '#search-histories' ).searchInput({
+ name : 'search-histories',
+ placeholder : _l( 'search histories' ),
+ onsearch : function( searchFor ){
+ multipanel.searchFor = searchFor;
+ multipanel.filters = [ function(){
+ return this.model.get( 'name' ).indexOf( multipanel.searchFor ) !== -1;
+ }];
+ multipanel.renderColumns( 0 );
+ },
+ onclear : function( searchFor ){
+ multipanel.searchFor = null;
+ multipanel.filters = [];
+ multipanel.renderColumns( 0 );
+ }
+ });
+
+ // input to search datasets
+ multipanel.$( '#search-datasets' ).searchInput({
+ name : 'search-datasets',
+ placeholder : _l( 'search all datasets' ),
+
+ onfirstsearch : function( searchFor ){
+ multipanel.hdaQueue.clear();
+ multipanel.$( '#search-datasets' ).searchInput( 'toggle-loading' );
+ multipanel.searchFor = searchFor;
+ multipanel.sortedFilteredColumns().forEach( function( column ){
+ column.panel.searchItems( searchFor );
+ // load details for them that need
+ multipanel.queueHdaFetchDetails( column );
+ });
+ multipanel.hdaQueue.progress( function( progress ){
+ multipanel.renderInfo([
+ _l( 'loading' ), ( progress.curr + 1 ), _l( 'of' ), progress.total
+ ].join( ' ' ));
+ });
+ multipanel.hdaQueue.deferred.done( function(){
+ multipanel.renderInfo( '' );
+ multipanel.$( '#search-datasets' ).searchInput( 'toggle-loading' );
+ });
+ },
+ onsearch : function( searchFor ){
+ multipanel.searchFor = searchFor;
+ multipanel.sortedFilteredColumns().forEach( function( column ){
+ column.panel.searchItems( searchFor );
+ });
+ },
+ onclear : function( searchFor ){
+ multipanel.searchFor = null;
+ multipanel.sortedFilteredColumns().forEach( function( column ){
+ column.panel.clearSearch();
+ });
+ }
+ });
+
+//TODO: each panel stores the hidden/deleted state - and that isn't reflected in the buttons
+ multipanel.$( '#toggle-deleted' ).modeButton({
+ initialMode : 'include',
+ modes: [
+ { mode: 'exclude', html: _l( 'Exclude deleted datasets' ) },
+ { mode: 'include', html: _l( 'Include deleted datasets' ) }
+ ]
+ }).click( function(){
+ var show = $( this ).modeButton( 'getMode' ).mode === 'exclude';
+ multipanel.sortedFilteredColumns().forEach( function( column, i ){
+ _.delay( function(){
+ column.panel.toggleShowDeleted( show, false );
+ }, i * 200 );
+ });
+ });
+
+ multipanel.$( '#toggle-hidden' ).modeButton({
+ initialMode : 'include',
+ modes: [
+ { mode: 'exclude', html: _l( 'Exclude hidden datasets' ) },
+ { mode: 'include', html: _l( 'Include hidden datasets' ) }
+ ]
+ }).click( function(){
+ var show = $( this ).modeButton( 'getMode' ).mode === 'exclude';
+ multipanel.sortedFilteredColumns().forEach( function( column, i ){
+ _.delay( function(){
+ column.panel.toggleShowHidden( show, false );
+ }, i * 200 );
+ });
+ });
+
+ // resize first (fixed position) column on page resize
+ $( window ).resize( function(){
+ multipanel._recalcFirstColumnHeight();
+ });
+
+ // when scrolling - check for histories now in view: they will fire 'in-view' and queueHdaLoading if necc.
+//TODO:?? might be able to simplify and not use pub-sub
+ var debouncedInView = _.debounce( _.bind( this.checkColumnsInView, this ), 100 );
+ this.$( '.middle' ).parent().scroll( debouncedInView );
+ },
+
+ //panelRenderQueue : function( columns, fn, args, renderEventName ){
+ //},
+
+ _recalcFirstColumnHeight : function(){
+ //var currentColumn = this.columnMap[ this.currentHistoryId ];
+ //if( !currentColumn ){ return; }
+ var $firstColumn = this.$( '.history-column' ).first(),
+ middleHeight = this.$( '.middle' ).height(),
+ controlHeight = $firstColumn.find( '.panel-controls' ).height();
+ $firstColumn.height( middleHeight )
+ .find( '.inner' ).height( middleHeight - controlHeight );
+
+//console.debug( '$firstColumn:', $firstColumn );
+ //var currentColumn = this.columnMap[ this.currentHistoryId ];
+ //if( !currentColumn ){ return; }
+ //var middleHeight = this.$( '.middle' ).height(),
+ // controlHeight = currentColumn.$( '.panel-controls' ).height();
+ //currentColumn.$el.height( middleHeight )
+ // .find( '.inner' ).height( middleHeight - controlHeight );
+ },
+
+ _viewport : function(){
+ var viewLeft = this.$( '.middle' ).parent().offset().left;
+ return { left: viewLeft, right: viewLeft + this.$( '.middle' ).parent().width() };
+ },
+
+ /** */
+ columnsInView : function(){
+ //TODO: uses offset which is render intensive
+//TODO: 2N - could use arg filter (sortedFilteredColumns( filter )) instead
+ var vp = this._viewport();
+ return this.sortedFilteredColumns().filter( function( column ){
+ return column.currentHistory || column.inView( vp.left, vp.right );
+ });
+ },
+
+//TODO: sortByInView - return cols in view, then others
+ /** */
+ checkColumnsInView : function(){
+//console.debug( 'checking columns in view', this.columnsInView() );
+ this.columnsInView().forEach( function( column ){
+ column.trigger( 'in-view', column );
+ });
+ },
+
+ /** */
+ currentColumnDropTargetOn : function(){
+ var currentColumn = this.columnMap[ this.currentHistoryId ];
+ if( !currentColumn ){ return; }
+//TODO: fix this - shouldn't need monkeypatch
+ currentColumn.panel.dataDropped = function( data ){};
+ currentColumn.panel.dropTargetOn();
+ },
+
+ /** */
+ currentColumnDropTargetOff : function(){
+ var currentColumn = this.columnMap[ this.currentHistoryId ];
+ if( !currentColumn ){ return; }
+ currentColumn.panel.dataDropped = HPANEL_EDIT.HistoryPanelEdit.prototype.dataDrop;
+ currentColumn.panel.dropTargetOff();
+ },
+
+ // ------------------------------------------------------------------------ misc
+ /** */
+ toString : function(){
+ return 'MultiPanelColumns(' + ( this.columns? this.columns.length : 0 ) + ')';
+ }
+});
+
+
+//==============================================================================
+ return {
+ MultiPanelColumns : MultiPanelColumns
+ };
+});
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/mvc/list/list-panel.js
--- a/client/galaxy/scripts/mvc/list/list-panel.js
+++ b/client/galaxy/scripts/mvc/list/list-panel.js
@@ -80,6 +80,9 @@
/** the last selected item.model.id */
this.lastSelected = null;
+ /** are sub-views draggable */
+ this.dragItems = attributes.dragItems || false;
+
/** list item view class (when passed models) */
this.viewClass = attributes.viewClass || this.viewClass;
@@ -317,6 +320,7 @@
//TODO: free prev. views?
panel.views = panel._filterCollection().map( function( itemModel ){
//TODO: creates views each time - not neccessarily good
+//TODO: pass speed here
return panel._createItemView( itemModel ).render( 0 );
});
//panel.debug( item$els );
@@ -377,7 +381,7 @@
expanded : false,
selectable : this.selecting,
selected : _.contains( this.selected, model.id ),
- draggable : this.dragging
+ draggable : this.dragItems
};
},
@@ -391,6 +395,19 @@
panel.trigger.apply( panel, args );
});
+ // drag multiple - hijack ev.setData to add all selected datasets
+ view.on( 'draggable:dragstart', function( ev, v ){
+ //TODO: set multiple drag data here
+ var json = {},
+ selected = this.getSelectedModels();
+ if( selected.length ){
+ json = selected.toJSON();
+ } else {
+ json = [ v.model.toJSON() ];
+ }
+ ev.dataTransfer.setData( 'text', JSON.stringify( json ) );
+ }, this );
+
// debugging
//if( this.logger ){
// view.on( 'all', function( event ){
@@ -567,6 +584,7 @@
this.searchFor = searchFor;
this.trigger( 'search:searching', searchFor, this );
this.renderItems();
+ this.$( '> .controls .search-query' ).val( searchFor );
return this;
},
@@ -576,6 +594,7 @@
this.searchFor = '';
this.trigger( 'search:clear', this );
this.renderItems();
+ this.$( '> .controls .search-query' ).val( '' );
return this;
},
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/mvc/ui.js
--- a/client/galaxy/scripts/mvc/ui.js
+++ b/client/galaxy/scripts/mvc/ui.js
@@ -691,6 +691,10 @@
}
}
})
+ .on( 'change', function( event ){
+ console.info( 'changed', $( this ), event );
+ search.call( this, event, $( this ).val() );
+ })
.val( options.initialVal );
}
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 client/galaxy/scripts/utils/ajax-queue.js
--- a/client/galaxy/scripts/utils/ajax-queue.js
+++ b/client/galaxy/scripts/utils/ajax-queue.js
@@ -46,10 +46,11 @@
this.numToProcess += 1;
this.queue.push( function(){
- var xhr = fn();
+ var fnIndex = index,
+ xhr = fn();
// if successful, notify using the deferred to allow tracking progress
xhr.done( function( response ){
- self.deferred.notify({ curr: index, total: self.numToProcess, response: response });
+ self.deferred.notify({ curr: fnIndex, total: self.numToProcess, response: response });
});
// (regardless of previous error or success) if not last ajax call, shift and call the next
// if last fn, resolve deferred
@@ -86,6 +87,8 @@
} else {
this.deferred.resolve( this.responses );
}
+ this.numToProcess = 0;
+ this.deferred = jQuery.Deferred();
return this;
};
@@ -137,6 +140,7 @@
/** add the obj.fn to the queue if obj.name hasn't been used before */
NamedAjaxQueue.prototype.add = function add( obj ){
+ //console.debug( 'NamedAjaxQueue.adding:', obj )
//console.debug( 'NamedAjaxQueue.prototype.add:', obj );
if( !( obj.hasOwnProperty( 'name' ) && obj.hasOwnProperty( 'fn' ) ) ){
throw new Error( 'NamedAjaxQueue.add requires an object with both "name" and "fn": ' + JSON.stringify( obj ) );
@@ -146,7 +150,14 @@
return;
}
this.names[ obj.name ] = true;
+ //console.debug( '\t names: ', this.names )
AjaxQueue.prototype.add.call( this, obj.fn );
+ //console.debug( '\t queue: ', this.queue.length );
+};
+
+/** override to remove names */
+NamedAjaxQueue.prototype.clear = function clear(){
+ this.names = {};
};
/** shortcut constructor / fire and forget
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 lib/galaxy/webapps/galaxy/controllers/history.py
--- a/lib/galaxy/webapps/galaxy/controllers/history.py
+++ b/lib/galaxy/webapps/galaxy/controllers/history.py
@@ -575,6 +575,26 @@
show_deleted=show_deleted, show_hidden=show_hidden, use_panels=use_panels )
@web.expose
+ def view_multiple( self, trans, include_deleted_histories=False, order='update' ):
+ """
+ """
+ #TODO: allow specifying user_id for admin?
+ include_deleted_histories = galaxy.util.string_as_bool( include_deleted_histories )
+ order = order if order in ( 'update', 'name', 'size' ) else 'update'
+
+ current_history = trans.get_history()
+ current_history_id = trans.security.encode_id( current_history.id ) if current_history else None
+
+ history_dictionaries = []
+ for history in self.get_user_histories( trans, user=trans.user, include_deleted=include_deleted_histories ):
+ history_dictionary = self.get_history_dict( trans, history )
+ history_dictionaries.append( history_dictionary )
+
+ return trans.fill_template_mako( "history/view_multiple.mako",
+ current_history_id=current_history_id, histories=history_dictionaries,
+ include_deleted_histories=include_deleted_histories, order=order )
+
+ @web.expose
def display_by_username_and_slug( self, trans, username, slug ):
"""
Display history based on a username and slug.
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 static/scripts/mvc/base-mvc.js
--- a/static/scripts/mvc/base-mvc.js
+++ b/static/scripts/mvc/base-mvc.js
@@ -380,11 +380,6 @@
/** allow the view to be dragged, set up event handlers */
draggableOn : function(){
this.draggable = true;
- //TODO: I have no idea why this doesn't work with the events hash or jq.on()...
- //this.$el.find( '.title-bar' )
- // .attr( 'draggable', true )
- // .bind( 'dragstart', this.dragStartHandler, false )
- // .bind( 'dragend', this.dragEndHandler, false );
this.dragStartHandler = _.bind( this._dragStartHandler, this );
this.dragEndHandler = _.bind( this._dragEndHandler, this );
@@ -402,23 +397,22 @@
},
/** sets the dataTransfer data to the model's toJSON
- * @fires dragstart (bbone event) which is passed this view
+ * @fires draggable:dragstart (bbone event) which is passed the event and this view
*/
_dragStartHandler : function( event ){
- //this.debug( 'dragStartHandler:', this, event, arguments )
- this.trigger( 'dragstart', this );
event.dataTransfer.effectAllowed = 'move';
+ //ASSUMES: this.model
//TODO: all except IE: should be 'application/json', IE: must be 'text'
event.dataTransfer.setData( 'text', JSON.stringify( this.model.toJSON() ) );
+ this.trigger( 'draggable:dragstart', event, this );
return false;
},
/** handle the dragend
- * @fires dragend (bbone event) which is passed this view
+ * @fires draggable:dragend (bbone event) which is passed the event and this view
*/
_dragEndHandler : function( event ){
- this.trigger( 'dragend', this );
- //this.debug( 'dragEndHandler:', event )
+ this.trigger( 'draggable:dragend', event, this );
return false;
}
};
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 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
@@ -181,6 +181,8 @@
}
var $visualizations = $( this.templates.visualizations( visualizations, this ) );
+ //HACK: need to re-write those directed at galaxy_main with linkTarget
+ $visualizations.find( '[target="galaxy_main"]').attr( 'target', this.linkTarget );
// use addBack here to include the root $visualizations elem (for the case of 1 visualization)
this._addScratchBookFn( $visualizations.find( '.visualization-link' ).addBack( '.visualization-link' ) );
return $visualizations;
@@ -188,6 +190,7 @@
/** add scratchbook functionality to visualization links */
_addScratchBookFn : function( $links ){
+ var li = this;
$links.click( function( ev ){
if( Galaxy.frame && Galaxy.frame.active ){
Galaxy.frame.add({
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 static/scripts/mvc/dataset/dataset-model.js
--- a/static/scripts/mvc/dataset/dataset-model.js
+++ b/static/scripts/mvc/dataset/dataset-model.js
@@ -359,74 +359,11 @@
Backbone.Collection.prototype.set.call( this, models, options );
},
-// /** Convert this ad-hoc collection of hdas to a formal collection tracked
-// by the server.
-// **/
-// promoteToHistoryDatasetCollection : function _promote( history, collection_type, options ){
-////TODO: seems like this would be better in mvc/collections
-// options = options || {};
-// options.url = this.url();
-// options.type = "POST";
-// var full_collection_type = collection_type;
-// var element_identifiers = [],
-// name = null;
-//
-// // This mechanism is rough - no error handling, allows invalid selections, no way
-// // for user to pick/override element identifiers. This is only really meant
-// if( collection_type === "list" ) {
-// this.chain().each( function( hda ) {
-// // TODO: Handle duplicate names.
-// var name = hda.attributes.name;
-// var id = hda.get('id');
-// var content_type = hda.attributes.history_content_type;
-// if( content_type === "dataset" ) {
-// if( full_collection_type !== "list" ) {
-// this.log( "Invalid collection type" );
-// }
-// element_identifiers.push( { name: name, src: "hda", id: id } );
-// } else {
-// if( full_collection_type === "list" ) {
-// full_collection_type = "list:" + hda.attributes.collection_type;
-// } else {
-// if( full_collection_type !== "list:" + hda.attributes.collection_type ) {
-// this.log( "Invalid collection type" );
-// }
-// }
-// element_identifiers.push( { name: name, src: "hdca", id: id } );
-// }
-// });
-// name = "New Dataset List";
-// } else if( collection_type === "paired" ) {
-// var ids = this.ids();
-// if( ids.length !== 2 ){
-// // TODO: Do something...
-// }
-// element_identifiers.push( { name: "forward", src: "hda", id: ids[ 0 ] } );
-// element_identifiers.push( { name: "reverse", src: "hda", id: ids[ 1 ] } );
-// name = "New Dataset Pair";
-// }
-// options.data = {
-// type: "dataset_collection",
-// name: name,
-// collection_type: full_collection_type,
-// element_identifiers: JSON.stringify( element_identifiers )
-// };
-//
-// var xhr = jQuery.ajax( options );
-// xhr.done( function( message, status, responseObj ){
-// history.refresh( );
-// });
-// xhr.fail( function( xhr, status, message ){
-// if( xhr.responseJSON && xhr.responseJSON.error ){
-// error = xhr.responseJSON.error;
-// } else {
-// error = xhr.responseJSON;
-// }
-// xhr.responseText = error;
-// // Do something?
-// });
-// return xhr;
-// },
+ ///** Convert this ad-hoc collection of hdas to a formal collection tracked
+ // by the server.
+ //**/
+ //promoteToHistoryDatasetCollection : function _promote( history, collection_type, options ){
+ //},
/** String representation. */
toString : function(){
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 static/scripts/mvc/history/history-contents.js
--- a/static/scripts/mvc/history/history-contents.js
+++ b/static/scripts/mvc/history/history-contents.js
@@ -187,6 +187,7 @@
/** copy an existing, accessible hda into this collection */
copy : function( id ){
+//TODO: incorp collections
var collection = this,
xhr = jQuery.post( this.url(), {
source : 'hda',
diff -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 -r 633b4212806d850135a28966d9759da3157b22e8 static/scripts/mvc/history/history-model.js
--- a/static/scripts/mvc/history/history-model.js
+++ b/static/scripts/mvc/history/history-model.js
@@ -117,7 +117,7 @@
return _.reduce( _.values( this.get( 'state_details' ) ), function( memo, num ){ return memo + num; }, 0 );
},
- // ........................................................................ ajax
+ // ........................................................................ updates
/** does the contents collection indicate they're still running and need to be updated later?
* delay + update if needed
* @param {Function} onReadyCallback function to run when all contents are in the ready state
@@ -187,6 +187,18 @@
return xhr;
},
+ // ........................................................................ ajax
+ /** save this history, _Mark_ing it as deleted (just a flag) */
+ _delete : function( options ){
+ if( this.get( 'deleted' ) ){ return jQuery.when(); }
+ return this.save( { deleted: true }, options );
+ },
+ /** save this history, _Mark_ing it as undeleted */
+ undelete : function( options ){
+ if( !this.get( 'deleted' ) ){ return jQuery.when(); }
+ return this.save( { deleted: false }, options );
+ },
+
/** Make a copy of this history on the server
* @param {Boolean} current if true, set the copy as the new current history (default: true)
* @param {String} name name of new history (default: none - server sets to: Copy of <current name>)
@@ -210,9 +222,28 @@
//TODO:?? all datasets?
var history = this,
- xhr = jQuery.post( this.urlRoot, postData );
- xhr.done( function( newData ){
- history.trigger( 'copied', history, newData );
+ copy = jQuery.post( this.urlRoot, postData );
+ // if current - queue to setAsCurrent before firing 'copied'
+ if( current ){
+ return copy.then( function( response ){
+ var newHistory = new History( response );
+ return newHistory.setAsCurrent()
+ .done( function(){
+ history.trigger( 'copied', history, response );
+ });
+ });
+ }
+ return copy.done( function( response ){
+ history.trigger( 'copied', history, response );
+ });
+ },
+
+ setAsCurrent : function(){
+ var history = this,
+ xhr = jQuery.getJSON( '/history/set_as_current?id=' + this.id );
+
+ xhr.done( function(){
+ history.trigger( 'set-as-current', history );
});
return xhr;
},
@@ -351,12 +382,15 @@
create : function create( data, hdas, historyOptions, xhrOptions ){
var collection = this,
- history = new History( data || {}, hdas || [], historyOptions || {} );
- return history.save( xhrOptions ).done( function( newData ){
+ xhr = jQuery.getJSON( galaxy_config.root + 'history/create_new_current' );
+ return xhr.done( function( newData ){
+ var history = new History( newData, [], historyOptions || {} );
// new histories go in the front
//TODO: (implicit ordering by update time...)
collection.unshift( history );
+ collection.trigger( 'new-current' );
});
+//TODO: move back to using history.save (via Deferred.then w/ set_as_current)
},
toString: function toString(){
This diff is so big that we needed to truncate the remainder.
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.
1
0
commit/galaxy-central: carlfeberhard: History API: add 'size' and 'update_time' to history show
by commits-noreply@bitbucket.org 29 Sep '14
by commits-noreply@bitbucket.org 29 Sep '14
29 Sep '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/349e558c8ef8/
Changeset: 349e558c8ef8
User: carlfeberhard
Date: 2014-09-29 13:33:27+00:00
Summary: History API: add 'size' and 'update_time' to history show
Affected #: 1 file
diff -r 0ef7a9e6973794876c3aee484512fb6c23de517d -r 349e558c8ef8e4ed4393f403d31e16f3e7235319 lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -877,7 +877,8 @@
class History( object, Dictifiable, UsesAnnotations, HasName ):
dict_collection_visible_keys = ( 'id', 'name', 'published', 'deleted' )
- dict_element_visible_keys = ( 'id', 'name', 'published', 'deleted', 'genome_build', 'purged', 'importable', 'slug', 'empty' )
+ dict_element_visible_keys = ( 'id', 'name', 'genome_build', 'deleted', 'purged', 'update_time',
+ 'published', 'importable', 'slug', 'empty' )
default_name = 'Unnamed history'
def __init__( self, id=None, name=None, user=None ):
@@ -1027,6 +1028,9 @@
tags_str_list.append( tag_str )
rval[ 'tags' ] = tags_str_list
+ if view == 'element':
+ rval[ 'size' ] = int( self.get_disk_size() )
+
return rval
def set_from_dict( self, new_data ):
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.
1
0
3 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/20ed0e6f5700/
Changeset: 20ed0e6f5700
User: jmchilton
Date: 2014-09-28 00:50:09+00:00
Summary: Merge next-stable.
Affected #: 1 file
https://bitbucket.org/galaxy/galaxy-central/commits/fe0cdf1166a8/
Changeset: fe0cdf1166a8
Branch: next-stable
User: jmchilton
Date: 2014-09-28 00:37:21+00:00
Summary: Fix tool migrations to respect GALAXY_CONFIG_* environment variables.
Thanks to Bjoern for the bug report.
Affected #: 1 file
diff -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d -r fe0cdf1166a841eb4b06dae4b40f552d12d947c7 scripts/manage_tools.py
--- a/scripts/manage_tools.py
+++ b/scripts/manage_tools.py
@@ -19,6 +19,7 @@
from galaxy.model.orm.scripts import require_dialect_egg
from galaxy.model.orm.scripts import read_config_file_arg
+from galaxy.util.properties import load_app_properties
log = logging.getLogger( __name__ )
@@ -28,18 +29,19 @@
sys.exit( 1 )
repo = 'lib/tool_shed/galaxy_install/migrate'
+properties = load_app_properties( ini_file=config_file )
cp = SafeConfigParser()
cp.read( config_file )
if config_file == 'config/galaxy.ini.sample' and 'GALAXY_TEST_DBURI' in os.environ:
# Running functional tests.
db_url = os.environ[ 'GALAXY_TEST_DBURI' ]
-elif cp.has_option( "app:main", "install_database_connection" ):
- db_url = cp.get( "app:main", "install_database_connection" )
-elif cp.has_option( "app:main", "database_connection" ):
- db_url = cp.get( "app:main", "database_connection" )
-elif cp.has_option( "app:main", "database_file" ):
- db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % cp.get( "app:main", "database_file" )
+elif "install_database_connection" in properties:
+ db_url = properties[ "install_database_connection" ]
+elif "database_connection" in properties:
+ db_url = properties[ "database_connection" ]
+elif "database_file" in properties:
+ db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % properties[ "database_file" ]
else:
db_url = "sqlite:///./database/universe.sqlite?isolation_level=IMMEDIATE"
https://bitbucket.org/galaxy/galaxy-central/commits/0ef7a9e69737/
Changeset: 0ef7a9e69737
User: jmchilton
Date: 2014-09-28 00:51:04+00:00
Summary: Merge next-stable.
Affected #: 1 file
diff -r 20ed0e6f5700dfee42cd0d82a2d5e4275fbe1829 -r 0ef7a9e6973794876c3aee484512fb6c23de517d scripts/manage_tools.py
--- a/scripts/manage_tools.py
+++ b/scripts/manage_tools.py
@@ -19,6 +19,7 @@
from galaxy.model.orm.scripts import require_dialect_egg
from galaxy.model.orm.scripts import read_config_file_arg
+from galaxy.util.properties import load_app_properties
log = logging.getLogger( __name__ )
@@ -28,18 +29,19 @@
sys.exit( 1 )
repo = 'lib/tool_shed/galaxy_install/migrate'
+properties = load_app_properties( ini_file=config_file )
cp = SafeConfigParser()
cp.read( config_file )
if config_file == 'config/galaxy.ini.sample' and 'GALAXY_TEST_DBURI' in os.environ:
# Running functional tests.
db_url = os.environ[ 'GALAXY_TEST_DBURI' ]
-elif cp.has_option( "app:main", "install_database_connection" ):
- db_url = cp.get( "app:main", "install_database_connection" )
-elif cp.has_option( "app:main", "database_connection" ):
- db_url = cp.get( "app:main", "database_connection" )
-elif cp.has_option( "app:main", "database_file" ):
- db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % cp.get( "app:main", "database_file" )
+elif "install_database_connection" in properties:
+ db_url = properties[ "install_database_connection" ]
+elif "database_connection" in properties:
+ db_url = properties[ "database_connection" ]
+elif "database_file" in properties:
+ db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % properties[ "database_file" ]
else:
db_url = "sqlite:///./database/universe.sqlite?isolation_level=IMMEDIATE"
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.
1
0
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/c29f651e4acc/
Changeset: c29f651e4acc
User: martenson
Date: 2014-09-26 19:17:35+00:00
Summary: select2 fixes and impl. of missing feature import from path
Affected #: 12 files
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
--- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
+++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
@@ -54,7 +54,12 @@
auto: {
id : 'auto',
text : 'Auto-detect',
- description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.'
+ description : 'This system will try to detect the file type automatically.' +
+ ' If your file is not detected properly as one of the known formats,' +
+ ' it most likely means that it has some format problems (e.g., different' +
+ ' number of columns on different rows). You can still coerce the system' +
+ ' to set your data to the format you think it should be.' +
+ ' You can also upload compressed files, which will automatically be decompressed.'
},
// genomes
@@ -73,15 +78,12 @@
id: this.options.id,
is_admin: false,
is_anonym: true,
- user_library_import_dir: Galaxy.config.user_library_import_dir,
- allow_library_path_paste: Galaxy.config.allow_library_path_paste,
- library_import_dir: Galaxy.config.library_import_dir,
mutiple_add_dataset_options: false
}
if (Galaxy.currUser){
template_defaults.is_admin = Galaxy.currUser.isAdmin();
template_defaults.is_anonym = Galaxy.currUser.isAnonymous();
- if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){
+ if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){
template_defaults.mutiple_add_dataset_options = true;
}
}
@@ -402,33 +404,38 @@
// https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy…
var that = this;
this.select_genome = new mod_select.View( {
- css: 'genome',
+ css: 'library-genome-select',
data: that.list_genomes,
- container: Galaxy.modal.$el.find( '#genome' ),
+ container: Galaxy.modal.$el.find( '#library_genome_select' ),
value: '?'
} );
this.select_extension = new mod_select.View({
- css: 'extension',
+ css: 'library-extension-select',
data: that.list_extensions,
- container: Galaxy.modal.$el.find('#extension'),
+ container: Galaxy.modal.$el.find( '#library_extension_select' ),
value: 'auto'
});
},
+
/**
- * Create modal for importing form user's directory
+ * Create modal for importing from given directory
* on Galaxy. Bind jQuery events.
*/
- importFilesFromUserdirModal: function(){
+ importFilesFromGalaxyFolderModal: function( options ){
var that = this;
+ var template_modal = this.templateBrowserModal();
this.modal = Galaxy.modal;
- var template_modal = this.templateBrowserModal();
this.modal.show({
closing_events : true,
title : 'Please select folders or files',
body : template_modal({}),
buttons : {
- 'Import' : function() {that.importFromUserdirClicked(that);},
- 'Close' : function() {Galaxy.modal.hide();}
+ 'Import' : function() {
+ that.importFromJstreePath( that, options );
+ },
+ 'Close' : function() {
+ Galaxy.modal.hide();
+ }
},
closing_callback: function(){
// TODO: should not trigger routes outside of the router
@@ -437,21 +444,24 @@
});
this.renderSelectBoxes();
- this.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ this.renderJstree( options );
- $('input[type=radio]').change(function(event){
+ $( 'input[type=radio]' ).change( function( event ){
if (event.target.value ==='jstree-disable-folders') {
- that.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ that.renderJstree( options );
$('.jstree-folders-message').hide();
$('.jstree-preserve-structure').hide();
$('.jstree-link-files').hide();
$('.jstree-files-message').show();
- } else if (event.target.value ==='jstree-disable-files'){
+ } else if ( event.target.value ==='jstree-disable-files' ){
$('.jstree-files-message').hide();
$('.jstree-folders-message').show();
$('.jstree-link-files').show();
$('.jstree-preserve-structure').show();
- that.renderJstree({disabled_jstree_element: 'files'});
+ options.disabled_jstree_element = 'files';
+ that.renderJstree( options );
}
}
);
@@ -463,12 +473,16 @@
* data.
* @param {[type]} options [description]
*/
- renderJstree: function(options){
+ renderJstree: function( options ){
var that = this;
- this.options = _.extend(this.options, options);
+ this.options = _.extend( this.options, options );
+ var target = options.source || 'userdir';
var disabled_jstree_element = this.options.disabled_jstree_element;
this.jstree = new mod_library_model.Jstree();
- this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element;
+ this.jstree.url = this.jstree.urlRoot +
+ '?target=' + target +
+ '&format=jstree' +
+ '&disable=' + disabled_jstree_element;
this.jstree.fetch({
success: function(model, response){
// This is to prevent double jquery load. I think. Carl is magician.
@@ -579,7 +593,7 @@
* jstree.js has to be loaded before
* @see renderJstree
*/
- importFromUserdirClicked: function ( that ){
+ importFromJstreePath: function ( that, options ){
var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true );
var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' );
var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' );
@@ -588,7 +602,7 @@
var selection_type = selected_nodes[0].type;
var paths = [];
if ( selected_nodes.length < 1 ){
- mod_toastr.info( 'You must select some items first.' );
+ mod_toastr.info( 'Please select some items first.' );
} else {
this.modal.disableButton( 'Import' );
for ( var i = selected_nodes.length - 1; i >= 0; i-- ){
@@ -598,17 +612,19 @@
}
this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } );
if ( selection_type === 'folder' ){
-
+ var full_source = options.source + '_folder';
this.chainCallImportingFolders( { paths: paths,
preserve_dirs: preserve_dirs,
link_data: link_data,
- source: 'userdir_folder',
+ source: full_source,
file_type: file_type,
dbkey: dbkey } );
} else if ( selection_type === 'file' ){
+ var full_source = options.source + '_file';
this.chainCallImportingUserdirFiles( { paths : paths,
file_type: file_type,
- dbkey: dbkey } );
+ dbkey: dbkey,
+ source: full_source } );
}
}
},
@@ -713,7 +729,7 @@
return true;
}
var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id +
- '&source=userdir_file' +
+ '&source=' + options.source +
'&path=' + popped_item +
'&file_type=' + options.file_type +
'&dbkey=' + options.dbkey ) )
@@ -760,22 +776,12 @@
'&dbkey=' + options.dbkey ) )
promise.done(function(response){
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
})
.fail(function(){
that.options.chain_call_control.failed_number += 1;
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
});
},
@@ -952,12 +958,13 @@
this.addFilesFromHistoryModal();
break;
case "importdir":
+ this.importFilesFromGalaxyFolderModal( { source: 'importdir' } );
break;
case "path":
this.importFilesFromPathModal();
break;
case "userdir":
- this.importFilesFromUserdirModal();
+ this.importFilesFromGalaxyFolderModal( { source: 'userdir' } );
break;
default:
Galaxy.libraries.library_router.back();
@@ -984,17 +991,19 @@
tmpl_array.push(' </button>');
tmpl_array.push(' <ul class="dropdown-menu" role="menu">');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');
- tmpl_array.push('<% if(user_library_import_dir !== null) { %>');
+ tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');
tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
- // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>');
- tmpl_array.push(' <li class="divider"></li>');
- tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
- // tmpl_array.push('<% if(library_import_dir !== null) { %>');
- // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
- // tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
+
+ tmpl_array.push(' <li class="divider"></li>');
+ tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
+
+ tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
+ tmpl_array.push('<% } %>');
+
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');
tmpl_array.push('<% } %>');
tmpl_array.push('<% } %>');
@@ -1154,8 +1163,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
@@ -1184,8 +1193,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb client/galaxy/scripts/mvc/ui/ui-select.js
--- a/client/galaxy/scripts/mvc/ui/ui-select.js
+++ b/client/galaxy/scripts/mvc/ui/ui-select.js
@@ -155,7 +155,6 @@
data : this.select_data,
containerCssClass : this.options.css,
placeholder : this.options.placeholder,
- width : 'resolve',
dropdownAutoWidth : true
};
this.$el.select2(select_opt);
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb lib/galaxy/webapps/galaxy/api/ftp_files.py
--- a/lib/galaxy/webapps/galaxy/api/ftp_files.py
+++ b/lib/galaxy/webapps/galaxy/api/ftp_files.py
@@ -49,7 +49,7 @@
userdir_jstree = self.__create_jstree( full_import_dir, disable )
response = userdir_jstree.jsonData()
except Exception, exception:
- log.debug(str(exception))
+ log.debug( str( exception ) )
raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( full_import_dir ) )
elif format == 'ajax':
raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' )
@@ -61,6 +61,26 @@
raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' )
else:
raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' )
+ elif target == 'importdir':
+ base_dir = trans.app.config.library_import_dir
+ if base_dir is None:
+ raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow usage of import directory.' )
+ if format == 'jstree':
+ disable = kwd.get( 'disable', 'folders')
+ try:
+ importdir_jstree = self.__create_jstree( base_dir, disable )
+ response = importdir_jstree.jsonData()
+ except Exception, exception:
+ log.debug( str( exception ) )
+ raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( base_dir ) )
+ elif format == 'ajax':
+ raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' )
+ else:
+ try:
+ response = self.__load_all_filenames( base_dir )
+ except Exception, exception:
+ log.error( 'Could not get user import files: %s', str( exception ), exc_info=True )
+ raise exceptions.InternalServerError( 'Could not get the files from your import directory folder.' )
else:
user_ftp_base_dir = trans.app.config.ftp_upload_dir
if user_ftp_base_dir is None:
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb lib/galaxy/webapps/galaxy/api/lda_datasets.py
--- a/lib/galaxy/webapps/galaxy/api/lda_datasets.py
+++ b/lib/galaxy/webapps/galaxy/api/lda_datasets.py
@@ -429,8 +429,15 @@
folder = self.folder_manager.get( trans, folder_id )
source = kwd.get( 'source', None )
- if source not in [ 'userdir_file', 'userdir_folder', 'admin_path' ]:
- raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder" and "admin_path". ')
+ if source not in [ 'userdir_file', 'userdir_folder', 'importdir_file', 'importdir_folder', 'admin_path' ]:
+ raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder", "admin_path", "importdir_file" and "importdir_folder". ')
+ if source in [ 'importdir_file', 'importdir_folder' ]:
+ if not trans.user_is_admin:
+ raise exceptions.AdminRequiredException( 'Only admins can import from importdir.' )
+ if not trans.app.config.library_import_dir:
+ raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow admins to import into library from importdir.' )
+ user_base_dir = trans.app.config.library_import_dir
+
if source in [ 'userdir_file', 'userdir_folder' ]:
user_login = trans.user.email
@@ -505,6 +512,7 @@
return job_dict
@web.expose
+ # TODO convert to expose_api
def download( self, trans, format, **kwd ):
"""
download( self, trans, format, **kwd )
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/mvc/library/library-foldertoolbar-view.js
--- a/static/scripts/mvc/library/library-foldertoolbar-view.js
+++ b/static/scripts/mvc/library/library-foldertoolbar-view.js
@@ -54,7 +54,12 @@
auto: {
id : 'auto',
text : 'Auto-detect',
- description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.'
+ description : 'This system will try to detect the file type automatically.' +
+ ' If your file is not detected properly as one of the known formats,' +
+ ' it most likely means that it has some format problems (e.g., different' +
+ ' number of columns on different rows). You can still coerce the system' +
+ ' to set your data to the format you think it should be.' +
+ ' You can also upload compressed files, which will automatically be decompressed.'
},
// genomes
@@ -73,15 +78,12 @@
id: this.options.id,
is_admin: false,
is_anonym: true,
- user_library_import_dir: Galaxy.config.user_library_import_dir,
- allow_library_path_paste: Galaxy.config.allow_library_path_paste,
- library_import_dir: Galaxy.config.library_import_dir,
mutiple_add_dataset_options: false
}
if (Galaxy.currUser){
template_defaults.is_admin = Galaxy.currUser.isAdmin();
template_defaults.is_anonym = Galaxy.currUser.isAnonymous();
- if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){
+ if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){
template_defaults.mutiple_add_dataset_options = true;
}
}
@@ -402,33 +404,38 @@
// https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy…
var that = this;
this.select_genome = new mod_select.View( {
- css: 'genome',
+ css: 'library-genome-select',
data: that.list_genomes,
- container: Galaxy.modal.$el.find( '#genome' ),
+ container: Galaxy.modal.$el.find( '#library_genome_select' ),
value: '?'
} );
this.select_extension = new mod_select.View({
- css: 'extension',
+ css: 'library-extension-select',
data: that.list_extensions,
- container: Galaxy.modal.$el.find('#extension'),
+ container: Galaxy.modal.$el.find( '#library_extension_select' ),
value: 'auto'
});
},
+
/**
- * Create modal for importing form user's directory
+ * Create modal for importing from given directory
* on Galaxy. Bind jQuery events.
*/
- importFilesFromUserdirModal: function(){
+ importFilesFromGalaxyFolderModal: function( options ){
var that = this;
+ var template_modal = this.templateBrowserModal();
this.modal = Galaxy.modal;
- var template_modal = this.templateBrowserModal();
this.modal.show({
closing_events : true,
title : 'Please select folders or files',
body : template_modal({}),
buttons : {
- 'Import' : function() {that.importFromUserdirClicked(that);},
- 'Close' : function() {Galaxy.modal.hide();}
+ 'Import' : function() {
+ that.importFromJstreePath( that, options );
+ },
+ 'Close' : function() {
+ Galaxy.modal.hide();
+ }
},
closing_callback: function(){
// TODO: should not trigger routes outside of the router
@@ -437,21 +444,24 @@
});
this.renderSelectBoxes();
- this.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ this.renderJstree( options );
- $('input[type=radio]').change(function(event){
+ $( 'input[type=radio]' ).change( function( event ){
if (event.target.value ==='jstree-disable-folders') {
- that.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ that.renderJstree( options );
$('.jstree-folders-message').hide();
$('.jstree-preserve-structure').hide();
$('.jstree-link-files').hide();
$('.jstree-files-message').show();
- } else if (event.target.value ==='jstree-disable-files'){
+ } else if ( event.target.value ==='jstree-disable-files' ){
$('.jstree-files-message').hide();
$('.jstree-folders-message').show();
$('.jstree-link-files').show();
$('.jstree-preserve-structure').show();
- that.renderJstree({disabled_jstree_element: 'files'});
+ options.disabled_jstree_element = 'files';
+ that.renderJstree( options );
}
}
);
@@ -463,12 +473,16 @@
* data.
* @param {[type]} options [description]
*/
- renderJstree: function(options){
+ renderJstree: function( options ){
var that = this;
- this.options = _.extend(this.options, options);
+ this.options = _.extend( this.options, options );
+ var target = options.source || 'userdir';
var disabled_jstree_element = this.options.disabled_jstree_element;
this.jstree = new mod_library_model.Jstree();
- this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element;
+ this.jstree.url = this.jstree.urlRoot +
+ '?target=' + target +
+ '&format=jstree' +
+ '&disable=' + disabled_jstree_element;
this.jstree.fetch({
success: function(model, response){
// This is to prevent double jquery load. I think. Carl is magician.
@@ -579,7 +593,7 @@
* jstree.js has to be loaded before
* @see renderJstree
*/
- importFromUserdirClicked: function ( that ){
+ importFromJstreePath: function ( that, options ){
var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true );
var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' );
var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' );
@@ -588,7 +602,7 @@
var selection_type = selected_nodes[0].type;
var paths = [];
if ( selected_nodes.length < 1 ){
- mod_toastr.info( 'You must select some items first.' );
+ mod_toastr.info( 'Please select some items first.' );
} else {
this.modal.disableButton( 'Import' );
for ( var i = selected_nodes.length - 1; i >= 0; i-- ){
@@ -598,17 +612,19 @@
}
this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } );
if ( selection_type === 'folder' ){
-
+ var full_source = options.source + '_folder';
this.chainCallImportingFolders( { paths: paths,
preserve_dirs: preserve_dirs,
link_data: link_data,
- source: 'userdir_folder',
+ source: full_source,
file_type: file_type,
dbkey: dbkey } );
} else if ( selection_type === 'file' ){
+ var full_source = options.source + '_file';
this.chainCallImportingUserdirFiles( { paths : paths,
file_type: file_type,
- dbkey: dbkey } );
+ dbkey: dbkey,
+ source: full_source } );
}
}
},
@@ -713,7 +729,7 @@
return true;
}
var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id +
- '&source=userdir_file' +
+ '&source=' + options.source +
'&path=' + popped_item +
'&file_type=' + options.file_type +
'&dbkey=' + options.dbkey ) )
@@ -760,22 +776,12 @@
'&dbkey=' + options.dbkey ) )
promise.done(function(response){
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
})
.fail(function(){
that.options.chain_call_control.failed_number += 1;
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
});
},
@@ -952,12 +958,13 @@
this.addFilesFromHistoryModal();
break;
case "importdir":
+ this.importFilesFromGalaxyFolderModal( { source: 'importdir' } );
break;
case "path":
this.importFilesFromPathModal();
break;
case "userdir":
- this.importFilesFromUserdirModal();
+ this.importFilesFromGalaxyFolderModal( { source: 'userdir' } );
break;
default:
Galaxy.libraries.library_router.back();
@@ -984,17 +991,19 @@
tmpl_array.push(' </button>');
tmpl_array.push(' <ul class="dropdown-menu" role="menu">');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');
- tmpl_array.push('<% if(user_library_import_dir !== null) { %>');
+ tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');
tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
- // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>');
- tmpl_array.push(' <li class="divider"></li>');
- tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
- // tmpl_array.push('<% if(library_import_dir !== null) { %>');
- // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
- // tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
+
+ tmpl_array.push(' <li class="divider"></li>');
+ tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
+
+ tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
+ tmpl_array.push('<% } %>');
+
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');
tmpl_array.push('<% } %>');
tmpl_array.push('<% } %>');
@@ -1154,8 +1163,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
@@ -1184,8 +1193,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/mvc/ui/ui-select.js
--- a/static/scripts/mvc/ui/ui-select.js
+++ b/static/scripts/mvc/ui/ui-select.js
@@ -155,7 +155,6 @@
data : this.select_data,
containerCssClass : this.options.css,
placeholder : this.options.placeholder,
- width : 'resolve',
dropdownAutoWidth : true
};
this.$el.select2(select_opt);
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/packed/mvc/library/library-foldertoolbar-view.js
--- a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js
+++ b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js
@@ -1,1 +1,1 @@
-define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,user_library_import_dir:Galaxy.config.user_library_import_dir,allow_library_path_paste:Galaxy.config.allow_library_path_paste,library_import_dir:Galaxy.config.library_import_dir,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(h.user_library_import_dir!==null||h.allow_library_path_paste!==false||h.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"genome",data:g.list_genomes,container:Galaxy.modal.$el.find("#genome"),value:"?"});this.select_extension=new a.View({css:"extension",data:g.list_extensions,container:Galaxy.modal.$el.find("#extension"),value:"auto"})},importFilesFromUserdirModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateBrowserModal();this.modal.show({closing_events:true,title:"Please select folders or files",body:g({}),buttons:{Import:function(){h.importFromUserdirClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes();this.renderJstree({disabled_jstree_element:"folders"});$("input[type=radio]").change(function(i){if(i.target.value==="jstree-disable-folders"){h.renderJstree({disabled_jstree_element:"folders"});$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(i.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();h.renderJstree({disabled_jstree_element:"files"})}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target=userdir&format=jstree&disable="+h;this.jstree.fetch({success:function(k,j){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(l){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:k},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromUserdirClicked:function(m){var g=$("#jstree_browser").jstree().get_selected(true);var l=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var o=this.select_genome.value();var j=g[0].type;var p=[];if(g.length<1){f.info("You must select some items first.")}else{this.modal.disableButton("Import");for(var k=g.length-1;k>=0;k--){if(g[k].li_attr.full_path!==undefined){p.push(g[k].li_attr.full_path)}}this.initChainCallControl({length:p.length,action:"adding_datasets"});if(j==="folder"){this.chainCallImportingFolders({paths:p,preserve_dirs:l,link_data:n,source:"userdir_folder",file_type:h,dbkey:o})}else{if(j==="file"){this.chainCallImportingUserdirFiles({paths:p,file_type:h,dbkey:o})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source=userdir_file&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromUserdirModal();break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}});
\ No newline at end of file
+define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(Galaxy.config.user_library_import_dir!==null||Galaxy.config.allow_library_path_paste!==false||Galaxy.config.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"library-genome-select",data:g.list_genomes,container:Galaxy.modal.$el.find("#library_genome_select"),value:"?"});this.select_extension=new a.View({css:"library-extension-select",data:g.list_extensions,container:Galaxy.modal.$el.find("#library_extension_select"),value:"auto"})},importFilesFromGalaxyFolderModal:function(g){var i=this;var h=this.templateBrowserModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Please select folders or files",body:h({}),buttons:{Import:function(){i.importFromJstreePath(i,g)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+i.id,{trigger:true})}});this.renderSelectBoxes();g.disabled_jstree_element="folders";this.renderJstree(g);$("input[type=radio]").change(function(j){if(j.target.value==="jstree-disable-folders"){g.disabled_jstree_element="folders";i.renderJstree(g);$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(j.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();g.disabled_jstree_element="files";i.renderJstree(g)}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var j=g.source||"userdir";var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target="+j+"&format=jstree&disable="+h;this.jstree.fetch({success:function(l,k){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(m){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:l},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(l,k){if(typeof k.responseJSON!=="undefined"){f.error(k.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromJstreePath:function(n,r){var g=$("#jstree_browser").jstree().get_selected(true);var m=this.modal.$el.find(".preserve-checkbox").is(":checked");var o=this.modal.$el.find(".link-checkbox").is(":checked");var j=this.select_extension.value();var p=this.select_genome.value();var k=g[0].type;var q=[];if(g.length<1){f.info("Please select some items first.")}else{this.modal.disableButton("Import");for(var l=g.length-1;l>=0;l--){if(g[l].li_attr.full_path!==undefined){q.push(g[l].li_attr.full_path)}}this.initChainCallControl({length:q.length,action:"adding_datasets"});if(k==="folder"){var h=r.source+"_folder";this.chainCallImportingFolders({paths:q,preserve_dirs:m,link_data:o,source:h,file_type:j,dbkey:p})}else{if(k==="file"){var h=r.source+"_file";this.chainCallImportingUserdirFiles({paths:q,file_type:j,dbkey:p,source:h})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders(g)})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":this.importFilesFromGalaxyFolderModal({source:"importdir"});break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromGalaxyFolderModal({source:"userdir"});break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(Galaxy.config.user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(Galaxy.config.library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}});
\ No newline at end of file
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/scripts/packed/mvc/ui/ui-select.js
--- a/static/scripts/packed/mvc/ui/ui-select.js
+++ b/static/scripts/packed/mvc/ui/ui-select.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,width:"resolve",dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}});
\ No newline at end of file
+define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}});
\ No newline at end of file
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/blue/base.css
--- a/static/style/blue/base.css
+++ b/static/style/blue/base.css
@@ -1323,6 +1323,8 @@
li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8}
li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9}
td.right-center{vertical-align:middle !important;text-align:right}
+.library-genome-select{max-width:350px}
+.library-extension-select{max-width:140px}
.library_table td{border-top:1px solid #5f6990 !important}
.library_table th{border-bottom:2px solid #5f6990 !important}
.library_table a{color:#0A143D}.library_table a:hover{color:maroon}
@@ -1574,6 +1576,7 @@
.jstree-default-large.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==")}
.jstree-default-large.jstree-rtl .jstree-last{background:transparent}
@media (max-width:768px){#jstree-dnd.jstree-dnd-responsive{line-height:40px;font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} #jstree-dnd.jstree-dnd-responsive>i{background:transparent;width:40px;height:40px} #jstree-dnd.jstree-dnd-responsive>.jstree-ok{background-image:url("../images/jstree/40px.png");background-position:0 -200px;background-size:120px 240px} #jstree-dnd.jstree-dnd-responsive>.jstree-er{background-image:url("../images/jstree/40px.png");background-position:-40px -200px;background-size:120px 240px} #jstree-marker.jstree-dnd-responsive{border-left-width:10px;border-top-width:10px;border-bottom-width:10px;margin-top:-10px}}@media (max-width:768px){.jstree-default-responsive{} .jstree-default-responsive .jstree-icon{background-image:url("../images/jstree/40px.png")} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-node{min-height:40px;line-height:40px;margin-left:40px;min-width:40px;white-space:nowrap} .jstree-default-responsive .jstree-anchor{line-height:40px;height:40px} .jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-icon:empty{width:40px;height:40px;line-height:40px} .jstree-default-responsive>.jstree-container-ul>.jstree-node{margin-left:0} .jstree-default-responsive.jstree-rtl .jstree-node{margin-left:0;margin-right:40px} .jstree-default-responsive.jstree-rtl .jstree-container-ul>.jstree-node{margin-right:0} .jstree-default-responsive .jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-size:120px 240px} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-open>.jstree-ocl{background-position:0 0px !important} .jstree-default-responsive .jstree-closed>.jstree-ocl{background-position:0 -40px !important} .jstree-default-responsive.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-40px 0 !important} .jstree-default-responsive .jstree-themeicon{background-position:-40px -40px} .jstree-default-responsive .jstree-checkbox,.jstree-default-responsive .jstree-checkbox:hover{background-position:-40px -80px} .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default-responsive .jstree-checked>.jstree-checkbox,.jstree-default-responsive .jstree-checked>.jstree-checkbox:hover{background-position:0 -80px} .jstree-default-responsive .jstree-anchor>.jstree-undetermined,.jstree-default-responsive .jstree-anchor>.jstree-undetermined:hover{background-position:0 -120px} .jstree-default-responsive .jstree-anchor{font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} .jstree-default-responsive>.jstree-striped{background:transparent} .jstree-default-responsive .jstree-wholerow{border-top:1px solid rgba(255,255,255,0.7);border-bottom:1px solid rgba(64,64,64,0.2);background:#ebebeb;height:40px} .jstree-default-responsive .jstree-wholerow-hovered{background:#e7f4f9} .jstree-default-responsive .jstree-wholerow-clicked{background:#beebff} .jstree-default-responsive .jstree-children .jstree-last>.jstree-wholerow{box-shadow:inset 0 -6px 3px -5px #666} .jstree-default-responsive .jstree-children .jstree-open>.jstree-wholerow{box-shadow:inset 0 6px 3px -5px #666;border-top:0} .jstree-default-responsive .jstree-children .jstree-open+.jstree-open{box-shadow:none} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-node>.jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-image:url("../images/jstree/40px.png");background-size:120px 240px} .jstree-default-responsive .jstree-node{background-position:-80px 0;background-repeat:repeat-y} .jstree-default-responsive .jstree-last{background:transparent} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background-position:-40px -120px} .jstree-default-responsive .jstree-last>.jstree-ocl{background-position:-40px -160px} .jstree-default-responsive .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0} .jstree-default-responsive .jstree-file{background:url("../images/jstree/40px.png") 0 -160px no-repeat;background-size:120px 240px} .jstree-default-responsive .jstree-folder{background:url("../images/jstree/40px.png") -40px -40px no-repeat;background-size:120px 240px}}.jstree-default>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0}
+.select2-minwidth{min-width:256px}
.unselectable{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}
.parent-width{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;*width:90%}
.clear:before,.clear:after{content:" ";display:table;}
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/blue/library.css
--- a/static/style/blue/library.css
+++ b/static/style/blue/library.css
@@ -7,6 +7,8 @@
li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8}
li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9}
td.right-center{vertical-align:middle !important;text-align:right}
+.library-genome-select{max-width:350px}
+.library-extension-select{max-width:140px}
.library_table td{border-top:1px solid #5f6990 !important}
.library_table th{border-bottom:2px solid #5f6990 !important}
.library_table a{color:#0A143D}.library_table a:hover{color:maroon}
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/src/less/base.less
--- a/static/style/src/less/base.less
+++ b/static/style/src/less/base.less
@@ -31,6 +31,11 @@
// Mixins
+/* fix for zero width select2 - remove when fixed there */
+.select2-minwidth {
+ min-width: 256px;
+}
+
.unselectable {
.user-select(none);
}
diff -r 10bf4bbcc3fa0ade8b325aa814b21655c3b33ba1 -r c29f651e4accc25bb1ba5aba78cf4e84409c6fcb static/style/src/less/library.less
--- a/static/style/src/less/library.less
+++ b/static/style/src/less/library.less
@@ -29,13 +29,19 @@
background-color: @table-bg-accent;
}
-td.right-center{
+td.right-center {
vertical-align: middle !important;
text-align: right;
-
}
-.library_table{
+.library-genome-select {
+ max-width: 350px;
+}
+.library-extension-select {
+ max-width: 140px;
+}
+
+.library_table {
td {
border-top:1px solid #5f6990 !important;
}
https://bitbucket.org/galaxy/galaxy-central/commits/1af9145657c0/
Changeset: 1af9145657c0
Branch: next-stable
User: martenson
Date: 2014-09-26 19:17:35+00:00
Summary: select2 fixes and impl. of missing feature import from path
Affected #: 12 files
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
--- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
+++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
@@ -54,7 +54,12 @@
auto: {
id : 'auto',
text : 'Auto-detect',
- description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.'
+ description : 'This system will try to detect the file type automatically.' +
+ ' If your file is not detected properly as one of the known formats,' +
+ ' it most likely means that it has some format problems (e.g., different' +
+ ' number of columns on different rows). You can still coerce the system' +
+ ' to set your data to the format you think it should be.' +
+ ' You can also upload compressed files, which will automatically be decompressed.'
},
// genomes
@@ -73,15 +78,12 @@
id: this.options.id,
is_admin: false,
is_anonym: true,
- user_library_import_dir: Galaxy.config.user_library_import_dir,
- allow_library_path_paste: Galaxy.config.allow_library_path_paste,
- library_import_dir: Galaxy.config.library_import_dir,
mutiple_add_dataset_options: false
}
if (Galaxy.currUser){
template_defaults.is_admin = Galaxy.currUser.isAdmin();
template_defaults.is_anonym = Galaxy.currUser.isAnonymous();
- if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){
+ if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){
template_defaults.mutiple_add_dataset_options = true;
}
}
@@ -402,33 +404,38 @@
// https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy…
var that = this;
this.select_genome = new mod_select.View( {
- css: 'genome',
+ css: 'library-genome-select',
data: that.list_genomes,
- container: Galaxy.modal.$el.find( '#genome' ),
+ container: Galaxy.modal.$el.find( '#library_genome_select' ),
value: '?'
} );
this.select_extension = new mod_select.View({
- css: 'extension',
+ css: 'library-extension-select',
data: that.list_extensions,
- container: Galaxy.modal.$el.find('#extension'),
+ container: Galaxy.modal.$el.find( '#library_extension_select' ),
value: 'auto'
});
},
+
/**
- * Create modal for importing form user's directory
+ * Create modal for importing from given directory
* on Galaxy. Bind jQuery events.
*/
- importFilesFromUserdirModal: function(){
+ importFilesFromGalaxyFolderModal: function( options ){
var that = this;
+ var template_modal = this.templateBrowserModal();
this.modal = Galaxy.modal;
- var template_modal = this.templateBrowserModal();
this.modal.show({
closing_events : true,
title : 'Please select folders or files',
body : template_modal({}),
buttons : {
- 'Import' : function() {that.importFromUserdirClicked(that);},
- 'Close' : function() {Galaxy.modal.hide();}
+ 'Import' : function() {
+ that.importFromJstreePath( that, options );
+ },
+ 'Close' : function() {
+ Galaxy.modal.hide();
+ }
},
closing_callback: function(){
// TODO: should not trigger routes outside of the router
@@ -437,21 +444,24 @@
});
this.renderSelectBoxes();
- this.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ this.renderJstree( options );
- $('input[type=radio]').change(function(event){
+ $( 'input[type=radio]' ).change( function( event ){
if (event.target.value ==='jstree-disable-folders') {
- that.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ that.renderJstree( options );
$('.jstree-folders-message').hide();
$('.jstree-preserve-structure').hide();
$('.jstree-link-files').hide();
$('.jstree-files-message').show();
- } else if (event.target.value ==='jstree-disable-files'){
+ } else if ( event.target.value ==='jstree-disable-files' ){
$('.jstree-files-message').hide();
$('.jstree-folders-message').show();
$('.jstree-link-files').show();
$('.jstree-preserve-structure').show();
- that.renderJstree({disabled_jstree_element: 'files'});
+ options.disabled_jstree_element = 'files';
+ that.renderJstree( options );
}
}
);
@@ -463,12 +473,16 @@
* data.
* @param {[type]} options [description]
*/
- renderJstree: function(options){
+ renderJstree: function( options ){
var that = this;
- this.options = _.extend(this.options, options);
+ this.options = _.extend( this.options, options );
+ var target = options.source || 'userdir';
var disabled_jstree_element = this.options.disabled_jstree_element;
this.jstree = new mod_library_model.Jstree();
- this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element;
+ this.jstree.url = this.jstree.urlRoot +
+ '?target=' + target +
+ '&format=jstree' +
+ '&disable=' + disabled_jstree_element;
this.jstree.fetch({
success: function(model, response){
// This is to prevent double jquery load. I think. Carl is magician.
@@ -579,7 +593,7 @@
* jstree.js has to be loaded before
* @see renderJstree
*/
- importFromUserdirClicked: function ( that ){
+ importFromJstreePath: function ( that, options ){
var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true );
var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' );
var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' );
@@ -588,7 +602,7 @@
var selection_type = selected_nodes[0].type;
var paths = [];
if ( selected_nodes.length < 1 ){
- mod_toastr.info( 'You must select some items first.' );
+ mod_toastr.info( 'Please select some items first.' );
} else {
this.modal.disableButton( 'Import' );
for ( var i = selected_nodes.length - 1; i >= 0; i-- ){
@@ -598,17 +612,19 @@
}
this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } );
if ( selection_type === 'folder' ){
-
+ var full_source = options.source + '_folder';
this.chainCallImportingFolders( { paths: paths,
preserve_dirs: preserve_dirs,
link_data: link_data,
- source: 'userdir_folder',
+ source: full_source,
file_type: file_type,
dbkey: dbkey } );
} else if ( selection_type === 'file' ){
+ var full_source = options.source + '_file';
this.chainCallImportingUserdirFiles( { paths : paths,
file_type: file_type,
- dbkey: dbkey } );
+ dbkey: dbkey,
+ source: full_source } );
}
}
},
@@ -713,7 +729,7 @@
return true;
}
var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id +
- '&source=userdir_file' +
+ '&source=' + options.source +
'&path=' + popped_item +
'&file_type=' + options.file_type +
'&dbkey=' + options.dbkey ) )
@@ -760,22 +776,12 @@
'&dbkey=' + options.dbkey ) )
promise.done(function(response){
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
})
.fail(function(){
that.options.chain_call_control.failed_number += 1;
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
});
},
@@ -952,12 +958,13 @@
this.addFilesFromHistoryModal();
break;
case "importdir":
+ this.importFilesFromGalaxyFolderModal( { source: 'importdir' } );
break;
case "path":
this.importFilesFromPathModal();
break;
case "userdir":
- this.importFilesFromUserdirModal();
+ this.importFilesFromGalaxyFolderModal( { source: 'userdir' } );
break;
default:
Galaxy.libraries.library_router.back();
@@ -984,17 +991,19 @@
tmpl_array.push(' </button>');
tmpl_array.push(' <ul class="dropdown-menu" role="menu">');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');
- tmpl_array.push('<% if(user_library_import_dir !== null) { %>');
+ tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');
tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
- // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>');
- tmpl_array.push(' <li class="divider"></li>');
- tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
- // tmpl_array.push('<% if(library_import_dir !== null) { %>');
- // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
- // tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
+
+ tmpl_array.push(' <li class="divider"></li>');
+ tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
+
+ tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
+ tmpl_array.push('<% } %>');
+
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');
tmpl_array.push('<% } %>');
tmpl_array.push('<% } %>');
@@ -1154,8 +1163,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
@@ -1184,8 +1193,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d client/galaxy/scripts/mvc/ui/ui-select.js
--- a/client/galaxy/scripts/mvc/ui/ui-select.js
+++ b/client/galaxy/scripts/mvc/ui/ui-select.js
@@ -155,7 +155,6 @@
data : this.select_data,
containerCssClass : this.options.css,
placeholder : this.options.placeholder,
- width : 'resolve',
dropdownAutoWidth : true
};
this.$el.select2(select_opt);
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d lib/galaxy/webapps/galaxy/api/ftp_files.py
--- a/lib/galaxy/webapps/galaxy/api/ftp_files.py
+++ b/lib/galaxy/webapps/galaxy/api/ftp_files.py
@@ -49,7 +49,7 @@
userdir_jstree = self.__create_jstree( full_import_dir, disable )
response = userdir_jstree.jsonData()
except Exception, exception:
- log.debug(str(exception))
+ log.debug( str( exception ) )
raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( full_import_dir ) )
elif format == 'ajax':
raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' )
@@ -61,6 +61,26 @@
raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' )
else:
raise exceptions.InternalServerError( 'Could not get the files from your user directory folder.' )
+ elif target == 'importdir':
+ base_dir = trans.app.config.library_import_dir
+ if base_dir is None:
+ raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow usage of import directory.' )
+ if format == 'jstree':
+ disable = kwd.get( 'disable', 'folders')
+ try:
+ importdir_jstree = self.__create_jstree( base_dir, disable )
+ response = importdir_jstree.jsonData()
+ except Exception, exception:
+ log.debug( str( exception ) )
+ raise exceptions.InternalServerError( 'Could not create tree representation of the given folder: ' + str( base_dir ) )
+ elif format == 'ajax':
+ raise exceptions.NotImplemented( 'Not implemented yet. Sorry.' )
+ else:
+ try:
+ response = self.__load_all_filenames( base_dir )
+ except Exception, exception:
+ log.error( 'Could not get user import files: %s', str( exception ), exc_info=True )
+ raise exceptions.InternalServerError( 'Could not get the files from your import directory folder.' )
else:
user_ftp_base_dir = trans.app.config.ftp_upload_dir
if user_ftp_base_dir is None:
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d lib/galaxy/webapps/galaxy/api/lda_datasets.py
--- a/lib/galaxy/webapps/galaxy/api/lda_datasets.py
+++ b/lib/galaxy/webapps/galaxy/api/lda_datasets.py
@@ -429,8 +429,15 @@
folder = self.folder_manager.get( trans, folder_id )
source = kwd.get( 'source', None )
- if source not in [ 'userdir_file', 'userdir_folder', 'admin_path' ]:
- raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder" and "admin_path". ')
+ if source not in [ 'userdir_file', 'userdir_folder', 'importdir_file', 'importdir_folder', 'admin_path' ]:
+ raise exceptions.RequestParameterMissingException( 'You have to specify "source" parameter. Possible values are "userdir_file", "userdir_folder", "admin_path", "importdir_file" and "importdir_folder". ')
+ if source in [ 'importdir_file', 'importdir_folder' ]:
+ if not trans.user_is_admin:
+ raise exceptions.AdminRequiredException( 'Only admins can import from importdir.' )
+ if not trans.app.config.library_import_dir:
+ raise exceptions.ConfigDoesNotAllowException( 'The configuration of this Galaxy instance does not allow admins to import into library from importdir.' )
+ user_base_dir = trans.app.config.library_import_dir
+
if source in [ 'userdir_file', 'userdir_folder' ]:
user_login = trans.user.email
@@ -505,6 +512,7 @@
return job_dict
@web.expose
+ # TODO convert to expose_api
def download( self, trans, format, **kwd ):
"""
download( self, trans, format, **kwd )
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/mvc/library/library-foldertoolbar-view.js
--- a/static/scripts/mvc/library/library-foldertoolbar-view.js
+++ b/static/scripts/mvc/library/library-foldertoolbar-view.js
@@ -54,7 +54,12 @@
auto: {
id : 'auto',
text : 'Auto-detect',
- description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.'
+ description : 'This system will try to detect the file type automatically.' +
+ ' If your file is not detected properly as one of the known formats,' +
+ ' it most likely means that it has some format problems (e.g., different' +
+ ' number of columns on different rows). You can still coerce the system' +
+ ' to set your data to the format you think it should be.' +
+ ' You can also upload compressed files, which will automatically be decompressed.'
},
// genomes
@@ -73,15 +78,12 @@
id: this.options.id,
is_admin: false,
is_anonym: true,
- user_library_import_dir: Galaxy.config.user_library_import_dir,
- allow_library_path_paste: Galaxy.config.allow_library_path_paste,
- library_import_dir: Galaxy.config.library_import_dir,
mutiple_add_dataset_options: false
}
if (Galaxy.currUser){
template_defaults.is_admin = Galaxy.currUser.isAdmin();
template_defaults.is_anonym = Galaxy.currUser.isAnonymous();
- if (template_defaults.user_library_import_dir !== null || template_defaults.allow_library_path_paste !== false || template_defaults.library_import_dir !== null ){
+ if ( Galaxy.config.user_library_import_dir !== null || Galaxy.config.allow_library_path_paste !== false || Galaxy.config.library_import_dir !== null ){
template_defaults.mutiple_add_dataset_options = true;
}
}
@@ -402,33 +404,38 @@
// https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy…
var that = this;
this.select_genome = new mod_select.View( {
- css: 'genome',
+ css: 'library-genome-select',
data: that.list_genomes,
- container: Galaxy.modal.$el.find( '#genome' ),
+ container: Galaxy.modal.$el.find( '#library_genome_select' ),
value: '?'
} );
this.select_extension = new mod_select.View({
- css: 'extension',
+ css: 'library-extension-select',
data: that.list_extensions,
- container: Galaxy.modal.$el.find('#extension'),
+ container: Galaxy.modal.$el.find( '#library_extension_select' ),
value: 'auto'
});
},
+
/**
- * Create modal for importing form user's directory
+ * Create modal for importing from given directory
* on Galaxy. Bind jQuery events.
*/
- importFilesFromUserdirModal: function(){
+ importFilesFromGalaxyFolderModal: function( options ){
var that = this;
+ var template_modal = this.templateBrowserModal();
this.modal = Galaxy.modal;
- var template_modal = this.templateBrowserModal();
this.modal.show({
closing_events : true,
title : 'Please select folders or files',
body : template_modal({}),
buttons : {
- 'Import' : function() {that.importFromUserdirClicked(that);},
- 'Close' : function() {Galaxy.modal.hide();}
+ 'Import' : function() {
+ that.importFromJstreePath( that, options );
+ },
+ 'Close' : function() {
+ Galaxy.modal.hide();
+ }
},
closing_callback: function(){
// TODO: should not trigger routes outside of the router
@@ -437,21 +444,24 @@
});
this.renderSelectBoxes();
- this.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ this.renderJstree( options );
- $('input[type=radio]').change(function(event){
+ $( 'input[type=radio]' ).change( function( event ){
if (event.target.value ==='jstree-disable-folders') {
- that.renderJstree({disabled_jstree_element: 'folders'});
+ options.disabled_jstree_element = 'folders';
+ that.renderJstree( options );
$('.jstree-folders-message').hide();
$('.jstree-preserve-structure').hide();
$('.jstree-link-files').hide();
$('.jstree-files-message').show();
- } else if (event.target.value ==='jstree-disable-files'){
+ } else if ( event.target.value ==='jstree-disable-files' ){
$('.jstree-files-message').hide();
$('.jstree-folders-message').show();
$('.jstree-link-files').show();
$('.jstree-preserve-structure').show();
- that.renderJstree({disabled_jstree_element: 'files'});
+ options.disabled_jstree_element = 'files';
+ that.renderJstree( options );
}
}
);
@@ -463,12 +473,16 @@
* data.
* @param {[type]} options [description]
*/
- renderJstree: function(options){
+ renderJstree: function( options ){
var that = this;
- this.options = _.extend(this.options, options);
+ this.options = _.extend( this.options, options );
+ var target = options.source || 'userdir';
var disabled_jstree_element = this.options.disabled_jstree_element;
this.jstree = new mod_library_model.Jstree();
- this.jstree.url = this.jstree.urlRoot + '?target=userdir&format=jstree&disable=' + disabled_jstree_element;
+ this.jstree.url = this.jstree.urlRoot +
+ '?target=' + target +
+ '&format=jstree' +
+ '&disable=' + disabled_jstree_element;
this.jstree.fetch({
success: function(model, response){
// This is to prevent double jquery load. I think. Carl is magician.
@@ -579,7 +593,7 @@
* jstree.js has to be loaded before
* @see renderJstree
*/
- importFromUserdirClicked: function ( that ){
+ importFromJstreePath: function ( that, options ){
var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true );
var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' );
var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' );
@@ -588,7 +602,7 @@
var selection_type = selected_nodes[0].type;
var paths = [];
if ( selected_nodes.length < 1 ){
- mod_toastr.info( 'You must select some items first.' );
+ mod_toastr.info( 'Please select some items first.' );
} else {
this.modal.disableButton( 'Import' );
for ( var i = selected_nodes.length - 1; i >= 0; i-- ){
@@ -598,17 +612,19 @@
}
this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } );
if ( selection_type === 'folder' ){
-
+ var full_source = options.source + '_folder';
this.chainCallImportingFolders( { paths: paths,
preserve_dirs: preserve_dirs,
link_data: link_data,
- source: 'userdir_folder',
+ source: full_source,
file_type: file_type,
dbkey: dbkey } );
} else if ( selection_type === 'file' ){
+ var full_source = options.source + '_file';
this.chainCallImportingUserdirFiles( { paths : paths,
file_type: file_type,
- dbkey: dbkey } );
+ dbkey: dbkey,
+ source: full_source } );
}
}
},
@@ -713,7 +729,7 @@
return true;
}
var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id +
- '&source=userdir_file' +
+ '&source=' + options.source +
'&path=' + popped_item +
'&file_type=' + options.file_type +
'&dbkey=' + options.dbkey ) )
@@ -760,22 +776,12 @@
'&dbkey=' + options.dbkey ) )
promise.done(function(response){
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
})
.fail(function(){
that.options.chain_call_control.failed_number += 1;
that.updateProgress();
- that.chainCallImportingFolders( { paths: options.paths,
- preserve_dirs: options.preserve_dirs,
- link_data: options.link_data,
- source: options.source,
- file_type: options.file_type,
- dbkey: options.dbkey } );
+ that.chainCallImportingFolders( options );
});
},
@@ -952,12 +958,13 @@
this.addFilesFromHistoryModal();
break;
case "importdir":
+ this.importFilesFromGalaxyFolderModal( { source: 'importdir' } );
break;
case "path":
this.importFilesFromPathModal();
break;
case "userdir":
- this.importFilesFromUserdirModal();
+ this.importFilesFromGalaxyFolderModal( { source: 'userdir' } );
break;
default:
Galaxy.libraries.library_router.back();
@@ -984,17 +991,19 @@
tmpl_array.push(' </button>');
tmpl_array.push(' <ul class="dropdown-menu" role="menu">');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');
- tmpl_array.push('<% if(user_library_import_dir !== null) { %>');
+ tmpl_array.push('<% if(Galaxy.config.user_library_import_dir !== null) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');
tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
- // tmpl_array.push('<% if(allow_library_path_paste || library_import_dir !== null) { %>');
- tmpl_array.push(' <li class="divider"></li>');
- tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
- // tmpl_array.push('<% if(library_import_dir !== null) { %>');
- // tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
- // tmpl_array.push('<% } %>');
- tmpl_array.push('<% if(allow_library_path_paste) { %>');
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
+
+ tmpl_array.push(' <li class="divider"></li>');
+ tmpl_array.push(' <li class="dropdown-header">Admins only</li>');
+
+ tmpl_array.push('<% if(Galaxy.config.library_import_dir !== null) { %>');
+ tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');
+ tmpl_array.push('<% } %>');
+
+ tmpl_array.push('<% if(Galaxy.config.allow_library_path_paste) { %>');
tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');
tmpl_array.push('<% } %>');
tmpl_array.push('<% } %>');
@@ -1154,8 +1163,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
@@ -1184,8 +1193,8 @@
tmpl_array.push('<hr />');
tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>');
tmpl_array.push('<div>');
- tmpl_array.push('Type: <span id="extension" class="extension" />');
- tmpl_array.push(' Genome: <span id="genome" class="genome" />');
+ tmpl_array.push('Type: <span id="library_extension_select" class="library-extension-select" />');
+ tmpl_array.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');
tmpl_array.push('</div>');
tmpl_array.push('</div>');
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/mvc/ui/ui-select.js
--- a/static/scripts/mvc/ui/ui-select.js
+++ b/static/scripts/mvc/ui/ui-select.js
@@ -155,7 +155,6 @@
data : this.select_data,
containerCssClass : this.options.css,
placeholder : this.options.placeholder,
- width : 'resolve',
dropdownAutoWidth : true
};
this.$el.select2(select_opt);
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/packed/mvc/library/library-foldertoolbar-view.js
--- a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js
+++ b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js
@@ -1,1 +1,1 @@
-define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,user_library_import_dir:Galaxy.config.user_library_import_dir,allow_library_path_paste:Galaxy.config.allow_library_path_paste,library_import_dir:Galaxy.config.library_import_dir,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(h.user_library_import_dir!==null||h.allow_library_path_paste!==false||h.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"genome",data:g.list_genomes,container:Galaxy.modal.$el.find("#genome"),value:"?"});this.select_extension=new a.View({css:"extension",data:g.list_extensions,container:Galaxy.modal.$el.find("#extension"),value:"auto"})},importFilesFromUserdirModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateBrowserModal();this.modal.show({closing_events:true,title:"Please select folders or files",body:g({}),buttons:{Import:function(){h.importFromUserdirClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes();this.renderJstree({disabled_jstree_element:"folders"});$("input[type=radio]").change(function(i){if(i.target.value==="jstree-disable-folders"){h.renderJstree({disabled_jstree_element:"folders"});$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(i.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();h.renderJstree({disabled_jstree_element:"files"})}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target=userdir&format=jstree&disable="+h;this.jstree.fetch({success:function(k,j){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(l){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:k},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromUserdirClicked:function(m){var g=$("#jstree_browser").jstree().get_selected(true);var l=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var o=this.select_genome.value();var j=g[0].type;var p=[];if(g.length<1){f.info("You must select some items first.")}else{this.modal.disableButton("Import");for(var k=g.length-1;k>=0;k--){if(g[k].li_attr.full_path!==undefined){p.push(g[k].li_attr.full_path)}}this.initChainCallControl({length:p.length,action:"adding_datasets"});if(j==="folder"){this.chainCallImportingFolders({paths:p,preserve_dirs:l,link_data:n,source:"userdir_folder",file_type:h,dbkey:o})}else{if(j==="file"){this.chainCallImportingUserdirFiles({paths:p,file_type:h,dbkey:o})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source=userdir_file&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromUserdirModal();break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}});
\ No newline at end of file
+define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(Galaxy.config.user_library_import_dir!==null||Galaxy.config.allow_library_path_paste!==false||Galaxy.config.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ld_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"library-genome-select",data:g.list_genomes,container:Galaxy.modal.$el.find("#library_genome_select"),value:"?"});this.select_extension=new a.View({css:"library-extension-select",data:g.list_extensions,container:Galaxy.modal.$el.find("#library_extension_select"),value:"auto"})},importFilesFromGalaxyFolderModal:function(g){var i=this;var h=this.templateBrowserModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Please select folders or files",body:h({}),buttons:{Import:function(){i.importFromJstreePath(i,g)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+i.id,{trigger:true})}});this.renderSelectBoxes();g.disabled_jstree_element="folders";this.renderJstree(g);$("input[type=radio]").change(function(j){if(j.target.value==="jstree-disable-folders"){g.disabled_jstree_element="folders";i.renderJstree(g);$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(j.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();g.disabled_jstree_element="files";i.renderJstree(g)}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var j=g.source||"userdir";var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target="+j+"&format=jstree&disable="+h;this.jstree.fetch({success:function(l,k){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(m){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:l},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(l,k){if(typeof k.responseJSON!=="undefined"){f.error(k.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromJstreePath:function(n,r){var g=$("#jstree_browser").jstree().get_selected(true);var m=this.modal.$el.find(".preserve-checkbox").is(":checked");var o=this.modal.$el.find(".link-checkbox").is(":checked");var j=this.select_extension.value();var p=this.select_genome.value();var k=g[0].type;var q=[];if(g.length<1){f.info("Please select some items first.")}else{this.modal.disableButton("Import");for(var l=g.length-1;l>=0;l--){if(g[l].li_attr.full_path!==undefined){q.push(g[l].li_attr.full_path)}}this.initChainCallControl({length:q.length,action:"adding_datasets"});if(k==="folder"){var h=r.source+"_folder";this.chainCallImportingFolders({paths:q,preserve_dirs:m,link_data:o,source:h,file_type:j,dbkey:p})}else{if(k==="file"){var h=r.source+"_file";this.chainCallImportingUserdirFiles({paths:q,file_type:j,dbkey:p,source:h})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders(g)})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":this.importFilesFromGalaxyFolderModal({source:"importdir"});break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromGalaxyFolderModal({source:"userdir"});break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(Galaxy.config.user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(Galaxy.config.library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/importdir">from Import Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(Galaxy.config.allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="library_extension_select" class="library-extension-select" />');g.push(' Genome: <span id="library_genome_select" class="library-genome-select" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}});
\ No newline at end of file
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/scripts/packed/mvc/ui/ui-select.js
--- a/static/scripts/packed/mvc/ui/ui-select.js
+++ b/static/scripts/packed/mvc/ui/ui-select.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,width:"resolve",dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}});
\ No newline at end of file
+define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}});
\ No newline at end of file
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/blue/base.css
--- a/static/style/blue/base.css
+++ b/static/style/blue/base.css
@@ -1322,6 +1322,8 @@
li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8}
li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9}
td.right-center{vertical-align:middle !important;text-align:right}
+.library-genome-select{max-width:350px}
+.library-extension-select{max-width:140px}
.library_table td{border-top:1px solid #5f6990 !important}
.library_table th{border-bottom:2px solid #5f6990 !important}
.library_table a{color:#0A143D}.library_table a:hover{color:maroon}
@@ -1573,6 +1575,7 @@
.jstree-default-large.jstree-rtl .jstree-node{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==")}
.jstree-default-large.jstree-rtl .jstree-last{background:transparent}
@media (max-width:768px){#jstree-dnd.jstree-dnd-responsive{line-height:40px;font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} #jstree-dnd.jstree-dnd-responsive>i{background:transparent;width:40px;height:40px} #jstree-dnd.jstree-dnd-responsive>.jstree-ok{background-image:url("../images/jstree/40px.png");background-position:0 -200px;background-size:120px 240px} #jstree-dnd.jstree-dnd-responsive>.jstree-er{background-image:url("../images/jstree/40px.png");background-position:-40px -200px;background-size:120px 240px} #jstree-marker.jstree-dnd-responsive{border-left-width:10px;border-top-width:10px;border-bottom-width:10px;margin-top:-10px}}@media (max-width:768px){.jstree-default-responsive{} .jstree-default-responsive .jstree-icon{background-image:url("../images/jstree/40px.png")} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-node{min-height:40px;line-height:40px;margin-left:40px;min-width:40px;white-space:nowrap} .jstree-default-responsive .jstree-anchor{line-height:40px;height:40px} .jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-icon:empty{width:40px;height:40px;line-height:40px} .jstree-default-responsive>.jstree-container-ul>.jstree-node{margin-left:0} .jstree-default-responsive.jstree-rtl .jstree-node{margin-left:0;margin-right:40px} .jstree-default-responsive.jstree-rtl .jstree-container-ul>.jstree-node{margin-right:0} .jstree-default-responsive .jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-size:120px 240px} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background:transparent} .jstree-default-responsive .jstree-open>.jstree-ocl{background-position:0 0px !important} .jstree-default-responsive .jstree-closed>.jstree-ocl{background-position:0 -40px !important} .jstree-default-responsive.jstree-rtl .jstree-closed>.jstree-ocl{background-position:-40px 0 !important} .jstree-default-responsive .jstree-themeicon{background-position:-40px -40px} .jstree-default-responsive .jstree-checkbox,.jstree-default-responsive .jstree-checkbox:hover{background-position:-40px -80px} .jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox,.jstree-default-responsive.jstree-checkbox-selection .jstree-clicked>.jstree-checkbox:hover,.jstree-default-responsive .jstree-checked>.jstree-checkbox,.jstree-default-responsive .jstree-checked>.jstree-checkbox:hover{background-position:0 -80px} .jstree-default-responsive .jstree-anchor>.jstree-undetermined,.jstree-default-responsive .jstree-anchor>.jstree-undetermined:hover{background-position:0 -120px} .jstree-default-responsive .jstree-anchor{font-weight:bold;font-size:1.1em;text-shadow:1px 1px white} .jstree-default-responsive>.jstree-striped{background:transparent} .jstree-default-responsive .jstree-wholerow{border-top:1px solid rgba(255,255,255,0.7);border-bottom:1px solid rgba(64,64,64,0.2);background:#ebebeb;height:40px} .jstree-default-responsive .jstree-wholerow-hovered{background:#e7f4f9} .jstree-default-responsive .jstree-wholerow-clicked{background:#beebff} .jstree-default-responsive .jstree-children .jstree-last>.jstree-wholerow{box-shadow:inset 0 -6px 3px -5px #666} .jstree-default-responsive .jstree-children .jstree-open>.jstree-wholerow{box-shadow:inset 0 6px 3px -5px #666;border-top:0} .jstree-default-responsive .jstree-children .jstree-open+.jstree-open{box-shadow:none} .jstree-default-responsive .jstree-node,.jstree-default-responsive .jstree-icon,.jstree-default-responsive .jstree-node>.jstree-ocl,.jstree-default-responsive .jstree-themeicon,.jstree-default-responsive .jstree-checkbox{background-image:url("../images/jstree/40px.png");background-size:120px 240px} .jstree-default-responsive .jstree-node{background-position:-80px 0;background-repeat:repeat-y} .jstree-default-responsive .jstree-last{background:transparent} .jstree-default-responsive .jstree-leaf>.jstree-ocl{background-position:-40px -120px} .jstree-default-responsive .jstree-last>.jstree-ocl{background-position:-40px -160px} .jstree-default-responsive .jstree-themeicon-custom{background-color:transparent;background-image:none;background-position:0 0} .jstree-default-responsive .jstree-file{background:url("../images/jstree/40px.png") 0 -160px no-repeat;background-size:120px 240px} .jstree-default-responsive .jstree-folder{background:url("../images/jstree/40px.png") -40px -40px no-repeat;background-size:120px 240px}}.jstree-default>.jstree-container-ul>.jstree-node{margin-left:0;margin-right:0}
+.select2-minwidth{min-width:256px}
.unselectable{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}
.parent-width{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;*width:90%}
.clear:before,.clear:after{content:" ";display:table;}
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/blue/library.css
--- a/static/style/blue/library.css
+++ b/static/style/blue/library.css
@@ -7,6 +7,8 @@
li.folderRow,li.datasetRow{border-top:solid 1px #c6bfa8}
li.folderRow:hover,li.datasetRow:hover{background-color:#f9f9f9}
td.right-center{vertical-align:middle !important;text-align:right}
+.library-genome-select{max-width:350px}
+.library-extension-select{max-width:140px}
.library_table td{border-top:1px solid #5f6990 !important}
.library_table th{border-bottom:2px solid #5f6990 !important}
.library_table a{color:#0A143D}.library_table a:hover{color:maroon}
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/src/less/base.less
--- a/static/style/src/less/base.less
+++ b/static/style/src/less/base.less
@@ -31,6 +31,11 @@
// Mixins
+/* fix for zero width select2 - remove when fixed there */
+.select2-minwidth {
+ min-width: 256px;
+}
+
.unselectable {
.user-select(none);
}
diff -r 1a87b74d4f428ac25dfe5517506ec16bfa9a1bc4 -r 1af9145657c0fc74175ee57fd2d696b9fc454a8d static/style/src/less/library.less
--- a/static/style/src/less/library.less
+++ b/static/style/src/less/library.less
@@ -29,13 +29,19 @@
background-color: @table-bg-accent;
}
-td.right-center{
+td.right-center {
vertical-align: middle !important;
text-align: right;
-
}
-.library_table{
+.library-genome-select {
+ max-width: 350px;
+}
+.library-extension-select {
+ max-width: 140px;
+}
+
+.library_table {
td {
border-top:1px solid #5f6990 !important;
}
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.
1
0