material 0.7.0 → 0.7.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/README.md +1 -5
- package/dist/demo-bundle.js +2281 -2
- package/dist/demo-bundle.js.map +7 -1
- package/dist/demo.js +13 -13
- package/esbuild.js +22 -0
- package/esbuild.watch.js +25 -0
- package/form.js +27 -0
- package/index.js +59 -58
- package/list.js +35 -0
- package/package.json +8 -17
- package/src/appbar.js +7 -204
- package/src/badge.js +27 -0
- package/src/button.js +127 -177
- package/src/calendar.js +53 -55
- package/src/card.js +1 -3
- package/src/checkbox.js +5 -55
- package/src/component.js +0 -2
- package/src/container.js +0 -2
- package/src/datehour.js +38 -0
- package/src/dialog.js +104 -151
- package/src/divider.js +1 -3
- package/src/drawer.js +1 -19
- package/src/element/attribute.js +7 -10
- package/src/element/build.js +6 -7
- package/src/element/create.js +3 -6
- package/src/element/event.js +2 -2
- package/src/element/insert.js +6 -17
- package/src/element/observer.js +22 -0
- package/src/element/offset.js +2 -2
- package/src/element/style.js +12 -12
- package/src/element.js +2 -2
- package/src/field/email.js +9 -44
- package/src/field/image.js +17 -51
- package/src/{control/file.js → file.js} +15 -45
- package/src/form/build.js +7 -7
- package/src/form/controller.js +8 -8
- package/src/form/create.js +1 -1
- package/src/form/data.js +9 -9
- package/src/form/delete.js +1 -1
- package/src/form/render.js +9 -9
- package/src/form/set.js +1 -1
- package/src/form/submit.js +6 -6
- package/src/form/update.js +3 -3
- package/src/form/verify.js +6 -6
- package/src/form.js +9 -11
- package/src/icon.js +4 -6
- package/src/image.js +39 -106
- package/src/item.js +1 -3
- package/src/layout.js +14 -14
- package/src/{control/link.js → link.js} +13 -32
- package/src/list/build.js +10 -10
- package/src/list/click.js +3 -3
- package/src/list/collection.js +1 -1
- package/src/list/filter.js +11 -11
- package/src/list/image.js +3 -3
- package/src/list/render.js +15 -15
- package/src/list/request.js +8 -8
- package/src/list/search.js +12 -12
- package/src/list/select.js +18 -18
- package/src/list/status.js +1 -1
- package/src/list/update.js +6 -6
- package/src/list/virtual.js +20 -20
- package/src/list/virtual.new.js +5 -5
- package/src/list.js +29 -217
- package/src/loading.js +73 -0
- package/src/map/build.js +2 -2
- package/src/map/countries.js +8 -8
- package/src/map/display.js +13 -13
- package/src/map/focus.js +7 -7
- package/src/map/select.js +2 -2
- package/src/map/set.js +3 -3
- package/src/map/viewport.js +11 -11
- package/src/menu.js +59 -115
- package/src/mixin/control.js +3 -3
- package/src/mixin/controller.js +5 -5
- package/src/mixin/create.js +1 -1
- package/src/mixin/display.js +1 -2
- package/src/mixin/events.js +4 -16
- package/src/mixin/focus.js +1 -1
- package/src/mixin/icon.js +2 -2
- package/src/mixin/init.js +2 -2
- package/src/mixin/insert.js +7 -29
- package/src/mixin/label.js +2 -2
- package/src/mixin/settings.js +5 -5
- package/src/module/attach.js +35 -49
- package/src/{control/module → module}/attributes.js +4 -4
- package/src/module/build.js +12 -12
- package/src/module/classify.js +4 -4
- package/src/module/controller.js +5 -32
- package/src/module/css.js +12 -84
- package/src/module/dataset.js +1 -1
- package/src/module/dom.js +8 -3
- package/src/module/dot.js +4 -4
- package/src/module/emitter.js +1 -1
- package/src/module/event.js +2 -2
- package/src/module/events.js +29 -35
- package/src/module/extract.js +10 -10
- package/src/module/last.js +18 -0
- package/src/module/mediator.js +1 -13
- package/src/module/object.js +4 -4
- package/src/module/observer.js +43 -16
- package/src/module/remove.js +10 -10
- package/src/module/ripple.js +19 -24
- package/src/module/scrollbar.js +10 -14
- package/src/module/smoothscroll.js +5 -9
- package/src/module/utils.js +14 -23
- package/src/module/viewport.js +5 -5
- package/src/navigation.js +19 -0
- package/src/progress.js +1 -11
- package/src/search.js +66 -0
- package/src/select.js +58 -273
- package/src/{control/selecter.js → selecter.js} +42 -42
- package/src/selector.js +3 -3
- package/src/skin/material/component/navigation.sass +9 -0
- package/src/skin/material/control/button.sass +10 -0
- package/src/slider.js +1 -3
- package/src/snackbar.js +72 -50
- package/src/switch.js +111 -103
- package/src/{control/switcher.js → switcher.js} +28 -31
- package/src/tabs.js +4 -5
- package/src/tabview.js +26 -46
- package/src/text.js +25 -74
- package/src/textfield.js +97 -234
- package/src/toolbar.js +12 -12
- package/src/tooltip.js +7 -7
- package/src/tree.js +10 -66
- package/src/view/build.js +2 -2
- package/src/view/dataset.js +1 -1
- package/src/view.js +9 -74
- package/rollup.config.js +0 -34
- package/src/banner.js +0 -231
- package/src/control/button.js +0 -239
- package/src/control/button.new.js +0 -190
- package/src/control/datehour.js +0 -65
- package/src/control/dialog.js +0 -175
- package/src/control/image.js +0 -92
- package/src/control/list.js +0 -67
- package/src/control/loading.js +0 -128
- package/src/control/menu.js +0 -85
- package/src/control/module/addclass.js +0 -16
- package/src/control/search.js +0 -98
- package/src/control/select.js +0 -130
- package/src/control/snackbar.js +0 -91
- package/src/control/switch.js +0 -272
- package/src/control/text.js +0 -70
- package/src/control/textfield.js +0 -177
- package/src/element/ripple.js +0 -90
- package/src/tabs/setup.js +0 -0
package/src/checkbox.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
import events from './mixin/events'
|
|
4
2
|
import control from './mixin/control'
|
|
5
3
|
import label from './mixin/label'
|
|
@@ -9,12 +7,12 @@ import build from './element/build'
|
|
|
9
7
|
|
|
10
8
|
import emitter from './module/emitter'
|
|
11
9
|
import attach from './module/attach'
|
|
12
|
-
import css from './module/css'
|
|
10
|
+
import * as css from './module/css'
|
|
13
11
|
|
|
14
12
|
import icon from './skin/material/icon/checkbox.svg'
|
|
15
13
|
// element related modules
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
const defaults = {
|
|
18
16
|
prefix: 'material',
|
|
19
17
|
class: 'checkbox',
|
|
20
18
|
type: 'control',
|
|
@@ -33,26 +31,8 @@ let defaults = {
|
|
|
33
31
|
['element.input.keydown', 'keydown', {}]
|
|
34
32
|
]
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
* Checkbox control class
|
|
38
|
-
* @class
|
|
39
|
-
* @extends Control
|
|
40
|
-
* @since 0.0.1
|
|
41
|
-
* @example
|
|
42
|
-
* var chkbox = checkbox({
|
|
43
|
-
* label: 'Primary raised button',
|
|
44
|
-
* type: 'raised',
|
|
45
|
-
* primary: true
|
|
46
|
-
* }).on('click', function(e) {
|
|
47
|
-
* console.log('button click', e);
|
|
48
|
-
* }).insert(document.body);
|
|
49
|
-
*/
|
|
34
|
+
|
|
50
35
|
class Checkbox {
|
|
51
|
-
/**
|
|
52
|
-
* Constructor
|
|
53
|
-
* @param {Object} options - Component options
|
|
54
|
-
* @return {Object} Class instance
|
|
55
|
-
*/
|
|
56
36
|
constructor (options) {
|
|
57
37
|
this.init(options)
|
|
58
38
|
this.build()
|
|
@@ -61,11 +41,6 @@ class Checkbox {
|
|
|
61
41
|
return this
|
|
62
42
|
}
|
|
63
43
|
|
|
64
|
-
/**
|
|
65
|
-
* Constructor
|
|
66
|
-
* @param {Object} options The class options
|
|
67
|
-
* @return {Object} This class instance
|
|
68
|
-
*/
|
|
69
44
|
init (options) {
|
|
70
45
|
this.options = Object.assign({}, defaults, options || {})
|
|
71
46
|
Object.assign(this, events, control, emitter, attach)
|
|
@@ -73,17 +48,13 @@ class Checkbox {
|
|
|
73
48
|
return this
|
|
74
49
|
}
|
|
75
50
|
|
|
76
|
-
/**
|
|
77
|
-
* build the component using the super method
|
|
78
|
-
* @return {Object} The class instance
|
|
79
|
-
*/
|
|
80
51
|
build () {
|
|
81
52
|
this.element = build(this.options.build)
|
|
82
53
|
this.element = this.element.root
|
|
83
54
|
|
|
84
55
|
this.element.control.innerHTML = icon
|
|
85
56
|
|
|
86
|
-
|
|
57
|
+
const text = this.options.text || this.options.label
|
|
87
58
|
|
|
88
59
|
this.element.label = label(this.element, text, this.options)
|
|
89
60
|
|
|
@@ -117,12 +88,6 @@ class Checkbox {
|
|
|
117
88
|
return this
|
|
118
89
|
}
|
|
119
90
|
|
|
120
|
-
/**
|
|
121
|
-
* Setter
|
|
122
|
-
* @param {string} prop
|
|
123
|
-
* @param {string} value
|
|
124
|
-
* @return {Object} The class instance
|
|
125
|
-
*/
|
|
126
91
|
set (prop, value) {
|
|
127
92
|
switch (prop) {
|
|
128
93
|
case 'checked':
|
|
@@ -141,23 +106,12 @@ class Checkbox {
|
|
|
141
106
|
return this
|
|
142
107
|
}
|
|
143
108
|
|
|
144
|
-
/**
|
|
145
|
-
* [insert description]
|
|
146
|
-
* @param {?} container [description]
|
|
147
|
-
* @param {?} context [description]
|
|
148
|
-
* @return {?} [description]
|
|
149
|
-
*/
|
|
150
109
|
insert (container, context) {
|
|
151
110
|
insert(this.element, container, context)
|
|
152
111
|
|
|
153
112
|
return this
|
|
154
113
|
}
|
|
155
114
|
|
|
156
|
-
/**
|
|
157
|
-
* [click description]
|
|
158
|
-
* @param {event} e [description]
|
|
159
|
-
* @return {?} [description]
|
|
160
|
-
*/
|
|
161
115
|
click (e) {
|
|
162
116
|
this.toggle(e)
|
|
163
117
|
this.element.input.focus()
|
|
@@ -165,12 +119,8 @@ class Checkbox {
|
|
|
165
119
|
return this
|
|
166
120
|
}
|
|
167
121
|
|
|
168
|
-
/**
|
|
169
|
-
* Set checkbox value
|
|
170
|
-
* @param {boolean} value [description]
|
|
171
|
-
*/
|
|
172
122
|
setValue (value) {
|
|
173
|
-
console.log('setValue', value)
|
|
123
|
+
// console.log('setValue', value)
|
|
174
124
|
this.value = value
|
|
175
125
|
this.element.input.setAttribute('value', value)
|
|
176
126
|
|
package/src/component.js
CHANGED
package/src/container.js
CHANGED
package/src/datehour.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import build from './module/build'
|
|
2
|
+
|
|
3
|
+
class DateHour {
|
|
4
|
+
static defaults = {
|
|
5
|
+
class: 'date',
|
|
6
|
+
tag: 'span'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
constructor (options) {
|
|
10
|
+
this.init(options)
|
|
11
|
+
this.build()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
init (options) {
|
|
15
|
+
this.options = Object.assign({}, DateHour.defaults, options || {})
|
|
16
|
+
Object.assign(this, build)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
set (date) {
|
|
20
|
+
// console.log('set', src)
|
|
21
|
+
const d = new Date(date)
|
|
22
|
+
const formatted = this.format(d)
|
|
23
|
+
this.element.innerHTML = formatted
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
format (date) {
|
|
27
|
+
let hours = date.getHours()
|
|
28
|
+
let minutes = date.getMinutes()
|
|
29
|
+
const ampm = hours >= 12 ? 'pm' : 'am'
|
|
30
|
+
hours = hours % 12
|
|
31
|
+
hours = hours || 12 // the hour '0' should be '12'
|
|
32
|
+
minutes = minutes < 10 ? '0' + minutes : minutes
|
|
33
|
+
const strTime = hours + ':' + minutes + ' ' + ampm
|
|
34
|
+
return date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear() + ' ' + strTime
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default DateHour
|
package/src/dialog.js
CHANGED
|
@@ -1,213 +1,166 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// dialog related modules
|
|
4
|
-
import events from './mixin/events'
|
|
5
2
|
import emitter from './module/emitter'
|
|
6
|
-
import controller from './mixin/controller'
|
|
7
3
|
import attach from './module/attach'
|
|
8
|
-
import
|
|
9
|
-
import event from './element/event.js'
|
|
10
|
-
import css from './module/css'
|
|
4
|
+
import display from './mixin/display'
|
|
11
5
|
|
|
6
|
+
import Element from './element'
|
|
12
7
|
import Text from './text'
|
|
13
8
|
import Button from './button'
|
|
14
|
-
import Toolbar from './toolbar'
|
|
15
9
|
import Layout from './layout'
|
|
16
10
|
|
|
17
|
-
let defaults = {
|
|
18
|
-
prefix: 'material',
|
|
19
|
-
class: 'dialog',
|
|
20
|
-
tag: 'div',
|
|
21
|
-
events: [
|
|
22
|
-
['root.click', 'close']
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
11
|
class Dialog {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
static defaults = {
|
|
13
|
+
class: 'dialog',
|
|
14
|
+
close: true,
|
|
15
|
+
layout: [
|
|
16
|
+
[Element, 'head', { class: 'head' },
|
|
17
|
+
[Text, 'title', { class: 'title' }],
|
|
18
|
+
[Button, 'close', { class: 'close' }]
|
|
19
|
+
],
|
|
20
|
+
[Element, 'body', { class: 'body' },
|
|
21
|
+
[Text, 'content', { class: 'content' }]
|
|
22
|
+
],
|
|
23
|
+
[Element, 'foot', { class: 'foot' },
|
|
24
|
+
[Element, { class: 'divider' }],
|
|
25
|
+
[Button, 'ok', { class: 'ok', text: 'Ok', color: 'primary' }]
|
|
26
|
+
]
|
|
27
|
+
],
|
|
28
|
+
events: [
|
|
29
|
+
['element.click', 'onClickRoot'],
|
|
30
|
+
['surface.click', 'onClick'],
|
|
31
|
+
['ui.ok.click', 'ok'],
|
|
32
|
+
['ui.cancel.click', 'cancel'],
|
|
33
|
+
['ui.close.click', 'close']
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
constructor (options) {
|
|
33
38
|
this.init(options)
|
|
34
39
|
this.build()
|
|
40
|
+
this.render()
|
|
35
41
|
this.attach()
|
|
36
42
|
|
|
37
|
-
this.element.style.display = 'none'
|
|
38
|
-
|
|
39
43
|
return this
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
/**
|
|
43
|
-
* Constructor
|
|
44
|
-
* @param {Object} options The class options
|
|
45
|
-
* @return {Object} This class instance
|
|
46
|
-
*/
|
|
47
46
|
init (options) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// implement modules
|
|
52
|
-
Object.assign(this, events, emitter, attach, insert)
|
|
53
|
-
|
|
54
|
-
this.layout = null
|
|
55
|
-
this.content = null
|
|
56
|
-
this.html = null
|
|
57
|
-
|
|
58
|
-
this.controller = controller
|
|
59
|
-
|
|
60
|
-
return this
|
|
47
|
+
this.options = Object.assign({}, Dialog.defaults, options || {})
|
|
48
|
+
Object.assign(this, emitter, attach, display)
|
|
61
49
|
}
|
|
62
50
|
|
|
63
|
-
/**
|
|
64
|
-
* build the component using the super method
|
|
65
|
-
* @return {Object} The class instance
|
|
66
|
-
*/
|
|
67
51
|
build () {
|
|
68
52
|
this.element = document.createElement('div')
|
|
53
|
+
this.element.classList.add('dialog')
|
|
69
54
|
|
|
70
|
-
|
|
55
|
+
this.element = this.element
|
|
71
56
|
|
|
72
|
-
if (this.options.
|
|
73
|
-
|
|
57
|
+
if (this.options.class !== 'dialog') {
|
|
58
|
+
this.element.classList.add(this.options.class)
|
|
74
59
|
}
|
|
75
60
|
|
|
76
|
-
if (this.options.
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (this.options.theme) {
|
|
81
|
-
css.add(this.element, this.options.theme + '-theme')
|
|
61
|
+
if (this.options.position) {
|
|
62
|
+
this.element.classList.add('position-' + this.options.position)
|
|
82
63
|
}
|
|
83
64
|
|
|
84
65
|
this.surface = document.createElement('div')
|
|
66
|
+
this.surface.classList.add('surface')
|
|
67
|
+
this.element.appendChild(this.surface)
|
|
85
68
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.insertElement(this.surface, this.element)
|
|
69
|
+
this.layout = new Layout(this.options.layout, this.surface)
|
|
70
|
+
this.ui = this.layout.component
|
|
89
71
|
|
|
90
|
-
if (this.options.
|
|
91
|
-
this.
|
|
72
|
+
if (this.options.container) {
|
|
73
|
+
this.options.container.appendChild(this.element)
|
|
92
74
|
}
|
|
93
75
|
|
|
94
|
-
if (this.options.
|
|
95
|
-
this.
|
|
76
|
+
if (this.options.display === 'show') {
|
|
77
|
+
this.show()
|
|
96
78
|
}
|
|
79
|
+
}
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
render () {
|
|
82
|
+
if (this.options.title && this.ui.title) {
|
|
83
|
+
this.ui.title.set(this.options.title)
|
|
100
84
|
}
|
|
101
85
|
|
|
102
|
-
if (this.options.
|
|
103
|
-
this.
|
|
86
|
+
if (this.options.content && this.ui.content) {
|
|
87
|
+
this.ui.content.set(this.options.content)
|
|
104
88
|
}
|
|
105
89
|
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
ev.stopPropagation()
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
buildTitle () {
|
|
114
|
-
this.title = new Text({
|
|
115
|
-
type: 'title',
|
|
116
|
-
css: 'dialog-title',
|
|
117
|
-
text: this.options.title
|
|
118
|
-
})
|
|
90
|
+
if (this.options.cancel && this.ui.cancel) {
|
|
91
|
+
this.ui.cancel.set('text', this.options.cancel)
|
|
92
|
+
}
|
|
119
93
|
|
|
120
|
-
|
|
94
|
+
if (this.options.ok && this.ui.ok) {
|
|
95
|
+
this.ui.ok.set('text', this.options.ok)
|
|
96
|
+
}
|
|
121
97
|
|
|
122
|
-
|
|
98
|
+
if (this.options.target) {
|
|
99
|
+
this.setPosition()
|
|
100
|
+
}
|
|
123
101
|
}
|
|
124
102
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
103
|
+
setPosition () {
|
|
104
|
+
const coord = this.options.target.getBoundingClientRect()
|
|
105
|
+
const surface_coord = this.surface.getBoundingClientRect()
|
|
129
106
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
107
|
+
if (this.options.position === 'right') {
|
|
108
|
+
this.surface.style.top = coord.top + 'px'
|
|
109
|
+
this.surface.style.left = coord.left + coord.width // surface_coord.width + 'px'
|
|
110
|
+
} else {
|
|
111
|
+
this.surface.style.top = coord.top + 'px'
|
|
112
|
+
this.surface.style.left = coord.left - surface_coord.width + 'px'
|
|
113
|
+
}
|
|
134
114
|
}
|
|
135
115
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
text: this.options.content
|
|
142
|
-
})
|
|
143
|
-
this.insertElement(this.content.root, this.surface)
|
|
116
|
+
ok () {
|
|
117
|
+
this.emit('ok')
|
|
118
|
+
if (this.options.close) {
|
|
119
|
+
this.destroy()
|
|
120
|
+
}
|
|
144
121
|
}
|
|
145
122
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.actions = new Layout(this.options.actions, this.surface)
|
|
123
|
+
cancel () {
|
|
124
|
+
this.emit('cancel')
|
|
149
125
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var actions
|
|
153
|
-
if (this.options.accept || this.options.cancel) {
|
|
154
|
-
actions = new Toolbar({ css: 'dialog-actions' })
|
|
155
|
-
this.insertElement(actions.root, this.surface)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (this.options.cancel) {
|
|
159
|
-
this.cancel = new Button(this.options.cancel)
|
|
160
|
-
.on('click', () => {
|
|
161
|
-
this.emit('canceled')
|
|
162
|
-
this.close()
|
|
163
|
-
})
|
|
164
|
-
this.insertElement(this.cancel.root, actions.root)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (this.options.accept) {
|
|
168
|
-
this.accept = new Button(this.options.accept)
|
|
169
|
-
.on('click', () => {
|
|
170
|
-
this.emit('accepted')
|
|
171
|
-
this.close()
|
|
172
|
-
})
|
|
173
|
-
this.insertElement(this.accept.root, actions.root)
|
|
174
|
-
}
|
|
126
|
+
if (this.options.close) {
|
|
127
|
+
this.destroy()
|
|
175
128
|
}
|
|
176
129
|
}
|
|
177
130
|
|
|
178
131
|
close () {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
var delayMillis = 200 // 1 second
|
|
182
|
-
setTimeout(() => {
|
|
183
|
-
this.element.style.display = 'none'
|
|
184
|
-
css.remove(this.element, 'dialog-closing')
|
|
185
|
-
css.remove(this.element, 'dialog-show')
|
|
186
|
-
}, delayMillis)
|
|
132
|
+
// this.hide()
|
|
187
133
|
|
|
188
|
-
this.
|
|
189
|
-
|
|
190
|
-
|
|
134
|
+
if (this.options.close) {
|
|
135
|
+
this.destroy()
|
|
136
|
+
}
|
|
191
137
|
}
|
|
192
138
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
this.element.style.display = 'flex'
|
|
197
|
-
// css.add(this.element, 'dialog-showing');
|
|
198
|
-
|
|
199
|
-
var delayMillis = 100 // 1 second
|
|
200
|
-
|
|
201
|
-
setTimeout(() => {
|
|
202
|
-
css.add(this.element, 'dialog-show')
|
|
203
|
-
// css.remove(this.element, 'dialog-showing');
|
|
204
|
-
}, delayMillis)
|
|
139
|
+
onClick (e) {
|
|
140
|
+
e.stopPropagation()
|
|
141
|
+
}
|
|
205
142
|
|
|
206
|
-
|
|
143
|
+
onClickRoot (e) {
|
|
144
|
+
// console.log('onClickRoot')
|
|
145
|
+
e.stopPropagation()
|
|
146
|
+
if (!this.options.modal) {
|
|
147
|
+
this.destroy()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
207
150
|
|
|
208
|
-
|
|
151
|
+
emphase () {
|
|
152
|
+
this.element.classList.add('emphase')
|
|
153
|
+
let it
|
|
154
|
+
it = setTimeout(() => {
|
|
155
|
+
clearTimeout(it)
|
|
156
|
+
this.element.classList.remove('emphase')
|
|
157
|
+
}, 100)
|
|
158
|
+
}
|
|
209
159
|
|
|
210
|
-
|
|
160
|
+
set (prop, value) {
|
|
161
|
+
if (this.ui[prop]) {
|
|
162
|
+
this.ui[prop].set(value)
|
|
163
|
+
}
|
|
211
164
|
}
|
|
212
165
|
}
|
|
213
166
|
|
package/src/divider.js
CHANGED
package/src/drawer.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
import init from './mixin/init'
|
|
4
2
|
import insert from './element/insert'
|
|
5
3
|
import classify from './module/classify'
|
|
6
|
-
import css from './module/css'
|
|
4
|
+
import * as css from './module/css'
|
|
7
5
|
import events from './mixin/events'
|
|
8
6
|
import create from './element/create'
|
|
9
7
|
import emitter from './module/emitter'
|
|
@@ -19,21 +17,7 @@ const defaults = {
|
|
|
19
17
|
modules: [emitter, events]
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
/**
|
|
23
|
-
* Class representing a UI Container. Can add components.
|
|
24
|
-
*
|
|
25
|
-
* @extends Component
|
|
26
|
-
* @return {parent} The class instance
|
|
27
|
-
* @example new Container({
|
|
28
|
-
* container: document.body
|
|
29
|
-
* });
|
|
30
|
-
*/
|
|
31
20
|
class Drawer {
|
|
32
|
-
/**
|
|
33
|
-
* Constructor
|
|
34
|
-
* @param {Object} options - Component options
|
|
35
|
-
* @return {Object} Class instance
|
|
36
|
-
*/
|
|
37
21
|
constructor (options) {
|
|
38
22
|
this.options = Object.assign({}, defaults, options || {})
|
|
39
23
|
|
|
@@ -43,8 +27,6 @@ class Drawer {
|
|
|
43
27
|
this.attach()
|
|
44
28
|
|
|
45
29
|
this.emit('ready')
|
|
46
|
-
|
|
47
|
-
return this
|
|
48
30
|
}
|
|
49
31
|
|
|
50
32
|
/**
|
package/src/element/attribute.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (var key in attribute) {
|
|
5
|
-
if (attribute.hasOwnProperty(key)) {
|
|
1
|
+
const init = (element, attribute) => {
|
|
2
|
+
for (const key in attribute) {
|
|
3
|
+
if (Object.prototype.hasOwnProperty.call(attribute, key)) {
|
|
6
4
|
element.setAttribute(key, attribute[key])
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
|
-
|
|
10
7
|
return element
|
|
11
8
|
}
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
return element.setAttribute(name,
|
|
10
|
+
const set = (element, name, value) => {
|
|
11
|
+
return element.setAttribute(name, `${value}`)
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
const get = (element, name) => {
|
|
18
15
|
return element.getAttribute(name) || null
|
|
19
16
|
}
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
const remove = (element, name) => {
|
|
22
19
|
return element.removeAttribute(name)
|
|
23
20
|
}
|
|
24
21
|
|
package/src/element/build.js
CHANGED
|
@@ -2,13 +2,13 @@ import attribute from './attribute'
|
|
|
2
2
|
import create from './create'
|
|
3
3
|
import insert from './insert'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const isObject = (object) => {
|
|
6
6
|
return object &&
|
|
7
7
|
typeof object === 'object' &&
|
|
8
8
|
Object.getPrototypeOf(object) === Object.getPrototypeOf({})
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const process = (string) => {
|
|
12
12
|
const tags = string.match(/^[\w-]+/)
|
|
13
13
|
const ids = string.match(/#([\w-]+)/)
|
|
14
14
|
const classes = string.match(/\.[\w-]+/g)
|
|
@@ -30,17 +30,16 @@ function process (string) {
|
|
|
30
30
|
return properties
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const build = (schema, container, object = {}, level) => {
|
|
34
34
|
let element
|
|
35
|
-
object = object || {}
|
|
36
35
|
|
|
37
|
-
for (
|
|
36
|
+
for (let i = 0; i < schema.length; i++) {
|
|
38
37
|
if (typeof schema[i] === 'string') {
|
|
39
|
-
|
|
38
|
+
const property = process(schema[i])
|
|
40
39
|
element = create(property.tag, property.class)
|
|
41
40
|
insert(element, container)
|
|
42
41
|
|
|
43
|
-
if (property.name)
|
|
42
|
+
if (property.name) object[property.name] = element
|
|
44
43
|
} else if (isObject(schema[i])) {
|
|
45
44
|
attribute.init(element, schema[i])
|
|
46
45
|
} else if (Array.isArray(schema[i])) {
|
package/src/element/create.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import css from '../module/css'
|
|
1
|
+
import * as css from '../module/css'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var element = document.createElement(tag)
|
|
3
|
+
const create = (tag = 'div', className) => {
|
|
4
|
+
const element = document.createElement(tag)
|
|
7
5
|
css.add(element, className)
|
|
8
|
-
|
|
9
6
|
return element
|
|
10
7
|
}
|
|
11
8
|
|
package/src/element/event.js
CHANGED
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
// avoid memory overhead of new anonymous functions for every event handler that's installed
|
|
13
13
|
// by using local functions
|
|
14
14
|
function listenHandler (e) {
|
|
15
|
-
|
|
15
|
+
const ret = fn.apply(this, arguments)
|
|
16
16
|
if (ret === false) {
|
|
17
17
|
e.stopPropagation()
|
|
18
18
|
e.preventDefault()
|
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
function attachHandler () {
|
|
24
24
|
// set the this pointer same as addEventListener when fn is called
|
|
25
25
|
// and make sure the event is passed to the fn also so that works the same too
|
|
26
|
-
|
|
26
|
+
const ret = fn.call(element, window.event)
|
|
27
27
|
if (ret === false) {
|
|
28
28
|
window.event.returnValue = false
|
|
29
29
|
window.event.cancelBubble = true
|