From ac9ba4480ddf137987b5ae98a644d5c620c50f3b Mon Sep 17 00:00:00 2001 From: thomascube Date: Mon, 5 Dec 2011 12:29:55 +0000 Subject: Replace prompt() with jQuery UI dialog (#1485135) --- program/js/app.js | 31 ++++++++++++++++++++++--------- program/steps/mail/compose.inc | 5 ++++- 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'program') diff --git a/program/js/app.js b/program/js/app.js index c0268d4fd..c31a69788 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -907,7 +907,7 @@ function rcube_webmail() if (!this.gui_objects.messageform) break; - if (!this.check_compose_input()) + if (!props.nocheck && !this.check_compose_input(command)) break; // Reset the auto-save timer @@ -2960,7 +2960,7 @@ function rcube_webmail() }; // checks the input fields before sending a message - this.check_compose_input = function() + this.check_compose_input = function(cmd) { // check input fields var ed, input_to = $("[name='_to']"), @@ -2995,15 +2995,28 @@ function rcube_webmail() // display localized warning for missing subject if (input_subject.val() == '') { - var subject = prompt(this.get_label('nosubjectwarning'), this.get_label('nosubject')); + var myprompt = $('
').html('
' + this.get_label('nosubjectwarning') + '
').appendTo(document.body); + var prompt_value = $('').attr('type', 'text').attr('size', 30).appendTo(myprompt).val(this.get_label('nosubject')); - // user hit cancel, so don't send - if (!subject && subject !== '') { + var buttons = {}; + buttons[this.get_label('cancel')] = function(){ input_subject.focus(); - return false; - } - else - input_subject.val((subject ? subject : this.get_label('nosubject'))); + $(this).dialog('close'); + }; + buttons[this.get_label('sendmessage')] = function(){ + input_subject.val(prompt_value.val()); + $(this).dialog('close'); + ref.command(cmd, { nocheck:true }); // repeat command which triggered this + }; + + myprompt.dialog({ + modal: true, + resizable: false, + buttons: buttons, + close: function(event, ui) { $(this).remove() } + }); + prompt_value.select(); + return false; } // Apply spellcheck changes if spell checker is active diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 7eaad2573..71729602a 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -124,7 +124,7 @@ if (!is_array($COMPOSE)) $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 'cancel', 'nobodywarning', 'notsentwarning', 'notuploadedwarning', 'savingmessage', 'sendingmessage', 'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany', - 'fileuploaderror'); + 'fileuploaderror', 'sendmessage'); $OUTPUT->set_env('compose_id', $COMPOSE['id']); @@ -139,6 +139,9 @@ $OUTPUT->set_env('sig_above', $RCMAIL->config->get('sig_above', false)); $OUTPUT->set_env('top_posting', $RCMAIL->config->get('top_posting', false)); $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ','))); +// use jquery UI for showing prompt() dialogs +$RCMAIL->plugins->load_plugin('jqueryui'); + // get reference message and set compose mode if ($msg_uid = $COMPOSE['param']['draft_uid']) { $RCMAIL->imap->set_mailbox($CONFIG['drafts_mbox']); -- cgit v1.2.3