material 0.7.0 → 0.7.1
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/form.js +27 -0
- package/index.js +59 -58
- package/list.js +35 -0
- package/package.json +5 -1
- package/src/appbar.js +7 -204
- package/src/badge.js +27 -0
- package/src/button.js +155 -155
- package/src/calendar.js +0 -2
- package/src/card.js +0 -2
- package/src/checkbox.js +0 -2
- package/src/component.js +0 -2
- package/src/container.js +0 -2
- package/src/datehour.js +38 -0
- package/src/dialog.js +105 -152
- package/src/divider.js +0 -2
- package/src/drawer.js +0 -2
- package/src/{control/file.js → file.js} +15 -45
- package/src/form/verify.js +2 -2
- package/src/form.js +0 -2
- package/src/icon.js +0 -2
- package/src/image.js +39 -106
- package/src/item.js +0 -2
- package/src/{control/link.js → link.js} +13 -32
- package/src/list/build.js +2 -2
- package/src/list/collection.js +1 -1
- package/src/list/filter.js +2 -2
- package/src/list/request.js +1 -1
- package/src/list/search.js +5 -5
- package/src/list.js +29 -217
- package/src/loading.js +73 -0
- package/src/menu.js +60 -116
- package/src/mixin/display.js +0 -1
- package/src/mixin/insert.js +2 -24
- package/src/{control/module → module}/attributes.js +2 -2
- package/src/module/build.js +8 -5
- package/src/navigation.js +19 -0
- package/src/progress.js +0 -2
- package/src/search.js +71 -0
- package/src/select.js +57 -272
- package/src/{control/selecter.js → selecter.js} +5 -5
- package/src/skin/material/component/navigation.sass +1 -0
- package/src/skin/material/control/button.sass +10 -0
- package/src/slider.js +0 -2
- package/src/snackbar.js +72 -51
- package/src/switch.js +111 -103
- package/src/{control/switcher.js → switcher.js} +17 -20
- package/src/text.js +25 -74
- package/src/textfield.js +96 -233
- 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/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/tabs/setup.js +0 -0
- /package/src/{control/module → module}/addclass.js +0 -0
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 './view/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
|
-
|
|
44
|
-
|
|
45
|
-
* @return {Object} This class instance
|
|
46
|
-
*/
|
|
47
|
-
init (options) {
|
|
48
|
-
// init options
|
|
49
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
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
|
|
46
|
+
init(options) {
|
|
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
|
+
var coord = this.options.target.getBoundingClientRect()
|
|
105
|
+
var 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
|
+
var 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,56 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import dataset from '../view/dataset'
|
|
3
|
-
import attributes from './module/attributes'
|
|
1
|
+
import EventEmitter from './mixin/emitter'
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
3
|
+
import build from './module/build'
|
|
4
|
+
import dataset from './module/dataset'
|
|
5
|
+
import attributes from './module/attributes'
|
|
9
6
|
|
|
10
7
|
class File {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @return {Object} Class instance
|
|
15
|
-
*/
|
|
16
|
-
constructor (options) {
|
|
17
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
18
|
-
Object.assign(this, emitter)
|
|
19
|
-
|
|
20
|
-
this.build()
|
|
21
|
-
this.attach()
|
|
22
|
-
|
|
23
|
-
return this
|
|
8
|
+
static defaults = {
|
|
9
|
+
class: 'file',
|
|
10
|
+
attributes: ['name', 'accept', 'required', 'disabled', 'multiple']
|
|
24
11
|
}
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
build () {
|
|
31
|
-
this.element = document.createElement('div')
|
|
32
|
-
this.element.classList.add('file')
|
|
33
|
-
|
|
34
|
-
if (this.options.class !== 'file') {
|
|
35
|
-
this.element.classList.add(this.options.class)
|
|
36
|
-
}
|
|
37
|
-
|
|
13
|
+
constructor (options) {
|
|
14
|
+
this.init(options)
|
|
15
|
+
this.build()
|
|
38
16
|
this.buildLabel()
|
|
39
17
|
this.buildInput()
|
|
18
|
+
this.attach()
|
|
19
|
+
}
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (this.options.focus) {
|
|
46
|
-
this.input.focus()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (this.options.container) {
|
|
50
|
-
this.options.container.appendChild(this.element)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return this
|
|
21
|
+
init (options) {
|
|
22
|
+
this.options = Object.assign({}, File.defaults, options || {})
|
|
23
|
+
Object.assign(this, build)
|
|
54
24
|
}
|
|
55
25
|
|
|
56
26
|
buildLabel () {
|
package/src/form/verify.js
CHANGED
|
@@ -8,10 +8,10 @@ export default {
|
|
|
8
8
|
var field = this.ui['info.' + list[i]]
|
|
9
9
|
|
|
10
10
|
if (!this.layout.get(list[i]).get()) {
|
|
11
|
-
field.
|
|
11
|
+
field.element.classList.add('textfield-error')
|
|
12
12
|
ok = false
|
|
13
13
|
} else {
|
|
14
|
-
field.
|
|
14
|
+
field.element.classList.remove('textfield-error')
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
package/src/form.js
CHANGED
package/src/icon.js
CHANGED
package/src/image.js
CHANGED
|
@@ -1,124 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
import build from './module/build'
|
|
2
2
|
|
|
3
|
-
// import insert from './mixin/insert'
|
|
4
|
-
import css from './module/css'
|
|
5
|
-
import insert from './element/insert'
|
|
6
|
-
import control from './mixin/control'
|
|
7
|
-
|
|
8
|
-
var defaults = {
|
|
9
|
-
prefix: 'material',
|
|
10
|
-
class: 'image',
|
|
11
|
-
tag: 'div'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The item class is used for example as item list
|
|
16
|
-
*
|
|
17
|
-
* @class
|
|
18
|
-
* @extends {Component}
|
|
19
|
-
* @return {Object} The class instance
|
|
20
|
-
* @example new Item(object);
|
|
21
|
-
*/
|
|
22
3
|
class Image {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
4
|
+
static defaults = {
|
|
5
|
+
class: 'image',
|
|
6
|
+
tag: 'div',
|
|
7
|
+
format: 'thumb'
|
|
8
|
+
}
|
|
9
|
+
|
|
27
10
|
constructor (options) {
|
|
28
11
|
this.init(options)
|
|
29
12
|
this.build()
|
|
30
|
-
|
|
31
|
-
return this
|
|
32
13
|
}
|
|
33
14
|
|
|
34
|
-
/**
|
|
35
|
-
* [init description]
|
|
36
|
-
* @param {?} options [description]
|
|
37
|
-
* @return {?} [description]
|
|
38
|
-
*/
|
|
39
15
|
init (options) {
|
|
40
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
41
|
-
Object.assign(this,
|
|
16
|
+
this.options = Object.assign({}, Image.defaults, options || {})
|
|
17
|
+
Object.assign(this, build)
|
|
42
18
|
}
|
|
43
19
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.info = document.createElement('span')
|
|
66
|
-
css.add(this.info, this.options.class + '-info')
|
|
67
|
-
|
|
68
|
-
insert(this.info, this.element)
|
|
69
|
-
|
|
70
|
-
this.label(text, this.info)
|
|
71
|
-
|
|
72
|
-
// this.label = this.element.label
|
|
73
|
-
|
|
74
|
-
this.icon(this.options.icon, this.info, 'bottom')
|
|
75
|
-
|
|
76
|
-
// if (text) {
|
|
77
|
-
// this.label = document.createElement('span')
|
|
78
|
-
// this.label.innerText = text
|
|
79
|
-
// css.add(this.label, this.options.class + '-label')
|
|
80
|
-
// insert(this.label, this.element)
|
|
81
|
-
// }
|
|
82
|
-
|
|
83
|
-
css.add(this.element, this.options.prefix + '-' + this.options.class)
|
|
84
|
-
|
|
85
|
-
if (options.css) { css.add(this.element, options.css) }
|
|
86
|
-
// css.add(this.element, this.options.class + '-adjust');
|
|
87
|
-
|
|
88
|
-
if (this.options.container) {
|
|
89
|
-
this.insert(this.options.container)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* [insert description]
|
|
95
|
-
* @param {?} container [description]
|
|
96
|
-
* @param {?} context [description]
|
|
97
|
-
* @return {?} [description]
|
|
98
|
-
*/
|
|
99
|
-
insert (container, context) {
|
|
100
|
-
insert(this.element, container, context)
|
|
101
|
-
|
|
102
|
-
return this
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Get or set text value of the element
|
|
107
|
-
* @param {string} value The text to set
|
|
108
|
-
* @returns {*}
|
|
109
|
-
*/
|
|
110
|
-
set (value) {
|
|
111
|
-
if (value) {
|
|
112
|
-
if (this.element.innerText) {
|
|
113
|
-
this.element.innerText = value
|
|
20
|
+
set (src) {
|
|
21
|
+
// console.log('set', src)
|
|
22
|
+
if (!src) {
|
|
23
|
+
this.element.style.backgroundImage = ''
|
|
24
|
+
} else {
|
|
25
|
+
var url = null
|
|
26
|
+
|
|
27
|
+
if (src.format) {
|
|
28
|
+
var format = this.sanitize(src.format)
|
|
29
|
+
|
|
30
|
+
if (format.length > 0) {
|
|
31
|
+
var index = format.indexOf(this.options.format)
|
|
32
|
+
if (index === -1) {
|
|
33
|
+
format = src.format[0] + '/'
|
|
34
|
+
} else {
|
|
35
|
+
format = this.options.format + '/'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
url = src.url + format
|
|
114
40
|
} else {
|
|
115
|
-
|
|
41
|
+
url = src.url
|
|
116
42
|
}
|
|
117
43
|
|
|
118
|
-
|
|
44
|
+
this.element.style.backgroundImage = 'url(' + url + src.filename + ')'
|
|
119
45
|
}
|
|
46
|
+
}
|
|
120
47
|
|
|
121
|
-
|
|
48
|
+
sanitize (formats) {
|
|
49
|
+
var a = []
|
|
50
|
+
for (var i = 0; i < formats.length; i++) {
|
|
51
|
+
var format = formats[i].replace(/\/$/, '')
|
|
52
|
+
a.push(format)
|
|
53
|
+
}
|
|
54
|
+
return a
|
|
122
55
|
}
|
|
123
56
|
}
|
|
124
57
|
|
package/src/item.js
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const defaults = {
|
|
4
|
-
class: 'link',
|
|
5
|
-
tag: 'a'
|
|
6
|
-
}
|
|
1
|
+
import build from './module/build'
|
|
7
2
|
|
|
8
3
|
class Link {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
constructor (options) {
|
|
15
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
4
|
+
static defaults = {
|
|
5
|
+
class: 'link',
|
|
6
|
+
tag: 'a'
|
|
7
|
+
}
|
|
16
8
|
|
|
9
|
+
constructor (options) {
|
|
10
|
+
this.init(options)
|
|
17
11
|
this.build()
|
|
18
|
-
|
|
19
|
-
return this
|
|
12
|
+
this.setup()
|
|
20
13
|
}
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
build () {
|
|
27
|
-
this.element = document.createElement(this.options.tag)
|
|
28
|
-
this.element.classList.add(this.options.class)
|
|
29
|
-
|
|
30
|
-
if (this.options.class !== 'link') {
|
|
31
|
-
this.element.classList.add('link')
|
|
32
|
-
}
|
|
15
|
+
init (options) {
|
|
16
|
+
this.options = Object.assign({}, Link.defaults, options || {})
|
|
17
|
+
Object.assign(this, build)
|
|
18
|
+
}
|
|
33
19
|
|
|
20
|
+
setup () {
|
|
34
21
|
if (this.options.link) {
|
|
35
22
|
this.set(this.options.link)
|
|
36
23
|
}
|
|
@@ -39,15 +26,9 @@ class Link {
|
|
|
39
26
|
this.element.target = this.options.target
|
|
40
27
|
}
|
|
41
28
|
|
|
42
|
-
if (this.options.container) {
|
|
43
|
-
this.options.container.appendChild(this.element)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
29
|
if (this.options.text) {
|
|
47
30
|
this.element.innerHTML = this.options.text
|
|
48
31
|
}
|
|
49
|
-
|
|
50
|
-
return this
|
|
51
32
|
}
|
|
52
33
|
|
|
53
34
|
set (link) {
|
package/src/list/build.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import scrollbar from '../module/scrollbar'
|
|
2
|
-
import dataset from '../
|
|
2
|
+
import dataset from '../module/dataset'
|
|
3
3
|
|
|
4
4
|
import Layout from '../layout'
|
|
5
5
|
import Virtual from './virtual'
|
|
6
|
-
import Loading from '../
|
|
6
|
+
import Loading from '../loading'
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
build (data) {
|