diff --git a/ui (gen4)/lib/actions.js b/ui (gen4)/lib/actions.js index 2eb043d9..a91b471a 100755 --- a/ui (gen4)/lib/actions.js +++ b/ui (gen4)/lib/actions.js @@ -625,7 +625,7 @@ module.MetaActions = { }, // Same as .inlineMmixin(..) but isolates a mixin in a seporate object - // in the ingeritance chain... + // in the inheritance chain... // mixin: function(from, all, descriptors, all_attr_types){ var proto = Object.create(this.__proto__) diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 9b8ce6ea..9986773f 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -91,7 +91,7 @@ var BrowserClassPrototype = { }, // Construct the dom... - make: function(options){ + make: function(obj, options){ var browser = $('
') .addClass('browse-widget') // make thie widget focusable... @@ -137,6 +137,11 @@ var BrowserClassPrototype = { .append($('
') .addClass('v-block list')) + // XXX make this part of the framework... + if(obj){ + browser.data('widget-controller', obj) + } + return browser }, } diff --git a/ui (gen4)/lib/widget/drawer.js b/ui (gen4)/lib/widget/drawer.js index 9374317f..faf8860d 100755 --- a/ui (gen4)/lib/widget/drawer.js +++ b/ui (gen4)/lib/widget/drawer.js @@ -17,7 +17,7 @@ var widget = require('./widget') /*********************************************************************/ var DrawerClassPrototype = { - make: function(client, options){ + make: function(obj, client, options){ var that = this var overlay = $('
') .addClass('drawer-widget') @@ -35,6 +35,11 @@ var DrawerClassPrototype = { overlay.attr('tabindex', 0) } + // XXX make this part of the framework... + if(obj){ + overlay.data('widget-controller', obj) + } + return overlay }, } diff --git a/ui (gen4)/lib/widget/overlay.js b/ui (gen4)/lib/widget/overlay.js index 193d46b9..b43fc425 100755 --- a/ui (gen4)/lib/widget/overlay.js +++ b/ui (gen4)/lib/widget/overlay.js @@ -17,7 +17,7 @@ var widget = require('./widget') /*********************************************************************/ var OverlayClassPrototype = { - make: function(client, options){ + make: function(obj, client, options){ var that = this var overlay = $('
') .addClass('overlay-widget') @@ -35,6 +35,11 @@ var OverlayClassPrototype = { overlay.attr('tabindex', 0) } + // XXX make this part of the framework... + if(obj){ + overlay.data('widget-controller', obj) + } + return overlay }, } @@ -120,6 +125,23 @@ Overlay.prototype.__proto__ = widget.Container.prototype +// XXX this should return a proxy with a set of extension API... +var getOverlay = +module.getOverlay = function(obj){ + var overlay = $(obj || 'body') + .find('.overlay-widget') + .last() + + if(overlay.length == 0){ + return null + } + + // get the controller... + return overlay.data('widget-controller') +} + + + /********************************************************************** * vim:set ts=4 sw=4 : */ return module }) diff --git a/ui (gen4)/lib/widget/widget.js b/ui (gen4)/lib/widget/widget.js index 23cb774b..48740c35 100755 --- a/ui (gen4)/lib/widget/widget.js +++ b/ui (gen4)/lib/widget/widget.js @@ -52,7 +52,7 @@ function(){ /*********************************************************************/ var WidgetClassPrototype = { - make: function(client, options){ + make: function(obj, client, options){ console.error('Widget must define a .make method.') }, } @@ -102,7 +102,7 @@ var WidgetPrototype = { // build the dom... if(this.constructor.make){ - this.dom = this.constructor.make(options) + this.dom = this.constructor.make(this, options) } // XXX do we do this here??? @@ -172,7 +172,7 @@ var ContainerPrototype = { // build the dom... if(this.constructor.make){ this.dom = this.constructor - .make(client.dom || client, options) + .make(this, client.dom || client, options) } // add keyboard handler... diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js index 1edfc069..3d8f19f4 100755 --- a/ui (gen4)/viewer.js +++ b/ui (gen4)/viewer.js @@ -2314,6 +2314,36 @@ var drawer = require('lib/widget/drawer') // scenario: // - an action is run while a menu runs a state changing action // - state restoration will overwrite the effects fo the BG action +// XXX .preventClosing(..) mechanism needs revision... +// ...might be a better idea to add a permanent action to work with +// modal overlays and to define strict rules under which such overlays +// operate, like: +// - only the top overlay is active and can receive events +// - an overlay is closed on open event +// - an overlay can be prevented from closing only while handling +// an open event +// - an overlay can close itself or the previous overlay during +// its open event +// +// Proposed API: +// getOverlay(context) +// -> overlay object +// -> null +// returns an overlay controller for a given container +// NOTE: if no overlay is open this returns null +// NOTE: this might be implemented as an action. +// NOTE: this returns an object that represents only +// the top overlay +// NOTE: this should either extend the overlay client +// or encapsulate it (preferred), providing a method to access +// it (something like: .client prop or +// .getCleint() method)... +// .preventClosing() +// prevent closing of an overlay after this open event is +// handled +// .close() +// +// var makeActionLister = function(list, filter, pre_order){ pre_order = typeof(filter) == typeof(true) ? filter : pre_order filter = typeof(filter) == typeof(true) ? null : filter @@ -2341,6 +2371,9 @@ var makeActionLister = function(list, filter, pre_order){ if(k.slice(-1) == '*'){ actions[k] = function(){ + // XXX this may cause race conditions as we are + // splitting the state in two and then + // overwriting one... var a = Object.create(that) a.preventClosing = function(){ closingPrevented = true @@ -2364,6 +2397,9 @@ var makeActionLister = function(list, filter, pre_order){ } else { actions[k] = function(){ + // XXX this may cause race conditions as we are + // splitting the state in two and then + // overwriting one... var a = Object.create(that) a.preventClosing = function(){ closingPrevented = true @@ -2403,6 +2439,11 @@ var makeActionLister = function(list, filter, pre_order){ } var ActionTreeActions = actions.Actions({ + // XXX move this to a generic modal overlay feature... + getOverlay: ['Interface/Get overlay object', + function(){ + }], + browseActions: ['Interface/Browse actions', makeActionLister(browse.makePathList, true)],