diff --git a/dest/javascript/breadcrumbs.js b/dest/javascript/breadcrumbs.js index bba0614..508e90a 100644 --- a/dest/javascript/breadcrumbs.js +++ b/dest/javascript/breadcrumbs.js @@ -109,7 +109,10 @@ var TrowelBreadcrumb = function () { this.toggleTriggers = [].slice.call(this.element.querySelectorAll('[data-breadcrumb="toggle"]')); this.list = this.element.querySelector('[data-breadcrumb="list"]'); - return this.listener(); + this.events = this.events(); + this.listener(); + this.element.dispatchEvent(this.events.mounted); + return; } _createClass(TrowelBreadcrumb, [{ @@ -120,17 +123,39 @@ var TrowelBreadcrumb = function () { }, { key: 'show', value: function show() { - return this.list.setAttribute('data-state', 'visible'); + this.element.dispatchEvent(this.events.show); + this.list.setAttribute('data-state', 'visible'); + this.element.dispatchEvent(this.events.shown); + return; } }, { key: 'hide', value: function hide() { - return this.list.setAttribute('data-state', 'hidden'); + this.element.dispatchEvent(this.events.hide); + this.list.setAttribute('data-state', 'hidden'); + this.element.dispatchEvent(this.events.hidden); + return; } }, { key: 'toggle', value: function toggle() { - return this.isVisible() ? this.hide() : this.show(); + this.element.dispatchEvent(this.events.toggle); + this.isVisible() ? this.hide() : this.show(); + this.element.dispatchEvent(this.events.toggled); + return; + } + }, { + key: 'events', + value: function events() { + var show = new Event('trowel.breadcrumb.show'); + var shown = new Event('trowel.breadcrumb.shown'); + var hide = new Event('trowel.breadcrumb.hide'); + var hidden = new Event('trowel.breadcrumb.hidden'); + var toggle = new Event('trowel.breadcrumb.toggle'); + var toggled = new Event('trowel.breadcrumb.toggled'); + var mounted = new Event('trowel.breadcrumb.mounted'); + + return { show: show, shown: shown, hide: hide, hidden: hidden, toggle: toggle, toggled: toggled, mounted: mounted }; } }, { key: 'listener', diff --git a/dest/javascript/breadcrumbs.js.map b/dest/javascript/breadcrumbs.js.map index 646621b..98b2f69 100644 --- a/dest/javascript/breadcrumbs.js.map +++ b/dest/javascript/breadcrumbs.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 5e9353dd7095b71a48c7","webpack:///./src/javascript/breadcrumbs.js"],"names":["TrowelBreadcrumbs","elements","forEach","element","index","element_obj","TrowelBreadcrumb","toggleTriggers","slice","call","querySelectorAll","list","querySelector","listener","getAttribute","setAttribute","isVisible","hide","show","map","toggleTrigger","addEventListener","toggle","bind"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;IChEqBA,iB,GACnB,2BAAYC,QAAZ,EAAsB;AAAA;;AACpBA,WAASC,OAAT,CAAiB,UAASC,OAAT,EAAkBC,KAAlB,EAAyB;AACxC,QAAIC,cAAc,IAAIC,gBAAJ,CAAqBH,OAArB,CAAlB;AACD,GAFD;AAGD,C;;kBALkBH,iB;;IAQfM,gB;AACJ,4BAAYH,OAAZ,EAAqB;AAAA;;AACnB,SAAKA,OAAL,GAAeA,OAAf;AACA,SAAKI,cAAL,GAAsB,GAAGC,KAAH,CAASC,IAAT,CAAc,KAAKN,OAAL,CAAaO,gBAAb,CAA8B,4BAA9B,CAAd,CAAtB;AACA,SAAKC,IAAL,GAAY,KAAKR,OAAL,CAAaS,aAAb,CAA2B,0BAA3B,CAAZ;;AAEA,WAAO,KAAKC,QAAL,EAAP;AACD;;;;gCAEW;AACV,aAAO,KAAKF,IAAL,CAAUG,YAAV,CAAuB,YAAvB,MAAyC,SAAhD;AACD;;;2BAEM;AACL,aAAO,KAAKH,IAAL,CAAUI,YAAV,CAAuB,YAAvB,EAAqC,SAArC,CAAP;AACD;;;2BAEM;AACL,aAAO,KAAKJ,IAAL,CAAUI,YAAV,CAAuB,YAAvB,EAAqC,QAArC,CAAP;AACD;;;6BAEQ;AACP,aAAO,KAAKC,SAAL,KAAmB,KAAKC,IAAL,EAAnB,GAAiC,KAAKC,IAAL,EAAxC;AACD;;;+BAGU;AAAA;;AACT,aAAO,KAAKX,cAAL,CACJY,GADI,CACA;AAAA,eAAiBC,cAAcC,gBAAd,CAA+B,OAA/B,EAAwC,MAAKC,MAAL,CAAYC,IAAZ,OAAxC,CAAjB;AAAA,OADA,CAAP;AAED","file":"breadcrumbs.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(\"TrowelBreadcrumbs\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TrowelBreadcrumbs\"] = factory();\n\telse\n\t\troot[\"TrowelBreadcrumbs\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \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// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 5e9353dd7095b71a48c7","export default class TrowelBreadcrumbs {\n constructor(elements) {\n elements.forEach(function(element, index) {\n let element_obj = new TrowelBreadcrumb(element);\n })\n }\n}\n\nclass TrowelBreadcrumb {\n constructor(element) {\n this.element = element;\n this.toggleTriggers = [].slice.call(this.element.querySelectorAll('[data-breadcrumb=\"toggle\"]'));\n this.list = this.element.querySelector('[data-breadcrumb=\"list\"]');\n\n return this.listener();\n }\n\n isVisible() {\n return this.list.getAttribute('data-state') === \"visible\";\n }\n\n show() {\n return this.list.setAttribute('data-state', 'visible');\n }\n\n hide() {\n return this.list.setAttribute('data-state', 'hidden');\n }\n\n toggle() {\n return this.isVisible() ? this.hide() : this.show();\n }\n\n\n listener() {\n return this.toggleTriggers\n .map(toggleTrigger => toggleTrigger.addEventListener('click', this.toggle.bind(this)));\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/javascript/breadcrumbs.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap daa8628dc7a92fbe888a","webpack:///./src/javascript/breadcrumbs.js"],"names":["TrowelBreadcrumbs","elements","forEach","element","index","element_obj","TrowelBreadcrumb","toggleTriggers","slice","call","querySelectorAll","list","querySelector","events","listener","dispatchEvent","mounted","getAttribute","show","setAttribute","shown","hide","hidden","toggle","isVisible","toggled","Event","map","toggleTrigger","addEventListener","bind"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;IChEqBA,iB,GACnB,2BAAYC,QAAZ,EAAsB;AAAA;;AACpBA,WAASC,OAAT,CAAiB,UAASC,OAAT,EAAkBC,KAAlB,EAAyB;AACxC,QAAIC,cAAc,IAAIC,gBAAJ,CAAqBH,OAArB,CAAlB;AACD,GAFD;AAGD,C;;kBALkBH,iB;;IAQfM,gB;AACJ,4BAAYH,OAAZ,EAAqB;AAAA;;AACnB,SAAKA,OAAL,GAAeA,OAAf;AACA,SAAKI,cAAL,GAAsB,GAAGC,KAAH,CAASC,IAAT,CAAc,KAAKN,OAAL,CAAaO,gBAAb,CAA8B,4BAA9B,CAAd,CAAtB;AACA,SAAKC,IAAL,GAAY,KAAKR,OAAL,CAAaS,aAAb,CAA2B,0BAA3B,CAAZ;;AAEA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,2BAAV,CAAhB;;AAEA,aAAO,EAAER,UAAF,EAAQE,YAAR,EAAeC,UAAf,EAAqBC,cAArB,EAA6BC,cAA7B,EAAqCE,gBAArC,EAA8CT,gBAA9C,EAAP;AACD;;;+BAGU;AAAA;;AACT,aAAO,KAAKT,cAAL,CACJoB,GADI,CACA;AAAA,eAAiBC,cAAcC,gBAAd,CAA+B,OAA/B,EAAwC,MAAKN,MAAL,CAAYO,IAAZ,OAAxC,CAAjB;AAAA,OADA,CAAP;AAED","file":"breadcrumbs.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(\"TrowelBreadcrumbs\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TrowelBreadcrumbs\"] = factory();\n\telse\n\t\troot[\"TrowelBreadcrumbs\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \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// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap daa8628dc7a92fbe888a","export default class TrowelBreadcrumbs {\n constructor(elements) {\n elements.forEach(function(element, index) {\n let element_obj = new TrowelBreadcrumb(element);\n })\n }\n}\n\nclass TrowelBreadcrumb {\n constructor(element) {\n this.element = element;\n this.toggleTriggers = [].slice.call(this.element.querySelectorAll('[data-breadcrumb=\"toggle\"]'));\n this.list = this.element.querySelector('[data-breadcrumb=\"list\"]');\n\n this.events = this.events();\n this.listener();\n this.element.dispatchEvent(this.events.mounted);\n return;\n }\n\n isVisible() {\n return this.list.getAttribute('data-state') === \"visible\";\n }\n\n show() {\n this.element.dispatchEvent(this.events.show);\n this.list.setAttribute('data-state', 'visible');\n this.element.dispatchEvent(this.events.shown);\n return;\n }\n\n hide() {\n this.element.dispatchEvent(this.events.hide);\n this.list.setAttribute('data-state', 'hidden');\n this.element.dispatchEvent(this.events.hidden);\n return;\n }\n\n toggle() {\n this.element.dispatchEvent(this.events.toggle);\n this.isVisible() ? this.hide() : this.show();\n this.element.dispatchEvent(this.events.toggled);\n return;\n }\n\n events() {\n const show = new Event('trowel.breadcrumb.show');\n const shown = new Event('trowel.breadcrumb.shown');\n const hide = new Event('trowel.breadcrumb.hide');\n const hidden = new Event('trowel.breadcrumb.hidden');\n const toggle = new Event('trowel.breadcrumb.toggle');\n const toggled = new Event('trowel.breadcrumb.toggled');\n const mounted = new Event('trowel.breadcrumb.mounted');\n\n return { show, shown, hide, hidden, toggle, toggled, mounted };\n }\n\n\n listener() {\n return this.toggleTriggers\n .map(toggleTrigger => toggleTrigger.addEventListener('click', this.toggle.bind(this)));\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/javascript/breadcrumbs.js"],"sourceRoot":""} \ No newline at end of file diff --git a/dest/javascript/breadcrumbs.min.js b/dest/javascript/breadcrumbs.min.js index 2ba0593..6e2ad5b 100644 --- a/dest/javascript/breadcrumbs.min.js +++ b/dest/javascript/breadcrumbs.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("TrowelBreadcrumbs",[],t):"object"==typeof exports?exports.TrowelBreadcrumbs=t():e.TrowelBreadcrumbs=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r