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 = []
}
var o = browse.makeList(
null,
Object.keys(this.url_history)
var o = browse.makeLister(null,
function(path, make){
Object.keys(that.url_history)
.reverse()
// NOTE: this might get a little slow for
// very large sets...
.map(function(p){
return !that.checkURLFromHistory(p) ?
'- ' + p
: p
}),
{
// add item buttons...
itemButtons: [
// move to top...
['&diams;',
function(p){
var top = this.filter('*', false).first()
var cur = this.filter('"'+p+'"', false)
.forEach(function(p){
make(p, {disabled: !that.checkURLFromHistory(p) })
.addClass(p == cur ? 'highlighted selected': '')
}) },
// add item buttons...
{ itemButtons: [
// move to top...
['&diams;',
function(p){
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)){
top.before(cur)
that.setTopURLHistory(p)
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)
}
}],
// 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){
removeStriked('open')
@ -485,19 +481,6 @@ var URLHistoryUIActions = actions.Actions({
&& 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
})],
})

View File

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

View File

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

View File

@ -163,28 +163,31 @@ function(actions, list_key, options){
var lst = actions.config[list_key]
lst = lst instanceof Array ? lst : Object.keys(lst)
var list = browse.makeList( null,
lst.concat(new_button ? [ new_button ] : []),
{itemButtons: options.itemButtons || [
// mark for removal...
['&times;',
function(p){
var e = this.filter('"'+p+'"', false)
.toggleClass('strike-out')
var list = browse.makeList(null,
lst.concat(new_button ? [ new_button ] : []),
{
path: options.path,
itemButtons: options.itemButtons || [
// 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)
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)
}
}
}],
// XXX add shift up/down/top/bottom and other buttons (optional)...
]})
} else {
var i = to_remove.indexOf(p)
if(i >= 0){
to_remove.splice(i, 1)
}
}
}],
// XXX add shift up/down/top/bottom and other buttons (optional)...
]
})
// select the new_button item...
.on('select', function(evt, elem){
if(new_button && $(elem).find('.text').text() == new_button){
@ -304,7 +307,6 @@ module.uiContainer = function(func){
// - mark the action as a container
//
// The container will:
// - stop the client's close event from propagating up
// - trigger the client's close event on close
//
// XXX pass options???
@ -313,10 +315,6 @@ module.makeUIContainer = function(make){
return uiContainer(function(){
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...
o.close(function(){ o.client.trigger('close') })
@ -427,10 +425,23 @@ var DialogsActions = actions.Actions({
o && o.focus()
})
})],
// XXX should this use .ribbons.viewer as base???
Drawer: ['- Interface/',
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:
// - dock panels
@ -737,6 +748,7 @@ var WidgetTestActions = actions.Actions({
})
make('do nothing')
.addClass('selected')
make('nested dialog...')
.on('open', function(){
@ -800,8 +812,8 @@ var WidgetTestActions = actions.Actions({
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 BUG: when using this.ribbons.viewer as base some actions leak
// between the two viewers...

View File

@ -299,6 +299,8 @@ var BrowserPrototype = {
'deselect',
//'keydown',
'close',
],
@ -2148,7 +2150,10 @@ var BrowserPrototype = {
}
// 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){
this.on(this.options.nonPropagatedEvents.join(' '),