-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent-tracker.min.js
17 lines (17 loc) · 8.3 KB
/
event-tracker.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*!
* @license event-tracker.js Copyright(c) 2016 IMJ Co., Ltd.
* https://github.com/tsukurite/event-tracker.js
* Released under the MIT license.
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.eventTracker=e():t.eventTracker=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return"function"==typeof t||"[object Function]"===u.call(t)}function o(t){var e,n,r,o,i,a,c;if(!t||1!==t.nodeType)throw new TypeError("element must be HTMLElement");if(!t.hasAttributes())return{};for(o={},e=t.attributes,n=0,r=e.length;n<r;++n)i=e[n],a=i.name,c=i.value,/^data-/.test(a)&&(o[a.replace(/^data-/,"").replace(/-./g,function(t){return t.slice(1).toUpperCase()})]=c);return o}function i(t,e,n,i){var c;return null===v?void y.push({eventType:t,selector:e,data:n,callback:i}):(n?r(n)?c=function(t,e){a(n(t,e),i)}:"object"==typeof n&&(c=function(t,e){a(n,i)}):c=function(t,e){a(o(e),i)},void v.on(t,e,c))}function a(t,e){var n,o,i,a,c,u;if(null===t||"object"!=typeof t)throw new TypeError("data must be an Object");if(f.call(t,"hitType")){switch(n=h({},t),r(e)&&(n.fieldsObject=h({},t.fieldsObject,{hitCallback:e})),n.hitType){case"event":o=["hitType","category","action","label","value","fieldsObject"];break;case"social":o=["hitType","socialNetwork","socialAction","socialTarget","fieldsObject"];break;case"screenview":case"exception":o=["hitType","fieldsObject"];break;case"timing":o=["hitType","timingCategory","timingVar","timingValue","timingLabel","fieldsObject"];break;default:o=[]}for(i=[],a=0,c=o.length;a<c;++a)u=o[a],f.call(n,u)&&i.push(n[u]);l.apply(l,["send"].concat(i))}else n=h({},t,r(e)?{eventCallback:e}:{}),s.push(n)}var c=window;c.ga||(c.ga=function(){(c.ga.q=c.ga.q||[]).push(arguments)},c.ga.l=(new Date).getTime()),c.dataLayer||(c.dataLayer=[]);var l=c.ga,s=c.dataLayer,u=Object.prototype.toString,f=Object.prototype.hasOwnProperty,h=n(4),p=n(2),d=n(3),v=null,y=[];t.exports={getDataAttributes:o,track:i},d(function(){var t,e,n;for(v=p(document.body),t=0,e=y.length;t<e;++t)n=y[t],i(n.eventType,n.selector,n.data,n.callback);y=[]})},function(t,e){"use strict";function n(t){this.listenerMap=[{},{}],t&&this.root(t),this.handle=n.prototype.handle.bind(this)}function r(t,e){return t.toLowerCase()===e.tagName.toLowerCase()}function o(t,e){return this.rootElement===window?e===document:this.rootElement===e}function i(t,e){return t===e.id}t.exports=n,n.prototype.root=function(t){var e,n=this.listenerMap;if(this.rootElement){for(e in n[1])n[1].hasOwnProperty(e)&&this.rootElement.removeEventListener(e,this.handle,!0);for(e in n[0])n[0].hasOwnProperty(e)&&this.rootElement.removeEventListener(e,this.handle,!1)}if(!t||!t.addEventListener)return this.rootElement&&delete this.rootElement,this;this.rootElement=t;for(e in n[1])n[1].hasOwnProperty(e)&&this.rootElement.addEventListener(e,this.handle,!0);for(e in n[0])n[0].hasOwnProperty(e)&&this.rootElement.addEventListener(e,this.handle,!1);return this},n.prototype.captureForType=function(t){return["blur","error","focus","load","resize","scroll"].indexOf(t)!==-1},n.prototype.on=function(t,e,n,c){var l,s,u,f;if(!t)throw new TypeError("Invalid event type: "+t);if("function"==typeof e&&(c=n,n=e,e=null),void 0===c&&(c=this.captureForType(t)),"function"!=typeof n)throw new TypeError("Handler must be a type of Function");return l=this.rootElement,s=this.listenerMap[c?1:0],s[t]||(l&&l.addEventListener(t,this.handle,c),s[t]=[]),e?/^[a-z]+$/i.test(e)?(f=e,u=r):/^#[a-z0-9\-_]+$/i.test(e)?(f=e.slice(1),u=i):(f=e,u=a):(f=null,u=o.bind(this)),s[t].push({selector:e,handler:n,matcher:u,matcherParam:f}),this},n.prototype.off=function(t,e,n,r){var o,i,a,c,l;if("function"==typeof e&&(r=n,n=e,e=null),void 0===r)return this.off(t,e,n,!0),this.off(t,e,n,!1),this;if(a=this.listenerMap[r?1:0],!t){for(l in a)a.hasOwnProperty(l)&&this.off(l,e,n);return this}if(c=a[t],!c||!c.length)return this;for(o=c.length-1;o>=0;o--)i=c[o],e&&e!==i.selector||n&&n!==i.handler||c.splice(o,1);return c.length||(delete a[t],this.rootElement&&this.rootElement.removeEventListener(t,this.handle,r)),this},n.prototype.handle=function(t){var e,n,r,o,i,a,c,l=t.type,s=[],u="ftLabsDelegateIgnore";if(t[u]!==!0){switch(c=t.target,3===c.nodeType&&(c=c.parentNode),r=this.rootElement,o=t.eventPhase||(t.target!==t.currentTarget?3:2)){case 1:s=this.listenerMap[1][l];break;case 2:this.listenerMap[0]&&this.listenerMap[0][l]&&(s=s.concat(this.listenerMap[0][l])),this.listenerMap[1]&&this.listenerMap[1][l]&&(s=s.concat(this.listenerMap[1][l]));break;case 3:s=this.listenerMap[0][l]}for(n=s.length;c&&n;){for(e=0;e<n&&(i=s[e],i);e++)if(i.matcher.call(c,i.matcherParam,c)&&(a=this.fire(t,c,i)),a===!1)return t[u]=!0,void t.preventDefault();if(c===r)break;n=s.length,c=c.parentElement}}},n.prototype.fire=function(t,e,n){return n.handler.call(e,t,e)};var a=function(t){if(t){var e=t.prototype;return e.matches||e.matchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector}}(Element);n.prototype.destroy=function(){this.off(),this.root()}},function(t,e,n){"use strict";/**
* @preserve Create and manage a DOM event delegator.
*
* @version 0.3.0
* @codingstandard ftlabs-jsv2
* @copyright The Financial Times Limited [All Rights Reserved]
* @license MIT License (see LICENSE.txt)
*/
var r=n(1);t.exports=function(t){return new r(t)},t.exports.Delegate=r},function(t,e,n){/*!
* domready (c) Dustin Diaz 2014 - License MIT
*/
!function(e,n){t.exports=n()}("domready",function(){var t,e=[],n=document,r=n.documentElement.doScroll,o="DOMContentLoaded",i=(r?/^loaded|^c/:/^loaded|^i|^c/).test(n.readyState);return i||n.addEventListener(o,t=function(){for(n.removeEventListener(o,t),i=1;t=e.shift();)t()}),function(t){i?setTimeout(t,0):e.push(t)}})},function(t,e){function n(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function r(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function o(t,e){return function(n){return t(e(n))}}function i(t,e){var n=z(t)||v(t)?r(t.length,String):[],o=n.length,i=!!o;for(var a in t)!e&&!P.call(t,a)||i&&("length"==a||f(a,o))||n.push(a);return n}function a(t,e,n){var r=t[e];P.call(t,e)&&d(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function c(t){if(!p(t))return C(t);var e=[];for(var n in Object(t))P.call(t,n)&&"constructor"!=n&&e.push(n);return e}function l(t,e){return e=D(void 0===e?t.length-1:e,0),function(){for(var r=arguments,o=-1,i=D(r.length-e,0),a=Array(i);++o<i;)a[o]=r[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=r[o];return c[e]=a,n(t,this,c)}}function s(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var c=e[o],l=r?r(n[c],t[c],c,n,t):void 0;a(n,c,void 0===l?t[c]:l)}return n}function u(t){return l(function(e,n){var r=-1,o=n.length,i=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(i=t.length>3&&"function"==typeof i?(o--,i):void 0,a&&h(n[0],n[1],a)&&(i=o<3?void 0:i,o=1),e=Object(e);++r<o;){var c=n[r];c&&t(e,c,r,i)}return e})}function f(t,e){return e=null==e?O:e,!!e&&("number"==typeof t||L.test(t))&&t>-1&&t%1==0&&t<e}function h(t,e,n){if(!E(n))return!1;var r=typeof e;return!!("number"==r?y(n)&&f(e,n.length):"string"==r&&e in n)&&d(n[e],t)}function p(t){var e=t&&t.constructor,n="function"==typeof e&&e.prototype||k;return t===n}function d(t,e){return t===e||t!==t&&e!==e}function v(t){return m(t)&&P.call(t,"callee")&&(!A.call(t,"callee")||S.call(t)==T)}function y(t){return null!=t&&g(t.length)&&!b(t)}function m(t){return w(t)&&y(t)}function b(t){var e=E(t)?S.call(t):"";return e==M||e==x}function g(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=O}function E(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function w(t){return!!t&&"object"==typeof t}function j(t){return y(t)?i(t):c(t)}var O=9007199254740991,T="[object Arguments]",M="[object Function]",x="[object GeneratorFunction]",L=/^(?:0|[1-9]\d*)$/,k=Object.prototype,P=k.hasOwnProperty,S=k.toString,A=k.propertyIsEnumerable,C=o(Object.keys,Object),D=Math.max,F=!A.call({valueOf:1},"valueOf"),z=Array.isArray,I=u(function(t,e){if(F||p(e)||y(e))return void s(e,j(e),t);for(var n in e)P.call(e,n)&&a(t,n,e[n])});t.exports=I}])});