Files
galaxy/static/scripts/layout/page.js
T
2018-05-23 15:37:14 -04:00

1 line
3.8 KiB
JavaScript

define("layout/page",["exports","layout/masthead","layout/panel","mvc/ui/ui-modal","utils/utils"],function(e,i,t,s,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(i),h=n(t),l=n(s),r=n(a),d=Backbone.View.extend({el:"body",className:"full-content",_panelids:["left","right"],initialize:function(e){var i=this,t=this;this.config=_.defaults(e.config||{},{message_box_visible:!1,message_box_content:"",message_box_class:"info",show_inactivity_warning:!1,inactivity_box_content:"",hide_panels:!1,hide_masthead:!1}),Galaxy.modal=this.modal=new l.default.View,Galaxy.router=this.router=e.Router&&new e.Router(t,e),this.masthead=new o.default.View(this.config),this.center=new h.default.CenterPanel,Galaxy.display=this.display=function(e){e.title?(r.default.setWindowTitle(e.title),e.allow_title_display=!1):(r.default.setWindowTitle(),e.allow_title_display=!0),e.active_tab&&t.masthead.highlight(e.active_tab),t.center.display(e)},this.$el.attr("scroll","no"),this.$el.html(this._template()),this.$masthead=this.$("#masthead"),this.$center=this.$("#center"),this.$messagebox=this.$("#messagebox"),this.$inactivebox=this.$("#inactivebox"),this.config.hide_masthead?(this.$masthead.remove(),this.$center.css("top",0)):this.$masthead.replaceWith(this.masthead.$el),this.$center.append(this.center.$el),this.$el.append(this.masthead.frame.$el),this.$el.append(this.modal.$el),this.panels={},this.config.hide_panels||_.each(this._panelids,function(s){var a=s.charAt(0).toUpperCase()+s.slice(1),n=e[a];if(n){var o=new n(t,e),l=t.$("#"+s);t[o.toString()]=o,t.panels[s]=new h.default.SidePanel({id:s,el:l,view:o}),i.config.hide_masthead&&l.css("top",0)}}),this.render(),this.router&&Backbone.history.start({root:Galaxy.root,pushState:!0})},render:function(){return $(".select2-hidden-accessible").remove(),this.config.hide_masthead||(this.masthead.render(),this.renderMessageBox(),this.renderInactivityBox()),this.renderPanels(),this._checkCommunicationServerOnline(),this},renderMessageBox:function(){if(this.config.message_box_visible){var e=this.config.message_box_content||"",i=this.config.message_box_class||"info";this.$el.addClass("has-message-box"),this.$messagebox.attr("class","panel-"+i+"-message").html(e).toggle(!!e).show()}else this.$el.removeClass("has-message-box"),this.$messagebox.hide();return this},renderInactivityBox:function(){if(this.config.show_inactivity_warning){var e=this.config.inactivity_box_content||"",i=$("<a/>").attr("href",Galaxy.root+"user/resend_verification").text("Resend verification");this.$el.addClass("has-inactivity-box"),this.$inactivebox.html(e+" ").append(i).toggle(!!e).show()}else this.$el.removeClass("has-inactivity-box"),this.$inactivebox.hide();return this},renderPanels:function(){var e=this;return _.each(this._panelids,function(i){var t=e.panels[i];t?t.render():(e.$center.css(i,0),e.$("#"+i).hide())}),this},_template:function(){return['<div id="everything">\n <div id="background"/>\n <div id="masthead"/>\n <div id="messagebox"/>\n <div id="inactivebox" class="panel-warning-message" />\n <div id="left" />\n <div id="center" />\n <div id="right" />\n </div>\n <div id="dd-helper" />'].join("")},toString:function(){return"PageLayoutView"},_checkCommunicationServerOnline:function(){var e=window.Galaxy.config.communication_server_host,i=window.Galaxy.config.communication_server_port,t=window.Galaxy.user.attributes.preferences,s=$("#show-chat-online");t&&-1!=["1","true"].indexOf(t.communication_server)?$.ajax({url:e+":"+i}).success(function(e){null!==window.Galaxy.user.id&&"hidden"===s.css("visibility")&&s.css("visibility","visible")}).error(function(e){s.css("visibility","hidden")}):s.css("visibility","hidden")}});e.default={View:d}});