dom7.cjs.js 42 KB

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