Boxzilla - Version 3.2.12

Version Description

Download this release

Release Info

Developer DvanKooten
Plugin Icon 128x128 Boxzilla
Version 3.2.12
Comparing to
See all releases

Code changes from version 3.2.11 to 3.2.12

assets/browserify/script.js CHANGED
@@ -66,8 +66,10 @@
66
  // add custom css to box
67
  css(box.element, boxOpts.css);
68
 
69
- box.element.firstChild.firstChild.className += " first-child";
70
- box.element.firstChild.lastChild.className += " last-child";
 
 
71
 
72
  // maybe show box right away
73
  if( box.fits() && locationHashRefersBox(box) ) {
66
  // add custom css to box
67
  css(box.element, boxOpts.css);
68
 
69
+ try {
70
+ box.element.firstChild.firstChild.className += " first-child";
71
+ box.element.firstChild.lastChild.className += " last-child";
72
+ } catch(e) {}
73
 
74
  // maybe show box right away
75
  if( box.fits() && locationHashRefersBox(box) ) {
assets/js/admin-script.js CHANGED
@@ -353,9 +353,9 @@ module.exports = Option;
353
 
354
  },{}],5:[function(require,module,exports){
355
  /*!
356
- * EventEmitter v5.2.5 - git.io/ee
357
  * Unlicense - http://unlicense.org/
358
- * Oliver Caldwell - http://oli.me.uk/
359
  * @preserve
360
  */
361
 
353
 
354
  },{}],5:[function(require,module,exports){
355
  /*!
356
+ * EventEmitter v5.2.6 - git.io/ee
357
  * Unlicense - http://unlicense.org/
358
+ * Oliver Caldwell - https://oli.me.uk/
359
  * @preserve
360
  */
361
 
assets/js/admin-script.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){var s=void 0;!function i(l,s,a){function u(t,e){if(!s[t]){if(!l[t]){var n=!1;if(!e&&n)return n(t,!0);if(c)return c(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var r=s[t]={exports:{}};l[t][0].call(r.exports,function(e){return u(l[t][1][e]||e)},r,r.exports,i,l,s,a)}return s[t].exports}for(var c=!1,e=0;e<a.length;e++)u(a[e]);return u}({1:[function(e,t,n){"use strict";window.Boxzilla_Admin=e("./admin/_admin.js")},{"./admin/_admin.js":2}],2:[function(d,f,e){"use strict";!function(){var l=window.jQuery,e=d("./_option.js"),n=document.getElementById("boxzilla-box-options-controls"),t=l(n),s=document.createTextNode(" logged in");if(0!==t.length){var o=new(d("wolfy87-eventemitter")),r=d("./_designer.js")(l,e,o),i=wp.template("rule-row-template"),a=boxzilla_i18n,u=document.getElementById("boxzilla-rule-comparison"),c=document.getElementById("boxzilla-box-rules");t.on("click",".boxzilla-add-rule",function(){var e={key:n.querySelectorAll(".boxzilla-rule-row").length,andor:"any"===u.value?a.or:a.and},t=i(e);return l(c).append(t),!1}),t.on("click",".boxzilla-remove-rule",function(){var e=l(this).parents("tr");e.prev().remove(),e.remove()}),t.on("change",".boxzilla-rule-condition",p),t.find(".boxzilla-auto-show-trigger").on("change",function(){t.find(".boxzilla-trigger-options").toggle(""!==this.value)}),l(u).change(function(){var e="any"===u.value?a.or:a.and;l(".boxzilla-andor").text(e)}),l(window).load(function(){void 0===window.tinyMCE&&(document.getElementById("notice-notinymce").style.display="")}),l(".boxzilla-rule-row").each(p),f.exports={Designer:r,Option:e,events:o}}function p(){var e="tr"===this.tagName.toLowerCase()?this:l(this).parents("tr").get(0),t=e.querySelector(".boxzilla-rule-condition").value,n=e.querySelector(".boxzilla-rule-value"),o=e.querySelector(".boxzilla-rule-qualifier"),r=n.cloneNode(!0),i=l(r);switch(l(e.querySelectorAll(".boxzilla-helper")).remove(),r.removeAttribute("name"),r.className=r.className+" boxzilla-helper",n.parentNode.insertBefore(r,n.nextSibling),i.change(function(){n.value=this.value}),r.style.display="",n.style.display="none",o.style.display="",o.querySelector('option[value="not_contains"]').style.display="none",o.querySelector('option[value="contains"]').style.display="none",s.parentNode&&s.parentNode.removeChild(s),t){default:r.placeholder=a.enterCommaSeparatedValues;break;case"":case"everywhere":o.value="1",n.value="",r.style.display="none",o.style.display="none";break;case"is_single":case"is_post":r.placeholder=a.enterCommaSeparatedPosts,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post",{multiple:!0,multipleSep:","});break;case"is_page":r.placeholder=a.enterCommaSeparatedPages,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=page",{multiple:!0,multipleSep:","});break;case"is_post_type":r.placeholder=a.enterCommaSeparatedPostTypes,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post_type",{multiple:!0,multipleSep:","});break;case"is_url":o.querySelector('option[value="contains"]').style.display="",o.querySelector('option[value="not_contains"]').style.display="",r.placeholder=a.enterCommaSeparatedRelativeUrls;break;case"is_post_in_category":i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=category",{multiple:!0,multipleSep:","});break;case"is_post_with_tag":i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post_tag",{multiple:!0,multipleSep:","});break;case"is_user_logged_in":r.style.display="none",n.parentNode.insertBefore(s,n.nextSibling);break;case"is_referer":o.querySelector('option[value="contains"]').style.display="",o.querySelector('option[value="not_contains"]').style.display=""}}}()},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(e,t,n){"use strict";function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t.exports=function(e,t,n){var o,r,i,l=document.getElementById("post_ID").value||0,s={},a=!1,u=e("#boxzilla-box-appearance-controls");function c(){return!!a&&(window.setTimeout(function(){i.css({"border-color":s.borderColor.getColorValue(),"border-width":s.borderWidth.getPxValue(),"border-style":s.borderStyle.getValue(),"background-color":s.backgroundColor.getColorValue(),width:s.width.getPxValue(),color:s.color.getColorValue()}),n.trigger("editor.styles.apply")},10),!0)}return s.borderColor=new t("border-color"),s.borderWidth=new t("border-width"),s.borderStyle=new t("border-style"),s.backgroundColor=new t("background-color"),s.width=new t("width"),s.color=new t("color"),u.find("input.boxzilla-color-field").wpColorPicker({change:c,clear:c}),u.find(":input").not(".boxzilla-color-field").change(c),n.on("editor.init",c),{init:function(){"object"===p(window.tinyMCE)&&null!==tinyMCE.get("content")&&(r=e("#content_ifr"),(o=r.contents().find("html")).css({background:"white"}),(i=o.find("#tinymce")).addClass("boxzilla boxzilla-"+l),i.css({margin:0,background:"white",display:"inline-block",width:"auto","min-width":"240px",position:"relative"}),i.get(0).style.cssText+=";padding: 25px !important;",a=!0,n.trigger("editor.init"))},resetStyles:function(){for(var e in s)"theme"!==e.substring(0,5)&&s[e].clear();c(),n.trigger("editor.styles.reset")},options:s}}},{}],4:[function(e,t,n){"use strict";var o=window.jQuery,r=function(e){"string"==typeof e&&(e=document.getElementById("boxzilla-"+e)),e||console.error("Unable to find option element."),this.element=e};r.prototype.getColorValue=function(){return 0<this.element.value.length?o(this.element).hasClass("wp-color-field")?o(this.element).wpColorPicker("color"):this.element.value:""},r.prototype.getPxValue=function(e){return 0<this.element.value.length?parseInt(this.element.value)+"px":e||""},r.prototype.getValue=function(e){return 0<this.element.value.length?this.element.value:e||""},r.prototype.clear=function(){this.element.value=""},r.prototype.setValue=function(e){this.element.value=e},t.exports=r},{}],5:[function(e,l,t){!function(e){"use strict";function t(){}var n=t.prototype,o=e.EventEmitter;function i(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function r(e){return function(){return this[e].apply(this,arguments)}}n.getListeners=function(e){var t,n,o=this._getEvents();if(e instanceof RegExp)for(n in t={},o)o.hasOwnProperty(n)&&e.test(n)&&(t[n]=o[n]);else t=o[e]||(o[e]=[]);return t},n.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},n.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&((t={})[e]=n),t||n},n.addListener=function(e,t){if(!function e(t){return"function"==typeof t||t instanceof RegExp||!(!t||"object"!=typeof t)&&e(t.listener)}(t))throw new TypeError("listener must be a function");var n,o=this.getListenersAsObject(e),r="object"==typeof t;for(n in o)o.hasOwnProperty(n)&&-1===i(o[n],t)&&o[n].push(r?t:{listener:t,once:!1});return this},n.on=r("addListener"),n.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},n.once=r("addOnceListener"),n.defineEvent=function(e){return this.getListeners(e),this},n.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},n.removeListener=function(e,t){var n,o,r=this.getListenersAsObject(e);for(o in r)r.hasOwnProperty(o)&&-1!==(n=i(r[o],t))&&r[o].splice(n,1);return this},n.off=r("removeListener"),n.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},n.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},n.manipulateListeners=function(e,t,n){var o,r,i=e?this.removeListener:this.addListener,l=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(o=n.length;o--;)i.call(this,t,n[o]);else for(o in t)t.hasOwnProperty(o)&&(r=t[o])&&("function"==typeof r?i.call(this,o,r):l.call(this,o,r));return this},n.removeEvent=function(e){var t,n=typeof e,o=this._getEvents();if("string"===n)delete o[e];else if(e instanceof RegExp)for(t in o)o.hasOwnProperty(t)&&e.test(t)&&delete o[t];else delete this._events;return this},n.removeAllListeners=r("removeEvent"),n.emitEvent=function(e,t){var n,o,r,i,l=this.getListenersAsObject(e);for(i in l)if(l.hasOwnProperty(i))for(n=l[i].slice(0),r=0;r<n.length;r++)!0===(o=n[r]).once&&this.removeListener(e,o.listener),o.listener.apply(this,t||[])===this._getOnceReturnValue()&&this.removeListener(e,o.listener);return this},n.trigger=r("emitEvent"),n.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},n.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},n._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},n._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return e.EventEmitter=o,t},"function"==typeof s&&s.amd?s(function(){return t}):"object"==typeof l&&l.exports?l.exports=t:e.EventEmitter=t}("undefined"!=typeof window?window:this||{})},{}]},{},[1])}();
2
  //# sourceMappingURL=admin-script.min.js.map
1
+ !function(){var s=void 0;!function i(l,s,a){function u(t,e){if(!s[t]){if(!l[t]){var n=!1;if(!e&&n)return n(t,!0);if(c)return c(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var r=s[t]={exports:{}};l[t][0].call(r.exports,function(e){return u(l[t][1][e]||e)},r,r.exports,i,l,s,a)}return s[t].exports}for(var c=!1,e=0;e<a.length;e++)u(a[e]);return u}({1:[function(e,t,n){"use strict";window.Boxzilla_Admin=e("./admin/_admin.js")},{"./admin/_admin.js":2}],2:[function(d,f,e){"use strict";!function(){var l=window.jQuery,e=d("./_option.js"),n=document.getElementById("boxzilla-box-options-controls"),t=l(n),s=document.createTextNode(" logged in");if(0!==t.length){var o=new(d("wolfy87-eventemitter")),r=d("./_designer.js")(l,e,o),i=wp.template("rule-row-template"),a=boxzilla_i18n,u=document.getElementById("boxzilla-rule-comparison"),c=document.getElementById("boxzilla-box-rules");t.on("click",".boxzilla-add-rule",function(){var e={key:n.querySelectorAll(".boxzilla-rule-row").length,andor:"any"===u.value?a.or:a.and},t=i(e);return l(c).append(t),!1}),t.on("click",".boxzilla-remove-rule",function(){var e=l(this).parents("tr");e.prev().remove(),e.remove()}),t.on("change",".boxzilla-rule-condition",p),t.find(".boxzilla-auto-show-trigger").on("change",function(){t.find(".boxzilla-trigger-options").toggle(""!==this.value)}),l(u).change(function(){var e="any"===u.value?a.or:a.and;l(".boxzilla-andor").text(e)}),l(window).load(function(){void 0===window.tinyMCE&&(document.getElementById("notice-notinymce").style.display="")}),l(".boxzilla-rule-row").each(p),f.exports={Designer:r,Option:e,events:o}}function p(){var e="tr"===this.tagName.toLowerCase()?this:l(this).parents("tr").get(0),t=e.querySelector(".boxzilla-rule-condition").value,n=e.querySelector(".boxzilla-rule-value"),o=e.querySelector(".boxzilla-rule-qualifier"),r=n.cloneNode(!0),i=l(r);switch(l(e.querySelectorAll(".boxzilla-helper")).remove(),r.removeAttribute("name"),r.className=r.className+" boxzilla-helper",n.parentNode.insertBefore(r,n.nextSibling),i.change(function(){n.value=this.value}),r.style.display="",n.style.display="none",o.style.display="",o.querySelector('option[value="not_contains"]').style.display="none",o.querySelector('option[value="contains"]').style.display="none",s.parentNode&&s.parentNode.removeChild(s),t){default:r.placeholder=a.enterCommaSeparatedValues;break;case"":case"everywhere":o.value="1",n.value="",r.style.display="none",o.style.display="none";break;case"is_single":case"is_post":r.placeholder=a.enterCommaSeparatedPosts,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post",{multiple:!0,multipleSep:","});break;case"is_page":r.placeholder=a.enterCommaSeparatedPages,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=page",{multiple:!0,multipleSep:","});break;case"is_post_type":r.placeholder=a.enterCommaSeparatedPostTypes,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post_type",{multiple:!0,multipleSep:","});break;case"is_url":o.querySelector('option[value="contains"]').style.display="",o.querySelector('option[value="not_contains"]').style.display="",r.placeholder=a.enterCommaSeparatedRelativeUrls;break;case"is_post_in_category":i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=category",{multiple:!0,multipleSep:","});break;case"is_post_with_tag":i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post_tag",{multiple:!0,multipleSep:","});break;case"is_user_logged_in":r.style.display="none",n.parentNode.insertBefore(s,n.nextSibling);break;case"is_referer":o.querySelector('option[value="contains"]').style.display="",o.querySelector('option[value="not_contains"]').style.display=""}}}()},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(e,t,n){"use strict";function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t.exports=function(e,t,n){var o,r,i,l=document.getElementById("post_ID").value||0,s={},a=!1,u=e("#boxzilla-box-appearance-controls");function c(){return!!a&&(window.setTimeout(function(){i.css({"border-color":s.borderColor.getColorValue(),"border-width":s.borderWidth.getPxValue(),"border-style":s.borderStyle.getValue(),"background-color":s.backgroundColor.getColorValue(),width:s.width.getPxValue(),color:s.color.getColorValue()}),n.trigger("editor.styles.apply")},10),!0)}return s.borderColor=new t("border-color"),s.borderWidth=new t("border-width"),s.borderStyle=new t("border-style"),s.backgroundColor=new t("background-color"),s.width=new t("width"),s.color=new t("color"),u.find("input.boxzilla-color-field").wpColorPicker({change:c,clear:c}),u.find(":input").not(".boxzilla-color-field").change(c),n.on("editor.init",c),{init:function(){"object"===p(window.tinyMCE)&&null!==tinyMCE.get("content")&&(r=e("#content_ifr"),(o=r.contents().find("html")).css({background:"white"}),(i=o.find("#tinymce")).addClass("boxzilla boxzilla-"+l),i.css({margin:0,background:"white",display:"inline-block",width:"auto","min-width":"240px",position:"relative"}),i.get(0).style.cssText+=";padding: 25px !important;",a=!0,n.trigger("editor.init"))},resetStyles:function(){for(var e in s)"theme"!==e.substring(0,5)&&s[e].clear();c(),n.trigger("editor.styles.reset")},options:s}}},{}],4:[function(e,t,n){"use strict";function o(e){"string"==typeof e&&(e=document.getElementById("boxzilla-"+e)),e||console.error("Unable to find option element."),this.element=e}var r=window.jQuery;o.prototype.getColorValue=function(){return 0<this.element.value.length?r(this.element).hasClass("wp-color-field")?r(this.element).wpColorPicker("color"):this.element.value:""},o.prototype.getPxValue=function(e){return 0<this.element.value.length?parseInt(this.element.value)+"px":e||""},o.prototype.getValue=function(e){return 0<this.element.value.length?this.element.value:e||""},o.prototype.clear=function(){this.element.value=""},o.prototype.setValue=function(e){this.element.value=e},t.exports=o},{}],5:[function(e,l,t){!function(e){"use strict";function t(){}var n=t.prototype,o=e.EventEmitter;function i(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function r(e){return function(){return this[e].apply(this,arguments)}}n.getListeners=function(e){var t,n,o=this._getEvents();if(e instanceof RegExp)for(n in t={},o)o.hasOwnProperty(n)&&e.test(n)&&(t[n]=o[n]);else t=o[e]||(o[e]=[]);return t},n.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},n.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&((t={})[e]=n),t||n},n.addListener=function(e,t){if(!function e(t){return"function"==typeof t||t instanceof RegExp||!(!t||"object"!=typeof t)&&e(t.listener)}(t))throw new TypeError("listener must be a function");var n,o=this.getListenersAsObject(e),r="object"==typeof t;for(n in o)o.hasOwnProperty(n)&&-1===i(o[n],t)&&o[n].push(r?t:{listener:t,once:!1});return this},n.on=r("addListener"),n.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},n.once=r("addOnceListener"),n.defineEvent=function(e){return this.getListeners(e),this},n.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},n.removeListener=function(e,t){var n,o,r=this.getListenersAsObject(e);for(o in r)r.hasOwnProperty(o)&&-1!==(n=i(r[o],t))&&r[o].splice(n,1);return this},n.off=r("removeListener"),n.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},n.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},n.manipulateListeners=function(e,t,n){var o,r,i=e?this.removeListener:this.addListener,l=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(o=n.length;o--;)i.call(this,t,n[o]);else for(o in t)t.hasOwnProperty(o)&&(r=t[o])&&("function"==typeof r?i.call(this,o,r):l.call(this,o,r));return this},n.removeEvent=function(e){var t,n=typeof e,o=this._getEvents();if("string"==n)delete o[e];else if(e instanceof RegExp)for(t in o)o.hasOwnProperty(t)&&e.test(t)&&delete o[t];else delete this._events;return this},n.removeAllListeners=r("removeEvent"),n.emitEvent=function(e,t){var n,o,r,i,l=this.getListenersAsObject(e);for(i in l)if(l.hasOwnProperty(i))for(n=l[i].slice(0),r=0;r<n.length;r++)!0===(o=n[r]).once&&this.removeListener(e,o.listener),o.listener.apply(this,t||[])===this._getOnceReturnValue()&&this.removeListener(e,o.listener);return this},n.trigger=r("emitEvent"),n.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},n.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},n._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},n._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return e.EventEmitter=o,t},"function"==typeof s&&s.amd?s(function(){return t}):"object"==typeof l&&l.exports?l.exports=t:e.EventEmitter=t}("undefined"!=typeof window?window:this||{})},{}]},{},[1])}();
2
  //# sourceMappingURL=admin-script.min.js.map
assets/js/admin-script.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["admin-script.js"],"names":["define","undefined","r","e","n","t","o","i","f","c","u","a","Error","code","p","exports","call","length","1","require","module","window","Boxzilla_Admin","./admin/_admin.js","2","$","jQuery","Option","optionControls","document","getElementById","$optionControls","tnLoggedIn","createTextNode","events","Designer","rowTemplate","wp","template","i18n","boxzilla_i18n","ruleComparisonEl","rulesContainerEl","on","data","key","querySelectorAll","andor","value","or","and","html","append","row","this","parents","prev","remove","setContextualHelpers","find","toggle","change","newText","text","load","tinyMCE","style","display","each","context","tagName","toLowerCase","get","condition","querySelector","valueInput","qualifierInput","betterInput","cloneNode","$betterInput","removeAttribute","className","parentNode","insertBefore","nextSibling","removeChild","placeholder","enterCommaSeparatedValues","enterCommaSeparatedPosts","suggest","ajaxurl","multiple","multipleSep","enterCommaSeparatedPages","enterCommaSeparatedPostTypes","enterCommaSeparatedRelativeUrls","./_designer.js","./_option.js","wolfy87-eventemitter","3","_typeof","obj","Symbol","iterator","constructor","prototype","$editor","$editorFrame","$innerEditor","boxId","options","visualEditorInitialised","$appearanceControls","applyStyles","setTimeout","css","border-color","borderColor","getColorValue","border-width","borderWidth","getPxValue","border-style","borderStyle","getValue","background-color","backgroundColor","width","color","trigger","wpColorPicker","clear","not","init","contents","background","addClass","margin","min-width","position","cssText","resetStyles","substring","4","element","console","error","hasClass","fallbackValue","parseInt","setValue","5","EventEmitter","proto","originalGlobalValue","indexOfListener","listeners","listener","alias","name","apply","arguments","getListeners","evt","response","_getEvents","RegExp","hasOwnProperty","test","flattenListeners","flatListeners","push","getListenersAsObject","Array","addListener","isValidListener","TypeError","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","index","splice","off","addListeners","manipulateListeners","removeListeners","single","removeEvent","type","_events","removeAllListeners","emitEvent","args","listenersMap","slice","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict","amd"],"mappings":"CAAA,WAAe,IAA8EA,OAASC,GAAuB,SAASC,EAAEC,EAAEC,EAAEC,GAAG,SAASC,EAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,IAAIE,GAAE,EAAoC,IAAID,GAAGC,EAAE,OAAOA,EAAEF,GAAE,GAAI,GAAGG,EAAE,OAAOA,EAAEH,GAAE,GAAI,IAAII,EAAE,IAAIC,MAAM,uBAAuBL,EAAE,KAAK,MAAMI,EAAEE,KAAK,mBAAmBF,EAAE,IAAIG,EAAEV,EAAEG,GAAG,CAACQ,QAAQ,IAAIZ,EAAEI,GAAG,GAAGS,KAAKF,EAAEC,QAAQ,SAASb,GAAoB,OAAOI,EAAlBH,EAAEI,GAAG,GAAGL,IAAeA,IAAIY,EAAEA,EAAEC,QAAQb,EAAEC,EAAEC,EAAEC,GAAG,OAAOD,EAAEG,GAAGQ,QAAQ,IAAI,IAAIL,GAAE,EAAoCH,EAAE,EAAEA,EAAEF,EAAEY,OAAOV,IAAID,EAAED,EAAEE,IAAI,OAAOD,EAA7b,CAA4c,CAACY,EAAE,CAAC,SAASC,EAAQC,EAAOL,GACzlB,aAEAM,OAAOC,eAAiBH,EAAQ,sBAE9B,CAACI,oBAAoB,IAAIC,EAAE,CAAC,SAASL,EAAQC,EAAOL,GACtD,cAEA,WAGE,IAAIU,EAAIJ,OAAOK,OAEXC,EAASR,EAAQ,gBAEjBS,EAAiBC,SAASC,eAAe,iCACzCC,EAAkBN,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EAAaxJ,GAAKyJ,MAAM,GAE/B/L,EAAI,EAAGA,EAAIqJ,EAAU3I,OAAQV,KAKR,KAFtBsJ,EAAWD,EAAUrJ,IAER2K,MACT5H,KAAKiI,eAAepB,EAAKN,EAASA,UAG3BA,EAASA,SAASG,MAAM1G,KAAM8I,GAAQ,MAEhC9I,KAAKiJ,uBAClBjJ,KAAKiI,eAAepB,EAAKN,EAASA,UAMlD,OAAOvG,MAMXmG,EAAMxB,QAAU6B,EAAM,aAUtBL,EAAM+C,KAAO,SAAcrC,GACvB,IAAIiC,EAAOvB,MAAMpE,UAAU6F,MAAMtL,KAAKiJ,UAAW,GACjD,OAAO3G,KAAK6I,UAAUhC,EAAKiC,IAW/B3C,EAAMgD,mBAAqB,SAA4BzJ,GAEnD,OADAM,KAAKoJ,iBAAmB1J,EACjBM,MAWXmG,EAAM8C,oBAAsB,WACxB,OAAIjJ,KAAKiH,eAAe,qBACbjH,KAAKoJ,kBAapBjD,EAAMY,WAAa,WACf,OAAO/G,KAAK2I,UAAY3I,KAAK2I,QAAU,KAQ3CzC,EAAamD,WAAa,WAEtB,OADA5L,EAAQyI,aAAeE,EAChBF,GAIW,mBAAXxJ,GAAyBA,EAAO4M,IACvC5M,EAAO,WACH,OAAOwJ,IAGY,iBAAXpI,GAAuBA,EAAOL,QAC1CK,EAAOL,QAAUyI,EAGjBzI,EAAQyI,aAAeA,EA5d9B,CA8dmB,oBAAXnI,OAAyBA,OAASiC,MAAQ,KAEjD,KAAK,GAAG,CAAC,IAz0BX","file":"admin-script.min.js","sourcesContent":["(function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){\n\"use strict\";\n\nwindow.Boxzilla_Admin = require('./admin/_admin.js');\n\n},{\"./admin/_admin.js\":2}],2:[function(require,module,exports){\n\"use strict\";\n\n(function () {\n 'use strict';\n\n var $ = window.jQuery;\n\n var Option = require('./_option.js');\n\n var optionControls = document.getElementById('boxzilla-box-options-controls');\n var $optionControls = $(optionControls);\n var tnLoggedIn = document.createTextNode(' logged in'); // sanity check, are we on the correct page?\n\n if ($optionControls.length === 0) {\n return;\n }\n\n var EventEmitter = require('wolfy87-eventemitter');\n\n var events = new EventEmitter();\n\n var Designer = require('./_designer.js')($, Option, events);\n\n var rowTemplate = wp.template('rule-row-template');\n var i18n = boxzilla_i18n;\n var ruleComparisonEl = document.getElementById('boxzilla-rule-comparison');\n var rulesContainerEl = document.getElementById('boxzilla-box-rules'); // events\n\n $optionControls.on('click', \".boxzilla-add-rule\", addRuleFields);\n $optionControls.on('click', \".boxzilla-remove-rule\", removeRule);\n $optionControls.on('change', \".boxzilla-rule-condition\", setContextualHelpers);\n $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);\n $(ruleComparisonEl).change(toggleAndOrTexts);\n $(window).load(function () {\n if (typeof window.tinyMCE === \"undefined\") {\n document.getElementById('notice-notinymce').style.display = '';\n }\n }); // call contextual helper method for each row\n\n $('.boxzilla-rule-row').each(setContextualHelpers);\n\n function toggleAndOrTexts() {\n var newText = ruleComparisonEl.value === 'any' ? i18n.or : i18n.and;\n $('.boxzilla-andor').text(newText);\n }\n\n function toggleTriggerOptions() {\n $optionControls.find('.boxzilla-trigger-options').toggle(this.value !== '');\n }\n\n function removeRule() {\n var row = $(this).parents('tr'); // delete andor row\n\n row.prev().remove(); // delete rule row\n\n row.remove();\n }\n\n function setContextualHelpers() {\n var context = this.tagName.toLowerCase() === \"tr\" ? this : $(this).parents('tr').get(0);\n var condition = context.querySelector('.boxzilla-rule-condition').value;\n var valueInput = context.querySelector('.boxzilla-rule-value');\n var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');\n var betterInput = valueInput.cloneNode(true);\n var $betterInput = $(betterInput); // remove previously added helpers\n\n $(context.querySelectorAll('.boxzilla-helper')).remove(); // prepare better input\n\n betterInput.removeAttribute('name');\n betterInput.className = betterInput.className + ' boxzilla-helper';\n valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);\n $betterInput.change(function () {\n valueInput.value = this.value;\n });\n betterInput.style.display = '';\n valueInput.style.display = 'none';\n qualifierInput.style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = 'none';\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = 'none';\n\n if (tnLoggedIn.parentNode) {\n tnLoggedIn.parentNode.removeChild(tnLoggedIn);\n } // change placeholder for textual help\n\n\n switch (condition) {\n default:\n betterInput.placeholder = i18n.enterCommaSeparatedValues;\n break;\n\n case '':\n case 'everywhere':\n qualifierInput.value = '1';\n valueInput.value = '';\n betterInput.style.display = 'none';\n qualifierInput.style.display = 'none';\n break;\n\n case 'is_single':\n case 'is_post':\n betterInput.placeholder = i18n.enterCommaSeparatedPosts;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_page':\n betterInput.placeholder = i18n.enterCommaSeparatedPages;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=page\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_post_type':\n betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post_type\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_url':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;\n break;\n\n case 'is_post_in_category':\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=category\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_post_with_tag':\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post_tag\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_user_logged_in':\n betterInput.style.display = 'none';\n valueInput.parentNode.insertBefore(tnLoggedIn, valueInput.nextSibling);\n break;\n\n case 'is_referer':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n break;\n }\n }\n\n function addRuleFields() {\n var data = {\n 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length,\n 'andor': ruleComparisonEl.value === 'any' ? i18n.or : i18n.and\n };\n var html = rowTemplate(data);\n $(rulesContainerEl).append(html);\n return false;\n }\n\n module.exports = {\n 'Designer': Designer,\n 'Option': Option,\n 'events': events\n };\n})();\n\n},{\"./_designer.js\":3,\"./_option.js\":4,\"wolfy87-eventemitter\":5}],3:[function(require,module,exports){\n\"use strict\";\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Designer = function Designer($, Option, events) {\n // vars\n var boxId = document.getElementById('post_ID').value || 0,\n $editor,\n $editorFrame,\n $innerEditor,\n options = {},\n visualEditorInitialised = false;\n var $appearanceControls = $(\"#boxzilla-box-appearance-controls\"); // create Option objects\n\n options.borderColor = new Option('border-color');\n options.borderWidth = new Option('border-width');\n options.borderStyle = new Option('border-style');\n options.backgroundColor = new Option('background-color');\n options.width = new Option('width');\n options.color = new Option('color'); // functions\n\n function init() {\n // Only run if TinyMCE has actually inited\n if (_typeof(window.tinyMCE) !== \"object\" || tinyMCE.get('content') === null) {\n return;\n } // add classes to TinyMCE <html>\n\n\n $editorFrame = $(\"#content_ifr\");\n $editor = $editorFrame.contents().find('html');\n $editor.css({\n 'background': 'white'\n }); // add content class and padding to TinyMCE <body>\n\n $innerEditor = $editor.find('#tinymce');\n $innerEditor.addClass('boxzilla boxzilla-' + boxId);\n $innerEditor.css({\n 'margin': 0,\n 'background': 'white',\n 'display': 'inline-block',\n 'width': 'auto',\n 'min-width': '240px',\n 'position': 'relative'\n });\n $innerEditor.get(0).style.cssText += ';padding: 25px !important;';\n visualEditorInitialised = true;\n /* @since 2.0.3 */\n\n events.trigger('editor.init');\n }\n /**\n * Applies the styles from the options to the TinyMCE Editor\n *\n * @return bool\n */\n\n\n function applyStyles() {\n if (!visualEditorInitialised) {\n return false;\n } // Apply styles from CSS editor. \n // Use short timeout to make sure color values are updated.\n\n\n window.setTimeout(function () {\n $innerEditor.css({\n 'border-color': options.borderColor.getColorValue(),\n //getColorValue( 'borderColor', '' ),\n 'border-width': options.borderWidth.getPxValue(),\n //getPxValue( 'borderWidth', '' ),\n 'border-style': options.borderStyle.getValue(),\n //getValue('borderStyle', '' ),\n 'background-color': options.backgroundColor.getColorValue(),\n //getColorValue( 'backgroundColor', ''),\n 'width': options.width.getPxValue(),\n //getPxValue( 'width', 'auto' ),\n 'color': options.color.getColorValue() // getColorValue( 'color', '' )\n\n });\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.apply');\n }, 10);\n return true;\n }\n\n function resetStyles() {\n for (var key in options) {\n if (key.substring(0, 5) === 'theme') {\n continue;\n }\n\n options[key].clear();\n }\n\n applyStyles();\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.reset');\n } // event binders\n\n\n $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({\n change: applyStyles,\n clear: applyStyles\n });\n $appearanceControls.find(\":input\").not(\".boxzilla-color-field\").change(applyStyles);\n events.on('editor.init', applyStyles); // public methods\n\n return {\n 'init': init,\n 'resetStyles': resetStyles,\n 'options': options\n };\n};\n\nmodule.exports = Designer;\n\n},{}],4:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery;\n\nvar Option = function Option(element) {\n // find corresponding element\n if (typeof element == \"string\") {\n element = document.getElementById('boxzilla-' + element);\n }\n\n if (!element) {\n console.error(\"Unable to find option element.\");\n }\n\n this.element = element;\n};\n\nOption.prototype.getColorValue = function () {\n if (this.element.value.length > 0) {\n if ($(this.element).hasClass('wp-color-field')) {\n return $(this.element).wpColorPicker('color');\n } else {\n return this.element.value;\n }\n }\n\n return '';\n};\n\nOption.prototype.getPxValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return parseInt(this.element.value) + \"px\";\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.getValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return this.element.value;\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.clear = function () {\n this.element.value = '';\n};\n\nOption.prototype.setValue = function (value) {\n this.element.value = value;\n};\n\nmodule.exports = Option;\n\n},{}],5:[function(require,module,exports){\n/*!\n * EventEmitter v5.2.5 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - http://oli.me.uk/\n * @preserve\n */\n\n;(function (exports) {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n function isValidListener (listener) {\n if (typeof listener === 'function' || listener instanceof RegExp) {\n return true\n } else if (listener && typeof listener === 'object') {\n return isValidListener(listener.listener)\n } else {\n return false\n }\n }\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n if (!isValidListener(listener)) {\n throw new TypeError('listener must be a function');\n }\n\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n\n for (i = 0; i < listeners.length; i++) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}(typeof window !== 'undefined' ? window : this || {}));\n\n},{}]},{},[1]);\n; })();"]}
1
+ {"version":3,"sources":["admin-script.js"],"names":["define","undefined","r","e","n","t","o","i","f","c","u","a","Error","code","p","exports","call","length","1","require","module","window","Boxzilla_Admin","./admin/_admin.js","2","$","jQuery","Option","optionControls","document","getElementById","$optionControls","tnLoggedIn","createTextNode","events","Designer","rowTemplate","wp","template","i18n","boxzilla_i18n","ruleComparisonEl","rulesContainerEl","on","data","key","querySelectorAll","andor","value","or","and","html","append","row","this","parents","prev","remove","setContextualHelpers","find","toggle","change","newText","text","load","tinyMCE","style","display","each","context","tagName","toLowerCase","get","condition","querySelector","valueInput","qualifierInput","betterInput","cloneNode","$betterInput","removeAttribute","className","parentNode","insertBefore","nextSibling","removeChild","placeholder","enterCommaSeparatedValues","enterCommaSeparatedPosts","suggest","ajaxurl","multiple","multipleSep","enterCommaSeparatedPages","enterCommaSeparatedPostTypes","enterCommaSeparatedRelativeUrls","./_designer.js","./_option.js","wolfy87-eventemitter","3","_typeof","obj","Symbol","iterator","constructor","prototype","$editor","$editorFrame","$innerEditor","boxId","options","visualEditorInitialised","$appearanceControls","applyStyles","setTimeout","css","border-color","borderColor","getColorValue","border-width","borderWidth","getPxValue","border-style","borderStyle","getValue","background-color","backgroundColor","width","color","trigger","wpColorPicker","clear","not","init","contents","background","addClass","margin","min-width","position","cssText","resetStyles","substring","4","element","console","error","hasClass","fallbackValue","parseInt","setValue","5","EventEmitter","proto","originalGlobalValue","indexOfListener","listeners","listener","alias","name","apply","arguments","getListeners","evt","response","_getEvents","RegExp","hasOwnProperty","test","flattenListeners","flatListeners","push","getListenersAsObject","Array","addListener","isValidListener","TypeError","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","index","splice","off","addListeners","manipulateListeners","removeListeners","single","removeEvent","type","_events","removeAllListeners","emitEvent","args","listenersMap","slice","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict","amd"],"mappings":"CAAA,WAAe,IAA8EA,OAASC,GAAuB,SAASC,EAAEC,EAAEC,EAAEC,GAAG,SAASC,EAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,IAAIE,GAAE,EAAoC,IAAID,GAAGC,EAAE,OAAOA,EAAEF,GAAE,GAAI,GAAGG,EAAE,OAAOA,EAAEH,GAAE,GAAI,IAAII,EAAE,IAAIC,MAAM,uBAAuBL,EAAE,KAAK,MAAMI,EAAEE,KAAK,mBAAmBF,EAAE,IAAIG,EAAEV,EAAEG,GAAG,CAACQ,QAAQ,IAAIZ,EAAEI,GAAG,GAAGS,KAAKF,EAAEC,QAAQ,SAASb,GAAoB,OAAOI,EAAlBH,EAAEI,GAAG,GAAGL,IAAeA,IAAIY,EAAEA,EAAEC,QAAQb,EAAEC,EAAEC,EAAEC,GAAG,OAAOD,EAAEG,GAAGQ,QAAQ,IAAI,IAAIL,GAAE,EAAoCH,EAAE,EAAEA,EAAEF,EAAEY,OAAOV,IAAID,EAAED,EAAEE,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esContent":["(function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){\n\"use strict\";\n\nwindow.Boxzilla_Admin = require('./admin/_admin.js');\n\n},{\"./admin/_admin.js\":2}],2:[function(require,module,exports){\n\"use strict\";\n\n(function () {\n 'use strict';\n\n var $ = window.jQuery;\n\n var Option = require('./_option.js');\n\n var optionControls = document.getElementById('boxzilla-box-options-controls');\n var $optionControls = $(optionControls);\n var tnLoggedIn = document.createTextNode(' logged in'); // sanity check, are we on the correct page?\n\n if ($optionControls.length === 0) {\n return;\n }\n\n var EventEmitter = require('wolfy87-eventemitter');\n\n var events = new EventEmitter();\n\n var Designer = require('./_designer.js')($, Option, events);\n\n var rowTemplate = wp.template('rule-row-template');\n var i18n = boxzilla_i18n;\n var ruleComparisonEl = document.getElementById('boxzilla-rule-comparison');\n var rulesContainerEl = document.getElementById('boxzilla-box-rules'); // events\n\n $optionControls.on('click', \".boxzilla-add-rule\", addRuleFields);\n $optionControls.on('click', \".boxzilla-remove-rule\", removeRule);\n $optionControls.on('change', \".boxzilla-rule-condition\", setContextualHelpers);\n $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);\n $(ruleComparisonEl).change(toggleAndOrTexts);\n $(window).load(function () {\n if (typeof window.tinyMCE === \"undefined\") {\n document.getElementById('notice-notinymce').style.display = '';\n }\n }); // call contextual helper method for each row\n\n $('.boxzilla-rule-row').each(setContextualHelpers);\n\n function toggleAndOrTexts() {\n var newText = ruleComparisonEl.value === 'any' ? i18n.or : i18n.and;\n $('.boxzilla-andor').text(newText);\n }\n\n function toggleTriggerOptions() {\n $optionControls.find('.boxzilla-trigger-options').toggle(this.value !== '');\n }\n\n function removeRule() {\n var row = $(this).parents('tr'); // delete andor row\n\n row.prev().remove(); // delete rule row\n\n row.remove();\n }\n\n function setContextualHelpers() {\n var context = this.tagName.toLowerCase() === \"tr\" ? this : $(this).parents('tr').get(0);\n var condition = context.querySelector('.boxzilla-rule-condition').value;\n var valueInput = context.querySelector('.boxzilla-rule-value');\n var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');\n var betterInput = valueInput.cloneNode(true);\n var $betterInput = $(betterInput); // remove previously added helpers\n\n $(context.querySelectorAll('.boxzilla-helper')).remove(); // prepare better input\n\n betterInput.removeAttribute('name');\n betterInput.className = betterInput.className + ' boxzilla-helper';\n valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);\n $betterInput.change(function () {\n valueInput.value = this.value;\n });\n betterInput.style.display = '';\n valueInput.style.display = 'none';\n qualifierInput.style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = 'none';\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = 'none';\n\n if (tnLoggedIn.parentNode) {\n tnLoggedIn.parentNode.removeChild(tnLoggedIn);\n } // change placeholder for textual help\n\n\n switch (condition) {\n default:\n betterInput.placeholder = i18n.enterCommaSeparatedValues;\n break;\n\n case '':\n case 'everywhere':\n qualifierInput.value = '1';\n valueInput.value = '';\n betterInput.style.display = 'none';\n qualifierInput.style.display = 'none';\n break;\n\n case 'is_single':\n case 'is_post':\n betterInput.placeholder = i18n.enterCommaSeparatedPosts;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_page':\n betterInput.placeholder = i18n.enterCommaSeparatedPages;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=page\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_post_type':\n betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post_type\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_url':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;\n break;\n\n case 'is_post_in_category':\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=category\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_post_with_tag':\n $betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post_tag\", {\n multiple: true,\n multipleSep: \",\"\n });\n break;\n\n case 'is_user_logged_in':\n betterInput.style.display = 'none';\n valueInput.parentNode.insertBefore(tnLoggedIn, valueInput.nextSibling);\n break;\n\n case 'is_referer':\n qualifierInput.querySelector('option[value=\"contains\"]').style.display = '';\n qualifierInput.querySelector('option[value=\"not_contains\"]').style.display = '';\n break;\n }\n }\n\n function addRuleFields() {\n var data = {\n 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length,\n 'andor': ruleComparisonEl.value === 'any' ? i18n.or : i18n.and\n };\n var html = rowTemplate(data);\n $(rulesContainerEl).append(html);\n return false;\n }\n\n module.exports = {\n 'Designer': Designer,\n 'Option': Option,\n 'events': events\n };\n})();\n\n},{\"./_designer.js\":3,\"./_option.js\":4,\"wolfy87-eventemitter\":5}],3:[function(require,module,exports){\n\"use strict\";\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Designer = function Designer($, Option, events) {\n // vars\n var boxId = document.getElementById('post_ID').value || 0,\n $editor,\n $editorFrame,\n $innerEditor,\n options = {},\n visualEditorInitialised = false;\n var $appearanceControls = $(\"#boxzilla-box-appearance-controls\"); // create Option objects\n\n options.borderColor = new Option('border-color');\n options.borderWidth = new Option('border-width');\n options.borderStyle = new Option('border-style');\n options.backgroundColor = new Option('background-color');\n options.width = new Option('width');\n options.color = new Option('color'); // functions\n\n function init() {\n // Only run if TinyMCE has actually inited\n if (_typeof(window.tinyMCE) !== \"object\" || tinyMCE.get('content') === null) {\n return;\n } // add classes to TinyMCE <html>\n\n\n $editorFrame = $(\"#content_ifr\");\n $editor = $editorFrame.contents().find('html');\n $editor.css({\n 'background': 'white'\n }); // add content class and padding to TinyMCE <body>\n\n $innerEditor = $editor.find('#tinymce');\n $innerEditor.addClass('boxzilla boxzilla-' + boxId);\n $innerEditor.css({\n 'margin': 0,\n 'background': 'white',\n 'display': 'inline-block',\n 'width': 'auto',\n 'min-width': '240px',\n 'position': 'relative'\n });\n $innerEditor.get(0).style.cssText += ';padding: 25px !important;';\n visualEditorInitialised = true;\n /* @since 2.0.3 */\n\n events.trigger('editor.init');\n }\n /**\n * Applies the styles from the options to the TinyMCE Editor\n *\n * @return bool\n */\n\n\n function applyStyles() {\n if (!visualEditorInitialised) {\n return false;\n } // Apply styles from CSS editor. \n // Use short timeout to make sure color values are updated.\n\n\n window.setTimeout(function () {\n $innerEditor.css({\n 'border-color': options.borderColor.getColorValue(),\n //getColorValue( 'borderColor', '' ),\n 'border-width': options.borderWidth.getPxValue(),\n //getPxValue( 'borderWidth', '' ),\n 'border-style': options.borderStyle.getValue(),\n //getValue('borderStyle', '' ),\n 'background-color': options.backgroundColor.getColorValue(),\n //getColorValue( 'backgroundColor', ''),\n 'width': options.width.getPxValue(),\n //getPxValue( 'width', 'auto' ),\n 'color': options.color.getColorValue() // getColorValue( 'color', '' )\n\n });\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.apply');\n }, 10);\n return true;\n }\n\n function resetStyles() {\n for (var key in options) {\n if (key.substring(0, 5) === 'theme') {\n continue;\n }\n\n options[key].clear();\n }\n\n applyStyles();\n /* @since 2.0.3 */\n\n events.trigger('editor.styles.reset');\n } // event binders\n\n\n $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({\n change: applyStyles,\n clear: applyStyles\n });\n $appearanceControls.find(\":input\").not(\".boxzilla-color-field\").change(applyStyles);\n events.on('editor.init', applyStyles); // public methods\n\n return {\n 'init': init,\n 'resetStyles': resetStyles,\n 'options': options\n };\n};\n\nmodule.exports = Designer;\n\n},{}],4:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery;\n\nvar Option = function Option(element) {\n // find corresponding element\n if (typeof element == \"string\") {\n element = document.getElementById('boxzilla-' + element);\n }\n\n if (!element) {\n console.error(\"Unable to find option element.\");\n }\n\n this.element = element;\n};\n\nOption.prototype.getColorValue = function () {\n if (this.element.value.length > 0) {\n if ($(this.element).hasClass('wp-color-field')) {\n return $(this.element).wpColorPicker('color');\n } else {\n return this.element.value;\n }\n }\n\n return '';\n};\n\nOption.prototype.getPxValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return parseInt(this.element.value) + \"px\";\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.getValue = function (fallbackValue) {\n if (this.element.value.length > 0) {\n return this.element.value;\n }\n\n return fallbackValue || '';\n};\n\nOption.prototype.clear = function () {\n this.element.value = '';\n};\n\nOption.prototype.setValue = function (value) {\n this.element.value = value;\n};\n\nmodule.exports = Option;\n\n},{}],5:[function(require,module,exports){\n/*!\n * EventEmitter v5.2.6 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - https://oli.me.uk/\n * @preserve\n */\n\n;(function (exports) {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n function isValidListener (listener) {\n if (typeof listener === 'function' || listener instanceof RegExp) {\n return true\n } else if (listener && typeof listener === 'object') {\n return isValidListener(listener.listener)\n } else {\n return false\n }\n }\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n if (!isValidListener(listener)) {\n throw new TypeError('listener must be a function');\n }\n\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n\n for (i = 0; i < listeners.length; i++) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}(typeof window !== 'undefined' ? window : this || {}));\n\n},{}]},{},[1]);\n; })();"]}
assets/js/script.js CHANGED
@@ -1,492 +1,148 @@
1
  (function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
- /*!
3
- * EventEmitter v5.2.5 - git.io/ee
4
- * Unlicense - http://unlicense.org/
5
- * Oliver Caldwell - http://oli.me.uk/
6
- * @preserve
7
- */
8
 
9
- ;(function (exports) {
10
- 'use strict';
11
 
12
- /**
13
- * Class for managing events.
14
- * Can be extended to provide event functionality in other classes.
15
- *
16
- * @class EventEmitter Manages event registering and emitting.
17
- */
18
- function EventEmitter() {}
19
 
20
- // Shortcuts to improve speed and size
21
- var proto = EventEmitter.prototype;
22
- var originalGlobalValue = exports.EventEmitter;
23
 
24
- /**
25
- * Finds the index of the listener for the event in its storage array.
26
- *
27
- * @param {Function[]} listeners Array of listeners to search through.
28
- * @param {Function} listener Method to look for.
29
- * @return {Number} Index of the specified listener, -1 if not found
30
- * @api private
31
- */
32
- function indexOfListener(listeners, listener) {
33
- var i = listeners.length;
34
- while (i--) {
35
- if (listeners[i].listener === listener) {
36
- return i;
37
- }
38
- }
39
 
40
- return -1;
 
 
 
 
41
  }
42
 
43
- /**
44
- * Alias a method while keeping the context correct, to allow for overwriting of target method.
45
- *
46
- * @param {String} name The name of the target method.
47
- * @return {Function} The aliased method
48
- * @api private
49
- */
50
- function alias(name) {
51
- return function aliasClosure() {
52
- return this[name].apply(this, arguments);
53
- };
54
  }
55
 
56
- /**
57
- * Returns the listener array for the specified event.
58
- * Will initialise the event object and listener arrays if required.
59
- * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
60
- * Each property in the object response is an array of listener functions.
61
- *
62
- * @param {String|RegExp} evt Name of the event to return the listeners from.
63
- * @return {Function[]|Object} All listener functions for the event.
64
- */
65
- proto.getListeners = function getListeners(evt) {
66
- var events = this._getEvents();
67
- var response;
68
- var key;
69
 
70
- // Return a concatenated array of all matching events if
71
- // the selector is a regular expression.
72
- if (evt instanceof RegExp) {
73
- response = {};
74
- for (key in events) {
75
- if (events.hasOwnProperty(key) && evt.test(key)) {
76
- response[key] = events[key];
77
- }
78
- }
79
- }
80
- else {
81
- response = events[evt] || (events[evt] = []);
82
- }
83
 
84
- return response;
85
- };
 
86
 
87
- /**
88
- * Takes a list of listener objects and flattens it into a list of listener functions.
89
- *
90
- * @param {Object[]} listeners Raw listener objects.
91
- * @return {Function[]} Just the listener functions.
92
- */
93
- proto.flattenListeners = function flattenListeners(listeners) {
94
- var flatListeners = [];
95
- var i;
96
 
97
- for (i = 0; i < listeners.length; i += 1) {
98
- flatListeners.push(listeners[i].listener);
99
- }
 
 
100
 
101
- return flatListeners;
102
- };
103
 
104
- /**
105
- * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
106
- *
107
- * @param {String|RegExp} evt Name of the event to return the listeners from.
108
- * @return {Object} All listener functions for an event in an object.
109
- */
110
- proto.getListenersAsObject = function getListenersAsObject(evt) {
111
- var listeners = this.getListeners(evt);
112
- var response;
113
 
114
- if (listeners instanceof Array) {
115
- response = {};
116
- response[evt] = listeners;
117
- }
118
 
119
- return response || listeners;
120
- };
 
121
 
122
- function isValidListener (listener) {
123
- if (typeof listener === 'function' || listener instanceof RegExp) {
124
- return true
125
- } else if (listener && typeof listener === 'object') {
126
- return isValidListener(listener.listener)
127
- } else {
128
- return false
129
- }
130
- }
131
 
132
- /**
133
- * Adds a listener function to the specified event.
134
- * The listener will not be added if it is a duplicate.
135
- * If the listener returns true then it will be removed after it is called.
136
- * If you pass a regular expression as the event name then the listener will be added to all events that match it.
137
- *
138
- * @param {String|RegExp} evt Name of the event to attach the listener to.
139
- * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
140
- * @return {Object} Current instance of EventEmitter for chaining.
141
- */
142
- proto.addListener = function addListener(evt, listener) {
143
- if (!isValidListener(listener)) {
144
- throw new TypeError('listener must be a function');
145
- }
146
 
147
- var listeners = this.getListenersAsObject(evt);
148
- var listenerIsWrapped = typeof listener === 'object';
149
- var key;
150
 
151
- for (key in listeners) {
152
- if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
153
- listeners[key].push(listenerIsWrapped ? listener : {
154
- listener: listener,
155
- once: false
156
- });
157
- }
158
- }
159
 
160
- return this;
161
- };
162
 
163
- /**
164
- * Alias of addListener
165
- */
166
- proto.on = alias('addListener');
167
 
168
- /**
169
- * Semi-alias of addListener. It will add a listener that will be
170
- * automatically removed after its first execution.
171
- *
172
- * @param {String|RegExp} evt Name of the event to attach the listener to.
173
- * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
174
- * @return {Object} Current instance of EventEmitter for chaining.
175
- */
176
- proto.addOnceListener = function addOnceListener(evt, listener) {
177
- return this.addListener(evt, {
178
- listener: listener,
179
- once: true
180
- });
181
- };
182
 
183
- /**
184
- * Alias of addOnceListener.
185
- */
186
- proto.once = alias('addOnceListener');
187
 
188
- /**
189
- * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
190
- * You need to tell it what event names should be matched by a regex.
191
- *
192
- * @param {String} evt Name of the event to create.
193
- * @return {Object} Current instance of EventEmitter for chaining.
194
- */
195
- proto.defineEvent = function defineEvent(evt) {
196
- this.getListeners(evt);
197
- return this;
198
- };
199
 
200
- /**
201
- * Uses defineEvent to define multiple events.
202
- *
203
- * @param {String[]} evts An array of event names to define.
204
- * @return {Object} Current instance of EventEmitter for chaining.
205
- */
206
- proto.defineEvents = function defineEvents(evts) {
207
- for (var i = 0; i < evts.length; i += 1) {
208
- this.defineEvent(evts[i]);
209
- }
210
- return this;
211
- };
212
 
213
- /**
214
- * Removes a listener function from the specified event.
215
- * When passed a regular expression as the event name, it will remove the listener from all events that match it.
216
- *
217
- * @param {String|RegExp} evt Name of the event to remove the listener from.
218
- * @param {Function} listener Method to remove from the event.
219
- * @return {Object} Current instance of EventEmitter for chaining.
220
- */
221
- proto.removeListener = function removeListener(evt, listener) {
222
- var listeners = this.getListenersAsObject(evt);
223
- var index;
224
- var key;
225
 
226
- for (key in listeners) {
227
- if (listeners.hasOwnProperty(key)) {
228
- index = indexOfListener(listeners[key], listener);
229
 
230
- if (index !== -1) {
231
- listeners[key].splice(index, 1);
232
- }
233
- }
234
- }
235
 
236
- return this;
237
- };
238
-
239
- /**
240
- * Alias of removeListener
241
- */
242
- proto.off = alias('removeListener');
243
 
244
- /**
245
- * Adds listeners in bulk using the manipulateListeners method.
246
- * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
247
- * You can also pass it a regular expression to add the array of listeners to all events that match it.
248
- * Yeah, this function does quite a bit. That's probably a bad thing.
249
- *
250
- * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
251
- * @param {Function[]} [listeners] An optional array of listener functions to add.
252
- * @return {Object} Current instance of EventEmitter for chaining.
253
- */
254
- proto.addListeners = function addListeners(evt, listeners) {
255
- // Pass through to manipulateListeners
256
- return this.manipulateListeners(false, evt, listeners);
257
- };
258
-
259
- /**
260
- * Removes listeners in bulk using the manipulateListeners method.
261
- * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
262
- * You can also pass it an event name and an array of listeners to be removed.
263
- * You can also pass it a regular expression to remove the listeners from all events that match it.
264
- *
265
- * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
266
- * @param {Function[]} [listeners] An optional array of listener functions to remove.
267
- * @return {Object} Current instance of EventEmitter for chaining.
268
- */
269
- proto.removeListeners = function removeListeners(evt, listeners) {
270
- // Pass through to manipulateListeners
271
- return this.manipulateListeners(true, evt, listeners);
272
- };
273
-
274
- /**
275
- * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
276
- * The first argument will determine if the listeners are removed (true) or added (false).
277
- * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
278
- * You can also pass it an event name and an array of listeners to be added/removed.
279
- * You can also pass it a regular expression to manipulate the listeners of all events that match it.
280
- *
281
- * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
282
- * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
283
- * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
284
- * @return {Object} Current instance of EventEmitter for chaining.
285
- */
286
- proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
287
- var i;
288
- var value;
289
- var single = remove ? this.removeListener : this.addListener;
290
- var multiple = remove ? this.removeListeners : this.addListeners;
291
-
292
- // If evt is an object then pass each of its properties to this method
293
- if (typeof evt === 'object' && !(evt instanceof RegExp)) {
294
- for (i in evt) {
295
- if (evt.hasOwnProperty(i) && (value = evt[i])) {
296
- // Pass the single listener straight through to the singular method
297
- if (typeof value === 'function') {
298
- single.call(this, i, value);
299
- }
300
- else {
301
- // Otherwise pass back to the multiple function
302
- multiple.call(this, i, value);
303
- }
304
- }
305
- }
306
- }
307
- else {
308
- // So evt must be a string
309
- // And listeners must be an array of listeners
310
- // Loop over it and pass each one to the multiple method
311
- i = listeners.length;
312
- while (i--) {
313
- single.call(this, evt, listeners[i]);
314
- }
315
- }
316
-
317
- return this;
318
- };
319
-
320
- /**
321
- * Removes all listeners from a specified event.
322
- * If you do not specify an event then all listeners will be removed.
323
- * That means every event will be emptied.
324
- * You can also pass a regex to remove all events that match it.
325
- *
326
- * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
327
- * @return {Object} Current instance of EventEmitter for chaining.
328
- */
329
- proto.removeEvent = function removeEvent(evt) {
330
- var type = typeof evt;
331
- var events = this._getEvents();
332
- var key;
333
-
334
- // Remove different things depending on the state of evt
335
- if (type === 'string') {
336
- // Remove all listeners for the specified event
337
- delete events[evt];
338
- }
339
- else if (evt instanceof RegExp) {
340
- // Remove all events matching the regex.
341
- for (key in events) {
342
- if (events.hasOwnProperty(key) && evt.test(key)) {
343
- delete events[key];
344
- }
345
- }
346
- }
347
- else {
348
- // Remove all listeners in all events
349
- delete this._events;
350
- }
351
-
352
- return this;
353
- };
354
 
355
- /**
356
- * Alias of removeEvent.
357
- *
358
- * Added to mirror the node API.
359
- */
360
- proto.removeAllListeners = alias('removeEvent');
361
 
362
- /**
363
- * Emits an event of your choice.
364
- * When emitted, every listener attached to that event will be executed.
365
- * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
366
- * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
367
- * So they will not arrive within the array on the other side, they will be separate.
368
- * You can also pass a regular expression to emit to all events that match it.
369
- *
370
- * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
371
- * @param {Array} [args] Optional array of arguments to be passed to each listener.
372
- * @return {Object} Current instance of EventEmitter for chaining.
373
- */
374
- proto.emitEvent = function emitEvent(evt, args) {
375
- var listenersMap = this.getListenersAsObject(evt);
376
- var listeners;
377
- var listener;
378
- var i;
379
- var key;
380
- var response;
381
 
382
- for (key in listenersMap) {
383
- if (listenersMap.hasOwnProperty(key)) {
384
- listeners = listenersMap[key].slice(0);
 
 
385
 
386
- for (i = 0; i < listeners.length; i++) {
387
- // If the listener returns true then it shall be removed from the event
388
- // The function is executed either with a basic call or an apply if there is an args array
389
- listener = listeners[i];
390
 
391
- if (listener.once === true) {
392
- this.removeListener(evt, listener.listener);
393
- }
 
394
 
395
- response = listener.listener.apply(this, args || []);
 
396
 
397
- if (response === this._getOnceReturnValue()) {
398
- this.removeListener(evt, listener.listener);
399
- }
400
- }
401
- }
402
- }
403
 
404
- return this;
405
- };
406
 
407
- /**
408
- * Alias of emitEvent
409
- */
410
- proto.trigger = alias('emitEvent');
 
 
411
 
412
- /**
413
- * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
414
- * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
415
- *
416
- * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
417
- * @param {...*} Optional additional arguments to be passed to each listener.
418
- * @return {Object} Current instance of EventEmitter for chaining.
419
- */
420
- proto.emit = function emit(evt) {
421
- var args = Array.prototype.slice.call(arguments, 1);
422
- return this.emitEvent(evt, args);
423
- };
424
 
425
- /**
426
- * Sets the current value to check against when executing listeners. If a
427
- * listeners return value matches the one set here then it will be removed
428
- * after execution. This value defaults to true.
429
- *
430
- * @param {*} value The new value to check for when executing listeners.
431
- * @return {Object} Current instance of EventEmitter for chaining.
432
- */
433
- proto.setOnceReturnValue = function setOnceReturnValue(value) {
434
- this._onceReturnValue = value;
435
- return this;
436
- };
437
 
438
- /**
439
- * Fetches the current value to check against when executing listeners. If
440
- * the listeners return value matches this one then it should be removed
441
- * automatically. It will return true by default.
442
- *
443
- * @return {*|Boolean} The current value to check for or the default, true.
444
- * @api private
445
- */
446
- proto._getOnceReturnValue = function _getOnceReturnValue() {
447
- if (this.hasOwnProperty('_onceReturnValue')) {
448
- return this._onceReturnValue;
449
- }
450
- else {
451
- return true;
452
- }
453
- };
454
 
455
- /**
456
- * Fetches the events object and creates one if required.
457
- *
458
- * @return {Object} The events storage object.
459
- * @api private
460
- */
461
- proto._getEvents = function _getEvents() {
462
- return this._events || (this._events = {});
463
- };
464
 
465
- /**
466
- * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
467
- *
468
- * @return {Function} Non conflicting EventEmitter class.
469
- */
470
- EventEmitter.noConflict = function noConflict() {
471
- exports.EventEmitter = originalGlobalValue;
472
- return EventEmitter;
473
- };
474
 
475
- // Expose the class either via AMD, CommonJS or the global object
476
- if (typeof define === 'function' && define.amd) {
477
- define(function () {
478
- return EventEmitter;
479
- });
480
- }
481
- else if (typeof module === 'object' && module.exports){
482
- module.exports = EventEmitter;
483
- }
484
- else {
485
- exports.EventEmitter = EventEmitter;
486
- }
487
- }(typeof window !== 'undefined' ? window : this || {}));
488
 
489
- },{}],2:[function(require,module,exports){
490
  "use strict";
491
 
492
  var duration = 320;
@@ -739,7 +395,10 @@ Box.prototype.events = function () {
739
  var box = this; // attach event to "close" icon inside box
740
 
741
  if (this.closeIcon) {
742
- this.closeIcon.addEventListener('click', this.dismiss.bind(this));
 
 
 
743
  }
744
 
745
  this.element.addEventListener('click', function (e) {
@@ -816,12 +475,9 @@ Box.prototype.setCustomBoxStyling = function () {
816
  }; // toggle visibility of the box
817
 
818
 
819
- Box.prototype.toggle = function (show) {
820
- // revert visibility if no explicit argument is given
821
- if (typeof show === "undefined") {
822
- show = !this.visible;
823
- } // is box already at desired visibility?
824
-
825
 
826
  if (show === this.visible) {
827
  return false;
@@ -846,27 +502,37 @@ Box.prototype.toggle = function (show) {
846
 
847
  if (this.config.position === 'center') {
848
  this.overlay.classList.toggle('boxzilla-' + this.id + '-overlay');
849
- Animator.toggle(this.overlay, "fade");
850
- }
851
 
852
- Animator.toggle(this.element, this.config.animation, function () {
853
- if (this.visible) {
854
- return;
 
855
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
856
 
857
- this.contentElement.innerHTML = this.contentElement.innerHTML;
858
- }.bind(this));
859
  return true;
860
  }; // show the box
861
 
862
 
863
- Box.prototype.show = function () {
864
- return this.toggle(true);
865
  }; // hide the box
866
 
867
 
868
- Box.prototype.hide = function () {
869
- return this.toggle(false);
870
  }; // calculate trigger height
871
 
872
 
@@ -978,16 +644,14 @@ Box.prototype.trigger = function () {
978
  */
979
 
980
 
981
- Box.prototype.dismiss = function (e) {
982
- // prevent default action
983
- e && e.preventDefault(); // only dismiss box if it's currently open.
984
-
985
  if (!this.visible) {
986
  return false;
987
  } // hide box element
988
 
989
 
990
- this.hide(); // set cookie
991
 
992
  if (this.config.cookie && this.config.cookie.dismissed) {
993
  this.setCookie(this.config.cookie.dismissed);
@@ -1288,44 +952,44 @@ Boxzilla.get = function (id) {
1288
  }; // dismiss a single box (or all by omitting id param)
1289
 
1290
 
1291
- Boxzilla.dismiss = function (id) {
1292
  // if no id given, dismiss all current open boxes
1293
- if (typeof id === "undefined") {
 
 
1294
  boxes.forEach(function (box) {
1295
- box.dismiss();
1296
  });
1297
- } else {
1298
- Boxzilla.get(id).dismiss();
1299
  }
1300
  };
1301
 
1302
- Boxzilla.hide = function (id) {
1303
- if (typeof id === "undefined") {
 
 
1304
  boxes.forEach(function (box) {
1305
- box.hide();
1306
  });
1307
- } else {
1308
- Boxzilla.get(id).hide();
1309
  }
1310
  };
1311
 
1312
- Boxzilla.show = function (id) {
1313
- if (typeof id === "undefined") {
 
 
1314
  boxes.forEach(function (box) {
1315
- box.show();
1316
  });
1317
- } else {
1318
- Boxzilla.get(id).show();
1319
  }
1320
  };
1321
 
1322
- Boxzilla.toggle = function (id) {
1323
- if (typeof id === "undefined") {
 
 
1324
  boxes.forEach(function (box) {
1325
- box.toggle();
1326
  });
1327
- } else {
1328
- Boxzilla.get(id).toggle();
1329
  }
1330
  }; // expose each individual box.
1331
 
@@ -1338,7 +1002,7 @@ if (typeof module !== 'undefined' && module.exports) {
1338
  module.exports = Boxzilla;
1339
  }
1340
 
1341
- },{"./box.js":3,"./styles.js":5,"./timer.js":6,"./triggers/exit-intent.js":7,"wolfy87-eventemitter":1}],5:[function(require,module,exports){
1342
  "use strict";
1343
 
1344
  var styles = "#boxzilla-overlay{position:fixed;background:rgba(0,0,0,.65);width:100%;height:100%;left:0;top:0;z-index:99999}.boxzilla-center-container{position:fixed;top:0;left:0;right:0;height:0;text-align:center;z-index:999999;line-height:0}.boxzilla-center-container .boxzilla{display:inline-block;text-align:left;position:relative;line-height:normal}.boxzilla{position:fixed;z-index:999999;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background:#fff;padding:25px}.boxzilla.boxzilla-top-left{top:0;left:0}.boxzilla.boxzilla-top-right{top:0;right:0}.boxzilla.boxzilla-bottom-left{bottom:0;left:0}.boxzilla.boxzilla-bottom-right{bottom:0;right:0}.boxzilla-content>:first-child{margin-top:0;padding-top:0}.boxzilla-content>:last-child{margin-bottom:0;padding-bottom:0}.boxzilla-close-icon{position:absolute;right:0;top:0;text-align:center;padding:6px;cursor:pointer;-webkit-appearance:none;font-size:28px;font-weight:700;line-height:20px;color:#000;opacity:.5}.boxzilla-close-icon:focus,.boxzilla-close-icon:hover{opacity:.8}";
@@ -1392,201 +1056,549 @@ module.exports = function (callback) {
1392
  return;
1393
  }
1394
 
1395
- window.clearTimeout(timeout);
1396
- timeout = null;
1397
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1398
 
1399
- function onMouseEnter(evt) {
1400
- clearTimeout();
1401
- }
1402
 
1403
- function onMouseLeave(evt) {
1404
- clearTimeout(); // did mouse leave at top of window?
1405
- // add small exception space in the top-right corner
 
 
 
 
 
 
1406
 
1407
- if (evt.clientY <= 0 && evt.clientX < 0.80 * window.innerWidth) {
1408
- timeout = window.setTimeout(triggerCallback, 400);
1409
- }
1410
- }
1411
 
1412
- function onTouchStart(evt) {
1413
- clearTimeout();
1414
- touchStart = {
1415
- timestamp: performance.now(),
1416
- scrollY: window.scrollY,
1417
- windowHeight: window.innerHeight
1418
  };
1419
- }
1420
 
1421
- function onTouchEnd(evt) {
1422
- clearTimeout(); // did address bar appear?
 
 
 
 
 
 
 
1423
 
1424
- if (window.innerHeight > touchStart.windowHeight) {
1425
- return;
1426
- } // allow a tiny tiny margin for error, to not fire on clicks
 
1427
 
 
 
1428
 
1429
- if (window.scrollY + 20 >= touchStart.scrollY) {
1430
- return;
 
 
 
 
 
 
1431
  }
1432
 
1433
- if (performance.now() - touchStart.timestamp > 300) {
1434
- return;
1435
- }
 
 
 
 
 
 
 
 
 
 
 
1436
 
1437
- if (['A', 'INPUT', 'BUTTON'].indexOf(evt.target.tagName) > -1) {
1438
- return;
1439
- }
1440
 
1441
- timeout = window.setTimeout(triggerCallback, 800);
1442
- }
 
 
 
 
 
 
1443
 
1444
- window.addEventListener('touchstart', onTouchStart);
1445
- window.addEventListener('touchend', onTouchEnd);
1446
- document.documentElement.addEventListener('mouseenter', onMouseEnter);
1447
- document.documentElement.addEventListener('mouseleave', onMouseLeave);
1448
- document.documentElement.addEventListener('click', clearTimeout);
1449
- };
1450
 
1451
- },{}],8:[function(require,module,exports){
1452
- "use strict";
 
 
1453
 
1454
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
 
 
 
 
 
 
 
 
 
 
 
 
 
1455
 
1456
- (function () {
1457
- 'use strict';
 
 
1458
 
1459
- var Boxzilla = require('boxzilla');
 
 
 
 
 
 
 
 
 
 
1460
 
1461
- var options = window.boxzilla_options; // expose Boxzilla object to window
 
 
 
 
 
 
 
 
 
 
 
1462
 
1463
- window.Boxzilla = Boxzilla; // helper function for setting CSS styles
 
 
 
 
 
 
 
 
 
 
 
1464
 
1465
- function css(element, styles) {
1466
- if (styles.background_color) {
1467
- element.style.background = styles.background_color;
1468
- }
1469
 
1470
- if (styles.color) {
1471
- element.style.color = styles.color;
1472
- }
 
 
1473
 
1474
- if (styles.border_color) {
1475
- element.style.borderColor = styles.border_color;
1476
- }
1477
 
1478
- if (styles.border_width) {
1479
- element.style.borderWidth = parseInt(styles.border_width) + "px";
1480
- }
 
1481
 
1482
- if (styles.border_style) {
1483
- element.style.borderStyle = styles.border_style;
1484
- }
 
 
 
 
 
 
 
 
 
 
 
1485
 
1486
- if (styles.width) {
1487
- element.style.maxWidth = parseInt(styles.width) + "px";
1488
- }
1489
- }
 
 
 
 
 
 
 
 
 
 
1490
 
1491
- function createBoxesFromConfig() {
1492
- // failsafe against including script twice.
1493
- if (options.inited) {
1494
- return;
1495
- } // create boxes from options
 
 
 
 
 
 
 
 
 
 
 
 
1496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1497
 
1498
- for (var key in options.boxes) {
1499
- // get opts
1500
- var boxOpts = options.boxes[key];
1501
- boxOpts.testMode = isLoggedIn && options.testMode; // find box content element, bail if not found
1502
 
1503
- var boxContentElement = document.getElementById('boxzilla-box-' + boxOpts.id + '-content');
 
 
 
 
 
 
 
 
 
 
 
 
1504
 
1505
- if (!boxContentElement) {
1506
- continue;
1507
- } // use element as content option
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1508
 
 
 
1509
 
1510
- boxOpts.content = boxContentElement; // create box
 
 
 
 
 
1511
 
1512
- var box = Boxzilla.create(boxOpts.id, boxOpts); // add box slug to box element as classname
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1513
 
1514
- box.element.className = box.element.className + ' boxzilla-' + boxOpts.post.slug; // add custom css to box
 
 
1515
 
1516
- css(box.element, boxOpts.css);
1517
- box.element.firstChild.firstChild.className += " first-child";
1518
- box.element.firstChild.lastChild.className += " last-child"; // maybe show box right away
 
1519
 
1520
- if (box.fits() && locationHashRefersBox(box)) {
1521
- box.show();
1522
- }
1523
- } // set flag to prevent initialising twice
1524
 
 
1525
 
1526
- options.inited = true; // trigger "done" event.
 
 
 
 
 
1527
 
1528
- Boxzilla.trigger('done'); // maybe open box with MC4WP form in it
 
1529
 
1530
- maybeOpenMailChimpForWordPressBox();
1531
- }
 
 
1532
 
1533
- function locationHashRefersBox(box) {
1534
- if (!window.location.hash || 0 === window.location.hash.length) {
1535
- return false;
1536
- } // parse "boxzilla-{id}" from location hash
 
 
 
 
 
 
 
 
1537
 
 
 
 
 
 
 
 
 
 
 
 
 
1538
 
1539
- var match = window.location.hash.match(/[#&](boxzilla-\d+)/);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1540
 
1541
- if (!match || _typeof(match) !== "object" || match.length < 2) {
1542
- return false;
1543
- }
 
 
 
 
 
 
1544
 
1545
- var elementId = match[1];
 
 
 
 
 
 
 
 
1546
 
1547
- if (elementId === box.element.id) {
1548
- return true;
1549
- } else if (box.element.querySelector('#' + elementId)) {
1550
- return true;
 
1551
  }
1552
-
1553
- return false;
1554
- }
1555
-
1556
- function maybeOpenMailChimpForWordPressBox() {
1557
- if (_typeof(window.mc4wp_forms_config) !== "object" || !window.mc4wp_forms_config.submitted_form) {
1558
- return;
1559
  }
1560
-
1561
- var selector = '#' + window.mc4wp_forms_config.submitted_form.element_id;
1562
- var boxes = Boxzilla.boxes;
1563
-
1564
- for (var boxId in boxes) {
1565
- if (!boxes.hasOwnProperty(boxId)) {
1566
- continue;
1567
- }
1568
-
1569
- var box = boxes[boxId];
1570
-
1571
- if (box.element.querySelector(selector)) {
1572
- box.show();
1573
- return;
1574
- }
1575
  }
1576
- } // print message when test mode is enabled
1577
-
1578
-
1579
- var isLoggedIn = document.body.className.indexOf('logged-in') > -1;
1580
-
1581
- if (isLoggedIn && options.testMode) {
1582
- console.log('Boxzilla: Test mode is enabled. Please disable test mode if you\'re done testing.');
1583
- } // init boxzilla
1584
-
1585
-
1586
- Boxzilla.init(); // on window.load, create DOM elements for boxes
1587
-
1588
- window.addEventListener('load', createBoxesFromConfig);
1589
- })();
1590
 
1591
- },{"boxzilla":4}]},{},[8]);
1592
  ; })();
1
  (function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
+ "use strict";
 
 
 
 
 
3
 
4
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
 
5
 
6
+ (function () {
7
+ 'use strict';
 
 
 
 
 
8
 
9
+ var Boxzilla = require('boxzilla');
 
 
10
 
11
+ var options = window.boxzilla_options; // expose Boxzilla object to window
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
+ window.Boxzilla = Boxzilla; // helper function for setting CSS styles
14
+
15
+ function css(element, styles) {
16
+ if (styles.background_color) {
17
+ element.style.background = styles.background_color;
18
  }
19
 
20
+ if (styles.color) {
21
+ element.style.color = styles.color;
 
 
 
 
 
 
 
 
 
22
  }
23
 
24
+ if (styles.border_color) {
25
+ element.style.borderColor = styles.border_color;
26
+ }
 
 
 
 
 
 
 
 
 
 
27
 
28
+ if (styles.border_width) {
29
+ element.style.borderWidth = parseInt(styles.border_width) + "px";
30
+ }
 
 
 
 
 
 
 
 
 
 
31
 
32
+ if (styles.border_style) {
33
+ element.style.borderStyle = styles.border_style;
34
+ }
35
 
36
+ if (styles.width) {
37
+ element.style.maxWidth = parseInt(styles.width) + "px";
38
+ }
39
+ }
 
 
 
 
 
40
 
41
+ function createBoxesFromConfig() {
42
+ // failsafe against including script twice.
43
+ if (options.inited) {
44
+ return;
45
+ } // create boxes from options
46
 
 
 
47
 
48
+ for (var key in options.boxes) {
49
+ // get opts
50
+ var boxOpts = options.boxes[key];
51
+ boxOpts.testMode = isLoggedIn && options.testMode; // find box content element, bail if not found
 
 
 
 
 
52
 
53
+ var boxContentElement = document.getElementById('boxzilla-box-' + boxOpts.id + '-content');
 
 
 
54
 
55
+ if (!boxContentElement) {
56
+ continue;
57
+ } // use element as content option
58
 
 
 
 
 
 
 
 
 
 
59
 
60
+ boxOpts.content = boxContentElement; // create box
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
+ var box = Boxzilla.create(boxOpts.id, boxOpts); // add box slug to box element as classname
 
 
63
 
64
+ box.element.className = box.element.className + ' boxzilla-' + boxOpts.post.slug; // add custom css to box
 
 
 
 
 
 
 
65
 
66
+ css(box.element, boxOpts.css);
 
67
 
68
+ try {
69
+ box.element.firstChild.firstChild.className += " first-child";
70
+ box.element.firstChild.lastChild.className += " last-child";
71
+ } catch (e) {} // maybe show box right away
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
+ if (box.fits() && locationHashRefersBox(box)) {
75
+ box.show();
76
+ }
77
+ } // set flag to prevent initialising twice
78
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ options.inited = true; // trigger "done" event.
 
 
 
 
 
 
 
 
 
 
 
81
 
82
+ Boxzilla.trigger('done'); // maybe open box with MC4WP form in it
 
 
 
 
 
 
 
 
 
 
 
83
 
84
+ maybeOpenMailChimpForWordPressBox();
85
+ }
 
86
 
87
+ function locationHashRefersBox(box) {
88
+ if (!window.location.hash || 0 === window.location.hash.length) {
89
+ return false;
90
+ } // parse "boxzilla-{id}" from location hash
 
91
 
 
 
 
 
 
 
 
92
 
93
+ var match = window.location.hash.match(/[#&](boxzilla-\d+)/);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
+ if (!match || _typeof(match) !== "object" || match.length < 2) {
96
+ return false;
97
+ }
 
 
 
98
 
99
+ var elementId = match[1];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ if (elementId === box.element.id) {
102
+ return true;
103
+ } else if (box.element.querySelector('#' + elementId)) {
104
+ return true;
105
+ }
106
 
107
+ return false;
108
+ }
 
 
109
 
110
+ function maybeOpenMailChimpForWordPressBox() {
111
+ if (_typeof(window.mc4wp_forms_config) !== "object" || !window.mc4wp_forms_config.submitted_form) {
112
+ return;
113
+ }
114
 
115
+ var selector = '#' + window.mc4wp_forms_config.submitted_form.element_id;
116
+ var boxes = Boxzilla.boxes;
117
 
118
+ for (var boxId in boxes) {
119
+ if (!boxes.hasOwnProperty(boxId)) {
120
+ continue;
121
+ }
 
 
122
 
123
+ var box = boxes[boxId];
 
124
 
125
+ if (box.element.querySelector(selector)) {
126
+ box.show();
127
+ return;
128
+ }
129
+ }
130
+ } // print message when test mode is enabled
131
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
+ var isLoggedIn = document.body.className.indexOf('logged-in') > -1;
 
 
 
 
 
 
 
 
 
 
 
134
 
135
+ if (isLoggedIn && options.testMode) {
136
+ console.log('Boxzilla: Test mode is enabled. Please disable test mode if you\'re done testing.');
137
+ } // init boxzilla
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
 
 
 
 
 
 
 
 
 
139
 
140
+ Boxzilla.init(); // on window.load, create DOM elements for boxes
 
 
 
 
 
 
 
 
141
 
142
+ window.addEventListener('load', createBoxesFromConfig);
143
+ })();
 
 
 
 
 
 
 
 
 
 
 
144
 
145
+ },{"boxzilla":4}],2:[function(require,module,exports){
146
  "use strict";
147
 
148
  var duration = 320;
395
  var box = this; // attach event to "close" icon inside box
396
 
397
  if (this.closeIcon) {
398
+ this.closeIcon.addEventListener('click', function (e) {
399
+ e.preventDefault();
400
+ box.dismiss();
401
+ });
402
  }
403
 
404
  this.element.addEventListener('click', function (e) {
475
  }; // toggle visibility of the box
476
 
477
 
478
+ Box.prototype.toggle = function (show, animate) {
479
+ show = typeof show === "undefined" ? !this.visible : show;
480
+ animate = typeof animate === "undefined" ? true : animate; // is box already at desired visibility?
 
 
 
481
 
482
  if (show === this.visible) {
483
  return false;
502
 
503
  if (this.config.position === 'center') {
504
  this.overlay.classList.toggle('boxzilla-' + this.id + '-overlay');
 
 
505
 
506
+ if (animate) {
507
+ Animator.toggle(this.overlay, "fade");
508
+ } else {
509
+ this.overlay.style.display = show ? '' : 'none';
510
  }
511
+ }
512
+
513
+ if (animate) {
514
+ Animator.toggle(this.element, this.config.animation, function () {
515
+ if (this.visible) {
516
+ return;
517
+ }
518
+
519
+ this.contentElement.innerHTML = this.contentElement.innerHTML;
520
+ }.bind(this));
521
+ } else {
522
+ this.element.style.display = show ? '' : 'none';
523
+ }
524
 
 
 
525
  return true;
526
  }; // show the box
527
 
528
 
529
+ Box.prototype.show = function (animate) {
530
+ return this.toggle(true, animate);
531
  }; // hide the box
532
 
533
 
534
+ Box.prototype.hide = function (animate) {
535
+ return this.toggle(false, animate);
536
  }; // calculate trigger height
537
 
538
 
644
  */
645
 
646
 
647
+ Box.prototype.dismiss = function (animate) {
648
+ // only dismiss box if it's currently open.
 
 
649
  if (!this.visible) {
650
  return false;
651
  } // hide box element
652
 
653
 
654
+ this.hide(animate); // set cookie
655
 
656
  if (this.config.cookie && this.config.cookie.dismissed) {
657
  this.setCookie(this.config.cookie.dismissed);
952
  }; // dismiss a single box (or all by omitting id param)
953
 
954
 
955
+ Boxzilla.dismiss = function (id, animate) {
956
  // if no id given, dismiss all current open boxes
957
+ if (id) {
958
+ Boxzilla.get(id).dismiss(animate);
959
+ } else {
960
  boxes.forEach(function (box) {
961
+ box.dismiss(animate);
962
  });
 
 
963
  }
964
  };
965
 
966
+ Boxzilla.hide = function (id, animate) {
967
+ if (id) {
968
+ Boxzilla.get(id).hide(animate);
969
+ } else {
970
  boxes.forEach(function (box) {
971
+ box.hide(animate);
972
  });
 
 
973
  }
974
  };
975
 
976
+ Boxzilla.show = function (id, animate) {
977
+ if (id) {
978
+ Boxzilla.get(id).show(animate);
979
+ } else {
980
  boxes.forEach(function (box) {
981
+ box.show(animate);
982
  });
 
 
983
  }
984
  };
985
 
986
+ Boxzilla.toggle = function (id, animate) {
987
+ if (id) {
988
+ Boxzilla.get(id).toggle(animate);
989
+ } else {
990
  boxes.forEach(function (box) {
991
+ box.toggle(animate);
992
  });
 
 
993
  }
994
  }; // expose each individual box.
995
 
1002
  module.exports = Boxzilla;
1003
  }
1004
 
1005
+ },{"./box.js":3,"./styles.js":5,"./timer.js":6,"./triggers/exit-intent.js":7,"wolfy87-eventemitter":8}],5:[function(require,module,exports){
1006
  "use strict";
1007
 
1008
  var styles = "#boxzilla-overlay{position:fixed;background:rgba(0,0,0,.65);width:100%;height:100%;left:0;top:0;z-index:99999}.boxzilla-center-container{position:fixed;top:0;left:0;right:0;height:0;text-align:center;z-index:999999;line-height:0}.boxzilla-center-container .boxzilla{display:inline-block;text-align:left;position:relative;line-height:normal}.boxzilla{position:fixed;z-index:999999;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background:#fff;padding:25px}.boxzilla.boxzilla-top-left{top:0;left:0}.boxzilla.boxzilla-top-right{top:0;right:0}.boxzilla.boxzilla-bottom-left{bottom:0;left:0}.boxzilla.boxzilla-bottom-right{bottom:0;right:0}.boxzilla-content>:first-child{margin-top:0;padding-top:0}.boxzilla-content>:last-child{margin-bottom:0;padding-bottom:0}.boxzilla-close-icon{position:absolute;right:0;top:0;text-align:center;padding:6px;cursor:pointer;-webkit-appearance:none;font-size:28px;font-weight:700;line-height:20px;color:#000;opacity:.5}.boxzilla-close-icon:focus,.boxzilla-close-icon:hover{opacity:.8}";
1056
  return;
1057
  }
1058
 
1059
+ window.clearTimeout(timeout);
1060
+ timeout = null;
1061
+ }
1062
+
1063
+ function onMouseEnter(evt) {
1064
+ clearTimeout();
1065
+ }
1066
+
1067
+ function onMouseLeave(evt) {
1068
+ clearTimeout(); // did mouse leave at top of window?
1069
+ // add small exception space in the top-right corner
1070
+
1071
+ if (evt.clientY <= 0 && evt.clientX < 0.80 * window.innerWidth) {
1072
+ timeout = window.setTimeout(triggerCallback, 400);
1073
+ }
1074
+ }
1075
+
1076
+ function onTouchStart(evt) {
1077
+ clearTimeout();
1078
+ touchStart = {
1079
+ timestamp: performance.now(),
1080
+ scrollY: window.scrollY,
1081
+ windowHeight: window.innerHeight
1082
+ };
1083
+ }
1084
+
1085
+ function onTouchEnd(evt) {
1086
+ clearTimeout(); // did address bar appear?
1087
+
1088
+ if (window.innerHeight > touchStart.windowHeight) {
1089
+ return;
1090
+ } // allow a tiny tiny margin for error, to not fire on clicks
1091
+
1092
+
1093
+ if (window.scrollY + 20 >= touchStart.scrollY) {
1094
+ return;
1095
+ }
1096
+
1097
+ if (performance.now() - touchStart.timestamp > 300) {
1098
+ return;
1099
+ }
1100
+
1101
+ if (['A', 'INPUT', 'BUTTON'].indexOf(evt.target.tagName) > -1) {
1102
+ return;
1103
+ }
1104
+
1105
+ timeout = window.setTimeout(triggerCallback, 800);
1106
+ }
1107
+
1108
+ window.addEventListener('touchstart', onTouchStart);
1109
+ window.addEventListener('touchend', onTouchEnd);
1110
+ document.documentElement.addEventListener('mouseenter', onMouseEnter);
1111
+ document.documentElement.addEventListener('mouseleave', onMouseLeave);
1112
+ document.documentElement.addEventListener('click', clearTimeout);
1113
+ };
1114
+
1115
+ },{}],8:[function(require,module,exports){
1116
+ /*!
1117
+ * EventEmitter v5.2.6 - git.io/ee
1118
+ * Unlicense - http://unlicense.org/
1119
+ * Oliver Caldwell - https://oli.me.uk/
1120
+ * @preserve
1121
+ */
1122
+
1123
+ ;(function (exports) {
1124
+ 'use strict';
1125
+
1126
+ /**
1127
+ * Class for managing events.
1128
+ * Can be extended to provide event functionality in other classes.
1129
+ *
1130
+ * @class EventEmitter Manages event registering and emitting.
1131
+ */
1132
+ function EventEmitter() {}
1133
+
1134
+ // Shortcuts to improve speed and size
1135
+ var proto = EventEmitter.prototype;
1136
+ var originalGlobalValue = exports.EventEmitter;
1137
+
1138
+ /**
1139
+ * Finds the index of the listener for the event in its storage array.
1140
+ *
1141
+ * @param {Function[]} listeners Array of listeners to search through.
1142
+ * @param {Function} listener Method to look for.
1143
+ * @return {Number} Index of the specified listener, -1 if not found
1144
+ * @api private
1145
+ */
1146
+ function indexOfListener(listeners, listener) {
1147
+ var i = listeners.length;
1148
+ while (i--) {
1149
+ if (listeners[i].listener === listener) {
1150
+ return i;
1151
+ }
1152
+ }
1153
+
1154
+ return -1;
1155
+ }
1156
+
1157
+ /**
1158
+ * Alias a method while keeping the context correct, to allow for overwriting of target method.
1159
+ *
1160
+ * @param {String} name The name of the target method.
1161
+ * @return {Function} The aliased method
1162
+ * @api private
1163
+ */
1164
+ function alias(name) {
1165
+ return function aliasClosure() {
1166
+ return this[name].apply(this, arguments);
1167
+ };
1168
+ }
1169
+
1170
+ /**
1171
+ * Returns the listener array for the specified event.
1172
+ * Will initialise the event object and listener arrays if required.
1173
+ * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
1174
+ * Each property in the object response is an array of listener functions.
1175
+ *
1176
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
1177
+ * @return {Function[]|Object} All listener functions for the event.
1178
+ */
1179
+ proto.getListeners = function getListeners(evt) {
1180
+ var events = this._getEvents();
1181
+ var response;
1182
+ var key;
1183
+
1184
+ // Return a concatenated array of all matching events if
1185
+ // the selector is a regular expression.
1186
+ if (evt instanceof RegExp) {
1187
+ response = {};
1188
+ for (key in events) {
1189
+ if (events.hasOwnProperty(key) && evt.test(key)) {
1190
+ response[key] = events[key];
1191
+ }
1192
+ }
1193
+ }
1194
+ else {
1195
+ response = events[evt] || (events[evt] = []);
1196
+ }
1197
 
1198
+ return response;
1199
+ };
 
1200
 
1201
+ /**
1202
+ * Takes a list of listener objects and flattens it into a list of listener functions.
1203
+ *
1204
+ * @param {Object[]} listeners Raw listener objects.
1205
+ * @return {Function[]} Just the listener functions.
1206
+ */
1207
+ proto.flattenListeners = function flattenListeners(listeners) {
1208
+ var flatListeners = [];
1209
+ var i;
1210
 
1211
+ for (i = 0; i < listeners.length; i += 1) {
1212
+ flatListeners.push(listeners[i].listener);
1213
+ }
 
1214
 
1215
+ return flatListeners;
 
 
 
 
 
1216
  };
 
1217
 
1218
+ /**
1219
+ * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
1220
+ *
1221
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
1222
+ * @return {Object} All listener functions for an event in an object.
1223
+ */
1224
+ proto.getListenersAsObject = function getListenersAsObject(evt) {
1225
+ var listeners = this.getListeners(evt);
1226
+ var response;
1227
 
1228
+ if (listeners instanceof Array) {
1229
+ response = {};
1230
+ response[evt] = listeners;
1231
+ }
1232
 
1233
+ return response || listeners;
1234
+ };
1235
 
1236
+ function isValidListener (listener) {
1237
+ if (typeof listener === 'function' || listener instanceof RegExp) {
1238
+ return true
1239
+ } else if (listener && typeof listener === 'object') {
1240
+ return isValidListener(listener.listener)
1241
+ } else {
1242
+ return false
1243
+ }
1244
  }
1245
 
1246
+ /**
1247
+ * Adds a listener function to the specified event.
1248
+ * The listener will not be added if it is a duplicate.
1249
+ * If the listener returns true then it will be removed after it is called.
1250
+ * If you pass a regular expression as the event name then the listener will be added to all events that match it.
1251
+ *
1252
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
1253
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
1254
+ * @return {Object} Current instance of EventEmitter for chaining.
1255
+ */
1256
+ proto.addListener = function addListener(evt, listener) {
1257
+ if (!isValidListener(listener)) {
1258
+ throw new TypeError('listener must be a function');
1259
+ }
1260
 
1261
+ var listeners = this.getListenersAsObject(evt);
1262
+ var listenerIsWrapped = typeof listener === 'object';
1263
+ var key;
1264
 
1265
+ for (key in listeners) {
1266
+ if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
1267
+ listeners[key].push(listenerIsWrapped ? listener : {
1268
+ listener: listener,
1269
+ once: false
1270
+ });
1271
+ }
1272
+ }
1273
 
1274
+ return this;
1275
+ };
 
 
 
 
1276
 
1277
+ /**
1278
+ * Alias of addListener
1279
+ */
1280
+ proto.on = alias('addListener');
1281
 
1282
+ /**
1283
+ * Semi-alias of addListener. It will add a listener that will be
1284
+ * automatically removed after its first execution.
1285
+ *
1286
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
1287
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
1288
+ * @return {Object} Current instance of EventEmitter for chaining.
1289
+ */
1290
+ proto.addOnceListener = function addOnceListener(evt, listener) {
1291
+ return this.addListener(evt, {
1292
+ listener: listener,
1293
+ once: true
1294
+ });
1295
+ };
1296
 
1297
+ /**
1298
+ * Alias of addOnceListener.
1299
+ */
1300
+ proto.once = alias('addOnceListener');
1301
 
1302
+ /**
1303
+ * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
1304
+ * You need to tell it what event names should be matched by a regex.
1305
+ *
1306
+ * @param {String} evt Name of the event to create.
1307
+ * @return {Object} Current instance of EventEmitter for chaining.
1308
+ */
1309
+ proto.defineEvent = function defineEvent(evt) {
1310
+ this.getListeners(evt);
1311
+ return this;
1312
+ };
1313
 
1314
+ /**
1315
+ * Uses defineEvent to define multiple events.
1316
+ *
1317
+ * @param {String[]} evts An array of event names to define.
1318
+ * @return {Object} Current instance of EventEmitter for chaining.
1319
+ */
1320
+ proto.defineEvents = function defineEvents(evts) {
1321
+ for (var i = 0; i < evts.length; i += 1) {
1322
+ this.defineEvent(evts[i]);
1323
+ }
1324
+ return this;
1325
+ };
1326
 
1327
+ /**
1328
+ * Removes a listener function from the specified event.
1329
+ * When passed a regular expression as the event name, it will remove the listener from all events that match it.
1330
+ *
1331
+ * @param {String|RegExp} evt Name of the event to remove the listener from.
1332
+ * @param {Function} listener Method to remove from the event.
1333
+ * @return {Object} Current instance of EventEmitter for chaining.
1334
+ */
1335
+ proto.removeListener = function removeListener(evt, listener) {
1336
+ var listeners = this.getListenersAsObject(evt);
1337
+ var index;
1338
+ var key;
1339
 
1340
+ for (key in listeners) {
1341
+ if (listeners.hasOwnProperty(key)) {
1342
+ index = indexOfListener(listeners[key], listener);
 
1343
 
1344
+ if (index !== -1) {
1345
+ listeners[key].splice(index, 1);
1346
+ }
1347
+ }
1348
+ }
1349
 
1350
+ return this;
1351
+ };
 
1352
 
1353
+ /**
1354
+ * Alias of removeListener
1355
+ */
1356
+ proto.off = alias('removeListener');
1357
 
1358
+ /**
1359
+ * Adds listeners in bulk using the manipulateListeners method.
1360
+ * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
1361
+ * You can also pass it a regular expression to add the array of listeners to all events that match it.
1362
+ * Yeah, this function does quite a bit. That's probably a bad thing.
1363
+ *
1364
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
1365
+ * @param {Function[]} [listeners] An optional array of listener functions to add.
1366
+ * @return {Object} Current instance of EventEmitter for chaining.
1367
+ */
1368
+ proto.addListeners = function addListeners(evt, listeners) {
1369
+ // Pass through to manipulateListeners
1370
+ return this.manipulateListeners(false, evt, listeners);
1371
+ };
1372
 
1373
+ /**
1374
+ * Removes listeners in bulk using the manipulateListeners method.
1375
+ * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
1376
+ * You can also pass it an event name and an array of listeners to be removed.
1377
+ * You can also pass it a regular expression to remove the listeners from all events that match it.
1378
+ *
1379
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
1380
+ * @param {Function[]} [listeners] An optional array of listener functions to remove.
1381
+ * @return {Object} Current instance of EventEmitter for chaining.
1382
+ */
1383
+ proto.removeListeners = function removeListeners(evt, listeners) {
1384
+ // Pass through to manipulateListeners
1385
+ return this.manipulateListeners(true, evt, listeners);
1386
+ };
1387
 
1388
+ /**
1389
+ * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
1390
+ * The first argument will determine if the listeners are removed (true) or added (false).
1391
+ * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
1392
+ * You can also pass it an event name and an array of listeners to be added/removed.
1393
+ * You can also pass it a regular expression to manipulate the listeners of all events that match it.
1394
+ *
1395
+ * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
1396
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
1397
+ * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
1398
+ * @return {Object} Current instance of EventEmitter for chaining.
1399
+ */
1400
+ proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
1401
+ var i;
1402
+ var value;
1403
+ var single = remove ? this.removeListener : this.addListener;
1404
+ var multiple = remove ? this.removeListeners : this.addListeners;
1405
 
1406
+ // If evt is an object then pass each of its properties to this method
1407
+ if (typeof evt === 'object' && !(evt instanceof RegExp)) {
1408
+ for (i in evt) {
1409
+ if (evt.hasOwnProperty(i) && (value = evt[i])) {
1410
+ // Pass the single listener straight through to the singular method
1411
+ if (typeof value === 'function') {
1412
+ single.call(this, i, value);
1413
+ }
1414
+ else {
1415
+ // Otherwise pass back to the multiple function
1416
+ multiple.call(this, i, value);
1417
+ }
1418
+ }
1419
+ }
1420
+ }
1421
+ else {
1422
+ // So evt must be a string
1423
+ // And listeners must be an array of listeners
1424
+ // Loop over it and pass each one to the multiple method
1425
+ i = listeners.length;
1426
+ while (i--) {
1427
+ single.call(this, evt, listeners[i]);
1428
+ }
1429
+ }
1430
 
1431
+ return this;
1432
+ };
 
 
1433
 
1434
+ /**
1435
+ * Removes all listeners from a specified event.
1436
+ * If you do not specify an event then all listeners will be removed.
1437
+ * That means every event will be emptied.
1438
+ * You can also pass a regex to remove all events that match it.
1439
+ *
1440
+ * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
1441
+ * @return {Object} Current instance of EventEmitter for chaining.
1442
+ */
1443
+ proto.removeEvent = function removeEvent(evt) {
1444
+ var type = typeof evt;
1445
+ var events = this._getEvents();
1446
+ var key;
1447
 
1448
+ // Remove different things depending on the state of evt
1449
+ if (type === 'string') {
1450
+ // Remove all listeners for the specified event
1451
+ delete events[evt];
1452
+ }
1453
+ else if (evt instanceof RegExp) {
1454
+ // Remove all events matching the regex.
1455
+ for (key in events) {
1456
+ if (events.hasOwnProperty(key) && evt.test(key)) {
1457
+ delete events[key];
1458
+ }
1459
+ }
1460
+ }
1461
+ else {
1462
+ // Remove all listeners in all events
1463
+ delete this._events;
1464
+ }
1465
 
1466
+ return this;
1467
+ };
1468
 
1469
+ /**
1470
+ * Alias of removeEvent.
1471
+ *
1472
+ * Added to mirror the node API.
1473
+ */
1474
+ proto.removeAllListeners = alias('removeEvent');
1475
 
1476
+ /**
1477
+ * Emits an event of your choice.
1478
+ * When emitted, every listener attached to that event will be executed.
1479
+ * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
1480
+ * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
1481
+ * So they will not arrive within the array on the other side, they will be separate.
1482
+ * You can also pass a regular expression to emit to all events that match it.
1483
+ *
1484
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
1485
+ * @param {Array} [args] Optional array of arguments to be passed to each listener.
1486
+ * @return {Object} Current instance of EventEmitter for chaining.
1487
+ */
1488
+ proto.emitEvent = function emitEvent(evt, args) {
1489
+ var listenersMap = this.getListenersAsObject(evt);
1490
+ var listeners;
1491
+ var listener;
1492
+ var i;
1493
+ var key;
1494
+ var response;
1495
 
1496
+ for (key in listenersMap) {
1497
+ if (listenersMap.hasOwnProperty(key)) {
1498
+ listeners = listenersMap[key].slice(0);
1499
 
1500
+ for (i = 0; i < listeners.length; i++) {
1501
+ // If the listener returns true then it shall be removed from the event
1502
+ // The function is executed either with a basic call or an apply if there is an args array
1503
+ listener = listeners[i];
1504
 
1505
+ if (listener.once === true) {
1506
+ this.removeListener(evt, listener.listener);
1507
+ }
 
1508
 
1509
+ response = listener.listener.apply(this, args || []);
1510
 
1511
+ if (response === this._getOnceReturnValue()) {
1512
+ this.removeListener(evt, listener.listener);
1513
+ }
1514
+ }
1515
+ }
1516
+ }
1517
 
1518
+ return this;
1519
+ };
1520
 
1521
+ /**
1522
+ * Alias of emitEvent
1523
+ */
1524
+ proto.trigger = alias('emitEvent');
1525
 
1526
+ /**
1527
+ * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
1528
+ * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
1529
+ *
1530
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
1531
+ * @param {...*} Optional additional arguments to be passed to each listener.
1532
+ * @return {Object} Current instance of EventEmitter for chaining.
1533
+ */
1534
+ proto.emit = function emit(evt) {
1535
+ var args = Array.prototype.slice.call(arguments, 1);
1536
+ return this.emitEvent(evt, args);
1537
+ };
1538
 
1539
+ /**
1540
+ * Sets the current value to check against when executing listeners. If a
1541
+ * listeners return value matches the one set here then it will be removed
1542
+ * after execution. This value defaults to true.
1543
+ *
1544
+ * @param {*} value The new value to check for when executing listeners.
1545
+ * @return {Object} Current instance of EventEmitter for chaining.
1546
+ */
1547
+ proto.setOnceReturnValue = function setOnceReturnValue(value) {
1548
+ this._onceReturnValue = value;
1549
+ return this;
1550
+ };
1551
 
1552
+ /**
1553
+ * Fetches the current value to check against when executing listeners. If
1554
+ * the listeners return value matches this one then it should be removed
1555
+ * automatically. It will return true by default.
1556
+ *
1557
+ * @return {*|Boolean} The current value to check for or the default, true.
1558
+ * @api private
1559
+ */
1560
+ proto._getOnceReturnValue = function _getOnceReturnValue() {
1561
+ if (this.hasOwnProperty('_onceReturnValue')) {
1562
+ return this._onceReturnValue;
1563
+ }
1564
+ else {
1565
+ return true;
1566
+ }
1567
+ };
1568
 
1569
+ /**
1570
+ * Fetches the events object and creates one if required.
1571
+ *
1572
+ * @return {Object} The events storage object.
1573
+ * @api private
1574
+ */
1575
+ proto._getEvents = function _getEvents() {
1576
+ return this._events || (this._events = {});
1577
+ };
1578
 
1579
+ /**
1580
+ * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
1581
+ *
1582
+ * @return {Function} Non conflicting EventEmitter class.
1583
+ */
1584
+ EventEmitter.noConflict = function noConflict() {
1585
+ exports.EventEmitter = originalGlobalValue;
1586
+ return EventEmitter;
1587
+ };
1588
 
1589
+ // Expose the class either via AMD, CommonJS or the global object
1590
+ if (typeof define === 'function' && define.amd) {
1591
+ define(function () {
1592
+ return EventEmitter;
1593
+ });
1594
  }
1595
+ else if (typeof module === 'object' && module.exports){
1596
+ module.exports = EventEmitter;