ace-colorpicker-rpk 0.0.12
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/.babelrc +30 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- package/ChangeLogs.md +22 -0
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/addon/ace-colorpicker.css +1074 -0
- package/addon/ace-colorpicker.js +9602 -0
- package/addon/sample/colorpicker.html +199 -0
- package/config/rollup.config.dev.js +52 -0
- package/config/rollup.config.prod.js +53 -0
- package/dist/ace-colorpicker.css +1074 -0
- package/dist/ace-colorpicker.js +9736 -0
- package/dist/ace-colorpicker.min.js +1 -0
- package/gl.html +56 -0
- package/index.html +172 -0
- package/package.json +87 -0
- package/resources/image/ace-editor.png +0 -0
- package/resources/image/colorpaletts.png +0 -0
- package/resources/image/colorpicker.png +0 -0
- package/resources/image/grapes.jpg +0 -0
- package/resources/image/palette-type.png +0 -0
- package/resources/image/scalecolors-title.png +0 -0
- package/resources/image/scalecolors.png +0 -0
- package/resources/image/screen-shot.png +0 -0
- package/resources/image/sketch-type.png +0 -0
- package/src/colorpicker/BaseBox.js +94 -0
- package/src/colorpicker/BaseColorPicker.js +404 -0
- package/src/colorpicker/BaseModule.js +19 -0
- package/src/colorpicker/BaseSlider.js +97 -0
- package/src/colorpicker/BaseStore.js +71 -0
- package/src/colorpicker/UIElement.js +46 -0
- package/src/colorpicker/VerticalSlider.js +57 -0
- package/src/colorpicker/chromedevtool/ColorControl.js +47 -0
- package/src/colorpicker/chromedevtool/index.js +36 -0
- package/src/colorpicker/index.js +37 -0
- package/src/colorpicker/macos/ColorControl.js +47 -0
- package/src/colorpicker/macos/index.js +38 -0
- package/src/colorpicker/mini/ColorControl.js +40 -0
- package/src/colorpicker/mini/index.js +24 -0
- package/src/colorpicker/mini-vertical/ColorControl.js +35 -0
- package/src/colorpicker/mini-vertical/index.js +23 -0
- package/src/colorpicker/module/ColorManager.js +111 -0
- package/src/colorpicker/module/ColorSetsList.js +132 -0
- package/src/colorpicker/ring/ColorControl.js +47 -0
- package/src/colorpicker/ring/index.js +42 -0
- package/src/colorpicker/ui/ColorInformation.js +216 -0
- package/src/colorpicker/ui/ColorPalette.js +130 -0
- package/src/colorpicker/ui/ColorRing.js +68 -0
- package/src/colorpicker/ui/ColorSetsChooser.js +96 -0
- package/src/colorpicker/ui/ColorWheel.js +257 -0
- package/src/colorpicker/ui/CurrentColorSets.js +81 -0
- package/src/colorpicker/ui/CurrentColorSetsContextMenu.js +63 -0
- package/src/colorpicker/ui/control/Hue.js +40 -0
- package/src/colorpicker/ui/control/Opacity.js +65 -0
- package/src/colorpicker/ui/control/Value.js +50 -0
- package/src/colorpicker/ui/control/VerticalHue.js +39 -0
- package/src/colorpicker/ui/control/VerticalOpacity.js +55 -0
- package/src/colorpicker/vscode/ColorControl.js +40 -0
- package/src/colorpicker/vscode/index.js +82 -0
- package/src/colorpicker/xd/ColorControl.js +36 -0
- package/src/colorpicker/xd/index.js +36 -0
- package/src/extension/ace/colorview.js +198 -0
- package/src/extension/ace/index.js +11 -0
- package/src/index.js +12 -0
- package/src/scss/colorpicker.scss +65 -0
- package/src/scss/colorview.scss +32 -0
- package/src/scss/component/button.scss +33 -0
- package/src/scss/component/colorchooser.scss +141 -0
- package/src/scss/component/colorsets-contextmenu.scss +33 -0
- package/src/scss/component/colorsets.scss +89 -0
- package/src/scss/component/control.scss +93 -0
- package/src/scss/component/gradient-editor.scss +260 -0
- package/src/scss/component/gradient-picker.scss +241 -0
- package/src/scss/component/information.scss +141 -0
- package/src/scss/component/palette.scss +45 -0
- package/src/scss/index.scss +5 -0
- package/src/scss/mixins.scss +21 -0
- package/src/scss/themes/macos.scss +71 -0
- package/src/scss/themes/mini-vertical.scss +94 -0
- package/src/scss/themes/mini.scss +76 -0
- package/src/scss/themes/palette.scss +85 -0
- package/src/scss/themes/ring.scss +57 -0
- package/src/scss/themes/sketch.scss +172 -0
- package/src/scss/themes/vscode.scss +93 -0
- package/src/scss/themes/xd.scss +88 -0
- package/src/util/Blender.js +29 -0
- package/src/util/Canvas.js +128 -0
- package/src/util/Color.js +27 -0
- package/src/util/ColorNames.js +14 -0
- package/src/util/Dom.js +361 -0
- package/src/util/Event.js +30 -0
- package/src/util/EventMachin.js +349 -0
- package/src/util/GL.js +8 -0
- package/src/util/HueColor.js +49 -0
- package/src/util/ImageFilter.js +9 -0
- package/src/util/ImageLoader.js +137 -0
- package/src/util/Kmeans.js +237 -0
- package/src/util/Matrix.js +196 -0
- package/src/util/State.js +42 -0
- package/src/util/blend/composite.js +124 -0
- package/src/util/blend/non-separable.js +118 -0
- package/src/util/blend/separable.js +76 -0
- package/src/util/filter/StackBlur.js +517 -0
- package/src/util/filter/functions.js +829 -0
- package/src/util/filter/image/crop.js +16 -0
- package/src/util/filter/image/flipH.js +23 -0
- package/src/util/filter/image/flipV.js +25 -0
- package/src/util/filter/image/histogram.js +45 -0
- package/src/util/filter/image/index.js +18 -0
- package/src/util/filter/image/resize.js +18 -0
- package/src/util/filter/image/rotate.js +39 -0
- package/src/util/filter/image/rotateDegree.js +53 -0
- package/src/util/filter/index.js +11 -0
- package/src/util/filter/matrix/blur.js +12 -0
- package/src/util/filter/matrix/emboss.js +17 -0
- package/src/util/filter/matrix/gaussian-blur-5x.js +17 -0
- package/src/util/filter/matrix/gaussian-blur.js +16 -0
- package/src/util/filter/matrix/grayscale2.js +16 -0
- package/src/util/filter/matrix/index.js +58 -0
- package/src/util/filter/matrix/kirsch-horizontal.js +13 -0
- package/src/util/filter/matrix/kirsch-vertical.js +13 -0
- package/src/util/filter/matrix/laplacian-5x.js +16 -0
- package/src/util/filter/matrix/laplacian.js +14 -0
- package/src/util/filter/matrix/motion-blur-2.js +18 -0
- package/src/util/filter/matrix/motion-blur-3.js +19 -0
- package/src/util/filter/matrix/motion-blur.js +18 -0
- package/src/util/filter/matrix/negative.js +16 -0
- package/src/util/filter/matrix/normal.js +11 -0
- package/src/util/filter/matrix/sepia2.js +16 -0
- package/src/util/filter/matrix/sharpen.js +14 -0
- package/src/util/filter/matrix/sobel-horizontal.js +11 -0
- package/src/util/filter/matrix/sobel-vertical.js +11 -0
- package/src/util/filter/matrix/stack-blur.js +15 -0
- package/src/util/filter/matrix/transparency.js +16 -0
- package/src/util/filter/matrix/unsharp-masking.js +16 -0
- package/src/util/filter/multi/index.js +9 -0
- package/src/util/filter/multi/kirsch.js +7 -0
- package/src/util/filter/multi/sobel.js +7 -0
- package/src/util/filter/multi/vintage.js +7 -0
- package/src/util/filter/pixel/bitonal.js +24 -0
- package/src/util/filter/pixel/brightness.js +19 -0
- package/src/util/filter/pixel/brownie.js +23 -0
- package/src/util/filter/pixel/clip.js +21 -0
- package/src/util/filter/pixel/contrast.js +18 -0
- package/src/util/filter/pixel/gamma.js +13 -0
- package/src/util/filter/pixel/gradient.js +52 -0
- package/src/util/filter/pixel/grayscale.js +27 -0
- package/src/util/filter/pixel/hue.js +28 -0
- package/src/util/filter/pixel/index.js +52 -0
- package/src/util/filter/pixel/invert.js +16 -0
- package/src/util/filter/pixel/kodachrome.js +23 -0
- package/src/util/filter/pixel/matrix.js +28 -0
- package/src/util/filter/pixel/noise.js +24 -0
- package/src/util/filter/pixel/opacity.js +14 -0
- package/src/util/filter/pixel/polaroid.js +23 -0
- package/src/util/filter/pixel/saturation.js +30 -0
- package/src/util/filter/pixel/sepia.js +28 -0
- package/src/util/filter/pixel/shade.js +21 -0
- package/src/util/filter/pixel/shift.js +23 -0
- package/src/util/filter/pixel/solarize.js +23 -0
- package/src/util/filter/pixel/technicolor.js +23 -0
- package/src/util/filter/pixel/threshold-color.js +35 -0
- package/src/util/filter/pixel/threshold.js +7 -0
- package/src/util/filter/pixel/tint.js +20 -0
- package/src/util/functions/formatter.js +99 -0
- package/src/util/functions/fromCMYK.js +17 -0
- package/src/util/functions/fromHSL.js +52 -0
- package/src/util/functions/fromHSV.js +64 -0
- package/src/util/functions/fromLAB.js +99 -0
- package/src/util/functions/fromRGB.js +220 -0
- package/src/util/functions/fromYCrCb.js +16 -0
- package/src/util/functions/func.js +194 -0
- package/src/util/functions/image.js +145 -0
- package/src/util/functions/math.js +56 -0
- package/src/util/functions/mixin.js +164 -0
- package/src/util/functions/parser.js +294 -0
- package/src/util/gl/filter/index.js +9 -0
- package/src/util/gl/filter/matrix/blur.js +9 -0
- package/src/util/gl/filter/matrix/emboss.js +17 -0
- package/src/util/gl/filter/matrix/gaussian-blur-5x.js +15 -0
- package/src/util/gl/filter/matrix/gaussian-blur.js +19 -0
- package/src/util/gl/filter/matrix/grayscale2.js +13 -0
- package/src/util/gl/filter/matrix/index.js +55 -0
- package/src/util/gl/filter/matrix/kirsch-horizontal.js +11 -0
- package/src/util/gl/filter/matrix/kirsch-vertical.js +11 -0
- package/src/util/gl/filter/matrix/laplacian-5x.js +13 -0
- package/src/util/gl/filter/matrix/laplacian.js +11 -0
- package/src/util/gl/filter/matrix/motion-blur-2.js +17 -0
- package/src/util/gl/filter/matrix/motion-blur-3.js +17 -0
- package/src/util/gl/filter/matrix/motion-blur.js +17 -0
- package/src/util/gl/filter/matrix/negative.js +13 -0
- package/src/util/gl/filter/matrix/normal.js +8 -0
- package/src/util/gl/filter/matrix/sepia2.js +13 -0
- package/src/util/gl/filter/matrix/sharpen.js +11 -0
- package/src/util/gl/filter/matrix/sobel-horizontal.js +11 -0
- package/src/util/gl/filter/matrix/sobel-vertical.js +11 -0
- package/src/util/gl/filter/matrix/transparency.js +13 -0
- package/src/util/gl/filter/matrix/unsharp-masking.js +14 -0
- package/src/util/gl/filter/multi/index.js +9 -0
- package/src/util/gl/filter/multi/kirsch.js +7 -0
- package/src/util/gl/filter/multi/sobel.js +7 -0
- package/src/util/gl/filter/multi/vintage.js +7 -0
- package/src/util/gl/filter/pixel/bitonal.js +22 -0
- package/src/util/gl/filter/pixel/brightness.js +14 -0
- package/src/util/gl/filter/pixel/brownie.js +11 -0
- package/src/util/gl/filter/pixel/chaos.js +20 -0
- package/src/util/gl/filter/pixel/clip.js +20 -0
- package/src/util/gl/filter/pixel/contrast.js +16 -0
- package/src/util/gl/filter/pixel/gamma.js +16 -0
- package/src/util/gl/filter/pixel/gradient.js +59 -0
- package/src/util/gl/filter/pixel/grayscale.js +22 -0
- package/src/util/gl/filter/pixel/hue.js +19 -0
- package/src/util/gl/filter/pixel/index.js +54 -0
- package/src/util/gl/filter/pixel/invert.js +18 -0
- package/src/util/gl/filter/pixel/kodachrome.js +11 -0
- package/src/util/gl/filter/pixel/matrix.js +29 -0
- package/src/util/gl/filter/pixel/noise.js +18 -0
- package/src/util/gl/filter/pixel/opacity.js +17 -0
- package/src/util/gl/filter/pixel/polaroid.js +11 -0
- package/src/util/gl/filter/pixel/saturation.js +20 -0
- package/src/util/gl/filter/pixel/sepia.js +19 -0
- package/src/util/gl/filter/pixel/shade.js +20 -0
- package/src/util/gl/filter/pixel/shift.js +11 -0
- package/src/util/gl/filter/pixel/solarize.js +21 -0
- package/src/util/gl/filter/pixel/technicolor.js +11 -0
- package/src/util/gl/filter/pixel/threshold-color.js +15 -0
- package/src/util/gl/filter/pixel/threshold.js +7 -0
- package/src/util/gl/filter/pixel/tint.js +25 -0
- package/src/util/gl/filter/util.js +185 -0
- package/src/util/gl/functions.js +158 -0
- package/src/util/gl/index.js +543 -0
- package/src/util/index.js +17 -0
- package/stand.html +975 -0
- package/test/util.Blend.spec.js +15 -0
- package/test/util.Color.spec.js +200 -0
- package/test/util.Filter.spec.js +12 -0
- package/test/util.ImageFilter.spec.js +16 -0
package/src/util/Dom.js
ADDED
@@ -0,0 +1,361 @@
|
|
1
|
+
import ColorUtil from './Color'
|
2
|
+
|
3
|
+
const color = ColorUtil.color;
|
4
|
+
|
5
|
+
let counter = 0;
|
6
|
+
let cached = [];
|
7
|
+
|
8
|
+
export default class Dom {
|
9
|
+
|
10
|
+
constructor (tag, className, attr) {
|
11
|
+
|
12
|
+
if (typeof tag != 'string') {
|
13
|
+
this.el = tag;
|
14
|
+
} else {
|
15
|
+
|
16
|
+
var el = document.createElement(tag);
|
17
|
+
this.uniqId = counter++;
|
18
|
+
|
19
|
+
if (className) {
|
20
|
+
el.className = className;
|
21
|
+
}
|
22
|
+
|
23
|
+
attr = attr || {};
|
24
|
+
|
25
|
+
for(var k in attr) {
|
26
|
+
el.setAttribute(k, attr[k]);
|
27
|
+
}
|
28
|
+
|
29
|
+
this.el = el;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
static getScrollTop () {
|
34
|
+
return Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop)
|
35
|
+
}
|
36
|
+
|
37
|
+
static getScrollLeft () {
|
38
|
+
return Math.max(window.pageXOffset, document.documentElement.scrollLeft, document.body.scrollLeft)
|
39
|
+
}
|
40
|
+
|
41
|
+
attr (key, value) {
|
42
|
+
if (arguments.length == 1) {
|
43
|
+
return this.el.getAttribute(key);
|
44
|
+
}
|
45
|
+
|
46
|
+
this.el.setAttribute(key, value);
|
47
|
+
|
48
|
+
return this;
|
49
|
+
}
|
50
|
+
|
51
|
+
closest (cls) {
|
52
|
+
|
53
|
+
var temp = this;
|
54
|
+
var checkCls = false;
|
55
|
+
|
56
|
+
while(!(checkCls = temp.hasClass(cls))) {
|
57
|
+
if (temp.el.parentNode) {
|
58
|
+
temp = new Dom(temp.el.parentNode);
|
59
|
+
} else {
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
if (checkCls) {
|
65
|
+
return temp;
|
66
|
+
}
|
67
|
+
|
68
|
+
return null;
|
69
|
+
}
|
70
|
+
|
71
|
+
checked() {
|
72
|
+
return this.el.checked;
|
73
|
+
}
|
74
|
+
|
75
|
+
removeClass (cls) {
|
76
|
+
this.el.className = ((` ${this.el.className} `).replace(` ${cls} `, ' ')).trim();
|
77
|
+
|
78
|
+
return this;
|
79
|
+
}
|
80
|
+
|
81
|
+
hasClass (cls) {
|
82
|
+
if (!this.el.className)
|
83
|
+
{
|
84
|
+
return false;
|
85
|
+
} else {
|
86
|
+
var newClass = ` ${this.el.className} `;
|
87
|
+
return newClass.indexOf(` ${cls} `) > -1;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
addClass (cls) {
|
92
|
+
if (!this.hasClass(cls)) {
|
93
|
+
this.el.className = `${this.el.className} ${cls}`;
|
94
|
+
}
|
95
|
+
|
96
|
+
return this;
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
toggleClass (cls) {
|
101
|
+
if (this.hasClass(cls)) {
|
102
|
+
this.removeClass(cls);
|
103
|
+
} else {
|
104
|
+
this.addClass(cls);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
html (html) {
|
109
|
+
try {
|
110
|
+
if (typeof html == 'string') {
|
111
|
+
this.el.innerHTML = html;
|
112
|
+
} else {
|
113
|
+
this.empty().append(html);
|
114
|
+
}
|
115
|
+
|
116
|
+
} catch (e) {
|
117
|
+
console.log(html);
|
118
|
+
}
|
119
|
+
|
120
|
+
return this;
|
121
|
+
}
|
122
|
+
|
123
|
+
find (selector) {
|
124
|
+
return this.el.querySelector(selector)
|
125
|
+
}
|
126
|
+
|
127
|
+
$ (selector) {
|
128
|
+
return new Dom(this.find(selector))
|
129
|
+
}
|
130
|
+
|
131
|
+
findAll (selector) {
|
132
|
+
return this.el.querySelectorAll(selector)
|
133
|
+
}
|
134
|
+
|
135
|
+
$$ (selector) {
|
136
|
+
return [...this.findAll(selector)].map(el => new Dom(el))
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
empty () {
|
141
|
+
return this.html('');
|
142
|
+
}
|
143
|
+
|
144
|
+
append (el) {
|
145
|
+
|
146
|
+
if (typeof el == 'string') {
|
147
|
+
this.el.appendChild(document.createTextNode(el));
|
148
|
+
} else {
|
149
|
+
this.el.appendChild(el.el || el);
|
150
|
+
}
|
151
|
+
|
152
|
+
return this;
|
153
|
+
}
|
154
|
+
|
155
|
+
appendTo (target) {
|
156
|
+
var t = target.el ? target.el : target;
|
157
|
+
|
158
|
+
t.appendChild(this.el);
|
159
|
+
|
160
|
+
return this;
|
161
|
+
}
|
162
|
+
|
163
|
+
remove () {
|
164
|
+
if (this.el.parentNode) {
|
165
|
+
this.el.parentNode.removeChild(this.el);
|
166
|
+
}
|
167
|
+
|
168
|
+
return this;
|
169
|
+
}
|
170
|
+
|
171
|
+
text () {
|
172
|
+
return this.el.textContent;
|
173
|
+
}
|
174
|
+
|
175
|
+
css (key, value) {
|
176
|
+
if (arguments.length == 2) {
|
177
|
+
this.el.style[key] = value;
|
178
|
+
} else if (arguments.length == 1) {
|
179
|
+
|
180
|
+
if (typeof key == 'string') {
|
181
|
+
return getComputedStyle(this.el)[key];
|
182
|
+
} else {
|
183
|
+
var keys = key || {};
|
184
|
+
Object.keys(keys).forEach(k => {
|
185
|
+
this.el.style[k] = keys[k];
|
186
|
+
})
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
return this;
|
192
|
+
}
|
193
|
+
|
194
|
+
cssFloat (key) {
|
195
|
+
return parseFloat(this.css(key));
|
196
|
+
}
|
197
|
+
|
198
|
+
cssInt (key) {
|
199
|
+
return parseInt(this.css(key));
|
200
|
+
}
|
201
|
+
|
202
|
+
offset () {
|
203
|
+
var rect = this.el.getBoundingClientRect();
|
204
|
+
|
205
|
+
return {
|
206
|
+
top: rect.top + Dom.getScrollTop(),
|
207
|
+
left: rect.left + Dom.getScrollLeft()
|
208
|
+
};
|
209
|
+
}
|
210
|
+
|
211
|
+
rect () {
|
212
|
+
return this.el.getBoundingClientRect()
|
213
|
+
}
|
214
|
+
|
215
|
+
position () {
|
216
|
+
|
217
|
+
if (this.el.style.top) {
|
218
|
+
return {
|
219
|
+
top: parseFloat(this.css('top')),
|
220
|
+
left: parseFloat(this.css('left'))
|
221
|
+
};
|
222
|
+
} else {
|
223
|
+
return this.el.getBoundingClientRect();
|
224
|
+
}
|
225
|
+
|
226
|
+
}
|
227
|
+
|
228
|
+
size () {
|
229
|
+
return [this.width(), this.height()]
|
230
|
+
}
|
231
|
+
|
232
|
+
width () {
|
233
|
+
return this.el.offsetWidth || this.el.getBoundingClientRect().width;
|
234
|
+
}
|
235
|
+
|
236
|
+
contentWidth() {
|
237
|
+
return this.width() - this.cssFloat('padding-left') - this.cssFloat('padding-right');
|
238
|
+
}
|
239
|
+
|
240
|
+
height () {
|
241
|
+
return this.el.offsetHeight || this.el.getBoundingClientRect().height;
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
contentHeight() {
|
246
|
+
return this.height() - this.cssFloat('padding-top') - this.cssFloat('padding-bottom');
|
247
|
+
}
|
248
|
+
|
249
|
+
dataKey (key) {
|
250
|
+
return this.uniqId + '.' + key;
|
251
|
+
}
|
252
|
+
|
253
|
+
data (key, value) {
|
254
|
+
if (arguments.length == 2) {
|
255
|
+
cached[this.dataKey(key)] = value;
|
256
|
+
} else if (arguments.length == 1) {
|
257
|
+
return cached[this.dataKey(key)];
|
258
|
+
} else {
|
259
|
+
var keys = Object.keys(cached);
|
260
|
+
|
261
|
+
var uniqId = this.uniqId + ".";
|
262
|
+
return keys.filter(function (key) {
|
263
|
+
if (key.indexOf(uniqId) == 0) {
|
264
|
+
return true;
|
265
|
+
}
|
266
|
+
|
267
|
+
return false;
|
268
|
+
}).map(function (value) {
|
269
|
+
return cached[value];
|
270
|
+
})
|
271
|
+
}
|
272
|
+
|
273
|
+
return this;
|
274
|
+
}
|
275
|
+
|
276
|
+
val (value) {
|
277
|
+
if (arguments.length == 0) {
|
278
|
+
return this.el.value;
|
279
|
+
} else if (arguments.length == 1) {
|
280
|
+
this.el.value = value;
|
281
|
+
}
|
282
|
+
|
283
|
+
return this;
|
284
|
+
}
|
285
|
+
|
286
|
+
int () {
|
287
|
+
return parseInt(this.val(), 10);
|
288
|
+
}
|
289
|
+
|
290
|
+
float () {
|
291
|
+
return parseFloat(this.val());
|
292
|
+
}
|
293
|
+
|
294
|
+
show () {
|
295
|
+
return this.css('display', 'block');
|
296
|
+
}
|
297
|
+
|
298
|
+
hide () {
|
299
|
+
return this.css('display', 'none');
|
300
|
+
}
|
301
|
+
|
302
|
+
toggle () {
|
303
|
+
if (this.css('display') == 'none') {
|
304
|
+
return this.show();
|
305
|
+
} else {
|
306
|
+
return this.hide();
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
scrollTop () {
|
311
|
+
if (this.el === document.body) {
|
312
|
+
return Dom.getScrollTop()
|
313
|
+
}
|
314
|
+
|
315
|
+
return this.el.scrollTop
|
316
|
+
}
|
317
|
+
|
318
|
+
scrollLeft () {
|
319
|
+
if (this.el === document.body) {
|
320
|
+
return Dom.getScrollLeft()
|
321
|
+
}
|
322
|
+
|
323
|
+
return this.el.scrollLeft
|
324
|
+
}
|
325
|
+
|
326
|
+
on (eventName, callback, opt1, opt2) {
|
327
|
+
this.el.addEventListener(eventName, callback, opt1, opt2);
|
328
|
+
|
329
|
+
return this;
|
330
|
+
}
|
331
|
+
|
332
|
+
off (eventName, callback ) {
|
333
|
+
this.el.removeEventListener(eventName, callback);
|
334
|
+
|
335
|
+
return this;
|
336
|
+
}
|
337
|
+
|
338
|
+
getElement ( ) {
|
339
|
+
return this.el;
|
340
|
+
}
|
341
|
+
|
342
|
+
createChild (tag, className = '', attrs = {}, css = {}) {
|
343
|
+
let $element = new Dom(tag, className, attrs);
|
344
|
+
$element.css(css);
|
345
|
+
|
346
|
+
this.append($element);
|
347
|
+
|
348
|
+
return $element;
|
349
|
+
}
|
350
|
+
|
351
|
+
firstChild () {
|
352
|
+
return new Dom(this.el.firstElementChild);
|
353
|
+
}
|
354
|
+
|
355
|
+
replace (oldElement, newElement) {
|
356
|
+
this.el.replaceChild(newElement, oldElement);
|
357
|
+
|
358
|
+
return this;
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
export default {
|
2
|
+
|
3
|
+
addEvent (dom, eventName, callback, options) {
|
4
|
+
if (dom) {
|
5
|
+
dom.addEventListener(eventName, callback, options);
|
6
|
+
}
|
7
|
+
},
|
8
|
+
|
9
|
+
removeEvent(dom, eventName, callback) {
|
10
|
+
if (dom) {
|
11
|
+
dom.removeEventListener(eventName, callback);
|
12
|
+
}
|
13
|
+
},
|
14
|
+
|
15
|
+
pos(e) {
|
16
|
+
if (e.touches && e.touches[0]) {
|
17
|
+
return e.touches[0];
|
18
|
+
}
|
19
|
+
|
20
|
+
return e;
|
21
|
+
},
|
22
|
+
|
23
|
+
posXY (e) {
|
24
|
+
var pos = this.pos(e);
|
25
|
+
return {
|
26
|
+
x: pos.pageX,
|
27
|
+
y: pos.pageY
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|