mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-26 13:01:58 +00:00
added ref to widget controller into the widget dom...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d11bf935d3
commit
ecb1458f93
@ -625,7 +625,7 @@ module.MetaActions = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Same as .inlineMmixin(..) but isolates a mixin in a seporate object
|
// 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){
|
mixin: function(from, all, descriptors, all_attr_types){
|
||||||
var proto = Object.create(this.__proto__)
|
var proto = Object.create(this.__proto__)
|
||||||
|
|||||||
@ -91,7 +91,7 @@ var BrowserClassPrototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Construct the dom...
|
// Construct the dom...
|
||||||
make: function(options){
|
make: function(obj, options){
|
||||||
var browser = $('<div>')
|
var browser = $('<div>')
|
||||||
.addClass('browse-widget')
|
.addClass('browse-widget')
|
||||||
// make thie widget focusable...
|
// make thie widget focusable...
|
||||||
@ -137,6 +137,11 @@ var BrowserClassPrototype = {
|
|||||||
.append($('<div>')
|
.append($('<div>')
|
||||||
.addClass('v-block list'))
|
.addClass('v-block list'))
|
||||||
|
|
||||||
|
// XXX make this part of the framework...
|
||||||
|
if(obj){
|
||||||
|
browser.data('widget-controller', obj)
|
||||||
|
}
|
||||||
|
|
||||||
return browser
|
return browser
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ var widget = require('./widget')
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
var DrawerClassPrototype = {
|
var DrawerClassPrototype = {
|
||||||
make: function(client, options){
|
make: function(obj, client, options){
|
||||||
var that = this
|
var that = this
|
||||||
var overlay = $('<div>')
|
var overlay = $('<div>')
|
||||||
.addClass('drawer-widget')
|
.addClass('drawer-widget')
|
||||||
@ -35,6 +35,11 @@ var DrawerClassPrototype = {
|
|||||||
overlay.attr('tabindex', 0)
|
overlay.attr('tabindex', 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX make this part of the framework...
|
||||||
|
if(obj){
|
||||||
|
overlay.data('widget-controller', obj)
|
||||||
|
}
|
||||||
|
|
||||||
return overlay
|
return overlay
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ var widget = require('./widget')
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
var OverlayClassPrototype = {
|
var OverlayClassPrototype = {
|
||||||
make: function(client, options){
|
make: function(obj, client, options){
|
||||||
var that = this
|
var that = this
|
||||||
var overlay = $('<div>')
|
var overlay = $('<div>')
|
||||||
.addClass('overlay-widget')
|
.addClass('overlay-widget')
|
||||||
@ -35,6 +35,11 @@ var OverlayClassPrototype = {
|
|||||||
overlay.attr('tabindex', 0)
|
overlay.attr('tabindex', 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX make this part of the framework...
|
||||||
|
if(obj){
|
||||||
|
overlay.data('widget-controller', obj)
|
||||||
|
}
|
||||||
|
|
||||||
return overlay
|
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 : */
|
* vim:set ts=4 sw=4 : */
|
||||||
return module })
|
return module })
|
||||||
|
|||||||
@ -52,7 +52,7 @@ function(){
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
var WidgetClassPrototype = {
|
var WidgetClassPrototype = {
|
||||||
make: function(client, options){
|
make: function(obj, client, options){
|
||||||
console.error('Widget must define a .make method.')
|
console.error('Widget must define a .make method.')
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ var WidgetPrototype = {
|
|||||||
|
|
||||||
// build the dom...
|
// build the dom...
|
||||||
if(this.constructor.make){
|
if(this.constructor.make){
|
||||||
this.dom = this.constructor.make(options)
|
this.dom = this.constructor.make(this, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX do we do this here???
|
// XXX do we do this here???
|
||||||
@ -172,7 +172,7 @@ var ContainerPrototype = {
|
|||||||
// build the dom...
|
// build the dom...
|
||||||
if(this.constructor.make){
|
if(this.constructor.make){
|
||||||
this.dom = this.constructor
|
this.dom = this.constructor
|
||||||
.make(client.dom || client, options)
|
.make(this, client.dom || client, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add keyboard handler...
|
// add keyboard handler...
|
||||||
|
|||||||
@ -2314,6 +2314,36 @@ var drawer = require('lib/widget/drawer')
|
|||||||
// scenario:
|
// scenario:
|
||||||
// - an action is run while a menu runs a state changing action
|
// - an action is run while a menu runs a state changing action
|
||||||
// - state restoration will overwrite the effects fo the BG 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){
|
var makeActionLister = function(list, filter, pre_order){
|
||||||
pre_order = typeof(filter) == typeof(true) ? filter : pre_order
|
pre_order = typeof(filter) == typeof(true) ? filter : pre_order
|
||||||
filter = typeof(filter) == typeof(true) ? null : filter
|
filter = typeof(filter) == typeof(true) ? null : filter
|
||||||
@ -2341,6 +2371,9 @@ var makeActionLister = function(list, filter, pre_order){
|
|||||||
if(k.slice(-1) == '*'){
|
if(k.slice(-1) == '*'){
|
||||||
actions[k] = function(){
|
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)
|
var a = Object.create(that)
|
||||||
a.preventClosing = function(){
|
a.preventClosing = function(){
|
||||||
closingPrevented = true
|
closingPrevented = true
|
||||||
@ -2364,6 +2397,9 @@ var makeActionLister = function(list, filter, pre_order){
|
|||||||
} else {
|
} else {
|
||||||
actions[k] = function(){
|
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)
|
var a = Object.create(that)
|
||||||
a.preventClosing = function(){
|
a.preventClosing = function(){
|
||||||
closingPrevented = true
|
closingPrevented = true
|
||||||
@ -2403,6 +2439,11 @@ var makeActionLister = function(list, filter, pre_order){
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ActionTreeActions = actions.Actions({
|
var ActionTreeActions = actions.Actions({
|
||||||
|
// XXX move this to a generic modal overlay feature...
|
||||||
|
getOverlay: ['Interface/Get overlay object',
|
||||||
|
function(){
|
||||||
|
}],
|
||||||
|
|
||||||
browseActions: ['Interface/Browse actions',
|
browseActions: ['Interface/Browse actions',
|
||||||
makeActionLister(browse.makePathList, true)],
|
makeActionLister(browse.makePathList, true)],
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user