mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
65fb923216
commit
893741b98f
@ -265,13 +265,9 @@ Items.EditablePinnedList = function(values){}
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Item...
|
// Item...
|
||||||
|
|
||||||
var ItemClassPrototype = {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var ItemPrototype = {
|
var ItemPrototype = {
|
||||||
// parent: null,
|
parent: null,
|
||||||
//
|
|
||||||
// children: null,
|
// children: null,
|
||||||
//
|
//
|
||||||
// id: null,
|
// id: null,
|
||||||
@ -282,20 +278,25 @@ var ItemPrototype = {
|
|||||||
// disabled: null,
|
// disabled: null,
|
||||||
// selected: null,
|
// selected: null,
|
||||||
// collapsed: null,
|
// collapsed: null,
|
||||||
|
|
||||||
|
get id(){
|
||||||
|
return this.__id || this.text },
|
||||||
|
set id(value){
|
||||||
|
this.__id = value },
|
||||||
|
|
||||||
// XXX can value be a function or as a list contain a function???
|
// XXX can value be a function or as a list contain a function???
|
||||||
// ...if so, to resolve it we'll need a context other than the item...
|
// ...if so, to resolve it we'll need a context other than the item...
|
||||||
// XXX should we remove '$' here or in an extension???
|
// XXX should we remove '$' here or in an extension???
|
||||||
get text(){
|
get text(){
|
||||||
return (
|
var txt = this.value instanceof Array ?
|
||||||
(this.value instanceof Array ?
|
this.value.join(' ')
|
||||||
this.value.join(' ')
|
: this.value == null || this.value instanceof Object ?
|
||||||
: this.value == null || this.value instanceof Object ?
|
this.alt || this.__id
|
||||||
this.alt || this.id
|
: this.value
|
||||||
: this.value) + '')
|
return txt != null ?
|
||||||
.replace(/\$(.)/g, '$1') },
|
(txt + '')
|
||||||
|
.replace(/\$(.)/g, '$1')
|
||||||
|
: txt },
|
||||||
|
|
||||||
__init__(...state){
|
__init__(...state){
|
||||||
Object.assign(this, ...state) },
|
Object.assign(this, ...state) },
|
||||||
@ -304,9 +305,7 @@ var ItemPrototype = {
|
|||||||
|
|
||||||
var Item =
|
var Item =
|
||||||
module.Item =
|
module.Item =
|
||||||
object.makeConstructor('Item',
|
object.makeConstructor('Item', ItemPrototype)
|
||||||
ItemClassPrototype,
|
|
||||||
ItemPrototype)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -938,23 +937,11 @@ var BaseBrowserPrototype = {
|
|||||||
|
|
||||||
// Configuration / Extension...
|
// Configuration / Extension...
|
||||||
|
|
||||||
// XXX need a better key/path API...
|
|
||||||
//
|
|
||||||
// Normalize value...
|
|
||||||
__value2key__: function(key){
|
|
||||||
//return JSON.stringify(key)
|
|
||||||
return key instanceof Array ?
|
|
||||||
key.join(' ')
|
|
||||||
: key },
|
|
||||||
|
|
||||||
// Key getter/generator...
|
// Key getter/generator...
|
||||||
__key__: function(item){
|
__key__: function(item){
|
||||||
return item.id
|
return item.id
|
||||||
// value is a browser -> generate an unique id...
|
|| item.text
|
||||||
// XXX identify via structure...
|
|| this.__id__() },
|
||||||
|| (item.value instanceof Browser
|
|
||||||
&& this.__id__())
|
|
||||||
|| this.__value2key__(item.value) },
|
|
||||||
|
|
||||||
// ID generator...
|
// ID generator...
|
||||||
//
|
//
|
||||||
@ -1533,7 +1520,7 @@ var BaseBrowserPrototype = {
|
|||||||
: [this]) }) }
|
: [this]) }) }
|
||||||
|
|
||||||
// prepare context...
|
// prepare context...
|
||||||
var id = node.id || node.text
|
var id = node.id
|
||||||
var path = context.path = context.path || []
|
var path = context.path = context.path || []
|
||||||
var [inline, p, children] =
|
var [inline, p, children] =
|
||||||
// inline...
|
// inline...
|
||||||
@ -3781,10 +3768,7 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// Base DOM...
|
// Base DOM...
|
||||||
var elem = document.createElement('div')
|
var elem = document.createElement('div')
|
||||||
var text = this.__value2key__(
|
var text = item.text
|
||||||
item.value != null ?
|
|
||||||
item.value
|
|
||||||
: item)
|
|
||||||
|
|
||||||
// classes...
|
// classes...
|
||||||
elem.classList.add(...['item']
|
elem.classList.add(...['item']
|
||||||
@ -4206,10 +4190,9 @@ var TextBrowserPrototype = {
|
|||||||
return this.renderNested(null, items, null, null, options)
|
return this.renderNested(null, items, null, null, options)
|
||||||
.join('\n') },
|
.join('\n') },
|
||||||
renderItem: function(item, i, options){
|
renderItem: function(item, i, options){
|
||||||
var value = item.text
|
|
||||||
return item.current ?
|
return item.current ?
|
||||||
`[ ${value} ]`
|
`[ ${ item.text } ]`
|
||||||
: value },
|
: item.text },
|
||||||
renderNested: function(header, children, context, item, options){
|
renderNested: function(header, children, context, item, options){
|
||||||
var that = this
|
var that = this
|
||||||
var nested = children
|
var nested = children
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user