dom7.esm.js 40 KB

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