mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 11:50:07 +00:00
added basic event infrastructure (piggybacked off of jQuery)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
74f7eb6b1a
commit
1f6c463760
@ -12,6 +12,16 @@ define(function(require){ var module = {}
|
|||||||
var object = require('../object')
|
var object = require('../object')
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
|
||||||
|
function proxyToDom(name){
|
||||||
|
return function(){
|
||||||
|
this.dom[name].apply(this.dom, arguments)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// NOTE: the widget itself does not need a title, that's the job for
|
// NOTE: the widget itself does not need a title, that's the job for
|
||||||
@ -141,6 +151,21 @@ var BrowserPrototype = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// proxy event api...
|
||||||
|
on: proxyToDom('on'),
|
||||||
|
one: proxyToDom('one'),
|
||||||
|
off: proxyToDom('off'),
|
||||||
|
trigger: proxyToDom('trigger'),
|
||||||
|
bind: proxyToDom('bind'),
|
||||||
|
unbind: proxyToDom('unbind'),
|
||||||
|
deligate: proxyToDom('deligate'),
|
||||||
|
undeligate: proxyToDom('undeligate'),
|
||||||
|
|
||||||
|
// specific events...
|
||||||
|
focus: proxyToDom('focus'),
|
||||||
|
blur: proxyToDom('blur'),
|
||||||
|
|
||||||
|
|
||||||
// XXX should these set both the options and dom???
|
// XXX should these set both the options and dom???
|
||||||
get flat(){
|
get flat(){
|
||||||
return !this.dom.hasClass('flat') || this.options.flat
|
return !this.dom.hasClass('flat') || this.options.flat
|
||||||
@ -193,7 +218,6 @@ var BrowserPrototype = {
|
|||||||
// path due to an error, we need to be able to render the new
|
// path due to an error, we need to be able to render the new
|
||||||
// path both in the path and list sections...
|
// path both in the path and list sections...
|
||||||
// NOTE: current behaviour is not wrong, it just not too flexible...
|
// NOTE: current behaviour is not wrong, it just not too flexible...
|
||||||
// XXX trigger an "update" event...
|
|
||||||
update: function(path){
|
update: function(path){
|
||||||
path = path || this.path
|
path = path || this.path
|
||||||
var browser = this.dom
|
var browser = this.dom
|
||||||
@ -276,6 +300,8 @@ var BrowserPrototype = {
|
|||||||
res.forEach(make)
|
res.forEach(make)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.trigger('update')
|
||||||
|
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -577,7 +603,7 @@ var BrowserPrototype = {
|
|||||||
// NOTE: this uses .filter(..) for string and regexp matching...
|
// NOTE: this uses .filter(..) for string and regexp matching...
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// XXX Q: should this trigger a "select" event???
|
// XXX Q: should this trigger a "deselect" event???
|
||||||
select: function(elem, filtering){
|
select: function(elem, filtering){
|
||||||
var pattern = '.list div:not(.disabled):not(.filtered-out)'
|
var pattern = '.list div:not(.disabled):not(.filtered-out)'
|
||||||
var browser = this.dom
|
var browser = this.dom
|
||||||
@ -675,6 +701,8 @@ var BrowserPrototype = {
|
|||||||
p.scrollTop(S + t - D)
|
p.scrollTop(S + t - D)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.trigger('select', elem)
|
||||||
|
|
||||||
return elem.addClass('selected')
|
return elem.addClass('selected')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -740,12 +768,15 @@ var BrowserPrototype = {
|
|||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
focus: function(){
|
focus: function(){
|
||||||
this.dom.focus()
|
this.dom.focus()
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
// XXX think about the API...
|
// XXX think about the API...
|
||||||
|
// XXX need to check if openable and if not use .push()
|
||||||
// XXX trigger an "open" event...
|
// XXX trigger an "open" event...
|
||||||
action: function(){
|
action: function(){
|
||||||
var elem = this.select('!')
|
var elem = this.select('!')
|
||||||
@ -760,11 +791,26 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
path.push(elem.text())
|
path.push(elem.text())
|
||||||
|
|
||||||
|
/* XXX need to sort out several issues:
|
||||||
|
* - if not openable and not traversable this infinitely recurs...
|
||||||
|
if(this.isOpenable && !this.isOpenable(path)){
|
||||||
|
return this.push()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
var res = this.open(path)
|
var res = this.open(path)
|
||||||
|
|
||||||
|
this.trigger('open', path)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
isOpenable: function(path){
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
// extension methods...
|
// extension methods...
|
||||||
|
|
||||||
// Open action...
|
// Open action...
|
||||||
@ -792,7 +838,7 @@ var BrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// 2) non-interactive:
|
// 2) non-interactive:
|
||||||
// .list(path) -> list
|
// .list(path) -> list
|
||||||
// - .list(..) should return a list
|
// - .list(..) should return an array
|
||||||
// - make should never get called
|
// - make should never get called
|
||||||
// - the returned list will be rendered
|
// - the returned list will be rendered
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user