Combine scratchbook requires

This commit is contained in:
Dannon Baker
2017-10-23 16:39:07 -04:00
parent 07e9e94c24
commit 116fb05038
11 changed files with 217 additions and 215 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
define([],function(){"use strict";define(["mvc/ui/ui-frames"],function(t){return Backbone.View.extend({initialize:function(e){var i=this;e=e||{},this.frames=new t.View({visible:!1}),this.setElement(this.frames.$el),this.buttonActive=e.collection.add({id:"enable-scratchbook",icon:"fa-th",tooltip:_l("Enable/Disable Scratchbook"),onclick:function(){i.active=!i.active,i.buttonActive.set({toggle:i.active,show_note:i.active,note_cls:i.active&&"fa fa-check"}),!i.active&&i.frames.hide()},onbeforeunload:function(){if(i.frames.length()>0)return"You opened "+i.frames.length()+" frame(s) which will be lost."}}),this.buttonLoad=e.collection.add({id:"show-scratchbook",icon:"fa-eye",tooltip:_l("Show/Hide Scratchbook"),show_note:!0,visible:!1,onclick:function(t){i.frames.visible?i.frames.hide():i.frames.show()}}),this.frames.on("add remove",function(){this.visible&&0==this.length()&&this.hide(),i.buttonLoad.set({note:this.length(),visible:this.length()>0})}).on("show hide ",function(){i.buttonLoad.set({toggle:this.visible,icon:this.visible&&"fa-eye"||"fa-eye-slash"})}),this.history_cache={}},addDataset:function(t){var e=this,i=null;if(Galaxy&&Galaxy.currHistoryPanel){var a=Galaxy.currHistoryPanel.collection.historyId;this.history_cache[a]={name:Galaxy.currHistoryPanel.model.get("name"),dataset_ids:[]},Galaxy.currHistoryPanel.collection.each(function(t){!t.get("deleted")&&t.get("visible")&&e.history_cache[a].dataset_ids.push(t.get("id"))})}var n=function(t,i){if(t){var a=e.history_cache[t.get("history_id")];if(a&&a.dataset_ids){var n=a.dataset_ids,o=n.indexOf(t.get("id"));if(-1!==o&&o+i>=0&&o+i<n.length)return n[o+i]}}},o=function(t,a,o){var r=n(t,a);r?e._loadDataset(r,function(t,e){i=t,o.model.set(e)}):o.model.trigger("change")};this._loadDataset(t,function(t,a){i=t,e.add(_.extend({menu:[{icon:"fa fa-chevron-circle-left",tooltip:"Previous in History",onclick:function(t){o(i,-1,t)},disabled:function(){return!n(i,-1)}},{icon:"fa fa-chevron-circle-right",tooltip:"Next in History",onclick:function(t){o(i,1,t)},disabled:function(){return!n(i,1)}}]},a))})},_loadDataset:function(t,e){var i=this;require(["mvc/dataset/data"],function(a){var n=new a.Dataset({id:t});$.when(n.fetch()).then(function(){var o=_.find(["tabular","interval"],function(t){return-1!==n.get("data_type").indexOf(t)}),r=n.get("name"),c=i.history_cache[n.get("history_id")];c&&(r=c.name+": "+r),e(n,o?{title:r,url:null,content:a.createTabularDatasetChunkedView({model:new a.TabularDataset(n.toJSON()),embedded:!0,height:"100%"}).$el}:{title:r,url:Galaxy.root+"datasets/"+t+"/display/?preview=True",content:null})})})},addTrackster:function(t){var e=this;require(["viz/visualization","viz/trackster"],function(i,a){var n=new i.Visualization({id:t});$.when(n.fetch()).then(function(){var t=new a.TracksterUI(Galaxy.root),i={title:n.get("name"),type:"other",content:function(e){var i={container:e,name:n.get("title"),id:n.id,dbkey:n.get("dbkey"),stand_alone:!1},a=n.get("latest_revision"),o=a.config.view.drawables;_.each(o,function(t){t.dataset={hda_ldda:t.hda_ldda,id:t.dataset_id}}),view=t.create_visualization(i,a.config.viewport,a.config.view.drawables,a.config.bookmarks,!1)}};e.add(i)})})},add:function(t){if("_blank"==t.target)window.open(t.url);else if("_top"==t.target||"_parent"==t.target||"_self"==t.target)window.location=t.url;else if(!this.active||t.noscratchbook){var e=$(window.parent.document).find("#galaxy_main");"galaxy_main"==t.target||"center"==t.target?0===e.length?window.location=t.url+(-1==t.url.indexOf("?")?"?":"&")+"use_panels=True":e.attr("src",t.url):window.location=t.url}else this.frames.add(t)}})})});
define([],function(){"use strict";define(["mvc/ui/ui-frames","mvc/dataset/data","viz/visualization","viz/trackster"],function(t,e,i,a){return Backbone.View.extend({initialize:function(e){var i=this;e=e||{},this.frames=new t.View({visible:!1}),this.setElement(this.frames.$el),this.buttonActive=e.collection.add({id:"enable-scratchbook",icon:"fa-th",tooltip:_l("Enable/Disable Scratchbook"),onclick:function(){i.active=!i.active,i.buttonActive.set({toggle:i.active,show_note:i.active,note_cls:i.active&&"fa fa-check"}),!i.active&&i.frames.hide()},onbeforeunload:function(){if(i.frames.length()>0)return"You opened "+i.frames.length()+" frame(s) which will be lost."}}),this.buttonLoad=e.collection.add({id:"show-scratchbook",icon:"fa-eye",tooltip:_l("Show/Hide Scratchbook"),show_note:!0,visible:!1,onclick:function(t){i.frames.visible?i.frames.hide():i.frames.show()}}),this.frames.on("add remove",function(){this.visible&&0==this.length()&&this.hide(),i.buttonLoad.set({note:this.length(),visible:this.length()>0})}).on("show hide ",function(){i.buttonLoad.set({toggle:this.visible,icon:this.visible&&"fa-eye"||"fa-eye-slash"})}),this.history_cache={}},addDataset:function(t){var e=this,i=null;if(Galaxy&&Galaxy.currHistoryPanel){var a=Galaxy.currHistoryPanel.collection.historyId;this.history_cache[a]={name:Galaxy.currHistoryPanel.model.get("name"),dataset_ids:[]},Galaxy.currHistoryPanel.collection.each(function(t){!t.get("deleted")&&t.get("visible")&&e.history_cache[a].dataset_ids.push(t.get("id"))})}var n=function(t,i){if(t){var a=e.history_cache[t.get("history_id")];if(a&&a.dataset_ids){var n=a.dataset_ids,o=n.indexOf(t.get("id"));if(-1!==o&&o+i>=0&&o+i<n.length)return n[o+i]}}},o=function(t,a,o){var s=n(t,a);s?e._loadDataset(s,function(t,e){i=t,o.model.set(e)}):o.model.trigger("change")};this._loadDataset(t,function(t,a){i=t,e.add(_.extend({menu:[{icon:"fa fa-chevron-circle-left",tooltip:"Previous in History",onclick:function(t){o(i,-1,t)},disabled:function(){return!n(i,-1)}},{icon:"fa fa-chevron-circle-right",tooltip:"Next in History",onclick:function(t){o(i,1,t)},disabled:function(){return!n(i,1)}}]},a))})},_loadDataset:function(t,i){var a=this,n=new e.Dataset({id:t});$.when(n.fetch()).then(function(){var o=_.find(["tabular","interval"],function(t){return-1!==n.get("data_type").indexOf(t)}),s=n.get("name"),c=a.history_cache[n.get("history_id")];c&&(s=c.name+": "+s),i(n,o?{title:s,url:null,content:e.createTabularDatasetChunkedView({model:new e.TabularDataset(n.toJSON()),embedded:!0,height:"100%"}).$el}:{title:s,url:Galaxy.root+"datasets/"+t+"/display/?preview=True",content:null})})},addTrackster:function(t){var e=this,n=new i.Visualization({id:t});$.when(n.fetch()).then(function(){var t=new a.TracksterUI(Galaxy.root),i={title:n.get("name"),type:"other",content:function(e){var i={container:e,name:n.get("title"),id:n.id,dbkey:n.get("dbkey"),stand_alone:!1},a=n.get("latest_revision"),o=a.config.view.drawables;_.each(o,function(t){t.dataset={hda_ldda:t.hda_ldda,id:t.dataset_id}}),view=t.create_visualization(i,a.config.viewport,a.config.view.drawables,a.config.bookmarks,!1)}};e.add(i)})},add:function(t){if("_blank"==t.target)window.open(t.url);else if("_top"==t.target||"_parent"==t.target||"_self"==t.target)window.location=t.url;else if(!this.active||t.noscratchbook){var e=$(window.parent.document).find("#galaxy_main");"galaxy_main"==t.target||"center"==t.target?0===e.length?window.location=t.url+(-1==t.url.indexOf("?")?"?":"&")+"use_panels=True":e.attr("src",t.url):window.location=t.url}else this.frames.add(t)}})})});
//# sourceMappingURL=../../maps/layout/scratchbook.js.map