@wiajs/core 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wia core v1.0.5
2
+ * wia core v1.0.6
3
3
  * (c) 2015-2023 Sibyl Yu and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -123,3305 +123,6 @@
123
123
  _setPrototypeOf(subClass, superClass);
124
124
  }
125
125
 
126
- function getDefaultExportFromCjs (x) {
127
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
128
- }
129
-
130
- var dom = {exports: {}};
131
-
132
- /*!
133
- * wia dom v1.0.1
134
- * (c) 2022-2023 Sibyl Yu and contributors
135
- * Released under the MIT License.
136
- */
137
-
138
- var dom_cmn;
139
- var hasRequiredDom_cmn;
140
-
141
- function requireDom_cmn () {
142
- if (hasRequiredDom_cmn) return dom_cmn;
143
- hasRequiredDom_cmn = 1;
144
-
145
- /*
146
- * Expand $.fn
147
- * 扩展 $.fn
148
- * same syntax as well known jQuery library
149
- */
150
-
151
- const emptyArray = [];
152
- const elementDisplay = {};
153
- const rootNodeRE = /^(?:body|html)$/i;
154
- const propMap = {
155
- tabindex: 'tabIndex',
156
- readonly: 'readOnly',
157
- for: 'htmlFor',
158
- class: 'className',
159
- maxlength: 'maxLength',
160
- cellspacing: 'cellSpacing',
161
- cellpadding: 'cellPadding',
162
- rowspan: 'rowSpan',
163
- colspan: 'colSpan',
164
- usemap: 'useMap',
165
- frameborder: 'frameBorder',
166
- contenteditable: 'contentEditable',
167
- };
168
-
169
- // 返回数组
170
- function concat(...arg) {
171
- const args = [];
172
- for (let i = 0; i < arg.length; i++) {
173
- const v = arg[i];
174
- args[i] = $.isDom(v) ? v.toArray() : v;
175
- }
176
- return emptyArray.concat.apply($.isDom(this) ? this.toArray() : this, args);
177
- }
178
-
179
- function ready(cb) {
180
- if (/complete|loaded|interactive/.test(document.readyState) && document.body) cb($);
181
- else
182
- document.addEventListener(
183
- 'DOMContentLoaded',
184
- function () {
185
- cb($);
186
- },
187
- false
188
- );
189
- return this;
190
- }
191
-
192
- // 转为节点数组,或指定索引节点
193
- function get(idx) {
194
- return idx === undefined ? emptyArray.slice.call(this) : this[idx >= 0 ? idx : idx + this.length];
195
- }
196
-
197
- function toArray() {
198
- return this.get();
199
- }
200
-
201
- function size() {
202
- return this.length;
203
- }
204
-
205
- /**
206
- * 删除或设置dom属性
207
- * @param {*} node
208
- * @param {*} n attr name
209
- * @param {*} value null or undefined
210
- */
211
- function setAttr(node, n, value) {
212
- if (node && node.nodeType === 1) {
213
- if (value == null) node.removeAttribute(n);
214
- else node.setAttribute(n, value);
215
- }
216
- }
217
-
218
- function attr(n, value) {
219
- let R;
220
- const el = this[0];
221
-
222
- // Get attr
223
- if (arguments.length === 1 && typeof n === 'string') {
224
- if (el.nodeType === 1 && el) R = el.getAttribute(n);
225
- } else {
226
- // Set attr
227
- R = this.each(function (idx) {
228
- if ($.isObject(n)) {
229
- Object.keys(n).forEach(k => {
230
- this[k] = n[k]; // f7
231
- setAttr(this, k, n[k]);
232
- });
233
- } else setAttr(this, n, $.funcArg(this, value, idx, this.getAttribute(n)));
234
- });
235
- }
236
-
237
- return R;
238
- }
239
-
240
- function removeAttr(n) {
241
- return this.each(function () {
242
- this.nodeType === 1 &&
243
- n.split(' ').forEach(function (v) {
244
- setAttr(this, v);
245
- }, this);
246
- });
247
- }
248
-
249
- function hasAttr(n) {
250
- return emptyArray.some.call(this, function (el) {
251
- return el.hasAttribute(n);
252
- });
253
- }
254
-
255
- function prop(n, value) {
256
- try {
257
- n = propMap[n] || n;
258
- // Get prop
259
- if (arguments.length === 1 && typeof n === 'string') this[0] && this[0][n];
260
- else {
261
- // Set props
262
- return this.each(function (idx) {
263
- if (arguments.length === 2) this[n] = $.funcArg(this, value, idx, this[n]);
264
- else if ($.isObject(n)) {
265
- // eslint-disable-next-line
266
- for (const prop in n) {
267
- this[prop] = n[prop];
268
- }
269
- }
270
- });
271
- }
272
- } catch (ex) {
273
- console.log('prop exp:', ex.message);
274
- }
275
- }
276
-
277
- function removeProp(n) {
278
- n = propMap[n] || n;
279
- return this.each(function () {
280
- delete this[n];
281
- });
282
- }
283
-
284
- // 读取或设置 data-* 属性值,保持与jQuery 兼容
285
- // 在dom节点上自定义 domElementDataStorage 对象存储数据
286
- function data(key, value) {
287
- let R;
288
- let el;
289
- const attrName = 'data-' + key.replace(/([A-Z])/g, '-$1').toLowerCase();
290
-
291
- if (typeof value === 'undefined') {
292
- [el] = this;
293
- // Get value
294
- if (el) {
295
- if (el.domElementDataStorage && key in el.domElementDataStorage) {
296
- R = el.domElementDataStorage[key];
297
- } else R = this.attr(attrName);
298
- }
299
- if (R) R = $.deserializeValue(R);
300
- } else {
301
- // Set value
302
- for (let i = 0; i < this.length; i += 1) {
303
- el = this[i];
304
- if (!el.domElementDataStorage) el.domElementDataStorage = {};
305
- el.domElementDataStorage[key] = value;
306
- this.attr(attrName, value);
307
- }
308
- R = this;
309
- }
310
-
311
- return R;
312
- }
313
-
314
- function removeData(key) {
315
- const attrName = 'data-' + key.replace(/([A-Z])/g, '-$1').toLowerCase();
316
-
317
- for (let i = 0; i < this.length; i += 1) {
318
- const el = this[i];
319
- if (el.domElementDataStorage && el.domElementDataStorage[key]) {
320
- el.domElementDataStorage[key] = null;
321
- delete el.domElementDataStorage[key];
322
- }
323
- el.removeAttribute(attrName);
324
- }
325
-
326
- return this;
327
- }
328
-
329
- function dataset() {
330
- const el = this[0];
331
- if (!el) return undefined;
332
-
333
- const dataset = {}; // eslint-disable-line
334
- if (el.dataset) {
335
- // eslint-disable-next-line
336
- for (const dataKey in el.dataset) {
337
- dataset[dataKey] = el.dataset[dataKey];
338
- }
339
- } else {
340
- for (let i = 0; i < el.attributes.length; i += 1) {
341
- // eslint-disable-next-line
342
- const attr = el.attributes[i];
343
- if (attr.name.indexOf('data-') >= 0) {
344
- dataset[$.camelCase(attr.name.split('data-')[1])] = attr.value;
345
- }
346
- }
347
- }
348
-
349
- // eslint-disable-next-line
350
- for (const key in dataset) dataset[key] = $.deserializeValue(dataset[key]);
351
-
352
- return dataset;
353
- }
354
-
355
- /**
356
- * 表单节点值的获取、设置
357
- * 获取时,只获取第一个dom对象value
358
- * 设置时,对节点数组同时设置
359
- * 支持 select单选、多选,checkbox,radio
360
- * @param {*} value 值
361
- * value 为Dom对象时,表示节点容器,带容器参数时,支持容器内radio、checkbox有效值获取
362
- * @param {*} el 节点容器,带容器参数时,支持容器内radio、checkbox赋值
363
- * @returns
364
- */
365
- function val(value, el) {
366
- let R;
367
- // 设置值
368
- if (0 in arguments && !$.isDom(value)) {
369
- if (value == null) value = '';
370
- return this.each(function (idx) {
371
- let vs = $.funcArg(this, value, idx, this.value);
372
- const dom = this;
373
-
374
- // 注意,节点value是字符串!
375
- // select 多选,单选直接赋值即可
376
- if (dom.multiple && dom.nodeName.toLowerCase() === 'select') {
377
- if (Array.isArray(vs)) vs = vs.map(v => v.toString());
378
- else vs = [vs.toString()];
379
- dom.options.forEach(o => (o.selected = vs.includes(o.value)));
380
- } else if (dom.type === 'checkbox' && el) {
381
- if (Array.isArray(vs)) vs = vs.map(v => v.toString());
382
- else vs = [vs.toString()];
383
-
384
- const name = $(dom).attr('name');
385
- const ns = $(`input[name=${name}]`, el);
386
- ns.forEach(n => (n.checked = vs.includes(n.value)));
387
- } else if (dom.type === 'radio' && el) {
388
- if (Array.isArray(vs)) vs = vs[0];
389
-
390
- const name = $(dom).attr('name');
391
- const ns = $(`input[name=${name}]`, el);
392
- ns.forEach(n => {
393
- n.checked = n.value === vs.toString();
394
- });
395
- } else dom.value = vs.toString();
396
- });
397
- } else if (this[0]) {
398
- // 获取值
399
- const dom = this[0];
400
- R = dom.value;
401
- // 多选
402
- if (dom.multiple && dom.nodeName.toLowerCase() === 'select')
403
- R = $(dom)
404
- .find('option')
405
- .filter(function () {
406
- return this.selected;
407
- })
408
- .pluck('value');
409
- else if (dom.type === 'checkbox' && $.isDom(value)) {
410
- const el = value;
411
- const name = this.attr('name');
412
- const ns = $(`input[name=${name}]:checked`, el);
413
- R = ns.pluck('value');
414
- } else if (dom.type === 'radio' && $.isDom(value)) {
415
- const el = value;
416
- const name = this.attr('name');
417
- const n = $(`input[name=${name}]:checked`, el);
418
- if (n && n.length) R = n[0].value;
419
- }
420
- }
421
-
422
- return R;
423
- }
424
-
425
- // Transforms
426
- // eslint-disable-next-line
427
- function transform(transform) {
428
- for (let i = 0; i < this.length; i += 1) {
429
- const elStyle = this[i].style;
430
- elStyle.webkitTransform = transform;
431
- elStyle.transform = transform;
432
- }
433
- return this;
434
- }
435
- function transition(duration) {
436
- if (typeof duration !== 'string') {
437
- duration = `${duration}ms`; // eslint-disable-line
438
- }
439
- for (let i = 0; i < this.length; i += 1) {
440
- const elStyle = this[i].style;
441
- elStyle.webkitTransitionDuration = duration;
442
- elStyle.transitionDuration = duration;
443
- }
444
- return this;
445
- }
446
-
447
- /**
448
- * 事件响应,第一个参数为event,
449
- * 第二个参数为this,解决类事件函数this绑定到对象无法获得事件this问题。
450
- * targetSelector 目标选择器,常用于容器中的click、change事件,
451
- * 根据触发源target动态向上查找指定元素
452
- * 事件响应,dom事件中的 event作为第一个参数,其他为扩展参数
453
- * trigger触发时,可带扩展参数,扩展参数通过el的 wiaDomEventData 传递
454
- * 触摸屏,click 300ms 有延迟,改用 touch 实现立即触发
455
- * 避免click穿透,touch触发click事件后,禁止300ms后的click事件
456
- * swipe 滑动事件上下左右四个方向,滑动距离超过10px,则触发回调函数
457
- * 触发回调函数,参数为 (ev, {x, y}),x y互斥,只有一个有值
458
- * press 按压事件,超过 1秒,移动距离小于 5px,为 press 事件
459
- */
460
- function on(...args) {
461
- let [eventType, targetSelector, listener, capture] = args;
462
-
463
- if (typeof args[1] === 'function') {
464
- [eventType, listener, capture] = args;
465
- targetSelector = undefined;
466
- }
467
-
468
- // 封装需动态查找目标元素的事件回调函数
469
- function liveHandler(ev, sender, ...evs) {
470
- const n = ev.target; // 事件源,不能用this
471
- if (!n) return;
472
-
473
- const {eventType: evType, selector, liveProxy: fn} = liveHandler;
474
-
475
- // 向上查找符合选择器元素,找到一个即触发,其他符合选择器不触发
476
- // f7是查找所有符合选择器父元素,全部触发,实际使用中,只需最近的元素触发,无需全部触发!
477
- const el = $(n).closest(selector)?.dom; // live事件函数,目标选择器对象,替换真正的this
478
- // console.log('liveHandler ', {listener: this, selector, event: ev, target: n, upper: $n?.dom});
479
- // debugger;
480
- if (el && (evType !== 'click' || canClick(el, fn))) {
481
- const param = [ev, el, ...evs]; // 符合元素作为事件函数第二个参数
482
- fn.apply(n, param); // this 指向符合选择器元素
483
- }
484
- }
485
-
486
- // 带有目标选择器,回调函数转换为 liveHandler
487
- if (targetSelector) {
488
- liveHandler.selector = targetSelector;
489
- liveHandler.liveProxy = listener;
490
- liveHandler.eventType = eventType;
491
- return this.on(eventType, liveHandler, capture);
492
- }
493
-
494
- if (!capture) capture = false;
495
-
496
- // 事件响应,dom事件中的 event作为第一个参数
497
- // trigger通过el的 wiaDomEventData 带额外参数,
498
- function handleEvent(ev, ...vs) {
499
- const ds = ev?.target?.wiaDomEventData ?? [];
500
- const param = [ev, this, ...vs, ...ds];
501
-
502
- // console.log('handleEvent ', {listener: this, event: ev, target: ev?.target});
503
- listener.apply(this, param);
504
- }
505
-
506
- /**
507
- * 同一节点、同一事件函数,过500毫秒才能重复触发click事件,避免连击时连续触发同一函数
508
- * @param {*} el 元素节点
509
- * @param {*} fn 事件函数
510
- * @returns
511
- */
512
- function canClick(el, fn) {
513
- let R = true;
514
-
515
- if (!el || !fn) return false;
516
-
517
- // 排除live、once封装代理函数,排除 document等非元素节点,主要针对 button、link、div
518
- if (fn.liveProxy || fn.onceProxy || el.nodeType !== 1) return true;
519
-
520
- try {
521
- // disabled not trigger event
522
- if (el.clickDisabled?.has?.(fn)) {
523
- // ev.stopPropagation(); // 阻止事件冒泡,会阻止live和对同一节点的多侦听事件
524
- console.log('duplicate click disabled.');
525
- R = false;
526
- } else {
527
- // 阻止连击 Prevent duplicate clicks
528
- if (!el.clickDisabled) el.clickDisabled = new Set();
529
- el.clickDisabled.add(fn);
530
- setTimeout(() => el.clickDisabled.delete(fn), 200); // wait 500 ms, can click again
531
- }
532
- } catch (ex) {
533
- console.log('canClick exp:', ex.message);
534
- }
535
-
536
- return R;
537
- }
538
-
539
- // Prevent duplicate clicks
540
- // click事件响应,dom事件中的 event作为第一个参数,其他为扩展参数
541
- function clickEvent(ev) {
542
- // console.log('clickEvent ', {listener: this, event: ev, target: ev?.target});
543
- const el = this;
544
-
545
- if (!canClick(el, listener)) return false;
546
-
547
- const ds = ev?.target?.wiaDomEventData || [];
548
- const param = [ev, this, ...ds];
549
- listener.apply(this, param);
550
- }
551
-
552
- // on 函数内共享闭包变量
553
- const touch = {};
554
- function touchStart(ev) {
555
- // console.log('touchStart');
556
-
557
- // ev.preventDefault(); // 默认行为为滚动屏幕,调用则禁止屏幕滚动,比如屏幕上画画,就需要禁止屏幕滚动
558
- // touch.x = e.targetTouches[0].pageX; // pageX 相对文档的位置
559
- touch.x = ev.targetTouches[0].pageX; // targetTouches clientX 可见视口位置,pageX 文档位置
560
- touch.y = ev.targetTouches[0].pageY;
561
- touch.el = $(ev.target);
562
- touch.top = touch.el.rect()?.top ?? 0;
563
- touch.left = touch.el.rect()?.left ?? 0;
564
- touch.time = new Date().getTime();
565
- touch.trigger = false;
566
- touch.scrollY = false;
567
- const pg = touch.el.closest('.page-content').dom;
568
- if (pg) {
569
- touch.scrollY = true;
570
- if (pg.scrollTop === 0 || pg.scrollTop + pg.clientHeight === pg.scrollHeight)
571
- touch.scrollY = false;
572
- }
573
- }
574
-
575
- // swipe 滑动事件
576
- function touchMove(ev) {
577
- // console.log('touchMove');
578
- if (eventType !== 'swipe' || touch.trigger) return;
579
-
580
- const x = Math.round(ev.targetTouches[0].pageX - touch.x);
581
- const y = Math.round(ev.targetTouches[0].pageY - touch.y);
582
- const top = Math.round((touch.el.rect()?.top ?? 0) - touch.top);
583
- const left = Math.round((touch.el.rect()?.left ?? 0) - touch.left);
584
-
585
- // 计算手指在屏幕上的滑动距离,减掉页面跟随手指滚动的距离
586
- const mx = Math.abs(x - left);
587
- const my = Math.abs(y - top);
588
-
589
- // 页面不滚动,滑动超过12px,触发滑动事件,页面滚动则不触发
590
- if (my > 15 && mx < 8 && top === 0 && !touch.scrollY) {
591
- // e.preventDefault(); // 滑动不会产生onclick事件! 不阻止后续的 onclick 事件,否则后续onclick 不会触发
592
- touch.trigger = true; // move 会反复触发,事件只触发一次
593
- return handleEvent.call(this, ev, {x: 0, y});
594
- }
595
-
596
- if (mx > 12 && my < 8 && left === 0 && top === 0) {
597
- // e.preventDefault(); // 滑动不会产生onclick事件! 不阻止后续的 onclick 事件,否则后续onclick 不会触发
598
- touch.trigger = true; // move 会反复触发,事件只触发一次
599
- return handleEvent.call(this, ev, {x, y: 0});
600
- }
601
- }
602
-
603
- // 同时具备 press click,需分开两个函数侦听,触发两次,否则只能触发一次
604
- function clickEnd(ev) {
605
- return touchEnd.call(this, ev);
606
- }
607
-
608
- function pressEnd(ev) {
609
- return touchEnd.call(this, ev);
610
- }
611
-
612
- // touch click 和 press 事件,与onclick事件需二选一,使用 touch click,不会抑制后续的onclick事件。
613
- // 如果上层有click事件,客户端需调用e.preventDefault()来阻止穿透。
614
- function touchEnd(ev) {
615
- // console.log('touchEnd', {eventType});
616
- if (eventType !== 'click' && eventType !== 'press') return;
617
- touch.trigger = false;
618
- const x = Math.abs(ev.changedTouches[0].pageX - touch.x);
619
- const y = Math.abs(ev.changedTouches[0].pageY - touch.y);
620
- const tm = new Date().getTime() - touch.time;
621
- // console.log('touchEnd', {x, y, tm});
622
- if (x <= 5 && y <= 5) {
623
- // 由于在层中使用click,禁止缺省行为后,层中的输入框、下拉框等均失效
624
- // 阻止后续的 onclick 事件,可在按钮中实现,否则页面变动后,后续onclick 事件会触发在其他节点上,导致点击穿透错误!
625
- // ev.preventDefault();
626
- if (tm < 500 && eventType === 'click') return clickEvent.call(this, ev);
627
- if (tm > 500 && eventType === 'press') return handleEvent.call(this, ev);
628
- }
629
- }
630
-
631
- const events = eventType.split(' ');
632
- let j;
633
- for (let i = 0; i < this.length; i += 1) {
634
- const el = this[i];
635
- // 未设置目标选择器
636
- for (j = 0; j < events.length; j += 1) {
637
- const event = events[j];
638
- // 侦听事件和函数,保存到el属性中,方便off
639
- if (!el.domListeners) el.domListeners = {};
640
- // 事件对应的函数数组,每个函数都要addEventListener,才能接收事件回调
641
- if (!el.domListeners[event]) el.domListeners[event] = [];
642
-
643
- // 触摸屏,touch 代替 click,proxyListener 事件处理代理,domListeners 保存在el上
644
- if ($.support.touch && (event === 'click' || event === 'swipe' || event === 'press')) {
645
- const lis = {
646
- capture,
647
- listener,
648
- proxyListener: [touchStart],
649
- };
650
-
651
- let passive = capture;
652
- if (event === 'swipe') {
653
- if ($.support.passiveListener) passive = {passive: true, capture};
654
- lis.proxyListener.push(touchMove);
655
- } else if (event === 'click') lis.proxyListener.push(clickEnd);
656
- else if (event === 'press') lis.proxyListener.push(pressEnd);
657
-
658
- el.domListeners[event].push(lis);
659
- lis.proxyListener.forEach(fn => {
660
- let type = '';
661
- // fn.name 会被优化,不可使用
662
- switch (fn) {
663
- case touchStart:
664
- type = 'touchstart';
665
- break;
666
- case touchMove:
667
- type = 'touchmove';
668
- break;
669
- case clickEnd:
670
- type = 'touchend';
671
- break;
672
- case pressEnd:
673
- type = 'touchend';
674
- break;
675
- }
676
- // console.log('touch', {type, fn: fn.name, passive});
677
- el.addEventListener(type, fn, passive);
678
- });
679
- } else if (event === 'click') {
680
- el.domListeners[event].push({
681
- capture,
682
- listener,
683
- proxyListener: clickEvent,
684
- });
685
- el.addEventListener(event, clickEvent, capture);
686
- } else {
687
- // 其他事件
688
- el.domListeners[event].push({
689
- capture,
690
- listener,
691
- proxyListener: handleEvent,
692
- });
693
- el.addEventListener(event, handleEvent, capture);
694
- }
695
- }
696
- }
697
-
698
- return this;
699
- }
700
-
701
- /**
702
- * 解除事件侦听
703
- * @param {...any} args
704
- * @param {String} event 事件,必选
705
- * listener 侦听函数,不传,则解除所有侦听
706
- * capture:不传默认为false,如果on时为true,off时需传true
707
- * targetSelector:多余参数,兼容f7
708
- * @returns
709
- */
710
- function off(...args) {
711
- let [eventType, targetSelector, listener, capture] = args;
712
- if (typeof args[1] === 'function') {
713
- [eventType, listener, capture] = args;
714
- targetSelector = undefined;
715
- }
716
- if (!capture) capture = false;
717
-
718
- const events = eventType.split(' ');
719
- for (let i = 0; i < events.length; i += 1) {
720
- const event = events[i];
721
- for (let j = 0; j < this.length; j += 1) {
722
- const el = this[j];
723
- const handlers = el?.domListeners[event];
724
- if (handlers?.length) {
725
- for (let k = handlers.length - 1; k >= 0; k -= 1) {
726
- const handler = handlers[k]; // 事件响应对象数组
727
- // 未封装,直接匹配,解除指定的侦听
728
- if (handler?.listener === listener && handler?.capture === capture) {
729
- // 解除额外添加的侦听
730
- if ((event === 'click' || event === 'swipe' || event === 'press') && $.support.touch) {
731
- el.removeEventListener('touchstart', handler.proxyListener[0], handler.capture);
732
-
733
- if (event === 'swipe')
734
- el.removeEventListener('touchmove', handler.proxyListener[1], handler.capture);
735
- else el.removeEventListener('touchend', handler.proxyListener[1], handler.capture);
736
- } else el.removeEventListener(event, handler.proxyListener, handler.capture);
737
- handlers.splice(k, 1);
738
- } else if (
739
- listener &&
740
- handler?.listener?.onceProxy === listener &&
741
- handler?.capture === capture
742
- ) {
743
- // once
744
- el.removeEventListener(event, handler.proxyListener, handler.capture);
745
- handlers.splice(k, 1);
746
- } else if (
747
- listener &&
748
- targetSelector &&
749
- handler?.listener?.liveProxy === listener &&
750
- handler?.listener?.selector === targetSelector &&
751
- handler?.capture === capture
752
- ) {
753
- // 指定选择器 live
754
- el.removeEventListener(event, handler.proxyListener, handler.capture);
755
- handlers.splice(k, 1);
756
- } else if (
757
- listener &&
758
- !targetSelector &&
759
- handler?.listener?.liveProxy === listener &&
760
- handler?.capture === capture
761
- ) {
762
- // 不指定选择器,所有 live
763
- el.removeEventListener(event, handler.proxyListener, handler.capture);
764
- handlers.splice(k, 1);
765
- } else if (!listener) {
766
- // 不指定函数,解除该元素所有侦听
767
- el.removeEventListener(event, handler.proxyListener, handler.capture);
768
- handlers.splice(k, 1);
769
- }
770
- }
771
- }
772
- }
773
- }
774
- return this;
775
- }
776
-
777
- function once(...args) {
778
- const self = this;
779
- let [eventName, targetSelector, listener, capture] = args;
780
- if (typeof args[1] === 'function') {
781
- [eventName, listener, capture] = args;
782
- targetSelector = undefined;
783
- }
784
- // 封装 回调函数,执行一次后自动 off
785
- function onceHandler(...eventArgs) {
786
- self.off(eventName, targetSelector, onceHandler, capture);
787
- if (onceHandler.onceProxy) {
788
- onceHandler.onceProxy.apply(this, eventArgs);
789
- delete onceHandler.onceProxy;
790
- }
791
- }
792
- onceHandler.onceProxy = listener;
793
- return self.on(eventName, targetSelector, onceHandler, capture);
794
- }
795
-
796
- /**
797
- * 触发事件函数
798
- * 第一个数据参数放入回调函数第一个参数event事件的 detail 属性中!
799
- * 扩展参数放入el的wiaDomEventData属性传递,触发时带入事件回调函数参数中!
800
- * @param {...any} args
801
- * @returns
802
- */
803
- function trigger(...args) {
804
- const events = args[0].split(' ');
805
- const eventData = args[1];
806
- for (let i = 0; i < events.length; i += 1) {
807
- const event = events[i];
808
- for (let j = 0; j < this.length; j += 1) {
809
- const el = this[j];
810
- let evt;
811
- try {
812
- evt = new window.CustomEvent(event, {
813
- detail: eventData,
814
- bubbles: true,
815
- cancelable: true,
816
- });
817
- } catch (e) {
818
- evt = document.createEvent('Event');
819
- evt.initEvent(event, true, true);
820
- evt.detail = eventData;
821
- }
822
- // eslint-disable-next-line
823
- el.wiaDomEventData = args.filter((data, dataIndex) => dataIndex > 0);
824
- el.dispatchEvent(evt); // el === event.target
825
- el.wiaDomEventData = [];
826
- delete el.wiaDomEventData;
827
- }
828
- }
829
- return this;
830
- }
831
-
832
- function transitionEnd(callback) {
833
- const events = ['webkitTransitionEnd', 'transitionend'];
834
- const dom = this;
835
- let i;
836
- function fireCallBack(e) {
837
- /* jshint validthis:true */
838
- if (e.target !== this) return;
839
- callback.call(this, e);
840
- for (i = 0; i < events.length; i += 1) {
841
- dom.off(events[i], fireCallBack);
842
- }
843
- }
844
- if (callback) {
845
- for (i = 0; i < events.length; i += 1) {
846
- dom.on(events[i], fireCallBack);
847
- }
848
- }
849
- return this;
850
- }
851
-
852
- function animationEnd(callback) {
853
- const events = ['webkitAnimationEnd', 'animationend'];
854
- const dom = this;
855
- let i;
856
- function fireCallBack(e) {
857
- if (e.target !== this) return;
858
- callback.call(this, e);
859
- for (i = 0; i < events.length; i += 1) {
860
- dom.off(events[i], fireCallBack);
861
- }
862
- }
863
- if (callback) {
864
- for (i = 0; i < events.length; i += 1) {
865
- dom.on(events[i], fireCallBack);
866
- }
867
- }
868
- return this;
869
- }
870
-
871
- // Sizing/Styles
872
- function width() {
873
- if (this[0] === window) {
874
- return window.innerWidth;
875
- }
876
-
877
- if (this.length > 0) {
878
- return parseFloat(this.css('width'));
879
- }
880
-
881
- return null;
882
- }
883
- function outerWidth(includeMargins) {
884
- if (this.length > 0) {
885
- if (includeMargins) {
886
- // eslint-disable-next-line
887
- const styles = this.styles();
888
- return (
889
- this[0].offsetWidth +
890
- parseFloat(styles.getPropertyValue('margin-right')) +
891
- parseFloat(styles.getPropertyValue('margin-left'))
892
- );
893
- }
894
- return this[0].offsetWidth;
895
- }
896
- return null;
897
- }
898
- function height() {
899
- if (this[0] === window) {
900
- return window.innerHeight;
901
- }
902
-
903
- if (this.length > 0) {
904
- return parseFloat(this.css('height'));
905
- }
906
-
907
- return null;
908
- }
909
- function outerHeight(includeMargins) {
910
- if (this.length > 0) {
911
- if (includeMargins) {
912
- // eslint-disable-next-line
913
- const styles = this.styles();
914
- return (
915
- this[0].offsetHeight +
916
- parseFloat(styles.getPropertyValue('margin-top')) +
917
- parseFloat(styles.getPropertyValue('margin-bottom'))
918
- );
919
- }
920
- return this[0].offsetHeight;
921
- }
922
- return null;
923
- }
924
-
925
- /**
926
- * 兼容 jQuery,dom7 是错误的
927
- * wia 中,window 滚动被 .page-content 页面层替代
928
- */
929
- function offset(coordinates) {
930
- if (coordinates)
931
- return this.each(function (idx) {
932
- var $this = $(this),
933
- coords = $.funcArg(this, coordinates, idx, $this.offset()),
934
- parentOffset = $this.offsetParent().offset(),
935
- props = {
936
- top: coords.top - parentOffset.top,
937
- left: coords.left - parentOffset.left,
938
- };
939
-
940
- if ($this.css('position') === 'static') props.position = 'relative';
941
- $this.css(props);
942
- });
943
- if (!this.length) return null;
944
- if (document.documentElement !== this[0] && !$.contains(document.documentElement, this[0]))
945
- return {top: 0, left: 0};
946
- const obj = this[0].getBoundingClientRect();
947
- const pg = this.closest('.page-content');
948
- const scrollX = pg.length ? pg.dom.scrollLeft : window.pageXOffset;
949
- const scrollY = pg.length ? pg.dom.scrollTop : window.pageYOffset;
950
- return {
951
- left: obj.left + scrollX,
952
- top: obj.top + scrollY,
953
- width: Math.round(obj.width),
954
- height: Math.round(obj.height),
955
- };
956
- }
957
-
958
- function rect() {
959
- if (!this.length) return null;
960
- if (document.documentElement !== this[0] && !$.contains(document.documentElement, this[0]))
961
- return {top: 0, left: 0};
962
- const obj = this[0].getBoundingClientRect();
963
- return {
964
- left: obj.left,
965
- top: obj.top,
966
- width: Math.round(obj.width),
967
- height: Math.round(obj.height),
968
- };
969
- }
970
-
971
- function position() {
972
- if (!this.length) return;
973
-
974
- var elem = this[0],
975
- // Get *real* offsetParent
976
- offsetParent = this.offsetParent(),
977
- // Get correct offsets
978
- offset = this.offset(),
979
- parentOffset = rootNodeRE.test(offsetParent[0].nodeName)
980
- ? {top: 0, left: 0}
981
- : offsetParent.offset();
982
-
983
- // Subtract element margins
984
- // note: when an element has margin: auto the offsetLeft and marginLeft
985
- // are the same in Safari causing offset.left to incorrectly be 0
986
- offset.top -= parseFloat($(elem).css('margin-top')) || 0;
987
- offset.left -= parseFloat($(elem).css('margin-left')) || 0;
988
-
989
- // Add offsetParent borders
990
- parentOffset.top += parseFloat($(offsetParent[0]).css('border-top-width')) || 0;
991
- parentOffset.left += parseFloat($(offsetParent[0]).css('border-left-width')) || 0;
992
-
993
- // Subtract the two offsets
994
- return {
995
- top: offset.top - parentOffset.top,
996
- left: offset.left - parentOffset.left,
997
- };
998
- }
999
-
1000
- function offsetParent() {
1001
- return this.map(function () {
1002
- let pt = this.offsetParent || document.body;
1003
- while (pt && !rootNodeRE.test(pt.nodeName) && $(pt).css('position') == 'static')
1004
- pt = pt.offsetParent;
1005
- return pt;
1006
- });
1007
- }
1008
-
1009
- function hide() {
1010
- return this.each(function () {
1011
- if (this.style.display !== 'none') this.style.display = 'none';
1012
- });
1013
- }
1014
-
1015
- function defaultDisplay(nodeName) {
1016
- if (!elementDisplay[nodeName]) {
1017
- const el = document.createElement(nodeName);
1018
- document.body.appendChild(el);
1019
- let display = getComputedStyle(el, '').getPropertyValue('display');
1020
- el.parentNode.removeChild(el);
1021
- display === 'none' && (display = 'block');
1022
- elementDisplay[nodeName] = display;
1023
- }
1024
- return elementDisplay[nodeName];
1025
- }
1026
-
1027
- function show() {
1028
- return this.each(function () {
1029
- this.style.display === 'none' && (this.style.display = '');
1030
- // Still not visible
1031
- if (getComputedStyle(this, '').getPropertyValue('display') === 'none')
1032
- this.style.display = defaultDisplay(this.nodeName); // block
1033
- });
1034
-
1035
- /*
1036
- for (let i = 0; i < this.length; i += 1) {
1037
- const el = this[i];
1038
- if (el.style.display === 'none') {
1039
- el.style.display = '';
1040
- }
1041
- if (window.getComputedStyle(el, null).getPropertyValue('display') === 'none') {
1042
- // Still not visible
1043
- el.style.display = 'block';
1044
- }
1045
- }
1046
- return this;
1047
- */
1048
- }
1049
-
1050
- function replaceWith(newContent) {
1051
- return this.before(newContent).remove();
1052
- }
1053
-
1054
- function styles() {
1055
- if (this[0]) return window.getComputedStyle(this[0], null);
1056
- return {};
1057
- }
1058
-
1059
- function css(props, value) {
1060
- const REGEXP_SUFFIX = /^width|height|left|top|marginLeft|marginTop|paddingLeft|paddingTop$/;
1061
-
1062
- let i;
1063
- if (arguments.length === 1) {
1064
- if (typeof props === 'string') {
1065
- if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
1066
- } else {
1067
- for (i = 0; i < this.length; i += 1) {
1068
- // eslint-disable-next-line
1069
- for (let prop in props) {
1070
- let v = props[prop];
1071
- if (REGEXP_SUFFIX.test(prop) && $.isNumber(v)) v = `${v}px`;
1072
-
1073
- this[i].style[prop] = v;
1074
- }
1075
- }
1076
- return this;
1077
- }
1078
- }
1079
- if (arguments.length === 2 && typeof props === 'string') {
1080
- for (i = 0; i < this.length; i += 1) {
1081
- let v = value;
1082
- if (REGEXP_SUFFIX.test(props) && $.isNumber(v)) v = `${v}px`;
1083
-
1084
- this[i].style[props] = v;
1085
- }
1086
- return this;
1087
- }
1088
- return this;
1089
- }
1090
-
1091
- function each(callback) {
1092
- emptyArray.some.call(this, function (el, idx) {
1093
- return callback.call(el, idx, el) === false; // 退出
1094
- });
1095
- return this;
1096
- }
1097
-
1098
- function forEach(callback) {
1099
- emptyArray.some.call(this, function (el, idx) {
1100
- return callback.call(el, el, idx) === false;
1101
- });
1102
- return this;
1103
- }
1104
-
1105
- function some(callback) {
1106
- return emptyArray.some.call(this, function (el, idx) {
1107
- return callback.call(el, el, idx);
1108
- });
1109
- }
1110
-
1111
- function every(callback) {
1112
- return emptyArray.every.call(this, function (el, idx) {
1113
- return callback.call(el, el, idx);
1114
- });
1115
- }
1116
-
1117
- /*
1118
- // Iterate over the collection passing elements to `callback`
1119
- function each(callback) {
1120
- // Don't bother continuing without a callback
1121
- if (!callback) return this;
1122
- // Iterate over the current collection
1123
- for (let i = 0; i < this.length; i += 1) {
1124
- // If the callback returns false
1125
- if (callback.call(this[i], i, this[i]) === false) {
1126
- // End the loop early
1127
- return this;
1128
- }
1129
- }
1130
- // Return `this` to allow chained DOM operations
1131
- return this;
1132
- }
1133
- function forEach(callback) {
1134
- // Don't bother continuing without a callback
1135
- if (!callback) return this;
1136
- // Iterate over the current collection
1137
- for (let i = 0; i < this.length; i += 1) {
1138
- // If the callback returns false
1139
- if (callback.call(this[i], this[i], i) === false) {
1140
- // End the loop early
1141
- return this;
1142
- }
1143
- }
1144
- // Return `this` to allow chained DOM operations
1145
- return this;
1146
- }
1147
- */
1148
-
1149
- /**
1150
- * 排除 dom 节点
1151
- * @param {*} sel 函数、nodeList、选择器
1152
- * @returns Dom对象
1153
- */
1154
- function not(sel) {
1155
- const R = [];
1156
- if ($.isFunction(sel) && sel.call)
1157
- this.each(function (id) {
1158
- if (!sel.call(this, id)) R.push(this);
1159
- });
1160
- else {
1161
- var excludes =
1162
- typeof sel == 'string'
1163
- ? this.filter(sel)
1164
- : likeArray(sel) && isFunction(sel.item)
1165
- ? emptyArray.slice.call(sel)
1166
- : $(sel);
1167
- this.forEach(function (el) {
1168
- if (excludes.indexOf(el) < 0) R.push(el);
1169
- });
1170
- }
1171
- return $(R);
1172
- }
1173
-
1174
- /**
1175
- * 过滤符合要求的dom节点的Dom对象
1176
- * @param {*} sel
1177
- * @returns
1178
- */
1179
- function filter(sel) {
1180
- let R = [];
1181
- try {
1182
- // 回调函数
1183
- if ($.isFunction(sel) && sel.call) {
1184
- this.each(function (id, it) {
1185
- if (sel.call(this, id, it)) R.push(this);
1186
- });
1187
- } else
1188
- R = emptyArray.filter.call(this, function (el) {
1189
- return $.matches(el, sel);
1190
- });
1191
- } catch (e) {}
1192
-
1193
- return $(R);
1194
- }
1195
-
1196
- function map(cb) {
1197
- return $(
1198
- $.map(this, function (el, i) {
1199
- return cb.call(el, i, el);
1200
- })
1201
- );
1202
- }
1203
-
1204
- function clone() {
1205
- return this.map(function () {
1206
- return this.cloneNode(true);
1207
- });
1208
- }
1209
-
1210
- function html(v) {
1211
- return 0 in arguments
1212
- ? this.each(function (idx) {
1213
- var originHtml = this.innerHTML;
1214
- $(this).empty().append($.funcArg(this, v, idx, originHtml));
1215
- })
1216
- : 0 in this
1217
- ? this[0].innerHTML
1218
- : undefined;
1219
- }
1220
-
1221
- /**
1222
- * 返回数组节点指定属性数组
1223
- * @param {*} p
1224
- * @returns
1225
- */
1226
- function pluck(p) {
1227
- return $.map(this, function (el) {
1228
- return el[p];
1229
- });
1230
- }
1231
-
1232
- function text(tx) {
1233
- return 0 in arguments
1234
- ? this.each(function (idx) {
1235
- var newText = $.funcArg(this, tx, idx, this.textContent);
1236
- this.textContent = newText == null ? '' : '' + newText;
1237
- })
1238
- : 0 in this
1239
- ? this.pluck('textContent').join('')
1240
- : undefined;
1241
- }
1242
-
1243
- function is(sel) {
1244
- return this.length > 0 && $.matches(this[0], sel);
1245
- }
1246
-
1247
- function indexOf(el) {
1248
- for (let i = 0; i < this.length; i += 1) {
1249
- if (this[i] === el) return i;
1250
- }
1251
- return -1;
1252
- }
1253
- function index() {
1254
- let chd = this[0];
1255
- let i;
1256
- if (chd) {
1257
- i = 0;
1258
- // eslint-disable-next-line
1259
- while ((chd = chd.previousSibling) !== null) {
1260
- if (chd.nodeType === 1) i += 1;
1261
- }
1262
- return i;
1263
- }
1264
- return undefined;
1265
- }
1266
-
1267
- function slice(...args) {
1268
- return $(emptyArray.slice.apply(this, args));
1269
- }
1270
-
1271
- /**
1272
- * 返回指定索引dom元素的Dom对象
1273
- * @param {*} idx
1274
- */
1275
- function eq(idx) {
1276
- if (typeof idx === 'undefined') return this;
1277
- const {length} = this;
1278
- if (idx > length - 1 || length + idx < 0) {
1279
- return $();
1280
- }
1281
- return idx === -1 ? this.slice(idx) : this.slice(idx, +idx + 1);
1282
- }
1283
-
1284
- function first() {
1285
- const el = this[0];
1286
- return el && !$.isObject(el) ? el : $(el);
1287
- }
1288
-
1289
- function last() {
1290
- const el = this[this.length - 1];
1291
- return el && !$.isObject(el) ? el : $(el);
1292
- }
1293
-
1294
- /**
1295
- * 同级后节点,如果符合条件返回节点,不符合条件,返回空节点,不含文本节点
1296
- */
1297
- function next(selector) {
1298
- if (this.length > 0) {
1299
- if (selector) {
1300
- if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {
1301
- return $([this[0].nextElementSibling]);
1302
- }
1303
- return $();
1304
- }
1305
-
1306
- if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);
1307
- return $();
1308
- }
1309
- return $();
1310
- }
1311
-
1312
- /**
1313
- * 同级向后查找符合条件的第一个元素节点,不含文本节点
1314
- */
1315
- function nextNode(selector) {
1316
- const nextEls = [];
1317
- const el = this[0];
1318
- if (!el) return $();
1319
-
1320
- let next = el.nextElementSibling; // eslint-disable-line
1321
- while (next) {
1322
- if (selector) {
1323
- if ($(next).is(selector)) {
1324
- nextEls.push(next);
1325
- break;
1326
- }
1327
- } else {
1328
- nextEls.push(next);
1329
- break;
1330
- }
1331
- next = next.nextElementSibling;
1332
- }
1333
- return $(nextEls);
1334
- }
1335
-
1336
- /**
1337
- * 同级向后查找所有符合条件的元素节点,不含文本节点
1338
- */
1339
- function nextAll(selector) {
1340
- const nextEls = [];
1341
- let el = this[0];
1342
- if (!el) return $();
1343
- while (el.nextElementSibling) {
1344
- const next = el.nextElementSibling; // eslint-disable-line
1345
- if (selector) {
1346
- if ($(next).is(selector)) nextEls.push(next);
1347
- } else nextEls.push(next);
1348
- el = next;
1349
- }
1350
- return $(nextEls);
1351
- }
1352
-
1353
- /**
1354
- * 同级前节点,如果符合条件返回节点,不符合条件,返回空节点,不含文本节点
1355
- */
1356
- function prev(selector) {
1357
- if (this.length > 0) {
1358
- const el = this[0];
1359
- if (selector) {
1360
- if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {
1361
- return $([el.previousElementSibling]);
1362
- }
1363
- return $();
1364
- }
1365
-
1366
- if (el.previousElementSibling) return $([el.previousElementSibling]);
1367
- return $();
1368
- }
1369
- return $();
1370
- }
1371
-
1372
- /**
1373
- * 同级向前查找符合条件的第一个元素节点,不含文本节点
1374
- */
1375
- function prevNode(selector) {
1376
- const prevEls = [];
1377
- const el = this[0];
1378
- if (!el) return $();
1379
-
1380
- let prev = el.previousElementSibling; // eslint-disable-line
1381
- while (prev) {
1382
- if (selector) {
1383
- if ($(prev).is(selector)) {
1384
- prevEls.push(prev);
1385
- break;
1386
- }
1387
- } else {
1388
- prevEls.push(prev);
1389
- break;
1390
- }
1391
- prev = prev.previousElementSibling;
1392
- }
1393
- return $(prevEls);
1394
- }
1395
-
1396
- /**
1397
- * 同级向前查找所有符合条件的元素节点,不含文本节点
1398
- */
1399
- function prevAll(selector) {
1400
- const prevEls = [];
1401
- let el = this[0];
1402
- if (!el) return $();
1403
- while (el.previousElementSibling) {
1404
- const prev = el.previousElementSibling; // eslint-disable-line
1405
- if (selector) {
1406
- if ($(prev).is(selector)) prevEls.push(prev);
1407
- } else prevEls.push(prev);
1408
- el = prev;
1409
- }
1410
- return $(prevEls);
1411
- }
1412
-
1413
- /**
1414
- * 同级前后所有兄弟元素节点,不含文本节点
1415
- */
1416
- function siblings(selector) {
1417
- return this.nextAll(selector).add(this.prevAll(selector));
1418
- }
1419
-
1420
- /**
1421
- * 所有dom节点符合条件的父元素
1422
- */
1423
- function parent(selector) {
1424
- const parents = []; // eslint-disable-line
1425
- for (let i = 0; i < this.length; i += 1) {
1426
- if (this[i].parentNode !== null) {
1427
- if (selector) {
1428
- if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
1429
- } else {
1430
- parents.push(this[i].parentNode);
1431
- }
1432
- }
1433
- }
1434
- return $($.uniq(parents));
1435
- }
1436
-
1437
- /**
1438
- * 从当前元素的父元素开始沿 DOM 树向上,获得匹配选择器的所有祖先元素。
1439
- */
1440
- function parents(selector) {
1441
- const parents = []; // eslint-disable-line
1442
- for (let i = 0; i < this.length; i += 1) {
1443
- let parent = this[i].parentNode; // eslint-disable-line
1444
- while (parent) {
1445
- if (selector) {
1446
- if ($(parent).is(selector)) parents.push(parent);
1447
- } else parents.push(parent);
1448
-
1449
- parent = parent.parentNode;
1450
- }
1451
- }
1452
- return $($.uniq(parents));
1453
- }
1454
-
1455
- /**
1456
- * 从当前元素的父元素开始沿 DOM 树向上,获得匹配选择器的第一个祖先元素。
1457
- * 选择器为空,则返回 空
1458
- */
1459
- function parentNode(sel) {
1460
- const R = [];
1461
-
1462
- for (let i = 0; i < this.length; i += 1) {
1463
- let pn = this[i].parentNode;
1464
- while (pn) {
1465
- if (sel) {
1466
- if ($(pn).is(sel)) {
1467
- R.push(pn);
1468
- return $(R, sel);
1469
- }
1470
- } else {
1471
- R.push(pn);
1472
- return $(R, sel);
1473
- }
1474
-
1475
- pn = pn.parentNode;
1476
- }
1477
- }
1478
- return $(R, sel);
1479
- }
1480
-
1481
- /**
1482
- * 从当前元素开始沿 DOM 树向上,获得匹配选择器的第一个祖先元素。
1483
- * 当前节点符合,则返回当前节点
1484
- * 选择器为空,则返回 空
1485
- */
1486
- function closest(sel) {
1487
- let self = this; // eslint-disable-line
1488
- if (typeof sel === 'undefined') return $();
1489
-
1490
- // ~开头,按 name 属性查找
1491
- if (sel[0] === '~') sel = `[name=${sel.substr(1)}]`;
1492
-
1493
- if (!self.is(sel)) {
1494
-
1495
- for (let i = 0; i < this.length; i += 1) {
1496
- let parent = this[i].parentNode; // eslint-disable-line
1497
- while (parent) {
1498
- const d = $(parent);
1499
- if (d.is(sel)) return d;
1500
-
1501
- parent = parent.parentNode;
1502
- }
1503
- }
1504
-
1505
- return $();
1506
- }
1507
-
1508
- return self;
1509
- }
1510
-
1511
- function upper(sel) {
1512
- return closest.bind(this)(sel);
1513
- }
1514
-
1515
- /**
1516
- * 后代中所有适合选择器的元素
1517
- * @param {*} sel
1518
- */
1519
- function find(sel) {
1520
- let R = null;
1521
- if (!sel) return $();
1522
-
1523
- // ~开头,按 name 属性查找
1524
- if (sel[0] === '~') sel = `[name=${sel.substr(1)}]`;
1525
-
1526
- const self = this;
1527
- // 选择器为对象
1528
- if (typeof sel === 'object')
1529
- R = $(sel).filter(function () {
1530
- const node = this;
1531
- return emptyArray.some.call(self, function (pn) {
1532
- return $.contains(pn, node);
1533
- });
1534
- });
1535
- else if (this.length === 1) R = $($.qsa(sel, this[0]));
1536
- else
1537
- R = this.map(function () {
1538
- return $.qsa(sel, this);
1539
- });
1540
-
1541
- return R || $();
1542
- }
1543
-
1544
- /**
1545
- * 后代中单个适合选择器的元素,效率高于find
1546
- * 不支持对象参数
1547
- * @param {*} sel
1548
- */
1549
- function findNode(sel) {
1550
- let R = null;
1551
- if (!sel) return $();
1552
-
1553
- // ~开头,按 name 属性查找
1554
- if (sel[0] === '~') sel = `[name=${sel.substr(1)}]`;
1555
-
1556
- if (this.length === 1) R = $($.qu(sel, this[0]));
1557
- else
1558
- R = this.map(function () {
1559
- return $.qu(sel, this);
1560
- });
1561
-
1562
- return R || $();
1563
- }
1564
-
1565
- /**
1566
- * 返回所有dom的所有符合条件的直接子元素,不包括文本节点
1567
- * @param {*} sel
1568
- */
1569
- function children(sel) {
1570
- const cs = []; // eslint-disable-line
1571
- for (let i = 0; i < this.length; i += 1) {
1572
- const childs = this[i].children;
1573
-
1574
- for (let j = 0; j < childs.length; j += 1) {
1575
- if (!sel) {
1576
- cs.push(childs[j]);
1577
- } else if ($(childs[j]).is(sel)) cs.push(childs[j]);
1578
- }
1579
- }
1580
- return $($.uniq(cs));
1581
- }
1582
-
1583
- /**
1584
- * 返回被选元素的第一个符合条件直接子元素,不包括文本节点
1585
- * @param {*} sel
1586
- */
1587
- function childNode(sel) {
1588
- return child.bind(this)(sel);
1589
- }
1590
-
1591
- /**
1592
- * 返回被选元素的第一个符合条件直接单个子元素,不包括文本节点
1593
- * 或者 替换节点的所有子元素
1594
- * @param {*} sel
1595
- */
1596
- function child(sel) {
1597
- if ($.isDom(sel)) {
1598
- this.empty().append(sel);
1599
- return this;
1600
- }
1601
-
1602
- const cs = []; // eslint-disable-line
1603
- for (let i = 0; i < this.length; i += 1) {
1604
- const childs = this[i].children;
1605
-
1606
- for (let j = 0; j < childs.length; j += 1) {
1607
- if (!sel) {
1608
- cs.push(childs[j]);
1609
- break;
1610
- } else if ($(childs[j]).is(sel)) {
1611
- cs.push(childs[j]);
1612
- break;
1613
- }
1614
- }
1615
- }
1616
- return $(cs, sel);
1617
- }
1618
-
1619
- function remove() {
1620
- return this.each(function () {
1621
- if (this.parentNode != null) this.parentNode.removeChild(this);
1622
- });
1623
- }
1624
-
1625
- function detach() {
1626
- return this.remove();
1627
- }
1628
-
1629
- function add(...args) {
1630
- const dom = this;
1631
- let i;
1632
- let j;
1633
- for (i = 0; i < args.length; i += 1) {
1634
- const toAdd = $(args[i]);
1635
- for (j = 0; j < toAdd.length; j += 1) {
1636
- dom[dom.length] = toAdd[j];
1637
- dom.length += 1;
1638
- }
1639
- }
1640
- return dom;
1641
- }
1642
-
1643
- function empty() {
1644
- return this.each(function () {
1645
- this.innerHTML = '';
1646
- });
1647
- }
1648
-
1649
- /**
1650
- * 是否包含子元素,不含文本节点
1651
- */
1652
- function hasChild() {
1653
- if (!this.dom) return false;
1654
- return this.dom.children.length > 0;
1655
- }
1656
-
1657
- /**
1658
- * 第一个子元素节点,不含文本节点
1659
- */
1660
- function firstChild() {
1661
- if (!this.dom || this.dom.children.length === 0) return null;
1662
- return $([this.dom.children[0]]);
1663
- }
1664
-
1665
- /**
1666
- * 最后一个子元素节点,不含文本节点
1667
- */
1668
- function lastChild() {
1669
- if (!this.dom || this.dom.children.length === 0) return null;
1670
- return $([this.dom.children[this.dom.children.length - 1]]);
1671
- }
1672
-
1673
- /**
1674
- * 元素子节点数量,不含文本节点
1675
- */
1676
- function childCount() {
1677
- if (!this.dom) return 0;
1678
- return this.dom.children.length;
1679
- }
1680
-
1681
- /**
1682
- * 光标放入尾部
1683
- * @param el
1684
- */
1685
- function cursorEnd() {
1686
- if (!this.dom) return null;
1687
-
1688
- const el = this.dom;
1689
- el.focus();
1690
-
1691
- if (typeof window.getSelection !== 'undefined' && typeof document.createRange !== 'undefined') {
1692
- const rg = document.createRange();
1693
- rg.selectNodeContents(el);
1694
- // 合并光标
1695
- rg.collapse(false);
1696
- const sel = window.getSelection();
1697
- sel.removeAllRanges();
1698
- sel.addRange(rg);
1699
- } else if (typeof document.body.createTextRangrge !== 'undefined') {
1700
- const rg = document.body.createTextRange();
1701
- rg.moveToElementText(el);
1702
- // 合并光标
1703
- rg.collapse(false);
1704
- // textRange.moveStart('character', 3);
1705
- rg.select();
1706
- }
1707
- }
1708
-
1709
- /**
1710
- * 获取光标位置
1711
- * @returns {number}
1712
- */
1713
- function getCursorPos() {
1714
- let R = 0;
1715
-
1716
- if (!this.dom) return 0;
1717
-
1718
- const el = this.dom;
1719
-
1720
- // obj.focus();
1721
- if (el.selectionStart) {
1722
- // IE以外
1723
- R = el.selectionStart;
1724
- } else {
1725
- // IE
1726
- let rg = null;
1727
- if (el.tagName.toLowerCase() === 'textarea') {
1728
- // TEXTAREA
1729
- rg = event.srcElement.createTextRange();
1730
- rg.moveToPoint(event.x, event.y);
1731
- } else {
1732
- // Text
1733
- rg = document.selection.createRange();
1734
- }
1735
- rg.moveStart('character', -event.srcElement.value.length);
1736
- // rg.setEndPoint("StartToStart", obj.createTextRange())
1737
- R = rg.text.length;
1738
- }
1739
- return R;
1740
- }
1741
-
1742
- /**
1743
- * 得到光标的位置
1744
- */
1745
- function getCursorPosition() {
1746
- if (!this.dom) return 0;
1747
-
1748
- const el = this.dom;
1749
-
1750
- const qswh = '@#%#^&#*$';
1751
- // obj.focus();
1752
- const rng = document.selection.createRange();
1753
- rng.text = qswh;
1754
- const nPosition = el.value.indexOf(qswh);
1755
- rng.moveStart('character', -qswh.length);
1756
- rng.text = '';
1757
- return nPosition;
1758
- }
1759
-
1760
- /**
1761
- * 设置光标位置
1762
- */
1763
- function setCursorPos(pos) {
1764
- if (!this.dom) return;
1765
-
1766
- const rg = this.dom.createTextRange();
1767
- rg.collapse(true);
1768
- rg.moveStart('character', pos);
1769
- rg.select();
1770
- }
1771
-
1772
- /**
1773
- * 移到第一行
1774
- */
1775
- function moveFirst() {
1776
- this.rowindex = 0;
1777
- }
1778
-
1779
- /**
1780
- * querySelector
1781
- * return only first
1782
- */
1783
- function qu(sel) {
1784
- let n = [];
1785
- try {
1786
- n = this.dom?.querySelector(sel);
1787
- } catch (e) {}
1788
-
1789
- return $(n || []);
1790
- }
1791
-
1792
- function qus(sel) {
1793
- return $(sel, this.dom);
1794
- }
1795
-
1796
- /**
1797
- * querySelector attribute
1798
- * return only first
1799
- */
1800
- function att(n, v) {
1801
- let R = [];
1802
- try {
1803
- if (this.attr(n) === v) return this; // 自己符合,返回自身
1804
- R = this.dom?.querySelector(`[${n}=${v}]`);
1805
- } catch (e) {}
1806
- return $(R || []);
1807
- }
1808
-
1809
- function atts(n, v) {
1810
- let R = [];
1811
- try {
1812
- R = $(`[${n}=${v}]`, this.dom);
1813
- if (this.attr(n) === v) R.push(this.dom); // 自己符合,添加自身
1814
- } catch (e) {}
1815
- return $(R || []);
1816
- }
1817
-
1818
- /**
1819
- * querySelector name
1820
- * return only first
1821
- */
1822
- function name(v) {
1823
- return this.att('name', v);
1824
- }
1825
-
1826
- function fastLink() {
1827
- $.fastLink(this);
1828
- return this;
1829
- }
1830
-
1831
- /**
1832
- * name 属性组件直接绑定到当前Dom实例,方便调用
1833
- * 只挂载一个,多个同名name,最后一个起作用,因此一个页面内,name不要重复
1834
- * 同节点多次调用不覆盖,同名不同dom节点,覆盖
1835
- * 覆盖后,原直接节点属性的 bind 会失效,需使用新的$dom重新bind
1836
- * 动态内容一般在 ready 中创建,创建后name会自动挂载
1837
- * show/back 中创建的动态内容,未自动挂载,需调用 bindName 挂载!
1838
- */
1839
- function bindName() {
1840
- const ns = this.qus('[name]');
1841
- ns?.forEach(n => {
1842
- const $n = $(n);
1843
- const nm = $n.attr('name');
1844
- if (!this.n) this.n = {};
1845
- if (!this.n[nm] || this.n[nm].dom !== n) this.n[nm] = $n;
1846
- });
1847
-
1848
- return this;
1849
- }
1850
-
1851
- function names(v) {
1852
- return this.atts('name', v);
1853
- }
1854
-
1855
- /**
1856
- * querySelector ClassName
1857
- * cls: 'aaa, bbb' => '.aaa, .bbb'
1858
- * return only first node
1859
- */
1860
- function clas(cls) {
1861
- let R = [];
1862
-
1863
- if (!cls) return $();
1864
-
1865
- try {
1866
- const rs = [];
1867
- const cs = cls.split(',');
1868
- cs.forEach(c => {
1869
- if (c) {
1870
- if (c.includes('.')) rs.push(c.trim());
1871
- else rs.push(`.${c.trim()}`);
1872
- }
1873
- });
1874
-
1875
- R = this.dom?.querySelector(rs.join(','));
1876
- } catch (e) {}
1877
-
1878
- return $(R || []);
1879
- }
1880
-
1881
- /**
1882
- * querySelectorAll ClassName
1883
- * cls: 'aaa, bbb' => '.aaa, .bbb'
1884
- * return all node
1885
- */
1886
- function classes(cls) {
1887
- let R = [];
1888
-
1889
- if (!cls) return $();
1890
-
1891
- try {
1892
- const rs = [];
1893
- const cs = cls.split(',');
1894
- cs.forEach(c => {
1895
- if (c.includes('.')) rs.push(c.trim());
1896
- else rs.push(`.${c.trim()}`);
1897
- });
1898
-
1899
- const ns = this.dom?.querySelectorAll(rs.join(','));
1900
- // if (ns && ns.length > 0) R = slice.call(ns);
1901
- if (ns && ns.length > 0) R = Array.from(ns);
1902
- } catch (e) {}
1903
-
1904
- return $(R || []);
1905
- }
1906
-
1907
- /**
1908
- * querySelector TagName
1909
- * tag: 'div'
1910
- * return only first
1911
- */
1912
- function tag(t) {
1913
- let R = this.dom?.getElementsByTagName(t);
1914
- if (R) R = R[0];
1915
-
1916
- return $(R);
1917
- }
1918
-
1919
- function tags(t) {
1920
- let R = this.dom?.getElementsByTagName(t);
1921
- if (R && R.length > 0) R = [].slice.call(R);
1922
- else R = [];
1923
-
1924
- return $(R);
1925
- }
1926
-
1927
- const Methods = /*#__PURE__*/Object.freeze({
1928
- __proto__: null,
1929
- add: add,
1930
- animationEnd: animationEnd,
1931
- att: att,
1932
- attr: attr,
1933
- atts: atts,
1934
- bindName: bindName,
1935
- child: child,
1936
- childCount: childCount,
1937
- childNode: childNode,
1938
- children: children,
1939
- class: clas,
1940
- classes: classes,
1941
- clone: clone,
1942
- closest: closest,
1943
- concat: concat,
1944
- css: css,
1945
- cursorEnd: cursorEnd,
1946
- data: data,
1947
- dataset: dataset,
1948
- detach: detach,
1949
- each: each,
1950
- empty: empty,
1951
- eq: eq,
1952
- every: every,
1953
- fastLink: fastLink,
1954
- filter: filter,
1955
- find: find,
1956
- findNode: findNode,
1957
- first: first,
1958
- firstChild: firstChild,
1959
- forEach: forEach,
1960
- get: get,
1961
- getCursorPos: getCursorPos,
1962
- getCursorPosition: getCursorPosition,
1963
- hasAttr: hasAttr,
1964
- hasChild: hasChild,
1965
- height: height,
1966
- hide: hide,
1967
- html: html,
1968
- index: index,
1969
- indexOf: indexOf,
1970
- is: is,
1971
- last: last,
1972
- lastChild: lastChild,
1973
- map: map,
1974
- moveFirst: moveFirst,
1975
- name: name,
1976
- names: names,
1977
- next: next,
1978
- nextAll: nextAll,
1979
- nextNode: nextNode,
1980
- not: not,
1981
- off: off,
1982
- offset: offset,
1983
- offsetParent: offsetParent,
1984
- on: on,
1985
- once: once,
1986
- outerHeight: outerHeight,
1987
- outerWidth: outerWidth,
1988
- parent: parent,
1989
- parentNode: parentNode,
1990
- parents: parents,
1991
- pluck: pluck,
1992
- position: position,
1993
- prev: prev,
1994
- prevAll: prevAll,
1995
- prevNode: prevNode,
1996
- prop: prop,
1997
- qu: qu,
1998
- qus: qus,
1999
- ready: ready,
2000
- rect: rect,
2001
- remove: remove,
2002
- removeAttr: removeAttr,
2003
- removeData: removeData,
2004
- removeProp: removeProp,
2005
- replaceWith: replaceWith,
2006
- setCursorPos: setCursorPos,
2007
- show: show,
2008
- siblings: siblings,
2009
- size: size,
2010
- slice: slice,
2011
- some: some,
2012
- styles: styles,
2013
- tag: tag,
2014
- tags: tags,
2015
- text: text,
2016
- toArray: toArray,
2017
- transform: transform,
2018
- transition: transition,
2019
- transitionEnd: transitionEnd,
2020
- trigger: trigger,
2021
- upper: upper,
2022
- val: val,
2023
- width: width
2024
- });
2025
-
2026
- /**
2027
- * 支持按动画滚动窗口
2028
- * @param {...any} args
2029
- * left, top, duration, easing, callback
2030
- * @returns
2031
- */
2032
- function scrollTo(...args) {
2033
- let [left, top, duration, easing, callback] = args;
2034
- if (args.length === 4 && typeof easing === 'function') {
2035
- callback = easing;
2036
- [left, top, duration, callback, easing] = args;
2037
- }
2038
- if (typeof easing === 'undefined') easing = 'swing';
2039
-
2040
- return this.each(function animate() {
2041
- const el = this; // dom
2042
-
2043
- let currentTop;
2044
- let currentLeft;
2045
- let maxTop;
2046
- let maxLeft;
2047
- let newTop;
2048
- let newLeft;
2049
- let scrollTop; // eslint-disable-line
2050
- let scrollLeft; // eslint-disable-line
2051
-
2052
- if (typeof easing === 'undefined') easing = 'swing';
2053
- const hasScrollTop = 'scrollTop' in el;
2054
- const hasScrollLeft = 'scrollLeft' in el;
2055
-
2056
- let animateTop = top > 0 || top === 0;
2057
- let animateLeft = left > 0 || left === 0;
2058
-
2059
- if (animateTop) {
2060
- currentTop = el.scrollTop;
2061
- if (!duration) {
2062
- if (hasScrollTop) el.scrollTop = top;
2063
- else el.scrollTo(el.scrollX, top);
2064
- }
2065
- }
2066
-
2067
- if (animateLeft) {
2068
- currentLeft = el.scrollLeft;
2069
- if (!duration) {
2070
- if (hasScrollLeft) el.scrollLeft = left;
2071
- else el.scrollTo(left, el.scrollY);
2072
- }
2073
- }
2074
-
2075
- // 不需要动画
2076
- if (!duration) return;
2077
-
2078
- // 延时动画
2079
- if (animateTop) {
2080
- maxTop = el.scrollHeight - el.offsetHeight;
2081
- newTop = Math.max(Math.min(top, maxTop), 0);
2082
- }
2083
-
2084
- if (animateLeft) {
2085
- maxLeft = el.scrollWidth - el.offsetWidth;
2086
- newLeft = Math.max(Math.min(left, maxLeft), 0);
2087
- }
2088
-
2089
- let startTime = null;
2090
- if (animateTop && newTop === currentTop) animateTop = false;
2091
- if (animateLeft && newLeft === currentLeft) animateLeft = false;
2092
-
2093
- function render(time = new Date().getTime()) {
2094
- if (startTime === null) {
2095
- startTime = time;
2096
- }
2097
- const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
2098
- const easeProgress =
2099
- easing === 'linear' ? progress : 0.5 - Math.cos(progress * Math.PI) / 2;
2100
-
2101
- let done;
2102
- if (animateTop)
2103
- scrollTop = currentTop + easeProgress * (newTop - currentTop);
2104
- if (animateLeft)
2105
- scrollLeft = currentLeft + easeProgress * (newLeft - currentLeft);
2106
- if (animateTop && newTop > currentTop && scrollTop >= newTop) {
2107
- el.scrollTop = newTop;
2108
- done = true;
2109
- }
2110
- if (animateTop && newTop < currentTop && scrollTop <= newTop) {
2111
- el.scrollTop = newTop;
2112
- done = true;
2113
- }
2114
- if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) {
2115
- el.scrollLeft = newLeft;
2116
- done = true;
2117
- }
2118
- if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) {
2119
- el.scrollLeft = newLeft;
2120
- done = true;
2121
- }
2122
-
2123
- if (done) {
2124
- if (callback) callback();
2125
- return;
2126
- }
2127
-
2128
- if (animateTop) el.scrollTop = scrollTop;
2129
- if (animateLeft) el.scrollLeft = scrollLeft;
2130
- $.requestAnimationFrame(render);
2131
- }
2132
- $.requestAnimationFrame(render);
2133
- });
2134
- }
2135
-
2136
- /**
2137
- * 垂直滚动
2138
- * @param {...any} args
2139
- * top 滚动距离
2140
- * duration 动画时长
2141
- * easing 动画
2142
- * callback 滚动完成后的回调
2143
- * @returns
2144
- */
2145
- function scrollTop(...args) {
2146
- if (!this.length) return;
2147
-
2148
- let [top, duration, easing, callback] = args;
2149
- if (args.length === 3 && typeof easing === 'function') {
2150
- [top, duration, callback, easing] = args;
2151
- }
2152
- const hasScrollTop = 'scrollTop' in this[0];
2153
-
2154
- // 没有传值,则取回当前dom节点的scrollTop
2155
- if (top === undefined)
2156
- return hasScrollTop ? this[0].scrollTop : this[0].pageYOffset;
2157
-
2158
- return this.scrollTo(undefined, top, duration, easing, callback);
2159
- }
2160
-
2161
- /**
2162
- * 水平滚动
2163
- * @param {...any} args
2164
- * left 滚动距离
2165
- * duration 动画时长
2166
- * easing 动画
2167
- * callback 滚动完成后的回调
2168
- * @returns
2169
- */
2170
- function scrollLeft(...args) {
2171
- if (!this.length) return;
2172
-
2173
- let [left, duration, easing, callback] = args;
2174
- if (args.length === 3 && typeof easing === 'function') {
2175
- [left, duration, callback, easing] = args;
2176
- }
2177
-
2178
- const hasScrollLeft = 'scrollLeft' in this[0];
2179
- if (left === undefined)
2180
- return hasScrollLeft ? this[0].scrollLeft : this[0].pageXOffset;
2181
-
2182
- return this.scrollTo(left, undefined, duration, easing, callback);
2183
- }
2184
-
2185
- function scrollHeight() {
2186
- return this[0].scrollHeight;
2187
- }
2188
-
2189
- function scrollWidth() {
2190
- return this[0].scrollWidth;
2191
- }
2192
-
2193
- const Scroll = /*#__PURE__*/Object.freeze({
2194
- __proto__: null,
2195
- scrollHeight: scrollHeight,
2196
- scrollLeft: scrollLeft,
2197
- scrollTo: scrollTo,
2198
- scrollTop: scrollTop,
2199
- scrollWidth: scrollWidth
2200
- });
2201
-
2202
- function animate(initialProps, initialParams) {
2203
- const els = this;
2204
- const a = {
2205
- props: Object.assign({}, initialProps),
2206
- params: Object.assign(
2207
- {
2208
- duration: 300,
2209
- easing: 'swing', // or 'linear'
2210
- /* Callbacks
2211
- begin(elements)
2212
- complete(elements)
2213
- progress(elements, complete, remaining, start, tweenValue)
2214
- */
2215
- },
2216
- initialParams
2217
- ),
2218
-
2219
- elements: els,
2220
- animating: false,
2221
- que: [],
2222
-
2223
- easingProgress(easing, progress) {
2224
- if (easing === 'swing') {
2225
- return 0.5 - Math.cos(progress * Math.PI) / 2;
2226
- }
2227
- if (typeof easing === 'function') {
2228
- return easing(progress);
2229
- }
2230
- return progress;
2231
- },
2232
- stop() {
2233
- if (a.frameId) {
2234
- $.cancelAnimationFrame(a.frameId);
2235
- }
2236
- a.animating = false;
2237
- a.elements.each((index, el) => {
2238
- const element = el;
2239
- delete element.dom7AnimateInstance;
2240
- });
2241
- a.que = [];
2242
- },
2243
- done(complete) {
2244
- a.animating = false;
2245
- a.elements.each((index, el) => {
2246
- const element = el;
2247
- delete element.domAnimateInstance;
2248
- });
2249
- if (complete) complete(els);
2250
- if (a.que.length > 0) {
2251
- const que = a.que.shift();
2252
- a.animate(que[0], que[1]);
2253
- }
2254
- },
2255
- animate(props, params) {
2256
- if (a.animating) {
2257
- a.que.push([props, params]);
2258
- return a;
2259
- }
2260
- const elements = [];
2261
-
2262
- // Define & Cache Initials & Units
2263
- a.elements.each((index, el) => {
2264
- let initialFullValue;
2265
- let initialValue;
2266
- let unit;
2267
- let finalValue;
2268
- let finalFullValue;
2269
-
2270
- if (!el.dom7AnimateInstance) a.elements[index].domAnimateInstance = a;
2271
-
2272
- elements[index] = {
2273
- container: el,
2274
- };
2275
- Object.keys(props).forEach(prop => {
2276
- initialFullValue = window
2277
- .getComputedStyle(el, null)
2278
- .getPropertyValue(prop)
2279
- .replace(',', '.');
2280
- initialValue = parseFloat(initialFullValue);
2281
- unit = initialFullValue.replace(initialValue, '');
2282
- finalValue = parseFloat(props[prop]);
2283
- finalFullValue = props[prop] + unit;
2284
- elements[index][prop] = {
2285
- initialFullValue,
2286
- initialValue,
2287
- unit,
2288
- finalValue,
2289
- finalFullValue,
2290
- currentValue: initialValue,
2291
- };
2292
- });
2293
- });
2294
-
2295
- let startTime = null;
2296
- let time;
2297
- let elementsDone = 0;
2298
- let propsDone = 0;
2299
- let done;
2300
- let began = false;
2301
-
2302
- a.animating = true;
2303
-
2304
- function render() {
2305
- time = new Date().getTime();
2306
- let progress;
2307
- let easeProgress;
2308
- // let el;
2309
- if (!began) {
2310
- began = true;
2311
- if (params.begin) params.begin(els);
2312
- }
2313
- if (startTime === null) {
2314
- startTime = time;
2315
- }
2316
- if (params.progress) {
2317
- // eslint-disable-next-line
2318
- params.progress(
2319
- els,
2320
- Math.max(Math.min((time - startTime) / params.duration, 1), 0),
2321
- startTime + params.duration - time < 0
2322
- ? 0
2323
- : startTime + params.duration - time,
2324
- startTime
2325
- );
2326
- }
2327
-
2328
- elements.forEach(element => {
2329
- const el = element;
2330
- if (done || el.done) return;
2331
- Object.keys(props).forEach(prop => {
2332
- if (done || el.done) return;
2333
- progress = Math.max(
2334
- Math.min((time - startTime) / params.duration, 1),
2335
- 0
2336
- );
2337
- easeProgress = a.easingProgress(params.easing, progress);
2338
- const {initialValue, finalValue, unit} = el[prop];
2339
- el[prop].currentValue =
2340
- initialValue + easeProgress * (finalValue - initialValue);
2341
- const currentValue = el[prop].currentValue;
2342
-
2343
- if (
2344
- (finalValue > initialValue && currentValue >= finalValue) ||
2345
- (finalValue < initialValue && currentValue <= finalValue)
2346
- ) {
2347
- el.container.style[prop] = finalValue + unit;
2348
- propsDone += 1;
2349
- if (propsDone === Object.keys(props).length) {
2350
- el.done = true;
2351
- elementsDone += 1;
2352
- }
2353
- if (elementsDone === elements.length) {
2354
- done = true;
2355
- }
2356
- }
2357
- if (done) {
2358
- a.done(params.complete);
2359
- return;
2360
- }
2361
- el.container.style[prop] = currentValue + unit;
2362
- });
2363
- });
2364
- if (done) return;
2365
- // Then call
2366
- a.frameId = $.requestAnimationFrame(render);
2367
- }
2368
- a.frameId = $.requestAnimationFrame(render);
2369
- return a;
2370
- },
2371
- };
2372
-
2373
- if (a.elements.length === 0) {
2374
- return els;
2375
- }
2376
-
2377
- let animateInstance;
2378
- for (let i = 0; i < a.elements.length; i += 1) {
2379
- if (a.elements[i].domAnimateInstance) {
2380
- animateInstance = a.elements[i].domAnimateInstance;
2381
- } else a.elements[i].domAnimateInstance = a;
2382
- }
2383
- if (!animateInstance) {
2384
- animateInstance = a;
2385
- }
2386
-
2387
- if (initialProps === 'stop') {
2388
- animateInstance.stop();
2389
- } else {
2390
- animateInstance.animate(a.props, a.params);
2391
- }
2392
-
2393
- return els;
2394
- }
2395
-
2396
- function stop() {
2397
- const els = this;
2398
- for (let i = 0; i < els.length; i += 1) {
2399
- if (els[i].domAnimateInstance) {
2400
- els[i].domAnimateInstance.stop();
2401
- }
2402
- }
2403
- }
2404
-
2405
- /**
2406
- * 通过css3 Translate 移动后,获取 x 或 y 坐标
2407
- * @param {*} el
2408
- * @param {*} axis
2409
- */
2410
- function getTranslate(axis = 'x') {
2411
- const els = this;
2412
- if (!els || !els.dom) return 0;
2413
-
2414
- const el = els.dom;
2415
-
2416
- let matrix;
2417
- let curTransform;
2418
- let transformMatrix;
2419
-
2420
- const curStyle = window.getComputedStyle(el, null);
2421
-
2422
- if (window.WebKitCSSMatrix) {
2423
- curTransform = curStyle.transform || curStyle.webkitTransform;
2424
- if (curTransform.split(',').length > 6) {
2425
- curTransform = curTransform
2426
- .split(', ')
2427
- .map(a => a.replace(',', '.'))
2428
- .join(', ');
2429
- }
2430
- // Some old versions of Webkit choke when 'none' is passed; pass
2431
- // empty string instead in this case
2432
- transformMatrix = new window.WebKitCSSMatrix(
2433
- curTransform === 'none' ? '' : curTransform
2434
- );
2435
- } else {
2436
- transformMatrix =
2437
- curStyle.MozTransform ||
2438
- curStyle.OTransform ||
2439
- curStyle.MsTransform ||
2440
- curStyle.msTransform ||
2441
- curStyle.transform ||
2442
- curStyle
2443
- .getPropertyValue('transform')
2444
- .replace('translate(', 'matrix(1, 0, 0, 1,');
2445
- matrix = transformMatrix.toString().split(',');
2446
- }
2447
-
2448
- if (axis === 'x') {
2449
- // Latest Chrome and webkits Fix
2450
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
2451
- // Crazy IE10 Matrix
2452
- else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
2453
- // Normal Browsers
2454
- else curTransform = parseFloat(matrix[4]);
2455
- }
2456
- if (axis === 'y') {
2457
- // Latest Chrome and webkits Fix
2458
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
2459
- // Crazy IE10 Matrix
2460
- else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
2461
- // Normal Browsers
2462
- else curTransform = parseFloat(matrix[5]);
2463
- }
2464
- return curTransform || 0;
2465
- }
2466
-
2467
- const Animate = /*#__PURE__*/Object.freeze({
2468
- __proto__: null,
2469
- animate: animate,
2470
- getTranslate: getTranslate,
2471
- stop: stop
2472
- });
2473
-
2474
- /**
2475
- * 实现页面视图(不限表单)与数据交互
2476
- *
2477
- * 简介:
2478
- * 数据与视图交互是所有带UI界面都需实现的基本功能,不同开发框架都制定了一套固定机制。
2479
- * 其中web前端与所有其他UI(原生ios、安卓、windows)都不一样,由于其开放、自由、无主,
2480
- * 导致没有一套固定机制,不同人、不同组织提供的开发框架、方式几十上百种。
2481
- *
2482
- * 最原始的方法,是通过jQuery操作页面dom对象完成,工作量大,效率低、容易出错,逐渐被淘汰。
2483
- * 现在主流的vue、react、angular都需要学习一套新的语法、知识、理论,并且不仅仅如此,
2484
- * 一旦采用其中一种,就得整体采用其全家桶,陷入技术陷阱。
2485
- * wia的form通过最自然的es6插值方式,在html页面写入插值即可实现数据展示。
2486
- * 这种方式,理解起来非常自然,一看就会,无需学习任何新的知识。
2487
- *
2488
- * setForm 分解对象属性(key)按名称匹配视图内的dom对象或模板,进行赋值。
2489
- * 属性名称对应的视图,可以是input,也可以是模板,模板则按setView方式赋值。
2490
- * 隐藏域(hidden)一般会带模板,通过模板展示内容(数组、对象),隐藏域收集信息。
2491
- * setForm调用了setView,可以理解为setView的批量调用。
2492
- * 比如页面有三个视图,a、b、c,通过 {a:v1,b:v2,c:v3},setForm等于调用了三次setView。
2493
- * 如果展示页面有input部分,需使用setForm。
2494
- * setForm 一般用于表单,不限于表单,也可以用于层。
2495
- * setView 不分解对象属性,将对象整体直接作为r传入页面模板${r.xxx},
2496
- * 进行字符串替换,支持子对象${r.aaa.bbb}。
2497
- * 如果只是页面模板展示,没有input,直接使用setView。
2498
- * 模板 es6中的插值字符串模式,${r.xxx},r为传入的对象,支持子对象、简单运算。
2499
- * 图片src,模板需使用src-tp="http://${r.url}",渲染时自动改为src。
2500
- * 直接使用src浏览器会下载http://${r.url},这个资源肯定找不到。
2501
- *
2502
- * 1. 简单数据直接填入 input的value。
2503
- * 2. 复杂数据,如对象、数组等,则填入 隐藏域 的data 对象,
2504
- * 并通过页面模板实现复杂数据展示。
2505
- * 3. 页面模板(数据替换展示),隐藏在页面,通过克隆模板替换插值字符串实现展现。
2506
- * 名称:name-tp,一般传入对象数组或对象,用于赋值,模板自身隐藏。
2507
- * 属性tp="kv":key-value键值对,对应模板中的${r.k} ${r.v},用于引用对象属性及值,实现动态列表。
2508
- * 属性tp="kv-3":${r.k1} ${r.v1} ${r.k2} ${r.v2} ${r.k3} ${r.v3} 对应对象中的第一个、第二个、第三个属性,
2509
- * 用于横向多列对象多属性展现,比如 PC版本订单详情,横向3列。
2510
- * 名称:name-val:直接按模板替换,与名称为 name效果等同。
2511
- * 名称:name:如果内部有 ${字符,则视为直接替换模板,类似 name-val。
2512
- * 4. 数据输出到页面,通过以下函数:
2513
- * setForm 对象数据对Form表单或者Div层,进行数据展现,每个字段对应同名dom或者name-tp模板。
2514
- * setView 对单个字段或视图,进行数据展现,如果为空,则清除
2515
- * addView 单个字段或视图,增加数据
2516
- * 5. 读取页面数据
2517
- * getForm 读取整个页面数据,返回 FormData 对象
2518
- * getView 读取指定字段数据,返回 仅仅包含 指定字段的 FormData对象
2519
- * 读取时,自动将所有隐藏域的data对象,转换为json字符串,方便FormData 提交服务器。
2520
- * 6. 对于重复 name 的 input,一般是对象数组,自动转换为对象数组,存入 FormData,
2521
- * 方便服务器处理。
2522
- * 7. 重复数据通过id 和 _id 字段判断,addView时,重复id 或 _id,删除之前的对象,仅保存新增的对象。
2523
- * id 作为服务器返回的字段,_id 作为客户端添加的字段,
2524
- * getForm 或 getView 时,tp模板自动删除,不返回给服务器,避免影响服务器数据。
2525
- * 8. 以上方法 绑定到 $.fn 中,使用时,按 Dom类似方法使用,如:
2526
- * _.name('fmData').setForm(data);
2527
- */
2528
-
2529
- /**
2530
- * 视图数据展现
2531
- * setViews 调用了 setView,为setView的批量操作
2532
- * 用于 tp模板中的form表单场景
2533
- * 数据内的元素,支持数组、对象,一次性实现整个容器的数据展现
2534
- * 根据数据项名称,自动查找页面对应input(按名称) 或 视图层(name 或 name-tp),实现数据展现
2535
- * 调用该方法的容器一般是 Form,也支持非Form,如 div
2536
- * 容器中的节点, 一般是input, 也支持非input,通过对象属性名称对应dom名称实现匹配展现
2537
- * 如果数据为数组,则使用调用者同名模板,生成多节点,
2538
- * field、input隐藏域带模板,会按模板生成字段部分展现
2539
- * 模板名称为 name-tp,根据模板添加后的节点名称为 name-data
2540
- * @param {*} v 数据
2541
- * @param {*} n 模板名称,可选,如果不填,默认调用者的name
2542
- * 注意,setViews的模板与setView中的模板不一样
2543
- * setViews 模板先调用clone克隆模板节点,不赋值,后续再调用 setView 进行赋值。
2544
- * 意味着 setViews 中的模板里面可以再嵌套字段模板。
2545
- * setView中的模板,使用带${r.name}这种插值模板,根据后台r数据,生成带数据值的 html。
2546
- * @param {*} add 新增,可选
2547
- */
2548
- function setForms(v, n, add = false) {
2549
- try {
2550
- const el = this;
2551
- // 清空所有数据,填充新数据
2552
- if (!add) clearForm.bind(el)();
2553
-
2554
- if (!n) n = el.attr('name');
2555
-
2556
- // 使用模板
2557
- if (n) {
2558
- const tp = el.name(`${n}-tp`);
2559
- if (tp.length) {
2560
- tp.hide();
2561
- if ($.isArray(v))
2562
- v.forEach(r => {
2563
- setTpForm.bind(el)(n, r, add);
2564
- });
2565
- else setTpForm.bind(el)(n, v, add);
2566
- }
2567
- }
2568
- } catch (ex) {
2569
- console.error('setForms exp.', {msg: ex.message});
2570
- }
2571
- }
2572
-
2573
- /**
2574
- * 向 view 中添加值
2575
- * @param {*} el 容器
2576
- * @param {*} k 字段名称
2577
- * @param {*} v 新增数据
2578
- */
2579
- function addForms(v, n) {
2580
- const el = this;
2581
- if (!n) n = el.attr('name');
2582
- setForms.bind(el)(v, n, true);
2583
- }
2584
-
2585
- /**
2586
- * 读取整个页面表单数据,返回对象 或对象数组
2587
- * 需要被读取的数据,需使用 input,包括隐藏域,否则无法被读取
2588
- * 读取时,自动将所有隐藏域的data对象,转换为字符串,方便FormData 提交服务器。
2589
- * @param {*} n 模板名称,不填与容器名称相同,可选参数
2590
- */
2591
- function getForm(n) {
2592
- let R = null;
2593
- try {
2594
- const el = this;
2595
- // 将data存入 value,方便FormData读取
2596
- el.find('input[type=hidden]').forEach(d => {
2597
- if (!$.isEmpty(d.data)) d.value = JSON.stringify(d.data);
2598
- });
2599
-
2600
- if (!n) n = el.attr('name');
2601
-
2602
- // 对象列表表单,需删除模板,避免模板数据干扰数据获取
2603
- const tp = el.name(`${n}-tp`);
2604
- let prev = null;
2605
- let hasTp = tp.length;
2606
- if (hasTp) {
2607
- hasTp = true;
2608
- prev = tp.prev();
2609
- tp.remove();
2610
- }
2611
-
2612
- // 读取整个表单输入数据
2613
- const fd = new FormData(el.dom);
2614
- // 还原模板
2615
- if (hasTp) tp.insertAfter(prev);
2616
-
2617
- const rs = [];
2618
- let last = null;
2619
- let r = {};
2620
- // eslint-disable-next-line no-restricted-syntax
2621
- for (const e of fd.entries()) {
2622
- const k = e[0];
2623
- if (!last) last = k;
2624
- else if (last === k) {
2625
- if (!$.isEmpty(r)) rs.push({...r});
2626
- r = {};
2627
- }
2628
- let v = e[1];
2629
- // 还原对象
2630
- try {
2631
- if (/^\s*[{[]/.test(v)) v = JSON.parse(v);
2632
- } catch (ex) {
2633
- console.error('getForm exp.', {msg: ex.message});
2634
- }
2635
- r[k] = v;
2636
- }
2637
-
2638
- if ($.hasVal(r)) rs.push(r);
2639
- if (rs.length === 1) [R] = rs;
2640
- else if (rs.length > 1) R = rs;
2641
- } catch (ex) {
2642
- console.error('getForm exp.', {msg: ex.message});
2643
- }
2644
-
2645
- return R;
2646
- }
2647
-
2648
- /**
2649
- * 清除表单
2650
- */
2651
- function clearForm() {
2652
- try {
2653
- const el = this;
2654
- // 清除input值
2655
- const es = el.find('input,textarea');
2656
- es.forEach(e => {
2657
- if (e.data) {
2658
- e.data = null;
2659
- delete e.data;
2660
- }
2661
- if (e.type !== 'checkbox') e.value = '';
2662
- });
2663
-
2664
- // 清除 模板数据
2665
- el.find('[name$=-data]').remove();
2666
- el.find('[name$=-empty]').show();
2667
- } catch (e) {
2668
- console.error(`clearForm exp:${e.message}`);
2669
- }
2670
- }
2671
-
2672
- /**
2673
- * 根据页面模板,设置视图域数据
2674
- * 模板为同名节点或tp模板
2675
- * 数据支持两维数组、对象、对象数组等
2676
- * 参数选项:opts: {
2677
- * add:是否新增
2678
- * name:指定视图名称,默认为当前Dom对象
2679
- * idx:数组索引
2680
- * form: 是否为表单,默认 false
2681
- * }
2682
- * 在Form表单中,一般用input来存放字符串值,如使用模板,input type 必须为 hidden
2683
- * 在非Form中,没有input,同名dom,或者名称-tp为插值模板,将对象数据与模板匹配展示数据
2684
- * tb.setView(data); // 数据
2685
- * tb.setView(arr, 0); // 数组,第一列为id
2686
- * tb.setView(arr, 0, 模板名称); // 数组,第一列为id
2687
- * tb.setView(obj, 模板名称); //
2688
- * tb.setView(arr, 0, 模板名称, add); // 第一列为id
2689
- * tb.setView(obj, 模板名称, add); // 对象数据,指定模版名称
2690
- * @param {*} v 数据
2691
- * @param {Number} idx 数组id列序号,可选
2692
- * @param {*} n 视图名称,缺省为dom对象name属性,dom容器如无name,参数n不传则不工作。
2693
- * @param {*} add 重置还是新增,重置会清除数据项,默认为重置
2694
- */
2695
- // function setView(v, idx = -1, n = '', add = false) {
2696
- function setView(v, ...args) {
2697
- let R = false;
2698
- try {
2699
- if (v === undefined || v === null) return false;
2700
-
2701
- const el = this;
2702
- let add = false;
2703
- let idx = -1;
2704
- // 表单视图
2705
- let form = false;
2706
- let name = el.attr('name');
2707
-
2708
- // 复合参数,兼容多参数
2709
- if (args.length) {
2710
- // opts
2711
- if ($.isObject(args[0])) {
2712
- const def = {add, name, idx, form};
2713
- const opt = {...def, ...args[0]};
2714
- ({add, name, idx, form} = opt);
2715
- } else if ($.isArray(v) && $.isNumber(args[0])) {
2716
- // eslint-disable-next-line
2717
- if (args.length >= 1) idx = args[0];
2718
- // eslint-disable-next-line
2719
- if (args.length >= 2 && $.isString(args[1])) name = args[1];
2720
- // eslint-disable-next-line
2721
- if (args.length >= 3 && $.isBool(args[2])) add = args[2];
2722
- } else {
2723
- // if ($.isObject(v) && $.isBool(args[0])) add = args[0];
2724
- // eslint-disable-next-line
2725
- if (args.length >= 1 && $.isString(args[0])) name = args[0];
2726
- else if (args.length >= 1 && $.isBool(args[0])) add = args[0];
2727
- // eslint-disable-next-line
2728
- else if (args.length >= 2 && $.isBool(args[1])) add = args[1];
2729
- }
2730
- }
2731
-
2732
- // 查找是否包含 input
2733
- // if (el.nodeName.toLowerCase() === 'form' || el.find('input,textarea').length) from = true;
2734
-
2735
- // 清除视图数据
2736
- if (!add) {
2737
- if (form) clearForm.bind(el)();
2738
- clearView.bind(el)(name);
2739
- }
2740
-
2741
- // 表单,需将对象拆开,按字段名称逐项赋值
2742
- if (form && $.isObject(v)) {
2743
- Object.keys(v).forEach(k => setData.bind(el)(k, v[k]));
2744
- } else if (name) R = setData.bind(el)(name, v, idx); // 没有指定name的dom,可通过name-tp、name-val等模板赋值
2745
- } catch (ex) {
2746
- console.error('setView exp.', {msg: ex.message});
2747
- }
2748
- return R;
2749
- }
2750
-
2751
- /**
2752
- * 表单赋值
2753
- * @param {*} v
2754
- * @param {*} opts
2755
- */
2756
- function setForm(v, opts) {
2757
- const opt = opts || {};
2758
- opt.form = true;
2759
- setView.bind(this)(v, opt);
2760
- }
2761
-
2762
- /**
2763
- * 向 field 中添加值
2764
- * tb.setView(d);
2765
- * tb.setView(arr, 0); // 第一列为id
2766
- * tb.setView(arr, 0, 模板名称); // 第一列为id
2767
- * tb.setView(obj, 模板名称); // 第一列为id
2768
- * tb.setView(arr, 0, 模板名称); // 第一列为id
2769
- * tb.setView(obj, 模板名称); // 第一列为id
2770
- * @param {*} v 数据
2771
- * @param {*} n 视图名称,缺省为调用者name
2772
- */
2773
- function addView(v, ...args) {
2774
- const el = this;
2775
- setView.bind(el)(v, ...args, true);
2776
- }
2777
-
2778
- /**
2779
- * 清除视图
2780
- * @param {*} k 视图名称
2781
- */
2782
- function clearView(n) {
2783
- try {
2784
- const el = this;
2785
- if (!n) n = el.attr('name');
2786
-
2787
- // 清除input值
2788
- const es = el.names(n);
2789
- es.forEach(e => {
2790
- if (e.tagName.toLowerCase() === 'input' || e.tagName.toLowerCase() === 'textarea') {
2791
- if (e.data) {
2792
- e.data = null;
2793
- delete e.data;
2794
- }
2795
- if (e.type !== 'checkbox') e.value = '';
2796
- }
2797
- });
2798
-
2799
- // 清除 模板数据
2800
- el.names(`${n}-data`).remove();
2801
- el.name(`${n}-empty`).show();
2802
- } catch (e) {
2803
- console.error(`clearView exp:${e.message}`);
2804
- }
2805
- }
2806
-
2807
- /**
2808
- * 读取指定视图数据,返回 仅仅包含 指定视图的值,如果有data,则返回 对象
2809
- * 读取时,自动将隐藏域的data对象,转换为字符串,方便FormData 提交服务器。
2810
- * @param {*} n 视图名称
2811
- */
2812
- function getView(n) {
2813
- let R = null;
2814
- try {
2815
- const el = this;
2816
- if (!n) n = el.attr('name');
2817
- const d = el.name(n);
2818
- if (d.length) {
2819
- if ($.hasVal(d.data)) R = d.data;
2820
- else R = d.val();
2821
- }
2822
- } catch (ex) {
2823
- console.error('getView exp.', {msg: ex.message});
2824
- }
2825
-
2826
- return R;
2827
- }
2828
-
2829
- /**
2830
- *
2831
- * @param {*} e
2832
- */
2833
- function removeChip(e) {
2834
- console.log('removeChip', {e});
2835
-
2836
- const el = $(e.target).closest('.chip');
2837
- if (el && el.length > 0) {
2838
- let id = el.data('id');
2839
- const n = el.prevNode('input[type=hidden]');
2840
- el.remove();
2841
- if (n && n.length > 0) {
2842
- id = n
2843
- .val()
2844
- .replace(new RegExp(`${id}\\s*,?\\s*`), '')
2845
- .replace(/\s*,\s*$/, '');
2846
- n.val(id);
2847
- }
2848
- }
2849
- }
2850
-
2851
- /**
2852
- * 根据模板添加 form 数据集
2853
- * 内部函数,被setViews调用
2854
- * @param {*} n 模板名称
2855
- * @param {*} v 数据对象
2856
- */
2857
- function setTpForm(n, v, add = false) {
2858
- try {
2859
- const el = this;
2860
- const tp = el.name(`${n}-tp`);
2861
- if (tp.length) {
2862
- tp.hide();
2863
- const p = tp.clone();
2864
- p.insertBefore(tp);
2865
- setView.bind(p)(v, {form: true, add});
2866
- p.attr('name', tp.attr('name').replace('-tp', '-data')).show();
2867
- }
2868
- } catch (ex) {
2869
- console.error('setForm exp.', {msg: ex.message});
2870
- }
2871
- }
2872
-
2873
- /**
2874
- * 渲染模板字符串,使用 r 参数,替换模板代参,生成展示html视图
2875
- * 替代 eval,减少安全漏洞,eval 会带入了所有内存上下文变量,导致数据泄露!
2876
- * @param {*} tp 模板
2877
- * @param {*} r 数据
2878
- * @returns 返回html
2879
- */
2880
- function render(tp, r) {
2881
- const code = `function(r){return \`${tp}\`}`;
2882
- // eslint-disable-next-line no-new-func
2883
- return Function(`"use strict";return (${code})`)()(r);
2884
- }
2885
-
2886
- /**
2887
- * 根据模板,添加数据节点
2888
- * 添加前,根据id 或 _id,删除相同已加载数据节点,避免重复添加
2889
- * 内部函数,被 setData 调用
2890
- * @param {*} tp 模板
2891
- * @param {*} n 字段名称
2892
- * @param {*} r 数据,对象 或 值
2893
- * @param {*} ns 已经存在的数据节点,避免重复添加
2894
- * @param {Number} idx 数组中作为id的序号,从0开始,-1表示没有
2895
- */
2896
- function addData(tp, n, r, ns, idx = -1) {
2897
- try {
2898
- if (!tp) return;
2899
-
2900
- // 对象、数组可能存在id、_id
2901
- const isObj = $.isObject(r);
2902
- const isArr = $.isArray(r);
2903
-
2904
- let id;
2905
- let _id;
2906
- if (isObj) {
2907
- id = r.id;
2908
- _id = r._id;
2909
- } else if (isArr) {
2910
- if (idx > -1) id = r[idx];
2911
- } // 普通值直接作为_id
2912
- else _id = r;
2913
-
2914
- // 通过id、_id删除重复节点
2915
- if ((id !== undefined || _id !== undefined) && ns?.length) {
2916
- const ds = ns.filter((i, n) => {
2917
- const $n = $(n);
2918
- return (id && $n.data('id') == id) || (_id && $n.data('_id') == _id);
2919
- });
2920
-
2921
- if (ds.length) ds.remove();
2922
- }
2923
-
2924
- // 通过模板与r结合,生成页面html
2925
- const $n = $(
2926
- render(tp.dom.outerHTML, r)
2927
- .replaceAll('undefined:', '')
2928
- .replaceAll('undefined:', '')
2929
- .replaceAll('undefined', '')
2930
- );
2931
- if (id !== undefined) $n.data('id', id);
2932
- else if (_id !== undefined) $n.data('_id', _id);
2933
- $n.attr('name', `${n}-data`).insertBefore(tp).show();
2934
- } catch (ex) {
2935
- console.error('addData exp.', {msg: ex.message});
2936
- }
2937
- }
2938
-
2939
- /**
2940
- * 视图赋值
2941
- * 优先节点名称表单value赋值:input、hidden、select、checkbox、radio、textarea
2942
- * 然后继续对模板继续赋值:-tp、-val 和内部包含 ${ 模板特殊字符串的视图赋值!
2943
- * 使用-tp模板或name的html作为模版,xxx-val 不判断 ${直接覆盖,
2944
- * xxx 判断内部是否有 ${,如果有,则视为模板,进行模板替换。
2945
- * 加载数据到页面,模板请使用 ${r} 或 ${r.xx}
2946
- * img 的 $src 改为 src
2947
- * 内部函数,被 setField 调用,只管模板,不管input 和 form
2948
- * 在非 form 和 input环境可用
2949
- * @param {*} n 模板名称,组件name="n-tp",n为模板名称
2950
- * @param {*} v 数据,对象或者对象数组
2951
- * @param {Numver} idx 指定数组id列序号,v 为数组时有效
2952
- */
2953
- function setData(n, v, idx = -1) {
2954
- try {
2955
- if (!n) return false;
2956
-
2957
- const el = this; // 容器
2958
-
2959
- // 查找名称节点
2960
- const $d = el.name(n); // 包含容器自身
2961
-
2962
- // 名称节点赋值优先!
2963
- // 容器内查找字段名称对应组件进行赋值,支持select、radio、checkbox,Dom的val已经支持,这里可直接调用val即可!
2964
- if ($d.length > 0) {
2965
- const d = $d.dom;
2966
- // console.log('setView', {type: d.type});
2967
- // null undfined 转换为空
2968
- v = v ?? '';
2969
- if (v === 'null' || v === 'undefined') v = '';
2970
-
2971
- if (d.tagName.toLowerCase() === 'textarea') $d.val(v);
2972
- // input 赋值
2973
- else if (d.tagName.toLowerCase() === 'input') {
2974
- if (d.type === 'text') setInput.bind(el)(n, v);
2975
- else if (
2976
- [
2977
- 'date',
2978
- 'time',
2979
- 'month',
2980
- 'week',
2981
- 'datetime',
2982
- 'datetime-local',
2983
- 'email',
2984
- 'number',
2985
- 'search',
2986
- 'url',
2987
- ].includes(d.type)
2988
- )
2989
- $d.val(v);
2990
- // 隐藏域,一般带同名模板,数据为数组或对象,不使用隐藏域也可以展示对象数据,使用隐藏域便于收集数据提交
2991
- else if (d.type === 'hidden') {
2992
- setInput.bind(el)(n, v);
2993
- // setData.bind(el)(n, v); // 后续继续执行模板部分!
2994
- // 触发 input的 onchange 事件,hidden 组件数据变化,不会触发onchange
2995
- // 这里发起change事件,方便其他组件接收事件后,实现UI等处理
2996
- // 其他接受change事件的组件,不能再次触发change,否则导致死循环
2997
- $d.change();
2998
- } else if (
2999
- d.type === 'select-one' ||
3000
- d.type === 'select-multiple' ||
3001
- d.type === 'checkbox' ||
3002
- d.type === 'radio'
3003
- ) {
3004
- $d.val(v, el);
3005
- }
3006
- }
3007
- }
3008
-
3009
- // 继续${} 模板字符串替换赋值:-tp、-val、和内部包含${特征字符串的内容赋值
3010
- if ($.isEmpty(v)) return false;
3011
-
3012
- // 查找数据模板,按模板增加数据,模板优先 name
3013
- const tp = el.name(`${n}-tp`);
3014
- // 有模板,使用模板添加数据,通过id或_id避免重复添加
3015
- if (tp.length) {
3016
- tp.hide();
3017
- let kv = false; // key value
3018
- const tpa = tp.attr('tp');
3019
- if (tpa === 'kv' || /kv-\d+/.test(tpa)) kv = true;
3020
- let empty = el.names(`${n}-data`).length === 0;
3021
- // chip
3022
- const d = el.name(n).dom;
3023
- // 如果 input存在,优先获取 input 中的 data
3024
- if (d && d.type === 'hidden') {
3025
- const val = d.value;
3026
- if (!$.isEmpty(d.data)) v = d.data;
3027
- else if (val) {
3028
- v = val;
3029
- if (val.indexOf(',') > -1) v = val.split(',');
3030
- }
3031
- }
3032
-
3033
- // 已经存在的数据视图,新增时,需删除后新增,避免重复
3034
- const ns = el.names(`${n}-data`);
3035
-
3036
- // 数组,两维数组,对象数组
3037
- if ($.isArray(v))
3038
- v.forEach((r, x) => {
3039
- if (r) {
3040
- empty = false;
3041
- addData.bind(el)(tp, n, r, ns, idx); // 二维数组,模板中通过 r[0] r[1] 引用数据
3042
- }
3043
- });
3044
- else if ($.isObject(v) && kv) {
3045
- const ks = Object.keys(v);
3046
- if (ks.length) {
3047
- empty = false;
3048
- const ms = /kv-(\d+)/.exec(tpa);
3049
- if (!ms) {
3050
- ks.forEach(vk => {
3051
- if (v[vk]) {
3052
- addData.bind(el)(tp, n, {k: vk, v: v[vk]}, ns, idx);
3053
- }
3054
- });
3055
- } else {
3056
- const kn = ms[1];
3057
- let ik = 0;
3058
- // 取模存值
3059
- const mks = [];
3060
- const mvs = [];
3061
- let m = 0;
3062
- ks.forEach(vk => {
3063
- ik++;
3064
- mks.push(vk);
3065
- mvs.push(v[vk] ?? '');
3066
-
3067
- // 取模
3068
- m = ik % kn;
3069
- // id >= kn
3070
- if (m === 0) {
3071
- const md = {};
3072
- mks.forEach((mk, mi) => {
3073
- md[`k${mi + 1}`] = mks[mi];
3074
- md[`v${mi + 1}`] = mvs[mi];
3075
- });
3076
- console.log('setData', {md});
3077
- addData.bind(el)(tp, n, md, ns, idx);
3078
- mks.length = 0;
3079
- mvs.length = 0;
3080
- }
3081
- });
3082
-
3083
- if (m > 0) {
3084
- const md = {};
3085
- mks.forEach((mk, mi) => {
3086
- md[`k${mi + 1}`] = mks[mi];
3087
- md[`v${mi + 1}`] = mvs[mi];
3088
- });
3089
- console.log('setData', {md});
3090
- addData.bind(el)(tp, n, md, ns, idx);
3091
- mks.length = 0;
3092
- mvs.length = 0;
3093
- }
3094
- }
3095
- }
3096
- } else if (v) {
3097
- empty = false;
3098
- addData.bind(el)(tp, n, v, ns, idx);
3099
- }
3100
-
3101
- // 支持点击删除
3102
- if (tp.hasClass('chip')) tp.parentNode().click(removeChip);
3103
-
3104
- // img src-tp replace src
3105
- const imgs = tp.find('img[src-tp]');
3106
- el.find('img[src-tp]').forEach(img => {
3107
- if (imgs.length === 0 || imgs.indexOf(img) === -1) {
3108
- const $img = $(img);
3109
- $img.attr('src', $img.attr('src-tp'));
3110
- $img.removeAttr('src-tp');
3111
- }
3112
- });
3113
-
3114
- // 如果数据节点为空,则显示空节点(存在则显示)
3115
- if (empty) el.name(`${n}-empty`).show();
3116
- else el.name(`${n}-empty`).hide();
3117
- } else {
3118
- // 没有-tp模板,查找-val,直接覆盖
3119
- const r = v;
3120
- const vp = el.name(`${n}-val`);
3121
- if (vp.length) {
3122
- const tx = vp.html();
3123
- if (r && tx.indexOf('${') > -1) {
3124
- vp.html(
3125
- render(tx, r)
3126
- .replaceAll('undefined:', '')
3127
- .replaceAll('undefined:', '')
3128
- .replaceAll('undefined', '')
3129
- );
3130
- // img $src replace src
3131
- vp.find('img[src-tp]').forEach(n => {
3132
- const $n = $(n);
3133
- $n.attr('src', $n.attr('src-tp'));
3134
- });
3135
- } else if (r) vp.html(r);
3136
- } else {
3137
- // 没有-tp和-val,获取name为k的视图,如果内部有${,按模板覆盖内容
3138
- // const $d = el.name(`${n}`);
3139
- if ($d.length && $d.dom.type !== 'text') {
3140
- const tx = $d.html();
3141
- if (r && tx && tx.indexOf('${') > -1) {
3142
- $d.html(
3143
- render(tx, r)
3144
- .replaceAll('undefined:', '')
3145
- .replaceAll('undefined:', '')
3146
- .replaceAll('undefined', '')
3147
- );
3148
- // img $src replace src
3149
- $d.find('img[src-tp]').forEach(img => {
3150
- const $img = $(img);
3151
- $img.attr('src', $img.attr('src-tp'));
3152
- });
3153
- }
3154
- }
3155
- }
3156
- }
3157
- } catch (ex) {
3158
- console.error('setData exp.', {msg: ex.message});
3159
- }
3160
- }
3161
-
3162
- /**
3163
- * input 赋值时设置数据,自动去重
3164
- * 内部函数,被 setInput调用
3165
- * @param {*} n input Dom 实例
3166
- * @param {*} v 值
3167
- * @param {*} org 原来的值
3168
- */
3169
- function getValue(n, v, org) {
3170
- let R = v;
3171
-
3172
- try {
3173
- // 对象需判断是否重复
3174
- if ($.isObject(v)) {
3175
- if ($.isObject(org)) {
3176
- if ((org.id && org.id == v.id) || (org._id && org._id == v._id)) R = v;
3177
- else R = [org, v];
3178
- } else if ($.isArray(org)) {
3179
- const rs = org.filter(
3180
- o => (!o.id && !o._id) || (o.id && o.id != v.id) || (o._id && o._id != v._id)
3181
- );
3182
- if (rs.length) {
3183
- rs.push(v);
3184
- R = rs;
3185
- }
3186
- }
3187
- } else {
3188
- // 值变量,直接使用 value 字符串方式存储
3189
- let val = `${org},${v}`;
3190
- // 去重
3191
- if (val.indexOf(',') > -1) val = Array.from(new Set(val.split(','))).join(',');
3192
- R = val;
3193
- }
3194
- } catch (e) {
3195
- console.error('getValue exp.', {msg: e.message});
3196
- }
3197
- return R;
3198
- }
3199
-
3200
- /**
3201
- * 设置 input 的值
3202
- * 如果带id,则检查是否已存在,避免重复添加
3203
- * @param {*} n 字段名称
3204
- * @param {*} v 值,接受字符串、对象 和 对象数组
3205
- * 对象、对象数组 赋值到 data,值,值数组,赋值到 value
3206
- */
3207
- function setInput(n, v) {
3208
- try {
3209
- const el = this;
3210
- const d = el.name(n);
3211
- if (!d.length) return;
3212
-
3213
- if ($.isEmpty(v)) return;
3214
-
3215
- // 没有id 和 _id,自动添加 _id,避免重复添加
3216
- if ($.isObject(v) && v.id === undefined && v._id === undefined) v._id = $.num();
3217
- else if ($.isArray(v)) {
3218
- v.forEach(r => {
3219
- if ($.isObject(r) && r.id === undefined && r._id === undefined) r._id = $.num();
3220
- });
3221
- }
3222
-
3223
- let org = d.dom.data;
3224
- if (!org) {
3225
- org = d.val();
3226
- // 隐藏域,从字符串还原对象,保存到 dom.data
3227
- if (d.dom.type === 'hidden' && /\s*[{[]/g.test(org)) {
3228
- try {
3229
- org = JSON.parse(org);
3230
- d.dom.data = org;
3231
- d.val('');
3232
- } catch (e) {
3233
- console.error('setInput exp.', {msg: e.message});
3234
- }
3235
- }
3236
- }
3237
-
3238
- if ($.isEmpty(org)) {
3239
- if ($.isVal(v)) d.val(v);
3240
- else if ($.isArray(v) && $.isVal(v[0])) d.val(v.join(','));
3241
- else d.dom.data = v;
3242
- } else {
3243
- if ($.isArray(v)) {
3244
- v = v.reduce((pre, cur) => getValue(d, cur, pre), org);
3245
- if ($.hasVal(v) && $.isArray(v)) {
3246
- v = Array.from(new Set(v));
3247
- }
3248
- } else v = getValue(d, v, org);
3249
-
3250
- if ($.hasVal(v)) {
3251
- if ($.isVal(v)) d.val(v);
3252
- // 值 数组
3253
- else if ($.isArray(v) && $.isVal(v[0])) d.val(v.join(','));
3254
- else d.dom.data = v;
3255
- }
3256
- }
3257
- } catch (ex) {
3258
- console.error('setInput exp.', {msg: ex.message});
3259
- }
3260
- }
3261
-
3262
- // test
3263
- // Object.keys(fn).forEach(k => ($.fn[k] = fn[k]));
3264
-
3265
- const View = /*#__PURE__*/Object.freeze({
3266
- __proto__: null,
3267
- addForms: addForms,
3268
- addView: addView,
3269
- clearForm: clearForm,
3270
- clearView: clearView,
3271
- getForm: getForm,
3272
- getView: getView,
3273
- setForm: setForm,
3274
- setForms: setForms,
3275
- setView: setView
3276
- });
3277
-
3278
- /**
3279
- * 输出方法到 $.fn,用户对 $(dom) 对象操作
3280
- * 相关方法与用法与 zepto、jQuery兼容。
3281
- * 替代zepto、jQuery,不可同时使用zepto、jQuery
3282
- */
3283
-
3284
-
3285
- // 获取当前全局$变量,$.fn 上增加操作函数!
3286
- const $$1 = window.$ ?? {};
3287
- [Methods, Scroll, Animate, View].forEach(group => {
3288
- // , eventShortcuts
3289
- Object.keys(group).forEach(methodName => {
3290
- $$1.fn[methodName] = group[methodName];
3291
- });
3292
- });
3293
-
3294
- // shortcut methods for `.on(event, fn)` for each event type
3295
- const noTrigger = 'resize scroll'.split(' ');
3296
- (
3297
- 'load,unload,dblclick,select,error,click,blur,focus,focusin,' +
3298
- 'focusout,keyup,keydown,keypress,submit,change,mousedown,mousemove,mouseup,' +
3299
- 'mouseenter,mouseleave,mouseout,mouseover,touchstart,touchend,touchmove,resize,' +
3300
- 'scroll,swipe,press'
3301
- )
3302
- .split(',')
3303
- .forEach(function (event) {
3304
- $$1.fn[event] = function (...args) {
3305
- if (typeof args[0] === 'undefined') {
3306
- for (let i = 0; i < this.length; i += 1) {
3307
- try {
3308
- if (noTrigger.indexOf(event) < 0) {
3309
- if (event in this[i]) this[i][event]();
3310
- else {
3311
- $$1(this[i]).trigger(event);
3312
- }
3313
- }
3314
- } catch (ex) {}
3315
- }
3316
- return this;
3317
- }
3318
- return this.on(event, ...args);
3319
- };
3320
- });
3321
-
3322
- function traverseNode(node, fun) {
3323
- fun(node);
3324
- for (var i = 0, len = node.childNodes.length; i < len; i++) traverseNode(node.childNodes[i], fun);
3325
- }
3326
-
3327
- // Generate the `after`, `prepend`, `before`, `append`,
3328
- // `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.
3329
- const operators = ['after', 'prepend', 'before', 'append'];
3330
- operators.forEach(function (op, idx) {
3331
- var inside = idx % 2; //=> prepend, append
3332
- $$1.fn[op] = function () {
3333
- // arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
3334
- let argType;
3335
- // map 每个参数,支持添加多个节点
3336
- const nodes = $$1.map(arguments, function (arg) {
3337
- var arr = [];
3338
- argType = $$1.type(arg);
3339
- if (argType == 'array') {
3340
- arg.forEach(function (el) {
3341
- if (el.nodeType !== undefined) return arr.push(el);
3342
- else if ($$1.isDom(el)) return (arr = arr.concat(el.get()));
3343
- arr = arr.concat($$1.fragment(el));
3344
- });
3345
- return arr;
3346
- }
3347
- return argType == 'object' || arg == null ? arg : $$1.fragment(arg);
3348
- });
3349
-
3350
- if (nodes.length < 1) return this;
3351
-
3352
- let parent;
3353
- // 多目标节点增加新节点时,需克隆,否则只有最后一个目标节点增加了新节点
3354
- let copyByClone = this.length > 1;
3355
-
3356
- // 针对每个节点进行节点添加操作
3357
- return this.each(function (_, target) {
3358
- parent = inside ? target : target.parentNode;
3359
-
3360
- // convert all methods to a "before" operation
3361
- target =
3362
- idx == 0
3363
- ? target.nextSibling // after
3364
- : idx == 1
3365
- ? target.firstChild // prepend
3366
- : idx == 2
3367
- ? target // before
3368
- : null; // append
3369
-
3370
- var parentInDoc = $$1.contains(document.documentElement, parent);
3371
-
3372
- nodes.forEach(function (node) {
3373
- if (copyByClone) node = node.cloneNode(true);
3374
- else if (!parent) return $$1(node).remove();
3375
-
3376
- parent.insertBefore(node, target);
3377
-
3378
- // 防止空链接,刷新页面
3379
- const ns = $$1.qus('a[href=""]', parent);
3380
- if (ns && ns.length > 0) ns.forEach(n => n.setAttribute('href', 'javascript:;'));
3381
-
3382
- if (parentInDoc)
3383
- // 执行 节点中包含的脚本代码
3384
- traverseNode(node, function (el) {
3385
- if (
3386
- el.nodeName != null &&
3387
- el.nodeName.toUpperCase() === 'SCRIPT' &&
3388
- (!el.type || el.type === 'text/javascript') &&
3389
- !el.src
3390
- ) {
3391
- var target = el.ownerDocument ? el.ownerDocument.defaultView : window;
3392
- target['eval'].call(target, el.innerHTML);
3393
- }
3394
- });
3395
- });
3396
- });
3397
- };
3398
-
3399
- // 参数调换,参数作为目标节点,this作为新增节点
3400
- // after => insertAfter
3401
- // prepend => prependTo
3402
- // before => insertBefore
3403
- // append => appendTo
3404
- const op2 = inside ? op + 'To' : 'insert' + (idx ? 'Before' : 'After');
3405
- $$1.fn[op2] = function (html) {
3406
- $$1(html)[op](this);
3407
- return this;
3408
- };
3409
- });
3410
-
3411
- $$1.default = $$1;
3412
- // export {$};
3413
-
3414
- dom_cmn = $$1;
3415
- return dom_cmn;
3416
- }
3417
-
3418
- {
3419
- dom.exports = requireDom_cmn();
3420
- }
3421
-
3422
- var domExports = dom.exports;
3423
- var $$1 = /*@__PURE__*/getDefaultExportFromCjs(domExports);
3424
-
3425
126
  function _extends() {
3426
127
  _extends = Object.assign ? Object.assign.bind() : function (target) {
3427
128
  for (var i = 1; i < arguments.length; i++) {
@@ -5591,8 +2292,9 @@
5591
2292
  var extend = Utils.extend,
5592
2293
  nextFrame = Utils.nextFrame,
5593
2294
  colorThemeCSSStyles = Utils.colorThemeCSSStyles;
5594
- var support = $$1.support,
5595
- device = $$1.device;
2295
+ var _$ = $,
2296
+ support = _$.support,
2297
+ device = _$.device;
5596
2298
  var def = {
5597
2299
  version: '1.0.1',
5598
2300
  el: 'body',
@@ -5641,7 +2343,7 @@
5641
2343
  }
5642
2344
  var passedParams = extend({}, opts);
5643
2345
  var app = _assertThisInitialized(_this);
5644
- $$1.App = App;
2346
+ $.App = App;
5645
2347
  App.instance = app;
5646
2348
  app.device = device;
5647
2349
  app.support = support;
@@ -5654,10 +2356,10 @@
5654
2356
  if (opts.root && !opts.el) {
5655
2357
  app.params.el = opts.root;
5656
2358
  }
5657
- $$1.isPage = function (p) {
2359
+ $.isPage = function (p) {
5658
2360
  return p instanceof Page;
5659
2361
  };
5660
- $$1.isApp = function (p) {
2362
+ $.isApp = function (p) {
5661
2363
  return p instanceof App;
5662
2364
  };
5663
2365
  extend(app, {
@@ -5692,7 +2394,7 @@
5692
2394
  app.initData();
5693
2395
  if (app.params.init) {
5694
2396
  if (device.cordova && app.params.initOnDeviceReady) {
5695
- $$1(document).on('deviceready', function () {
2397
+ $(document).on('deviceready', function () {
5696
2398
  app.init();
5697
2399
  });
5698
2400
  } else {
@@ -5730,7 +2432,7 @@
5730
2432
  };
5731
2433
  _proto.mount = function mount(rootEl) {
5732
2434
  var app = this;
5733
- var $rootEl = $$1(rootEl || app.params.el).eq(0);
2435
+ var $rootEl = $(rootEl || app.params.el).eq(0);
5734
2436
  extend(app, {
5735
2437
  root: $rootEl,
5736
2438
  $el: $rootEl,
@@ -5774,9 +2476,9 @@
5774
2476
  var app = this;
5775
2477
  app.data = {};
5776
2478
  if (app.params.data && typeof app.params.data === 'function') {
5777
- $$1.extend(app.data, app.params.data.bind(app)());
2479
+ $.extend(app.data, app.params.data.bind(app)());
5778
2480
  } else if (app.params.data) {
5779
- $$1.extend(app.data, app.params.data);
2481
+ $.extend(app.data, app.params.data);
5780
2482
  }
5781
2483
  app.methods = {};
5782
2484
  if (app.params.methods) {
@@ -5819,7 +2521,7 @@
5819
2521
  app.enableAutoDarkMode();
5820
2522
  } else {
5821
2523
  app.disableAutoDarkMode();
5822
- $$1('html')[mode ? 'addClass' : 'removeClass']('dark');
2524
+ $('html')[mode ? 'addClass' : 'removeClass']('dark');
5823
2525
  app.darkMode = mode;
5824
2526
  }
5825
2527
  };
@@ -5830,7 +2532,7 @@
5830
2532
  el: app.$el[0]
5831
2533
  }
5832
2534
  }, function (el) {
5833
- app.$el = $$1(el);
2535
+ app.$el = $(el);
5834
2536
  app.$el[0].wia = app;
5835
2537
  app.$elComponent = el.f7Component;
5836
2538
  app.el = app.$el[0];
@@ -5845,10 +2547,10 @@
5845
2547
  if (app.initialized) return app;
5846
2548
  app.$el.addClass('framework7-initializing');
5847
2549
  if (app.rtl) {
5848
- $$1('html').attr('dir', 'rtl');
2550
+ $('html').attr('dir', 'rtl');
5849
2551
  }
5850
2552
  if (typeof app.params.darkMode === 'undefined') {
5851
- app.darkMode = $$1('html').hasClass('dark');
2553
+ app.darkMode = $('html').hasClass('dark');
5852
2554
  } else {
5853
2555
  app.setDarkMode(app.params.darkMode);
5854
2556
  }
@@ -5863,12 +2565,12 @@
5863
2565
  app.emit('connection', true);
5864
2566
  });
5865
2567
  app.$el.addClass('framework7-root');
5866
- $$1('html').removeClass('ios md pc').addClass(app.theme);
2568
+ $('html').removeClass('ios md pc').addClass(app.theme);
5867
2569
  if (app.params.iosTranslucentBars && app.theme === 'ios') {
5868
- $$1('html').addClass('ios-translucent-bars');
2570
+ $('html').addClass('ios-translucent-bars');
5869
2571
  }
5870
2572
  if (app.params.iosTranslucentModals && app.theme === 'ios') {
5871
- $$1('html').addClass('ios-translucent-modals');
2573
+ $('html').addClass('ios-translucent-modals');
5872
2574
  }
5873
2575
  nextFrame(function () {
5874
2576
  app.$el.removeClass('framework7-initializing');
@@ -5901,17 +2603,17 @@
5901
2603
  _createClass(App, [{
5902
2604
  key: "$",
5903
2605
  get: function get() {
5904
- return $$1;
2606
+ return $;
5905
2607
  }
5906
2608
  }], [{
5907
2609
  key: "Dom",
5908
2610
  get: function get() {
5909
- return $$1;
2611
+ return $;
5910
2612
  }
5911
2613
  }, {
5912
2614
  key: "$",
5913
2615
  get: function get() {
5914
- return $$1;
2616
+ return $;
5915
2617
  }
5916
2618
  }, {
5917
2619
  key: "Module",