From 2334e0b28e5934516fad78bf258c9fb791d2bf40 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 10 Nov 2016 05:34:15 +0300 Subject: [PATCH] some docs/notes... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-widgets.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index c7e8ee9e..4ffca8a8 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -92,15 +92,25 @@ function(context, cls, data){ .appendTo(context.ribbons.viewer) } +// XXX write docs: +// - cls can be +// - a single class (str) +// - space separated multiple classes (str) +// - list of classes +// - if cfg is not given then cls[0] is used for it +// - parent can be an element, a getter function or null (defaults to viewer) var makeButtonControlsToggler = module.makeButtonControlsToggler = -function(cls, cfg){ +function(cls, cfg, parent){ cls = cls instanceof Array ? cls : cls.split(/\s+/g) cfg = cfg || cls[0] return toggler.Toggler(null, function(){ - return this.ribbons.viewer.find('.'+ cls.join('.')).length > 0 ? 'on' : 'off' }, + parent = parent == null ? this.ribbons.viewer + : parent instanceof Function ? parent.call(this) + : parent + return parent.find('.'+ cls.join('.')).length > 0 ? 'on' : 'off' }, ['off', 'on'], function(state){ if(state == 'on'){