added .options.updateMaxDelay + some docs and notes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-06-30 23:09:06 +03:00
parent 20f78d1393
commit 1023468aa7

View File

@ -871,22 +871,65 @@ var BaseBrowserClassPrototype = {
// carefully + strictly document the result... // carefully + strictly document the result...
var BaseBrowserPrototype = { var BaseBrowserPrototype = {
options: { options: {
// List of sections to make...
//
// default: ['header', 'items', 'footer']
sections: [ sections: [
'header', 'header',
'items', 'items',
'footer', 'footer',
], ],
// If true allows disabled items to be focused...
focusDisabledItems: false, focusDisabledItems: false,
// If true allows focus to shift into header/footer...
//
// XXX needs more work and testing....
allowSecondaySectionFocus: false, allowSecondaySectionFocus: false,
// If true item keys must be unique... // If true item keys must be unique...
uniqueKeys: false, uniqueKeys: false,
// Controls how the disabled sub-tree root elements are skipped...
//
// Can be:
// 'node' - skip only the disabled node (default)
// 'branch' - skip whole branch, i.e. all nested elements.
//
// XXX if this is 'branch' we should also either show all the
// nested elements as disabled or outright disable them,
// otherwise they can still be focused via clicking and other
// means...
//skipDisabledMode: 'node', //skipDisabledMode: 'node',
// Minimum number of milliseconds between updates...
//
// This works in the following manner:
// - for 10 consecutive calls:
// - call (first)
// -> triggered right away
// - call (within timeout)
// -> schedule after timeout
// - call (within timeout)
// -> drop previous scheduled call
// -> schedule after timeout
// - ...
//
// Essentially this prevents more than one call to .update(..)
// within the timeout and more than two calls within a fast call
// sequence...
//
// NOTE: this does not care about the semantics of the .update(..)
// calls it drops (i.e. the arguments passed), only the first
// and last call in sequence get actually called.
// XXX is this correct???
//
// XXX should update handlers of canceled calls also be canceled???
updateTimeout: 30, updateTimeout: 30,
// Sets the maximum time between .update(..) when calling updates
// in sequence...
updateMaxDelay: 200,
// Item templates... // Item templates...
// //
@ -895,7 +938,7 @@ var BaseBrowserPrototype = {
// // Default item template... // // Default item template...
// // // //
// // This will be added to all items, including ones that // // This will be added to all items, including ones that
// // directly match a template... // // directly match another template template...
// '*': <item>, // '*': <item>,
// //
// // Normal item template... // // Normal item template...
@ -3176,7 +3219,12 @@ var BaseBrowserPrototype = {
// //
// XXX calling this on a nested browser should update the whole thing... // XXX calling this on a nested browser should update the whole thing...
// ...can we restore the context via .parent??? // ...can we restore the context via .parent???
// XXX should we force calling update if options are given???
// ...and should full get passed if at least one call in sequence
// got a full=true???
// XXX should we cancel update handlers of delayed calls???
__update_timeout: null, __update_timeout: null,
__update_max_timeout: null,
update: makeEventMethod('update', update: makeEventMethod('update',
function(evt, full, options){ function(evt, full, options){
options = (full && full !== true && full !== false) ? options = (full && full !== true && full !== false) ?
@ -3187,8 +3235,12 @@ var BaseBrowserPrototype = {
: full : full
var timeout = (options || {}).updateTimeout var timeout = (options || {}).updateTimeout
|| this.options.updateTimeout || this.options.updateTimeout
var max_timeout = (options || {}).updateMaxTimeout
|| this.options.updateMaxTimeout
var _update = function(){ var _update = function(){
clearTimeout(this.__update_max_timeout)
delete this.__update_max_timeout
delete this.__update_timeout delete this.__update_timeout
this this
.run(function(){ .run(function(){
@ -3204,8 +3256,11 @@ var BaseBrowserPrototype = {
// first call -> call sync then delay... // first call -> call sync then delay...
} else if(this.__update_timeout == null){ } else if(this.__update_timeout == null){
// call...
_update() _update()
// schedule clear...
this.__update_timeout = setTimeout(function(){ this.__update_timeout = setTimeout(function(){
delete this.__update_max_timeout
delete this.__update_timeout delete this.__update_timeout
}.bind(this), timeout) }.bind(this), timeout)
@ -3213,6 +3268,10 @@ var BaseBrowserPrototype = {
} else { } else {
clearTimeout(this.__update_timeout) clearTimeout(this.__update_timeout)
this.__update_timeout = setTimeout(_update, timeout) this.__update_timeout = setTimeout(_update, timeout)
// force run at max_timeout...
max_timeout
&& this.__update_max_timeout == null
&& (this.__update_max_timeout = setTimeout(_update, max_timeout))
} }
}, },
// we'll retrigger manually... // we'll retrigger manually...