mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
still experimenting with views/clones...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
495054309f
commit
e037755d0f
@ -490,6 +490,38 @@ object.makeConstructor('BaseItem',
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
var getMixinRoot = function(o, attr){
|
||||||
|
var cur = o
|
||||||
|
while(cur.source
|
||||||
|
&& (!attr
|
||||||
|
|| !cur.hasOwnProperty(attr))){
|
||||||
|
cur = cur.source }
|
||||||
|
return cur }
|
||||||
|
|
||||||
|
var BrowserCloneMixin = {
|
||||||
|
// keep the DOM data in one place (.source)...
|
||||||
|
//
|
||||||
|
// NOTE: this is in contrast to the rest of the props that
|
||||||
|
// are explicitly local...
|
||||||
|
// NOTE: these will affect the source only when .render(..)
|
||||||
|
// is called...
|
||||||
|
get dom(){
|
||||||
|
return getMixinRoot(this, '__dom').dom },
|
||||||
|
set dom(value){
|
||||||
|
getMixinRoot(this, '__dom').dom = value },
|
||||||
|
get container(){
|
||||||
|
return getMixinRoot(this, '__container').container },
|
||||||
|
set container(value){
|
||||||
|
getMixinRoot(this, '__container').container = value },
|
||||||
|
|
||||||
|
end: function(){
|
||||||
|
return this.source },
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Event system parts and helpers...
|
// Event system parts and helpers...
|
||||||
//
|
//
|
||||||
@ -1091,6 +1123,7 @@ var BaseBrowserPrototype = {
|
|||||||
// NOTE: this can't be a map/dict as we need both order manipulation
|
// NOTE: this can't be a map/dict as we need both order manipulation
|
||||||
// and nested structures which would overcomplicate things, as
|
// and nested structures which would overcomplicate things, as
|
||||||
// a compromise we use .index below for item identification.
|
// a compromise we use .index below for item identification.
|
||||||
|
// XXX should we use .hasOwnProperty(..)???
|
||||||
__header: null,
|
__header: null,
|
||||||
get header(){
|
get header(){
|
||||||
this.__header
|
this.__header
|
||||||
@ -1141,7 +1174,6 @@ var BaseBrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// NOTE: .clearCache(true) will yield a state that would require at
|
// NOTE: .clearCache(true) will yield a state that would require at
|
||||||
// least a .update() call to be usable...
|
// least a .update() call to be usable...
|
||||||
// XXX should we use .hasOwnProperty(..)???
|
|
||||||
clearCache: function(title){
|
clearCache: function(title){
|
||||||
if(title == null || title === true){
|
if(title == null || title === true){
|
||||||
Object.keys(this)
|
Object.keys(this)
|
||||||
@ -1157,7 +1189,9 @@ var BaseBrowserPrototype = {
|
|||||||
}.bind(this))
|
}.bind(this))
|
||||||
}
|
}
|
||||||
if(title === true){
|
if(title === true){
|
||||||
|
delete this.__header
|
||||||
delete this.__items
|
delete this.__items
|
||||||
|
delete this.__footer
|
||||||
}
|
}
|
||||||
return this },
|
return this },
|
||||||
|
|
||||||
@ -1185,7 +1219,7 @@ var BaseBrowserPrototype = {
|
|||||||
__item_index_cache: null,
|
__item_index_cache: null,
|
||||||
get index(){
|
get index(){
|
||||||
return (this.__item_index_cache =
|
return (this.__item_index_cache =
|
||||||
this.__item_index_cache
|
(this.hasOwnProperty('__item_index_cache') && this.__item_index_cache)
|
||||||
|| this
|
|| this
|
||||||
.reduce(function(index, e, i, p){
|
.reduce(function(index, e, i, p){
|
||||||
var id = p = p.join('/')
|
var id = p = p.join('/')
|
||||||
@ -3507,57 +3541,31 @@ var BaseBrowserPrototype = {
|
|||||||
// -> reset on parent .make(..)
|
// -> reset on parent .make(..)
|
||||||
// -> re-acquire data (???)
|
// -> re-acquire data (???)
|
||||||
// - take control (optionally), i.e. handle keyboard
|
// - take control (optionally), i.e. handle keyboard
|
||||||
// XXX make all navigation DOM-based... (???)
|
// XXX BUG?: .update(..) from events resolves to the .source...
|
||||||
// ...we can't do this in a trivial way because we could have a
|
// to reproduce:
|
||||||
// partially rendered state...
|
// dialog
|
||||||
// XXX BUG:
|
|
||||||
// // render a part of the dialog...
|
|
||||||
// d = dialog
|
|
||||||
// .clone([7, 8, 9])
|
// .clone([7, 8, 9])
|
||||||
// .update()
|
// .update()
|
||||||
// // XXX this does not restore the dialog...
|
// .focus()
|
||||||
// // would need to
|
// // XXX this will render the base dialog...
|
||||||
// // dialog.dom = d.dom
|
// // ...likely due to that the handler's context
|
||||||
// // ...after each render...
|
// // resolves to the root and not the clone...
|
||||||
// dialog
|
// .disable()
|
||||||
// .update(true)
|
view: function(action, ...args){
|
||||||
// this is due to the fact that we overwrite the .dom in the child
|
|
||||||
// but not in the source...
|
|
||||||
// a simple solution would be to keep all the dom props in one
|
|
||||||
// place...
|
|
||||||
clone: function(action, ...args){
|
|
||||||
var that = this
|
var that = this
|
||||||
// XXX move this out...
|
args = args[0] instanceof Array && args.length == 1 ?
|
||||||
// this can be merged into BaseBrowser or live in a separate mixin...
|
args[0]
|
||||||
var getRoot = function(o, attr){
|
: args
|
||||||
var cur = o
|
// NOTE: for super calls do:
|
||||||
while(cur.source
|
// this.__proto__.<method>.call(this, ...)
|
||||||
&& (!attr
|
return object
|
||||||
|| !cur.hasOwnProperty(attr))){
|
.mixinFlat({
|
||||||
cur = cur.source }
|
|
||||||
return cur }
|
|
||||||
return {
|
|
||||||
__proto__: this,
|
__proto__: this,
|
||||||
source: this,
|
source: this,
|
||||||
|
},
|
||||||
// keep the DOM data in one place...
|
BrowserCloneMixin)
|
||||||
get dom(){
|
.run(function(){
|
||||||
return getRoot(this, '__dom').dom },
|
// XXX how do we handle sections???
|
||||||
set dom(value){
|
|
||||||
getRoot(this, '__dom').dom = value },
|
|
||||||
get container(){
|
|
||||||
return getRoot(this, '__container').container },
|
|
||||||
set container(value){
|
|
||||||
getRoot(this, '__container').container = value },
|
|
||||||
|
|
||||||
// XXX do we need to isolate caches???
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
end: function(){
|
|
||||||
return this.source },
|
|
||||||
|
|
||||||
}.run(function(){
|
|
||||||
// XXX do we need to copy other sections???
|
|
||||||
this.items =
|
this.items =
|
||||||
action instanceof Array ?
|
action instanceof Array ?
|
||||||
action
|
action
|
||||||
@ -3566,6 +3574,8 @@ var BaseBrowserPrototype = {
|
|||||||
: action ?
|
: action ?
|
||||||
that[action](...args)
|
that[action](...args)
|
||||||
: that.items.slice() }) },
|
: that.items.slice() }) },
|
||||||
|
isView: function(){
|
||||||
|
return !!this.source },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4020,7 +4030,8 @@ var HTMLBrowserPrototype = {
|
|||||||
var that = this
|
var that = this
|
||||||
// XXX should this be here on in start event???
|
// XXX should this be here on in start event???
|
||||||
var kb = this.__keyboard_object =
|
var kb = this.__keyboard_object =
|
||||||
this.__keyboard_object
|
(this.hasOwnProperty('__keyboard_object')
|
||||||
|
&& this.__keyboard_object)
|
||||||
|| keyboard.KeyboardWithCSSModes(
|
|| keyboard.KeyboardWithCSSModes(
|
||||||
function(data){
|
function(data){
|
||||||
if(data){
|
if(data){
|
||||||
@ -4032,14 +4043,17 @@ var HTMLBrowserPrototype = {
|
|||||||
function(){ return that.dom })
|
function(){ return that.dom })
|
||||||
return kb },
|
return kb },
|
||||||
// NOTE: this is not designed for direct use...
|
// NOTE: this is not designed for direct use...
|
||||||
|
____keyboard_handler: null,
|
||||||
get __keyboard_handler(){
|
get __keyboard_handler(){
|
||||||
var options = this.options || {}
|
var options = this.options || {}
|
||||||
return (this.____keyboard_handler = this.____keyboard_handler
|
return (this.____keyboard_handler =
|
||||||
|
(this.hasOwnProperty('____keyboard_handler')
|
||||||
|
&& this.____keyboard_handler)
|
||||||
|| keyboard.makePausableKeyboardHandler(
|
|| keyboard.makePausableKeyboardHandler(
|
||||||
this.keyboard,
|
this.keyboard,
|
||||||
function(){
|
function(){
|
||||||
options.keyboardReportUnhandled
|
options.keyboardReportUnhandled
|
||||||
&& console.log('KEY:', ...arguments) },
|
&& console.log('UNHANDLED KEY:', ...arguments) },
|
||||||
this)) },
|
this)) },
|
||||||
|
|
||||||
// Proxy to .keyboard.parseStringHandler(..)
|
// Proxy to .keyboard.parseStringHandler(..)
|
||||||
@ -4058,6 +4072,7 @@ var HTMLBrowserPrototype = {
|
|||||||
// parent element (optional)...
|
// parent element (optional)...
|
||||||
// XXX rename???
|
// XXX rename???
|
||||||
// ... should this be .containerDom or .parentDom???
|
// ... should this be .containerDom or .parentDom???
|
||||||
|
// XXX do we use .hasOwnProperty(..) here???
|
||||||
get container(){
|
get container(){
|
||||||
return this.__container
|
return this.__container
|
||||||
|| (this.__dom ?
|
|| (this.__dom ?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user