From d745423732d363ee91fcd81f65e7f0038d8f659a Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Mon, 23 Oct 2017 14:59:02 -0400 Subject: [PATCH] Convert galaxy.js imports; minor fixup. --- client/galaxy/scripts/galaxy.js | 542 ++++++++++----------- client/galaxy/scripts/onload.js | 2 +- static/maps/galaxy.js.map | 2 +- static/maps/onload.js.map | 2 +- static/scripts/bundled/libs.bundled.js | 2 +- static/scripts/bundled/libs.bundled.js.map | 2 +- static/scripts/galaxy.js | 2 +- 7 files changed, 265 insertions(+), 289 deletions(-) diff --git a/client/galaxy/scripts/galaxy.js b/client/galaxy/scripts/galaxy.js index 6e9032673e6..e0613f2ea32 100644 --- a/client/galaxy/scripts/galaxy.js +++ b/client/galaxy/scripts/galaxy.js @@ -1,25 +1,13 @@ -define( - [ - "libs/underscore", - "libs/backbone", - "mvc/base-mvc", - "mvc/user/user-model", - "utils/metrics-logger", - "utils/add-logging", - "utils/localization" - ], - function( - _, - Backbone, - BASE_MVC, - userModel, - metricsLogger, - addLogging, - localize - ) { - // TODO: move into a singleton pattern and have dependents import Galaxy - // ============================================================================ - /** Base galaxy client-side application. +import _ from "libs/underscore"; +import Backbone from "libs/backbone"; +import BASE_MVC from "mvc/base-mvc"; +import userModel from "mvc/user/user-model"; +import metricsLogger from "utils/metrics-logger"; +import addLogging from "utils/add-logging"; +import localize from "utils/localization"; +// TODO: move into a singleton pattern and have dependents import Galaxy +// ============================================================================ +/** Base galaxy client-side application. * Iniitializes: * logger : the logger/metrics-logger * localize : the string localizer @@ -27,278 +15,266 @@ define( * galaxy.ini available from the configuration API) * user : the current user (as a mvc/user/user-model) */ - function GalaxyApp(options, bootstrapped) { - var self = this; - return self._init(options || {}, bootstrapped || {}); +function GalaxyApp(options, bootstrapped) { + var self = this; + return self._init(options || {}, bootstrapped || {}); +} + +// add logging shortcuts for this object +addLogging(GalaxyApp, "GalaxyApp"); + +// a debug flag can be set via local storage and made available during script/page loading +var DEBUGGING_KEY = "galaxy:debug", + NAMESPACE_KEY = DEBUGGING_KEY + ":namespaces", + localDebugging = false; +try { + localDebugging = localStorage.getItem(DEBUGGING_KEY) == "true"; +} catch (storageErr) { + console.log( + localize("localStorage not available for debug flag retrieval") + ); +} + +/** initalize options and sub-components */ +GalaxyApp.prototype._init = function __init(options, bootstrapped) { + var self = this; + _.extend(self, Backbone.Events); + if (localDebugging) { + self.logger = console; + console.debug( + "debugging galaxy:", + "options:", + options, + "bootstrapped:", + bootstrapped + ); + } + + self._processOptions(options); + + // add root and url parameters + self.root = options.root || "/"; + self.params = options.params || {}; + self.session_csrf_token = options.session_csrf_token || null; + + self._initConfig(options.config || {}); + self._patchGalaxy(window.Galaxy); + + self._initLogger(self.options.loggerOptions || {}); + // at this point, either logging or not and namespaces are enabled - chat it up + self.debug("GalaxyApp.options: ", self.options); + self.debug("GalaxyApp.config: ", self.config); + self.debug("GalaxyApp.logger: ", self.logger); + + self._initLocale(); + self.debug("GalaxyApp.localize: ", self.localize); + + self.config = options.config || {}; + self.debug("GalaxyApp.config: ", self.config); + + self._initUser(options.user || {}); + self.debug("GalaxyApp.user: ", self.user); + + self._setUpListeners(); + self.trigger("ready", self); + + return self; +}; + +/** default options */ +GalaxyApp.prototype.defaultOptions = { + /** monkey patch attributes from existing window.Galaxy object? */ + patchExisting: true, + /** root url of this app */ + root: "/", + session_csrf_token: null +}; + +/** filter to options present in defaultOptions (and default to them) */ +GalaxyApp.prototype._processOptions = function _processOptions(options) { + var self = this, + defaults = self.defaultOptions; + + self.options = {}; + for (var k in defaults) { + if (defaults.hasOwnProperty(k)) { + self.options[k] = options.hasOwnProperty(k) + ? options[k] + : defaults[k]; } + } + return self; +}; - // add logging shortcuts for this object - addLogging(GalaxyApp, "GalaxyApp"); +/** parse the config and any extra info derived from it */ +GalaxyApp.prototype._initConfig = function _initConfig(config) { + var self = this; + self.config = config; - // a debug flag can be set via local storage and made available during script/page loading - var DEBUGGING_KEY = "galaxy:debug", - NAMESPACE_KEY = DEBUGGING_KEY + ":namespaces", - localDebugging = false; + // give precendence to localdebugging for this setting + self.config.debug = localDebugging || self.config.debug; + + return self; +}; + +/** add an option from options if the key matches an option in defaultOptions */ +GalaxyApp.prototype._patchGalaxy = function _patchGalaxy(patchWith) { + var self = this; + // in case req or plain script tag order has created a prev. version of the Galaxy obj... + if (self.options.patchExisting && patchWith) { + // self.debug( 'found existing Galaxy object:', patchWith ); + // ...(for now) monkey patch any added attributes that the previous Galaxy may have had + //TODO: move those attributes to more formal assignment in GalaxyApp + for (var k in patchWith) { + if (patchWith.hasOwnProperty(k)) { + // self.debug( '\t patching in ' + k + ' to Galaxy:', self[ k ] ); + self[k] = patchWith[k]; + } + } + } +}; + +/** set up the metrics logger (utils/metrics-logger) and pass loggerOptions */ +GalaxyApp.prototype._initLogger = function _initLogger(loggerOptions) { + var self = this; + + // default to console logging at the debug level if the debug flag is set + if (self.config.debug) { + loggerOptions.consoleLogger = loggerOptions.consoleLogger || console; + loggerOptions.consoleLevel = + loggerOptions.consoleLevel || metricsLogger.MetricsLogger.ALL; + // load any logging namespaces from localStorage if we can try { - localDebugging = localStorage.getItem(DEBUGGING_KEY) == "true"; - } catch (storageErr) { - console.log( - localize("localStorage not available for debug flag retrieval") + loggerOptions.consoleNamespaceWhitelist = localStorage + .getItem(NAMESPACE_KEY) + .split(","); + } catch (storageErr) {} + } + + self.logger = new metricsLogger.MetricsLogger(loggerOptions); + self.emit = {}; + ["log", "debug", "info", "warn", "error", "metric"].map(function(i) { + self.emit[i] = function(data) { + self.logger.emit( + i, + arguments[0], + Array.prototype.slice.call(arguments, 1) ); + }; + }); + + if (self.config.debug) { + // add this logger to mvc's loggable mixin so that all models can use the logger + BASE_MVC.LoggableMixin.logger = self.logger; + } + return self; +}; + +/** add the localize fn to this object and the window namespace (as '_l') */ +GalaxyApp.prototype._initLocale = function _initLocale(options) { + var self = this; + self.debug("_initLocale:", options); + self.localize = localize; + // add to window as global shortened alias + // TODO: temporary - remove when can require for plugins + window._l = self.localize; + return self; +}; + +/** set up the current user as a Backbone model (mvc/user/user-model) */ +GalaxyApp.prototype._initUser = function _initUser(userJSON) { + var self = this; + self.debug("_initUser:", userJSON); + self.user = new userModel.User(userJSON); + self.user.logger = self.logger; + return self; +}; + +/** Set up DOM/jQuery/Backbone event listeners enabled for all pages */ +GalaxyApp.prototype._setUpListeners = function _setUpListeners() { + var self = this; + + // hook to jq beforeSend to record the most recent ajax call and cache some data about it + /** cached info about the last ajax call made through jQuery */ + self.lastAjax = {}; + $(document).bind("ajaxSend", function(ev, xhr, options) { + var data = options.data; + try { + data = JSON.parse(data); + } catch (err) {} + + self.lastAjax = { + url: location.href.slice(0, -1) + options.url, + data: data + }; + //TODO:?? we might somehow manage to *retry* ajax using either this hook or Backbone.sync + }); + return self; +}; + +/** Turn debugging/console-output on/off by passing boolean. Pass nothing to get current setting. */ +GalaxyApp.prototype.debugging = function _debugging(setting) { + var self = this; + try { + if (setting === undefined) { + return localStorage.getItem(DEBUGGING_KEY) === "true"; + } + if (setting) { + localStorage.setItem(DEBUGGING_KEY, true); + return true; } - /** initalize options and sub-components */ - GalaxyApp.prototype._init = function __init(options, bootstrapped) { - var self = this; - _.extend(self, Backbone.Events); - if (localDebugging) { - self.logger = console; - console.debug( - "debugging galaxy:", - "options:", - options, - "bootstrapped:", - bootstrapped - ); - } + localStorage.removeItem(DEBUGGING_KEY); + // also remove all namespaces + self.debuggingNamespaces(null); + } catch (storageErr) { + console.log( + localize("localStorage not available for debug flag retrieval") + ); + } + return false; +}; - self._processOptions(options); - - // add root and url parameters - self.root = options.root || "/"; - self.params = options.params || {}; - self.session_csrf_token = options.session_csrf_token || null; - - self._initConfig(options.config || {}); - self._patchGalaxy(window.Galaxy); - - self._initLogger(self.options.loggerOptions || {}); - // at this point, either logging or not and namespaces are enabled - chat it up - self.debug("GalaxyApp.options: ", self.options); - self.debug("GalaxyApp.config: ", self.config); - self.debug("GalaxyApp.logger: ", self.logger); - - self._initLocale(); - self.debug("GalaxyApp.localize: ", self.localize); - - self.config = options.config || {}; - self.debug("GalaxyApp.config: ", self.config); - - self._initUser(options.user || {}); - self.debug("GalaxyApp.user: ", self.user); - - self._setUpListeners(); - self.trigger("ready", self); - - return self; - }; - - /** default options */ - GalaxyApp.prototype.defaultOptions = { - /** monkey patch attributes from existing window.Galaxy object? */ - patchExisting: true, - /** root url of this app */ - root: "/", - session_csrf_token: null - }; - - /** filter to options present in defaultOptions (and default to them) */ - GalaxyApp.prototype._processOptions = function _processOptions( - options - ) { - var self = this, - defaults = self.defaultOptions; - - self.options = {}; - for (var k in defaults) { - if (defaults.hasOwnProperty(k)) { - self.options[k] = options.hasOwnProperty(k) - ? options[k] - : defaults[k]; - } - } - return self; - }; - - /** parse the config and any extra info derived from it */ - GalaxyApp.prototype._initConfig = function _initConfig(config) { - var self = this; - self.config = config; - - // give precendence to localdebugging for this setting - self.config.debug = localDebugging || self.config.debug; - - return self; - }; - - /** add an option from options if the key matches an option in defaultOptions */ - GalaxyApp.prototype._patchGalaxy = function _patchGalaxy(patchWith) { - var self = this; - // in case req or plain script tag order has created a prev. version of the Galaxy obj... - if (self.options.patchExisting && patchWith) { - // self.debug( 'found existing Galaxy object:', patchWith ); - // ...(for now) monkey patch any added attributes that the previous Galaxy may have had - //TODO: move those attributes to more formal assignment in GalaxyApp - for (var k in patchWith) { - if (patchWith.hasOwnProperty(k)) { - // self.debug( '\t patching in ' + k + ' to Galaxy:', self[ k ] ); - self[k] = patchWith[k]; - } - } - } - }; - - /** set up the metrics logger (utils/metrics-logger) and pass loggerOptions */ - GalaxyApp.prototype._initLogger = function _initLogger(loggerOptions) { - var self = this; - - // default to console logging at the debug level if the debug flag is set - if (self.config.debug) { - loggerOptions.consoleLogger = - loggerOptions.consoleLogger || console; - loggerOptions.consoleLevel = - loggerOptions.consoleLevel || - metricsLogger.MetricsLogger.ALL; - // load any logging namespaces from localStorage if we can - try { - loggerOptions.consoleNamespaceWhitelist = localStorage - .getItem(NAMESPACE_KEY) - .split(","); - } catch (storageErr) {} - } - - self.logger = new metricsLogger.MetricsLogger(loggerOptions); - self.emit = {}; - ["log", "debug", "info", "warn", "error", "metric"].map(function( - i - ) { - self.emit[i] = function(data) { - self.logger.emit( - i, - arguments[0], - Array.prototype.slice.call(arguments, 1) - ); - }; - }); - - if (self.config.debug) { - // add this logger to mvc's loggable mixin so that all models can use the logger - BASE_MVC.LoggableMixin.logger = self.logger; - } - return self; - }; - - /** add the localize fn to this object and the window namespace (as '_l') */ - GalaxyApp.prototype._initLocale = function _initLocale(options) { - var self = this; - self.debug("_initLocale:", options); - self.localize = localize; - // add to window as global shortened alias - // TODO: temporary - remove when can require for plugins - window._l = self.localize; - return self; - }; - - /** set up the current user as a Backbone model (mvc/user/user-model) */ - GalaxyApp.prototype._initUser = function _initUser(userJSON) { - var self = this; - self.debug("_initUser:", userJSON); - self.user = new userModel.User(userJSON); - self.user.logger = self.logger; - return self; - }; - - /** Set up DOM/jQuery/Backbone event listeners enabled for all pages */ - GalaxyApp.prototype._setUpListeners = function _setUpListeners() { - var self = this; - - // hook to jq beforeSend to record the most recent ajax call and cache some data about it - /** cached info about the last ajax call made through jQuery */ - self.lastAjax = {}; - $(document).bind("ajaxSend", function(ev, xhr, options) { - var data = options.data; - try { - data = JSON.parse(data); - } catch (err) {} - - self.lastAjax = { - url: location.href.slice(0, -1) + options.url, - data: data - }; - //TODO:?? we might somehow manage to *retry* ajax using either this hook or Backbone.sync - }); - return self; - }; - - /** Turn debugging/console-output on/off by passing boolean. Pass nothing to get current setting. */ - GalaxyApp.prototype.debugging = function _debugging(setting) { - var self = this; - try { - if (setting === undefined) { - return localStorage.getItem(DEBUGGING_KEY) === "true"; - } - if (setting) { - localStorage.setItem(DEBUGGING_KEY, true); - return true; - } - - localStorage.removeItem(DEBUGGING_KEY); - // also remove all namespaces - self.debuggingNamespaces(null); - } catch (storageErr) { - console.log( - localize( - "localStorage not available for debug flag retrieval" - ) - ); - } - return false; - }; - - /** Add, remove, or clear namespaces from the debugging filters +/** Add, remove, or clear namespaces from the debugging filters * Pass no arguments to retrieve the existing namespaces as an array. * Pass in null to clear all namespaces (all logging messages will show now). * Pass in an array of strings or single string of the namespaces to filter to. * Returns the new/current namespaces as an array; */ - GalaxyApp.prototype.debuggingNamespaces = function _debuggingNamespaces( - namespaces - ) { - var self = this; - try { - if (namespaces === undefined) { - var csv = localStorage.getItem(NAMESPACE_KEY); - return typeof csv === "string" ? csv.split(",") : []; - } else if (namespaces === null) { - localStorage.removeItem(NAMESPACE_KEY); - } else { - localStorage.setItem(NAMESPACE_KEY, namespaces); - } - var newSettings = self.debuggingNamespaces(); - if (self.logger) { - self.logger.options.consoleNamespaceWhitelist = newSettings; - } - return newSettings; - } catch (storageErr) { - console.log( - localize( - "localStorage not available for debug namespace retrieval" - ) - ); - } - }; - - /** string rep */ - GalaxyApp.prototype.toString = function toString() { - var userEmail = this.user - ? this.user.get("email") || "(anonymous)" - : "uninitialized"; - return "GalaxyApp(" + userEmail + ")"; - }; - - // ============================================================================ - return { - GalaxyApp: GalaxyApp - }; +GalaxyApp.prototype.debuggingNamespaces = function _debuggingNamespaces( + namespaces +) { + var self = this; + try { + if (namespaces === undefined) { + var csv = localStorage.getItem(NAMESPACE_KEY); + return typeof csv === "string" ? csv.split(",") : []; + } else if (namespaces === null) { + localStorage.removeItem(NAMESPACE_KEY); + } else { + localStorage.setItem(NAMESPACE_KEY, namespaces); + } + var newSettings = self.debuggingNamespaces(); + if (self.logger) { + self.logger.options.consoleNamespaceWhitelist = newSettings; + } + return newSettings; + } catch (storageErr) { + console.log( + localize("localStorage not available for debug namespace retrieval") + ); } -); +}; + +/** string rep */ +GalaxyApp.prototype.toString = function toString() { + var userEmail = this.user + ? this.user.get("email") || "(anonymous)" + : "uninitialized"; + return "GalaxyApp(" + userEmail + ")"; +}; + +// ============================================================================ +export default { + GalaxyApp: GalaxyApp +}; diff --git a/client/galaxy/scripts/onload.js b/client/galaxy/scripts/onload.js index 989a3755196..81abd35aee0 100644 --- a/client/galaxy/scripts/onload.js +++ b/client/galaxy/scripts/onload.js @@ -22,7 +22,7 @@ window.async_save_text = async_save_text; import POPUPMENU from "ui/popupmenu"; window.make_popupmenu = POPUPMENU.make_popupmenu; window.make_popup_menus = POPUPMENU.make_popup_menus; -import init_tag_click_function from 'ui/autocom_tagging'; +import init_tag_click_function from "ui/autocom_tagging"; window.init_tag_click_function = init_tag_click_function; import TOURS from "mvc/tours"; import QUERY_STRING from "utils/query-string-parsing"; diff --git a/static/maps/galaxy.js.map b/static/maps/galaxy.js.map index ffb32ad0bfd..d3a2678d1c8 100644 --- a/static/maps/galaxy.js.map +++ b/static/maps/galaxy.js.map @@ -1 +1 @@ -{"version":3,"sources":["galaxy.js"],"names":["define","_","Backbone","BASE_MVC","userModel","metricsLogger","addLogging","localize","console","bootstrapped","this","_init","options","extend","NAMESPACE_KEY","DEBUGGING_KEY","localDebugging","self","localStorage","getItem","debug","storageErr","root","GalaxyApp","prototype","_initLogger","Events","_initLocale","config","trigger","params","session_csrf_token","_initConfig","_patchGalaxy","window","Galaxy","loggerOptions","logger","defaults","defaultOptions","user","_processOptions","k","hasOwnProperty","patchWith","patchExisting","MetricsLogger","consoleLogger","consoleLevel","_l","ALL","consoleNamespaceWhitelist","_initUser","split","data","emit","map","i","arguments","lastAjax","slice","call","userJSON","User","removeItem","_setUpListeners","$","document","bind","ev","xhr","JSON","parse","namespaces","undefined","url","csv","setting","newSettings","setItem","userEmail","debuggingNamespaces","log","toString","get"],"mappings":"kCAAAA,QAEQ,kBAFRA,gBAmBQ,eACA,sBACA,uBAdA,oBACA,sBAEJ,SACIC,EACAC,EACAC,EAgBAC,EACIC,EACAC,EACHC,GAYGC,SAAAA,EACID,EAASE,GAdb,OAgBHC,KAhBeC,MAAMC,MAAeH,OAqBjCR,EAAEY,EAAaX,aAGXM,IAOHM,EAAAC,0BAtBDC,GAAiB,EAwBjBC,IAtBAD,EAAwD,QAAvCE,aAAaC,QAalBC,gBAWZ,MAAAC,GACAJ,QAAKK,IACLL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AAEC,UAAUC,KAAK,WAAY,SAASC,EAAIC,EAAK1D,GAC3C,IAAI0C,EAAO1C,EAAQ0C,KACnB,IACIA,EAAOiB,KAAKC,MAAMlB,GA2CpB9B,MAAAA,IAIFP,EAAA0C,UACIc,IAAAA,SAAAA,KAAeC,MAAnB,GAA8B,GAAA9D,EAAA+D,IAC1BrB,KAAIsB,KAED3D,GAMPM,EAAAC,UAASa,UAAQ,SAAAwC,GACb5D,IAAAA,EAAAA,KACH,IACD,QAAO6D,IAAPD,EACF,MAAmB,SAAZxD,aAAYF,QAlOTC,gBAwOX,GAAAyD,EA9CO,OAsBZ3D,aAAA6D,QAhNgB3D,gBAgNhB,IAtBmB,EAmDX4D,aAAYhB,WA7OJ5C,gBA4OhBH,EAAAgE,oBAAA,MA5CM,MAAO5D,GAmDbb,QAAA0E,IACO3E,EACQgB,wDA9CX,OAAO,GASXA,EAAUC,UAAUyD,oBAAsB,SACtCR,GAEA,IAAIxD,EAAOP,KACX,IACI,QAAmBgE,IAAfD,EAA0B,CAC1B,IAAIG,EAAM1D,aAAaC,QAAQL,GAC/B,MAAsB,iBAAR8D,EAAmBA,EAAIvB,MAAM,QACrB,OAAfoB,EACPvD,aAAa8C,WAAWlD,GAExBI,aAAa6D,QAAQjE,EAAe2D,GAExC,IAAIK,EAAc7D,EAAKgE,sBAIvB,OAHIhE,EAAKoB,SACLpB,EAAKoB,OAAOzB,QAAQuC,0BAA4B2B,GAE7CA,EACT,MAAOzD,GACLb,QAAQ0E,IACJ3E,EACI,+DAOhBgB,EAAUC,UAAU2D,SAAW,WAI3B,MAAO,cAHSzE,KAAK8B,KACf9B,KAAK8B,KAAK4C,IAAI,UAAY,cAC1B,iBAC4B,MAKlC7D,UAAWA","file":"../scripts/galaxy.js","sourcesContent":["define(\n [\n \"libs/underscore\",\n \"libs/backbone\",\n \"mvc/base-mvc\",\n \"mvc/user/user-model\",\n \"utils/metrics-logger\",\n \"utils/add-logging\",\n \"utils/localization\"\n ],\n function(\n _,\n Backbone,\n BASE_MVC,\n userModel,\n metricsLogger,\n addLogging,\n localize\n ) {\n // TODO: move into a singleton pattern and have dependents import Galaxy\n // ============================================================================\n /** Base galaxy client-side application.\n * Iniitializes:\n * logger : the logger/metrics-logger\n * localize : the string localizer\n * config : the current configuration (any k/v in\n * galaxy.ini available from the configuration API)\n * user : the current user (as a mvc/user/user-model)\n */\n function GalaxyApp(options, bootstrapped) {\n var self = this;\n return self._init(options || {}, bootstrapped || {});\n }\n\n // add logging shortcuts for this object\n addLogging(GalaxyApp, \"GalaxyApp\");\n\n // a debug flag can be set via local storage and made available during script/page loading\n var DEBUGGING_KEY = \"galaxy:debug\",\n NAMESPACE_KEY = DEBUGGING_KEY + \":namespaces\",\n localDebugging = false;\n try {\n localDebugging = localStorage.getItem(DEBUGGING_KEY) == \"true\";\n } catch (storageErr) {\n console.log(\n localize(\"localStorage not available for debug flag retrieval\")\n );\n }\n\n /** initalize options and sub-components */\n GalaxyApp.prototype._init = function __init(options, bootstrapped) {\n var self = this;\n _.extend(self, Backbone.Events);\n if (localDebugging) {\n self.logger = console;\n console.debug(\n \"debugging galaxy:\",\n \"options:\",\n options,\n \"bootstrapped:\",\n bootstrapped\n );\n }\n\n self._processOptions(options);\n\n // add root and url parameters\n self.root = options.root || \"/\";\n self.params = options.params || {};\n self.session_csrf_token = options.session_csrf_token || null;\n\n self._initConfig(options.config || {});\n self._patchGalaxy(window.Galaxy);\n\n self._initLogger(self.options.loggerOptions || {});\n // at this point, either logging or not and namespaces are enabled - chat it up\n self.debug(\"GalaxyApp.options: \", self.options);\n self.debug(\"GalaxyApp.config: \", self.config);\n self.debug(\"GalaxyApp.logger: \", self.logger);\n\n self._initLocale();\n self.debug(\"GalaxyApp.localize: \", self.localize);\n\n self.config = options.config || {};\n self.debug(\"GalaxyApp.config: \", self.config);\n\n self._initUser(options.user || {});\n self.debug(\"GalaxyApp.user: \", self.user);\n\n self._setUpListeners();\n self.trigger(\"ready\", self);\n\n return self;\n };\n\n /** default options */\n GalaxyApp.prototype.defaultOptions = {\n /** monkey patch attributes from existing window.Galaxy object? */\n patchExisting: true,\n /** root url of this app */\n root: \"/\",\n session_csrf_token: null\n };\n\n /** filter to options present in defaultOptions (and default to them) */\n GalaxyApp.prototype._processOptions = function _processOptions(\n options\n ) {\n var self = this,\n defaults = self.defaultOptions;\n\n self.options = {};\n for (var k in defaults) {\n if (defaults.hasOwnProperty(k)) {\n self.options[k] = options.hasOwnProperty(k)\n ? options[k]\n : defaults[k];\n }\n }\n return self;\n };\n\n /** parse the config and any extra info derived from it */\n GalaxyApp.prototype._initConfig = function _initConfig(config) {\n var self = this;\n self.config = config;\n\n // give precendence to localdebugging for this setting\n self.config.debug = localDebugging || self.config.debug;\n\n return self;\n };\n\n /** add an option from options if the key matches an option in defaultOptions */\n GalaxyApp.prototype._patchGalaxy = function _patchGalaxy(patchWith) {\n var self = this;\n // in case req or plain script tag order has created a prev. version of the Galaxy obj...\n if (self.options.patchExisting && patchWith) {\n // self.debug( 'found existing Galaxy object:', patchWith );\n // ...(for now) monkey patch any added attributes that the previous Galaxy may have had\n //TODO: move those attributes to more formal assignment in GalaxyApp\n for (var k in patchWith) {\n if (patchWith.hasOwnProperty(k)) {\n // self.debug( '\\t patching in ' + k + ' to Galaxy:', self[ k ] );\n self[k] = patchWith[k];\n }\n }\n }\n };\n\n /** set up the metrics logger (utils/metrics-logger) and pass loggerOptions */\n GalaxyApp.prototype._initLogger = function _initLogger(loggerOptions) {\n var self = this;\n\n // default to console logging at the debug level if the debug flag is set\n if (self.config.debug) {\n loggerOptions.consoleLogger =\n loggerOptions.consoleLogger || console;\n loggerOptions.consoleLevel =\n loggerOptions.consoleLevel ||\n metricsLogger.MetricsLogger.ALL;\n // load any logging namespaces from localStorage if we can\n try {\n loggerOptions.consoleNamespaceWhitelist = localStorage\n .getItem(NAMESPACE_KEY)\n .split(\",\");\n } catch (storageErr) {}\n }\n\n self.logger = new metricsLogger.MetricsLogger(loggerOptions);\n self.emit = {};\n [\"log\", \"debug\", \"info\", \"warn\", \"error\", \"metric\"].map(function(\n i\n ) {\n self.emit[i] = function(data) {\n self.logger.emit(\n i,\n arguments[0],\n Array.prototype.slice.call(arguments, 1)\n );\n };\n });\n\n if (self.config.debug) {\n // add this logger to mvc's loggable mixin so that all models can use the logger\n BASE_MVC.LoggableMixin.logger = self.logger;\n }\n return self;\n };\n\n /** add the localize fn to this object and the window namespace (as '_l') */\n GalaxyApp.prototype._initLocale = function _initLocale(options) {\n var self = this;\n self.debug(\"_initLocale:\", options);\n self.localize = localize;\n // add to window as global shortened alias\n // TODO: temporary - remove when can require for plugins\n window._l = self.localize;\n return self;\n };\n\n /** set up the current user as a Backbone model (mvc/user/user-model) */\n GalaxyApp.prototype._initUser = function _initUser(userJSON) {\n var self = this;\n self.debug(\"_initUser:\", userJSON);\n self.user = new userModel.User(userJSON);\n self.user.logger = self.logger;\n return self;\n };\n\n /** Set up DOM/jQuery/Backbone event listeners enabled for all pages */\n GalaxyApp.prototype._setUpListeners = function _setUpListeners() {\n var self = this;\n\n // hook to jq beforeSend to record the most recent ajax call and cache some data about it\n /** cached info about the last ajax call made through jQuery */\n self.lastAjax = {};\n $(document).bind(\"ajaxSend\", function(ev, xhr, options) {\n var data = options.data;\n try {\n data = JSON.parse(data);\n } catch (err) {}\n\n self.lastAjax = {\n url: location.href.slice(0, -1) + options.url,\n data: data\n };\n //TODO:?? we might somehow manage to *retry* ajax using either this hook or Backbone.sync\n });\n return self;\n };\n\n /** Turn debugging/console-output on/off by passing boolean. Pass nothing to get current setting. */\n GalaxyApp.prototype.debugging = function _debugging(setting) {\n var self = this;\n try {\n if (setting === undefined) {\n return localStorage.getItem(DEBUGGING_KEY) === \"true\";\n }\n if (setting) {\n localStorage.setItem(DEBUGGING_KEY, true);\n return true;\n }\n\n localStorage.removeItem(DEBUGGING_KEY);\n // also remove all namespaces\n self.debuggingNamespaces(null);\n } catch (storageErr) {\n console.log(\n localize(\n \"localStorage not available for debug flag retrieval\"\n )\n );\n }\n return false;\n };\n\n /** Add, remove, or clear namespaces from the debugging filters\n * Pass no arguments to retrieve the existing namespaces as an array.\n * Pass in null to clear all namespaces (all logging messages will show now).\n * Pass in an array of strings or single string of the namespaces to filter to.\n * Returns the new/current namespaces as an array;\n */\n GalaxyApp.prototype.debuggingNamespaces = function _debuggingNamespaces(\n namespaces\n ) {\n var self = this;\n try {\n if (namespaces === undefined) {\n var csv = localStorage.getItem(NAMESPACE_KEY);\n return typeof csv === \"string\" ? csv.split(\",\") : [];\n } else if (namespaces === null) {\n localStorage.removeItem(NAMESPACE_KEY);\n } else {\n localStorage.setItem(NAMESPACE_KEY, namespaces);\n }\n var newSettings = self.debuggingNamespaces();\n if (self.logger) {\n self.logger.options.consoleNamespaceWhitelist = newSettings;\n }\n return newSettings;\n } catch (storageErr) {\n console.log(\n localize(\n \"localStorage not available for debug namespace retrieval\"\n )\n );\n }\n };\n\n /** string rep */\n GalaxyApp.prototype.toString = function toString() {\n var userEmail = this.user\n ? this.user.get(\"email\") || \"(anonymous)\"\n : \"uninitialized\";\n return \"GalaxyApp(\" + userEmail + \")\";\n };\n\n // ============================================================================\n return {\n GalaxyApp: GalaxyApp\n };\n }\n);\n"]} \ No newline at end of file +{"version":3,"sources":["galaxy.js"],"names":["GalaxyApp","options","bootstrapped","this","_init","_addLogging2","default","NAMESPACE_KEY","DEBUGGING_KEY","localDebugging","localStorage","getItem","storageErr","console","log","_localization2","prototype","self","_underscore2","extend","_backbone2","Events","logger","debug","root","session_csrf_token","_initConfig","config","_initLogger","loggerOptions","_processOptions","_patchGalaxy","Galaxy","user","defaultOptions","_initUser","_setUpListeners","defaults","patchExisting","hasOwnProperty","k","patchWith","consoleLogger","consoleLevel","_metricsLogger2","MetricsLogger","ALL","split","emit","map","i","consoleNamespaceWhitelist","arguments","slice","call","_baseMvc2","LoggableMixin","_initLocale","localize","userJSON","lastAjax","$","document","bind","ev","xhr","data","JSON","parse","url","location","href","debugging","setting","removeItem","debuggingNamespaces","namespaces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,UAAAgE,SAAA,WASIhF,MAAAA,cARgBG,KAAK8B,KAMzB9B,KAAA8B,KAAAgD,IAAA,UAAA,cAJU,iBAMKjF,gBAAXA,UAAWA","file":"../scripts/galaxy.js","sourcesContent":["import _ from \"libs/underscore\";\nimport Backbone from \"libs/backbone\";\nimport BASE_MVC from \"mvc/base-mvc\";\nimport userModel from \"mvc/user/user-model\";\nimport metricsLogger from \"utils/metrics-logger\";\nimport addLogging from \"utils/add-logging\";\nimport localize from \"utils/localization\";\n// TODO: move into a singleton pattern and have dependents import Galaxy\n// ============================================================================\n/** Base galaxy client-side application.\n * Iniitializes:\n * logger : the logger/metrics-logger\n * localize : the string localizer\n * config : the current configuration (any k/v in\n * galaxy.ini available from the configuration API)\n * user : the current user (as a mvc/user/user-model)\n */\nfunction GalaxyApp(options, bootstrapped) {\n var self = this;\n return self._init(options || {}, bootstrapped || {});\n}\n\n// add logging shortcuts for this object\naddLogging(GalaxyApp, \"GalaxyApp\");\n\n// a debug flag can be set via local storage and made available during script/page loading\nvar DEBUGGING_KEY = \"galaxy:debug\",\n NAMESPACE_KEY = DEBUGGING_KEY + \":namespaces\",\n localDebugging = false;\ntry {\n localDebugging = localStorage.getItem(DEBUGGING_KEY) == \"true\";\n} catch (storageErr) {\n console.log(\n localize(\"localStorage not available for debug flag retrieval\")\n );\n}\n\n/** initalize options and sub-components */\nGalaxyApp.prototype._init = function __init(options, bootstrapped) {\n var self = this;\n _.extend(self, Backbone.Events);\n if (localDebugging) {\n self.logger = console;\n console.debug(\n \"debugging galaxy:\",\n \"options:\",\n options,\n \"bootstrapped:\",\n bootstrapped\n );\n }\n\n self._processOptions(options);\n\n // add root and url parameters\n self.root = options.root || \"/\";\n self.params = options.params || {};\n self.session_csrf_token = options.session_csrf_token || null;\n\n self._initConfig(options.config || {});\n self._patchGalaxy(window.Galaxy);\n\n self._initLogger(self.options.loggerOptions || {});\n // at this point, either logging or not and namespaces are enabled - chat it up\n self.debug(\"GalaxyApp.options: \", self.options);\n self.debug(\"GalaxyApp.config: \", self.config);\n self.debug(\"GalaxyApp.logger: \", self.logger);\n\n self._initLocale();\n self.debug(\"GalaxyApp.localize: \", self.localize);\n\n self.config = options.config || {};\n self.debug(\"GalaxyApp.config: \", self.config);\n\n self._initUser(options.user || {});\n self.debug(\"GalaxyApp.user: \", self.user);\n\n self._setUpListeners();\n self.trigger(\"ready\", self);\n\n return self;\n};\n\n/** default options */\nGalaxyApp.prototype.defaultOptions = {\n /** monkey patch attributes from existing window.Galaxy object? */\n patchExisting: true,\n /** root url of this app */\n root: \"/\",\n session_csrf_token: null\n};\n\n/** filter to options present in defaultOptions (and default to them) */\nGalaxyApp.prototype._processOptions = function _processOptions(options) {\n var self = this,\n defaults = self.defaultOptions;\n\n self.options = {};\n for (var k in defaults) {\n if (defaults.hasOwnProperty(k)) {\n self.options[k] = options.hasOwnProperty(k)\n ? options[k]\n : defaults[k];\n }\n }\n return self;\n};\n\n/** parse the config and any extra info derived from it */\nGalaxyApp.prototype._initConfig = function _initConfig(config) {\n var self = this;\n self.config = config;\n\n // give precendence to localdebugging for this setting\n self.config.debug = localDebugging || self.config.debug;\n\n return self;\n};\n\n/** add an option from options if the key matches an option in defaultOptions */\nGalaxyApp.prototype._patchGalaxy = function _patchGalaxy(patchWith) {\n var self = this;\n // in case req or plain script tag order has created a prev. version of the Galaxy obj...\n if (self.options.patchExisting && patchWith) {\n // self.debug( 'found existing Galaxy object:', patchWith );\n // ...(for now) monkey patch any added attributes that the previous Galaxy may have had\n //TODO: move those attributes to more formal assignment in GalaxyApp\n for (var k in patchWith) {\n if (patchWith.hasOwnProperty(k)) {\n // self.debug( '\\t patching in ' + k + ' to Galaxy:', self[ k ] );\n self[k] = patchWith[k];\n }\n }\n }\n};\n\n/** set up the metrics logger (utils/metrics-logger) and pass loggerOptions */\nGalaxyApp.prototype._initLogger = function _initLogger(loggerOptions) {\n var self = this;\n\n // default to console logging at the debug level if the debug flag is set\n if (self.config.debug) {\n loggerOptions.consoleLogger = loggerOptions.consoleLogger || console;\n loggerOptions.consoleLevel =\n loggerOptions.consoleLevel || metricsLogger.MetricsLogger.ALL;\n // load any logging namespaces from localStorage if we can\n try {\n loggerOptions.consoleNamespaceWhitelist = localStorage\n .getItem(NAMESPACE_KEY)\n .split(\",\");\n } catch (storageErr) {}\n }\n\n self.logger = new metricsLogger.MetricsLogger(loggerOptions);\n self.emit = {};\n [\"log\", \"debug\", \"info\", \"warn\", \"error\", \"metric\"].map(function(i) {\n self.emit[i] = function(data) {\n self.logger.emit(\n i,\n arguments[0],\n Array.prototype.slice.call(arguments, 1)\n );\n };\n });\n\n if (self.config.debug) {\n // add this logger to mvc's loggable mixin so that all models can use the logger\n BASE_MVC.LoggableMixin.logger = self.logger;\n }\n return self;\n};\n\n/** add the localize fn to this object and the window namespace (as '_l') */\nGalaxyApp.prototype._initLocale = function _initLocale(options) {\n var self = this;\n self.debug(\"_initLocale:\", options);\n self.localize = localize;\n // add to window as global shortened alias\n // TODO: temporary - remove when can require for plugins\n window._l = self.localize;\n return self;\n};\n\n/** set up the current user as a Backbone model (mvc/user/user-model) */\nGalaxyApp.prototype._initUser = function _initUser(userJSON) {\n var self = this;\n self.debug(\"_initUser:\", userJSON);\n self.user = new userModel.User(userJSON);\n self.user.logger = self.logger;\n return self;\n};\n\n/** Set up DOM/jQuery/Backbone event listeners enabled for all pages */\nGalaxyApp.prototype._setUpListeners = function _setUpListeners() {\n var self = this;\n\n // hook to jq beforeSend to record the most recent ajax call and cache some data about it\n /** cached info about the last ajax call made through jQuery */\n self.lastAjax = {};\n $(document).bind(\"ajaxSend\", function(ev, xhr, options) {\n var data = options.data;\n try {\n data = JSON.parse(data);\n } catch (err) {}\n\n self.lastAjax = {\n url: location.href.slice(0, -1) + options.url,\n data: data\n };\n //TODO:?? we might somehow manage to *retry* ajax using either this hook or Backbone.sync\n });\n return self;\n};\n\n/** Turn debugging/console-output on/off by passing boolean. Pass nothing to get current setting. */\nGalaxyApp.prototype.debugging = function _debugging(setting) {\n var self = this;\n try {\n if (setting === undefined) {\n return localStorage.getItem(DEBUGGING_KEY) === \"true\";\n }\n if (setting) {\n localStorage.setItem(DEBUGGING_KEY, true);\n return true;\n }\n\n localStorage.removeItem(DEBUGGING_KEY);\n // also remove all namespaces\n self.debuggingNamespaces(null);\n } catch (storageErr) {\n console.log(\n localize(\"localStorage not available for debug flag retrieval\")\n );\n }\n return false;\n};\n\n/** Add, remove, or clear namespaces from the debugging filters\n * Pass no arguments to retrieve the existing namespaces as an array.\n * Pass in null to clear all namespaces (all logging messages will show now).\n * Pass in an array of strings or single string of the namespaces to filter to.\n * Returns the new/current namespaces as an array;\n */\nGalaxyApp.prototype.debuggingNamespaces = function _debuggingNamespaces(\n namespaces\n) {\n var self = this;\n try {\n if (namespaces === undefined) {\n var csv = localStorage.getItem(NAMESPACE_KEY);\n return typeof csv === \"string\" ? csv.split(\",\") : [];\n } else if (namespaces === null) {\n localStorage.removeItem(NAMESPACE_KEY);\n } else {\n localStorage.setItem(NAMESPACE_KEY, namespaces);\n }\n var newSettings = self.debuggingNamespaces();\n if (self.logger) {\n self.logger.options.consoleNamespaceWhitelist = newSettings;\n }\n return newSettings;\n } catch (storageErr) {\n console.log(\n localize(\"localStorage not available for debug namespace retrieval\")\n );\n }\n};\n\n/** string rep */\nGalaxyApp.prototype.toString = function toString() {\n var userEmail = this.user\n ? this.user.get(\"email\") || \"(anonymous)\"\n : \"uninitialized\";\n return \"GalaxyApp(\" + userEmail + \")\";\n};\n\n// ============================================================================\nexport default {\n GalaxyApp: GalaxyApp\n};\n"]} \ No newline at end of file diff --git a/static/maps/onload.js.map b/static/maps/onload.js.map index feeb10a38f4..84ed6f03266 100644 --- a/static/maps/onload.js.map +++ b/static/maps/onload.js.map @@ -1 +1 @@ -{"version":3,"sources":["onload.js"],"names":["replace_big_select_inputs","min_length","max_length","select_elts","refresh_select2","element","panels","placeholder","closeOnSelect","$","is","dropdownAutoWidth","containerCssClass","window","async_save_text","options","jQuery","fn","select2","undefined","num_options","select_elt","find","length","init_refresh_on_change","off","change","select_field","this","select_val","val","ref_on_change_vals","attr","split","last_selected_value","inArray","document","trigger","submit","click","refresh","get","form","confirm","_","Backbone","_panel2","default","extend","_modal2","_asyncSaveText2","make_popupmenu","_popupmenu2","make_popup_menus","init_tag_click_function","_autocom_tagging2","webhooks","each","webhook","activate","script","type","onloadWebhooks","appendTo","setTimeout","tooltip","placement","anchor","galaxy_main_exists","parent","frames","galaxy_main","href","et","JSON","parse","sessionStorage","getItem","steps","hooked_tour_from_data","tour","Tour","tour_opts","init","restart"],"mappings":"oOAkCA,SAASA,EAA0BC,EAAYC,EAAYC,GAtB3D,SAAAC,EAAAC,GAwBQ,IAtBDC,GAwBKC,YAAa,kBAtBzBC,eAoByBC,EAAEJ,GApB3BK,GAAA,cAwBYC,mBAAmB,EAtB/BC,kBAAA,oBAEAC,OAAOC,EAAAA,QAAPC,GA2BSC,OAAOC,GAAGC,eAjBnBC,IAAAlB,IACAA,EAAA,SAEAkB,IAAAjB,IACAA,EAASF,MAGDG,EAAIY,GAAUN,EAAA,WAEVD,KAAAA,WACAG,IAAAA,EAAAA,EAAAA,MAAAA,IAAmB,cAHTS,EAAdC,EAAAC,KAAA,UAAAC,OAMAH,EAAOf,GAAgBU,EAAvBb,GAIAmB,EAAWH,SAAS,oBAiCpBd,EAAgBiB,MAjBhB,SAAAG,IACAf,EAAA,oCACAgB,IAAA,UACIC,OAAA,WACH,IAAAC,EAAAlB,EAAAmB,MAuBOC,EAAaF,EAAaG,MApB9BC,EAAAJ,EAAAK,KACH,4BAED,GAAAD,EAAA,CAuBQA,EAAqBA,EAAmBE,MAAM,KAC9C,IAAIC,EAAsBP,EAAaK,KACnC,uBAEJ,IACmD,IAA/CvB,EAAE0B,QAAQN,EAAYE,KArBlC,IAAA3B,EAAAA,QAAgBiB,EAAhBU,GAEP,OAGDtB,EAASe,QAAAA,QAAAA,qBACHf,EAAA2B,UAAAC,QAAA,qBAGMV,EAAIA,IAAAA,GAAelB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AKDrD,EAA0B,GAAI,MAE9BS,EAAA,KAAA8B,MAAA,WACA,IAAA4B,EAAA1D,EAAAmB,MACEwC,EAAsBC,OAAAC,QAAAD,OAAAC,OAAAC,YACpB,GAAA,eAAAJ,EAAIA,KAAAA,YAAJC,EAAA,CACA,IAAIA,EAAAA,EAAAA,KAAAA,SACA,GAAAD,EAAAA,QAAY,KACZK,GAAIA,IAEAA,GAAAA,IAEAA,GAAAA,kBACHL,EAAAnC,KAAA,OAAAwC,GACDA,EAAAA,KAAQ,SAAA,SAERL,OAAAA,IAGP,IAAAM,EAfDC,KAAAC,MAAAC,eAAAC,QAAA,qBAkBA,GAAIJ,IADJA,EAAIA,EAAAA,QAAKC,sBAAWE,KACZH,EAAAK,OACJL,QAAK5D,OAAMkE,OAAAA,OAAAA,IAAN,CAKG,IAAAC,EAAA,IAAAC,KACArC,EAAAI,QAIY8B,MAAUA,EAAAA,OAKtBE,EAAAA,QAAAE,YAGPF,EAAAG,OACJH,EAAAI,UAuBDtB","file":"../scripts/onload.js","sourcesContent":["// ============================================================================\n// Globals (temporary)\n// ============================================================================\n// HACK: add these to global scope until we stop asking for them there...\n// Via webpack: these are required here automatically by the provider plugin\n// Via script tag: these are redundant (identities) since they're already global\nwindow[\"jQuery\"] = jQuery; // a weird form to prevent webpack from sub'ing 'window.jQuery' in the provider plugin\nwindow.$ = jQuery;\nwindow._ = _;\nwindow.Backbone = Backbone;\n// console.debug('globals loaded:', window.jQuery, window.Backbone, '...');\n\n// these are galaxy globals not defined in the provider (although they could be - but why encourage that?)\nimport Panel from \"layout/panel\";\nwindow.panels = Panel;\n\n// using extend bc there are multiple fns/objs to decorate the window with\nimport layout_modal from \"layout/modal\";\n_.extend(window, layout_modal);\nimport async_save_text from \"utils/async-save-text\";\nwindow.async_save_text = async_save_text;\nimport POPUPMENU from \"ui/popupmenu\";\nwindow.make_popupmenu = POPUPMENU.make_popupmenu;\nwindow.make_popup_menus = POPUPMENU.make_popup_menus;\nimport init_tag_click_function from 'ui/autocom_tagging';\nwindow.init_tag_click_function = init_tag_click_function;\nimport TOURS from \"mvc/tours\";\nimport QUERY_STRING from \"utils/query-string-parsing\";\n// console.debug( 'galaxy globals loaded' );\n\n// ============================================================================\n// jquery on document ready\n// ============================================================================\n// Replace select box with a text input box + autocomplete.\nfunction replace_big_select_inputs(min_length, max_length, select_elts) {\n function refresh_select2(element) {\n var select_elt = $(element);\n var options = {\n placeholder: \"Click to select\",\n closeOnSelect: !select_elt.is(\"[MULTIPLE]\"),\n dropdownAutoWidth: true,\n containerCssClass: \"select2-minwidth\"\n };\n return element.select2(options);\n }\n\n // To do replace, the select2 plugin must be loaded.\n if (!jQuery.fn.select2) {\n return;\n }\n\n // Set default for min_length and max_length\n if (min_length === undefined) {\n min_length = 20;\n }\n if (max_length === undefined) {\n max_length = 3000;\n }\n\n select_elts = select_elts || $(\"select\");\n\n select_elts.each(function() {\n var select_elt = $(this).not(\"[multiple]\");\n // Make sure that options is within range.\n var num_options = select_elt.find(\"option\").length;\n if (num_options < min_length || num_options > max_length) {\n return;\n }\n\n if (select_elt.hasClass(\"no-autocomplete\")) {\n return;\n }\n\n /* Replaced jQuery.autocomplete with select2, notes:\n * - multiple selects are supported\n * - the original element is updated with the value, convert_to_values should not be needed\n * - events are fired when updating the original element, so refresh_on_change should just work\n *\n * - should we still sort dbkey fields here?\n */\n refresh_select2(select_elt);\n });\n}\n\n// Initialize refresh events.\nfunction init_refresh_on_change() {\n $(\"select[refresh_on_change='true']\")\n .off(\"change\")\n .change(function() {\n var select_field = $(this),\n select_val = select_field.val(),\n refresh = false,\n ref_on_change_vals = select_field.attr(\n \"refresh_on_change_values\"\n );\n if (ref_on_change_vals) {\n ref_on_change_vals = ref_on_change_vals.split(\",\");\n var last_selected_value = select_field.attr(\n \"last_selected_value\"\n );\n if (\n $.inArray(select_val, ref_on_change_vals) === -1 &&\n $.inArray(last_selected_value, ref_on_change_vals) === -1\n ) {\n return;\n }\n }\n $(window).trigger(\"refresh_on_change\");\n $(document).trigger(\"convert_to_values\"); // Convert autocomplete text to values\n select_field.get(0).form.submit();\n });\n\n // checkboxes refresh on change\n $(\":checkbox[refresh_on_change='true']\")\n .off(\"click\")\n .click(function() {\n var select_field = $(this),\n select_val = select_field.val(),\n refresh = false,\n ref_on_change_vals = select_field.attr(\n \"refresh_on_change_values\"\n );\n if (ref_on_change_vals) {\n ref_on_change_vals = ref_on_change_vals.split(\",\");\n var last_selected_value = select_field.attr(\n \"last_selected_value\"\n );\n if (\n $.inArray(select_val, ref_on_change_vals) === -1 &&\n $.inArray(last_selected_value, ref_on_change_vals) === -1\n ) {\n return;\n }\n }\n $(window).trigger(\"refresh_on_change\");\n select_field.get(0).form.submit();\n });\n\n // Links with confirmation\n $(\"a[confirm]\")\n .off(\"click\")\n .click(function() {\n return confirm($(this).attr(\"confirm\"));\n });\n}\n// used globally in grid-view\nwindow.init_refresh_on_change = init_refresh_on_change;\n\n$(document).ready(function() {\n // Refresh events for form fields.\n init_refresh_on_change();\n\n // Tooltips\n if ($.fn.tooltip) {\n // Put tooltips below items in panel header so that they do not overlap masthead.\n $(\".unified-panel-header [title]\").tooltip({ placement: \"bottom\" });\n\n // default tooltip initialization, it will follow the data-placement tag for tooltip location\n // and fallback to 'top' if not present\n $(\"[title]\").tooltip();\n }\n // Make popup menus.\n make_popup_menus();\n\n // Replace big selects.\n replace_big_select_inputs(20, 1500);\n\n // If galaxy_main frame does not exist and link targets galaxy_main,\n // add use_panels=True and set target to self.\n $(\"a\").click(function() {\n var anchor = $(this);\n var galaxy_main_exists = parent.frames && parent.frames.galaxy_main;\n if (anchor.attr(\"target\") == \"galaxy_main\" && !galaxy_main_exists) {\n var href = anchor.attr(\"href\");\n if (href.indexOf(\"?\") == -1) {\n href += \"?\";\n } else {\n href += \"&\";\n }\n href += \"use_panels=True\";\n anchor.attr(\"href\", href);\n anchor.attr(\"target\", \"_self\");\n }\n return anchor;\n });\n\n var et = JSON.parse(sessionStorage.getItem(\"activeGalaxyTour\"));\n if (et) {\n et = TOURS.hooked_tour_from_data(et);\n if (et && et.steps) {\n if (window && window.self === window.top) {\n // Only kick off a new tour if this is the toplevel window (non-iframe). This\n // functionality actually *could* be useful, but we'd need to handle it better and\n // come up with some design guidelines for tours jumping between windows.\n // Disabling for now.\n var tour = new Tour(\n _.extend(\n {\n steps: et.steps\n },\n TOURS.tour_opts\n )\n );\n tour.init();\n tour.restart();\n }\n }\n }\n\n function onloadWebhooks() {\n if (Galaxy.root !== undefined) {\n // Load all webhooks with the type 'onload'\n $.getJSON(Galaxy.root + \"api/webhooks/onload/all\", function(\n webhooks\n ) {\n _.each(webhooks, function(webhook) {\n if (webhook.activate && webhook.script) {\n $(\"