mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
refactored event bubbling mechanics...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d213f26aeb
commit
db4735f409
@ -203,7 +203,7 @@ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, br
|
|||||||
'option 7',
|
'option 7',
|
||||||
],
|
],
|
||||||
|
|
||||||
fullpathedit: false,
|
fullPathEdit: false,
|
||||||
traversable: false,
|
traversable: false,
|
||||||
flat: true,
|
flat: true,
|
||||||
|
|
||||||
|
|||||||
@ -113,7 +113,7 @@ var BrowserPrototype = {
|
|||||||
|
|
||||||
// Enable/disable full path editing...
|
// Enable/disable full path editing...
|
||||||
// NOTE: as with .filter above, this only affects .startFullPathEdit(..)
|
// NOTE: as with .filter above, this only affects .startFullPathEdit(..)
|
||||||
fullpathedit: true,
|
fullPathEdit: true,
|
||||||
|
|
||||||
// If false will disable traversal...
|
// If false will disable traversal...
|
||||||
// NOTE: if false this will also disable traversal up.
|
// NOTE: if false this will also disable traversal up.
|
||||||
@ -131,6 +131,11 @@ var BrowserPrototype = {
|
|||||||
// elements.
|
// elements.
|
||||||
// This is mainly used for flat list selectors.
|
// This is mainly used for flat list selectors.
|
||||||
flat: false,
|
flat: false,
|
||||||
|
|
||||||
|
// List of events that will not get propagated outside the browser...
|
||||||
|
nonPropagatedEvents: [
|
||||||
|
'open',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// XXX TEST: this should prevent event handler delegation...
|
// XXX TEST: this should prevent event handler delegation...
|
||||||
@ -282,19 +287,18 @@ var BrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// This will pass the Browser instance to .source attribute of the
|
// This will pass the Browser instance to .source attribute of the
|
||||||
// event object triggered.
|
// event object triggered.
|
||||||
|
//
|
||||||
|
// NOTE: event triggered by this will not propagate up.
|
||||||
trigger: function(){
|
trigger: function(){
|
||||||
var args = args2array(arguments)
|
var args = args2array(arguments)
|
||||||
var evt = args.shift()
|
var evt = args.shift()
|
||||||
|
|
||||||
if(typeof(evt) == typeof('str')){
|
if(typeof(evt) == typeof('str')){
|
||||||
evt = {
|
evt = $.Event(evt)
|
||||||
type: evt,
|
|
||||||
source: this,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
evt.source = this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
evt.source = this
|
||||||
|
|
||||||
args.splice(0, 0, evt)
|
args.splice(0, 0, evt)
|
||||||
|
|
||||||
this.dom.trigger.apply(this.dom, args)
|
this.dom.trigger.apply(this.dom, args)
|
||||||
@ -784,7 +788,7 @@ var BrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// XXX should these be a toggle???
|
// XXX should these be a toggle???
|
||||||
startFullPathEdit: function(){
|
startFullPathEdit: function(){
|
||||||
if(this.options.fullpathedit){
|
if(this.options.fullPathEdit){
|
||||||
var browser = this.dom
|
var browser = this.dom
|
||||||
var path = this.strPath
|
var path = this.strPath
|
||||||
var orig = this.selected
|
var orig = this.selected
|
||||||
@ -1353,9 +1357,12 @@ var BrowserPrototype = {
|
|||||||
res = res || this
|
res = res || this
|
||||||
|
|
||||||
// trigger the 'open' events...
|
// trigger the 'open' events...
|
||||||
// NOTE: this will propagate up to the parent...
|
|
||||||
if(elem.length > 0){
|
if(elem.length > 0){
|
||||||
elem.trigger('open', path)
|
// NOTE: this will bubble up to the browser root...
|
||||||
|
elem.trigger({
|
||||||
|
type: 'open',
|
||||||
|
source: this,
|
||||||
|
}, path)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger('open', path)
|
this.trigger('open', path)
|
||||||
@ -1483,6 +1490,9 @@ var BrowserPrototype = {
|
|||||||
// load the initial state...
|
// load the initial state...
|
||||||
// XXX check if this default is correct...
|
// XXX check if this default is correct...
|
||||||
this.update(options.path || this.path)
|
this.update(options.path || this.path)
|
||||||
|
|
||||||
|
this.on(this.options.nonPropagatedEvents.join(''),
|
||||||
|
function(evt){ evt.stopPropagation() })
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1534,7 +1544,7 @@ object.makeConstructor('Browser',
|
|||||||
var ListPrototype = Object.create(BrowserPrototype)
|
var ListPrototype = Object.create(BrowserPrototype)
|
||||||
ListPrototype.options = {
|
ListPrototype.options = {
|
||||||
|
|
||||||
fullpathedit: false,
|
fullPathEdit: false,
|
||||||
traversable: false,
|
traversable: false,
|
||||||
flat: true,
|
flat: true,
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user