Choices/assets/scripts/dist/bundle.js
2016-03-16 20:24:11 +00:00

1 line
6.6 KiB
JavaScript

!function(e){function n(i){if(t[i])return t[i].exports;var o=t[i]={exports:{},id:i,loaded:!1};return e[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="/assets/scripts/dist/",n(0)}([function(e,n,t){e.exports=t(1)},function(e,n,t){function i(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var o,r=function(){function e(e,n){for(var t=0;t<n.length;t++){var i=n[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(n,t,i){return t&&e(n.prototype,t),i&&e(n,i),n}}(),s=("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},t(2));!function(i,r){o=function(){return r(i)}.call(n,t,n,e),!(void 0!==o&&(e.exports=o))}(void 0,function(e){"use strict";var n=function(){function e(){i(this,e);var n=document.createElement("fakeelement"),t={element:"[data-choice]",disabled:!1,maxItems:0,debug:!1,placeholder:!1,callbackOnInit:function(){},callbackOnRender:function(){},callbackOnKeyUp:function(){},callbackOnKeyDown:function(){},callbackOnEntry:function(){},callbackOnRemove:function(){}};this.options=t,this.initialised=!1,this.supports="querySelector"in document&&"addEventListener"in document&&"classList"in n,this.elements=document.querySelectorAll(this.options.element),this.onClick=this.onClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onChange=this.onChange.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onChange.bind(this)}return r(e,[{key:"isOpen",value:function(){}},{key:"isDisabled",value:function(){}},{key:"isEmpty",value:function(){}},{key:"onKeyDown",value:function(e){console.log("Key down"),13===e.keyCode&&e.target.value&&(this.addItem(e.target,e.target.value),e.target.value="")}},{key:"onFocus",value:function(e){console.log("Focus")}},{key:"onClick",value:function(e){console.log("Click")}},{key:"onChange",value:function(e){console.log("Change")}},{key:"addEventListeners",value:function(e){e.addEventListener("click",this.onClick),e.addEventListener("keydown",this.onKeyDown),e.addEventListener("change",this.onChange),e.addEventListener("focus",this.onFocus),e.addEventListener("blur",this.onBlur)}},{key:"removeEventListeners",value:function(e){e.removeEventListener("click",this.onClick),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("change",this.onChange),e.removeEventListener("focus",this.onFocus),e.removeEventListener("blur",this.onBlur)}},{key:"setPlaceholder",value:function(){}},{key:"setValue",value:function(){}},{key:"getValue",value:function(){}},{key:"getPlaceholder",value:function(){}},{key:"search",value:function(){}},{key:"addItem",value:function(e,n){console.log("Add item");var t=e.parentNode,i=(t.querySelector(".choice__list"),document.createElement("li"));i.classList.add("choice__item"),i.textContent=n,t.appendChild(i)}},{key:"removeItem",value:function(){}},{key:"removeAllItems",value:function(){}},{key:"createItemList",value:function(){}},{key:"init",value:function(){this.supports||console.error("Your browser doesn'nt support shit"),this.initialised=!0;for(var e=this.elements,n=e.length-1;n>=0;n--){var t=e[n];this.render(t)}}},{key:"render",value:function(e){console.log("Render");var n=document.createElement("div"),t=document.createElement("input"),i=document.createElement("ul");n.classList.add("choice","choice--active"),e.classList.add("choice__input","choice__input--original"),e.tabIndex="-1",e.setAttribute("style","display:none;"),(0,s.wrap)(e,n),i.classList.add("choice__list"),t.type="text",t.classList.add("choice__input","choice__input--cloned"),n.appendChild(i),n.appendChild(t),this.addEventListeners(t)}},{key:"destroy",value:function(){this.options=null,this.elements=null;for(var e=this.elements,n=e.length-1;n>=0;n--){var t=e[n];this.removeEventListeners(t)}}}]),e}(),t=new n;t.init(),console.log(t)})},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=(n.capitalise=function(e){return e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})},n.isType=function(e,n){var t=Object.prototype.toString.call(n).slice(8,-1);return void 0!==n&&null!==n&&t===e},n.whichTransitionEvent=function(){var e,n=document.createElement("fakeelement"),t={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in t)if(void 0!==n.style[e])return t[e]},n.whichAnimationEvent=function(){var e,n=document.createElement("fakeelement"),t={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(e in t)if(void 0!==n.style[e])return t[e]});n.getParentsUntil=function(e,n,t){for(var i=[];e&&e!==document;e=e.parentNode){if(n){var o=n.charAt(0);if("."===o&&e.classList.contains(n.substr(1)))break;if("#"===o&&e.id===n.substr(1))break;if("["===o&&e.hasAttribute(n.substr(1,n.length-1)))break;if(e.tagName.toLowerCase()===n)break}if(t){var r=t.charAt(0);"."===r&&e.classList.contains(t.substr(1))&&i.push(e),"#"===r&&e.id===t.substr(1)&&i.push(e),"["===r&&e.hasAttribute(t.substr(1,t.length-1))&&i.push(e),e.tagName.toLowerCase()===t&&i.push(e)}else i.push(e)}return 0===i.length?null:i},n.wrap=function(e,n){return n=n||document.createElement("div"),e.nextSibling?e.parentNode.insertBefore(n,e.nextSibling):e.parentNode.appendChild(n),n.appendChild(e)},n.getSiblings=function(e){for(var n=[],t=e.parentNode.firstChild;t;t=t.nextSibling)1===t.nodeType&&t!==e&&n.push(t);return n},n.findAncestor=function(e,n){for(;(e=e.parentElement)&&!e.classList.contains(n););return e},n.debounce=function(e,n,t){var i;return function(){var o=this,r=arguments,s=function(){i=null,t||e.apply(o,r)},a=t&&!i;clearTimeout(i),i=setTimeout(s,n),a&&e.apply(o,r)}},n.getElemDistance=function(e){var n=0;if(e.offsetParent)do n+=e.offsetTop,e=e.offsetParent;while(e);return n>=0?n:0},n.getElementOffset=function(e,n){var t=n;return t>1&&(t=1),t>0&&(t=0),Math.max(e.offsetHeight*t)},n.getScrollPosition=function(e){return"bottom"===e?Math.max((window.scrollY||window.pageYOffset)+(window.innerHeight||document.documentElement.clientHeight)):window.scrollY||window.pageYOffset},n.isInView=function(e,n,t){return this.getScrollPosition(n)>this.getElemDistance(e)+this.getElementOffset(e,t)},n.stripHTML=function(e){var n=document.createElement("DIV");return n.innerHTML=e,n.textContent||n.innerText||""},n.addAnimation=function(e,n){var i=t(),o=function r(){e.classList.remove(n),e.removeEventListener(i,r,!1)};e.classList.add(n),e.addEventListener(i,o,!1)},n.getRandomNumber=function(e,n){return Math.floor(Math.random()*(n-e)+e)}}]);