Files
galaxy/static/scripts/galaxy.js
T

3 lines
3.6 KiB
JavaScript

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