[-] MO sendtoafriend : a message is displayed whether the e-mail has been sent or not

#PNM-627
#PNM-1610
#PNM-1616
This commit is contained in:
Fabio Chelly
2013-09-06 11:40:41 +02:00
parent 7e1c0d5a24
commit 663f592306
2 changed files with 43 additions and 2 deletions
+37
View File
@@ -294,6 +294,43 @@ function removeQuotes(value)
return value;
}
/**
* Display a MessageBox
* @param {string} msg
* @param {string} title (optional)
*/
function fancyMsgBox(msg, title)
{
if (title) msg = "<h2>" + title + "</h2><p>" + msg + "</p>";
msg += "<br/><p class=\"submit\" style=\"text-align:right; padding-bottom: 0\"><input class=\"button\" type=\"button\" value=\"OK\" onclick=\"$.fancybox.close();\" /></p>";
$.fancybox( msg, {'autoDimensions': false, 'width': 500, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none'} );
}
/**
* Display a messageDialog with different buttons including a callback for each one
* @param {string} question
* @param {mixed} title Optional title for the dialog box. Send false if you don't want any title
* @param {object} buttons Associative array containg a list of {buttonCaption: callbackFunctionName, ...}. Use an empty space instead of function name for no callback
* @param {mixed} otherParams Optional data sent to the callback function
*/
function fancyChooseBox(question, title, buttons, otherParams)
{
var msg, funcName, action;
if (title) msg = "<h2>" + title + "</h2><p>" + question + "</p>";
msg += "<br/><p class=\"submit\" style=\"text-align:right; padding-bottom: 0\">";
var i = 0;
for (var caption in buttons) {
if (!buttons.hasOwnProperty(caption)) continue;
funcName = buttons[caption];
otherParams = escape(JSON.stringify(otherParams));
action = funcName ? "$.fancybox.close();window['" + funcName + "'](JSON.parse(unescape('" + otherParams + "')), " + i + ")" : "$.fancybox.close()";
msg += '<input class="button" style="margin-right: 5px" type="button" value="' + caption + '" onclick="' + action + '" />';
i++;
}
msg += "</p>";
$.fancybox( msg, {'autoDimensions': false, 'width': 500, 'height': 'auto', 'transitionIn': 'none', 'transitionOut': 'none'} );
}
//On dom ready
$().ready(function()
{
@@ -23,7 +23,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<script text="javascript">
<script type="text/javascript">
{literal}
$('document').ready(function(){
$('#send_friend_button').fancybox({
@@ -49,8 +49,11 @@ $('document').ready(function(){
headers: {"cache-control": "no-cache"},
data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', friend: unescape(JSON.stringify(datas).replace(/\\u/g, '%u'))},{/literal}{literal}
dataType: "json",
success: function(result){
success: function(result) {
$.fancybox.close();
var msg = result ? "{/literal}{l s='Your e-mail has been sent successfully' mod='sendtoafriend'}{literal}" : "{/literal}{l s='Your e-mail could not be sent. Please check the e-mail address and try again.' mod='sendtoafriend'}{literal}";
var title = "{/literal}{l s='Send to a friend' mod='sendtoafriend'}{literal}";
fancyMsgBox(msg, title);
}
});
}
@@ -77,6 +80,7 @@ $('document').ready(function(){
<div class="send_friend_form_content" id="send_friend_form_content">
<div id="send_friend_form_error"></div>
<div id="send_friend_form_success"></div>
<div class="form_container">
<p class="intro_form">{l s='Recipient' mod='sendtoafriend'} :</p>
<p class="text">