mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
.make(..) now makes the header, next introduce header (as option) to item access and rendering...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7aef4d6537
commit
cf510bf6b3
@ -1180,7 +1180,6 @@ var BaseBrowserPrototype = {
|
|||||||
Object.create(this.options || {}),
|
Object.create(this.options || {}),
|
||||||
options || {})
|
options || {})
|
||||||
|
|
||||||
var items = this.items = []
|
|
||||||
|
|
||||||
// item constructor...
|
// item constructor...
|
||||||
//
|
//
|
||||||
@ -1204,11 +1203,12 @@ var BaseBrowserPrototype = {
|
|||||||
// while the latter stores a list of items.
|
// while the latter stores a list of items.
|
||||||
// ...would be more logical to store the object (i.e. browser/list)
|
// ...would be more logical to store the object (i.e. browser/list)
|
||||||
// directly as the element...
|
// directly as the element...
|
||||||
|
var make_called = false
|
||||||
|
var list = []
|
||||||
|
var ids = new Set()
|
||||||
var keys = options.uniqueKeys ?
|
var keys = options.uniqueKeys ?
|
||||||
new Set()
|
new Set()
|
||||||
: null
|
: null
|
||||||
var ids = new Set()
|
|
||||||
var make_called = false
|
|
||||||
var make = function(value, opts){
|
var make = function(value, opts){
|
||||||
make_called = true
|
make_called = true
|
||||||
|
|
||||||
@ -1277,11 +1277,12 @@ var BaseBrowserPrototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// user extended make...
|
// user extended make...
|
||||||
this.__make__
|
// XXX differentiate this for header and list...
|
||||||
&& this.__make__(item)
|
//this.__make__
|
||||||
|
// && this.__make__(item)
|
||||||
|
|
||||||
// store the item...
|
// store the item...
|
||||||
items.push(item)
|
list.push(item)
|
||||||
ids.add(key)
|
ids.add(key)
|
||||||
|
|
||||||
return make
|
return make
|
||||||
@ -1289,30 +1290,37 @@ var BaseBrowserPrototype = {
|
|||||||
make.__proto__ = Items
|
make.__proto__ = Items
|
||||||
make.dialog = this
|
make.dialog = this
|
||||||
|
|
||||||
// XXX call .__header__(..) if defined...
|
// build the lists...
|
||||||
// ...considering that this is exactly the same as .__list__(..)
|
//* XXX
|
||||||
// might be a good idea to loop through:
|
|
||||||
// [['__header__', header],
|
|
||||||
// ['__items__', items]]
|
|
||||||
// ...might also be good to add some logic to avoid header
|
|
||||||
// rendering every time we call make...
|
|
||||||
/*/ XXX
|
|
||||||
var header this.header = this.__header__ ?
|
|
||||||
[]
|
|
||||||
: null
|
|
||||||
;[...(this.__header__ ?
|
;[...(this.__header__ ?
|
||||||
['__header__', header]
|
[['__header__', 'header']]
|
||||||
: []),
|
: []),
|
||||||
['__items__', items]]
|
['__list__', 'items']]
|
||||||
.forEach(function([method, list]){
|
.forEach(function([method, name]){
|
||||||
// XXX check that this is enough...
|
// setup closure for make(..)...
|
||||||
make.items = list
|
make_called = false
|
||||||
var res = this[method](make, ..)
|
ids = new Set()
|
||||||
...
|
list = make.items = that[name] = []
|
||||||
})
|
|
||||||
//*/
|
|
||||||
|
|
||||||
make.items = items
|
// build list...
|
||||||
|
// XXX check that this is enough...
|
||||||
|
// ...do we index header items???
|
||||||
|
var res = that[method](make,
|
||||||
|
// XXX not sure about this -- revise options handling...
|
||||||
|
options ?
|
||||||
|
Object.assign(
|
||||||
|
Object.create(that.options || {}),
|
||||||
|
options || {})
|
||||||
|
: null)
|
||||||
|
|
||||||
|
// if make was not called use the .__list__(..) return value...
|
||||||
|
that[name] = make_called ?
|
||||||
|
that[name]
|
||||||
|
: res })
|
||||||
|
|
||||||
|
/*/
|
||||||
|
// setup closure for make(..)...
|
||||||
|
list = make.items = this.items = []
|
||||||
// XXX not sure about this -- revise options handling...
|
// XXX not sure about this -- revise options handling...
|
||||||
var res = this.__list__(make,
|
var res = this.__list__(make,
|
||||||
options ?
|
options ?
|
||||||
@ -1324,6 +1332,7 @@ var BaseBrowserPrototype = {
|
|||||||
this.items = make_called ?
|
this.items = make_called ?
|
||||||
this.items
|
this.items
|
||||||
: res
|
: res
|
||||||
|
//*/
|
||||||
|
|
||||||
// reset the index/cache...
|
// reset the index/cache...
|
||||||
var old_index = this.__item_index_cache || {}
|
var old_index = this.__item_index_cache || {}
|
||||||
@ -1333,6 +1342,7 @@ var BaseBrowserPrototype = {
|
|||||||
// NOTE: we are doing this in a separate pass as items can get
|
// NOTE: we are doing this in a separate pass as items can get
|
||||||
// rearranged during the make phase (Items.nest(..) ...),
|
// rearranged during the make phase (Items.nest(..) ...),
|
||||||
// thus avoiding odd duplicate index numbering...
|
// thus avoiding odd duplicate index numbering...
|
||||||
|
// XXX should we also index header???
|
||||||
var index = this.__item_index_cache = this.index
|
var index = this.__item_index_cache = this.index
|
||||||
|
|
||||||
// post process the items...
|
// post process the items...
|
||||||
@ -3438,8 +3448,10 @@ var HTMLBrowserPrototype = {
|
|||||||
// ]
|
// ]
|
||||||
itemButtons: [
|
itemButtons: [
|
||||||
],
|
],
|
||||||
// XXX need to mix these into the header only...
|
// XXX TEST...
|
||||||
headerItemButtons: [
|
headerButtons: [
|
||||||
|
['c', 'collapse: "*"'],
|
||||||
|
['e', 'expand: "*"'],
|
||||||
],
|
],
|
||||||
|
|
||||||
itemTemplate: {
|
itemTemplate: {
|
||||||
@ -3542,6 +3554,18 @@ var HTMLBrowserPrototype = {
|
|||||||
this.__dom = value },
|
this.__dom = value },
|
||||||
|
|
||||||
|
|
||||||
|
// XXX header...
|
||||||
|
// XXX might be a good idea to make this expandable -- show/hide options...
|
||||||
|
__header__: function(make, options){
|
||||||
|
make('CURRENT_PATH', {
|
||||||
|
id: 'current_path',
|
||||||
|
cls: 'path',
|
||||||
|
buttons: (options || {}).headerButtons
|
||||||
|
|| (this.options || {}).headerButtons
|
||||||
|
|| [],
|
||||||
|
}) },
|
||||||
|
|
||||||
|
|
||||||
// Extending query...
|
// Extending query...
|
||||||
//
|
//
|
||||||
// Extended .search(..) to support:
|
// Extended .search(..) to support:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user