diff --git a/ui (gen4)/features/external-editor.js b/ui (gen4)/features/external-editor.js index c0a6602d..5ecc1fd0 100755 --- a/ui (gen4)/features/external-editor.js +++ b/ui (gen4)/features/external-editor.js @@ -235,6 +235,11 @@ var ExternalEditorUIActions = actions.Actions({ .on('open', function(){ var editors = that.config['external-editors'] + // commit all fields... + dialog.dom + .find('.editable-field[contenteditable]') + .trigger('commit') + // updated editor... if(editor_i >= 0){ that.config['external-editors'] = editors.slice() diff --git a/ui (gen4)/lib/util.js b/ui (gen4)/lib/util.js index 8715a769..d7d7d25d 100755 --- a/ui (gen4)/lib/util.js +++ b/ui (gen4)/lib/util.js @@ -267,11 +267,19 @@ if(typeof(jQuery) != typeof(undefined)){ // ], // } // + // This listens to these events triggerable by user: + // 'commit' - will commit changes and fire 'edit-done' with + // field text. + // 'abort' - will reset field and trigger 'edit-aborted' + // with original (before edit started) field text + // // XXX should we just use form elements??? // ...it's a trade-off, here we add editing functionality and fight // a bit the original function, in an input we'll need to fight part // of the editing functionality and add our own navigation... // XXX move this to a more generic spot... + // XXX should this reset field to it's original state after + // commit/abort??? jQuery.fn.makeEditable = function(options){ options = options || {} var that = this @@ -304,15 +312,14 @@ if(typeof(jQuery) != typeof(undefined)){ (options.reset_on_abort == null || options.reset_on_abort) && that.text(original) - that - .trigger('edit-aborted', original) + that.trigger('abort') // done -- single line... } else if(n == 'Enter' && !options.multiline){ event.preventDefault() - that.trigger('edit-done', that.text()) + that.trigger('commit') // done -- multiline... } else if(n == 'Enter' @@ -320,9 +327,16 @@ if(typeof(jQuery) != typeof(undefined)){ && options.multiline){ event.preventDefault() - that.trigger('edit-done', that.text()) + that.trigger('commit') } }) + // user triggerable events... + .on('abort', function(){ + that.trigger('edit-aborted', original) + }) + .on('commit', function(){ + that.trigger('edit-done', that.text()) + }) return this }