dom7.js 51 KB

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