From 6c76ba20a2fe7aacc11d563ca9a7c8836fa7ce19 Mon Sep 17 00:00:00 2001 From: Eston Bond Date: Mon, 1 Nov 2010 18:52:28 -0700 Subject: [PATCH] keep things event-driven --- scratch/js/gollum-editor/gollum.editor.js | 25 +++++++++++++++++++++- scratch/js/gollum-editor/langs/markdown.js | 19 +++++++++------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/scratch/js/gollum-editor/gollum.editor.js b/scratch/js/gollum-editor/gollum.editor.js index b2201342..e3ee688a 100644 --- a/scratch/js/gollum-editor/gollum.editor.js +++ b/scratch/js/gollum-editor/gollum.editor.js @@ -79,6 +79,17 @@ + /** + * $.GollumEditor.Dialog + * Used in exec() to display dialogs with dynamic fields. + * + */ + $.GollumEditor.Dialog = function( argObject ) { + return Dialog.init( argObject ); + }; + + + /** * debug * Prints debug information to console.log if debug output is enabled. @@ -385,14 +396,26 @@ $field.val( fullStr.substring(0, selPos.start) + replaceText + fullStr.substring(selPos.end)); + $field[0].focus(); if ( selectNew && $field[0].setSelectionRange ) { - $field[0].focus(); $field[0].setSelectionRange( selPos.start, selPos.start + replaceText.length ); } } }; + + + + /** + * Dialog + * Used by FunctionBar & internally to display editor-specific messages, + * inputs and more. + * + */ + var Dialog = { + //TODO + }; })(jQuery); diff --git a/scratch/js/gollum-editor/langs/markdown.js b/scratch/js/gollum-editor/langs/markdown.js index 0f734997..9cc460f0 100644 --- a/scratch/js/gollum-editor/langs/markdown.js +++ b/scratch/js/gollum-editor/langs/markdown.js @@ -58,7 +58,7 @@ var MarkDown = { 'function-link' : { exec: function( txt, selText, $field ) { var results = null; - res = $.GollumEditor.Dialog({ + $.GollumEditor.Dialog({ title: '', fields: [ { @@ -73,15 +73,18 @@ var MarkDown = { type: 'text', help: 'The URL to link to.' } - ] + ], + OK: function( res ) { + if ( res['text'] && res['href'] ) { + return '[' + res['text'] + '](' + + res['href'] + ')'; + } + else + return ''; + } }); - if ( res['text'] && res['href'] ) { - return '[' + res['text'] + '](' - + res['href'] + ')'; - } - else - return ''; + } },