dom7.modular.js 38 KB

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