refactoring from elements...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-01-14 21:29:50 +03:00
parent 509924db53
commit 487eb5c167

View File

@ -1087,7 +1087,6 @@ browse.items.makeSubContext('field',
// - a way to define defaults -- global options? // - a way to define defaults -- global options?
// - access to the .app -- should be configurable... // - access to the .app -- should be configurable...
// - default methods .showEditableList(..) / .showList(..) on make(..) // - default methods .showEditableList(..) / .showList(..) on make(..)
// XXX need to make this handle updates correctly...
browse.items.field.Toggle = browse.items.field.Toggle =
function(title, options){ function(title, options){
var that = this var that = this
@ -1100,10 +1099,10 @@ function(title, options){
: args.shift() : args.shift()
options = args.shift() || {} options = args.shift() || {}
// user open handler...
var open = options.open var open = options.open
// toggler default settings... var toggler_defaults =
var toggler_defaults = options.__toggle_setup ? // only setup once...
options.__toggle_setup ?
{} {}
: { : {
__toggler_setup: true, __toggler_setup: true,
@ -1235,12 +1234,11 @@ function(title, options){
// XXX should this also take batch options??? // XXX should this also take batch options???
// XXX need to make this handle updates correctly...
browse.items.batch = browse.items.batch =
function(spec, callback){ function(spec, callback){
var that = this var that = this
// build the fields... // build the fields...
;(spec || []) spec
.forEach(function(field){ .forEach(function(field){
// array... // array...
field instanceof Array ? field instanceof Array ?
@ -1258,6 +1256,8 @@ function(spec, callback){
: that(field) }) : that(field) })
// batch callback... // batch callback...
callback callback
// only setup events once...
&& !spec.__batch_setup
&& this.dialog && this.dialog
.close(function(mode){ .close(function(mode){
// XXX get the field data and pass it to the callback... // XXX get the field data and pass it to the callback...
@ -1278,6 +1278,8 @@ function(spec, callback){
spec, spec,
// XXX is this the right spot for this??? // XXX is this the right spot for this???
mode) }) mode) })
// XXX is this a good way to do this???
spec.__batch_setup = true
return this } return this }