[-] MO : Add ModuleController in ProductComments
// refacto ProductComments
This commit is contained in:
@@ -23,98 +23,10 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<script type="text/javascript" src="{$module_dir}js/jquery.rating.pack.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function(){literal}{{/literal} $('input[@type=radio].star').rating(); {literal}}{/literal});
|
||||
$(function(){literal}{{/literal}
|
||||
$('.auto-submit-star').rating({literal}{{/literal}
|
||||
callback: function(value, link){literal}{{/literal}
|
||||
{literal}}{/literal}
|
||||
{literal}}{/literal});
|
||||
{literal}}{/literal});
|
||||
|
||||
{literal}
|
||||
$('document').ready(function(){
|
||||
|
||||
$('#new_comment_tab_btn').fancybox({
|
||||
'hideOnContentClick': false,
|
||||
'onClosed': function(){
|
||||
},
|
||||
});
|
||||
|
||||
$('button[id^=comment_useful_yes_]').click(function(){
|
||||
|
||||
var idProductComment = $(this).attr('id').replace('comment_useful_yes_', '');
|
||||
var parent = $(this).parent();
|
||||
|
||||
$.ajax({
|
||||
{/literal}url: "{$module_dir}productcomments-ajax.php",{literal}
|
||||
post: "POST",
|
||||
data: "id_product_comment=" + idProductComment + "&action=usefulness&value=1",
|
||||
success: function(result){
|
||||
parent.fadeOut("normal", function() {
|
||||
parent.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('button[id^=comment_useful_no_]').click(function(){
|
||||
|
||||
var idProductComment = $(this).attr('id').replace('comment_useful_no_', '');
|
||||
var parent = $(this).parent();
|
||||
|
||||
$.ajax({
|
||||
{/literal}url: "{$module_dir}productcomments-ajax.php",{literal}
|
||||
post: "POST",
|
||||
data: "id_product_comment=" + idProductComment + "&action=usefulness&value=0",
|
||||
success: function(result){
|
||||
parent.fadeOut("normal", function() {
|
||||
parent.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('span[id^=comment_report_]').click(function(){
|
||||
|
||||
{/literal}if (confirm('{l s='Are you sure you want report this comment?' mod='productcomments'}')){literal}
|
||||
{
|
||||
var idProductComment = $(this).attr('id').replace('comment_report_', '');
|
||||
var parent = $(this).parent();
|
||||
|
||||
$.ajax({
|
||||
{/literal}url: "{$module_dir}productcomments-ajax.php",{literal}
|
||||
post: "POST",
|
||||
data: "id_product_comment=" + idProductComment + "&action=report",
|
||||
success: function(result){
|
||||
parent.fadeOut("normal", function() {
|
||||
parent.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#submitNewMessage').click(function(){
|
||||
var datas = [];
|
||||
$('#fancybox-content').find('input, textarea, select').each(function(index){
|
||||
var o = {}
|
||||
o.key = $(this).attr('name');
|
||||
o.value = $(this).val();
|
||||
datas.push(o);
|
||||
});
|
||||
$.ajax({
|
||||
{/literal}url: "{$module_dir}productcomments-ajax.php",{literal}
|
||||
post: "POST",
|
||||
data: {action: 'sendComment', secure_key: '{/literal}{$secure_key}{literal}', review: JSON.stringify(datas)},
|
||||
dataType: "json",
|
||||
success: function(result){
|
||||
$.fancybox.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
{/literal}
|
||||
var productcomments_controller_url = '{$productcomments_controller_url}';
|
||||
var confirm_report_message = "{l s='Are you sure you want report this comment?' mod='productcomments'}";
|
||||
var secure_key = "{$secure_key}";
|
||||
</script>
|
||||
|
||||
<div id="idTab5">
|
||||
@@ -148,10 +60,10 @@
|
||||
{/if}
|
||||
{if $logged == 1}
|
||||
{if !$comment.customer_advice}
|
||||
<li>{l s='Was this comment useful to you?' mod='productcomments'}<button class="usefulness_btn" id="comment_useful_yes_{$comment.id_product_comment}">{l s='yes' mod='productcomments'}</button><button class="usefulness_btn" id="comment_useful_no_{$comment.id_product_comment}">{l s='no' mod='productcomments'}</button></li>
|
||||
<li>{l s='Was this comment useful to you?' mod='productcomments'}<button class="usefulness_btn" data-is-usefull="1" data-id-product-comment="{$comment.id_product_comment}">{l s='yes' mod='productcomments'}</button><button class="usefulness_btn" data-is-usefull="0" data-id-product-comment="{$comment.id_product_comment}">{l s='no' mod='productcomments'}</button></li>
|
||||
{/if}
|
||||
{if !$comment.customer_report}
|
||||
<li><span class="report_btn" id="comment_report_{$comment.id_product_comment}">{l s='Report abuse' mod='productcomments'}</span></li>
|
||||
<li><span class="report_btn" data-id-product-comment="{$comment.id_product_comment}">{l s='Report abuse' mod='productcomments'}</span></li>
|
||||
{/if}
|
||||
{/if}
|
||||
</ul>
|
||||
@@ -161,69 +73,74 @@
|
||||
{/foreach}
|
||||
{else}
|
||||
{if ($too_early == false AND ($logged OR $allow_guests))}
|
||||
|
||||
<div style="display: none;">
|
||||
<div id="new_comment_form">
|
||||
<h2 class="title">{l s='Write your review' mod='productcomments'}</h2>
|
||||
<div class="product clearfix">
|
||||
<img src="{$link->getImageLink($product->link_rewrite, $productcomment_cover, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product->name|escape:html:'UTF-8'}" />
|
||||
<div class="product_desc">
|
||||
<p class="product_name"><strong>{$product->name}</strong></p>
|
||||
{$product->description_short}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="new_comment_form_content">
|
||||
<p class="intro_form">{l s='Write your review' mod='productcomments'}</p>
|
||||
{if $criterions|@count > 0}
|
||||
<div class="grade_content clearfix">
|
||||
{section loop=$criterions name=i start=0 step=1}
|
||||
<span>
|
||||
<input type="hidden" name="id_product_comment_criterion_{$smarty.section.i.iteration}" value="{$criterions[i].id_product_comment_criterion|intval}" />
|
||||
{$criterions[i].name|escape:'html':'UTF-8'}:
|
||||
</span>
|
||||
<div class="star_content">
|
||||
<input class="star" type="radio" name="{$smarty.section.i.iteration}_grade" id="{$smarty.section.i.iteration}_grade" value="1" />
|
||||
<input class="star" type="radio" name="{$smarty.section.i.iteration}_grade" value="2" />
|
||||
<input class="star" type="radio" name="{$smarty.section.i.iteration}_grade" value="3" checked="checked" />
|
||||
<input class="star" type="radio" name="{$smarty.section.i.iteration}_grade" value="4" />
|
||||
<input class="star" type="radio" name="{$smarty.section.i.iteration}_grade" value="5" />
|
||||
<form action="#">
|
||||
<h2 class="title">{l s='Write your review' mod='productcomments'}</h2>
|
||||
<div class="product clearfix">
|
||||
<img src="{$link->getImageLink($product->link_rewrite, $productcomment_cover, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product->name|escape:html:'UTF-8'}" />
|
||||
<div class="product_desc">
|
||||
<p class="product_name"><strong>{$product->name}</strong></p>
|
||||
{$product->description_short}
|
||||
</div>
|
||||
{/section}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="form_contenair">
|
||||
<p class="text">
|
||||
<label for="comment_title">{l s='Title' mod='productcomments'} <sup>*</sup>:</label>
|
||||
<input id="commentTitle" name="title" type="text" value=""/>
|
||||
</p>
|
||||
<p class="textarea">
|
||||
<label for="content">{l s='Comment' mod='productcomments'} <sup>*</sup>:</label>
|
||||
<textarea id="commentContent" name="content"></textarea>
|
||||
</p>
|
||||
{if $allow_guests == true && $logged == 0}
|
||||
<p class="text">
|
||||
<label>{l s='Your name' mod='productcomments'} <sup>*</sup>:</label>
|
||||
<input id="commentCustomerName" name="customer_name" type="text" value=""/>
|
||||
</p>
|
||||
|
||||
<div class="new_comment_form_content">
|
||||
<h2>{l s='Write your review' mod='productcomments'}</h2>
|
||||
|
||||
<div id="new_comment_form_error" class="error" style="display: none;">
|
||||
<ul></ul>
|
||||
</div>
|
||||
|
||||
{if $criterions|@count > 0}
|
||||
<ul id="criterions_list">
|
||||
{foreach from=$criterions item='criterion'}
|
||||
<li>
|
||||
<label>{$criterion.name|escape:'html':'UTF-8'}:</label>
|
||||
<div class="star_content">
|
||||
<input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|intval}]" value="1" />
|
||||
<input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|intval}]" value="2" />
|
||||
<input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|intval}]" value="3" checked="checked" />
|
||||
<input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|intval}]" value="4" />
|
||||
<input class="star" type="radio" name="criterion[{$criterion.id_product_comment_criterion|intval}]" value="5" />
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
<p class="submit">
|
||||
<span class="txt_required">* {l s='Required fields' mod='productcomments'}</span>
|
||||
|
||||
<label for="comment_title">{l s='Title' mod='productcomments'}: <sup class="required">*</sup></label>
|
||||
<input id="comment_title" name="title" type="text" value=""/>
|
||||
|
||||
<label for="content">{l s='Comment' mod='productcomments'}: <sup class="required">*</sup></label>
|
||||
<textarea id="content" name="content"></textarea>
|
||||
|
||||
{if $allow_guests == true && $logged == 0}
|
||||
<label>{l s='Your name' mod='productcomments'}: <sup class="required">*</sup></label>
|
||||
<input id="commentCustomerName" name="customer_name" type="text" value=""/>
|
||||
{/if}
|
||||
|
||||
<div id="new_comment_form_footer">
|
||||
<input id="id_product_comment_send" name="id_product" type="hidden" value='{$id_product_comment_form}'></input>
|
||||
<button id="submitNewMessage" name="submitMessage" type="submit">{l s='Send' mod='productcomments'}</button>
|
||||
{l s='or' mod='productcomments'} <a href="#" onclick="$.fancybox.close();">{l s='Cancel' mod='productcomments'}</a>
|
||||
</p>
|
||||
<p class="fl required"><sup>*</sup> {l s='Required fields' mod='productcomments'}</p>
|
||||
<p class="fr">
|
||||
<button id="submitNewMessage" name="submitMessage" type="submit">{l s='Send' mod='productcomments'}</button>
|
||||
{l s='or' mod='productcomments'} <a href="#" onclick="$.fancybox.close();">{l s='Cancel' mod='productcomments'}</a>
|
||||
</p>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /end new_comment_form_content -->
|
||||
</form><!-- /end new_comment_form_content -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="align_center">
|
||||
<a id="new_comment_tab_btn" href="#new_comment_form">{l s='Be the first to write your review' mod='productcomments'} !</a>
|
||||
<a id="new_comment_tab_btn" class="open-comment-form" href="#new_comment_form">{l s='Be the first to write your review' mod='productcomments'} !</a>
|
||||
</p>
|
||||
{else}
|
||||
<p class="align_center">{l s='No customer comments for the moment.' mod='productcomments'}</p>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user