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.
Files changed (98) hide show
  1. package/form.js +27 -0
  2. package/index.js +61 -51
  3. package/list.js +35 -0
  4. package/package.json +5 -1
  5. package/src/appbar.js +7 -204
  6. package/src/badge.js +27 -0
  7. package/src/button.js +160 -161
  8. package/src/calendar.js +8 -10
  9. package/src/card.js +4 -6
  10. package/src/checkbox.js +8 -10
  11. package/src/component.js +4 -6
  12. package/src/container.js +4 -6
  13. package/src/datehour.js +38 -0
  14. package/src/dialog.js +106 -153
  15. package/src/divider.js +4 -6
  16. package/src/drawer.js +11 -13
  17. package/src/field/email.js +5 -5
  18. package/src/field/image.js +4 -4
  19. package/src/{control/file.js → file.js} +18 -48
  20. package/src/form/build.js +7 -7
  21. package/src/form/verify.js +2 -2
  22. package/src/form.js +6 -8
  23. package/src/icon.js +8 -10
  24. package/src/image.js +39 -106
  25. package/src/item.js +7 -9
  26. package/src/layout.js +10 -10
  27. package/src/link.js +50 -0
  28. package/src/list/add.js +1 -1
  29. package/src/list/build.js +9 -9
  30. package/src/list/collection.js +1 -1
  31. package/src/list/display.js +10 -10
  32. package/src/list/filter.js +2 -2
  33. package/src/list/request.js +1 -1
  34. package/src/list/search.js +7 -7
  35. package/src/list.js +29 -217
  36. package/src/loading.js +73 -0
  37. package/src/map/build.js +6 -6
  38. package/src/map/display.js +8 -8
  39. package/src/menu.js +60 -116
  40. package/src/{component → mixin}/control.js +10 -10
  41. package/src/{component → mixin}/create.js +1 -1
  42. package/src/{module → mixin}/display.js +9 -22
  43. package/src/{component → mixin}/events.js +2 -2
  44. package/src/{component → mixin}/focus.js +2 -3
  45. package/src/{component → mixin}/insert.js +3 -25
  46. package/src/{control/module → module}/attributes.js +2 -2
  47. package/src/module/build.js +11 -7
  48. package/src/{component → module}/classify.js +0 -13
  49. package/src/module/dom.js +1 -57
  50. package/src/module/events.js +4 -2
  51. package/src/{component → module}/ripple.js +15 -42
  52. package/src/navigation.js +19 -0
  53. package/src/progress.js +7 -9
  54. package/src/search.js +71 -0
  55. package/src/select.js +58 -273
  56. package/src/{control/selecter.js → selecter.js} +20 -20
  57. package/src/selector.js +32 -32
  58. package/src/skin/material/component/navigation.sass +1 -0
  59. package/src/skin/material/control/button.sass +10 -0
  60. package/src/slider.js +32 -34
  61. package/src/snackbar.js +72 -51
  62. package/src/switch.js +115 -107
  63. package/src/{control/switcher.js → switcher.js} +33 -36
  64. package/src/tabs.js +8 -8
  65. package/src/tabview.js +8 -8
  66. package/src/text.js +25 -74
  67. package/src/textfield.js +97 -234
  68. package/src/toolbar.js +28 -28
  69. package/src/tooltip.js +11 -11
  70. package/src/tree.js +12 -16
  71. package/src/view/build.js +6 -6
  72. package/src/view/display.js +16 -16
  73. package/src/view.js +5 -5
  74. package/src/banner.js +0 -231
  75. package/src/component/click.js +0 -17
  76. package/src/control/button.js +0 -267
  77. package/src/control/button.new.js +0 -190
  78. package/src/control/datehour.js +0 -65
  79. package/src/control/dialog.js +0 -175
  80. package/src/control/image.js +0 -92
  81. package/src/control/link.js +0 -69
  82. package/src/control/list.js +0 -67
  83. package/src/control/loading.js +0 -128
  84. package/src/control/menu.js +0 -85
  85. package/src/control/search.js +0 -98
  86. package/src/control/select.js +0 -130
  87. package/src/control/snackbar.js +0 -89
  88. package/src/control/switch.js +0 -272
  89. package/src/control/text.js +0 -70
  90. package/src/control/textfield.js +0 -177
  91. /package/src/{component → mixin}/controller.js +0 -0
  92. /package/src/{component → mixin}/emitter.js +0 -0
  93. /package/src/{component → mixin}/icon.js +0 -0
  94. /package/src/{component → mixin}/init.js +0 -0
  95. /package/src/{component → mixin}/label.js +0 -0
  96. /package/src/{component → mixin}/settings.js +0 -0
  97. /package/src/{control/module → module}/addclass.js +0 -0
  98. /package/src/{tabs/setup.js → module/last.js} +0 -0
package/src/tree.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import insert from './component/insert'
3
+ import insert from './mixin/insert'
4
4
  import css from './module/css'
5
5
  import attach from './module/attach'
6
6
 
@@ -85,8 +85,8 @@ class Tree {
85
85
  // define main tag
86
86
  var tag = this.options.tag || 'div'
87
87
 
88
- this.root = document.createElement(tag)
89
- css.add(this.root, this.options.prefix + '-' + this.options.class)
88
+ this.element = document.createElement(tag)
89
+ css.add(this.element, this.options.prefix + '-' + this.options.class)
90
90
 
91
91
  if (this.options.container) {
92
92
  this.insert(this.options.container)
@@ -96,7 +96,7 @@ class Tree {
96
96
  this.buildTree(this.options.data)
97
97
  }
98
98
 
99
- // this.root.addEventListener("click", function(e) {
99
+ // this.element.addEventListener("click", function(e) {
100
100
  // // console.log("list", this, e);
101
101
  // // e.target was the clicked element
102
102
  // });
@@ -105,13 +105,12 @@ class Tree {
105
105
  }
106
106
 
107
107
  buildTree (data) {
108
- this.root.innerHTML = ''
108
+ this.element.innerHTML = ''
109
109
 
110
110
  // console.log('buildTree', data);
111
111
 
112
112
  var tree = ''
113
113
 
114
-
115
114
  function checkChildren (parentObj, level) {
116
115
  if (level) {
117
116
  level++
@@ -119,11 +118,10 @@ class Tree {
119
118
  level = 0
120
119
  }
121
120
 
122
-
123
- level++;
121
+ level++
124
122
 
125
123
  // console.log('-- ', level, parentObj);
126
- if (parentObj.path) {
124
+ if (parentObj.path) {
127
125
  var level = (parentObj.path.split('/').length - 1)
128
126
 
129
127
  if (level > 0) {
@@ -131,7 +129,7 @@ class Tree {
131
129
  }
132
130
  } else {
133
131
  if (level > 1) {
134
- tree += '<li class="item-tree" data-id="'+parentObj._id+'">' + parentObj.name
132
+ tree += '<li class="item-tree" data-id="' + parentObj._id + '">' + parentObj.name
135
133
  }
136
134
  }
137
135
 
@@ -150,13 +148,11 @@ class Tree {
150
148
  }
151
149
  }
152
150
 
153
-
154
-
155
151
  checkChildren(data)
156
152
 
157
153
  // console.log('html tree', tree);
158
154
 
159
- this.root.innerHTML = tree
155
+ this.element.innerHTML = tree
160
156
 
161
157
  return tree
162
158
  }
@@ -238,8 +234,8 @@ class Tree {
238
234
  }
239
235
 
240
236
  var where = 'bottom'
241
- this.insertElement(item.root, this.root, where)
242
- // item.insert(this.root, where);
237
+ this.insertElement(item.root, this.element, where)
238
+ // item.insert(this.element, where);
243
239
  this.items.push(item)
244
240
 
245
241
  return item
@@ -247,7 +243,7 @@ class Tree {
247
243
 
248
244
  empty () {
249
245
  // console.log('empty')
250
- this.root.innerHTML = ''
246
+ this.element.innerHTML = ''
251
247
  this.items = []
252
248
  this.item = null
253
249
  }
package/src/view/build.js CHANGED
@@ -4,22 +4,22 @@ import Layout from '../layout'
4
4
 
5
5
  export default {
6
6
  build () {
7
- this.root = document.createElement('div')
8
- this.root.classList.add('view')
7
+ this.element = document.createElement('div')
8
+ this.element.classList.add('view')
9
9
 
10
10
  if (this.options.class) {
11
11
  this.addClass(this.options.class)
12
12
  }
13
13
 
14
14
  if (this.options.data) {
15
- dataset(this.root, this.options.data)
15
+ dataset(this.element, this.options.data)
16
16
  }
17
17
 
18
18
  this.container = this.options.container || document.body
19
- this.container.appendChild(this.root)
19
+ this.container.appendChild(this.element)
20
20
 
21
21
  if (this.options.layout) {
22
- this.layout = new Layout(this.options.layout, this.root)
22
+ this.layout = new Layout(this.options.layout, this.element)
23
23
  this.ui = this.layout.component
24
24
  }
25
25
  },
@@ -28,7 +28,7 @@ export default {
28
28
  var list = c.split(' ')
29
29
 
30
30
  for (var i = 0; i < list.length; i++) {
31
- this.root.classList.add(list[i])
31
+ this.element.classList.add(list[i])
32
32
  }
33
33
  }
34
34
  }
@@ -11,15 +11,15 @@ export default {
11
11
  // console.log('show', this.visible)
12
12
 
13
13
  // if (this.options.transition) {
14
- // this.root.style.display = 'initial'
14
+ // this.element.style.display = 'initial'
15
15
  // }
16
16
 
17
- this.root.getBoundingClientRect()
17
+ this.element.getBoundingClientRect()
18
18
 
19
19
  // clearTimeout(this.displayTimeout)
20
- // this.root.style.display = this._display
20
+ // this.element.style.display = this._display
21
21
 
22
- this.root.classList.add('show')
22
+ this.element.classList.add('show')
23
23
  this.visible = true
24
24
 
25
25
  if (this.underlay) {
@@ -31,14 +31,14 @@ export default {
31
31
  },
32
32
 
33
33
  hide () {
34
- // console.log('hide')
35
- // if (this.root.style.display === 'none') return
34
+ // console.trace('hide')
35
+ // if (this.element.style.display === 'none') return
36
36
  // clearTimeout(this.displayTimeout)
37
- // this._display = getComputedStyle(this.root).display
37
+ // this._display = getComputedStyle(this.element).display
38
38
 
39
- if (!this.root) return
39
+ if (!this.element) return
40
40
 
41
- this.root.classList.remove('show')
41
+ this.element.classList.remove('show')
42
42
  this.visible = false
43
43
 
44
44
  if (this.underlay) {
@@ -48,7 +48,7 @@ export default {
48
48
  // if (this.options.transition) {
49
49
  // this.displayTimeout = setTimeout(() => {
50
50
  // console.log('display: none', this._display)
51
- // this.root.style.display = 'none'
51
+ // this.element.style.display = 'none'
52
52
  // }, this.options.transition)
53
53
  // }
54
54
 
@@ -57,9 +57,9 @@ export default {
57
57
  },
58
58
 
59
59
  destroy () {
60
- // console.log('destroy', this.options.transition, this.root)
61
- if (this.options.transition && this.root) {
62
- this.root.classList.remove('show')
60
+ // console.log('destroy', this.options.transition, this.element)
61
+ if (this.options.transition && this.element) {
62
+ this.element.classList.remove('show')
63
63
 
64
64
  if (this.underlay) {
65
65
  this.underlay.classList.remove('show')
@@ -76,9 +76,9 @@ export default {
76
76
  },
77
77
 
78
78
  removeChild () {
79
- if (this.root && this.root.parentNode) {
80
- this.root.parentNode.removeChild(this.root)
81
- this.root = null
79
+ if (this.element && this.element.parentNode) {
80
+ this.element.parentNode.removeChild(this.element)
81
+ this.element = null
82
82
  }
83
83
 
84
84
  if (this.underlay && this.underlay.parentNode) {
package/src/view.js CHANGED
@@ -62,26 +62,26 @@ class View {
62
62
  build (props) {
63
63
  var tag = this.options.tag || 'div'
64
64
 
65
- this.root = create(tag, this.options.prefix + '-' + this.options.class)
65
+ this.element = create(tag, this.options.prefix + '-' + this.options.class)
66
66
 
67
67
  if (this.options.name) {
68
- css.add(this.root, this.options.class + '-' + this.options.name)
68
+ css.add(this.element, this.options.class + '-' + this.options.name)
69
69
  }
70
70
 
71
71
  if (this.options.css) {
72
- css.add(this.root, this.options.css)
72
+ css.add(this.element, this.options.css)
73
73
  }
74
74
 
75
75
  if (this.options.container) {
76
76
  // console.log(this.options.name, opts.container);
77
- insert(this.root, this.options.container)
77
+ insert(this.element, this.options.container)
78
78
  }
79
79
 
80
80
  return this
81
81
  }
82
82
 
83
83
  insert (container, context) {
84
- insert(this.root, container, context)
84
+ insert(this.element, container, context)
85
85
  return this
86
86
  }
87
87
  }
package/src/banner.js DELETED
@@ -1,231 +0,0 @@
1
- 'use strict'
2
-
3
- import create from './component/create'
4
- import insert from './element/insert'
5
- import event from './element/event'
6
- import offset from './element/offset'
7
- import emitter from './module/emitter'
8
-
9
- const defaults = {
10
- prefix: 'material',
11
- class: 'banner',
12
- tag: 'div'
13
- }
14
-
15
- /**
16
- * Class representing a UI Container. Can add components.
17
- *
18
- * @extends Component
19
- * @return {parent} The class instance
20
- * @example new Container({
21
- * container: document.body
22
- * });
23
- */
24
- class Banner {
25
- /**
26
- * Constructor
27
- * @param {Object} options - Component options
28
- * @return {Object} Class instance
29
- */
30
- constructor (options) {
31
- // init and build
32
- this.init(options)
33
- this.build()
34
- this.attach()
35
-
36
- return this
37
- }
38
-
39
- /**
40
- * Init class
41
- * @params {Object} options The instance options
42
- * @return {Object} This class instance
43
- */
44
- init (options) {
45
- this.options = Object.assign({}, defaults, options || {})
46
- Object.assign(this, emitter)
47
-
48
- return this
49
- }
50
-
51
- /**
52
- * [build description]
53
- * @return {Object} This class instance
54
- */
55
- build () {
56
- this.root = create(this.options)
57
-
58
- if (this.options.container) {
59
- insert(this.root, this.options.container)
60
- }
61
-
62
- return this
63
- }
64
-
65
- attach () {
66
- event.add(this.root, 'click', (ev) => {
67
- // console.log('click', ev.target)
68
-
69
- if (ev.target && ev.target.classList.contains('material-button')) {
70
- var name = ev.target.getAttribute('data-name')
71
- // console.log('name', name)
72
- this.emit('select', name)
73
- this.dismiss(ev.target)
74
- }
75
-
76
- ev.stopPropagation()
77
- })
78
-
79
- this.root.addEventListener('DOMNodeInserted', (e) => {
80
- // console.log('DOMNodeInserted', e.target)
81
- var textNode = e.target
82
-
83
- if (textNode == this.root) {
84
- // console.log('banner root inserted', e.target)
85
- if (!this.wrapper) { this.wrap() }
86
- this.scroll(this.view)
87
- }
88
- this.updatePaddingView()
89
-
90
- // if (textNode !== this.root) return
91
- })
92
- }
93
-
94
- dismiss () {
95
- this.wrapper.classList.add('is-closed')
96
- this.wrapper.style.height = '0'
97
- this.updatePaddingView()
98
- }
99
-
100
- show () {
101
- console.log('this.height', this.height)
102
- this.wrapper.classList.remove('is-closed')
103
- this.wrapper.style.height = this.height + 'px'
104
- this.updatePaddingView()
105
- this.updatePosition()
106
- }
107
-
108
- wrap () {
109
- this.view = this.root.parentNode
110
-
111
- // console.log('wrap', this.root, this.view)
112
- this.wrapper = document.createElement('div')
113
-
114
- this.wrapper.classList.add('banner-wrapper')
115
-
116
- this.view.insertBefore(this.wrapper, this.root)
117
-
118
- this.wrapper.appendChild(this.root)
119
-
120
- // insert(this.wrapper, this.root, 'before')
121
-
122
- // insert(this.root, this.wrapper)
123
- }
124
-
125
- updatePaddingView () {
126
- // console.log('updatePaddingView', this.view)
127
-
128
- this.height = offset(this.root, 'height')
129
- if (!this.paddingview) {
130
- this.paddingview = window.getComputedStyle(this.view)['padding-top']
131
- }
132
-
133
- // this.root.style.top = 'top: ' + this.paddingview
134
-
135
- // console.log('paddingTop', padding)
136
- // if (!padding) padding = window.getComputedStyle(this.root.parentNode, 'padding')
137
- // console.log('padding', padding)
138
-
139
- var padding = parseInt(this.paddingview, 10)
140
- var size = parseInt(this.height, 10)
141
-
142
- this.padding = padding
143
-
144
- // console.log(' banner inserted in', size, 'padding', padding)
145
- //
146
- //
147
-
148
- var ptop = this.ptop = padding
149
-
150
- if (this.wrapper.classList.contains('is-fixed') && !this.wrapper.classList.contains('is-closed')) {
151
- var ptop = this.ptop = size + padding
152
- }
153
-
154
- this.view.setAttribute('style', 'padding-top: ' + ptop + 'px')
155
- }
156
-
157
- scroll (view) {
158
- // console.log('initScroll', offset(this.root, 'top'), offset(view, 'top'))
159
-
160
- var isBody = false
161
-
162
- var element = view
163
-
164
- this.scrolling = view
165
-
166
- if (view === document.body) {
167
- isBody = true
168
- element = document
169
- this.scrolling = document.body
170
- }
171
-
172
- // view.classList.add()
173
-
174
- element.addEventListener('scroll', (e) => {
175
- // console.log('scroll', this.view)
176
- this.updatePosition()
177
- })
178
- }
179
-
180
- updatePosition () {
181
- var view = this.view
182
- var scrollTop
183
- if (view === document.body) {
184
- scrollTop = (document.documentElement ||
185
- document.body.parentNode ||
186
- document.body).scrollTop
187
- } else {
188
- scrollTop = view.scrollTop
189
- }
190
-
191
- // var o = offset(this.root, 'top') - offset(view, 'top')
192
- // console.log('o', this.root.offsetTop)
193
-
194
- var padding = this.paddingview
195
- padding = parseInt(padding, 10)
196
-
197
- // console.log('scroll', scrollTop, padding)
198
-
199
- if (scrollTop > padding) {
200
- var y = scrollTop - padding
201
- // console.log('fixed', y)
202
- this.wrapper.classList.add('is-fixed')
203
- this.wrapper.style.transform = 'translateY(' + y + 'px)'
204
-
205
- // this.update(scrollTop, padding)
206
- // this.wrapper.setAttribute('style', 'top: ' + this.paddingview)
207
- this.wrapper.style.top = this.paddingview
208
- } else {
209
- // console.log('relative')
210
- this.wrapper.classList.remove('is-fixed')
211
- this.wrapper.style.transform = 'translateY(' + 0 + 'px)'
212
- this.wrapper.style.top = '0'
213
- // this.wrapper.setAttribute('style', 'top: ' + this.paddingview)
214
- // this.wrapper.setAttribute('style', 'top: 0')
215
- }
216
-
217
- this.updatePaddingView()
218
- }
219
-
220
- update (scrollTop, padding) {
221
-
222
- }
223
-
224
- insert (container, context) {
225
- insert(this.root, container, context)
226
-
227
- return this
228
- }
229
- }
230
-
231
- export default Banner
@@ -1,17 +0,0 @@
1
- // event related functions and listeners
2
- /**
3
- * on element click
4
- * @param {event} e click event
5
- * @return {void}
6
- */
7
- function click(e) {
8
- e.preventDefault()
9
-
10
- // console.log('click caller', arguments.callee.caller)
11
-
12
- if (e && e.target && e.target.disabled === 'disabled') return
13
- // if (options.upload) return
14
- // api.emit('click', e)
15
- }
16
-
17
- export default click