material 0.6.2 → 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 +61 -51
- 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 +160 -161
- package/src/calendar.js +8 -10
- package/src/card.js +4 -6
- package/src/checkbox.js +8 -10
- package/src/component.js +4 -6
- package/src/container.js +4 -6
- package/src/datehour.js +38 -0
- package/src/dialog.js +106 -153
- package/src/divider.js +4 -6
- package/src/drawer.js +11 -13
- package/src/field/email.js +5 -5
- package/src/field/image.js +4 -4
- package/src/{control/file.js → file.js} +18 -48
- package/src/form/build.js +7 -7
- package/src/form/verify.js +2 -2
- package/src/form.js +6 -8
- package/src/icon.js +8 -10
- package/src/image.js +39 -106
- package/src/item.js +7 -9
- package/src/layout.js +10 -10
- package/src/link.js +50 -0
- package/src/list/add.js +1 -1
- package/src/list/build.js +9 -9
- package/src/list/collection.js +1 -1
- package/src/list/display.js +10 -10
- package/src/list/filter.js +2 -2
- package/src/list/request.js +1 -1
- package/src/list/search.js +7 -7
- package/src/list.js +29 -217
- package/src/loading.js +73 -0
- package/src/map/build.js +6 -6
- package/src/map/display.js +8 -8
- package/src/menu.js +60 -116
- package/src/{component → mixin}/control.js +10 -10
- package/src/{component → mixin}/create.js +1 -1
- package/src/{module → mixin}/display.js +9 -22
- package/src/{component → mixin}/events.js +2 -2
- package/src/{component → mixin}/focus.js +2 -3
- package/src/{component → mixin}/insert.js +3 -25
- package/src/{control/module → module}/attributes.js +2 -2
- package/src/module/build.js +11 -7
- package/src/{component → module}/classify.js +0 -13
- package/src/module/dom.js +1 -57
- package/src/module/events.js +4 -2
- package/src/{component → module}/ripple.js +15 -42
- package/src/navigation.js +19 -0
- package/src/progress.js +7 -9
- package/src/search.js +71 -0
- package/src/select.js +58 -273
- package/src/{control/selecter.js → selecter.js} +20 -20
- package/src/selector.js +32 -32
- package/src/skin/material/component/navigation.sass +1 -0
- package/src/skin/material/control/button.sass +10 -0
- package/src/slider.js +32 -34
- package/src/snackbar.js +72 -51
- package/src/switch.js +115 -107
- package/src/{control/switcher.js → switcher.js} +33 -36
- package/src/tabs.js +8 -8
- package/src/tabview.js +8 -8
- package/src/text.js +25 -74
- package/src/textfield.js +97 -234
- package/src/toolbar.js +28 -28
- package/src/tooltip.js +11 -11
- package/src/tree.js +12 -16
- package/src/view/build.js +6 -6
- package/src/view/display.js +16 -16
- package/src/view.js +5 -5
- package/src/banner.js +0 -231
- package/src/component/click.js +0 -17
- package/src/control/button.js +0 -267
- 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/link.js +0 -69
- 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 -89
- package/src/control/switch.js +0 -272
- package/src/control/text.js +0 -70
- package/src/control/textfield.js +0 -177
- /package/src/{component → mixin}/controller.js +0 -0
- /package/src/{component → mixin}/emitter.js +0 -0
- /package/src/{component → mixin}/icon.js +0 -0
- /package/src/{component → mixin}/init.js +0 -0
- /package/src/{component → mixin}/label.js +0 -0
- /package/src/{component → mixin}/settings.js +0 -0
- /package/src/{control/module → module}/addclass.js +0 -0
- /package/src/{tabs/setup.js → module/last.js} +0 -0
package/src/textfield.js
CHANGED
|
@@ -1,307 +1,170 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
import emitter from './module/emitter'
|
|
4
2
|
import attach from './module/attach'
|
|
3
|
+
import dataset from './module/dataset'
|
|
4
|
+
import attributes from './module/attributes'
|
|
5
5
|
|
|
6
|
-
var defaults = {
|
|
7
|
-
prefix: 'material',
|
|
8
|
-
class: 'textfield',
|
|
9
|
-
type: 'control',
|
|
10
|
-
tag: 'div',
|
|
11
|
-
events: [
|
|
12
|
-
// 'change': '_onChange',
|
|
13
|
-
['input.focus', 'focus'],
|
|
14
|
-
['input.blur', 'blur'],
|
|
15
|
-
// ['input.keypress', '_handleInputKeyPress',
|
|
16
|
-
['input.keyup', '_handleInputKeyPress']
|
|
17
|
-
// ['input.change', '_onChange']
|
|
18
|
-
// 'input.keydown': '_handleInputKeyPress'
|
|
19
|
-
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Textfield class
|
|
25
|
-
* @class
|
|
26
|
-
*/
|
|
27
6
|
class Textfield {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* @return {Object} Class instance
|
|
32
|
-
*/
|
|
33
|
-
constructor (options) {
|
|
34
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
7
|
+
static isComponent () {
|
|
8
|
+
return true
|
|
9
|
+
}
|
|
35
10
|
|
|
36
|
-
|
|
11
|
+
static defaults = {
|
|
12
|
+
class: 'textfield',
|
|
13
|
+
attributes: ['type', 'name', 'title', 'maxlength', 'pattern', 'min', 'max', 'placeholder', 'readonly', 'autocomplete', 'required', 'disabled'],
|
|
14
|
+
events: [
|
|
15
|
+
['input.input', 'onInput'],
|
|
16
|
+
['input.focus', 'onFocus'],
|
|
17
|
+
['input.blur', 'onBlur'],
|
|
18
|
+
['input.click', 'onClick']
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
constructor (options) {
|
|
23
|
+
this.init(options)
|
|
37
24
|
this.build()
|
|
38
25
|
this.attach()
|
|
39
|
-
|
|
40
|
-
return this
|
|
41
26
|
}
|
|
42
27
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*/
|
|
48
|
-
init () {
|
|
49
|
-
Object.assign(this, emitter, attach)
|
|
50
|
-
|
|
51
|
-
this.value = this.options.value
|
|
52
|
-
this.readonly = this.options.readonly
|
|
53
|
-
this.disabled = this.options.disabled
|
|
54
|
-
|
|
55
|
-
return this
|
|
28
|
+
init (options) {
|
|
29
|
+
this.options = Object.assign({}, Textfield.defaults, options || {})
|
|
30
|
+
Object.assign(this, emitter, attach, dataset)
|
|
31
|
+
// console.log('options', options)
|
|
56
32
|
}
|
|
57
33
|
|
|
58
|
-
/**
|
|
59
|
-
* [build description]
|
|
60
|
-
* @return {Object} The class instance
|
|
61
|
-
*/
|
|
62
34
|
build () {
|
|
63
|
-
// create a new div as input element
|
|
64
35
|
var tag = this.options.tag || 'div'
|
|
65
|
-
|
|
66
|
-
this.
|
|
36
|
+
|
|
37
|
+
this.element = document.createElement(tag)
|
|
38
|
+
this.element.classList.add('textfield')
|
|
39
|
+
|
|
40
|
+
if (this.options.class !== 'textfield') {
|
|
41
|
+
this.element.classList.add(this.options.class)
|
|
42
|
+
}
|
|
67
43
|
|
|
68
44
|
this.buildLabel()
|
|
69
45
|
this.buildInput()
|
|
70
|
-
this.buildUnderline()
|
|
71
46
|
|
|
72
|
-
if (this.
|
|
73
|
-
|
|
47
|
+
if (this.options.value) {
|
|
48
|
+
this.set(this.options.value)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (this.options.data) {
|
|
52
|
+
dataset(this.element, this.options.data)
|
|
74
53
|
}
|
|
75
54
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// console.log(this.name, opts.container);
|
|
79
|
-
insert(this.root, this.options.container)
|
|
55
|
+
if (this.container) {
|
|
56
|
+
this.container.appendChild(this.element)
|
|
80
57
|
}
|
|
58
|
+
|
|
59
|
+
return this
|
|
81
60
|
}
|
|
82
61
|
|
|
83
62
|
buildLabel () {
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this.setLabel()
|
|
63
|
+
if (this.options.label) {
|
|
64
|
+
this.label = document.createElement('label')
|
|
65
|
+
this.label.classList.add('label')
|
|
66
|
+
this.label.innerHTML = this.options.label
|
|
67
|
+
this.element.appendChild(this.label)
|
|
90
68
|
}
|
|
91
69
|
}
|
|
92
70
|
|
|
93
|
-
/**
|
|
94
|
-
* [_initInput description]
|
|
95
|
-
* @return {Object} The class instance
|
|
96
|
-
*/
|
|
97
71
|
buildInput () {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.root.appendChild(this.input)
|
|
102
|
-
|
|
103
|
-
if (this.options.name) {
|
|
104
|
-
this.input.setAttribute('name', this.options.name)
|
|
72
|
+
let tag = 'input'
|
|
73
|
+
if (this.options.type === 'multiline') {
|
|
74
|
+
tag = 'textarea'
|
|
105
75
|
}
|
|
106
76
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (this.readonly) {
|
|
112
|
-
this.input.setAttribute('readonly', 'readonly')
|
|
113
|
-
this.input.setAttribute('tabindex', '-1')
|
|
114
|
-
}
|
|
77
|
+
this.input = document.createElement(tag)
|
|
78
|
+
this.input.classList.add('input')
|
|
115
79
|
|
|
116
|
-
|
|
117
|
-
}
|
|
80
|
+
this.element.appendChild(this.input)
|
|
118
81
|
|
|
119
|
-
|
|
120
|
-
* _initUnderline
|
|
121
|
-
* @return {Object} The class instance
|
|
122
|
-
*/
|
|
123
|
-
buildUnderline () {
|
|
124
|
-
this.underline = document.createElement('span')
|
|
125
|
-
this.underline.classList.add(this.options.class + '-underline')
|
|
126
|
-
this.root.appendChild(this.underline)
|
|
127
|
-
}
|
|
82
|
+
attributes(this.input, this.options)
|
|
128
83
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
* @param {string} prop
|
|
132
|
-
* @param {string} value
|
|
133
|
-
*/
|
|
134
|
-
set (prop, value, options) {
|
|
135
|
-
switch (prop) {
|
|
136
|
-
case 'value':
|
|
137
|
-
this.setValue(value, options)
|
|
138
|
-
break
|
|
139
|
-
case 'label':
|
|
140
|
-
this.setLabel(value, options)
|
|
141
|
-
break
|
|
142
|
-
case 'disabled':
|
|
143
|
-
if (value === true) {
|
|
144
|
-
this.disable()
|
|
145
|
-
} else if (value === false) {
|
|
146
|
-
this.enable()
|
|
147
|
-
}
|
|
148
|
-
break
|
|
149
|
-
default:
|
|
150
|
-
this.setValue(prop, value)
|
|
84
|
+
if (this.options.focus) {
|
|
85
|
+
this.input.focus()
|
|
151
86
|
}
|
|
152
|
-
|
|
153
|
-
return this
|
|
154
87
|
}
|
|
155
88
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
* @return {Object} The class instance
|
|
159
|
-
*/
|
|
160
|
-
setLabel (label) {
|
|
161
|
-
label = label || this.options.label
|
|
162
|
-
var text
|
|
163
|
-
|
|
164
|
-
if (label === null || label === false) {
|
|
165
|
-
text = ''
|
|
166
|
-
} else if (this.options.label) {
|
|
167
|
-
text = label
|
|
168
|
-
} else {
|
|
169
|
-
text = this.options.name
|
|
170
|
-
}
|
|
89
|
+
onInput (ev) {
|
|
90
|
+
// console.log('onInput', this.value, this.input.value)
|
|
171
91
|
|
|
172
|
-
this.
|
|
92
|
+
this.emit('change', ev)
|
|
173
93
|
}
|
|
174
94
|
|
|
175
|
-
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
this.input.setAttribute('disabled', 'disabled')
|
|
179
|
-
this.root.classList.add('is-disabled')
|
|
180
|
-
return this
|
|
95
|
+
onFocus (ev) {
|
|
96
|
+
this.element.classList.add('focused')
|
|
97
|
+
this.emit('focus', ev)
|
|
181
98
|
}
|
|
182
99
|
|
|
183
|
-
|
|
184
|
-
this.
|
|
100
|
+
onBlur (ev) {
|
|
101
|
+
this.element.classList.remove('focused')
|
|
102
|
+
this.emit('blur', ev)
|
|
103
|
+
}
|
|
185
104
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
105
|
+
onClick (ev) {
|
|
106
|
+
// console.log('click')
|
|
107
|
+
this.emit('click', ev)
|
|
189
108
|
}
|
|
190
109
|
|
|
191
110
|
/**
|
|
192
|
-
*
|
|
111
|
+
* Setter
|
|
193
112
|
* @param {string} prop
|
|
194
113
|
* @param {string} value
|
|
114
|
+
* @return {Object} The class instance
|
|
195
115
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
116
|
+
set (prop, value) {
|
|
117
|
+
// console.log('set', this.element, prop, value)
|
|
199
118
|
switch (prop) {
|
|
200
119
|
case 'value':
|
|
201
|
-
|
|
120
|
+
this.setValue(value)
|
|
202
121
|
break
|
|
203
|
-
case '
|
|
204
|
-
|
|
122
|
+
case 'label':
|
|
123
|
+
this.setLabel(value)
|
|
205
124
|
break
|
|
206
125
|
default:
|
|
207
|
-
|
|
126
|
+
// console.log('prop', prop)
|
|
127
|
+
this.setValue(prop)
|
|
208
128
|
}
|
|
209
129
|
|
|
210
|
-
return
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* [getValue description]
|
|
215
|
-
* @return {Object} The class instance
|
|
216
|
-
*/
|
|
217
|
-
getValue () {
|
|
218
|
-
// console.log('getValue', this);
|
|
219
|
-
return this.input.value
|
|
130
|
+
return this
|
|
220
131
|
}
|
|
221
132
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// console.log('setValue', value, silent);
|
|
228
|
-
this.input.value = value
|
|
229
|
-
|
|
230
|
-
if (value) {
|
|
231
|
-
this.root.classList.remove('is-empty')
|
|
133
|
+
setValue (value) {
|
|
134
|
+
// console.log('set', typeof value, value)
|
|
135
|
+
if (value && value !== 'undefined') {
|
|
136
|
+
this.value = value
|
|
137
|
+
this.input.value = value
|
|
232
138
|
} else {
|
|
233
|
-
this.
|
|
139
|
+
this.input.value = ''
|
|
234
140
|
}
|
|
235
|
-
|
|
236
|
-
if (!silent) { this.emit('change', value) }
|
|
237
141
|
}
|
|
238
142
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
_initValue () {
|
|
244
|
-
var opts = this.options
|
|
245
|
-
|
|
246
|
-
// create a new div as input element
|
|
247
|
-
if (opts.value) {
|
|
248
|
-
this.setValue(opts.value)
|
|
143
|
+
setLabel (value) {
|
|
144
|
+
// console.log('setLabel', value)
|
|
145
|
+
if (this.label) {
|
|
146
|
+
this.label.innerHTML = value
|
|
249
147
|
}
|
|
250
148
|
}
|
|
251
149
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
* @return {Object} The class instance
|
|
255
|
-
*/
|
|
256
|
-
_handleInputKeyPress (e) {
|
|
257
|
-
// console.log('_handleInputKeyPress', e);
|
|
258
|
-
if (this.readonly) return
|
|
150
|
+
setText (value) {
|
|
151
|
+
this.setLabel(value)
|
|
259
152
|
|
|
260
|
-
if (this.
|
|
261
|
-
this.
|
|
262
|
-
} else {
|
|
263
|
-
this.root.classList.remove('is-empty')
|
|
153
|
+
if (this.options.placeholder) {
|
|
154
|
+
this.input.placeholder = value
|
|
264
155
|
}
|
|
265
|
-
|
|
266
|
-
this.emit('change', this.getValue())
|
|
267
156
|
}
|
|
268
157
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* @return {?} [description]
|
|
272
|
-
*/
|
|
273
|
-
focus () {
|
|
274
|
-
if (this.disabled) return this
|
|
275
|
-
if (this.readonly) return this
|
|
276
|
-
|
|
277
|
-
this.root.classList.add('is-focused')
|
|
278
|
-
if (this.input !== document.activeElement) { this.input.focus() }
|
|
279
|
-
return this
|
|
158
|
+
hide () {
|
|
159
|
+
this.element.classList.add('hide')
|
|
280
160
|
}
|
|
281
161
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
* @return {?} [description]
|
|
285
|
-
*/
|
|
286
|
-
blur () {
|
|
287
|
-
if (this.readonly) return this
|
|
288
|
-
|
|
289
|
-
this.root.classList.remove('is-focused')
|
|
290
|
-
|
|
291
|
-
return this
|
|
162
|
+
show () {
|
|
163
|
+
this.element.classList.remove('hide')
|
|
292
164
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
*/
|
|
297
|
-
setError (error) {
|
|
298
|
-
if (error) {
|
|
299
|
-
this.addClass('field-error')
|
|
300
|
-
if (this.error) { this.error.set('html', error) }
|
|
301
|
-
} else {
|
|
302
|
-
if (this.error) { this.removeClass('field-error') }
|
|
303
|
-
if (this.error) { this.error.set('html', '') }
|
|
304
|
-
}
|
|
165
|
+
|
|
166
|
+
get () {
|
|
167
|
+
return this.input.value
|
|
305
168
|
}
|
|
306
169
|
}
|
|
307
170
|
|
package/src/toolbar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import create from './
|
|
4
|
-
import insert from './
|
|
3
|
+
import create from './mixin/create'
|
|
4
|
+
import insert from './mixin/insert'
|
|
5
5
|
import offset from './element/offset'
|
|
6
6
|
|
|
7
7
|
const defaults = {
|
|
@@ -37,21 +37,21 @@ class Toolbar {
|
|
|
37
37
|
* @return {Object} This class instance
|
|
38
38
|
*/
|
|
39
39
|
build () {
|
|
40
|
-
this.
|
|
40
|
+
this.element = create(this.options)
|
|
41
41
|
|
|
42
42
|
// console.log(this.options.height, this.options.fixed)
|
|
43
43
|
|
|
44
44
|
if (this.options.height) {
|
|
45
|
-
this.
|
|
45
|
+
this.element.style.height = this.options.height + 'px'
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
if (this.options.fixed) {
|
|
49
49
|
// console.log('is-fixed')
|
|
50
|
-
this.
|
|
50
|
+
this.element.classList.add('is-fixed')
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (this.options.flexible) {
|
|
54
|
-
this.
|
|
54
|
+
this.element.classList.add('is-flexible')
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// if (this.options.container) {
|
|
@@ -62,19 +62,19 @@ class Toolbar {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
attach () {
|
|
65
|
-
this.
|
|
65
|
+
this.element.addEventListener('DOMNodeInserted', (e) => {
|
|
66
66
|
var textNode = e.target
|
|
67
|
-
if (textNode !== this.
|
|
67
|
+
if (textNode !== this.element) return
|
|
68
68
|
|
|
69
|
-
var size = this.size = offset(this.
|
|
69
|
+
var size = this.size = offset(this.element, 'height')
|
|
70
70
|
|
|
71
|
-
var view = this.view = this.
|
|
71
|
+
var view = this.view = this.element.parentNode
|
|
72
72
|
|
|
73
73
|
// console.log('view', view)
|
|
74
74
|
|
|
75
75
|
var padding = window.getComputedStyle(view)['padding-top']
|
|
76
76
|
// console.log('paddingTop', padding)
|
|
77
|
-
// if (!padding) padding = window.getComputedStyle(this.
|
|
77
|
+
// if (!padding) padding = window.getComputedStyle(this.element.parentNode, 'padding')
|
|
78
78
|
// console.log('padding', padding)
|
|
79
79
|
|
|
80
80
|
padding = parseInt(padding, 10)
|
|
@@ -89,7 +89,7 @@ class Toolbar {
|
|
|
89
89
|
|
|
90
90
|
if (document.body == view) {
|
|
91
91
|
// console.log('toolbar container body')
|
|
92
|
-
this.
|
|
92
|
+
this.element.classList.add('toolbar-body')
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// view.setAttribute('style', 'padding-top: ' + ptop + 'px')
|
|
@@ -107,7 +107,7 @@ class Toolbar {
|
|
|
107
107
|
set (prop, value) {
|
|
108
108
|
switch (prop) {
|
|
109
109
|
case 'minimize':
|
|
110
|
-
this.
|
|
110
|
+
this.element.setAttribute('style', 'height: 64px')
|
|
111
111
|
break
|
|
112
112
|
case 'value':
|
|
113
113
|
this.setValue(value)
|
|
@@ -150,9 +150,9 @@ class Toolbar {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
if (scrollTop > 0) {
|
|
153
|
-
this.
|
|
153
|
+
this.element.classList.add('is-scrolled')
|
|
154
154
|
} else {
|
|
155
|
-
this.
|
|
155
|
+
this.element.classList.remove('is-scrolled')
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// console.log('scroll', scrollTop)
|
|
@@ -167,42 +167,42 @@ class Toolbar {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
flexible (e, scrollTop) {
|
|
170
|
-
var size = offset(this.
|
|
171
|
-
// console.log('flexible', size, this.
|
|
170
|
+
var size = offset(this.element, 'height')
|
|
171
|
+
// console.log('flexible', size, this.element.offsetHeight, scrollTop)
|
|
172
172
|
// if (scrollTop < this.size) {
|
|
173
173
|
//
|
|
174
174
|
var height = '64'
|
|
175
175
|
if (size < height) {
|
|
176
|
-
this.
|
|
176
|
+
this.element.style.height = height + 'px'
|
|
177
177
|
} else {
|
|
178
178
|
height = this.size - scrollTop
|
|
179
179
|
if (height < 64) height = 64
|
|
180
|
-
this.
|
|
180
|
+
this.element.style.height = height + 'px'
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
// console.log('scroll', this.
|
|
183
|
+
// console.log('scroll', this.element.style.top, scrollTop)
|
|
184
184
|
|
|
185
185
|
// if (scrollTop > 50) {
|
|
186
|
-
// this.
|
|
186
|
+
// this.element.style.trans = scrollTop + 'px'
|
|
187
187
|
// } else {
|
|
188
|
-
// this.
|
|
188
|
+
// this.element.style.top = scrollTop + 'px'
|
|
189
189
|
// }
|
|
190
190
|
// }
|
|
191
|
-
// this.
|
|
192
|
-
// this.
|
|
191
|
+
// this.element.style.top = scrollTop + 'px'
|
|
192
|
+
// this.element.style.height = this.size - scrollTop
|
|
193
193
|
// } else {
|
|
194
194
|
// console.log('size scroll', this.size, scrollTop)
|
|
195
195
|
|
|
196
|
-
// this.
|
|
197
|
-
// // this.
|
|
196
|
+
// this.element.style.height = this.size - scrollTop + 'px'
|
|
197
|
+
// // this.element.style.top = scrollTop + 'px'
|
|
198
198
|
// }
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
fixed (e, scrollTop) {
|
|
202
202
|
if (scrollTop > 0) {
|
|
203
|
-
this.
|
|
203
|
+
this.element.style.transform = 'translateY(' + scrollTop + 'px)'
|
|
204
204
|
} else {
|
|
205
|
-
this.
|
|
205
|
+
this.element.style.transform = 'translateY(' + scrollTop + 'px)'
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
package/src/tooltip.js
CHANGED
|
@@ -40,19 +40,19 @@ class Tooltip {
|
|
|
40
40
|
build () {
|
|
41
41
|
var container = this.options.container || document.body
|
|
42
42
|
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
43
|
+
this.element = document.createElement('span')
|
|
44
|
+
this.element.classList.add('tooltip')
|
|
45
|
+
this.element.classList.add('control')
|
|
46
46
|
|
|
47
47
|
this.pointer = document.createElement('span')
|
|
48
48
|
this.pointer.classList.add('pointer')
|
|
49
|
-
this.
|
|
49
|
+
this.element.appendChild(this.pointer)
|
|
50
50
|
|
|
51
51
|
this.label = document.createElement('span')
|
|
52
52
|
this.label.classList.add('label')
|
|
53
|
-
this.
|
|
53
|
+
this.element.appendChild(this.label)
|
|
54
54
|
|
|
55
|
-
container.appendChild(this.
|
|
55
|
+
container.appendChild(this.element)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
attach () {
|
|
@@ -78,8 +78,8 @@ class Tooltip {
|
|
|
78
78
|
var coord = this.offset(e.currentTarget)
|
|
79
79
|
|
|
80
80
|
this.show()
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
81
|
+
this.element.style.top = (coord.top + this.options.offset.top) + 'px'
|
|
82
|
+
this.element.style.left = coord.left - (this.element.offsetWidth / 2) + (e.currentTarget.offsetWidth / 2) + 'px'
|
|
83
83
|
})
|
|
84
84
|
|
|
85
85
|
targets[i].addEventListener('mouseleave', (e) => {
|
|
@@ -88,7 +88,7 @@ class Tooltip {
|
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
this.
|
|
91
|
+
this.element.addEventListener('click', (e) => {
|
|
92
92
|
e.preventDefault()
|
|
93
93
|
e.stop()
|
|
94
94
|
this.hide()
|
|
@@ -103,11 +103,11 @@ class Tooltip {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
hide () {
|
|
106
|
-
this.
|
|
106
|
+
this.element.classList.remove('show')
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
show () {
|
|
110
|
-
this.
|
|
110
|
+
this.element.classList.add('show')
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
disable () {
|