mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
the sub-context experiment finally working... still thinking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
16ecebb1c0
commit
0ead526ea9
@ -934,11 +934,11 @@ var ExampleUIActions = actions.Actions({
|
||||
return that.features.features.length })
|
||||
|
||||
make.field('A', 'B')
|
||||
make.field.field('C', 'D')
|
||||
make.field.field.field('E', 'F')
|
||||
//make.field.field('C', 'D')
|
||||
//make.field.field.field('E', 'F')
|
||||
make.field.field.field.field('G', 'H')
|
||||
|
||||
//make.field.Toggle('Toggle', 'on')
|
||||
make.field.Toggle('Toggle', 'on')
|
||||
|
||||
}, {
|
||||
cls: 'table-view',
|
||||
|
||||
@ -960,15 +960,62 @@ module.Dialogs = core.ImageGridFeatures.Feature({
|
||||
|
||||
// XXX EXPERIMENTAL...
|
||||
//
|
||||
// .makeContext(name[, obj])
|
||||
// .makeContext(name, func[, obj])
|
||||
// Make a nested context...
|
||||
//
|
||||
// Make a nested context object...
|
||||
// .makeSubContext(name[, obj])
|
||||
// -> context
|
||||
//
|
||||
// Make a nested context function...
|
||||
// .makeSubContext(name, func[, obj])
|
||||
// -> context
|
||||
//
|
||||
//
|
||||
// The context inherits from .items / make(..)
|
||||
//
|
||||
// If the context is callable it will be called in the context of make(..)
|
||||
//
|
||||
// If the context is constructed recursively it will return self
|
||||
//
|
||||
//
|
||||
// XXX BUGGY...
|
||||
// XXX move this to browse???
|
||||
// ...there seems to be no way to make this generic...
|
||||
browse.items.makeContext = function(name, obj){
|
||||
}
|
||||
browse.items.makeSubContext = function(name, obj){
|
||||
// arse args...
|
||||
var args = [...arguments].slice(1)
|
||||
var func = args[0] instanceof Function ?
|
||||
args.shift()
|
||||
: null
|
||||
obj = args.shift()
|
||||
|
||||
var n = '__'+ name
|
||||
Object.defineProperty(this, name, {
|
||||
get: function(){
|
||||
var that = this
|
||||
if(!this.hasOwnProperty(n)){
|
||||
// build the context object...
|
||||
var nested =
|
||||
func ?
|
||||
// NOTE: we always call func(..) in the root context...
|
||||
function(){
|
||||
return func.call(that, ...arguments) }
|
||||
: this instanceof Function ?
|
||||
function(){
|
||||
return root.call(this, ...arguments) }
|
||||
: {}
|
||||
nested.__proto__ = this
|
||||
|
||||
// mixin parent/obj...
|
||||
Object.assign(nested,
|
||||
this[n] || obj || {})
|
||||
|
||||
// NOTE: this will prevent constructing a nested context
|
||||
// (see test above)...
|
||||
this[n] = nested[n] = nested
|
||||
}
|
||||
return this[n] },
|
||||
})
|
||||
return this[name] }
|
||||
|
||||
|
||||
|
||||
@ -994,7 +1041,7 @@ browse.items.makeContext = function(name, obj){
|
||||
// ...and should we break the make(..) convention of passing an arg
|
||||
// array for multiple .text blocks, i.e. make([title, value], ...)??
|
||||
//browse.items.Field =
|
||||
browse.items.makeContext('field',
|
||||
browse.items.makeSubContext('field',
|
||||
function(title, value, options){
|
||||
options = options || {}
|
||||
Object.assign(
|
||||
@ -1148,7 +1195,6 @@ function(spec, callback){
|
||||
|
||||
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var EditorActions = actions.Actions({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user