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()
|
||||
|
||||
|
||||
// Flat list demo...
|
||||
// Custom flat list demo...
|
||||
f = browser.Browser($('.container.flat'), {
|
||||
data: [
|
||||
'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 2': function(_, p){ console.log('option:', p) },
|
||||
'option 3': function(_, p){ console.log('option:', p) },
|
||||
|
||||
@ -920,24 +920,17 @@ object.makeConstructor('Browser',
|
||||
BrowserPrototype)
|
||||
|
||||
|
||||
// Construct a flat list selector...
|
||||
// Flat list...
|
||||
//
|
||||
// makeList(<elem>, <list>)
|
||||
// -> browser
|
||||
//
|
||||
//
|
||||
// <list> format:
|
||||
// This expects a data option set with the following format:
|
||||
// {
|
||||
// <text>: <callback>,
|
||||
// <option-text>: <callback>,
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
//
|
||||
// XXX should this be an object???
|
||||
var makeList =
|
||||
module.makeList = function(elem, list){
|
||||
return browser.Browser(elem, {
|
||||
data: list,
|
||||
// NOTE: this essentially a different default configuration of Browser...
|
||||
var ListPrototype = Object.create(BrowserPrototype)
|
||||
ListPrototype.options = {
|
||||
|
||||
traversable: false,
|
||||
flat: true,
|
||||
@ -946,7 +939,6 @@ module.makeList = function(elem, list){
|
||||
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)
|
||||
@ -955,7 +947,20 @@ module.makeList = function(elem, list){
|
||||
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 =
|
||||
module.makeList = function(elem, list){
|
||||
return List(elem, { data: list })
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user