dom7.js 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. /**
  2. * Dom7 2.1.5
  3. * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
  4. * http://framework7.io/docs/dom.html
  5. *
  6. * Copyright 2020, Vladimir Kharlampidi
  7. * The iDangero.us
  8. * http://www.idangero.us/
  9. *
  10. * Licensed under MIT
  11. *
  12. * Released on: May 15, 2020
  13. */
  14. (function (global, factory) {
  15. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  16. typeof define === 'function' && define.amd ? define(factory) :
  17. (global = global || self, global.Dom7 = factory());
  18. }(this, function () { 'use strict';
  19. /**
  20. * SSR Window 2.0.0
  21. * Better handling for window object in SSR environment
  22. * https://github.com/nolimits4web/ssr-window
  23. *
  24. * Copyright 2020, Vladimir Kharlampidi
  25. *
  26. * Licensed under MIT
  27. *
  28. * Released on: May 12, 2020
  29. */
  30. /* eslint-disable no-param-reassign */
  31. function isObject(obj) {
  32. return (obj !== null &&
  33. typeof obj === 'object' &&
  34. 'constructor' in obj &&
  35. obj.constructor === Object);
  36. }
  37. function extend(target, src) {
  38. if (target === void 0) { target = {}; }
  39. if (src === void 0) { src = {}; }
  40. Object.keys(src).forEach(function (key) {
  41. if (typeof target[key] === 'undefined')
  42. { target[key] = src[key]; }
  43. else if (isObject(src[key]) &&
  44. isObject(target[key]) &&
  45. Object.keys(src[key]).length > 0) {
  46. extend(target[key], src[key]);
  47. }
  48. });
  49. }
  50. var doc = typeof document !== 'undefined' ? document : {};
  51. var ssrDocument = {
  52. body: {},
  53. addEventListener: function () { },
  54. removeEventListener: function () { },
  55. activeElement: {
  56. blur: function () { },
  57. nodeName: '',
  58. },
  59. querySelector: function () {
  60. return null;
  61. },
  62. querySelectorAll: function () {
  63. return [];
  64. },
  65. getElementById: function () {
  66. return null;
  67. },
  68. createEvent: function () {
  69. return {
  70. initEvent: function () { },
  71. };
  72. },
  73. createElement: function () {
  74. return {
  75. children: [],
  76. childNodes: [],
  77. style: {},
  78. setAttribute: function () { },
  79. getElementsByTagName: function () {
  80. return [];
  81. },
  82. };
  83. },
  84. createElementNS: function () {
  85. return {};
  86. },
  87. importNode: function () {
  88. return null;
  89. },
  90. location: {
  91. hash: '',
  92. host: '',
  93. hostname: '',
  94. href: '',
  95. origin: '',
  96. pathname: '',
  97. protocol: '',
  98. search: '',
  99. },
  100. };
  101. extend(doc, ssrDocument);
  102. var win = typeof window !== 'undefined' ? window : {};
  103. var ssrWindow = {
  104. document: ssrDocument,
  105. navigator: {
  106. userAgent: '',
  107. },
  108. location: {
  109. hash: '',
  110. host: '',
  111. hostname: '',
  112. href: '',
  113. origin: '',
  114. pathname: '',
  115. protocol: '',
  116. search: '',
  117. },
  118. history: {
  119. replaceState: function () { },
  120. pushState: function () { },
  121. go: function () { },
  122. back: function () { },
  123. },
  124. CustomEvent: function CustomEvent() {
  125. return this;
  126. },
  127. addEventListener: function () { },
  128. removeEventListener: function () { },
  129. getComputedStyle: function () {
  130. return {
  131. getPropertyValue: function () {
  132. return '';
  133. },
  134. };
  135. },
  136. Image: function () { },
  137. Date: function () { },
  138. screen: {},
  139. setTimeout: function () { },
  140. clearTimeout: function () { },
  141. matchMedia: function () {
  142. return {};
  143. },
  144. };
  145. extend(win, ssrWindow);
  146. var Dom7 = function Dom7(arr) {
  147. var self = this;
  148. // Create array-like object
  149. for (var i = 0; i < arr.length; i += 1) {
  150. self[i] = arr[i];
  151. }
  152. self.length = arr.length;
  153. // Return collection with methods
  154. return this;
  155. };
  156. function $(selector, context) {
  157. var arr = [];
  158. var i = 0;
  159. if (selector && !context) {
  160. if (selector instanceof Dom7) {
  161. return selector;
  162. }
  163. }
  164. if (selector) {
  165. // String
  166. if (typeof selector === 'string') {
  167. var els;
  168. var tempParent;
  169. var html = selector.trim();
  170. if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
  171. var toCreate = 'div';
  172. if (html.indexOf('<li') === 0) { toCreate = 'ul'; }
  173. if (html.indexOf('<tr') === 0) { toCreate = 'tbody'; }
  174. if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) { toCreate = 'tr'; }
  175. if (html.indexOf('<tbody') === 0) { toCreate = 'table'; }
  176. if (html.indexOf('<option') === 0) { toCreate = 'select'; }
  177. tempParent = doc.createElement(toCreate);
  178. tempParent.innerHTML = html;
  179. for (i = 0; i < tempParent.childNodes.length; i += 1) {
  180. arr.push(tempParent.childNodes[i]);
  181. }
  182. } else {
  183. if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) {
  184. // Pure ID selector
  185. els = [doc.getElementById(selector.trim().split('#')[1])];
  186. } else {
  187. // Other selectors
  188. els = (context || doc).querySelectorAll(selector.trim());
  189. }
  190. for (i = 0; i < els.length; i += 1) {
  191. if (els[i]) { arr.push(els[i]); }
  192. }
  193. }
  194. } else if (selector.nodeType || selector === win || selector === doc) {
  195. // Node/element
  196. arr.push(selector);
  197. } else if (selector.length > 0 && selector[0].nodeType) {
  198. // Array of elements or instance of Dom
  199. for (i = 0; i < selector.length; i += 1) {
  200. arr.push(selector[i]);
  201. }
  202. }
  203. }
  204. return new Dom7(arr);
  205. }
  206. $.fn = Dom7.prototype;
  207. $.Class = Dom7;
  208. $.Dom7 = Dom7;
  209. function unique(arr) {
  210. var uniqueArray = [];
  211. for (var i = 0; i < arr.length; i += 1) {
  212. if (uniqueArray.indexOf(arr[i]) === -1) { uniqueArray.push(arr[i]); }
  213. }
  214. return uniqueArray;
  215. }
  216. function toCamelCase(string) {
  217. return string.toLowerCase().replace(/-(.)/g, function (match, group1) { return group1.toUpperCase(); });
  218. }
  219. function requestAnimationFrame(callback) {
  220. if (win.requestAnimationFrame) { return win.requestAnimationFrame(callback); }
  221. else if (win.webkitRequestAnimationFrame) { return win.webkitRequestAnimationFrame(callback); }
  222. return win.setTimeout(callback, 1000 / 60);
  223. }
  224. function cancelAnimationFrame(id) {
  225. if (win.cancelAnimationFrame) { return win.cancelAnimationFrame(id); }
  226. else if (win.webkitCancelAnimationFrame) { return win.webkitCancelAnimationFrame(id); }
  227. return win.clearTimeout(id);
  228. }
  229. // Classes and attributes
  230. function addClass(className) {
  231. if (typeof className === 'undefined') {
  232. return this;
  233. }
  234. var classes = className.split(' ');
  235. for (var i = 0; i < classes.length; i += 1) {
  236. for (var j = 0; j < this.length; j += 1) {
  237. if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.add(classes[i]); }
  238. }
  239. }
  240. return this;
  241. }
  242. function removeClass(className) {
  243. var classes = className.split(' ');
  244. for (var i = 0; i < classes.length; i += 1) {
  245. for (var j = 0; j < this.length; j += 1) {
  246. if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.remove(classes[i]); }
  247. }
  248. }
  249. return this;
  250. }
  251. function hasClass(className) {
  252. if (!this[0]) { return false; }
  253. return this[0].classList.contains(className);
  254. }
  255. function toggleClass(className) {
  256. var classes = className.split(' ');
  257. for (var i = 0; i < classes.length; i += 1) {
  258. for (var j = 0; j < this.length; j += 1) {
  259. if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.toggle(classes[i]); }
  260. }
  261. }
  262. return this;
  263. }
  264. function attr(attrs, value) {
  265. var arguments$1 = arguments;
  266. if (arguments.length === 1 && typeof attrs === 'string') {
  267. // Get attr
  268. if (this[0]) { return this[0].getAttribute(attrs); }
  269. return undefined;
  270. }
  271. // Set attrs
  272. for (var i = 0; i < this.length; i += 1) {
  273. if (arguments$1.length === 2) {
  274. // String
  275. this[i].setAttribute(attrs, value);
  276. } else {
  277. // Object
  278. // eslint-disable-next-line
  279. for (var attrName in attrs) {
  280. this[i][attrName] = attrs[attrName];
  281. this[i].setAttribute(attrName, attrs[attrName]);
  282. }
  283. }
  284. }
  285. return this;
  286. }
  287. // eslint-disable-next-line
  288. function removeAttr(attr) {
  289. for (var i = 0; i < this.length; i += 1) {
  290. this[i].removeAttribute(attr);
  291. }
  292. return this;
  293. }
  294. // eslint-disable-next-line
  295. function prop(props, value) {
  296. var arguments$1 = arguments;
  297. if (arguments.length === 1 && typeof props === 'string') {
  298. // Get prop
  299. if (this[0]) { return this[0][props]; }
  300. } else {
  301. // Set props
  302. for (var i = 0; i < this.length; i += 1) {
  303. if (arguments$1.length === 2) {
  304. // String
  305. this[i][props] = value;
  306. } else {
  307. // Object
  308. // eslint-disable-next-line
  309. for (var propName in props) {
  310. this[i][propName] = props[propName];
  311. }
  312. }
  313. }
  314. return this;
  315. }
  316. }
  317. function data(key, value) {
  318. var el;
  319. if (typeof value === 'undefined') {
  320. el = this[0];
  321. // Get value
  322. if (el) {
  323. if (el.dom7ElementDataStorage && (key in el.dom7ElementDataStorage)) {
  324. return el.dom7ElementDataStorage[key];
  325. }
  326. var dataKey = el.getAttribute(("data-" + key));
  327. if (dataKey) {
  328. return dataKey;
  329. }
  330. return undefined;
  331. }
  332. return undefined;
  333. }
  334. // Set value
  335. for (var i = 0; i < this.length; i += 1) {
  336. el = this[i];
  337. if (!el.dom7ElementDataStorage) { el.dom7ElementDataStorage = {}; }
  338. el.dom7ElementDataStorage[key] = value;
  339. }
  340. return this;
  341. }
  342. function removeData(key) {
  343. for (var i = 0; i < this.length; i += 1) {
  344. var el = this[i];
  345. if (el.dom7ElementDataStorage && el.dom7ElementDataStorage[key]) {
  346. el.dom7ElementDataStorage[key] = null;
  347. delete el.dom7ElementDataStorage[key];
  348. }
  349. }
  350. }
  351. function dataset() {
  352. var el = this[0];
  353. if (!el) { return undefined; }
  354. var dataset = {}; // eslint-disable-line
  355. if (el.dataset) {
  356. // eslint-disable-next-line
  357. for (var dataKey in el.dataset) {
  358. dataset[dataKey] = el.dataset[dataKey];
  359. }
  360. } else {
  361. for (var i = 0; i < el.attributes.length; i += 1) {
  362. // eslint-disable-next-line
  363. var attr = el.attributes[i];
  364. if (attr.name.indexOf('data-') >= 0) {
  365. dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value;
  366. }
  367. }
  368. }
  369. // eslint-disable-next-line
  370. for (var key in dataset) {
  371. if (dataset[key] === 'false') { dataset[key] = false; }
  372. else if (dataset[key] === 'true') { dataset[key] = true; }
  373. else if (parseFloat(dataset[key]) === dataset[key] * 1) { dataset[key] *= 1; }
  374. }
  375. return dataset;
  376. }
  377. function val(value) {
  378. var dom = this;
  379. if (typeof value === 'undefined') {
  380. if (dom[0]) {
  381. if (dom[0].multiple && dom[0].nodeName.toLowerCase() === 'select') {
  382. var values = [];
  383. for (var i = 0; i < dom[0].selectedOptions.length; i += 1) {
  384. values.push(dom[0].selectedOptions[i].value);
  385. }
  386. return values;
  387. }
  388. return dom[0].value;
  389. }
  390. return undefined;
  391. }
  392. for (var i$1 = 0; i$1 < dom.length; i$1 += 1) {
  393. var el = dom[i$1];
  394. if (Array.isArray(value) && el.multiple && el.nodeName.toLowerCase() === 'select') {
  395. for (var j = 0; j < el.options.length; j += 1) {
  396. el.options[j].selected = value.indexOf(el.options[j].value) >= 0;
  397. }
  398. } else {
  399. el.value = value;
  400. }
  401. }
  402. return dom;
  403. }
  404. // Transforms
  405. // eslint-disable-next-line
  406. function transform(transform) {
  407. for (var i = 0; i < this.length; i += 1) {
  408. var elStyle = this[i].style;
  409. elStyle.webkitTransform = transform;
  410. elStyle.transform = transform;
  411. }
  412. return this;
  413. }
  414. function transition(duration) {
  415. if (typeof duration !== 'string') {
  416. duration = duration + "ms"; // eslint-disable-line
  417. }
  418. for (var i = 0; i < this.length; i += 1) {
  419. var elStyle = this[i].style;
  420. elStyle.webkitTransitionDuration = duration;
  421. elStyle.transitionDuration = duration;
  422. }
  423. return this;
  424. }
  425. // Events
  426. function on() {
  427. var assign;
  428. var args = [], len = arguments.length;
  429. while ( len-- ) args[ len ] = arguments[ len ];
  430. var eventType = args[0];
  431. var targetSelector = args[1];
  432. var listener = args[2];
  433. var capture = args[3];
  434. if (typeof args[1] === 'function') {
  435. (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]);
  436. targetSelector = undefined;
  437. }
  438. if (!capture) { capture = false; }
  439. function handleLiveEvent(e) {
  440. var target = e.target;
  441. if (!target) { return; }
  442. var eventData = e.target.dom7EventData || [];
  443. if (eventData.indexOf(e) < 0) {
  444. eventData.unshift(e);
  445. }
  446. if ($(target).is(targetSelector)) { listener.apply(target, eventData); }
  447. else {
  448. var parents = $(target).parents(); // eslint-disable-line
  449. for (var k = 0; k < parents.length; k += 1) {
  450. if ($(parents[k]).is(targetSelector)) { listener.apply(parents[k], eventData); }
  451. }
  452. }
  453. }
  454. function handleEvent(e) {
  455. var eventData = e && e.target ? e.target.dom7EventData || [] : [];
  456. if (eventData.indexOf(e) < 0) {
  457. eventData.unshift(e);
  458. }
  459. listener.apply(this, eventData);
  460. }
  461. var events = eventType.split(' ');
  462. var j;
  463. for (var i = 0; i < this.length; i += 1) {
  464. var el = this[i];
  465. if (!targetSelector) {
  466. for (j = 0; j < events.length; j += 1) {
  467. var event = events[j];
  468. if (!el.dom7Listeners) { el.dom7Listeners = {}; }
  469. if (!el.dom7Listeners[event]) { el.dom7Listeners[event] = []; }
  470. el.dom7Listeners[event].push({
  471. listener: listener,
  472. proxyListener: handleEvent,
  473. });
  474. el.addEventListener(event, handleEvent, capture);
  475. }
  476. } else {
  477. // Live events
  478. for (j = 0; j < events.length; j += 1) {
  479. var event$1 = events[j];
  480. if (!el.dom7LiveListeners) { el.dom7LiveListeners = {}; }
  481. if (!el.dom7LiveListeners[event$1]) { el.dom7LiveListeners[event$1] = []; }
  482. el.dom7LiveListeners[event$1].push({
  483. listener: listener,
  484. proxyListener: handleLiveEvent,
  485. });
  486. el.addEventListener(event$1, handleLiveEvent, capture);
  487. }
  488. }
  489. }
  490. return this;
  491. }
  492. function off() {
  493. var assign;
  494. var args = [], len = arguments.length;
  495. while ( len-- ) args[ len ] = arguments[ len ];
  496. var eventType = args[0];
  497. var targetSelector = args[1];
  498. var listener = args[2];
  499. var capture = args[3];
  500. if (typeof args[1] === 'function') {
  501. (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]);
  502. targetSelector = undefined;
  503. }
  504. if (!capture) { capture = false; }
  505. var events = eventType.split(' ');
  506. for (var i = 0; i < events.length; i += 1) {
  507. var event = events[i];
  508. for (var j = 0; j < this.length; j += 1) {
  509. var el = this[j];
  510. var handlers = (void 0);
  511. if (!targetSelector && el.dom7Listeners) {
  512. handlers = el.dom7Listeners[event];
  513. } else if (targetSelector && el.dom7LiveListeners) {
  514. handlers = el.dom7LiveListeners[event];
  515. }
  516. if (handlers && handlers.length) {
  517. for (var k = handlers.length - 1; k >= 0; k -= 1) {
  518. var handler = handlers[k];
  519. if (listener && handler.listener === listener) {
  520. el.removeEventListener(event, handler.proxyListener, capture);
  521. handlers.splice(k, 1);
  522. } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {
  523. el.removeEventListener(event, handler.proxyListener, capture);
  524. handlers.splice(k, 1);
  525. } else if (!listener) {
  526. el.removeEventListener(event, handler.proxyListener, capture);
  527. handlers.splice(k, 1);
  528. }
  529. }
  530. }
  531. }
  532. }
  533. return this;
  534. }
  535. function once() {
  536. var assign;
  537. var args = [], len = arguments.length;
  538. while ( len-- ) args[ len ] = arguments[ len ];
  539. var dom = this;
  540. var eventName = args[0];
  541. var targetSelector = args[1];
  542. var listener = args[2];
  543. var capture = args[3];
  544. if (typeof args[1] === 'function') {
  545. (assign = args, eventName = assign[0], listener = assign[1], capture = assign[2]);
  546. targetSelector = undefined;
  547. }
  548. function onceHandler() {
  549. var eventArgs = [], len = arguments.length;
  550. while ( len-- ) eventArgs[ len ] = arguments[ len ];
  551. listener.apply(this, eventArgs);
  552. dom.off(eventName, targetSelector, onceHandler, capture);
  553. if (onceHandler.dom7proxy) {
  554. delete onceHandler.dom7proxy;
  555. }
  556. }
  557. onceHandler.dom7proxy = listener;
  558. return dom.on(eventName, targetSelector, onceHandler, capture);
  559. }
  560. function trigger() {
  561. var args = [], len = arguments.length;
  562. while ( len-- ) args[ len ] = arguments[ len ];
  563. var events = args[0].split(' ');
  564. var eventData = args[1];
  565. for (var i = 0; i < events.length; i += 1) {
  566. var event = events[i];
  567. for (var j = 0; j < this.length; j += 1) {
  568. var el = this[j];
  569. var evt = (void 0);
  570. try {
  571. evt = new win.CustomEvent(event, {
  572. detail: eventData,
  573. bubbles: true,
  574. cancelable: true,
  575. });
  576. } catch (e) {
  577. evt = doc.createEvent('Event');
  578. evt.initEvent(event, true, true);
  579. evt.detail = eventData;
  580. }
  581. // eslint-disable-next-line
  582. el.dom7EventData = args.filter(function (data, dataIndex) { return dataIndex > 0; });
  583. el.dispatchEvent(evt);
  584. el.dom7EventData = [];
  585. delete el.dom7EventData;
  586. }
  587. }
  588. return this;
  589. }
  590. function transitionEnd(callback) {
  591. var events = ['webkitTransitionEnd', 'transitionend'];
  592. var dom = this;
  593. var i;
  594. function fireCallBack(e) {
  595. /* jshint validthis:true */
  596. if (e.target !== this) { return; }
  597. callback.call(this, e);
  598. for (i = 0; i < events.length; i += 1) {
  599. dom.off(events[i], fireCallBack);
  600. }
  601. }
  602. if (callback) {
  603. for (i = 0; i < events.length; i += 1) {
  604. dom.on(events[i], fireCallBack);
  605. }
  606. }
  607. return this;
  608. }
  609. function animationEnd(callback) {
  610. var events = ['webkitAnimationEnd', 'animationend'];
  611. var dom = this;
  612. var i;
  613. function fireCallBack(e) {
  614. if (e.target !== this) { return; }
  615. callback.call(this, e);
  616. for (i = 0; i < events.length; i += 1) {
  617. dom.off(events[i], fireCallBack);
  618. }
  619. }
  620. if (callback) {
  621. for (i = 0; i < events.length; i += 1) {
  622. dom.on(events[i], fireCallBack);
  623. }
  624. }
  625. return this;
  626. }
  627. // Sizing/Styles
  628. function width() {
  629. if (this[0] === win) {
  630. return win.innerWidth;
  631. }
  632. if (this.length > 0) {
  633. return parseFloat(this.css('width'));
  634. }
  635. return null;
  636. }
  637. function outerWidth(includeMargins) {
  638. if (this.length > 0) {
  639. if (includeMargins) {
  640. // eslint-disable-next-line
  641. var styles = this.styles();
  642. return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));
  643. }
  644. return this[0].offsetWidth;
  645. }
  646. return null;
  647. }
  648. function height() {
  649. if (this[0] === win) {
  650. return win.innerHeight;
  651. }
  652. if (this.length > 0) {
  653. return parseFloat(this.css('height'));
  654. }
  655. return null;
  656. }
  657. function outerHeight(includeMargins) {
  658. if (this.length > 0) {
  659. if (includeMargins) {
  660. // eslint-disable-next-line
  661. var styles = this.styles();
  662. return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));
  663. }
  664. return this[0].offsetHeight;
  665. }
  666. return null;
  667. }
  668. function offset() {
  669. if (this.length > 0) {
  670. var el = this[0];
  671. var box = el.getBoundingClientRect();
  672. var body = doc.body;
  673. var clientTop = el.clientTop || body.clientTop || 0;
  674. var clientLeft = el.clientLeft || body.clientLeft || 0;
  675. var scrollTop = el === win ? win.scrollY : el.scrollTop;
  676. var scrollLeft = el === win ? win.scrollX : el.scrollLeft;
  677. return {
  678. top: (box.top + scrollTop) - clientTop,
  679. left: (box.left + scrollLeft) - clientLeft,
  680. };
  681. }
  682. return null;
  683. }
  684. function hide() {
  685. for (var i = 0; i < this.length; i += 1) {
  686. this[i].style.display = 'none';
  687. }
  688. return this;
  689. }
  690. function show() {
  691. for (var i = 0; i < this.length; i += 1) {
  692. var el = this[i];
  693. if (el.style.display === 'none') {
  694. el.style.display = '';
  695. }
  696. if (win.getComputedStyle(el, null).getPropertyValue('display') === 'none') {
  697. // Still not visible
  698. el.style.display = 'block';
  699. }
  700. }
  701. return this;
  702. }
  703. function styles() {
  704. if (this[0]) { return win.getComputedStyle(this[0], null); }
  705. return {};
  706. }
  707. function css(props, value) {
  708. var i;
  709. if (arguments.length === 1) {
  710. if (typeof props === 'string') {
  711. if (this[0]) { return win.getComputedStyle(this[0], null).getPropertyValue(props); }
  712. } else {
  713. for (i = 0; i < this.length; i += 1) {
  714. // eslint-disable-next-line
  715. for (var prop in props) {
  716. this[i].style[prop] = props[prop];
  717. }
  718. }
  719. return this;
  720. }
  721. }
  722. if (arguments.length === 2 && typeof props === 'string') {
  723. for (i = 0; i < this.length; i += 1) {
  724. this[i].style[props] = value;
  725. }
  726. return this;
  727. }
  728. return this;
  729. }
  730. // Dom manipulation
  731. function toArray() {
  732. var arr = [];
  733. for (var i = 0; i < this.length; i += 1) {
  734. arr.push(this[i]);
  735. }
  736. return arr;
  737. }
  738. // Iterate over the collection passing elements to `callback`
  739. function each(callback) {
  740. // Don't bother continuing without a callback
  741. if (!callback) { return this; }
  742. // Iterate over the current collection
  743. for (var i = 0; i < this.length; i += 1) {
  744. // If the callback returns false
  745. if (callback.call(this[i], i, this[i]) === false) {
  746. // End the loop early
  747. return this;
  748. }
  749. }
  750. // Return `this` to allow chained DOM operations
  751. return this;
  752. }
  753. function forEach(callback) {
  754. // Don't bother continuing without a callback
  755. if (!callback) { return this; }
  756. // Iterate over the current collection
  757. for (var i = 0; i < this.length; i += 1) {
  758. // If the callback returns false
  759. if (callback.call(this[i], this[i], i) === false) {
  760. // End the loop early
  761. return this;
  762. }
  763. }
  764. // Return `this` to allow chained DOM operations
  765. return this;
  766. }
  767. function filter(callback) {
  768. var matchedItems = [];
  769. var dom = this;
  770. for (var i = 0; i < dom.length; i += 1) {
  771. if (callback.call(dom[i], i, dom[i])) { matchedItems.push(dom[i]); }
  772. }
  773. return new Dom7(matchedItems);
  774. }
  775. function map(callback) {
  776. var modifiedItems = [];
  777. var dom = this;
  778. for (var i = 0; i < dom.length; i += 1) {
  779. modifiedItems.push(callback.call(dom[i], i, dom[i]));
  780. }
  781. return new Dom7(modifiedItems);
  782. }
  783. // eslint-disable-next-line
  784. function html(html) {
  785. if (typeof html === 'undefined') {
  786. return this[0] ? this[0].innerHTML : undefined;
  787. }
  788. for (var i = 0; i < this.length; i += 1) {
  789. this[i].innerHTML = html;
  790. }
  791. return this;
  792. }
  793. // eslint-disable-next-line
  794. function text(text) {
  795. if (typeof text === 'undefined') {
  796. if (this[0]) {
  797. return this[0].textContent.trim();
  798. }
  799. return null;
  800. }
  801. for (var i = 0; i < this.length; i += 1) {
  802. this[i].textContent = text;
  803. }
  804. return this;
  805. }
  806. function is(selector) {
  807. var el = this[0];
  808. var compareWith;
  809. var i;
  810. if (!el || typeof selector === 'undefined') { return false; }
  811. if (typeof selector === 'string') {
  812. if (el.matches) { return el.matches(selector); }
  813. else if (el.webkitMatchesSelector) { return el.webkitMatchesSelector(selector); }
  814. else if (el.msMatchesSelector) { return el.msMatchesSelector(selector); }
  815. compareWith = $(selector);
  816. for (i = 0; i < compareWith.length; i += 1) {
  817. if (compareWith[i] === el) { return true; }
  818. }
  819. return false;
  820. } else if (selector === doc) { return el === doc; }
  821. else if (selector === win) { return el === win; }
  822. if (selector.nodeType || selector instanceof Dom7) {
  823. compareWith = selector.nodeType ? [selector] : selector;
  824. for (i = 0; i < compareWith.length; i += 1) {
  825. if (compareWith[i] === el) { return true; }
  826. }
  827. return false;
  828. }
  829. return false;
  830. }
  831. function indexOf(el) {
  832. for (var i = 0; i < this.length; i += 1) {
  833. if (this[i] === el) { return i; }
  834. }
  835. return -1;
  836. }
  837. function index() {
  838. var child = this[0];
  839. var i;
  840. if (child) {
  841. i = 0;
  842. // eslint-disable-next-line
  843. while ((child = child.previousSibling) !== null) {
  844. if (child.nodeType === 1) { i += 1; }
  845. }
  846. return i;
  847. }
  848. return undefined;
  849. }
  850. // eslint-disable-next-line
  851. function eq(index) {
  852. if (typeof index === 'undefined') { return this; }
  853. var length = this.length;
  854. var returnIndex;
  855. if (index > length - 1) {
  856. return new Dom7([]);
  857. }
  858. if (index < 0) {
  859. returnIndex = length + index;
  860. if (returnIndex < 0) { return new Dom7([]); }
  861. return new Dom7([this[returnIndex]]);
  862. }
  863. return new Dom7([this[index]]);
  864. }
  865. function append() {
  866. var args = [], len = arguments.length;
  867. while ( len-- ) args[ len ] = arguments[ len ];
  868. var newChild;
  869. for (var k = 0; k < args.length; k += 1) {
  870. newChild = args[k];
  871. for (var i = 0; i < this.length; i += 1) {
  872. if (typeof newChild === 'string') {
  873. var tempDiv = doc.createElement('div');
  874. tempDiv.innerHTML = newChild;
  875. while (tempDiv.firstChild) {
  876. this[i].appendChild(tempDiv.firstChild);
  877. }
  878. } else if (newChild instanceof Dom7) {
  879. for (var j = 0; j < newChild.length; j += 1) {
  880. this[i].appendChild(newChild[j]);
  881. }
  882. } else {
  883. this[i].appendChild(newChild);
  884. }
  885. }
  886. }
  887. return this;
  888. }
  889. // eslint-disable-next-line
  890. function appendTo(parent) {
  891. $(parent).append(this);
  892. return this;
  893. }
  894. function prepend(newChild) {
  895. var i;
  896. var j;
  897. for (i = 0; i < this.length; i += 1) {
  898. if (typeof newChild === 'string') {
  899. var tempDiv = doc.createElement('div');
  900. tempDiv.innerHTML = newChild;
  901. for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {
  902. this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
  903. }
  904. } else if (newChild instanceof Dom7) {
  905. for (j = 0; j < newChild.length; j += 1) {
  906. this[i].insertBefore(newChild[j], this[i].childNodes[0]);
  907. }
  908. } else {
  909. this[i].insertBefore(newChild, this[i].childNodes[0]);
  910. }
  911. }
  912. return this;
  913. }
  914. // eslint-disable-next-line
  915. function prependTo(parent) {
  916. $(parent).prepend(this);
  917. return this;
  918. }
  919. function insertBefore(selector) {
  920. var before = $(selector);
  921. for (var i = 0; i < this.length; i += 1) {
  922. if (before.length === 1) {
  923. before[0].parentNode.insertBefore(this[i], before[0]);
  924. } else if (before.length > 1) {
  925. for (var j = 0; j < before.length; j += 1) {
  926. before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);
  927. }
  928. }
  929. }
  930. }
  931. function insertAfter(selector) {
  932. var after = $(selector);
  933. for (var i = 0; i < this.length; i += 1) {
  934. if (after.length === 1) {
  935. after[0].parentNode.insertBefore(this[i], after[0].nextSibling);
  936. } else if (after.length > 1) {
  937. for (var j = 0; j < after.length; j += 1) {
  938. after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);
  939. }
  940. }
  941. }
  942. }
  943. function next(selector) {
  944. if (this.length > 0) {
  945. if (selector) {
  946. if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {
  947. return new Dom7([this[0].nextElementSibling]);
  948. }
  949. return new Dom7([]);
  950. }
  951. if (this[0].nextElementSibling) { return new Dom7([this[0].nextElementSibling]); }
  952. return new Dom7([]);
  953. }
  954. return new Dom7([]);
  955. }
  956. function nextAll(selector) {
  957. var nextEls = [];
  958. var el = this[0];
  959. if (!el) { return new Dom7([]); }
  960. while (el.nextElementSibling) {
  961. var next = el.nextElementSibling; // eslint-disable-line
  962. if (selector) {
  963. if ($(next).is(selector)) { nextEls.push(next); }
  964. } else { nextEls.push(next); }
  965. el = next;
  966. }
  967. return new Dom7(nextEls);
  968. }
  969. function prev(selector) {
  970. if (this.length > 0) {
  971. var el = this[0];
  972. if (selector) {
  973. if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {
  974. return new Dom7([el.previousElementSibling]);
  975. }
  976. return new Dom7([]);
  977. }
  978. if (el.previousElementSibling) { return new Dom7([el.previousElementSibling]); }
  979. return new Dom7([]);
  980. }
  981. return new Dom7([]);
  982. }
  983. function prevAll(selector) {
  984. var prevEls = [];
  985. var el = this[0];
  986. if (!el) { return new Dom7([]); }
  987. while (el.previousElementSibling) {
  988. var prev = el.previousElementSibling; // eslint-disable-line
  989. if (selector) {
  990. if ($(prev).is(selector)) { prevEls.push(prev); }
  991. } else { prevEls.push(prev); }
  992. el = prev;
  993. }
  994. return new Dom7(prevEls);
  995. }
  996. function siblings(selector) {
  997. return this.nextAll(selector).add(this.prevAll(selector));
  998. }
  999. function parent(selector) {
  1000. var parents = []; // eslint-disable-line
  1001. for (var i = 0; i < this.length; i += 1) {
  1002. if (this[i].parentNode !== null) {
  1003. if (selector) {
  1004. if ($(this[i].parentNode).is(selector)) { parents.push(this[i].parentNode); }
  1005. } else {
  1006. parents.push(this[i].parentNode);
  1007. }
  1008. }
  1009. }
  1010. return $(unique(parents));
  1011. }
  1012. function parents(selector) {
  1013. var parents = []; // eslint-disable-line
  1014. for (var i = 0; i < this.length; i += 1) {
  1015. var parent = this[i].parentNode; // eslint-disable-line
  1016. while (parent) {
  1017. if (selector) {
  1018. if ($(parent).is(selector)) { parents.push(parent); }
  1019. } else {
  1020. parents.push(parent);
  1021. }
  1022. parent = parent.parentNode;
  1023. }
  1024. }
  1025. return $(unique(parents));
  1026. }
  1027. function closest(selector) {
  1028. var closest = this; // eslint-disable-line
  1029. if (typeof selector === 'undefined') {
  1030. return new Dom7([]);
  1031. }
  1032. if (!closest.is(selector)) {
  1033. closest = closest.parents(selector).eq(0);
  1034. }
  1035. return closest;
  1036. }
  1037. function find(selector) {
  1038. var foundElements = [];
  1039. for (var i = 0; i < this.length; i += 1) {
  1040. var found = this[i].querySelectorAll(selector);
  1041. for (var j = 0; j < found.length; j += 1) {
  1042. foundElements.push(found[j]);
  1043. }
  1044. }
  1045. return new Dom7(foundElements);
  1046. }
  1047. function children(selector) {
  1048. var children = []; // eslint-disable-line
  1049. for (var i = 0; i < this.length; i += 1) {
  1050. var childNodes = this[i].childNodes;
  1051. for (var j = 0; j < childNodes.length; j += 1) {
  1052. if (!selector) {
  1053. if (childNodes[j].nodeType === 1) { children.push(childNodes[j]); }
  1054. } else if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) {
  1055. children.push(childNodes[j]);
  1056. }
  1057. }
  1058. }
  1059. return new Dom7(unique(children));
  1060. }
  1061. function remove() {
  1062. for (var i = 0; i < this.length; i += 1) {
  1063. if (this[i].parentNode) { this[i].parentNode.removeChild(this[i]); }
  1064. }
  1065. return this;
  1066. }
  1067. function detach() {
  1068. return this.remove();
  1069. }
  1070. function add() {
  1071. var args = [], len = arguments.length;
  1072. while ( len-- ) args[ len ] = arguments[ len ];
  1073. var dom = this;
  1074. var i;
  1075. var j;
  1076. for (i = 0; i < args.length; i += 1) {
  1077. var toAdd = $(args[i]);
  1078. for (j = 0; j < toAdd.length; j += 1) {
  1079. dom[dom.length] = toAdd[j];
  1080. dom.length += 1;
  1081. }
  1082. }
  1083. return dom;
  1084. }
  1085. function empty() {
  1086. for (var i = 0; i < this.length; i += 1) {
  1087. var el = this[i];
  1088. if (el.nodeType === 1) {
  1089. for (var j = 0; j < el.childNodes.length; j += 1) {
  1090. if (el.childNodes[j].parentNode) {
  1091. el.childNodes[j].parentNode.removeChild(el.childNodes[j]);
  1092. }
  1093. }
  1094. el.textContent = '';
  1095. }
  1096. }
  1097. return this;
  1098. }
  1099. var Methods = /*#__PURE__*/Object.freeze({
  1100. addClass: addClass,
  1101. removeClass: removeClass,
  1102. hasClass: hasClass,
  1103. toggleClass: toggleClass,
  1104. attr: attr,
  1105. removeAttr: removeAttr,
  1106. prop: prop,
  1107. data: data,
  1108. removeData: removeData,
  1109. dataset: dataset,
  1110. val: val,
  1111. transform: transform,
  1112. transition: transition,
  1113. on: on,
  1114. off: off,
  1115. once: once,
  1116. trigger: trigger,
  1117. transitionEnd: transitionEnd,
  1118. animationEnd: animationEnd,
  1119. width: width,
  1120. outerWidth: outerWidth,
  1121. height: height,
  1122. outerHeight: outerHeight,
  1123. offset: offset,
  1124. hide: hide,
  1125. show: show,
  1126. styles: styles,
  1127. css: css,
  1128. toArray: toArray,
  1129. each: each,
  1130. forEach: forEach,
  1131. filter: filter,
  1132. map: map,
  1133. html: html,
  1134. text: text,
  1135. is: is,
  1136. indexOf: indexOf,
  1137. index: index,
  1138. eq: eq,
  1139. append: append,
  1140. appendTo: appendTo,
  1141. prepend: prepend,
  1142. prependTo: prependTo,
  1143. insertBefore: insertBefore,
  1144. insertAfter: insertAfter,
  1145. next: next,
  1146. nextAll: nextAll,
  1147. prev: prev,
  1148. prevAll: prevAll,
  1149. siblings: siblings,
  1150. parent: parent,
  1151. parents: parents,
  1152. closest: closest,
  1153. find: find,
  1154. children: children,
  1155. remove: remove,
  1156. detach: detach,
  1157. add: add,
  1158. empty: empty
  1159. });
  1160. function scrollTo() {
  1161. var assign;
  1162. var args = [], len = arguments.length;
  1163. while ( len-- ) args[ len ] = arguments[ len ];
  1164. var left = args[0];
  1165. var top = args[1];
  1166. var duration = args[2];
  1167. var easing = args[3];
  1168. var callback = args[4];
  1169. if (args.length === 4 && typeof easing === 'function') {
  1170. callback = easing;
  1171. (assign = args, left = assign[0], top = assign[1], duration = assign[2], callback = assign[3], easing = assign[4]);
  1172. }
  1173. if (typeof easing === 'undefined') { easing = 'swing'; }
  1174. return this.each(function animate() {
  1175. var el = this;
  1176. var currentTop;
  1177. var currentLeft;
  1178. var maxTop;
  1179. var maxLeft;
  1180. var newTop;
  1181. var newLeft;
  1182. var scrollTop; // eslint-disable-line
  1183. var scrollLeft; // eslint-disable-line
  1184. var animateTop = top > 0 || top === 0;
  1185. var animateLeft = left > 0 || left === 0;
  1186. if (typeof easing === 'undefined') {
  1187. easing = 'swing';
  1188. }
  1189. if (animateTop) {
  1190. currentTop = el.scrollTop;
  1191. if (!duration) {
  1192. el.scrollTop = top;
  1193. }
  1194. }
  1195. if (animateLeft) {
  1196. currentLeft = el.scrollLeft;
  1197. if (!duration) {
  1198. el.scrollLeft = left;
  1199. }
  1200. }
  1201. if (!duration) { return; }
  1202. if (animateTop) {
  1203. maxTop = el.scrollHeight - el.offsetHeight;
  1204. newTop = Math.max(Math.min(top, maxTop), 0);
  1205. }
  1206. if (animateLeft) {
  1207. maxLeft = el.scrollWidth - el.offsetWidth;
  1208. newLeft = Math.max(Math.min(left, maxLeft), 0);
  1209. }
  1210. var startTime = null;
  1211. if (animateTop && newTop === currentTop) { animateTop = false; }
  1212. if (animateLeft && newLeft === currentLeft) { animateLeft = false; }
  1213. function render(time) {
  1214. if ( time === void 0 ) time = new Date().getTime();
  1215. if (startTime === null) {
  1216. startTime = time;
  1217. }
  1218. var progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
  1219. var easeProgress = easing === 'linear' ? progress : (0.5 - (Math.cos(progress * Math.PI) / 2));
  1220. var done;
  1221. if (animateTop) { scrollTop = currentTop + (easeProgress * (newTop - currentTop)); }
  1222. if (animateLeft) { scrollLeft = currentLeft + (easeProgress * (newLeft - currentLeft)); }
  1223. if (animateTop && newTop > currentTop && scrollTop >= newTop) {
  1224. el.scrollTop = newTop;
  1225. done = true;
  1226. }
  1227. if (animateTop && newTop < currentTop && scrollTop <= newTop) {
  1228. el.scrollTop = newTop;
  1229. done = true;
  1230. }
  1231. if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) {
  1232. el.scrollLeft = newLeft;
  1233. done = true;
  1234. }
  1235. if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) {
  1236. el.scrollLeft = newLeft;
  1237. done = true;
  1238. }
  1239. if (done) {
  1240. if (callback) { callback(); }
  1241. return;
  1242. }
  1243. if (animateTop) { el.scrollTop = scrollTop; }
  1244. if (animateLeft) { el.scrollLeft = scrollLeft; }
  1245. requestAnimationFrame(render);
  1246. }
  1247. requestAnimationFrame(render);
  1248. });
  1249. }
  1250. // scrollTop(top, duration, easing, callback) {
  1251. function scrollTop() {
  1252. var assign;
  1253. var args = [], len = arguments.length;
  1254. while ( len-- ) args[ len ] = arguments[ len ];
  1255. var top = args[0];
  1256. var duration = args[1];
  1257. var easing = args[2];
  1258. var callback = args[3];
  1259. if (args.length === 3 && typeof easing === 'function') {
  1260. (assign = args, top = assign[0], duration = assign[1], callback = assign[2], easing = assign[3]);
  1261. }
  1262. var dom = this;
  1263. if (typeof top === 'undefined') {
  1264. if (dom.length > 0) { return dom[0].scrollTop; }
  1265. return null;
  1266. }
  1267. return dom.scrollTo(undefined, top, duration, easing, callback);
  1268. }
  1269. function scrollLeft() {
  1270. var assign;
  1271. var args = [], len = arguments.length;
  1272. while ( len-- ) args[ len ] = arguments[ len ];
  1273. var left = args[0];
  1274. var duration = args[1];
  1275. var easing = args[2];
  1276. var callback = args[3];
  1277. if (args.length === 3 && typeof easing === 'function') {
  1278. (assign = args, left = assign[0], duration = assign[1], callback = assign[2], easing = assign[3]);
  1279. }
  1280. var dom = this;
  1281. if (typeof left === 'undefined') {
  1282. if (dom.length > 0) { return dom[0].scrollLeft; }
  1283. return null;
  1284. }
  1285. return dom.scrollTo(left, undefined, duration, easing, callback);
  1286. }
  1287. var Scroll = /*#__PURE__*/Object.freeze({
  1288. scrollTo: scrollTo,
  1289. scrollTop: scrollTop,
  1290. scrollLeft: scrollLeft
  1291. });
  1292. function animate(initialProps, initialParams) {
  1293. var els = this;
  1294. var a = {
  1295. props: Object.assign({}, initialProps),
  1296. params: Object.assign({
  1297. duration: 300,
  1298. easing: 'swing', // or 'linear'
  1299. /* Callbacks
  1300. begin(elements)
  1301. complete(elements)
  1302. progress(elements, complete, remaining, start, tweenValue)
  1303. */
  1304. }, initialParams),
  1305. elements: els,
  1306. animating: false,
  1307. que: [],
  1308. easingProgress: function easingProgress(easing, progress) {
  1309. if (easing === 'swing') {
  1310. return 0.5 - (Math.cos(progress * Math.PI) / 2);
  1311. }
  1312. if (typeof easing === 'function') {
  1313. return easing(progress);
  1314. }
  1315. return progress;
  1316. },
  1317. stop: function stop() {
  1318. if (a.frameId) {
  1319. cancelAnimationFrame(a.frameId);
  1320. }
  1321. a.animating = false;
  1322. a.elements.each(function (index, el) {
  1323. var element = el;
  1324. delete element.dom7AnimateInstance;
  1325. });
  1326. a.que = [];
  1327. },
  1328. done: function done(complete) {
  1329. a.animating = false;
  1330. a.elements.each(function (index, el) {
  1331. var element = el;
  1332. delete element.dom7AnimateInstance;
  1333. });
  1334. if (complete) { complete(els); }
  1335. if (a.que.length > 0) {
  1336. var que = a.que.shift();
  1337. a.animate(que[0], que[1]);
  1338. }
  1339. },
  1340. animate: function animate(props, params) {
  1341. if (a.animating) {
  1342. a.que.push([props, params]);
  1343. return a;
  1344. }
  1345. var elements = [];
  1346. // Define & Cache Initials & Units
  1347. a.elements.each(function (index, el) {
  1348. var initialFullValue;
  1349. var initialValue;
  1350. var unit;
  1351. var finalValue;
  1352. var finalFullValue;
  1353. if (!el.dom7AnimateInstance) { a.elements[index].dom7AnimateInstance = a; }
  1354. elements[index] = {
  1355. container: el,
  1356. };
  1357. Object.keys(props).forEach(function (prop) {
  1358. initialFullValue = win.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.');
  1359. initialValue = parseFloat(initialFullValue);
  1360. unit = initialFullValue.replace(initialValue, '');
  1361. finalValue = parseFloat(props[prop]);
  1362. finalFullValue = props[prop] + unit;
  1363. elements[index][prop] = {
  1364. initialFullValue: initialFullValue,
  1365. initialValue: initialValue,
  1366. unit: unit,
  1367. finalValue: finalValue,
  1368. finalFullValue: finalFullValue,
  1369. currentValue: initialValue,
  1370. };
  1371. });
  1372. });
  1373. var startTime = null;
  1374. var time;
  1375. var elementsDone = 0;
  1376. var propsDone = 0;
  1377. var done;
  1378. var began = false;
  1379. a.animating = true;
  1380. function render() {
  1381. time = new Date().getTime();
  1382. var progress;
  1383. var easeProgress;
  1384. // let el;
  1385. if (!began) {
  1386. began = true;
  1387. if (params.begin) { params.begin(els); }
  1388. }
  1389. if (startTime === null) {
  1390. startTime = time;
  1391. }
  1392. if (params.progress) {
  1393. // eslint-disable-next-line
  1394. params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), ((startTime + params.duration) - time < 0 ? 0 : (startTime + params.duration) - time), startTime);
  1395. }
  1396. elements.forEach(function (element) {
  1397. var el = element;
  1398. if (done || el.done) { return; }
  1399. Object.keys(props).forEach(function (prop) {
  1400. if (done || el.done) { return; }
  1401. progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0);
  1402. easeProgress = a.easingProgress(params.easing, progress);
  1403. var ref = el[prop];
  1404. var initialValue = ref.initialValue;
  1405. var finalValue = ref.finalValue;
  1406. var unit = ref.unit;
  1407. el[prop].currentValue = initialValue + (easeProgress * (finalValue - initialValue));
  1408. var currentValue = el[prop].currentValue;
  1409. if (
  1410. (finalValue > initialValue && currentValue >= finalValue) ||
  1411. (finalValue < initialValue && currentValue <= finalValue)) {
  1412. el.container.style[prop] = finalValue + unit;
  1413. propsDone += 1;
  1414. if (propsDone === Object.keys(props).length) {
  1415. el.done = true;
  1416. elementsDone += 1;
  1417. }
  1418. if (elementsDone === elements.length) {
  1419. done = true;
  1420. }
  1421. }
  1422. if (done) {
  1423. a.done(params.complete);
  1424. return;
  1425. }
  1426. el.container.style[prop] = currentValue + unit;
  1427. });
  1428. });
  1429. if (done) { return; }
  1430. // Then call
  1431. a.frameId = requestAnimationFrame(render);
  1432. }
  1433. a.frameId = requestAnimationFrame(render);
  1434. return a;
  1435. },
  1436. };
  1437. if (a.elements.length === 0) {
  1438. return els;
  1439. }
  1440. var animateInstance;
  1441. for (var i = 0; i < a.elements.length; i += 1) {
  1442. if (a.elements[i].dom7AnimateInstance) {
  1443. animateInstance = a.elements[i].dom7AnimateInstance;
  1444. } else { a.elements[i].dom7AnimateInstance = a; }
  1445. }
  1446. if (!animateInstance) {
  1447. animateInstance = a;
  1448. }
  1449. if (initialProps === 'stop') {
  1450. animateInstance.stop();
  1451. } else {
  1452. animateInstance.animate(a.props, a.params);
  1453. }
  1454. return els;
  1455. }
  1456. function stop() {
  1457. var els = this;
  1458. for (var i = 0; i < els.length; i += 1) {
  1459. if (els[i].dom7AnimateInstance) {
  1460. els[i].dom7AnimateInstance.stop();
  1461. }
  1462. }
  1463. }
  1464. var Animate = /*#__PURE__*/Object.freeze({
  1465. animate: animate,
  1466. stop: stop
  1467. });
  1468. var noTrigger = ('resize scroll').split(' ');
  1469. function eventShortcut(name) {
  1470. var ref;
  1471. var args = [], len = arguments.length - 1;
  1472. while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
  1473. if (typeof args[0] === 'undefined') {
  1474. for (var i = 0; i < this.length; i += 1) {
  1475. if (noTrigger.indexOf(name) < 0) {
  1476. if (name in this[i]) { this[i][name](); }
  1477. else {
  1478. $(this[i]).trigger(name);
  1479. }
  1480. }
  1481. }
  1482. return this;
  1483. }
  1484. return (ref = this).on.apply(ref, [ name ].concat( args ));
  1485. }
  1486. function click() {
  1487. var args = [], len = arguments.length;
  1488. while ( len-- ) args[ len ] = arguments[ len ];
  1489. return eventShortcut.bind(this).apply(void 0, [ 'click' ].concat( args ));
  1490. }
  1491. function blur() {
  1492. var args = [], len = arguments.length;
  1493. while ( len-- ) args[ len ] = arguments[ len ];
  1494. return eventShortcut.bind(this).apply(void 0, [ 'blur' ].concat( args ));
  1495. }
  1496. function focus() {
  1497. var args = [], len = arguments.length;
  1498. while ( len-- ) args[ len ] = arguments[ len ];
  1499. return eventShortcut.bind(this).apply(void 0, [ 'focus' ].concat( args ));
  1500. }
  1501. function focusin() {
  1502. var args = [], len = arguments.length;
  1503. while ( len-- ) args[ len ] = arguments[ len ];
  1504. return eventShortcut.bind(this).apply(void 0, [ 'focusin' ].concat( args ));
  1505. }
  1506. function focusout() {
  1507. var args = [], len = arguments.length;
  1508. while ( len-- ) args[ len ] = arguments[ len ];
  1509. return eventShortcut.bind(this).apply(void 0, [ 'focusout' ].concat( args ));
  1510. }
  1511. function keyup() {
  1512. var args = [], len = arguments.length;
  1513. while ( len-- ) args[ len ] = arguments[ len ];
  1514. return eventShortcut.bind(this).apply(void 0, [ 'keyup' ].concat( args ));
  1515. }
  1516. function keydown() {
  1517. var args = [], len = arguments.length;
  1518. while ( len-- ) args[ len ] = arguments[ len ];
  1519. return eventShortcut.bind(this).apply(void 0, [ 'keydown' ].concat( args ));
  1520. }
  1521. function keypress() {
  1522. var args = [], len = arguments.length;
  1523. while ( len-- ) args[ len ] = arguments[ len ];
  1524. return eventShortcut.bind(this).apply(void 0, [ 'keypress' ].concat( args ));
  1525. }
  1526. function submit() {
  1527. var args = [], len = arguments.length;
  1528. while ( len-- ) args[ len ] = arguments[ len ];
  1529. return eventShortcut.bind(this).apply(void 0, [ 'submit' ].concat( args ));
  1530. }
  1531. function change() {
  1532. var args = [], len = arguments.length;
  1533. while ( len-- ) args[ len ] = arguments[ len ];
  1534. return eventShortcut.bind(this).apply(void 0, [ 'change' ].concat( args ));
  1535. }
  1536. function mousedown() {
  1537. var args = [], len = arguments.length;
  1538. while ( len-- ) args[ len ] = arguments[ len ];
  1539. return eventShortcut.bind(this).apply(void 0, [ 'mousedown' ].concat( args ));
  1540. }
  1541. function mousemove() {
  1542. var args = [], len = arguments.length;
  1543. while ( len-- ) args[ len ] = arguments[ len ];
  1544. return eventShortcut.bind(this).apply(void 0, [ 'mousemove' ].concat( args ));
  1545. }
  1546. function mouseup() {
  1547. var args = [], len = arguments.length;
  1548. while ( len-- ) args[ len ] = arguments[ len ];
  1549. return eventShortcut.bind(this).apply(void 0, [ 'mouseup' ].concat( args ));
  1550. }
  1551. function mouseenter() {
  1552. var args = [], len = arguments.length;
  1553. while ( len-- ) args[ len ] = arguments[ len ];
  1554. return eventShortcut.bind(this).apply(void 0, [ 'mouseenter' ].concat( args ));
  1555. }
  1556. function mouseleave() {
  1557. var args = [], len = arguments.length;
  1558. while ( len-- ) args[ len ] = arguments[ len ];
  1559. return eventShortcut.bind(this).apply(void 0, [ 'mouseleave' ].concat( args ));
  1560. }
  1561. function mouseout() {
  1562. var args = [], len = arguments.length;
  1563. while ( len-- ) args[ len ] = arguments[ len ];
  1564. return eventShortcut.bind(this).apply(void 0, [ 'mouseout' ].concat( args ));
  1565. }
  1566. function mouseover() {
  1567. var args = [], len = arguments.length;
  1568. while ( len-- ) args[ len ] = arguments[ len ];
  1569. return eventShortcut.bind(this).apply(void 0, [ 'mouseover' ].concat( args ));
  1570. }
  1571. function touchstart() {
  1572. var args = [], len = arguments.length;
  1573. while ( len-- ) args[ len ] = arguments[ len ];
  1574. return eventShortcut.bind(this).apply(void 0, [ 'touchstart' ].concat( args ));
  1575. }
  1576. function touchend() {
  1577. var args = [], len = arguments.length;
  1578. while ( len-- ) args[ len ] = arguments[ len ];
  1579. return eventShortcut.bind(this).apply(void 0, [ 'touchend' ].concat( args ));
  1580. }
  1581. function touchmove() {
  1582. var args = [], len = arguments.length;
  1583. while ( len-- ) args[ len ] = arguments[ len ];
  1584. return eventShortcut.bind(this).apply(void 0, [ 'touchmove' ].concat( args ));
  1585. }
  1586. function resize() {
  1587. var args = [], len = arguments.length;
  1588. while ( len-- ) args[ len ] = arguments[ len ];
  1589. return eventShortcut.bind(this).apply(void 0, [ 'resize' ].concat( args ));
  1590. }
  1591. function scroll() {
  1592. var args = [], len = arguments.length;
  1593. while ( len-- ) args[ len ] = arguments[ len ];
  1594. return eventShortcut.bind(this).apply(void 0, [ 'scroll' ].concat( args ));
  1595. }
  1596. var eventShortcuts = /*#__PURE__*/Object.freeze({
  1597. click: click,
  1598. blur: blur,
  1599. focus: focus,
  1600. focusin: focusin,
  1601. focusout: focusout,
  1602. keyup: keyup,
  1603. keydown: keydown,
  1604. keypress: keypress,
  1605. submit: submit,
  1606. change: change,
  1607. mousedown: mousedown,
  1608. mousemove: mousemove,
  1609. mouseup: mouseup,
  1610. mouseenter: mouseenter,
  1611. mouseleave: mouseleave,
  1612. mouseout: mouseout,
  1613. mouseover: mouseover,
  1614. touchstart: touchstart,
  1615. touchend: touchend,
  1616. touchmove: touchmove,
  1617. resize: resize,
  1618. scroll: scroll
  1619. });
  1620. [Methods, Scroll, Animate, eventShortcuts].forEach(function (group) {
  1621. Object.keys(group).forEach(function (methodName) {
  1622. $.fn[methodName] = group[methodName];
  1623. });
  1624. });
  1625. return $;
  1626. }));