Author Topic: Slightly Advanced Review  (Read 1981 times)

kok

  • Beginner
  • *
  • Posts: 35
  • VirtueMart Version: 2.6.10
Slightly Advanced Review
« on: October 14, 2013, 10:12:30 am »
I rewrote some code in the file "default_reviews.php"

Code: [Select]
<?php // Show Review Length While Your Are Writing
$reviewJavascript "
function check_reviewform() {
var form = document.getElementById('reviewform');

var ausgewaehlt = false;

// for (var i=0; i<form.vote.length; i++) {
// if (form.vote[i].checked) {
// ausgewaehlt = true;
// }
// }
// if (!ausgewaehlt)  {
// alert('" 
JText::('COM_VIRTUEMART_REVIEW_ERR_RATE'FALSE) . "');
// return false;
// }
//else
if (form.comment.value.length < " 
VmConfig::get ('reviews_minimum_comment_length'100) . ") {
alert('" 
addslashes (JText::sprintf ('COM_VIRTUEMART_REVIEW_ERR_COMMENT1_JS'VmConfig::get ('reviews_minimum_comment_length'100))) . "');
return false;
}
else if (form.comment.value.length > " 
VmConfig::get ('reviews_maximum_comment_length'2000) . ") {
alert('" 
addslashes (JText::sprintf ('COM_VIRTUEMART_REVIEW_ERR_COMMENT2_JS'VmConfig::get ('reviews_maximum_comment_length'2000))) . "');
return false;
}
else {
return true;
}
}

function refresh_counter() {
var form = document.getElementById('reviewform');
form.counter.value= form.comment.value.length;
}
jQuery(function($) {
var steps = " 
$maxrating ";
var parentPos= $('.write-reviews .ratingbox').position();
var boxWidth = $('.write-reviews .ratingbox').width();// nbr of total pixels
var starSize = (boxWidth/steps);
//var ratingboxPos= $('.write-reviews .ratingbox').offset();

$('.write-reviews .ratingbox').mousemove( function(e){
var span = $(this).children();
var ratingboxPos= $('.write-reviews .ratingbox').offset();
var dif = e.pageX-ratingboxPos.left; // nbr of pixels
difRatio = Math.floor(dif/boxWidth* steps )+1; //step
span.width(difRatio*starSize);
$('#vote').val(difRatio);
//console.log('note = ', difRatio);
});
});


"
;

These advantages:
1. If you use tabs (that tab Review previously hidden), the code works correctly (for example, http://softex.it-klub.ru/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=5&virtuemart_category_id=8&Itemid=158
2. The Review is now working as you resize the browser window.

disadvantages:
Resources are used to the frequent use of the item's position.
Joomla! 2.5.27
VirtueMart 2.6.10