mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
element access and revising the key/id API...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
daf5e96951
commit
b4a9b1c29c
@ -364,6 +364,15 @@ var BaseBrowserPrototype = {
|
|||||||
__list__: function(make, options){
|
__list__: function(make, options){
|
||||||
throw new Error('.__list__(..): Not implemented.') },
|
throw new Error('.__list__(..): Not implemented.') },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// XXX need a better key/path API...
|
||||||
|
//
|
||||||
|
// XXX is this the correct way to handle a key???
|
||||||
|
__value2key__: function(key){
|
||||||
|
return JSON.stringify(key)
|
||||||
|
},
|
||||||
|
|
||||||
// Key getter/generator...
|
// Key getter/generator...
|
||||||
//
|
//
|
||||||
// XXX should these include the path???
|
// XXX should these include the path???
|
||||||
@ -374,7 +383,7 @@ var BaseBrowserPrototype = {
|
|||||||
// XXX identify via structure...
|
// XXX identify via structure...
|
||||||
|| (item.value instanceof Browser
|
|| (item.value instanceof Browser
|
||||||
&& this.__id__())
|
&& this.__id__())
|
||||||
|| JSON.stringify(item.value) },
|
|| this.__value2key__(item.value) },
|
||||||
|
|
||||||
// ID generator...
|
// ID generator...
|
||||||
//
|
//
|
||||||
@ -395,6 +404,7 @@ var BaseBrowserPrototype = {
|
|||||||
+ Date.now() },
|
+ Date.now() },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Make .items...
|
// Make .items...
|
||||||
//
|
//
|
||||||
// .make()
|
// .make()
|
||||||
@ -652,11 +662,62 @@ var BaseBrowserPrototype = {
|
|||||||
|
|
||||||
|
|
||||||
// XXX item API...
|
// XXX item API...
|
||||||
get: function(){},
|
//
|
||||||
set: function(){},
|
// .get()
|
||||||
remove: function(){},
|
// .get(id)
|
||||||
sort: function(){},
|
// .get(index)
|
||||||
splice: function(){},
|
// .get(path)
|
||||||
|
// -> item
|
||||||
|
// -> undefined
|
||||||
|
//
|
||||||
|
get: function(key){
|
||||||
|
key = key == null ? 0 : key
|
||||||
|
|
||||||
|
// index...
|
||||||
|
if(typeof(key) == typeof(123)){
|
||||||
|
// XXX need to account for nesting browsers and groups...
|
||||||
|
throw new Error('Not implemented.')
|
||||||
|
|
||||||
|
// key...
|
||||||
|
// XXX account for paths...
|
||||||
|
} else {
|
||||||
|
// XXX
|
||||||
|
var k = this.__value2key__(key)
|
||||||
|
|
||||||
|
// direct match...
|
||||||
|
if(k in this.item_index){
|
||||||
|
return this.item_index[k]
|
||||||
|
}
|
||||||
|
|
||||||
|
// query nested...
|
||||||
|
var nested = Object.values(this.item_index)
|
||||||
|
.filter(function(e){
|
||||||
|
return e.sublist instanceof Browser })
|
||||||
|
while(nested.length > 0){
|
||||||
|
var n = nested.shift().sublist
|
||||||
|
var res = n.get(key)
|
||||||
|
if(res !== undefined){
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// .find(id)
|
||||||
|
// .find(index)
|
||||||
|
// .find(path)
|
||||||
|
// .find(query)
|
||||||
|
// -> list
|
||||||
|
//
|
||||||
|
find: function(){
|
||||||
|
},
|
||||||
|
|
||||||
|
// XXX do we need edit ability here?
|
||||||
|
// i.e. .set(..), .remove(..), .sort(..), ...
|
||||||
|
// ...if we are going to implement editing then we'll need to
|
||||||
|
// callback the user code or update the user state...
|
||||||
|
|
||||||
|
|
||||||
// Events...
|
// Events...
|
||||||
@ -1091,7 +1152,7 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// Base DOM...
|
// Base DOM...
|
||||||
var elem = document.createElement('div')
|
var elem = document.createElement('div')
|
||||||
var text = JSON.stringify(item.value || item)
|
var text = this.__value2key__(item.value || item)
|
||||||
|
|
||||||
// classes...
|
// classes...
|
||||||
elem.classList.add(...['item']
|
elem.classList.add(...['item']
|
||||||
@ -1190,13 +1251,12 @@ var BrowserPrototype = {
|
|||||||
// XXX do we use jQuery event handling or vanilla?
|
// XXX do we use jQuery event handling or vanilla?
|
||||||
// ...feels like jQuery here wins as it provides a far simpler
|
// ...feels like jQuery here wins as it provides a far simpler
|
||||||
// API + it's a not time critical area...
|
// API + it's a not time critical area...
|
||||||
open: function(func){
|
//open: function(func){},
|
||||||
},
|
|
||||||
|
|
||||||
filter: function(){},
|
//filter: function(){},
|
||||||
|
|
||||||
select: function(){},
|
//select: function(){},
|
||||||
get: function(){},
|
//get: function(){},
|
||||||
//focus: function(){},
|
//focus: function(){},
|
||||||
|
|
||||||
// Navigation...
|
// Navigation...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user