From 3c9b552c39b3567491214ba81aa9e6e83ec3326d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 14 Nov 2019 06:36:14 +0300 Subject: [PATCH] minor tweaks and fixes... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-slideshow.js | 97 ++++++------------------------ ui (gen4)/features/ui-widgets.js | 51 ++++++++++------ 2 files changed, 51 insertions(+), 97 deletions(-) diff --git a/ui (gen4)/features/ui-slideshow.js b/ui (gen4)/features/ui-slideshow.js index 51f52a10..32078190 100755 --- a/ui (gen4)/features/ui-slideshow.js +++ b/ui (gen4)/features/ui-slideshow.js @@ -36,10 +36,6 @@ var SlideshowActions = actions.Actions({ 'slideshow-looping': 'on', 'slideshow-direction': 'forward', 'slideshow-interval': '3s', - 'slideshow-interval-max-count': 7, - - 'slideshow-pause-on-blur': true, - 'slideshow-intervals': [ '0.2s', '1s', @@ -47,6 +43,10 @@ var SlideshowActions = actions.Actions({ '5s', '7s', ], + 'slideshow-interval-max-count': 7, + + 'slideshow-pause-on-blur': true, + }, toggleSlideshow: ['Slideshow/$Slideshow quick toggle', @@ -133,62 +133,11 @@ var SlideshowActions = actions.Actions({ slideshowDialog: ['Slideshow/Slideshow...', widgets.makeUIDialog(function(){ var that = this - - // suspend the timer if it's not suspended outside... - var suspended_timer = this.__slideshow_timer == 'suspended' - suspended_timer || this.suspendSlideshowTimer() - - // XXX might be a good idea to make this generic... - var _makeToggleHandler = function(o, toggler){ - return function(){ - var txt = $(this).find('.text').first().text() - that[toggler]() - o.update() - .then(function(){ o.select(txt) }) - that.toggleSlideshow('?') == 'on' - && o.close() - } - } - - return browse.makeLister(null, function(path, make){ - make(['$Interval: ', - function(){ return that.config['slideshow-interval'] }]) - .on('open', function(){ - that.slideshowIntervalDialog(make.dialog) }) - - make(['$Direction: ', - function(){ return that.config['slideshow-direction'] }]) - .on('open', _makeToggleHandler(make.dialog, 'toggleSlideshowDirection')) - make(['$Looping: ', - function(){ return that.config['slideshow-looping'] }]) - .on('open', _makeToggleHandler(make.dialog, 'toggleSlideshowLooping')) - - // Start/stop... - make([function(){ - return that.toggleSlideshow('?') == 'on' ? '$Stop' : '$Start' }]) - .on('open', function(){ - that.toggleSlideshow() - make.dialog.close() - }) - }, - { - path: that.toggleSlideshow('?') == 'on' ? 'Stop' : 'Start', - cls: 'table-view tail-action', - }) - .on('close', function(){ - // reset the timer if it was not suspended outside... - suspended_timer - || that.resetSlideshowTimer() - }) - })], - slideshowDialog2: ['Slideshow/Slideshow (new)...', - widgets.makeUIDialog(function(){ - var that = this + var spec // suspend the timer if it's not suspended outside... var suspended_timer = this.__slideshow_timer == 'suspended' suspended_timer || this.suspendSlideshowTimer() - var spec return browse.makeLister(null, function(path, make){ @@ -196,35 +145,22 @@ var SlideshowActions = actions.Actions({ that.makeEditor(make, spec = spec || [ - // XXX move this to the interval editor... { title: '$Interval: ', type: 'configToggle', key: 'slideshow-interval', values_key: 'slideshow-intervals', - /* XXX + nonstrict: true, list: function(cur, set){ - this.slideshowIntervalDialog() - .close(function(){ - // XXX this works only once per dialog instance... - set() }) }, }, - /*/ - values_key: 'slideshow-intervals', - list_editable: true, - list: { - length_limit: that.config['slideshow-interval-max-count'], - check: Date.str2ms, - unique: Date.str2ms, - normalize: function(e){ return e.trim() }, - sort: function(a, b){ - return Date.str2ms(a) - Date.str2ms(b) }, - sortable: false, }, }, - //*/ + this.slideshowIntervalDialog() + .close(function(){ set() }) }, }, { title: '$Direction: ', type: 'toggler', - toggler: 'toggleSlideshowDirection', }, + toggler: 'toggleSlideshowDirection', + live_update: true, }, { title: '$Looping: ', type: 'toggler', - toggler: 'toggleSlideshowLooping', }, ]) + toggler: 'toggleSlideshowLooping', + live_update: true, }, ]) // Start/stop... make([function(){ return that.toggleSlideshow('?') == 'on' ? '$Stop' : '$Start' }], @@ -234,8 +170,8 @@ var SlideshowActions = actions.Actions({ },{ path: that.toggleSlideshow('?') == 'on' ? 'Stop' : 'Start', cls: 'table-view tail-action', + // reset the timer if it was not suspended outside... close: function(){ - // reset the timer if it was not suspended outside... suspended_timer || that.resetSlideshowTimer() }, }) })], @@ -258,7 +194,7 @@ var SlideshowActions = actions.Actions({ // settings... // NOTE: these are disabled as they are repeated in the slideshow dialog... - // XXX do we need both these and the dialog??? + // XXX do we need both this and .slideshowDialog(???)??? slideshowIntervalDialog: ['- Slideshow/Slideshow $interval...', widgets.makeUIDialog(function(parent){ var that = this @@ -290,8 +226,7 @@ var SlideshowActions = actions.Actions({ parent.update() .then(function(){ txt != '' - && parent.select(txt) - }) + && parent.select(txt) }) } }) return dialog @@ -304,6 +239,7 @@ var SlideshowActions = actions.Actions({ toggleSlideshowPauseOnBlur: ['Interface|Slideshow/Slideshow pause on app blur', core.makeConfigToggler('slideshow-pause-on-blur', ['on', 'off'])], + // XXX make these stack-like... resetSlideshowTimer: ['- Slideshow/Reset slideshow timer', function(){ this.__slideshow_timer && this.toggleSlideshow('on') }], @@ -314,6 +250,7 @@ var SlideshowActions = actions.Actions({ this.__slideshow_timer = 'suspended' } }], + toggleSlideshowTimer: ['Slideshow/Pause or resume running slideshow', core.doc` diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index c62668f8..1e64931f 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -972,24 +972,25 @@ var EditorActions = actions.Actions({ // NOTE: we are not supporting aliases here as we need to pass strings // as-is into .makeEditorBlock(..)'s spec to be able to create things // like '---' ->
and other stuff... + // + // XXX should we support dialog.close(..)'s reject mode??? __editor_fields__: { // Generic field... // // options format: // { + // type: , + // // // NOTE: if this is not set then the id is used... // title: , // - // // // value... // // // value: | , // - // // // XXX not implemented... // doc: | , // - // // ... // } // @@ -1019,6 +1020,9 @@ var EditorActions = actions.Actions({ // { // values: | , // + // // if true this will only alow setting .value from .values... + // nonstrict: , + // // // XXX not implemented... // value_editable: , // @@ -1053,15 +1057,12 @@ var EditorActions = actions.Actions({ type: 'toggle', open: function(evt){ - var values = options.values instanceof Function ? + var getValues = function(){ + return options.values instanceof Function ? options.values.call(actions) : options.values ? options.values - : ['off', 'on'] - - var elem = $(this).find('.text').last() - var current = elem.text() - + : ['off', 'on'] } var set = function(v){ // get current value... v = arguments.length > 0 ? @@ -1070,18 +1071,35 @@ var EditorActions = actions.Actions({ options.value.call(actions) : options.value // normalize... - v = values.includes(v) ? - v - : values[0] + // NOTE: we are re-getting the values here + // as it can get updated in options.list(..) + // or via options.values(..)... + if(!options.nonstrict){ + var values = getValues() + v = values.includes(v) ? + v + : values[0] } // update the value... - options.value instanceof Function ? - (v = options.value.call(actions, v)) - : (options.value = v) + // NOTE: we update the local value iff set(..) + // got an explicit value argument... + // calling set(..) will not store anything, + // just update the current state, either to + // the already stored value or to the output + // of .value(..)... + arguments.length > 0 + && (options.value instanceof Function ? + (v = options.value.call(actions, v)) + : (options.value = v)) elem.text(v) // update dialog... options.doNotAutoUpdateDialog || make.dialog.update() } + + var elem = $(this).find('.text').last() + var current = elem.text() + var values = getValues() + // editable list or more than 2 values -> show value list... if(options.list_editable || (values.length > 2 @@ -1188,8 +1206,6 @@ var EditorActions = actions.Actions({ // // // NOTE: this extends .toggle(..) - // - // XXX should we support dialog.close(..)'s reject mode here??? attrToggle: function(actions, make, options){ var update = function(){ if(!options.read_only){ @@ -1250,6 +1266,7 @@ var EditorActions = actions.Actions({ options)) }, + // Toggler-based field... // // options format: // {