mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-24 20:11:56 +00:00
some cleanup and minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
8e755ded9f
commit
606d151b73
@ -191,7 +191,7 @@ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, b)
|
|||||||
.focus()
|
.focus()
|
||||||
|
|
||||||
|
|
||||||
// Flat list demo...
|
// Custom flat list demo...
|
||||||
f = browser.Browser($('.container.flat'), {
|
f = browser.Browser($('.container.flat'), {
|
||||||
data: [
|
data: [
|
||||||
'option 1',
|
'option 1',
|
||||||
@ -226,7 +226,9 @@ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, b)
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
f = browser.makeList($('.container.flat2'), {
|
|
||||||
|
// Default flat list demo...
|
||||||
|
f2 = browser.makeList($('.container.flat2'), {
|
||||||
'option 1': function(_, p){ console.log('option:', p) },
|
'option 1': function(_, p){ console.log('option:', p) },
|
||||||
'option 2': function(_, p){ console.log('option:', p) },
|
'option 2': function(_, p){ console.log('option:', p) },
|
||||||
'option 3': function(_, p){ console.log('option:', p) },
|
'option 3': function(_, p){ console.log('option:', p) },
|
||||||
|
|||||||
@ -920,42 +920,47 @@ object.makeConstructor('Browser',
|
|||||||
BrowserPrototype)
|
BrowserPrototype)
|
||||||
|
|
||||||
|
|
||||||
// Construct a flat list selector...
|
// Flat list...
|
||||||
//
|
//
|
||||||
// makeList(<elem>, <list>)
|
// This expects a data option set with the following format:
|
||||||
// -> browser
|
// {
|
||||||
|
// <option-text>: <callback>,
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
//
|
// NOTE: this essentially a different default configuration of Browser...
|
||||||
// <list> format:
|
var ListPrototype = Object.create(BrowserPrototype)
|
||||||
// {
|
ListPrototype.options = {
|
||||||
// <text>: <callback>,
|
|
||||||
// ...
|
traversable: false,
|
||||||
// }
|
flat: true,
|
||||||
//
|
|
||||||
//
|
list: function(path, make){
|
||||||
// XXX should this be an object???
|
var that = this
|
||||||
|
return Object.keys(this.options.data)
|
||||||
|
.map(function(k){
|
||||||
|
var e = make(k)
|
||||||
|
.on('open', function(){
|
||||||
|
return that.options.data[k].apply(this, arguments)
|
||||||
|
})
|
||||||
|
|
||||||
|
return k
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ListPrototype.options.__proto__ = BrowserPrototype.options
|
||||||
|
|
||||||
|
var List =
|
||||||
|
module.List =
|
||||||
|
object.makeConstructor('List',
|
||||||
|
BrowserClassPrototype,
|
||||||
|
ListPrototype)
|
||||||
|
|
||||||
|
|
||||||
|
// This is a shorthand for: new List(<elem>, { data: <list> })
|
||||||
var makeList =
|
var makeList =
|
||||||
module.makeList = function(elem, list){
|
module.makeList = function(elem, list){
|
||||||
return browser.Browser(elem, {
|
return List(elem, { data: list })
|
||||||
data: list,
|
|
||||||
|
|
||||||
traversable: false,
|
|
||||||
flat: true,
|
|
||||||
|
|
||||||
list: function(path, make){
|
|
||||||
var that = this
|
|
||||||
return Object.keys(this.options.data)
|
|
||||||
.map(function(k){
|
|
||||||
// make the element...
|
|
||||||
var e = make(k)
|
|
||||||
.on('open', function(){
|
|
||||||
return that.options.data[k].apply(this, arguments)
|
|
||||||
})
|
|
||||||
|
|
||||||
return k
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user