mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
1 line
1.7 KiB
JavaScript
1 line
1.7 KiB
JavaScript
define(["galaxy.masthead","mvc/ui/ui-frames"],function(b,c){var a=Backbone.View.extend({el_main:"body",active:false,button_active:null,button_load:null,initialize:function(e){var d=this;this.frames=new c.View({visible:false,});this.button_active=new b.GalaxyMastheadIcon({icon:"fa-th",tooltip:"Enable/Disable Scratchbook",onclick:function(){d._activate()},onunload:function(){if(d.frames.length()>0){return"You opened "+d.frames.length()+" frame(s) which will be lost."}}});Galaxy.masthead.append(this.button_active);this.button_load=new b.GalaxyMastheadIcon({icon:"fa-eye",tooltip:"Show/Hide Scratchbook",onclick:function(f){if(d.frames.visible){d.frames.hide()}else{d.frames.show()}},with_number:true});Galaxy.masthead.append(this.button_load);this.setElement(this.frames.$el);$(this.el_main).append(this.$el);this.frames.setOnChange(function(){d._refresh()});this._refresh()},add:function(e){if(e.target=="_blank"){window.open(e.content);return}if(e.target=="_top"||e.target=="_parent"||e.target=="_self"){window.location=e.content;return}if(!this.active){var f=$(window.parent.document).find("#galaxy_main");if(e.target=="galaxy_main"||e.target=="center"){if(f.length==0){var d=e.content;if(d.indexOf("?")==-1){d+="?"}else{d+="&"}d+="use_panels=True";window.location=d}else{f.attr("src",e.content)}}else{window.location=e.content}return}this.frames.add(e)},_activate:function(){if(this.active){this.active=false;this.button_active.untoggle();this.frames.hide()}else{this.active=true;this.button_active.toggle()}},_refresh:function(){this.button_load.number(this.frames.length());if(this.frames.length()==0){this.button_load.hide()}else{this.button_load.show()}if(this.frames.visible){this.button_load.toggle()}else{this.button_load.untoggle()}}});return{GalaxyFrame:a}}); |