added default/shorthand elements...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-02-27 06:47:41 +03:00
parent ea8209c1f4
commit fa61d33f67
2 changed files with 24 additions and 12 deletions

View File

@ -109,6 +109,7 @@ requirejs([
make('a'), make('a'),
'b') 'b')
make('---') make('---')
make('...')
make('e') make('e')
// embeded browser... // embeded browser...
make(browser.Browser(function(make){ make(browser.Browser(function(make){

View File

@ -930,16 +930,26 @@ var BrowserPrototype = {
return null return null
} }
// XXX handle special items... // item shorthands...
// XXX if(item.value in options.elementShorthand){
var text = null
item = options.elementShorthand[item.value]
var text = JSON.stringify(item.value) var elem = $(item.html)[0]
elem.classList.add(...item['class'].split(/\s+/))
return elem
}
// normal items...
var elem = document.createElement('div') var elem = document.createElement('div')
var text = JSON.stringify(item.value || item)
// classes... // classes...
elem.classList.add(...['item'] elem.classList.add(...['item']
// user classes... // user classes...
.concat(item.cls || []) .concat(item['class'] || item.cls || [])
// special classes... // special classes...
.concat([ .concat([
'selected', 'selected',
@ -957,7 +967,8 @@ var BrowserPrototype = {
elem.setAttribute('value', text) elem.setAttribute('value', text)
// values... // values...
;(item.value instanceof Array ? item.value : [item.value]) text
&& (item.value instanceof Array ? item.value : [item.value])
// XXX handle $keys and other stuff... // XXX handle $keys and other stuff...
.map(function(v){ .map(function(v){
var value = document.createElement('span') var value = document.createElement('span')