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/list.js
CHANGED
|
@@ -1,255 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import Item from './item'
|
|
4
|
-
import Divider from './divider'
|
|
5
|
-
|
|
6
|
-
// import init from './mixin/init'
|
|
7
|
-
import emitter from './module/emitter'
|
|
8
|
-
import insert from './element/insert'
|
|
9
|
-
import css from './module/css'
|
|
10
|
-
import attach from './module/attach'
|
|
1
|
+
import * css from './module/css'
|
|
11
2
|
|
|
12
3
|
const defaults = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
functions: ['render', 'select'],
|
|
17
|
-
target: 'LI',
|
|
18
|
-
events: [
|
|
19
|
-
['root.click', 'handleSelect']
|
|
20
|
-
]
|
|
4
|
+
className: 'text',
|
|
5
|
+
tag: 'span',
|
|
6
|
+
seprator: ' | '
|
|
21
7
|
}
|
|
22
8
|
|
|
23
|
-
/**
|
|
24
|
-
* List view class
|
|
25
|
-
* @class
|
|
26
|
-
* @param {Object} options Default options for view
|
|
27
|
-
* @extends {View}
|
|
28
|
-
* @since 0.0.4
|
|
29
|
-
* @author Jerome Vial
|
|
30
|
-
*
|
|
31
|
-
* @type {prime}
|
|
32
|
-
*/
|
|
33
9
|
class List {
|
|
34
|
-
/**
|
|
35
|
-
* init
|
|
36
|
-
* @return {Object} The class options
|
|
37
|
-
*/
|
|
38
10
|
constructor (options) {
|
|
39
11
|
this.options = Object.assign({}, defaults, options || {})
|
|
40
12
|
|
|
41
|
-
|
|
42
|
-
this.build(this.options)
|
|
43
|
-
this.attach(this.options.events)
|
|
44
|
-
|
|
45
|
-
return this
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* [_initView description]
|
|
50
|
-
* @return Class instance
|
|
51
|
-
*/
|
|
52
|
-
init () {
|
|
53
|
-
this.filters = []
|
|
54
|
-
this.data = []
|
|
55
|
-
this.items = []
|
|
56
|
-
|
|
57
|
-
// assign modules
|
|
58
|
-
Object.assign(this, emitter, attach)
|
|
13
|
+
// console.log('options', this.options)
|
|
59
14
|
|
|
60
|
-
|
|
61
|
-
this._initFunction(this.options.functions)
|
|
15
|
+
this.build()
|
|
62
16
|
|
|
63
17
|
return this
|
|
64
18
|
}
|
|
65
19
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* @return {?} [description]
|
|
70
|
-
*/
|
|
71
|
-
_initFunction (functions) {
|
|
72
|
-
for (var i = 0; i < functions.length; i++) {
|
|
73
|
-
var name = functions[i]
|
|
74
|
-
if (this.options[name]) {
|
|
75
|
-
this[name] = this.options[name]
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
20
|
+
build () {
|
|
21
|
+
this.element = document.createElement(this.options.tag)
|
|
22
|
+
css.add(this.element, this.options.class)
|
|
79
23
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
* @param {Object} options this class options
|
|
83
|
-
* @return {Object} The class instance
|
|
84
|
-
*/
|
|
85
|
-
build (options) {
|
|
86
|
-
// define main tag
|
|
87
|
-
var tag = this.options.tag || 'ul'
|
|
88
|
-
|
|
89
|
-
this.element = document.createElement(tag)
|
|
90
|
-
css.add(this.element, 'material-' + this.options.class)
|
|
91
|
-
|
|
92
|
-
if (options.name) {
|
|
93
|
-
css.add(this.element, options.class + '-' + options.name)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (options.type) {
|
|
97
|
-
css.add(this.element, 'type-' + options.type)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (options.layout) {
|
|
101
|
-
css.add(this.element, 'layout-' + options.layout)
|
|
24
|
+
if (this.options.class !== 'text') {
|
|
25
|
+
this.element.classList.add('text')
|
|
102
26
|
}
|
|
103
27
|
|
|
104
28
|
if (this.options.list) {
|
|
105
|
-
this.set(
|
|
29
|
+
this.set(this.options.list)
|
|
106
30
|
}
|
|
107
31
|
|
|
108
32
|
if (this.options.container) {
|
|
109
|
-
|
|
33
|
+
this.options.container.appendChild(this.element)
|
|
110
34
|
}
|
|
111
35
|
|
|
112
|
-
// this.element.addEventListener("click", function(e) {
|
|
113
|
-
// // console.log("list", this, e);
|
|
114
|
-
// // e.target was the clicked element
|
|
115
|
-
// });
|
|
116
|
-
|
|
117
36
|
return this
|
|
118
37
|
}
|
|
119
38
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* @param {?} e [description]
|
|
123
|
-
* @return {?} [description]
|
|
124
|
-
*/
|
|
125
|
-
handleSelect (e) {
|
|
126
|
-
// console.log('handleSelect-', e.currentTarget, this.options.target)
|
|
127
|
-
e.stopPropagation()
|
|
128
|
-
|
|
129
|
-
if (e.target === e.currentTarget) {
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (e && e.target) {
|
|
134
|
-
var el = e.target
|
|
135
|
-
// console.log('el', el, el.matches(this.options.target))
|
|
136
|
-
while (el && !el.matches(this.options.target)) {
|
|
137
|
-
el = el.parentNode
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
css.remove(this.item, 'is-selected')
|
|
141
|
-
css.add(el, 'is-selected')
|
|
142
|
-
|
|
143
|
-
this.select(el, e, this.item)
|
|
144
|
-
this.item = el
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* select
|
|
150
|
-
* @param {Element} item [description]
|
|
151
|
-
* @param {event} event The caller event
|
|
152
|
-
* @return [description]
|
|
153
|
-
*/
|
|
154
|
-
select (item, e, selected) {
|
|
155
|
-
this.emit('select', item)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* [render description]
|
|
160
|
-
* @param {?} info [description]
|
|
161
|
-
* @return {?} [description]
|
|
162
|
-
*/
|
|
163
|
-
render (info) {
|
|
164
|
-
var item
|
|
165
|
-
|
|
166
|
-
if (info.type === 'divider') {
|
|
167
|
-
item = new Divider()
|
|
168
|
-
} else {
|
|
169
|
-
item = new Item({
|
|
170
|
-
name: info.name,
|
|
171
|
-
text: info.text || info.name
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return item
|
|
176
|
-
}
|
|
39
|
+
set (list) {
|
|
40
|
+
var text = ''
|
|
177
41
|
|
|
178
|
-
/**
|
|
179
|
-
* Setter
|
|
180
|
-
* @param {string} prop
|
|
181
|
-
* @param {string} value
|
|
182
|
-
*/
|
|
183
|
-
set (prop, value, options) {
|
|
184
|
-
// console.log('set', prop, value)
|
|
185
|
-
switch (prop) {
|
|
186
|
-
case 'list':
|
|
187
|
-
this.setList(value, options)
|
|
188
|
-
break
|
|
189
|
-
default:
|
|
190
|
-
this.setList(prop, options)
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return this
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Set list
|
|
198
|
-
* @param {Array} list List of info object
|
|
199
|
-
* @return {Object} The class instance
|
|
200
|
-
*/
|
|
201
|
-
setList (list) {
|
|
202
42
|
for (var i = 0; i < list.length; i++) {
|
|
203
|
-
|
|
43
|
+
if (i < list.length - 1) {
|
|
44
|
+
text = text + list[i] + this.options.seprator
|
|
45
|
+
} else {
|
|
46
|
+
text = text + list[i]
|
|
47
|
+
}
|
|
204
48
|
}
|
|
205
49
|
|
|
206
|
-
|
|
207
|
-
|
|
50
|
+
// console.log('set', text)
|
|
51
|
+
if (text === undefined) return
|
|
208
52
|
|
|
209
|
-
|
|
210
|
-
this.element.scrollTop = this.element.scrollHeight - this.element.getBoundingClientRect().height
|
|
211
|
-
}
|
|
53
|
+
var label = this.options.label || ''
|
|
212
54
|
|
|
213
|
-
|
|
214
|
-
* [add description]
|
|
215
|
-
* @param {Object} item [description]
|
|
216
|
-
*/
|
|
217
|
-
addItem (item /*, index */) {
|
|
218
|
-
if (!item) {
|
|
219
|
-
return
|
|
220
|
-
}
|
|
55
|
+
this.element.innerHTML = label + text
|
|
221
56
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
insert(item.root, this.element, where)
|
|
225
|
-
} else {
|
|
226
|
-
insert(item, this.element, where)
|
|
57
|
+
if (this.options.spaceAfter) {
|
|
58
|
+
this.element.innerHTML = this.element.innerHTML + ' '
|
|
227
59
|
}
|
|
228
|
-
|
|
229
|
-
this.items.push(item)
|
|
230
|
-
|
|
231
|
-
return item
|
|
232
60
|
}
|
|
233
61
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
empty () {
|
|
239
|
-
this.element.innerHTML = ''
|
|
240
|
-
this.items = []
|
|
241
|
-
this.item = null
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Reverse the list order
|
|
246
|
-
* @return {Object} The class instance
|
|
247
|
-
*/
|
|
248
|
-
reverse () {
|
|
249
|
-
this.list.reverse()
|
|
250
|
-
this.update(this.list)
|
|
251
|
-
|
|
252
|
-
return this
|
|
62
|
+
setText (text) {
|
|
63
|
+
// console.log('setText', text)
|
|
64
|
+
this.element.innerHTML = text
|
|
253
65
|
}
|
|
254
66
|
}
|
|
255
67
|
|
package/src/loading.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import build from './module/build'
|
|
2
|
+
|
|
3
|
+
class Loading {
|
|
4
|
+
static isComponent () {
|
|
5
|
+
return true
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
static defaults = {
|
|
9
|
+
class: 'loading',
|
|
10
|
+
tag: 'div',
|
|
11
|
+
delay: 1000,
|
|
12
|
+
type: 'indeterminate',
|
|
13
|
+
circular: `<svg class="progress" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
|
|
14
|
+
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
|
|
15
|
+
</svg>`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor (options) {
|
|
19
|
+
this.init(options)
|
|
20
|
+
this.build()
|
|
21
|
+
this.buildLoading()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
init (options) {
|
|
25
|
+
this.options = Object.assign({}, Loading.defaults, options || {})
|
|
26
|
+
Object.assign(this, build)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
buildLoading (options) {
|
|
30
|
+
if (this.options.type === 'circular') {
|
|
31
|
+
this.element.innerHTML = this.options.circular
|
|
32
|
+
} if (this.options.type === 'indeterminate') {
|
|
33
|
+
this.bar = document.createElement(this.options.tag)
|
|
34
|
+
this.bar.classList.add('bar')
|
|
35
|
+
this.element.classList.add('type-indeterminate')
|
|
36
|
+
this.element.appendChild(this.bar)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
set (progress) {
|
|
41
|
+
this.bar.setAttribute('style', 'width: ' + progress)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
show (delay) {
|
|
45
|
+
delay = delay || this.options.delay
|
|
46
|
+
|
|
47
|
+
clearTimeout(this.showTimeout)
|
|
48
|
+
this.showTimeout = setTimeout(() => {
|
|
49
|
+
this.element.classList.add('show')
|
|
50
|
+
}, this.options.delay)
|
|
51
|
+
|
|
52
|
+
this.visible = true
|
|
53
|
+
|
|
54
|
+
return this
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
showNow () {
|
|
58
|
+
this.element.classList.add('show')
|
|
59
|
+
|
|
60
|
+
this.visible
|
|
61
|
+
|
|
62
|
+
return this
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
hide () {
|
|
66
|
+
clearTimeout(this.showTimeout)
|
|
67
|
+
this.element.classList.remove('show')
|
|
68
|
+
this.visible = false
|
|
69
|
+
return this
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default Loading
|
package/src/map/build.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import observer from '../module/observer'
|
|
1
|
+
import observer from '../module/element/observer'
|
|
2
2
|
import Islands from '../view/islands'
|
|
3
3
|
import preventPullRefresh from '../module/preventPullRefresh'
|
|
4
4
|
import touch from '../module/touchscreen'
|
|
@@ -51,7 +51,7 @@ export default {
|
|
|
51
51
|
|
|
52
52
|
// })
|
|
53
53
|
// } else {
|
|
54
|
-
|
|
54
|
+
// console.log('panzoom')
|
|
55
55
|
this.draggable = new PanZoom(this.slide, {
|
|
56
56
|
maxZoom: 16,
|
|
57
57
|
minZoom: 1
|
package/src/map/countries.js
CHANGED
|
@@ -7,10 +7,10 @@ export default {
|
|
|
7
7
|
*/
|
|
8
8
|
updateCountries (isocodes) {
|
|
9
9
|
// console.log('updateCountries', isocodes.length)
|
|
10
|
-
|
|
10
|
+
const list = document.querySelectorAll('svg.mapsvg g')
|
|
11
11
|
// console.log('svg', list)
|
|
12
12
|
|
|
13
|
-
for (
|
|
13
|
+
for (let i = 0; i < list.length; i++) {
|
|
14
14
|
if (isocodes.indexOf(list[i].dataset.isocode) > -1) {
|
|
15
15
|
list[i].classList.remove('empty')
|
|
16
16
|
} else {
|
|
@@ -31,7 +31,7 @@ export default {
|
|
|
31
31
|
*/
|
|
32
32
|
random (isocodes) {
|
|
33
33
|
// console.log('random', isocodes.length)
|
|
34
|
-
|
|
34
|
+
const i = Math.floor(Math.random() * isocodes.length)
|
|
35
35
|
this.isocodes = isocodes[i]
|
|
36
36
|
this.highlight(this.isocodes)
|
|
37
37
|
|
|
@@ -42,10 +42,10 @@ export default {
|
|
|
42
42
|
* [setAllCountries description]
|
|
43
43
|
*/
|
|
44
44
|
setAllCountries () {
|
|
45
|
-
|
|
45
|
+
const list = document.querySelectorAll('svg.mapsvg g')
|
|
46
46
|
// console.log('svg', list)
|
|
47
47
|
|
|
48
|
-
for (
|
|
48
|
+
for (let i = 0; i < list.length; i++) {
|
|
49
49
|
list[i].classList.remove('empty')
|
|
50
50
|
}
|
|
51
51
|
},
|
|
@@ -64,7 +64,7 @@ export default {
|
|
|
64
64
|
if (typeof isocodes === 'string') {
|
|
65
65
|
this.highlightCountry(isocodes, option)
|
|
66
66
|
} else {
|
|
67
|
-
for (
|
|
67
|
+
for (let i = 0; i < isocodes.length; i++) {
|
|
68
68
|
this.highlightCountry(isocodes[i], option)
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -78,7 +78,7 @@ export default {
|
|
|
78
78
|
*/
|
|
79
79
|
highlightCountry (isocode, option) {
|
|
80
80
|
// console.log('highlightCountry', isocode, option)
|
|
81
|
-
|
|
81
|
+
const group = this.map.querySelector('[data-isocode="' + isocode + '"]')
|
|
82
82
|
|
|
83
83
|
if (!group) return
|
|
84
84
|
|
|
@@ -108,7 +108,7 @@ export default {
|
|
|
108
108
|
},
|
|
109
109
|
|
|
110
110
|
removePlaying () {
|
|
111
|
-
|
|
111
|
+
const group = document.querySelector('svg.mapsvg g.playing')
|
|
112
112
|
group.classList.remove('playing')
|
|
113
113
|
}
|
|
114
114
|
}
|
package/src/map/display.js
CHANGED
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
// object used to cache map by decade
|
|
6
6
|
this.mapsvg = this.mapsvg || {}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const decade = decades[0]
|
|
9
9
|
|
|
10
10
|
// do not update map when in taxi mode
|
|
11
11
|
// if (typeof decade !== 'number') {
|
|
@@ -20,7 +20,7 @@ export default {
|
|
|
20
20
|
if (cb) cb()
|
|
21
21
|
} else {
|
|
22
22
|
// fetch map for the corresponding decade
|
|
23
|
-
|
|
23
|
+
const url = this.options.path + decade + '.svg'
|
|
24
24
|
// console.log(url)
|
|
25
25
|
fetch(url).then((response) => {
|
|
26
26
|
response.text().then((map) => {
|
|
@@ -52,12 +52,12 @@ export default {
|
|
|
52
52
|
|
|
53
53
|
optimizeMap (decade) {
|
|
54
54
|
// console.log('optimizing map', decade)
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const parts = this.map.querySelectorAll('g[data-isocode]')
|
|
56
|
+
const country = {}
|
|
57
57
|
|
|
58
|
-
for (
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
for (let i = 0; i < parts.length; i++) {
|
|
59
|
+
const part = parts[i]
|
|
60
|
+
const code = part.dataset.isocode
|
|
61
61
|
if (!country[code]) {
|
|
62
62
|
country[code] = part
|
|
63
63
|
} else {
|
|
@@ -98,7 +98,7 @@ export default {
|
|
|
98
98
|
},
|
|
99
99
|
|
|
100
100
|
updateMap () {
|
|
101
|
-
|
|
101
|
+
const offsetX = this.element.offsetWidth - this.map.offsetWidth
|
|
102
102
|
// var offsetY = this.element.height - this.map.offsetHeight
|
|
103
103
|
|
|
104
104
|
// console.log('--', this.offsetX / 2 + 'px')
|
|
@@ -114,17 +114,17 @@ export default {
|
|
|
114
114
|
|
|
115
115
|
screenSize () {
|
|
116
116
|
// console.log('screensize')
|
|
117
|
-
|
|
117
|
+
const width = window.innerWidth ||
|
|
118
118
|
document.documentElement.clientWidth ||
|
|
119
119
|
document.body.clientWidth
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
const height = window.innerHeight ||
|
|
122
122
|
document.documentElement.clientHeight ||
|
|
123
123
|
document.body.clientHeight
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
width
|
|
127
|
-
height
|
|
125
|
+
const screen = {
|
|
126
|
+
width,
|
|
127
|
+
height
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
this.screen = screen
|
package/src/map/focus.js
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
*/
|
|
7
7
|
focus (country) {
|
|
8
8
|
// console.log('focus', country)
|
|
9
|
-
|
|
9
|
+
const part = this.getCountryParts(country)
|
|
10
10
|
// console.log('focus on part', part)
|
|
11
11
|
this.draggable.focus(part)
|
|
12
12
|
|
|
@@ -15,18 +15,18 @@ export default {
|
|
|
15
15
|
|
|
16
16
|
getCountryParts (country) {
|
|
17
17
|
// console.log('focus', country)
|
|
18
|
-
|
|
18
|
+
const parts = this.map.querySelectorAll('[data-isocode="' + country + '"]')
|
|
19
19
|
// console.log('parts', parts)
|
|
20
20
|
|
|
21
21
|
return this.getBiggestPart(parts)
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
getBiggestPart (parts) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
for (
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
let surface = 0
|
|
26
|
+
let biggest = null
|
|
27
|
+
for (let i = 0; i < parts.length; i++) {
|
|
28
|
+
const part = parts[i]
|
|
29
|
+
const rect = part.getBoundingClientRect()
|
|
30
30
|
|
|
31
31
|
if (rect.width * rect.height > surface) {
|
|
32
32
|
surface = rect.width * rect.height
|
package/src/map/select.js
CHANGED
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
this.isocodes = [isocode]
|
|
18
18
|
} else {
|
|
19
19
|
this.isocodes = this.isocodes || []
|
|
20
|
-
|
|
20
|
+
const index = this.isocodes.indexOf(isocode)
|
|
21
21
|
if (index > -1) {
|
|
22
22
|
this.isocodes.splice(index, 1)
|
|
23
23
|
this.highlight(isocode, false)
|
|
@@ -54,7 +54,7 @@ export default {
|
|
|
54
54
|
|
|
55
55
|
// console.log('islands list', this.islands.list, island.dataset.id)
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const info = this.islands.list[island.dataset.id]
|
|
58
58
|
|
|
59
59
|
this.emit('island', info)
|
|
60
60
|
},
|
package/src/map/set.js
CHANGED
|
@@ -54,9 +54,9 @@ export default {
|
|
|
54
54
|
|
|
55
55
|
setIsocodes (isocodes) {
|
|
56
56
|
this.isocodes = this.isocodes || []
|
|
57
|
-
|
|
58
|
-
for (
|
|
59
|
-
|
|
57
|
+
const l = this.isocodes.length
|
|
58
|
+
for (let i = 0; i < l; i++) {
|
|
59
|
+
const isocode = this.isocodes.splice(0, 1)
|
|
60
60
|
this.highlight(isocode, false)
|
|
61
61
|
}
|
|
62
62
|
|
package/src/map/viewport.js
CHANGED
|
@@ -3,21 +3,21 @@ export default {
|
|
|
3
3
|
updatePaths () {
|
|
4
4
|
this.path = {}
|
|
5
5
|
this.paths = []
|
|
6
|
-
|
|
6
|
+
const paths = this.paths = this.map.querySelectorAll('path')
|
|
7
7
|
this.path = this.path || {}
|
|
8
8
|
|
|
9
|
-
for (
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (let i = 0; i < paths.length; i++) {
|
|
10
|
+
const path = paths[i]
|
|
11
|
+
const rect = path.getBoundingClientRect()
|
|
12
12
|
this.path[i] = rect
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
updateViewport () {
|
|
17
17
|
console.log('updateViewport', this.rect, this.screen)
|
|
18
|
-
|
|
19
|
-
for (
|
|
20
|
-
|
|
18
|
+
const paths = this.paths
|
|
19
|
+
for (let i = 0; i < paths.length; i++) {
|
|
20
|
+
const path = paths[i]
|
|
21
21
|
if (this.viewport(this.path[i])) {
|
|
22
22
|
path.classList.remove('hide')
|
|
23
23
|
} else {
|
|
@@ -31,10 +31,10 @@ export default {
|
|
|
31
31
|
|
|
32
32
|
// *var rect = this.path[path]
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const top = rect.top
|
|
35
|
+
const left = rect.left
|
|
36
|
+
const width = rect.width
|
|
37
|
+
const height = rect.height
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
40
|
top >= this.screen.y &&
|