78 lines
3.0 KiB
Smarty
Executable File
78 lines
3.0 KiB
Smarty
Executable File
<script type="text/javascript">
|
|
{literal}
|
|
$('document').ready(function(){
|
|
$('.adv_send_friend_button').fancybox({
|
|
'hideOnContentClick': false
|
|
}).click(function(e){
|
|
e.preventDefault();
|
|
var sale_id = $(this).attr('rel');
|
|
fillFormContent(sale_id);
|
|
});
|
|
|
|
$('#adv_sendEmail').click(function(){
|
|
|
|
var name = $('#friend_name').val();
|
|
var email = $('#friend_email').val();
|
|
var id_sale = $('#id_sale_comment_send').val();
|
|
if (name && email && !isNaN(id_sale))
|
|
{
|
|
$.ajax({
|
|
{/literal}url: "{$module_dir}sendtoafriend_ajax.php",{literal}
|
|
type: "POST",
|
|
headers: {"cache-control": "no-cache"},
|
|
data: {action: 'sendToMyFriend', secure_key: '{/literal}{$secure_key}{literal}', name: name, email: email, id_sale: id_sale},{/literal}{literal}
|
|
dataType: "json",
|
|
success: function(result) {
|
|
$.fancybox.close();
|
|
var msg = result ? "{/literal}{l s='Your e-mail has been sent successfully' mod='advsendtoafriend'}{literal}" : "{/literal}{l s='Your e-mail could not be sent. Please check the e-mail address and try again.' mod='advsendtoafriend'}{literal}";
|
|
var title = "{/literal}{l s='Send to a friend' mod='advsendtoafriend'}{literal}";
|
|
fancyMsgBox(msg, title);
|
|
}
|
|
});
|
|
}
|
|
else
|
|
$('#send_friend_form_error').text("{/literal}{l s='You did not fill required fields' mod='advsendtoafriend' js=1}{literal}");
|
|
});
|
|
});
|
|
|
|
|
|
function fillFormContent(id){
|
|
$('#send_friend_form .sale_image').attr('src', $('#sale_image_'+id).val());
|
|
$('#send_friend_form .sale_image').attr('alt', $('#sale_image_title_'+id).val());
|
|
$("#id_sale_comment_send").val(id);
|
|
$('#send_friend_form .sale_description').empty().append($('#sale_description_'+id).val());
|
|
}
|
|
|
|
{/literal}
|
|
</script>
|
|
|
|
<div style="display: none;">
|
|
<div id="send_friend_form">
|
|
<h2>
|
|
{l s='Envoyer à un ami' mod='advsendtoafriend'}<br>
|
|
<span class="shape-red-long"></span>
|
|
</h2>
|
|
|
|
<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="required form-group">
|
|
<label for="friend_email">{l s='Adresse e-mail de votre ami' mod='advsendtoafriend'} :</label>
|
|
<input id="friend_email" name="friend_email" type="text" value="" class="form-control"/>
|
|
</div>
|
|
<div class="required form-group">
|
|
<label for="friend_name">{l s='Nom de votre ami' mod='advsendtoafriend'} :</label>
|
|
<input id="friend_name" name="friend_name" type="text" value="" class="form-control"/>
|
|
</p>
|
|
<p class="submit">
|
|
<input id="id_sale_comment_send" name="id_sale" type="hidden" value="" />
|
|
<a href="#" class="button-grey button-grey-min left" onclick="$.fancybox.close();"><span>{l s='Annuler' mod='advsendtoafriend'}</span></a>
|
|
<button id="adv_sendEmail" class="button-grey right" name="sendEmail" type="submit">
|
|
<span>{l s='Envoyer' mod='advsendtoafriend'}</span>
|
|
</button>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|