material 0.7.1 → 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/package.json +7 -20
- package/src/badge.js +1 -1
- package/src/button.js +50 -100
- package/src/calendar.js +53 -53
- package/src/card.js +1 -1
- package/src/checkbox.js +5 -53
- package/src/datehour.js +7 -7
- package/src/dialog.js +5 -5
- package/src/divider.js +1 -1
- package/src/drawer.js +1 -17
- 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/file.js +1 -1
- 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 +4 -4
- package/src/form.js +9 -9
- package/src/icon.js +4 -4
- package/src/image.js +7 -7
- package/src/item.js +1 -1
- package/src/layout.js +14 -14
- package/src/link.js +1 -1
- package/src/list/build.js +8 -8
- package/src/list/click.js +3 -3
- 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 +7 -7
- package/src/list/search.js +9 -9
- 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 +8 -8
- 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 +12 -12
- 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 -1
- 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 +5 -5
- package/src/mixin/label.js +2 -2
- package/src/mixin/settings.js +5 -5
- package/src/module/attach.js +35 -49
- package/src/module/attributes.js +2 -2
- package/src/module/build.js +7 -10
- 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/progress.js +1 -9
- package/src/search.js +24 -29
- package/src/select.js +6 -6
- package/src/selecter.js +39 -39
- package/src/selector.js +3 -3
- package/src/skin/material/component/navigation.sass +9 -1
- package/src/slider.js +1 -1
- package/src/snackbar.js +8 -7
- package/src/switch.js +1 -1
- package/src/switcher.js +15 -15
- package/src/tabs.js +4 -5
- package/src/tabview.js +26 -46
- package/src/text.js +1 -1
- package/src/textfield.js +1 -1
- 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/element/ripple.js +0 -90
- package/src/module/addclass.js +0 -16
package/src/list/update.js
CHANGED
|
@@ -9,8 +9,8 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
getUpdatedIndex (id) {
|
|
11
11
|
// console.log('getUpdatedIndex', id)
|
|
12
|
-
|
|
13
|
-
for (
|
|
12
|
+
let index = null
|
|
13
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
14
14
|
// console.log('--', this.data[i][this.dataId], id)
|
|
15
15
|
if (this.data[i][this.dataId] === id) {
|
|
16
16
|
index = i
|
|
@@ -23,9 +23,9 @@ export default {
|
|
|
23
23
|
|
|
24
24
|
getUpdatedInfo (id) {
|
|
25
25
|
// console.log('getUpdatedInfo', id)
|
|
26
|
-
|
|
26
|
+
const index = this.getUpdatedIndex(id)
|
|
27
27
|
// console.log('index', index)
|
|
28
|
-
|
|
28
|
+
const route = this.buildRoute(index + 1, 1)
|
|
29
29
|
// console.log('roote', route)
|
|
30
30
|
fetch(route).then((resp) => {
|
|
31
31
|
return resp.json()
|
|
@@ -50,10 +50,10 @@ export default {
|
|
|
50
50
|
this.dataStore[info[this.dataId]] = info
|
|
51
51
|
|
|
52
52
|
// update item if on the screen
|
|
53
|
-
|
|
53
|
+
const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
|
|
54
54
|
if (item) {
|
|
55
55
|
item.innerHTML = ''
|
|
56
|
-
|
|
56
|
+
const layout = new Layout(this.options.layout.item, item)
|
|
57
57
|
|
|
58
58
|
this.renderInfo(layout, info)
|
|
59
59
|
}
|
package/src/list/virtual.js
CHANGED
|
@@ -39,14 +39,14 @@ function VirtualList (options) {
|
|
|
39
39
|
VirtualList.prototype._renderChunk = function (node, from, number) {
|
|
40
40
|
// console.log('_renderChunk', from, number, this.options.class)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const fragment = document.createDocumentFragment()
|
|
43
43
|
fragment.appendChild(this.scroller)
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
let last = from + number
|
|
46
46
|
if (last > this.count) last = this.count
|
|
47
47
|
|
|
48
|
-
for (
|
|
49
|
-
|
|
48
|
+
for (let i = from; i < last; i++) {
|
|
49
|
+
const item = this.render(i)
|
|
50
50
|
|
|
51
51
|
item.style.position = 'absolute'
|
|
52
52
|
item.style.top = i * this.itemHeight + 'px'
|
|
@@ -84,7 +84,7 @@ VirtualList.prototype.set = function (items) {
|
|
|
84
84
|
this.container.innerHTML = ''
|
|
85
85
|
this.container.scrollTop = 0
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
const height = this.itemHeight * this.count
|
|
88
88
|
|
|
89
89
|
this.scroller.style.height = height + 'px'
|
|
90
90
|
|
|
@@ -94,7 +94,7 @@ VirtualList.prototype.set = function (items) {
|
|
|
94
94
|
// console.log('this.itemsByScreen', this.itemsByScreen)
|
|
95
95
|
|
|
96
96
|
// Cache 4 times the number of items that fit in the container viewport
|
|
97
|
-
|
|
97
|
+
let size = this.itemsByScreen * 4
|
|
98
98
|
this._renderChunk(this.container, 0, size)
|
|
99
99
|
|
|
100
100
|
this.size = size
|
|
@@ -102,13 +102,13 @@ VirtualList.prototype.set = function (items) {
|
|
|
102
102
|
// console.log('emit size', size)
|
|
103
103
|
this.emit('size', size)
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
const self = this
|
|
106
|
+
let lastRepaintY
|
|
107
|
+
const maxBuffer = this.itemsByScreen * this.itemHeight
|
|
108
108
|
|
|
109
109
|
function onScroll (e) {
|
|
110
110
|
// console.log('scroll', e.target.scrollTop, height)
|
|
111
|
-
|
|
111
|
+
const scrollTop = e.target.scrollTop
|
|
112
112
|
|
|
113
113
|
// console.log('itemsByScreen', self.itemsByScreen)
|
|
114
114
|
|
|
@@ -124,7 +124,7 @@ VirtualList.prototype.set = function (items) {
|
|
|
124
124
|
|
|
125
125
|
// console.log('itemsByScreen', self.itemsByScreen)
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
let first = parseInt(scrollTop / self.itemHeight) - self.itemsByScreen
|
|
128
128
|
first = first < 0 ? 0 : first
|
|
129
129
|
|
|
130
130
|
size = self.itemsByScreen * 4
|
|
@@ -134,7 +134,7 @@ VirtualList.prototype.set = function (items) {
|
|
|
134
134
|
lastRepaintY = scrollTop
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
const progress = Math.ceil((scrollTop / self.itemHeight) + self.itemsByScreen) - 1
|
|
138
138
|
// console.log('progress', progress)
|
|
139
139
|
self.emit('progress', progress)
|
|
140
140
|
|
|
@@ -160,14 +160,14 @@ VirtualList.prototype.update = function (items) {
|
|
|
160
160
|
this.count = this.items.length
|
|
161
161
|
|
|
162
162
|
// var itemsByScreen = Math.ceil(this.container.offsetHeight / this.itemHeight)
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
const cachedItemsLen = this.itemsByScreen * 4
|
|
164
|
+
const scrollTop = this.container.scrollTop
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
const height = this.itemHeight * this.count
|
|
167
167
|
|
|
168
168
|
this.scroller.style.height = height + 'px'
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
let first = parseInt(scrollTop / this.itemHeight) - this.itemsByScreen
|
|
171
171
|
first = first < 0 ? 0 : first
|
|
172
172
|
|
|
173
173
|
// console.log('first', first, cachedItemsLen)
|
|
@@ -183,7 +183,7 @@ VirtualList.prototype.add = function (items) {
|
|
|
183
183
|
|
|
184
184
|
this.count = this.items.length
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
const height = this.itemHeight * this.count
|
|
187
187
|
|
|
188
188
|
this.scroller.style.height = height + 'px'
|
|
189
189
|
}
|
|
@@ -212,10 +212,10 @@ VirtualList.prototype.setOffset = function (info) {
|
|
|
212
212
|
|
|
213
213
|
// console.log('new itemsByScreen', this.itemsByScreen)
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
const itemsByScreen = Math.ceil(this.offsetHeight / this.itemHeight)
|
|
216
216
|
|
|
217
217
|
// Cache 4 times the number of items that fit in the container viewport
|
|
218
|
-
|
|
218
|
+
const size = itemsByScreen * 4
|
|
219
219
|
|
|
220
220
|
return size
|
|
221
221
|
}
|
|
@@ -227,7 +227,7 @@ VirtualList.prototype.getCount = function () {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
VirtualList.createScroller = function () {
|
|
230
|
-
|
|
230
|
+
const scroller = document.createElement('div')
|
|
231
231
|
scroller.classList.add('scroller')
|
|
232
232
|
return scroller
|
|
233
233
|
}
|
package/src/list/virtual.new.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// based on https://sergimansilla.com/blog/virtual-scrolling/
|
|
2
2
|
|
|
3
3
|
// Import necessary modules
|
|
4
|
-
import passiveEvents from '../module/passive'
|
|
5
|
-
import emitter from '../module/emitter'
|
|
4
|
+
import passiveEvents from '../module/passive' // Import the passiveEvents utility.
|
|
5
|
+
import emitter from '../module/emitter' // Import the emitter module.
|
|
6
6
|
|
|
7
7
|
// Define the VirtualList class
|
|
8
8
|
class VirtualList {
|
|
9
9
|
constructor (options) {
|
|
10
10
|
// Initialize the class with options passed to the constructor.
|
|
11
|
-
this.options = { ...(options || {}) }
|
|
12
|
-
Object.assign(this, emitter)
|
|
11
|
+
this.options = { ...(options || {}) } // Spread operator to merge options with default values.
|
|
12
|
+
Object.assign(this, emitter) // Assign emitter methods to the instance.
|
|
13
13
|
|
|
14
14
|
// Destructure options for easier access to properties.
|
|
15
15
|
const { itemHeight = 0, size = 0, items = [], render, container } = options
|
|
@@ -103,7 +103,7 @@ class VirtualList {
|
|
|
103
103
|
// Add a scroll event listener to render items dynamically.
|
|
104
104
|
const onScroll = (e) => {
|
|
105
105
|
const scrollTop = e.target.scrollTop
|
|
106
|
-
|
|
106
|
+
const first = parseInt(scrollTop / this.itemHeight) - this.itemsByScreen
|
|
107
107
|
|
|
108
108
|
size = this.itemsByScreen * 4
|
|
109
109
|
|
package/src/list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * css from './module/css'
|
|
2
2
|
|
|
3
3
|
const defaults = {
|
|
4
4
|
className: 'text',
|
|
@@ -18,11 +18,11 @@ class List {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
build () {
|
|
21
|
-
this.
|
|
22
|
-
|
|
21
|
+
this.element = document.createElement(this.options.tag)
|
|
22
|
+
css.add(this.element, this.options.class)
|
|
23
23
|
|
|
24
24
|
if (this.options.class !== 'text') {
|
|
25
|
-
this.
|
|
25
|
+
this.element.classList.add('text')
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (this.options.list) {
|
|
@@ -30,7 +30,7 @@ class List {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (this.options.container) {
|
|
33
|
-
this.options.container.appendChild(this.
|
|
33
|
+
this.options.container.appendChild(this.element)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return this
|
|
@@ -52,16 +52,16 @@ class List {
|
|
|
52
52
|
|
|
53
53
|
var label = this.options.label || ''
|
|
54
54
|
|
|
55
|
-
this.
|
|
55
|
+
this.element.innerHTML = label + text
|
|
56
56
|
|
|
57
57
|
if (this.options.spaceAfter) {
|
|
58
|
-
this.
|
|
58
|
+
this.element.innerHTML = this.element.innerHTML + ' '
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
setText (text) {
|
|
63
63
|
// console.log('setText', text)
|
|
64
|
-
this.
|
|
64
|
+
this.element.innerHTML = text
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
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 &&
|
package/src/menu.js
CHANGED
|
@@ -20,26 +20,26 @@ class Menu extends EventEmitter {
|
|
|
20
20
|
events: [
|
|
21
21
|
['element.click', 'close']
|
|
22
22
|
]
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
|
|
25
25
|
constructor (options) {
|
|
26
26
|
super()
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
this.init(options)
|
|
29
|
-
this.build(this.constructor)
|
|
29
|
+
this.build(this.constructor)
|
|
30
30
|
this.bindEvents()
|
|
31
31
|
|
|
32
32
|
this.render(this.options.items)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
init(options) {
|
|
35
|
+
init (options) {
|
|
36
36
|
this.options = Object.assign({}, Menu.defaults, options || {})
|
|
37
37
|
Object.assign(this, build, bindEvents, display)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
render (items) {
|
|
41
|
-
|
|
42
|
-
for (
|
|
41
|
+
if (items && Array.isArray(items)) {
|
|
42
|
+
for (let i = 0; i < items.length; i++) {
|
|
43
43
|
this.add(items[i])
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -48,8 +48,8 @@ class Menu extends EventEmitter {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
add (obj) {
|
|
51
|
-
if (typeof obj !== 'object') return this
|
|
52
|
-
let item
|
|
51
|
+
if (typeof obj !== 'object') return this
|
|
52
|
+
let item
|
|
53
53
|
if (obj.type === 'divider') {
|
|
54
54
|
item = new Element({ tag: 'li', class: 'divider' })
|
|
55
55
|
} else {
|
|
@@ -64,11 +64,11 @@ class Menu extends EventEmitter {
|
|
|
64
64
|
return this
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
position(target) {
|
|
67
|
+
position (target) {
|
|
68
68
|
if (!target) return
|
|
69
|
-
|
|
69
|
+
const offs = target.getBoundingClientRect()
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
const offsw = this.offset = this.ui.surface.getBoundingClientRect()
|
|
72
72
|
|
|
73
73
|
this.ui.surface.style.top = (offs.top - 4) + 'px'
|
|
74
74
|
this.ui.surface.style.left = offs.left - offsw.width + offs.width + 'px'
|
|
@@ -76,7 +76,7 @@ class Menu extends EventEmitter {
|
|
|
76
76
|
return this
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
close() {
|
|
79
|
+
close () {
|
|
80
80
|
// console.log('close')
|
|
81
81
|
this.destroy()
|
|
82
82
|
}
|
package/src/mixin/control.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import create from '../element/create'
|
|
2
|
-
import css from '../module/css'
|
|
2
|
+
import * as css from '../module/css'
|
|
3
3
|
import insert from '../element/insert'
|
|
4
4
|
|
|
5
5
|
const KEYCODE = {
|
|
@@ -7,7 +7,7 @@ const KEYCODE = {
|
|
|
7
7
|
SPACE: 32
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const control = {
|
|
11
11
|
/**
|
|
12
12
|
* [toggle description]
|
|
13
13
|
* @return {Object} The class instance
|
|
@@ -96,7 +96,7 @@ var control = {
|
|
|
96
96
|
error = error || this.options.error
|
|
97
97
|
if (this.options.error === null) return
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
const text = this.options.error || this.options.text
|
|
100
100
|
|
|
101
101
|
if (!this.element.error) { this.element.error = create('error', this.options.class + '-error') }
|
|
102
102
|
|
package/src/mixin/controller.js
CHANGED
|
@@ -110,7 +110,7 @@ class Controller {
|
|
|
110
110
|
return false
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
for (
|
|
113
|
+
for (let i = 0, len = this._topics[topic].length; i < len; i++) {
|
|
114
114
|
if (this._topics[topic][i] === callback) {
|
|
115
115
|
this._topics[topic].splice(i, 1)
|
|
116
116
|
return true
|
|
@@ -127,20 +127,20 @@ class Controller {
|
|
|
127
127
|
publish () {
|
|
128
128
|
this._topics = this._topics || {}
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
const args = Array.prototype.slice.call(arguments)
|
|
131
|
+
const topic = args.shift()
|
|
132
132
|
// _log.debug('publish', topic);
|
|
133
133
|
if (!this._topics.hasOwnProperty(topic)) {
|
|
134
134
|
return false
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
for (
|
|
137
|
+
for (let i = 0, len = this._topics[topic].length; i < len; i++) {
|
|
138
138
|
this._topics[topic][i].apply(undefined, args)
|
|
139
139
|
}
|
|
140
140
|
return true
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
const controller = new Controller()
|
|
145
145
|
|
|
146
146
|
export default controller
|
package/src/mixin/create.js
CHANGED