').text(review.rating),\n\t\t\t\t\t\t\t\ttext = $('').addClass(prefix + 'text').text(review.text),\n\t\t\t\t\t\t\t\tdate = $('').text(day + '/' + month + '/' + year).addClass(prefix + 'date');\n\n\t\t\t\t\t\t\tfor (var i = 0; i < parseInt(review.rating); i++){\n\t\t\t\t\t\t\t\trating.append('');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tslide.append([thing, name, date, rating.append(ratingValue), text]);\n\t\t\t\t\t\t\tratings.push(parseInt(review.rating));\n\n\t\t\t\t\t\t\treturn slide;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn reviewsDOM;\n\t\t\t\t}\n\n\t\t\t}\n\t})());\n\n\tvar router = avm.require('avast.web.router');\n\trouter.set({\n\t\trate: function(){\n\t\t\tvar $ = avm.require('jquery'),\n\t\t\t\ttimeout;\n\n\t\t\t$.colorbox({\n\t\t\t\tinline: true,\n\t\t\t\twidth: 570,\n\t\t\t\theight: 600,\n\t\t\t\tinitialHeight: 600,\n\t\t\t\thref: '#ratingPopup',\n\t\t\t\tclassName: 'rating-form',\n\n\t\t\t\tonLoad: function(){\n\n\t\t\t\t\tvar url = avastGlobals.web.RootPath ? avastGlobals.web.RootPath + locale + '/' + 'rating-form.php' : 'rating-form.php';\n\n\t\t\t\t\t$(\"#ratingForm\").load(url, function(){\n\t\t\t\t\t\tvar rating = avm.require('avast.web.rating')($('.rating-form').find('input[type=\"radio\"][name=\"rating\"]').get()),\n\t\t\t\t\t\t\tstars = rating.stars(),\n\t\t\t\t\t\t\ttarget = document.querySelector('#colorbox.rating-form .form-table');\n\n\t\t\t\t\t\tinitAvastForm();\n\n\t\t\t\t\t\t$('#colorbox.rating-form').find('input[type=\"radio\"][name=\"rating\"]')\n\t\t\t\t\t\t\t.closest('.form-item')\n\t\t\t\t\t\t\t.hide()\n\t\t\t\t\t\t\t.before($('
').addClass('form-item').append(stars));\n\n\t\t\t\t\t\t$.colorbox.resize();\n\t\t\t\t\t\t// Form tweaks\n\t\t\t\t\t\t$('#colorbox.rating-form').find('#frm-text').attr('maxlength', '300');\n\n\t\t\t\t\t\t//console.log('mutation target %o', target);\n\t\t\t\t\t\t// create an observer instance\n\t\t\t\t\t\tif(typeof MutationObserver === 'function') {\n\t\t\t\t\t\t\tvar observer = new MutationObserver(function(mutations) {\n\t\t\t\t\t\t\t\tmutations.forEach(function(mutation) {\n\t\t\t\t\t\t\t\t\t//console.log(mutation.type);\n\t\t\t\t\t\t\t\t\t//console.log($(target).has('.bubble'));\n\n\t\t\t\t\t\t\t\t\tif(mutation.type === 'childList' && $(target).has('.bubble')){\n\t\t\t\t\t\t\t\t\t\t// Autoclose\n\t\t\t\t\t\t\t\t\t\ttimeout = setTimeout(function() {\n\t\t\t\t\t\t\t\t\t\t\t$.colorbox.close();\n\t\t\t\t\t\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\t\t\t\t\t}, 5000);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t// configuration of the observer:\n\t\t\t\t\t\t\tvar config = {\n\t\t\t\t\t\t\t\tchildList: true\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// pass in the target node, as well as the observer options\n\t\t\t\t\t\t\tvar oTimeout = setTimeout(function() {\n\t\t\t\t\t\t\t\t//console.log('mutation target %o', target);\n\t\t\t\t\t\t\t\tobserver.observe(target, config);\n\t\t\t\t\t\t\t\tclearTimeout(oTimeout)\n\t\t\t\t\t\t\t}, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t},\n\t\t\t\tonClosed: function(){\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t// hash for tracking closed popup\n\t\t\t\t\twindow.location.hash = '!';\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n})();\n\n\n\n$(document).ready(function(){\n\t//console.time('buildSlides')\n\tvar reviewModule = avm.require('avast.web.review');\n\t\treviews = reviewModule.reviews;\n\t\tbxFetchSlide = 0,\n\t\tratingPoints = 5;\n\n\t// Open rating form\n\n\t// Slider\n\tvar bxslider = $('.js-slider')\n\t\t.empty()\n\t\t.append(reviewModule.fetch(0, 21))\n\t\t.bxSlider({\n\t\t\tauto: false,\n\t\t\tcontrols: true,\n\t\t\tpager: false,\n\t\t\tinfiniteLoop: true,\n\t\t\t//hideControlOnEnd: true,\n\t\t\tminSlides: 1,\n\t\t\tmaxSlides: 3,\n\t\t\tslideWidth: 330,\n\t\t\tnextSelector: '.arrow-box.arrow-right',\n\t\t\tnextText: '',\n\t\t\tprevSelector: '.arrow-box.arrow-left',\n\t\t\tprevText: '',\n\t\t\tonSlideNext: function(slider, index, oldIndex){\n\t\t\t\tvar last = bxslider.getSlideCount();\n\t\t\t\t\tfrom = (bxFetchSlide + 1) * 3;\n\t\t\t\t\tto = (bxFetchSlide + 8) * 3;\n\n\t\t\t\tif (bxFetchSlide) {\n\t\t\t\t\t//console.log('from: %s', from)\n\t\t\t\t\t//console.log('to: %s', to)\n\n\t\t\t\t\t$('.slider-reviews').addClass('is-loading')\n\t\t\t\t\t$('.js-slider').append(reviewModule.fetch(from, to));\n\t\t\t\t\tbxslider.reloadSlider();\n\t\t\t\t}\n\n\t\t\t\tif (((bxslider.getCurrentSlide() + 1) * 3) >= bxslider.getSlideCount()) {\n\t\t\t\t\t// Prepare to reload but reload with next slide\n\t\t\t\t\tbxFetchSlide = bxslider.getCurrentSlide();\n\t\t\t\t}\n\n\t\t\t},\n\t\t\tonSliderLoad: function(){\n\t\t\t\tvar timeout;\n\n\t\t\t\tif (bxFetchSlide) {\n\t\t\t\t\t//console.log('onSliderLoad')\n\t\t\t\t\t//console.log('onSliderLoad count: %s', bxslider.getSlideCount())\n\n\t\t\t\t\t// It's too early to move on correct position. For some reason the width is still not correctly recalculated.\n\t\t\t\t\ttimeout = setTimeout(function(){\n\t\t\t\t\t\tbxslider.goToSlide(bxFetchSlide + 1);\n\n\t\t\t\t\t\t// @todo: remove loader\n\n\t\t\t\t\t\t// Clear state\n\t\t\t\t\t\tbxFetchSlide = 0;\n\n\t\t\t\t\t\t// Clear timeout\n\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t}, 0)\n\t\t\t\t}\n\t\t\t},\n\t\t\tonSlideAfter: function(){\n\t\t\t\t$('.slider-reviews').removeClass('is-loading');\n\t\t\t}\n\t\t});\n\n\t// Total reviews and average rating to DOM\n\tvar totalRatings = reviews.reduce(function(pv, cv) { return pv + cv.rating; }, 0);\n\tvar avgRating = (totalRatings) / reviews.length;\n\tvar percentAvgRating = Math.floor((100 / ratingPoints) * avgRating);\n\n\t$('.rating-bar').width(30 * ratingPoints);\n\t$('.rating-bar-average').width(percentAvgRating + '%');\n\n\t$('.total-reviews').text(reviews.length)\n\t$('.average-rating').text(avgRating.toPrecision(2))\n\t//console.timeEnd('buildSlides')\n\n\t// next modification per GLOWEB-1970\n\t$('.slider-review-date').css('display', 'none');\n});\n\n\n"]}