Comparing version 0.3.5 to 0.3.6
{ | ||
"name": "material", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "A lightweight implementation of Material Design Components - ES6", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -57,2 +57,6 @@ 'use strict' | ||
this.layout = null | ||
this.content = null | ||
this.html = null | ||
this.controller = controller | ||
@@ -71,2 +75,7 @@ | ||
css.add(this.root, 'material-dialog') | ||
if (this.options.name) { | ||
css.add(this.root, 'dialog-' + this.options.name) | ||
} | ||
if (this.options.css) { | ||
@@ -94,2 +103,10 @@ css.add(this.root, this.options.css) | ||
if (this.options.layout) { | ||
this.buildLayout() | ||
} | ||
if (this.options.html) { | ||
this.buildHTML() | ||
} | ||
this.buildActions() | ||
@@ -114,21 +131,22 @@ | ||
buildContent () { | ||
console.log('buildContent', typeof this.options.content) | ||
if (typeof this.options.content === 'string') { | ||
console.log('text content', this.options.content) | ||
this.content = new Text({ | ||
type: 'content', | ||
css: 'dialog-content', | ||
text: this.options.content | ||
}) | ||
buildLayout () { | ||
this.layout = new Layout(this.options.layout, this.surface) | ||
} | ||
this.insertElement(this.content.root, this.surface) | ||
} else if (_isArray(this.options.content)) { | ||
this.content = new Layout(this.options.content, this.surface) | ||
console.log('layout content', this.content) | ||
} else { | ||
console.log('other content', this.content) | ||
} | ||
buildHTML () { | ||
this.html = new Container({ | ||
css: 'dialog-content' | ||
}) | ||
} | ||
buildContent () { | ||
console.log('text content', this.options.content) | ||
this.content = new Text({ | ||
type: 'content', | ||
css: 'dialog-content', | ||
text: this.options.content | ||
}) | ||
this.insertElement(this.content.root, this.surface) | ||
} | ||
buildActions () { | ||
@@ -177,2 +195,4 @@ if (this.options.actions) { | ||
this.previousActive.focus() | ||
return this | ||
} | ||
@@ -193,2 +213,4 @@ | ||
return this | ||
// var button = this.root.querySelector('button') | ||
@@ -195,0 +217,0 @@ |
@@ -51,3 +51,5 @@ import { is as isObject } from './module/object' | ||
name = schema[i + 1] | ||
options.name = name | ||
if (!schema[i].isElement) { | ||
options.name = name | ||
} | ||
} | ||
@@ -54,0 +56,0 @@ |
@@ -16,3 +16,3 @@ 'use strict' | ||
functions: ['render', 'select'], | ||
target: '.material-item', | ||
target: 'LI', | ||
events: [ | ||
@@ -126,10 +126,15 @@ ['root.click', 'handleSelect'] | ||
handleSelect (e) { | ||
// console.log('onSelect', e.target, this.options.target); | ||
if (e.target && e.target.matches(this.options.target)) { | ||
// console.log("item clicked: ", e.target); | ||
if (e && e.target) { | ||
var el = e.target | ||
while (el && !el.matches(this.options.target)) { | ||
el = el.parentNode | ||
} | ||
console.log('item clicked: ', el) | ||
css.remove(this.item, 'is-selected') | ||
css.add(e.target, 'is-selected') | ||
css.add(el, 'is-selected') | ||
this.select(e.target, e, this.item) | ||
this.item = e.target | ||
this.select(el, e, this.item) | ||
this.item = el | ||
} | ||
@@ -213,3 +218,7 @@ } | ||
var where = 'bottom' | ||
insert(item.root, this.root, where) | ||
if (item.root) { | ||
insert(item.root, this.root, where) | ||
} else { | ||
insert(item, this.root, where) | ||
} | ||
@@ -216,0 +225,0 @@ this.items.push(item) |
@@ -19,2 +19,3 @@ 'use strict' | ||
attach: function (events) { | ||
// console.log('attach', events) | ||
events = events || this.options.events | ||
@@ -26,12 +27,45 @@ if (!events) return | ||
events.map((def) => { | ||
// console.log('map', def) | ||
var e = extract.e(instance, def[0]) | ||
var f = extract.f(instance, def[1]) | ||
var o = def[2] || false | ||
e.element.addEventListener(e.name, f.bind(this)) | ||
// console.log('attach', def[0], def[1]) | ||
var keys = def[1].split('.') | ||
keys.pop() | ||
var bound = this._path(keys.join('.')) | ||
if (e.element && e.element.addEventListener) { | ||
e.element.addEventListener(e.name, f.bind(bound), o) | ||
} else if (e.element && e.element.on) { | ||
// console.log('on', e.name) | ||
e.element.on(e.name, f.bind(bound)) | ||
} else { | ||
console.log('can\'t attach', e.name) | ||
} | ||
}) | ||
return this | ||
}, | ||
/** | ||
* Return the last reference from an object | ||
* @param {string} str Object path for example key1.key2.key3 | ||
* @return {value} The value of the last reference | ||
*/ | ||
_path: function (str) { | ||
if (!str) return this | ||
else if (!str.match(/\./)) return this[str] | ||
var last | ||
var keys = str.split('.') | ||
for (var i = 0, l = keys.length; i < l; i++) { | ||
var key = keys[i] | ||
last = last || this | ||
last = last[key] | ||
} | ||
return last | ||
} | ||
} |
@@ -12,3 +12,3 @@ 'use strict' | ||
events: [ | ||
// 'change': '_onChange', | ||
['input.change', '_onChange'], | ||
['input.focus', 'focus'], | ||
@@ -238,2 +238,8 @@ ['input.blur', 'blur'], | ||
_onChange (ev) { | ||
console.log('change', ev) | ||
this.emit('change', ev.target.value) | ||
} | ||
/** | ||
@@ -268,5 +274,6 @@ * [_initValue description] | ||
add (key, value) { | ||
add (key, value, selected) { | ||
selected = selected || false | ||
var select = this.input | ||
select.options[select.options.length] = new Option(value, key) | ||
select.options[select.options.length] = new Option(value, key, selected, selected) | ||
} | ||
@@ -273,0 +280,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
624985
139
10421