@joyzl/eno 1.0.1 → 1.0.2
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/index.js +37 -67
- package/package.json +1 -1
- package/publish.cmd +0 -1
package/index.js
CHANGED
@@ -13,7 +13,6 @@ export default {
|
|
13
13
|
|
14
14
|
show,
|
15
15
|
hide,
|
16
|
-
stack,
|
17
16
|
toggle,
|
18
17
|
|
19
18
|
gets,
|
@@ -21,10 +20,6 @@ export default {
|
|
21
20
|
entity,
|
22
21
|
action,
|
23
22
|
element,
|
24
|
-
|
25
|
-
date,
|
26
|
-
time,
|
27
|
-
datetime
|
28
23
|
}
|
29
24
|
|
30
25
|
/**
|
@@ -46,6 +41,7 @@ function show(element) {
|
|
46
41
|
}
|
47
42
|
}
|
48
43
|
}
|
44
|
+
|
49
45
|
/**
|
50
46
|
* 隐藏单个/多个元素
|
51
47
|
* @param {Element} element
|
@@ -65,36 +61,37 @@ function hide(element) {
|
|
65
61
|
}
|
66
62
|
}
|
67
63
|
}
|
64
|
+
|
68
65
|
/**
|
69
|
-
*
|
70
|
-
*
|
71
|
-
* @param {
|
66
|
+
* 切换指定元素显示,其余元素隐藏;
|
67
|
+
* 如果指定样式类名,则当前原始添加样式类,其余元素移除样式类
|
68
|
+
* @param {Element} parent 父级
|
69
|
+
* @param {Element} element 当前元素
|
72
70
|
* @param {String} className 类名称
|
73
71
|
*/
|
74
72
|
function toggle(parent, element, className) {
|
73
|
+
if (parent && parent.trim) {
|
74
|
+
parent = select(parent);
|
75
|
+
}
|
76
|
+
if (element && element.trim) {
|
77
|
+
element = select(parent, element);
|
78
|
+
|
79
|
+
if (element.parentElement != parent) {
|
80
|
+
parent.appendChild(element);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
75
84
|
if (arguments.length == 1) {
|
76
85
|
// toggle(element);
|
77
|
-
|
78
|
-
|
79
|
-
element = select(element);
|
80
|
-
}
|
81
|
-
if (element.hidden) {
|
82
|
-
element.hidden = false;
|
86
|
+
if (parent.hidden) {
|
87
|
+
parent.hidden = false;
|
83
88
|
} else {
|
84
|
-
|
89
|
+
parent.hidden = true;
|
85
90
|
}
|
86
91
|
} else
|
87
92
|
if (arguments.length == 2) {
|
88
93
|
// toggle(parent,element);
|
89
|
-
|
90
|
-
parent = select(parent);
|
91
|
-
}
|
92
|
-
if (element.trim) {
|
93
|
-
element = select(element);
|
94
|
-
}
|
95
|
-
if (element.parentElement != parent) {
|
96
|
-
parent.appendChild(element);
|
97
|
-
}
|
94
|
+
// display:flex 导致 hidden 属性失效而不会隐藏
|
98
95
|
for (let i = 0; i < parent.children.length; i++) {
|
99
96
|
if (element == parent.children[i]) {
|
100
97
|
parent.children[i].hidden = false;
|
@@ -105,17 +102,16 @@ function toggle(parent, element, className) {
|
|
105
102
|
} else
|
106
103
|
if (arguments.length == 3) {
|
107
104
|
// toggle(parent,element,className);
|
108
|
-
|
105
|
+
for (let i = 0; i < parent.children.length; i++) {
|
106
|
+
parent.children[i].hidden = false;
|
107
|
+
parent.children[i].classList.remove(className);
|
108
|
+
if (element == parent.children[i]) {
|
109
|
+
parent.children[i].classList.add(className);
|
110
|
+
}
|
111
|
+
}
|
109
112
|
}
|
110
113
|
}
|
111
114
|
|
112
|
-
function stack(parent, element, className) {
|
113
|
-
// 单选 增加class/移除其它
|
114
|
-
// 多选 增加class
|
115
|
-
// 增加 class
|
116
|
-
// 移除 class
|
117
|
-
}
|
118
|
-
|
119
115
|
/**
|
120
116
|
* 在指定元素内/整个文档查找标签
|
121
117
|
* @param {Element} element 元素内
|
@@ -411,6 +407,7 @@ function gets(element, converter = defaultConverter) {
|
|
411
407
|
}
|
412
408
|
}
|
413
409
|
}
|
410
|
+
|
414
411
|
/**
|
415
412
|
* 从指定JSON设置元素值,以name属性作为标识
|
416
413
|
* @param {Element} element 元素
|
@@ -572,6 +569,7 @@ function sets(element, parameter, converter = defaultConverter) {
|
|
572
569
|
}
|
573
570
|
}
|
574
571
|
}
|
572
|
+
|
575
573
|
/**
|
576
574
|
* 获取元素值
|
577
575
|
* <input name="AAA" value="123"/>
|
@@ -601,6 +599,7 @@ function get(element, parameter, converter) {
|
|
601
599
|
}
|
602
600
|
}
|
603
601
|
}
|
602
|
+
|
604
603
|
/**
|
605
604
|
* 设置元素值
|
606
605
|
* <input name="AAA" value="123"/>
|
@@ -630,6 +629,7 @@ function set(element, parameter, converter) {
|
|
630
629
|
}
|
631
630
|
}
|
632
631
|
}
|
632
|
+
|
633
633
|
/**
|
634
634
|
* 根据名称获取对象值
|
635
635
|
* @param {Object} o 对象
|
@@ -657,6 +657,7 @@ function vale(o, name) {
|
|
657
657
|
}
|
658
658
|
return o;
|
659
659
|
}
|
660
|
+
|
660
661
|
/**
|
661
662
|
* 根据名称设置对象值
|
662
663
|
* @param {Object} o
|
@@ -678,6 +679,7 @@ function valu(o, name, value) {
|
|
678
679
|
o[name[i]] = value;
|
679
680
|
return o;
|
680
681
|
}
|
682
|
+
|
681
683
|
/**
|
682
684
|
* 转换为字符串值
|
683
685
|
* @param {Object} o
|
@@ -692,6 +694,7 @@ function text(o) {
|
|
692
694
|
}
|
693
695
|
return "";
|
694
696
|
}
|
697
|
+
|
695
698
|
/**
|
696
699
|
* 根据事件或元素获取由sets关联的实体对象
|
697
700
|
*/
|
@@ -722,6 +725,7 @@ function entity(e, selector) {
|
|
722
725
|
}
|
723
726
|
return null;
|
724
727
|
}
|
728
|
+
|
725
729
|
/**
|
726
730
|
* 根据事件或元素获取属性指定的动作
|
727
731
|
* @param {Event} e
|
@@ -744,6 +748,7 @@ function action(e, a) {
|
|
744
748
|
}
|
745
749
|
return false;
|
746
750
|
}
|
751
|
+
|
747
752
|
/**
|
748
753
|
* 根据事件获取绑定实体的元素
|
749
754
|
* @param {Event} e
|
@@ -764,39 +769,4 @@ function element(e) {
|
|
764
769
|
}
|
765
770
|
}
|
766
771
|
return null;
|
767
|
-
}
|
768
|
-
|
769
|
-
/**
|
770
|
-
* 2024-6-24
|
771
|
-
*/
|
772
|
-
function date() {
|
773
|
-
const now = new Date();
|
774
|
-
const year = now.getFullYear();
|
775
|
-
const month = (now.getMonth() + 1 /*月份从0开始,需要加1*/ ).toString().padStart(2, '0');
|
776
|
-
const day = (now.getDate()).toString().padStart(2, '0');
|
777
|
-
return `${year}-${month}-${day}`;
|
778
|
-
}
|
779
|
-
|
780
|
-
/**
|
781
|
-
* 10:28:12
|
782
|
-
*/
|
783
|
-
function time() {
|
784
|
-
const now = new Date();
|
785
|
-
const hours = now.getHours();
|
786
|
-
const minutes = now.getMinutes();
|
787
|
-
const seconds = now.getSeconds();
|
788
|
-
return `${hours}:${minutes}:${seconds}`;
|
789
|
-
}
|
790
|
-
/**
|
791
|
-
* 2024-6-24 10:28:12
|
792
|
-
*/
|
793
|
-
function datetime() {
|
794
|
-
const now = new Date();
|
795
|
-
const year = now.getFullYear();
|
796
|
-
const month = now.getMonth() + 1 /*月份从0开始,需要加1*/ ;
|
797
|
-
const day = now.getDate();
|
798
|
-
const hours = now.getHours();
|
799
|
-
const minutes = now.getMinutes();
|
800
|
-
const seconds = now.getSeconds();
|
801
|
-
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
802
772
|
}
|
package/package.json
CHANGED
package/publish.cmd
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
npm publish --access public
|