added slideshow interval list limit...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-14 16:37:58 +03:00
parent b3e9eb6766
commit f60f051420
2 changed files with 36 additions and 16 deletions

View File

@ -41,6 +41,7 @@ var SlideshowActions = actions.Actions({
'slideshow-looping': 'on',
'slideshow-direction': 'forward',
'slideshow-interval': '3s',
'slideshow-interval-max-count': 7,
'slideshow-intervals': [
'0.2s',
@ -51,17 +52,6 @@ var SlideshowActions = actions.Actions({
],
},
// XXX make interval editable...
// i.e.
// Interval: 3s / -- 3s is editable...
// 0.2 x -- a history of values that can be
// selected w/o closing the dialog
// or can be removed...
// 1 x
// 3 x
// Custom... -- editable/placeholder... 'enter'
// selects value and adds it to
// history...
// XXX BUG: there are still problems with focus...
// to reproduce:
// click on the first option with a mouse...
@ -122,10 +112,34 @@ var SlideshowActions = actions.Actions({
return
}
// list length limit -> add ass is...
// XXX should this take into account crossed out items???
if(that.config['slideshow-interval-max-count']
&& (that.config['slideshow-intervals'].length
>= that.config['slideshow-interval-max-count'])){
that.config['slideshow-interval'] = txt
oo.close()
if(that.toggleSlideshow('?') == 'on'){
o.close()
} else {
o.client.update()
.done(function(){
o.client.select(txt)
})
}
return
}
// add new value and sort list...
that.config['slideshow-intervals']
.push(txt)
that.config['slideshow-intervals']
= that.config['slideshow-intervals']
.unique(Date.str2ms)
.sort(function(a, b){
return Date.str2ms(a) - Date.str2ms(b)
})

View File

@ -45,9 +45,15 @@ Array.prototype.compact = function(){
// return an array with duplicate elements removed...
//
Array.prototype.unique = function(){
Array.prototype.unique = function(normalize){
if(normalize){
var cache = this.map(normalize)
return this.filter(function(e, i, a){ return cache.indexOf(cache[i]) == i })
} else {
return this.filter(function(e, i, a){ return a.indexOf(e) == i })
}
}
// Compare two arrays...