From c411826fe5e7662fb0f6dc5fbcb074c68b467ea4 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sun, 4 Mar 2012 00:35:37 +0100 Subject: moving gallery op to one file, migrate gallery dialogs to oc dialogs --- core/js/oc-dialogs.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'core/js') diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index de67c342a71..9ce2bae1642 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -52,7 +52,7 @@ OCdialogs = { */ confirm:function(text, title, callback) { var content = '

'+text+'

'; - OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTON, callback); + OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback); }, /** * prompt for user input @@ -60,8 +60,8 @@ OCdialogs = { * @param title dialog title * @param callback which will be triggered when user press OK (input text will be passed to callback) */ - prompt:function(text, title, callback) { - var content = '

'+text+':

'; + prompt:function(text, title, default_value, callback) { + var content = '

'+text+':

'; OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback); }, /** @@ -131,15 +131,19 @@ OCdialogs = { } return $(element).val(); }, - prompt_ok_handler: function(callback, c_id){callback(true, $(c_id + " input#oc-dialog-prompt-input").val()); $(c_id).dialog('close');}, + prompt_ok_handler: function(callback, c_id) { $(c_id).dialog('close'); if (callback != undefined) callback($(c_id + " input#oc-dialog-prompt-input").val()); }, form_ok_handler: function(callback, c_id) { - var r = []; - var c = 0; - $(c_id + ' input').each(function(i, elem) { - r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)}; - c++; - }); - $(c_id).dialog('close'); - callback(r); + if (callback != undefined) { + var r = []; + var c = 0; + $(c_id + ' input').each(function(i, elem) { + r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)}; + c++; + }); + $(c_id).dialog('close'); + callback(r); + } else { + $(c_id).dialog('close'); + } } }; -- cgit v1.2.3