dom7.js 44 KB

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