{"version":3,"sources":["webpack:///index.js","webpack:///webpack/bootstrap 79081821ac232cf7084f","webpack:///./src/index.js","webpack:///./~/custom-event-polyfill/custom-event-polyfill.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","_classCallCheck","instance","Constructor","TypeError","getDispatcherElement","dispatcherElementSelector","element","document","querySelector","generatedElement","createElement","setAttribute","scripts","getElementsByTagName","currentScriptPath","length","src","split","spinnerLocation","join","_createClass","defineProperties","target","props","i","descriptor","protoProps","staticProps","prototype","EVENTS","ERROR_LOADING_WIDGET","REFRESH_WIDGET","WidgetLoaderClass","this","dispatcherElement","eventName","detail","arguments","undefined","evt","CustomEvent","dispatchEvent","callback","addEventListener","removeEventListener","_this","fn","e","_ref","name","version","container","path","spinner","_ref$options","options","_ref$language","language","console","error","containersById","containerNodes","toString","window","sparta","widgetLoader","push","forEach","currentContainer","dest","getElementById","querySelectorAll","pub","generateStyleSheet","widgetXHR","containers","style","styles","type","stylesSheet","styleSheet","cssText","appendChild","createTextNode","head","classList","add","xhrReq","XMLHttpRequest","LANG_PATH","toLowerCase","WIDGET_PATH","self","onreadystatechange","_this2","readyState","status","innerHTML","widget","responseText","JSON","stringify","height","backgroundImage","myScripts","slice","item","newElem","parentNode","removeChild","open","send","ce","preventDefault","defaultPrevented","Error","event","params","origPrevent","bubbles","cancelable","createEvent","initCustomEvent","get","Event"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAE,WACAE,GAAAJ,EACAK,QAAA,EAUA,OANAP,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,QAAA,EAGAF,EAAAD,QAvBA,GAAAD,KAqCA,OATAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EA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,UAAAmC,OAAA6D,MAAAhG,UACAmC,OAAAvB","file":"index.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\t__webpack_require__(1);\n\t\n\tfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t// spinnerLocation will store a reference to our spinner's GIF file\n\tvar spinnerLocation = void 0;\n\t\n\t/**\n\t * @method getDispatcherElement\n\t * @description checks to see if DispatcherElement exists and creates it if necessary\n\t * @returns Node\n\t */\n\tfunction getDispatcherElement() {\n\t /**\n\t * @const dispatcherDataAttribute\n\t * @description data attribute that our DispatcherElement will have\n\t */\n\t var dispatcherDataAttribute = 'sparta-event-dispatcher';\n\t\n\t /**\n\t * @const dispatcherElementSelector\n\t * @description selector that will be used to determine if our DispatcherElement already exists\n\t */\n\t var dispatcherElementSelector = '[data-' + dispatcherDataAttribute + ']';\n\t\n\t /**\n\t * @const element\n\t * @description selected DispatcherElement from document\n\t */\n\t var element = document.querySelector(dispatcherElementSelector);\n\t\n\t // if DispatcherElement does not yet exist\n\t if (!element) {\n\t /**\n\t * @const generatedElement\n\t * @description created element to become our DispatcherElement\n\t */\n\t var generatedElement = document.createElement('div');\n\t\n\t // set our DispatcherElement data attribute\n\t generatedElement.setAttribute('data-' + dispatcherDataAttribute, true);\n\t\n\t // get current script path and use it to produce relevant spinner path\n\t var scripts = document.getElementsByTagName('script');\n\t\n\t var currentScriptPath = scripts[scripts.length - 1].src.split('/');\n\t\n\t currentScriptPath[currentScriptPath.length - 1] = 'loading.gif';\n\t\n\t spinnerLocation = currentScriptPath.join('/');\n\t\n\t return generatedElement;\n\t }\n\t\n\t // return selected DispatcherElement element\n\t return element;\n\t}\n\t\n\tvar EVENTS = {\n\t ERROR_LOADING_WIDGET: \"errorLoadingWidget\",\n\t REFRESH_WIDGET: \"refreshWidget\"\n\t};\n\t\n\t/**\n\t * @class WidgetLoader\n\t * @description class for our WidgetLoader that will initialize widgets and facilitate communication between widget and page\n\t */\n\t\n\tvar WidgetLoaderClass = function () {\n\t /**\n\t * @method constructor\n\t * @description initializes a new instance of WidgetLoader and makes sure our DispatcherElement exists\n\t */\n\t function WidgetLoaderClass() {\n\t _classCallCheck(this, WidgetLoaderClass);\n\t\n\t this.dispatcherElement = getDispatcherElement();\n\t }\n\t\n\t /**\n\t * @method pub\n\t * @description creates and dispatches a native CustomEvent on our DispatcherElement\n\t * @param {String} eventName the event name to dispatch\n\t * @param {*} [detail={}] the event data to attach to the event.detail parameter\n\t */\n\t\n\t\n\t _createClass(WidgetLoaderClass, [{\n\t key: 'pub',\n\t value: function pub(eventName) {\n\t var detail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\t\n\t /**\n\t * @const evt\n\t * @description native CustomEvent to dispatch\n\t */\n\t var evt = new CustomEvent(eventName, { detail: detail });\n\t\n\t // dispatch our CustomEvent from our DispatcherElement\n\t this.dispatcherElement.dispatchEvent(evt);\n\t }\n\t\n\t /**\n\t * @method sub\n\t * @description attaches an event listener to our DispatcherElement\n\t * @param {String} eventName the event name to listen for\n\t * @param {Function} callback the event handler to fire\n\t */\n\t\n\t }, {\n\t key: 'sub',\n\t value: function sub(eventName, callback) {\n\t // add event listener to DispatcherElement\n\t this.dispatcherElement.addEventListener(eventName, callback);\n\t }\n\t\n\t /**\n\t * @method unsub\n\t * @description allows subscriber to unsubscribe from event\n\t * @param {String} eventName the event name to listen for\n\t * @param {Function} callback the event handler to fire\n\t */\n\t\n\t }, {\n\t key: 'unsub',\n\t value: function unsub(eventName, callback) {\n\t this.dispatcherElement.removeEventListener(eventName, callback);\n\t }\n\t\n\t /**\n\t * @method once\n\t * @description allows subscriber to listen to one instance of event and then unsub\n\t * @param {String} eventName the event name to listen for\n\t * @param {Function} callback the event handler to fire\n\t */\n\t\n\t }, {\n\t key: 'once',\n\t value: function once(eventName, callback) {\n\t var _this = this;\n\t\n\t var fn = function fn(e) {\n\t _this.dispatcherElement.removeEventListener(eventName, fn);\n\t\n\t callback(e);\n\t };\n\t\n\t this.dispatcherElement.addEventListener(eventName, fn);\n\t }\n\t\n\t /**\n\t * @method load\n\t * @description loads a widget into the specified container\n\t * @param {Object} Config object, must contain keys 'name, version, container, path', optional spinner Boolean value\n\t */\n\t\n\t }, {\n\t key: 'load',\n\t value: function load(_ref) {\n\t var name = _ref.name,\n\t version = _ref.version,\n\t container = _ref.container,\n\t path = _ref.path,\n\t spinner = _ref.spinner,\n\t _ref$options = _ref.options,\n\t options = _ref$options === undefined ? {} : _ref$options,\n\t _ref$language = _ref.language,\n\t language = _ref$language === undefined ? 'en' : _ref$language;\n\t\n\t if (!name || !version || !container) {\n\t console.error('invalid config object passed to widget loader');\n\t return false;\n\t }\n\t\n\t var containersById = [];\n\t var containerNodes = [];\n\t\n\t // check if loading widget in multiple places\n\t if (Object.prototype.toString.call(container) === \"[object Array]\") {\n\t window.sparta.widgetLoader[name] = _defineProperty({}, version, {});\n\t containersById = container;\n\t } else {\n\t containersById.push(container);\n\t }\n\t\n\t // loop over the containers, check if they exist and load as appropriate\n\t containersById.forEach(function (currentContainer) {\n\t //window.sparta.widgetLoader[name][version][currentContainer] = {loaded:false};\n\t\n\t // get Node for widget container\n\t var dest = document.getElementById(currentContainer);\n\t\n\t // if widget container does not exist\n\t if (!dest) {\n\t console.error('widget container destination does not exist');\n\t return false;\n\t }\n\t\n\t containerNodes.push(dest);\n\t });\n\t\n\t // refresh widget if it exists, otherwise load it\n\t if (document.querySelectorAll('[data-sparta-container=\"' + name + '\"][data-version=\"' + version + '\"]').length > 0) {\n\t this.pub(EVENTS.REFRESH_WIDGET, { name: name, version: version, container: containerNodes });\n\t } else {\n\t this.generateStyleSheet(containerNodes, spinner);\n\t this.widgetXHR(containerNodes, path, name, version, options, language);\n\t }\n\t }\n\t\n\t /**\n\t * @method generatedStyleSheet\n\t * @description add stylesheet for loading states so we don't need another HTTP request\n\t * @param {Array} containers array of widget container Nodes\n\t * @param {Boolean} [spinner=true] should we use default spinner\n\t */\n\t\n\t }, {\n\t key: 'generateStyleSheet',\n\t value: function generateStyleSheet(containers) {\n\t var spinner = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n\t\n\t containers.forEach(function (dest) {\n\t // generate stylesheet for loading\n\t var style = document.createElement('style');\n\t\n\t var styles = '\\n #' + dest.id + ' > [data-sparta-container].sparta-widget-loading,\\n #' + dest.id + ' > [data-sparta-container].sparta-widget-loading > .sparta-widget {\\n visibility: hidden;\\n height: 100%;\\n widht: 100%;\\n }\\n ';\n\t\n\t // if we are supposed to show our spinner, add a style to the widget container\n\t if (spinner) {\n\t styles += '\\n #' + dest.id + '.sparta-widget-loading {\\n height: 100%;\\n background-image: url(\\'' + spinnerLocation + '\\');\\n background-repeat: no-repeat;\\n background-position: center center;\\n }\\n ';\n\t }\n\t\n\t // add stylesheet to page\n\t style.type = 'text/css';\n\t style.id = dest.id + '-sparta-widget-style-sheet';\n\t\n\t if (style.stylesSheet) {\n\t style.styleSheet.cssText = styles;\n\t } else {\n\t style.appendChild(document.createTextNode(styles));\n\t }\n\t\n\t document.head.appendChild(style);\n\t\n\t dest.classList.add('sparta-widget-loading');\n\t });\n\t }\n\t\n\t /**\n\t * @method widgetXHR\n\t * @description loads widget via AJAX request\n\t * @param {Array} containers array of widget container Nodes\n\t * @param {String} path where to load the widget from\n\t * @param {String} name the name of the widget\n\t * @param {String} version the version number of the widget to load\n\t * @param {String} language the language to attempt to load (en default)\n\t */\n\t\n\t }, {\n\t key: 'widgetXHR',\n\t value: function widgetXHR(containers, path, name, version, options, language) {\n\t var xhrReq = new XMLHttpRequest();\n\t\n\t var LANG_PATH = !language || language.toLowerCase() === \"en\" ? \"\" : language.toLowerCase() + '/';\n\t var WIDGET_PATH = path + '/spa/widgets/' + name + '/' + version + '/' + LANG_PATH + 'index.html';\n\t var self = this;\n\t\n\t xhrReq.onreadystatechange = function () {\n\t var _this2 = this;\n\t\n\t if (this.readyState === 4) {\n\t if (this.status !== 200) {\n\t console.error('unable to load widget:', WIDGET_PATH, this.status);\n\t\n\t containers.forEach(function (dest) {\n\t dest.innerHTML = 'unable to load widget';\n\t self.pub(EVENTS.ERROR_LOADING_WIDGET, { widget: { name: name, version: version, path: path, container: dest }, xhrReq: _this2 });\n\t });\n\t } else {\n\t (function () {\n\t // place HTML in all containers\n\t containers.forEach(function (currentContainer) {\n\t currentContainer.innerHTML = _this2.responseText;\n\t });\n\t\n\t // grab the last item and load the JS into that\n\t var dest = containers[containers.length - 1];\n\t\n\t // add options into meta data for bootstrapper\n\t dest.querySelector(\"[data-sparta-widget]\").setAttribute(\"data-sparta-options\", JSON.stringify(options));\n\t\n\t // remove loader\n\t dest.style.height = 'auto';\n\t dest.style.backgroundImage = '';\n\t\n\t // get all script tags so we can make the scripts load\n\t var myScripts = [].slice.call(dest.querySelectorAll('script'));\n\t\n\t // iterate through scripts\n\t myScripts.forEach(function (item) {\n\t // generate new script element\n\t var newElem = document.createElement('script');\n\t\n\t // depending on script type\n\t if (item.src) {\n\t // update src attribute\n\t newElem.src = item.src;\n\t } else {\n\t // inject code into script innerHTML\n\t newElem.innerHTML = item.innerHTML;\n\t }\n\t\n\t // add script tag to widget container\n\t dest.appendChild(newElem);\n\t\n\t // remove original script node (ie10 does not support item.remove())\n\t item.parentNode.removeChild(item);\n\t });\n\t })();\n\t }\n\t }\n\t };\n\t\n\t // execute AJAX request\n\t xhrReq.open('GET', WIDGET_PATH);\n\t xhrReq.send();\n\t }\n\t }]);\n\t\n\t return WidgetLoaderClass;\n\t}();\n\t\n\tif (!(window.sparta && window.sparta.widgetLoader)) {\n\t var widgetLoader = new WidgetLoaderClass();\n\t\n\t window.sparta = window.sparta || {};\n\t\n\t window.sparta.widgetLoader = widgetLoader;\n\t\n\t document.dispatchEvent(new CustomEvent('spartaLoaderLoaded'));\n\t}\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\t// Polyfill for creating CustomEvents on IE9/10/11\n\t\n\t// code pulled from:\n\t// https://github.com/d4tocchini/customevent-polyfill\n\t// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill\n\t\n\ttry {\n\t var ce = new window.CustomEvent('test');\n\t ce.preventDefault();\n\t if (ce.defaultPrevented !== true) {\n\t // IE has problems with .preventDefault() on custom events\n\t // http://stackoverflow.com/questions/23349191\n\t throw new Error('Could not prevent default');\n\t }\n\t} catch(e) {\n\t var CustomEvent = function(event, params) {\n\t var evt, origPrevent;\n\t params = params || {\n\t bubbles: false,\n\t cancelable: false,\n\t detail: undefined\n\t };\n\t\n\t evt = document.createEvent(\"CustomEvent\");\n\t evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n\t origPrevent = evt.preventDefault;\n\t evt.preventDefault = function () {\n\t origPrevent.call(this);\n\t try {\n\t Object.defineProperty(this, 'defaultPrevented', {\n\t get: function () {\n\t return true;\n\t }\n\t });\n\t } catch(e) {\n\t this.defaultPrevented = true;\n\t }\n\t };\n\t return evt;\n\t };\n\t\n\t CustomEvent.prototype = window.Event.prototype;\n\t window.CustomEvent = CustomEvent; // expose definition to window\n\t}\n\n\n/***/ }\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// index.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 79081821ac232cf7084f","\nimport 'custom-event-polyfill';\n\n// spinnerLocation will store a reference to our spinner's GIF file\nlet spinnerLocation;\n\n/**\n * @method getDispatcherElement\n * @description checks to see if DispatcherElement exists and creates it if necessary\n * @returns Node\n */\nfunction getDispatcherElement() {\n /**\n * @const dispatcherDataAttribute\n * @description data attribute that our DispatcherElement will have\n */\n const dispatcherDataAttribute = 'sparta-event-dispatcher';\n\n /**\n * @const dispatcherElementSelector\n * @description selector that will be used to determine if our DispatcherElement already exists\n */\n const dispatcherElementSelector = `[data-${dispatcherDataAttribute}]`;\n\n /**\n * @const element\n * @description selected DispatcherElement from document\n */\n const element = document.querySelector(dispatcherElementSelector);\n\n // if DispatcherElement does not yet exist\n if (!element) {\n /**\n * @const generatedElement\n * @description created element to become our DispatcherElement\n */\n const generatedElement = document.createElement('div');\n\n // set our DispatcherElement data attribute\n generatedElement.setAttribute(`data-${dispatcherDataAttribute}`, true);\n\n // get current script path and use it to produce relevant spinner path\n const scripts = document.getElementsByTagName('script');\n\n let currentScriptPath = scripts[scripts.length - 1].src.split('/');\n\n currentScriptPath[currentScriptPath.length - 1] = 'loading.gif';\n\n spinnerLocation = currentScriptPath.join('/');\n\n return generatedElement;\n }\n\n // return selected DispatcherElement element\n return element;\n}\n\nconst EVENTS = {\n ERROR_LOADING_WIDGET: \"errorLoadingWidget\",\n REFRESH_WIDGET: \"refreshWidget\"\n}\n\n/**\n * @class WidgetLoader\n * @description class for our WidgetLoader that will initialize widgets and facilitate communication between widget and page\n */\nclass WidgetLoaderClass {\n /**\n * @method constructor\n * @description initializes a new instance of WidgetLoader and makes sure our DispatcherElement exists\n */\n constructor() {\n this.dispatcherElement = getDispatcherElement();\n }\n\n /**\n * @method pub\n * @description creates and dispatches a native CustomEvent on our DispatcherElement\n * @param {String} eventName the event name to dispatch\n * @param {*} [detail={}] the event data to attach to the event.detail parameter\n */\n pub(eventName, detail = {}) {\n /**\n * @const evt\n * @description native CustomEvent to dispatch\n */\n const evt = new CustomEvent(eventName, { detail });\n\n // dispatch our CustomEvent from our DispatcherElement\n this.dispatcherElement.dispatchEvent(evt);\n }\n\n /**\n * @method sub\n * @description attaches an event listener to our DispatcherElement\n * @param {String} eventName the event name to listen for\n * @param {Function} callback the event handler to fire\n */\n sub(eventName, callback) {\n // add event listener to DispatcherElement\n this.dispatcherElement.addEventListener(eventName, callback);\n }\n\n /**\n * @method unsub\n * @description allows subscriber to unsubscribe from event\n * @param {String} eventName the event name to listen for\n * @param {Function} callback the event handler to fire\n */\n unsub(eventName, callback) {\n this.dispatcherElement.removeEventListener(eventName, callback);\n }\n\n /**\n * @method once\n * @description allows subscriber to listen to one instance of event and then unsub\n * @param {String} eventName the event name to listen for\n * @param {Function} callback the event handler to fire\n */\n once(eventName, callback) {\n const fn = (e) => {\n this.dispatcherElement.removeEventListener(eventName, fn);\n\n callback(e);\n };\n\n this.dispatcherElement.addEventListener(eventName, fn);\n }\n\n /**\n * @method load\n * @description loads a widget into the specified container\n * @param {Object} Config object, must contain keys 'name, version, container, path', optional spinner Boolean value\n */\n load({ name, version, container, path, spinner, options = {}, language='en' }) {\n if (!name || !version || !container) {\n console.error('invalid config object passed to widget loader');\n return false;\n }\n\n let containersById = [];\n let containerNodes = [];\n\n // check if loading widget in multiple places\n if (Object.prototype.toString.call(container) === \"[object Array]\") {\n window.sparta.widgetLoader[name] = {[version]:{}};\n containersById = container;\n } else {\n containersById.push(container);\n }\n\n // loop over the containers, check if they exist and load as appropriate\n containersById.forEach((currentContainer) => {\n //window.sparta.widgetLoader[name][version][currentContainer] = {loaded:false};\n\n // get Node for widget container\n const dest = document.getElementById(currentContainer);\n\n // if widget container does not exist\n if (!dest) {\n console.error('widget container destination does not exist');\n return false;\n }\n\n containerNodes.push(dest);\n })\n\n // refresh widget if it exists, otherwise load it\n if (document.querySelectorAll('[data-sparta-container=\"' + name + '\"][data-version=\"' + version + '\"]').length > 0) {\n this.pub(EVENTS.REFRESH_WIDGET, {name:name, version:version, container:containerNodes});\n } else {\n this.generateStyleSheet(containerNodes, spinner);\n this.widgetXHR(containerNodes, path, name, version, options, language);\n }\n }\n\n /**\n * @method generatedStyleSheet\n * @description add stylesheet for loading states so we don't need another HTTP request\n * @param {Array} containers array of widget container Nodes\n * @param {Boolean} [spinner=true] should we use default spinner\n */\n generateStyleSheet(containers, spinner = true) {\n containers.forEach((dest) => {\n // generate stylesheet for loading\n const style = document.createElement('style');\n\n let styles = `\n #${dest.id} > [data-sparta-container].sparta-widget-loading,\n #${dest.id} > [data-sparta-container].sparta-widget-loading > .sparta-widget {\n visibility: hidden;\n height: 100%;\n widht: 100%;\n }\n `;\n\n // if we are supposed to show our spinner, add a style to the widget container\n if (spinner) {\n styles += `\n #${dest.id}.sparta-widget-loading {\n height: 100%;\n background-image: url('${spinnerLocation}');\n background-repeat: no-repeat;\n background-position: center center;\n }\n `;\n }\n\n // add stylesheet to page\n style.type = 'text/css';\n style.id = `${dest.id}-sparta-widget-style-sheet`;\n\n if (style.stylesSheet) {\n style.styleSheet.cssText = styles;\n } else {\n style.appendChild(document.createTextNode(styles));\n }\n\n document.head.appendChild(style);\n\n dest.classList.add('sparta-widget-loading');\n })\n }\n\n /**\n * @method widgetXHR\n * @description loads widget via AJAX request\n * @param {Array} containers array of widget container Nodes\n * @param {String} path where to load the widget from\n * @param {String} name the name of the widget\n * @param {String} version the version number of the widget to load\n * @param {String} language the language to attempt to load (en default)\n */\n widgetXHR(containers, path, name, version, options, language) {\n const xhrReq = new XMLHttpRequest();\n\n const LANG_PATH = (!language || language.toLowerCase() === \"en\") ? \"\" : `${language.toLowerCase()}/`;\n const WIDGET_PATH = `${path}/spa/widgets/${name}/${version}/${LANG_PATH}index.html`;\n const self = this;\n\n xhrReq.onreadystatechange = function() {\n if (this.readyState === 4) {\n if (this.status !== 200) {\n console.error('unable to load widget:', WIDGET_PATH, this.status);\n\n containers.forEach((dest) => {\n dest.innerHTML = 'unable to load widget';\n self.pub(EVENTS.ERROR_LOADING_WIDGET, {widget:{name:name, version:version, path:path, container:dest}, xhrReq:this});\n });\n\n } else {\n // place HTML in all containers\n containers.forEach((currentContainer) => {\n currentContainer.innerHTML = this.responseText;\n })\n\n // grab the last item and load the JS into that\n let dest = containers[containers.length - 1];\n\n // add options into meta data for bootstrapper\n dest.querySelector(\"[data-sparta-widget]\").setAttribute(\"data-sparta-options\", JSON.stringify(options));\n\n // remove loader\n dest.style.height = 'auto';\n dest.style.backgroundImage = '';\n\n // get all script tags so we can make the scripts load\n let myScripts = [].slice.call(dest.querySelectorAll('script'));\n\n // iterate through scripts\n myScripts.forEach((item) => {\n // generate new script element\n let newElem = document.createElement('script');\n\n // depending on script type\n if (item.src) {\n // update src attribute\n newElem.src = item.src;\n } else {\n // inject code into script innerHTML\n newElem.innerHTML = item.innerHTML;\n }\n\n // add script tag to widget container\n dest.appendChild(newElem);\n\n // remove original script node (ie10 does not support item.remove())\n item.parentNode.removeChild(item);\n });\n }\n }\n };\n\n // execute AJAX request\n xhrReq.open('GET', WIDGET_PATH);\n xhrReq.send();\n }\n}\n\nif (!(window.sparta && window.sparta.widgetLoader)) {\n const widgetLoader = new WidgetLoaderClass();\n\n window.sparta = window.sparta || {};\n\n window.sparta.widgetLoader = widgetLoader;\n\n document.dispatchEvent(new CustomEvent('spartaLoaderLoaded'));\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js","// Polyfill for creating CustomEvents on IE9/10/11\n\n// code pulled from:\n// https://github.com/d4tocchini/customevent-polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill\n\ntry {\n var ce = new window.CustomEvent('test');\n ce.preventDefault();\n if (ce.defaultPrevented !== true) {\n // IE has problems with .preventDefault() on custom events\n // http://stackoverflow.com/questions/23349191\n throw new Error('Could not prevent default');\n }\n} catch(e) {\n var CustomEvent = function(event, params) {\n var evt, origPrevent;\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n };\n\n evt = document.createEvent(\"CustomEvent\");\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n origPrevent = evt.preventDefault;\n evt.preventDefault = function () {\n origPrevent.call(this);\n try {\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () {\n return true;\n }\n });\n } catch(e) {\n this.defaultPrevented = true;\n }\n };\n return evt;\n };\n\n CustomEvent.prototype = window.Event.prototype;\n window.CustomEvent = CustomEvent; // expose definition to window\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/custom-event-polyfill/custom-event-polyfill.js\n// module id = 1\n// module chunks = 0"],"sourceRoot":""}