From 186068077bc59713d23143bdae2e916ce7775342 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 20 Nov 2010 23:45:31 +0300 Subject: [PATCH] rework email article dialog --- modules/popup-dialog.php | 50 ++++++++++------------- prefs.js | 2 + tt-rss.js | 4 ++ viewfeed.js | 85 +++++++++++++++++++--------------------- 4 files changed, 68 insertions(+), 73 deletions(-) diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 351d4b0f..ad3ca0c3 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -177,10 +177,10 @@ print "
"; - print " "; - print ""; print "
"; @@ -638,18 +638,13 @@ if ($id == "emailArticle") { - print "".__('Forward article by email').""; - print ""; - $secretkey = sha1(uniqid(rand(), true)); $_SESSION['email_secretkey'] = $secretkey; - print ""; - print ""; - print ""; + print ""; + print ""; + print ""; $result = db_query($link, "SELECT email, full_name FROM ttrss_users WHERE id = " . $_SESSION["uid"]); @@ -705,8 +700,7 @@ print ""; - print "\">"; print ""; @@ -715,12 +709,12 @@ print ""; - print ""; + print ""; - print "
"; + print "
"; print ""; @@ -728,23 +722,21 @@ print ""; - print ""; - print ""; + print ""; - print ""; - print ""; + print ""; print "
"; - - print " "; - print ""; - - print "]]>"; + print " "; + print ""; + print "
"; //return; } @@ -770,10 +762,10 @@ print "
"; - print " "; - print ""; print "
"; diff --git a/prefs.js b/prefs.js index 33e0ccf4..6c7ed367 100644 --- a/prefs.js +++ b/prefs.js @@ -1027,6 +1027,8 @@ function validatePrefsReset() { function pref_hotkey_handler(e) { try { + if (dijit.getEnclosingWidget(e.target)) return; + var keycode; var shift_key = false; diff --git a/tt-rss.js b/tt-rss.js index 8af5c222..a0c1b70f 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -280,6 +280,7 @@ function init() { dojo.require("dijit.form.ValidationTextBox"); dojo.require("dijit.form.FilteringSelect"); dojo.require("dijit.form.CheckBox"); + dojo.require("dijit.form.SimpleTextarea"); dojo.require("dijit.Toolbar"); dojo.require("dijit.ProgressBar"); dojo.require("dijit.Menu"); @@ -623,6 +624,9 @@ function hotkey_handler(e) { try { + var widget = dijit.getEnclosingWidget(e.target); + if (widget && Element.visible(widget.domNode)) return; + var keycode; var shift_key = false; diff --git a/viewfeed.js b/viewfeed.js index bee13f5a..d14d9818 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -1869,61 +1869,58 @@ function emailArticle(id) { id = ids.toString(); } - displayDlg('emailArticle', id, - function () { - document.forms['article_email_form'].destination.focus(); + if (dijit.byId("emailArticleDlg")) + dijit.byId("emailArticleDlg").destroyRecursive(); - new Ajax.Autocompleter('destination', 'destination_choices', - "backend.php?op=rpc&subop=completeEmails", - { tokens: '', paramName: "search" }); + var query = "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id); - }); - - } catch (e) { - exception_error("emailArticle", e); - } -} + dialog = new dijit.Dialog({ + id: "emailArticleDlg", + title: __("Forward article by email"), + style: "width: 600px", + execute: function() { + if (this.validate()) { -function emailArticleDo() { - try { - var f = document.forms['article_email_form']; - - if (f.destination.value == "") { - alert("Please fill in the destination email."); - return; - } - - if (f.subject.value == "") { - alert("Please fill in the subject."); - return; - } - - var query = Form.serialize("article_email_form"); + new Ajax.Request("backend.php", { + parameters: dojo.objectToQuery(this.attr('value')), + onComplete: function(transport) { + + var error = transport.responseXML.getElementsByTagName('error')[0]; + + if (error) { + alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue); + } else { + notify_info('Your message has been sent.'); + dialog.hide(); + } + + } }); + } + }, + href: query}); -// console.log(query); + var tmph = dojo.connect(dialog, 'onLoad', function() { + dojo.disconnect(tmph); - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - try { + new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', + "backend.php?op=rpc&subop=completeEmails", + { tokens: '', paramName: "search" }); + }); - var error = transport.responseXML.getElementsByTagName('error')[0]; + dialog.show(); - if (error) { - alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue); - } else { - notify_info('Your message has been sent.'); - closeInfoBox(); - } + /* displayDlg('emailArticle', id, + function () { + document.forms['article_email_form'].destination.focus(); - } catch (e) { - exception_error("sendEmailDo", e); - } + new Ajax.Autocompleter('destination', 'destination_choices', + "backend.php?op=rpc&subop=completeEmails", + { tokens: '', paramName: "search" }); - } }); + }); */ } catch (e) { - exception_error("emailArticleDo", e); + exception_error("emailArticle", e); } } -- 2.39.5