mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
1 line
4.1 KiB
JavaScript
1 line
4.1 KiB
JavaScript
define("layout/scratchbook",["exports","backbone","underscore","mvc/ui/ui-frames","mvc/dataset/data","viz/visualization","viz/trackster","utils/localization"],function(t,e,a,i,n,o,l,r){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}function c(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e.default=t,e}Object.defineProperty(t,"__esModule",{value:!0});var d=c(e),u=c(a),f=s(i),h=s(n),v=s(o),_=s(l),b=s(r);t.default=d.View.extend({initialize:function(t){var e=this;t=t||{},this.frames=new f.default.View({visible:!1}),this.setElement(this.frames.$el),this.buttonActive=t.collection.add({id:"enable-scratchbook",icon:"fa-th",tooltip:(0,b.default)("Enable/Disable Scratchbook"),onclick:function(){e.active=!e.active,e.buttonActive.set({toggle:e.active,show_note:e.active,note_cls:e.active&&"fa fa-check"}),e.active||e.frames.hide()},onbeforeunload:function(){if(e.frames.length()>0)return"You opened "+e.frames.length()+" frame(s) which will be lost."}}),this.buttonLoad=t.collection.add({id:"show-scratchbook",icon:"fa-eye",tooltip:(0,b.default)("Show/Hide Scratchbook"),show_note:!0,visible:!1,onclick:function(t){e.frames.visible?e.frames.hide():e.frames.show()}}),this.frames.on("add remove",function(){this.visible&&0===this.length()&&this.hide(),e.buttonLoad.set({note:this.length(),visible:this.length()>0})}).on("show hide ",function(){e.buttonLoad.set({toggle:this.visible,icon:this.visible&&"fa-eye"||"fa-eye-slash"})}),this.history_cache={}},addDataset:function(t){var e=this,a=null;if(Galaxy&&Galaxy.currHistoryPanel){var i=Galaxy.currHistoryPanel.collection.historyId;this.history_cache[i]={name:Galaxy.currHistoryPanel.model.get("name"),dataset_ids:[]},Galaxy.currHistoryPanel.collection.each(function(t){!t.get("deleted")&&t.get("visible")&&e.history_cache[i].dataset_ids.push(t.get("id"))})}var n=function(t,a){if(t){var i=e.history_cache[t.get("history_id")];if(i&&i.dataset_ids){var n=i.dataset_ids,o=n.indexOf(t.get("id"));if(-1!==o&&o+a>=0&&o+a<n.length)return n[o+a]}}},o=function(t,i,o){var l=n(t,i);l?e._loadDataset(l,function(t,e){a=t,o.model.set(e)}):o.model.trigger("change")};this._loadDataset(t,function(t,i){a=t,e.add(u.extend({menu:[{icon:"fa fa-chevron-circle-left",tooltip:(0,b.default)("Previous in History"),onclick:function(t){o(a,-1,t)},disabled:function(){return!n(a,-1)}},{icon:"fa fa-chevron-circle-right",tooltip:(0,b.default)("Next in History"),onclick:function(t){o(a,1,t)},disabled:function(){return!n(a,1)}}]},i))})},_loadDataset:function(t,e){var a=this,i=new h.default.Dataset({id:t});$.when(i.fetch()).then(function(){var n=u.find(["tabular","interval"],function(t){return-1!==i.get("data_type").indexOf(t)}),o=i.get("name"),l=a.history_cache[i.get("history_id")];l&&(o=l.name+": "+o),e(i,n?{title:o,url:null,content:h.default.createTabularDatasetChunkedView({model:new h.default.TabularDataset(i.toJSON()),embedded:!0,height:"100%"}).$el}:{title:o,url:Galaxy.root+"datasets/"+t+"/display/?preview=True",content:null})})},addTrackster:function(t){var e=this,a=new v.default.Visualization({id:t});$.when(a.fetch()).then(function(){var t=new _.default.TracksterUI(Galaxy.root),i={title:a.get("name"),type:"other",content:function(e){var i={container:e,name:a.get("title"),id:a.id,dbkey:a.get("dbkey"),stand_alone:!1},n=a.get("latest_revision"),o=n.config.view.drawables;u.each(o,function(t){t.dataset={hda_ldda:t.hda_ldda,id:t.dataset_id}}),t.create_visualization(i,n.config.viewport,n.config.view.drawables,n.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=this._build_url(t.url,{use_panels:!0}):e.attr("src",t.url):window.location=t.url}else t.url=this._build_url(t.url,{hide_panels:!0,hide_masthead:!0}),this.frames.add(t)},_build_url:function(t,e){if(t)return t+=-1==t.indexOf("?")?"?":"&",t+=$.param(e,!0)}})}); |