Files
galaxy/static/scripts/galaxy.js
T

3 lines
3.4 KiB
JavaScript

"use strict";define(["libs/underscore","libs/backbone","mvc/base-mvc","mvc/user/user-model","utils/metrics-logger","utils/add-logging","utils/localization"],function(e,o,t,r,a,i,n){function l(e,o){return this._init(e||{},o||{})}i(l,"GalaxyApp");var g="galaxy:debug:namespaces",s=!1;try{s="true"==localStorage.getItem("galaxy:debug")}catch(e){console.log(n("localStorage not available for debug flag retrieval"))}return l.prototype._init=function(t,r){var a=this;return e.extend(a,o.Events),s&&(a.logger=console,console.debug("debugging galaxy:","options:",t,"bootstrapped:",r)),a._processOptions(t),a.root=t.root||"/",a.params=t.params||{},a.session_csrf_token=t.session_csrf_token||null,a._initConfig(t.config||{}),a._patchGalaxy(window.Galaxy),a._initLogger(a.options.loggerOptions||{}),a.debug("GalaxyApp.options: ",a.options),a.debug("GalaxyApp.config: ",a.config),a.debug("GalaxyApp.logger: ",a.logger),a._initLocale(),a.debug("GalaxyApp.localize: ",a.localize),a.config=t.config||{},a.debug("GalaxyApp.config: ",a.config),a._initUser(t.user||{}),a.debug("GalaxyApp.user: ",a.user),a._setUpListeners(),a.trigger("ready",a),a},l.prototype.defaultOptions={patchExisting:!0,root:"/",session_csrf_token:null},l.prototype._processOptions=function(e){var o=this,t=o.defaultOptions;o.options={};for(var r in t)t.hasOwnProperty(r)&&(o.options[r]=e.hasOwnProperty(r)?e[r]:t[r]);return o},l.prototype._initConfig=function(e){var o=this;return o.config=e,o.config.debug=s||o.config.debug,o},l.prototype._patchGalaxy=function(e){var o=this;if(o.options.patchExisting&&e)for(var t in e)e.hasOwnProperty(t)&&(o[t]=e[t])},l.prototype._initLogger=function(e){var o=this;if(o.config.debug){e.consoleLogger=e.consoleLogger||console,e.consoleLevel=e.consoleLevel||a.MetricsLogger.ALL;try{e.consoleNamespaceWhitelist=localStorage.getItem(g).split(",")}catch(e){}}return o.logger=new a.MetricsLogger(e),o.emit={},["log","debug","info","warn","error","metric"].map(function(e){o.emit[e]=function(t){o.logger.emit(e,arguments[0],Array.prototype.slice.call(arguments,1))}}),o.config.debug&&(t.LoggableMixin.logger=o.logger),o},l.prototype._initLocale=function(e){var o=this;return o.debug("_initLocale:",e),o.localize=n,window._l=o.localize,o},l.prototype._initUser=function(e){var o=this;return o.debug("_initUser:",e),o.user=new r.User(e),o.user.logger=o.logger,o},l.prototype._setUpListeners=function(){var e=this;return e.lastAjax={},$(document).bind("ajaxSend",function(o,t,r){var a=r.data;try{a=JSON.parse(a)}catch(e){}e.lastAjax={url:location.href.slice(0,-1)+r.url,data:a}}),e},l.prototype.debugging=function(e){var o=this;try{if(void 0===e)return"true"===localStorage.getItem("galaxy:debug");if(e)return localStorage.setItem("galaxy:debug",!0),!0;localStorage.removeItem("galaxy:debug"),o.debuggingNamespaces(null)}catch(e){console.log(n("localStorage not available for debug flag retrieval"))}return!1},l.prototype.debuggingNamespaces=function(e){var o=this;try{if(void 0===e){var t=localStorage.getItem(g);return"string"==typeof t?t.split(","):[]}null===e?localStorage.removeItem(g):localStorage.setItem(g,e);var r=o.debuggingNamespaces();return o.logger&&(o.logger.options.consoleNamespaceWhitelist=r),r}catch(e){console.log(n("localStorage not available for debug namespace retrieval"))}},l.prototype.toString=function(){return"GalaxyApp("+(this.user?this.user.get("email")||"(anonymous)":"uninitialized")+")"},{GalaxyApp:l}});
//# sourceMappingURL=../maps/galaxy.js.map