cloud browse working...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-06-01 21:39:32 +03:00
parent 5ca94a26f6
commit 5088530227
2 changed files with 47 additions and 32 deletions

View File

@ -1059,13 +1059,13 @@ var WidgetTestActions = actions.Actions({
}) })
})], })],
testTagCloud: ['Test/Demo cloud dialog...', testBrowseCloud: ['Test/Demo cloud dialog...',
makeUIDialog(function(){ makeUIDialog(function(){
var actions = this var actions = this
console.log('>>> args:', [].slice.call(arguments)) console.log('>>> args:', [].slice.call(arguments))
var res = browse.makeLister(null, function(path, make){ return browse.makeLister(null, function(path, make){
var that = this var that = this
var words = 'Lorem ipsum dolor sit amet, audiam sensibus ' var words = 'Lorem ipsum dolor sit amet, audiam sensibus '
@ -1094,17 +1094,14 @@ var WidgetTestActions = actions.Actions({
// on sync, but for async dialogs this will align // on sync, but for async dialogs this will align
// the selected field correctly. // the selected field correctly.
make.done() make.done()
}, {
cloudView: true
}) })
// NOTE: this is not a dialog event, it is defined by the // NOTE: this is not a dialog event, it is defined by the
// container to notify us that we are closing... // container to notify us that we are closing...
.on('close', function(){ .on('close', function(){
console.log('Dialog closing...') console.log('Dialog closing...')
}) })
res.dom
.addClass('cloud-view')
return res
})], })],
// XXX make this a toggler.... // XXX make this a toggler....

View File

@ -66,6 +66,17 @@ function makeBrowserMaker(constructor){
} }
function makeSimpleAction(direction){
return function(elem){
if(elem != null){
this.select(elem)
}
this.navigate(direction)
return this
}
}
/*********************************************************************/ /*********************************************************************/
@ -124,7 +135,7 @@ var BrowserClassPrototype = {
// Construct the dom... // Construct the dom...
make: function(obj, options){ make: function(obj, options){
var browser = $('<div>') var browser = $('<div>')
.addClass('browse-widget') .addClass('browse-widget '+ ((options.cloudView || false) ? 'cloud-view' : ''))
// make thie widget focusable... // make thie widget focusable...
// NOTE: tabindex 0 means automatic tab indexing and -1 means // NOTE: tabindex 0 means automatic tab indexing and -1 means
// focusable bot not tabable... // focusable bot not tabable...
@ -281,6 +292,9 @@ var BrowserPrototype = {
// This is mainly used for flat list selectors. // This is mainly used for flat list selectors.
flat: false, flat: false,
// If set this will switch the browse dialog into cloud mode.
cloudView: false,
// List of events that will not get propagated outside the browser... // List of events that will not get propagated outside the browser...
// //
// NOTE: these are local events defined on the widget, so it // NOTE: these are local events defined on the widget, so it
@ -440,11 +454,11 @@ var BrowserPrototype = {
Up: 'up!', Up: 'up!',
Down: 'down!', Down: 'down!',
Left: { Left: {
default: 'pop!', default: 'left!',
ctrl: 'update!: "/"', ctrl: 'update!: "/"',
}, },
Backspace: 'Left', Backspace: 'Left',
Right: 'push', Right: 'right',
P: 'push', P: 'push',
// XXX // XXX
@ -529,6 +543,18 @@ var BrowserPrototype = {
this.options.flat = value this.options.flat = value
}, },
get cloud(){
return this.dom.hasClass('cloud-view') || this.options.cloudView
},
set cloud(value){
if(value){
this.dom.addClass('cloud-view')
} else {
this.dom.removeClass('cloud-view')
}
this.options.cloudView = value
},
// XXX should these set both the options and dom??? // XXX should these set both the options and dom???
get traversable(){ get traversable(){
return !this.dom.hasClass('not-traversable') && this.options.traversable return !this.dom.hasClass('not-traversable') && this.options.traversable
@ -1722,36 +1748,28 @@ var BrowserPrototype = {
// fall back to select... // fall back to select...
: this.select(action, filtering) : this.select(action, filtering)
}, },
// shorthand actions...
next: makeSimpleAction('next'),
prev: makeSimpleAction('prev'),
// Select next/prev element... up: makeSimpleAction('up'),
next: function(elem){ down: makeSimpleAction('down'),
left: function(elem){
if(elem != null){ if(elem != null){
this.select(elem) this.select(elem)
} }
this.navigate('next') return this.cloud ?
return this this.navigate('prev')
: this.pop()
}, },
prev: function(elem){ right: function(elem){
if(elem != null){ if(elem != null){
this.select(elem) this.select(elem)
} }
this.navigate('prev') return this.cloud ?
return this this.navigate('next')
}, : this.push()
up: function(elem){
if(elem != null){
this.select(elem)
}
this.navigate('up')
return this
},
down: function(elem){
if(elem != null){
this.select(elem)
}
this.navigate('down')
return this
}, },