From 5e00e7164c0cf2ef060e932dc298045b8bea7aca Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 16 Apr 2019 19:47:27 +0300 Subject: [PATCH] added base path to export dialog... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/filesystem.js | 114 ++++++++++++++++++------------- ui (gen4)/lib/util-dom.js | 7 +- 2 files changed, 72 insertions(+), 49 deletions(-) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index f00d6a3d..cb2b530f 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -2238,6 +2238,7 @@ var FileSystemWriterUIActions = actions.Actions({ alias: 'index', action: 'exportIndex', data: [ + 'base_path', 'target_dir', // XXX need to add options to size: 'none', // XXX use closest preview instead of hi-res when @@ -2255,8 +2256,9 @@ var FileSystemWriterUIActions = actions.Actions({ data: [ 'pattern', 'size', - 'level_dir', + 'base_path', 'target_dir', + 'level_dir', ], }, }, @@ -2448,59 +2450,76 @@ var FileSystemWriterUIActions = actions.Actions({ return e != 'no limit' }, })) }, + // XXX should this be editable??? + // XXX make this selectable... + 'base_path': function(actions, make, parent){ + var elem = make(['Current path: ', this.location.path], + { + events: { + select: function(){ + elem.find('.text').last().selectText() + }, + deselect: function(){ + elem.find('.text').last().selectText(null) + }, + }, + }) + }, // XXX BUG: history closing errors -- non-critical... 'target_dir': function(actions, make, parent){ var elem = make(['$To: ', function(){ return actions.config['export-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() + { + buttons: [ + ['browse', function(p){ + var e = this.filter('"'+p+'"', false) + var path = e.find('.text').last().text() + var txt = e.find('.text').first().text() - // XXX add new dir global button... - return actions.browsePath(path, - function(path){ - actions.config['export-path'] = path - actions.config['export-paths'].splice(0, 0, path) + // XXX add new dir global button... + return actions.browsePath(path, + function(path){ + actions.config['export-path'] = path + actions.config['export-paths'].splice(0, 0, path) - parent.update() - parent.select(txt) - }) - }], - // XXX BUG: closing this breaks on parant.focus()... - ['histroy', widgets.makeNestedConfigListEditor(actions, parent, - 'export-paths', - 'export-path', - { - length_limit: 10, - new_item: false, - })], - ]}) - // XXX make this editable??? - .on('open', function(){ - event.preventDefault() - - var path = elem.find('.text').last() - .makeEditable({ - activate: true, - clear_on_edit: false, - abort_keys: [ - 'Esc', - ], - }) - .on('edit-commit', function(_, path){ - actions.config['export-path'] = path - actions.config['export-paths'].indexOf(path) < 0 - && actions.config['export-paths'].splice(0, 0, path) - - }) - .on('edit-abort edit-commit', function(evt, path){ - parent.update() - .then(function(){ - parent.select(path) + parent.update() + parent.select(txt) }) - }) + }], + // XXX BUG: closing this breaks on parant.focus()... + ['histroy', widgets.makeNestedConfigListEditor(actions, parent, + 'export-paths', + 'export-path', + { + length_limit: 10, + new_item: false, + })], + ], + // XXX make this editable??? + open: function(){ + event.preventDefault() + + var path = elem.find('.text').last() + .makeEditable({ + activate: true, + clear_on_edit: false, + abort_keys: [ + 'Esc', + ], + }) + .on('edit-commit', function(_, path){ + actions.config['export-path'] = path + actions.config['export-paths'].indexOf(path) < 0 + && actions.config['export-paths'].splice(0, 0, path) + + }) + .on('edit-abort edit-commit', function(evt, path){ + parent.update() + .then(function(){ + parent.select(path) + }) + }) + }, }) }, 'comment': function(actions, make, parent){ @@ -2532,6 +2551,7 @@ var FileSystemWriterUIActions = actions.Actions({ }) }, }, + // XXX might be a good idea to show (editable?) base path??? // XXX update export state: index, crop, image... // XXX should this be visible directly??? exportDialog: ['- File/$Export/Export...', diff --git a/ui (gen4)/lib/util-dom.js b/ui (gen4)/lib/util-dom.js index 0ec3d39e..e1f15f42 100755 --- a/ui (gen4)/lib/util-dom.js +++ b/ui (gen4)/lib/util-dom.js @@ -94,7 +94,7 @@ if(typeof(jQuery) != typeof(undefined)){ } - jQuery.fn.selectText = function(){ + jQuery.fn.selectText = function(mode){ var range = document.createRange() this.each(function(){ @@ -103,10 +103,13 @@ if(typeof(jQuery) != typeof(undefined)){ var sel = window.getSelection() sel.removeAllRanges() - sel.addRange(range) + + mode === null + || sel.addRange(range) return this } + jQuery.fn.deselectText = function(){ this.selectText(null) } jQuery.fn.caretOffset = function(){ return getCaretOffset(this) } jQuery.fn.selectionCollapsed = function(){ return selectionCollapsed(this) }