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