diff --git a/ui (gen4)/features/external-editor.js b/ui (gen4)/features/external-editor.js index aa9e8200..f40829cc 100755 --- a/ui (gen4)/features/external-editor.js +++ b/ui (gen4)/features/external-editor.js @@ -11,6 +11,8 @@ define(function(require){ var module = {} var actions = require('lib/actions') var core = require('features/core') +var widgets = require('features/ui-widgets') + // widgets... var browse = require('lib/widget/browse') var overlay = require('lib/widget/overlay') @@ -44,6 +46,12 @@ var ExternalEditorActions = actions.Actions({ // as argument unless it uses only '\' and not '/' ['IrfanView|"C:/Program Files (x86)/IrfanView/i_view32.exe" "$PATH"'], ], + + 'external-editor-targets': [ + 'Original image', + 'Best preview', + // XXX + ], }, // XXX this still needs image type and better support for OS paths @@ -109,6 +117,106 @@ module.ExternalEditor = core.ImageGridFeatures.Feature({ //--------------------------------------------------------------------- var ExternalEditorUIActions = actions.Actions({ + // XXX get editor data... + // XXX set editor data... + // XXX revise editor format... + // XXX empty title -- use app name without ext... + externalEditorDialog: ['- Edit/', + function(editor){ + var that = this + + // XXX STUB: get the real editor... + var editor = { + // NOTE: empty means use app name... + title: '', + // NOTE: empty means system to select editor... + path: '/', + // NOTE: empty is the same as '$TARGET'... + // XXX use $TARGET... + arguments: '', + target: 'Original image', + } + + var o = overlay.Overlay(this.ribbons.viewer, + browse.makeLister(null, function(_, make){ + make(['Title: ', function(){ return editor.title || '' }]) + .on('open', function(){ + event.preventDefault() + widgets.makeEditableItem(o.client, + $(this).find('.text').last(), + function(_, text){ editor.title = text }) }) + + make(['Path: ', function(){ return editor.path }], { + buttons: [ + ['browse', function(p){ + var e = this.filter('"'+p+'"', false) + var path = e.find('.text').last().text() + var txt = e.find('.text').first().text() + + var b = overlay.Overlay(that.ribbons.viewer, + browseWalk.makeWalk(null, path, + // XXX + '*+(exe|cmd|ps1|sh)', + {}) + // path selected... + .open(function(evt, path){ + editor.path = path + + b.close() + + o.client.update() + .then(function(){ o.client.select(txt+path) }) + })) + .close(function(){ + // XXX + that.getOverlay().focus() + }) + }] + ] + }) + .on('open', function(){ + event.preventDefault() + widgets.makeEditableItem(o.client, + $(this).find('.text').last(), + function(_, text){ editor.path = text }) }) + + make(['Arguments: ', function(){ return editor.arguments || '' }]) + .on('open', function(){ + event.preventDefault() + widgets.makeEditableItem(o.client, + $(this).find('.text').last(), + function(_, text){ editor.arguments = text }) }) + + make(['Target: ', function(){ return editor.target || 'Original image' }]) + .on('open', + widgets.makeNestedConfigListEditor(that, o, + 'external-editor-targets', + function(val){ + if(val == null){ + return editor.target + } else { + editor.target = val + } + }, + { + new_button: false, + itemButtons: [], + })) + + make(['Save']) + .on('open', function(){ + // XXX save stuff... + // XXX + + o.close() + }) + })) + + o.client.dom.addClass('metadata-view tail-action') + + return o + }], + // XXX use .externalEditorDialog(..) listExtenalEditors: ['Edit/List external editors', function(){ var that = this diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 44060560..72d6e1e8 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -860,7 +860,7 @@ var FileSystemWriterActions = actions.Actions({ // XXX copy img.path -- the main image, especially when no previews present.... // XXX - Object.keys(previews).forEach(function(res){ + previews && Object.keys(previews).forEach(function(res){ var preview_path = decodeURI(previews[res]) var from = (img_base || base_dir) +'/'+ preview_path diff --git a/ui (gen4)/features/metadata.js b/ui (gen4)/features/metadata.js index f6b14ffd..fba4d6d9 100755 --- a/ui (gen4)/features/metadata.js +++ b/ui (gen4)/features/metadata.js @@ -507,6 +507,8 @@ module.MetadataUI = core.ImageGridFeatures.Feature({ +// Load etdata on demand... +// var MetadataFSUI = module.MetadataFSUI = core.ImageGridFeatures.Feature({ title: '', diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index caa55697..523cd4b0 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -31,6 +31,27 @@ var browseWalk = require('lib/widget/browse-walk') /*********************************************************************/ +// XXX make the selector more accurate... +// ...at this point this will select the first elem with text which +// can be a different elem... +var makeEditableItem = +module.makeEditableItem = +function(list, elem, callback, options){ + return elem + .makeEditable({ + clear_on_edit: false, + }) + .on('edit-done', callback || function(){}) + .on('edit-aborted edit-done', function(_, text){ + list.update() + // XXX make the selector more accurate... + // ...at this point this will select the first elem + // with text which can be a different elem... + .then(function(){ list.select(text) }) + }) +} + + // // Options format: // { @@ -224,7 +245,11 @@ function(actions, parent, list_key, value_key, options){ // NOTE: this is called when adding a new value and // list maximum length is reached... callback: function(value){ - actions.config[value_key] = value + if(typeof(value_key) == typeof(function(){})){ + value_key(value) + } else { + actions.config[value_key] = value + } o.close() }, @@ -244,7 +269,12 @@ function(actions, parent, list_key, value_key, options){ parent.focus() }) - o.client.select(actions.config[value_key]) + if(typeof(value_key) == typeof(function(){})){ + o.client.select(value_key()) + + } else { + o.client.select(actions.config[value_key]) + } } }