more cleanup and refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-30 19:59:29 +03:00
parent a2c75dd5be
commit 1560ce647b
5 changed files with 86 additions and 95 deletions

View File

@ -419,52 +419,48 @@ var URLHistoryUIActions = actions.Actions({
to_remove = [] to_remove = []
} }
var o = browse.makeList( var o = browse.makeLister(null,
null, function(path, make){
Object.keys(this.url_history) Object.keys(that.url_history)
.reverse() .reverse()
// NOTE: this might get a little slow for // NOTE: this might get a little slow for
// very large sets... // very large sets...
.map(function(p){ .forEach(function(p){
return !that.checkURLFromHistory(p) ? make(p, {disabled: !that.checkURLFromHistory(p) })
'- ' + p .addClass(p == cur ? 'highlighted selected': '')
: p }) },
}), // add item buttons...
{ { itemButtons: [
// add item buttons... // move to top...
itemButtons: [ ['&diams;',
// move to top... function(p){
['&diams;', var top = this.filter('*', false).first()
function(p){ var cur = this.filter('"'+p+'"', false)
var top = this.filter('*', false).first()
var cur = this.filter('"'+p+'"', false)
console.log('!!!', p) if(!top.is(cur)){
top.before(cur)
that.setTopURLHistory(p)
}
}],
// mark for removal...
['&times;',
function(p){
var e = this.filter('"'+p+'"', false)
.toggleClass('strike-out')
if(!top.is(cur)){ if(e.hasClass('strike-out')){
top.before(cur) to_remove.indexOf(p) < 0
that.setTopURLHistory(p) && to_remove.push(p)
} else {
var i = to_remove.indexOf(p)
if(i >= 0){
to_remove.splice(i, 1)
} }
}], }
// mark for removal... }],
['&times;', ],
function(p){ })
var e = this.filter('"'+p+'"', false)
.toggleClass('strike-out')
if(e.hasClass('strike-out')){
to_remove.indexOf(p) < 0
&& to_remove.push(p)
} else {
var i = to_remove.indexOf(p)
if(i >= 0){
to_remove.splice(i, 1)
}
}
}],
],
})
.open(function(evt, path){ .open(function(evt, path){
removeStriked('open') removeStriked('open')
@ -485,19 +481,6 @@ var URLHistoryUIActions = actions.Actions({
&& parent.focus() && parent.focus()
}) })
/*
Object.keys(this.url_history).reverse().forEach(function(p){
that.checkURLFromHistory(p) || o.filter(p).addClass('disabled')
})
*/
// select and highlight current path...
setTimeout(function(){
cur && o
.select('"'+ cur +'"')
.addClass('highlighted')
}, 0)
return o return o
})], })],
}) })

View File

@ -405,7 +405,7 @@ var SortUIActions = actions.Actions({
that.config['default-sort-order'] == 'reverse') that.config['default-sort-order'] == 'reverse')
lister.parent.close() lister.parent.close()
}) })
.addClass(mode == cur ? 'highlighted' : '') .addClass(mode == cur ? 'highlighted selected' : '')
.addClass(mode == dfl ? 'default' : '') .addClass(mode == dfl ? 'default' : '')
}) })
@ -433,9 +433,6 @@ var SortUIActions = actions.Actions({
.addClass('item-value-view') .addClass('item-value-view')
}) })
// select the current order...
o.select('"' + this.toggleImageSort('?') + '"')
return o return o
})] })]
}) })

View File

@ -59,6 +59,7 @@ var SlideshowActions = actions.Actions({
var button_text = 'New...' var button_text = 'New...'
var o = widgets.makeConfigListEditor(that, 'slideshow-intervals', { var o = widgets.makeConfigListEditor(that, 'slideshow-intervals', {
path: that.config['slideshow-interval'],
new_button: button_text, new_button: button_text,
length_limit: that.config['slideshow-interval-max-count'], length_limit: that.config['slideshow-interval-max-count'],
check: Date.str2ms, check: Date.str2ms,
@ -77,12 +78,6 @@ var SlideshowActions = actions.Actions({
// reset the timer if it was not suspended outside... // reset the timer if it was not suspended outside...
suspended_timer || that.resetSlideshowTimer() suspended_timer || that.resetSlideshowTimer()
}) })
// XXX HACK: without a setTimeout(..) this will not select...
setTimeout(function(){
o.select(that.config['slideshow-interval'])
}, 0)
return o return o
})], })],
// XXX BUG: there are still problems with focus... // XXX BUG: there are still problems with focus...
@ -152,6 +147,7 @@ var SlideshowActions = actions.Actions({
that.toggleSlideshow() that.toggleSlideshow()
o.parent.close() o.parent.close()
}) })
.addClass('selected')
}) })
.on('close', function(){ .on('close', function(){
// reset the timer if it was not suspended outside... // reset the timer if it was not suspended outside...
@ -160,8 +156,6 @@ var SlideshowActions = actions.Actions({
o.dom.addClass('metadata-view tail-action') o.dom.addClass('metadata-view tail-action')
setTimeout(function(){ o.select(-1) }, 0)
return o return o
})], })],

View File

@ -163,28 +163,31 @@ function(actions, list_key, options){
var lst = actions.config[list_key] var lst = actions.config[list_key]
lst = lst instanceof Array ? lst : Object.keys(lst) lst = lst instanceof Array ? lst : Object.keys(lst)
var list = browse.makeList( null, var list = browse.makeList(null,
lst.concat(new_button ? [ new_button ] : []), lst.concat(new_button ? [ new_button ] : []),
{itemButtons: options.itemButtons || [ {
// mark for removal... path: options.path,
['&times;', itemButtons: options.itemButtons || [
function(p){ // mark for removal...
var e = this.filter('"'+p+'"', false) ['&times;',
.toggleClass('strike-out') function(p){
var e = this.filter('"'+p+'"', false)
.toggleClass('strike-out')
if(e.hasClass('strike-out')){ if(e.hasClass('strike-out')){
to_remove.indexOf(p) < 0 to_remove.indexOf(p) < 0
&& to_remove.push(p) && to_remove.push(p)
} else { } else {
var i = to_remove.indexOf(p) var i = to_remove.indexOf(p)
if(i >= 0){ if(i >= 0){
to_remove.splice(i, 1) to_remove.splice(i, 1)
} }
} }
}], }],
// XXX add shift up/down/top/bottom and other buttons (optional)... // XXX add shift up/down/top/bottom and other buttons (optional)...
]}) ]
})
// select the new_button item... // select the new_button item...
.on('select', function(evt, elem){ .on('select', function(evt, elem){
if(new_button && $(elem).find('.text').text() == new_button){ if(new_button && $(elem).find('.text').text() == new_button){
@ -304,7 +307,6 @@ module.uiContainer = function(func){
// - mark the action as a container // - mark the action as a container
// //
// The container will: // The container will:
// - stop the client's close event from propagating up
// - trigger the client's close event on close // - trigger the client's close event on close
// //
// XXX pass options??? // XXX pass options???
@ -313,10 +315,6 @@ module.makeUIContainer = function(make){
return uiContainer(function(){ return uiContainer(function(){
var o = make.apply(this, arguments) var o = make.apply(this, arguments)
// prevent the client event from bubbling up...
// XXX is this the right way to go???
o.client.on('close', function(evt){ evt.stopPropagation() })
// notify the client that we are closing... // notify the client that we are closing...
o.close(function(){ o.client.trigger('close') }) o.close(function(){ o.client.trigger('close') })
@ -427,10 +425,23 @@ var DialogsActions = actions.Actions({
o && o.focus() o && o.focus()
}) })
})], })],
// XXX should this use .ribbons.viewer as base???
Drawer: ['- Interface/', Drawer: ['- Interface/',
makeUIContainer(function(dialog, options){ makeUIContainer(function(dialog, options){
return drawer.Drawer($('body'), dialog, options) })], var parent = (options || {}).parentElement
parent = parent ? $(parent) : this.ribbons.viewer
var d = drawer.Drawer(
parent,
dialog,
options)
// we need to clear other ui elements, like the status bar...
// XXX is this the right way to go???
d.dom.css({
'z-index': 5000,
})
return d
})],
// XXX need to: // XXX need to:
// - dock panels // - dock panels
@ -737,6 +748,7 @@ var WidgetTestActions = actions.Actions({
}) })
make('do nothing') make('do nothing')
.addClass('selected')
make('nested dialog...') make('nested dialog...')
.on('open', function(){ .on('open', function(){
@ -800,8 +812,8 @@ var WidgetTestActions = actions.Actions({
return o return o
}], }],
// XXX needs cleanup...
// XXX need a clean constructor strategy -- this and ui.js are a mess... // XXX migrate to the dialog framework...
// XXX use this.ribbons.viewer as base... // XXX use this.ribbons.viewer as base...
// XXX BUG: when using this.ribbons.viewer as base some actions leak // XXX BUG: when using this.ribbons.viewer as base some actions leak
// between the two viewers... // between the two viewers...

View File

@ -299,6 +299,8 @@ var BrowserPrototype = {
'deselect', 'deselect',
//'keydown', //'keydown',
'close',
], ],
@ -2148,7 +2150,10 @@ var BrowserPrototype = {
} }
// load the initial state... // load the initial state...
this.update(options.path || this.path || '/') //this.update(options.path || this.path || '/')
// XXX is this the right way to go???
setTimeout(function(){
that.update(options.path || that.path || '/') }, 0)
if(this.options.nonPropagatedEvents != null){ if(this.options.nonPropagatedEvents != null){
this.on(this.options.nonPropagatedEvents.join(' '), this.on(this.options.nonPropagatedEvents.join(' '),