@kizmann/nano-ui 1.0.14 → 1.1.0
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/nano-ui.css +1 -1
- package/dist/nano-ui.js +1 -1
- package/dist/nano-ui.js.map +1 -1
- package/dist/themes/dark.css +1 -1
- package/dist/themes/glossy.dark.css +1 -0
- package/dist/themes/glossy.light.css +1 -0
- package/dist/themes/light.css +1 -1
- package/package.json +1 -1
- package/src/button/src/button/button.jsx +12 -0
- package/src/button/src/button/button.scss +4 -1
- package/src/collapse/src/collapse-item/collapse-item.jsx +1 -1
- package/src/draggable/src/draglist/draglist.jsx +1 -1
- package/src/draggable/src/draglist-item/draglist-item.jsx +5 -2
- package/src/drawer/src/drawer/drawer.jsx +9 -3
- package/src/form/src/form/form.jsx +9 -4
- package/src/form/src/form-frame/form-frame.jsx +53 -21
- package/src/form/src/form-frame/form-frame.scss +7 -0
- package/src/form/src/form-group/form-group.jsx +31 -11
- package/src/form/src/form-item/form-item.jsx +9 -5
- package/src/info/src/info/info.jsx +1 -1
- package/src/modal/src/modal/modal.jsx +1 -1
- package/src/modal/src/modal/modal.scss +2 -2
- package/src/paginator/src/paginator/paginator.jsx +24 -29
- package/src/preview/index.js +2 -0
- package/src/preview/index.scss +1 -0
- package/src/preview/src/_tools/preview-handler.js +193 -0
- package/src/preview/src/_tools/preview-helper.js +142 -0
- package/src/preview/src/preview/preview.jsx +48 -115
- package/src/preview/src/preview/preview.scss +2 -1
- package/src/preview/src/preview-modal/preview-modal.jsx +156 -0
- package/src/preview/src/preview-modal/preview-modal.scss +56 -0
- package/src/preview/src/preview-video/preview-video.jsx +4 -60
- package/src/resizer/index.js +3 -1
- package/src/resizer/src/resizer/resizer-next.jsx +536 -0
- package/src/resizer/src/resizer/resizer.jsx +17 -11
- package/src/scrollbar/index.js +3 -1
- package/src/scrollbar/index.scss +1 -0
- package/src/scrollbar/src/scrollbar/scrollbar.scss +14 -8
- package/src/scrollbar/src/scrollbar-next/scrollbar-next.jsx +640 -0
- package/src/scrollbar/src/scrollbar-next/scrollbar-next.scss +148 -0
- package/src/select/src/select/select.jsx +12 -16
- package/src/select/src/select/select.scss +1 -1
- package/src/table/src/table/table.jsx +4 -7
- package/src/table/src/table/table.scss +15 -14
- package/src/table/src/table-cell/types/table-cell-image.jsx +9 -3
- package/src/table/src/table-column/table-column.jsx +11 -27
- package/src/table/src/table-filter/types/table-filter-datetime.jsx +1 -1
- package/src/tabs/src/tabs-item/tabs-item.jsx +1 -1
- package/src/tags/src/tags-item/tags-item.jsx +1 -2
- package/src/timepicker/src/timepicker-panel/timepicker-panel.jsx +15 -3
- package/src/timepicker/src/timepicker-panel/timepicker-panel.scss +2 -1
- package/src/virtualscroller/src/virtualscroller/virtualscroller.jsx +63 -30
- package/src/virtualscroller/src/virtualscroller/virtualscroller.scss +1 -0
- package/themes/glossy/button/index.scss +2 -0
- package/themes/glossy/button/src/button/button.scss +116 -0
- package/themes/glossy/button/src/button-group/button-group.scss +1 -0
- package/themes/glossy/index-dark.scss +3 -0
- package/themes/glossy/index-light.scss +3 -0
- package/themes/glossy/index.scss +43 -0
- package/themes/glossy/root/image/empty-default.svg +30 -0
- package/themes/glossy/root/image/empty-space.svg +34 -0
- package/themes/glossy/root/image/star-default.svg +10 -0
- package/themes/glossy/root/image/test.svg +1 -0
- package/themes/glossy/root/vars-dark.scss +234 -0
- package/themes/glossy/root/vars-light.scss +234 -0
- package/themes/glossy/root/vars.scss +233 -0
- package/themes/macos/button/src/button/button.scss +46 -8
- package/themes/macos/form/src/form-frame/form-frame.scss +2 -2
- package/themes/macos/index.scss +1 -0
- package/themes/macos/preview/index.scss +1 -0
- package/themes/macos/preview/src/preview-modal/preview-modal.scss +28 -0
- package/themes/macos/scrollbar/src/scrollbar/scrollbar.scss +1 -0
- package/themes/macos/table/src/table/table.scss +5 -0
|
@@ -63,7 +63,7 @@ export default {
|
|
|
63
63
|
|
|
64
64
|
data()
|
|
65
65
|
{
|
|
66
|
-
return { search: '' };
|
|
66
|
+
return { search: '', star: '', block: false };
|
|
67
67
|
},
|
|
68
68
|
|
|
69
69
|
mounted()
|
|
@@ -75,10 +75,48 @@ export default {
|
|
|
75
75
|
this.$nextTick(() => {
|
|
76
76
|
this.onScrollEvent();
|
|
77
77
|
});
|
|
78
|
+
|
|
79
|
+
this.onMoveEvent();
|
|
78
80
|
},
|
|
79
81
|
|
|
80
82
|
methods: {
|
|
81
83
|
|
|
84
|
+
applyStar(id, block = false)
|
|
85
|
+
{
|
|
86
|
+
if ( this.block ) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this.block = block;
|
|
91
|
+
|
|
92
|
+
if ( ! Any.isEmpty(this.timeout) ) {
|
|
93
|
+
clearTimeout(this.timeout);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ( block ) {
|
|
97
|
+
this.star = id;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.timeout = setTimeout(() => {
|
|
101
|
+
this.star = id; this.block = false;
|
|
102
|
+
}, 500);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
onMoveEvent()
|
|
106
|
+
{
|
|
107
|
+
Dom.find(window).on('mousemove', Any.debounce(e => {
|
|
108
|
+
|
|
109
|
+
let el = Dom.find(e.target).closest('[data-group-key]');
|
|
110
|
+
|
|
111
|
+
if ( Any.isEmpty(el) ) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.applyStar(Dom.find(el).attr('data-group-key'), true);
|
|
116
|
+
|
|
117
|
+
}, 100));
|
|
118
|
+
},
|
|
119
|
+
|
|
82
120
|
onScrollEvent()
|
|
83
121
|
{
|
|
84
122
|
Dom.find(this.$el).find('[data-menu-key]').each((el) => {
|
|
@@ -107,12 +145,7 @@ export default {
|
|
|
107
145
|
this.$refs.menu.scrollIntoView(selector)
|
|
108
146
|
});
|
|
109
147
|
|
|
110
|
-
|
|
111
|
-
el: el, attr: Dom.find(el).attr('data-group-key')
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
Dom.find(`[data-menu-key="${star.attr}"]`)
|
|
115
|
-
.addClass('is-star');
|
|
148
|
+
this.applyStar(Dom.find(el).attr('data-group-key'), false);
|
|
116
149
|
},
|
|
117
150
|
|
|
118
151
|
onSearchInput()
|
|
@@ -127,7 +160,12 @@ export default {
|
|
|
127
160
|
}
|
|
128
161
|
|
|
129
162
|
let groups = Arr.filter(this.NForm.groups, (group) => {
|
|
130
|
-
|
|
163
|
+
|
|
164
|
+
let labels = Arr.extract(group.items, 'label')
|
|
165
|
+
.join("\n");
|
|
166
|
+
|
|
167
|
+
return Str.lower(group.label + "\n" + labels)
|
|
168
|
+
.indexOf(search) !== -1;
|
|
131
169
|
});
|
|
132
170
|
|
|
133
171
|
Arr.each(groups, (group) => {
|
|
@@ -147,20 +185,10 @@ export default {
|
|
|
147
185
|
item.openGroup();
|
|
148
186
|
}
|
|
149
187
|
|
|
150
|
-
if (
|
|
151
|
-
|
|
188
|
+
if ( this.star !== item.key ) {
|
|
189
|
+
this.applyStar(item.key, true);
|
|
152
190
|
}
|
|
153
191
|
|
|
154
|
-
Dom.find('[data-group-key]').removeClass('on-search');
|
|
155
|
-
|
|
156
|
-
this.timeout = setTimeout(() => {
|
|
157
|
-
Dom.find(selector).removeClass('on-search');
|
|
158
|
-
}, 4000);
|
|
159
|
-
|
|
160
|
-
this.$nextTick(() => {
|
|
161
|
-
Dom.find(selector).addClass('on-search');
|
|
162
|
-
});
|
|
163
|
-
|
|
164
192
|
this.$refs.body.scrollIntoView(selector, 0, 100);
|
|
165
193
|
}
|
|
166
194
|
|
|
@@ -214,7 +242,11 @@ export default {
|
|
|
214
242
|
let classList = [
|
|
215
243
|
'n-form-frame__menu',
|
|
216
244
|
'n-form-frame__menu--' + item.type
|
|
217
|
-
]
|
|
245
|
+
];
|
|
246
|
+
|
|
247
|
+
if ( this.star === item.key ) {
|
|
248
|
+
classList.push('is-star');
|
|
249
|
+
}
|
|
218
250
|
|
|
219
251
|
return (
|
|
220
252
|
<a class={classList} data-menu-key={item.key} {...buttonProps}>
|
|
@@ -57,6 +57,13 @@
|
|
|
57
57
|
.n-form-frame__menu i {
|
|
58
58
|
flex: 0 0 auto;
|
|
59
59
|
text-align: center;
|
|
60
|
+
transition: opacity 0.3s;
|
|
61
|
+
opacity: 0.7;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.n-form-frame__menu.on-search i,
|
|
65
|
+
.n-form-frame__menu.is-visible i {
|
|
66
|
+
opacity: 1;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
.n-form-frame__menu span {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UUID } from "@kizmann/pico-js";
|
|
1
|
+
import { Arr, UUID } from "@kizmann/pico-js";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
|
|
@@ -107,27 +107,32 @@ export default {
|
|
|
107
107
|
|
|
108
108
|
},
|
|
109
109
|
|
|
110
|
+
data()
|
|
111
|
+
{
|
|
112
|
+
return {
|
|
113
|
+
uid: UUID(), tempValue: this.modelValue, items: []
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
provide()
|
|
118
|
+
{
|
|
119
|
+
return { NFormGroup: this };
|
|
120
|
+
},
|
|
121
|
+
|
|
110
122
|
mounted()
|
|
111
123
|
{
|
|
112
124
|
if ( this.NForm ) {
|
|
113
|
-
this.NForm.
|
|
125
|
+
this.NForm.appendGroup(this);
|
|
114
126
|
}
|
|
115
127
|
},
|
|
116
128
|
|
|
117
129
|
unmounted()
|
|
118
130
|
{
|
|
119
131
|
if ( this.NForm ) {
|
|
120
|
-
this.NForm.
|
|
132
|
+
this.NForm.removeGroup(this);
|
|
121
133
|
}
|
|
122
134
|
},
|
|
123
135
|
|
|
124
|
-
data()
|
|
125
|
-
{
|
|
126
|
-
return {
|
|
127
|
-
tempValue: this.modelValue
|
|
128
|
-
};
|
|
129
|
-
},
|
|
130
|
-
|
|
131
136
|
watch: {
|
|
132
137
|
|
|
133
138
|
modelValue(value)
|
|
@@ -141,6 +146,21 @@ export default {
|
|
|
141
146
|
|
|
142
147
|
methods: {
|
|
143
148
|
|
|
149
|
+
getItems()
|
|
150
|
+
{
|
|
151
|
+
return this.items;
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
appendItem(item)
|
|
155
|
+
{
|
|
156
|
+
this.items[item.uid] = item;
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
removeItem(item)
|
|
160
|
+
{
|
|
161
|
+
delete this.items[item.uid];
|
|
162
|
+
},
|
|
163
|
+
|
|
144
164
|
toggleGroup()
|
|
145
165
|
{
|
|
146
166
|
this.$emit('update:modelValue', this.tempValue = ! this.tempValue);
|
|
@@ -154,7 +174,7 @@ export default {
|
|
|
154
174
|
closeGroup()
|
|
155
175
|
{
|
|
156
176
|
this.$emit('update:modelValue', this.tempValue = true);
|
|
157
|
-
}
|
|
177
|
+
},
|
|
158
178
|
|
|
159
179
|
},
|
|
160
180
|
|
|
@@ -6,11 +6,15 @@ export default {
|
|
|
6
6
|
|
|
7
7
|
inject: {
|
|
8
8
|
|
|
9
|
+
NTabs: {
|
|
10
|
+
default: undefined
|
|
11
|
+
},
|
|
12
|
+
|
|
9
13
|
NForm: {
|
|
10
14
|
default: undefined
|
|
11
15
|
},
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
NFormGroup: {
|
|
14
18
|
default: undefined
|
|
15
19
|
},
|
|
16
20
|
|
|
@@ -175,8 +179,8 @@ export default {
|
|
|
175
179
|
|
|
176
180
|
beforeMount()
|
|
177
181
|
{
|
|
178
|
-
if ( this.
|
|
179
|
-
this.
|
|
182
|
+
if ( this.NFormGroup ) {
|
|
183
|
+
this.NFormGroup.appendItem(this);
|
|
180
184
|
}
|
|
181
185
|
},
|
|
182
186
|
|
|
@@ -189,8 +193,8 @@ export default {
|
|
|
189
193
|
|
|
190
194
|
beforeUnmount()
|
|
191
195
|
{
|
|
192
|
-
if ( this.
|
|
193
|
-
this.
|
|
196
|
+
if ( this.NFormGroup ) {
|
|
197
|
+
this.NFormGroup.removeItem(this);
|
|
194
198
|
}
|
|
195
199
|
},
|
|
196
200
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
transition: opacity 0.5s ease-in-out;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.n-modal:not(.n-ready) .n-modal__backdrop {
|
|
30
|
+
.n-modal:not(.n-ready,.n-loop) .n-modal__backdrop {
|
|
31
31
|
opacity: 0;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
transition: opacity 0.2s 0.1s ease-out, transform 0.2s 0.1s ease-out;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.n-modal:not(.n-ready) .n-modal__frame {
|
|
50
|
+
.n-modal:not(.n-ready,.n-loop) .n-modal__frame {
|
|
51
51
|
opacity: 0;
|
|
52
52
|
transform: translateY(20px);
|
|
53
53
|
}
|
|
@@ -95,7 +95,6 @@ export default {
|
|
|
95
95
|
},
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
|
|
99
98
|
methods: {
|
|
100
99
|
|
|
101
100
|
forcePage(page)
|
|
@@ -175,11 +174,11 @@ export default {
|
|
|
175
174
|
renderLimit()
|
|
176
175
|
{
|
|
177
176
|
let props = {
|
|
178
|
-
modelValue:
|
|
179
|
-
size:
|
|
180
|
-
type:
|
|
181
|
-
optionsValue:
|
|
182
|
-
optionsLabel:
|
|
177
|
+
modelValue: this.tempLimit,
|
|
178
|
+
size: this.size,
|
|
179
|
+
type: this.type,
|
|
180
|
+
optionsValue: '$value.value',
|
|
181
|
+
optionsLabel: '$value.label',
|
|
183
182
|
};
|
|
184
183
|
|
|
185
184
|
props.options = Arr.each(this.limitOptions, (limit) => {
|
|
@@ -201,7 +200,7 @@ export default {
|
|
|
201
200
|
{
|
|
202
201
|
return (
|
|
203
202
|
<div class="n-paginator__count">
|
|
204
|
-
{
|
|
203
|
+
{this.choice('No items|Total :count item|Total :count items', this.total)}
|
|
205
204
|
</div>
|
|
206
205
|
);
|
|
207
206
|
},
|
|
@@ -210,7 +209,7 @@ export default {
|
|
|
210
209
|
{
|
|
211
210
|
return (
|
|
212
211
|
<div class="n-paginator__spacer">
|
|
213
|
-
{ /* Nothing :( */
|
|
212
|
+
{ /* Nothing :( */}
|
|
214
213
|
</div>
|
|
215
214
|
);
|
|
216
215
|
},
|
|
@@ -218,28 +217,24 @@ export default {
|
|
|
218
217
|
renderGoto()
|
|
219
218
|
{
|
|
220
219
|
if ( this.pageOptions.length > 500 ) {
|
|
221
|
-
return null;
|
|
220
|
+
// return null;
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
let props = {
|
|
225
|
-
modelValue:
|
|
226
|
-
size:
|
|
227
|
-
type:
|
|
228
|
-
undefinedText:
|
|
229
|
-
|
|
230
|
-
|
|
224
|
+
modelValue: this.tempPage,
|
|
225
|
+
size: this.size,
|
|
226
|
+
type: this.type,
|
|
227
|
+
undefinedText: '?',
|
|
228
|
+
lazy: true,
|
|
229
|
+
options: this.pageOptions,
|
|
230
|
+
optionsValue: '$value',
|
|
231
|
+
optionsLabel: '$value',
|
|
231
232
|
};
|
|
232
233
|
|
|
233
|
-
props.options = Arr.reduce(this.pageOptions, (merge, index) => {
|
|
234
|
-
return Arr.push(merge, {
|
|
235
|
-
value: index, label: index
|
|
236
|
-
});
|
|
237
|
-
}, []);
|
|
238
|
-
|
|
239
234
|
props['onUpdate:modelValue'] = this.onPageInput;
|
|
240
235
|
|
|
241
236
|
return (
|
|
242
|
-
<div class="n-paginator__goto">
|
|
237
|
+
<div class="n-paginator__goto" key={'paginate' + this.pageOptions.length}>
|
|
243
238
|
<NSelect {...props} />
|
|
244
239
|
</div>
|
|
245
240
|
);
|
|
@@ -369,7 +364,7 @@ export default {
|
|
|
369
364
|
};
|
|
370
365
|
|
|
371
366
|
return (
|
|
372
|
-
<NButton {...props}>{
|
|
367
|
+
<NButton {...props}>{current}</NButton>
|
|
373
368
|
);
|
|
374
369
|
},
|
|
375
370
|
|
|
@@ -381,18 +376,18 @@ export default {
|
|
|
381
376
|
|
|
382
377
|
return (
|
|
383
378
|
<div class="n-paginator__pages">
|
|
384
|
-
{
|
|
385
|
-
{
|
|
386
|
-
{
|
|
387
|
-
{
|
|
388
|
-
{
|
|
379
|
+
{this.ctor('renderFirst')()}
|
|
380
|
+
{this.ctor('renderPrev')()}
|
|
381
|
+
{...pages}
|
|
382
|
+
{this.ctor('renderNext')()}
|
|
383
|
+
{this.ctor('renderLast')()}
|
|
389
384
|
</div>
|
|
390
385
|
);
|
|
391
386
|
},
|
|
392
387
|
|
|
393
388
|
renderSlot(view)
|
|
394
389
|
{
|
|
395
|
-
let renderFunction = this.ctor('render' +
|
|
390
|
+
let renderFunction = this.ctor('render' +
|
|
396
391
|
Str.ucfirst(view));
|
|
397
392
|
|
|
398
393
|
if ( Any.isFunction(renderFunction) ) {
|
package/src/preview/index.js
CHANGED
|
@@ -2,9 +2,11 @@ import Preview from "./src/preview/preview.jsx";
|
|
|
2
2
|
import PreviewPlain from "./src/preview-plain/preview-plain.jsx";
|
|
3
3
|
import PreviewImage from "./src/preview-image/preview-image.jsx";
|
|
4
4
|
import PreviewVideo from "./src/preview-video/preview-video.jsx";
|
|
5
|
+
import PreviewModal from "./src/preview-modal/preview-modal.jsx";
|
|
5
6
|
|
|
6
7
|
export default function (App) {
|
|
7
8
|
App.component(Preview.name, Preview);
|
|
9
|
+
App.component(PreviewModal.name, PreviewModal);
|
|
8
10
|
App.component(PreviewPlain.name, PreviewPlain);
|
|
9
11
|
App.component(PreviewImage.name, PreviewImage);
|
|
10
12
|
App.component(PreviewVideo.name, PreviewVideo);
|
package/src/preview/index.scss
CHANGED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { Any, Arr, Obj, Dom } from "@kizmann/pico-js";
|
|
2
|
+
|
|
3
|
+
window.NPreviewCacheGroups = {};
|
|
4
|
+
|
|
5
|
+
export class NPreviewHandler
|
|
6
|
+
{
|
|
7
|
+
current = null;
|
|
8
|
+
|
|
9
|
+
static append(item)
|
|
10
|
+
{
|
|
11
|
+
if ( !window.NPreviewCacheGroups[item.group] ) {
|
|
12
|
+
window.NPreviewCacheGroups[item.group] = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
window.NPreviewCacheGroups[item.group][item.uid] = item;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static remove(item)
|
|
19
|
+
{
|
|
20
|
+
delete window.NPreviewCacheGroups[item.group][item.uid];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static get(group)
|
|
24
|
+
{
|
|
25
|
+
if ( !window.NPreviewCacheGroups[group] ) {
|
|
26
|
+
window.NPreviewCacheGroups[group] = {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return Arr.sort(window.NPreviewCacheGroups[group], 'index');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static next()
|
|
33
|
+
{
|
|
34
|
+
if ( ! Any.isObject(this.current) ) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let items = NPreviewHandler.get(this.current.group);
|
|
39
|
+
|
|
40
|
+
let index = Arr.findIndex(items, {
|
|
41
|
+
uid: this.current.uid
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
let next = Arr.first(items);
|
|
45
|
+
|
|
46
|
+
if ( items.length > index + 1 ) {
|
|
47
|
+
next = Arr.get(items, index + 1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return NPreviewHandler.switch(next);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static prev()
|
|
54
|
+
{
|
|
55
|
+
if ( ! Any.isObject(this.current) ) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let items = NPreviewHandler.get(this.current.group);
|
|
60
|
+
|
|
61
|
+
let index = Arr.findIndex(items, {
|
|
62
|
+
uid: this.current.uid
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
let prev = Arr.last(items);
|
|
66
|
+
|
|
67
|
+
if ( 0 <= index - 1 ) {
|
|
68
|
+
prev = Arr.get(items, index - 1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return NPreviewHandler.switch(prev);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static create()
|
|
75
|
+
{
|
|
76
|
+
el = Dom.find('.n-preview-modal');
|
|
77
|
+
|
|
78
|
+
if ( el.length() ) {
|
|
79
|
+
return el;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let el = Dom.make('div', {
|
|
83
|
+
classList: 'n-preview-modal'
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
el.attr('data-preview', 'nano');
|
|
87
|
+
|
|
88
|
+
let close = Dom.make('div', {
|
|
89
|
+
classList: 'n-preview-modal__close',
|
|
90
|
+
innerHTML: `<i class="${nano.Icons.times}"></i>`
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
close.on('click', () => {
|
|
94
|
+
NPreviewHandler.close()
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
close.appendTo(el);
|
|
98
|
+
|
|
99
|
+
let prev = Dom.make('div', {
|
|
100
|
+
classList: 'n-preview-modal__prev',
|
|
101
|
+
innerHTML: `<i class="${nano.Icons.angleLeft}"></i>`
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
prev.on('click', () => {
|
|
105
|
+
NPreviewHandler.prev()
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
prev.appendTo(el);
|
|
109
|
+
|
|
110
|
+
let next = Dom.make('div', {
|
|
111
|
+
classList: 'n-preview-modal__next',
|
|
112
|
+
innerHTML: `<i class="${nano.Icons.angleRight}"></i>`
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
next.on('click', () => {
|
|
116
|
+
NPreviewHandler.next()
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
next.appendTo(el);
|
|
120
|
+
|
|
121
|
+
el.appendTo(document.body);
|
|
122
|
+
|
|
123
|
+
return el;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static open(item)
|
|
127
|
+
{
|
|
128
|
+
let el = NPreviewHandler.create();
|
|
129
|
+
|
|
130
|
+
el.css({
|
|
131
|
+
'z-index': window.zIndex++
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
let keydownFn = (e) => {
|
|
135
|
+
|
|
136
|
+
if ( e.keyCode === 27 ) {
|
|
137
|
+
return NPreviewHandler.close();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if ( e.keyCode === 37 ) {
|
|
141
|
+
return NPreviewHandler.prev();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if ( e.keyCode === 39 ) {
|
|
145
|
+
return NPreviewHandler.next();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Dom.find(window).on('keydown', keydownFn, {
|
|
151
|
+
uid: 'n-preview-modal'
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
NPreviewHandler.switch(item);
|
|
155
|
+
|
|
156
|
+
el.addClass('n-ready');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static close()
|
|
160
|
+
{
|
|
161
|
+
let el = NPreviewHandler.create();
|
|
162
|
+
|
|
163
|
+
Dom.find(window).off('keydown', null, {
|
|
164
|
+
uid: 'n-preview-modal'
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
NPreviewHandler.switch(null);
|
|
168
|
+
|
|
169
|
+
el.removeClass('n-ready');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static switch(item)
|
|
173
|
+
{
|
|
174
|
+
if ( Any.isObject(this.current) ) {
|
|
175
|
+
Obj.set(this.current, 'visible', false);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.current = item;
|
|
179
|
+
|
|
180
|
+
if ( Any.isObject(this.current) ) {
|
|
181
|
+
Obj.set(this.current, 'visible', true);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return item;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default { NPreviewHandler }
|
|
190
|
+
|
|
191
|
+
if ( ! window.NPreviewHandler ) {
|
|
192
|
+
window.NPreviewHandler = NPreviewHandler;
|
|
193
|
+
}
|