{"version":3,"sources":["webpack://HSSwitchText/webpack/universalModuleDefinition","webpack://HSSwitchText/webpack/bootstrap","webpack://HSSwitchText/./src/js/hs-switch-text.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","defaults","target","eventType","afterChange","startUpdateOnChange","HSSwitchText","el","options","id","this","collection","elems","HTMLElement","document","querySelectorAll","length","addToCollection","_init","that","_$el","_options","$el","addEventListener","querySelector","selector","innerHTML","text","$initializedEl","item","push","assign","hasAttribute","JSON","parse","getAttribute","find"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAsB,aAAID,IAE1BD,EAAmB,aAAIC,IARzB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC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WAAWK,SAfRN,KAoBRQ,QAEER,M,4CAGR,WAGC,IAFA,IAAMS,EAAOT,KADN,WAGEzC,GACR,IAAImD,OAAI,EACJC,OAAQ,EAEZ,GAAIF,EAAKR,WAAW1C,GAAG6B,eAAe,kBACrC,iBAGDsB,EAAOD,EAAKR,WAAW1C,GAAGqD,IAC1BD,EAAWF,EAAKR,WAAW1C,GAAGuC,QAE9BY,EAAKG,iBAAiBF,EAASlB,WAAU,WACxC,IAAK,IAAIlC,EAAI,EAAGA,EAAIoD,EAASnB,OAAOc,OAAQ/C,IAC/B6C,SAASU,cAAcH,EAASnB,OAAOjC,GAAGwD,UAClDC,UAAWL,EAASnB,OAAOjC,GAAG0D,KAGC,mBAAzBN,EAASjB,aACnBiB,EAASjB,iBAIXe,EAAKR,WAAW1C,GAAG2D,eAAiBP,GAtB5BpD,EAAI,EAAGA,EAAIkD,EAAKR,WAAWK,OAAQ/C,GAAK,EAAG,EAA3CA,K,6BA0BV,SAAiB4D,EAAMrB,EAASC,GAC/BC,KAAKC,WAAWmB,KAAK,CACpBR,IAAKO,EACLpB,GAAIA,GAAM,KACVD,QAAS7B,OAAOoD,OACf,GACA9B,EACA4B,EAAKG,aAxEiB,+BAyEnBC,KAAKC,MAAML,EAAKM,aAzEG,gCA0EnB,GACH3B,O,qBAKH,SAASqB,GACR,MAAoB,iBAATA,EACHnB,KAAKC,WAAWkB,GAAMD,eAEtBlB,KAAKC,WAAWyB,MAAK,SAAA7B,GAC3B,OAAOA,EAAGE,KAAOoB,KACfD,oB","file":"hs-switch-text.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"HSSwitchText\"] = factory();\n\telse\n\t\troot[\"HSSwitchText\"] = factory();\n})(window, function() {\nreturn "," \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 \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\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.l = 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// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/js/hs-switch-text.js\");\n","const dataAttributeName = 'data-hs-switch-text-options'\nconst defaults = {\n\ttarget: null,\n\teventType: 'change',\n\tafterChange: null,\n\tstartUpdateOnChange: false\n}\n\nexport default class HSSwitchText {\n\tconstructor(el, options, id) {\n\t\tthis.collection = []\n\t\tconst that = this\n\t\tlet elems\n\n\t\tif (el instanceof HTMLElement) {\n\t\t\telems = [el]\n\t\t} else if (el instanceof Object) {\n\t\t\telems = el\n\t\t} else {\n\t\t\telems = document.querySelectorAll(el)\n\t\t}\n\n\t\tfor (let i = 0; i < elems.length; i += 1) {\n\t\t\tthat.addToCollection(elems[i], options, id || elems[i].id)\n\t\t}\n\n\t\tif (!that.collection.length) {\n\t\t\treturn false\n\t\t}\n\n\t\t// initialization calls\n\t\tthat._init()\n\n\t\treturn this\n\t}\n\n\t_init() {\n\t\tconst that = this;\n\n\t\tfor (let i = 0; i < that.collection.length; i += 1) {\n\t\t\tlet _$el\n\t\t\tlet _options\n\n\t\t\tif (that.collection[i].hasOwnProperty('$initializedEl')) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_$el = that.collection[i].$el;\n\t\t\t_options = that.collection[i].options\n\n\t\t\t_$el.addEventListener(_options.eventType,() => {\n\t\t\t\tfor (let i = 0; i < _options.target.length; i++) {\n\t\t\t\t\tconst $el = document.querySelector(_options.target[i].selector)\n\t\t\t\t\t$el.innerHTML =_options.target[i].text\n\t\t\t\t}\n\n\t\t\t\tif (typeof _options.afterChange === \"function\") {\n\t\t\t\t\t_options.afterChange();\n\t\t\t\t}\n\t\t\t})\n\t\t\t\n\t\t\tthat.collection[i].$initializedEl = _options\n\t\t}\n\t}\n\n\taddToCollection (item, options, id) {\n\t\tthis.collection.push({\n\t\t\t$el: item,\n\t\t\tid: id || null,\n\t\t\toptions: Object.assign(\n\t\t\t\t{},\n\t\t\t\tdefaults,\n\t\t\t\titem.hasAttribute(dataAttributeName)\n\t\t\t\t\t? JSON.parse(item.getAttribute(dataAttributeName))\n\t\t\t\t\t: {},\n\t\t\t\toptions,\n\t\t\t),\n\t\t})\n\t}\n\n\tgetItem (item) {\n\t\tif (typeof item === 'number') {\n\t\t\treturn this.collection[item].$initializedEl;\n\t\t} else {\n\t\t\treturn this.collection.find(el => {\n\t\t\t\treturn el.id === item;\n\t\t\t}).$initializedEl;\n\t\t}\n\t}\n}\n"],"sourceRoot":""}