From f8dfa167c936e6050e41e2333c98ad8631dfc62f Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 14 Nov 2017 00:13:47 +0300 Subject: [PATCH] added docs to export pattern... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/filesystem.js | 31 +++++++++++++++++++-------- ui (gen4)/features/ui-widgets.js | 9 +++++--- ui (gen4)/lib/widget/browse.js | 36 ++++++++++++++++++++++---------- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 3f85e2a0..857bcd54 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -2393,7 +2393,7 @@ var FileSystemWriterUIActions = actions.Actions({ } // make this a dialog... - var res = make(['Filename pattern: ', pattern], { + var res = make(['Filename $pattern: ', pattern], { open: widgets.makeNestedConfigListEditor(actions, parent, 'export-preview-name-patterns', 'export-preview-name-pattern', { @@ -2404,19 +2404,32 @@ var FileSystemWriterUIActions = actions.Actions({ buttons: [ ['i', function(p){ showExaples(p) }], ], + }, function(){ + this.showExaples = function(){ showExaples(this.selected) } + this.keyboard.handler('General', 'i', 'showExaples') + + this.showDoc = function(){ actions.showDoc('formatImageName') } + this.keyboard.handler('General', '?', 'showDoc') }), + buttons: [ + ['?', function(){ + actions.showDoc('formatImageName') + }], + ], }) // show example generated names... make(['Filename:', - function(){ return actions.formatImageName(pattern, img) }]) - .on('open', function(){ - showExaples(actions.config['export-preview-name-pattern'] || '%f') }) + function(){ return actions.formatImageName(pattern, img) }], + { + open: function(){ + showExaples(actions.config['export-preview-name-pattern'] || '%f') }, + }) return res }, 'level_dir': function(actions, make, parent){ - return make(['Level directory: ', + return make(['$Level directory: ', function(){ return actions.config['export-level-directory-name'] || 'fav' }]) .on('open', @@ -2427,7 +2440,7 @@ var FileSystemWriterUIActions = actions.Actions({ })) }, 'size': function(actions, make, parent){ - return make(['Image size: ', + return make(['Image $size: ', function(){ return actions.config['export-preview-size'] || 1000 }]) // XXX add validation??? @@ -2442,7 +2455,7 @@ var FileSystemWriterUIActions = actions.Actions({ }, 'size_limit': function(actions, make, parent){ - return make(['Limit image size: ', + return make(['Limit image $size: ', function(){ return actions.config['export-preview-size-limit'] || 'no limit' }], { buttons: [ @@ -2463,7 +2476,7 @@ var FileSystemWriterUIActions = actions.Actions({ }, // XXX BUG: history closing errors -- non-critical... 'target_dir': function(actions, make, parent){ - var elem = make(['To: ', + var elem = make(['$To: ', function(){ return actions.config['export-path'] || './' }], { buttons: [ ['browse', function(p){ @@ -2517,7 +2530,7 @@ var FileSystemWriterUIActions = actions.Actions({ }) }, 'comment': function(actions, make, parent){ - var elem = make(['Comment: ', + var elem = make(['$Comment: ', // XXX get staged comment??? function(){ return actions.getSaveComment() }]) .on('open', function(){ diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 540dc1b9..b5fceefe 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -212,7 +212,7 @@ function(list, elem, callback, options){ // var makeConfigListEditor = module.makeConfigListEditor = -function(actions, path, value_path, options){ +function(actions, path, value_path, options, setup){ path = path.split('.') var key = path.pop() @@ -275,6 +275,9 @@ function(actions, path, value_path, options){ save(dialog.selected) }) + setup + && setup.call(dialog, dialog) + return dialog } @@ -289,7 +292,7 @@ function(actions, path, value_path, options){ // .text element... var makeNestedConfigListEditor = module.makeNestedConfigListEditor = -function(actions, list, list_key, value_key, options){ +function(actions, list, list_key, value_key, options, setup){ options = options || {} return function(){ @@ -305,7 +308,7 @@ function(actions, list, list_key, value_key, options){ } options.__proto__ = dfl_options - var o = makeConfigListEditor(actions, list_key, value_key, options) + var o = makeConfigListEditor(actions, list_key, value_key, options, setup) // update parent menu... .open(function(){ list diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index f1721237..a5bc6f24 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -1532,7 +1532,11 @@ var BrowserPrototype = { //'close', ], - optionsEventShorthands: [ + // List of event handlers that can be set directly from item + // options... + // + // This is a shorthand to using options.events object. + itemOptionsEventShorthands: [ 'open', 'menu', 'update', @@ -1762,19 +1766,29 @@ var BrowserPrototype = { return this }, blur: widget.proxyToDom('blur'), - //menu: widget.proxyToDom('menu'), - //* XXX + + // Trigger/bind to menu event... + // + // Bind handler to menu event... + // .menu(handler) + // -> this + // + // Trigger menu event on current item... + // .menu() + // -> this + // + // Trigger menu event on pattern item... + // .menu(pattern) + // -> this + // + // NOTE: pattern is .select(..) compatible pattern. menu: function(){ arguments[0] instanceof Function ? this.dom.on('menu', arguments[0]) - : this.select('!').trigger('menu', - //: this.dom.trigger('menu', - arguments.length > 0 ? - [].slice.call(arguments) - : [this.selected]) + : this.select(arguments[0] || '!') + .trigger('menu', [this.selected]) return this }, - //*/ // base api... @@ -2086,7 +2100,7 @@ var BrowserPrototype = { // // // // These are the sugar for commonly used events in the events // // section below... - // // NOTE: these are defined in .options.optionsEventShorthands + // // NOTE: these are defined in .options.itmeOptionsEventShorthands // open: , // menu: , // update: , @@ -2575,7 +2589,7 @@ var BrowserPrototype = { //--------------------------------- user event handlers --- res.on('update', function(evt){ evt.stopPropagation() }) // shorthands... - ;(that.options.optionsEventShorthands || []) + ;(that.options.itemOptionsEventShorthands || []) .forEach(function(p){ res.on(p, opts[p]) }) // events... Object.keys(opts.events || {})