/*! * Raty - A Star Rating Plugin * * The MIT License * * author: Washington Botelho * github: wbotelhos/raty * version: 3.1.0 * */ useJquery().then(() => { !function(t,e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(t.jQuery)}(this,(function(t){"use strict";var e;t.raty={cancelButton:!1,cancelClass:"raty-cancel",cancelHint:"Cancel this rating!",cancelOff:"cancel-off.png",cancelOn:"cancel-on.png",cancelPlace:"left",click:void 0,half:!1,halfShow:!0,hints:["bad","poor","regular","good","gorgeous"],iconRange:void 0,iconRangeSame:!1,mouseout:void 0,mouseover:void 0,noRatedMsg:"Not rated yet!",number:5,numberMax:20,path:void 0,precision:!1,readOnly:!1,round:{down:.25,full:.6,up:.76},score:void 0,scoreName:"score",single:!1,space:!0,starHalf:"star-half.png",starOff:"star-off.png",starOn:"star-on.png",starType:"img",target:void 0,targetFormat:"{score}",targetKeep:!1,targetScore:void 0,targetText:"",targetType:"hint"},t.fn.raty=function(e){return this.each((function(){return new t.raty.Raty(this,e)._create()}))},t.raty.Raty=((e=function(e,i){this.element=e,this.self=t(e),this.opt=t.extend(!0,{},t.raty,i,this.self.data())}).prototype={_create:function(){this._executeCallbacks(),this._adjustNumber(),this._adjustHints(),this.opt.score=this._adjustedScore(this.opt.score),"img"!==this.opt.starType&&this._adjustStarName(),this._setPath(),this._createStars(),this.opt.cancelButton&&this._createCancel(),this.opt.precision&&this._adjustPrecision(),this._createScore(),this._apply(this.opt.score),this._setTitle(this.opt.score),this._target(this.opt.score),this.opt.readOnly?this._lock():(this.element.style.cursor="pointer",this._binds()),this.self.data("raty",this)},_adjustedScore:function(t){if(t||0===t)return this._between(t,0,this.opt.number)},_adjustHints:function(){if(this.opt.hints||(this.opt.hints=[]),this.opt.halfShow||this.opt.half)for(var t=this.opt.precision?10:2,e=0;e0&&this.scoreField.val(t),this._roundStars(t))},_attributesForIndex:function(t){var e=this._nameForIndex(t),i={alt:t,src:this.opt.path+this.opt[e]};return"img"!==this.opt.starType&&(i={"data-alt":t,class:this.opt[e]}),i.title=this._getHint(t),i},_between:function(t,e,i){return Math.min(Math.max(parseFloat(t),e),i)},_binds:function(){this.cancelButton&&(this._bindOverCancel(),this._bindClickCancel(),this._bindOutCancel()),this._bindOver(),this._bindClick(),this._bindOut()},_bindClick:function(){var e=this;this.stars.on("click.raty",(function(i){if(!e.self.data("readonly")){var s=!0,o=e.opt.half||e.opt.precision?e.self.data("score"):this.alt||t(this).data("alt");e.opt.half&&!e.opt.precision&&(o=e._roundHalfScore(o)),e.opt.click&&(s=e.opt.click.call(e.element,+o,i)),(s||void 0===s)&&e._apply(+o)}}))},_bindClickCancel:function(){this.cancelButton.on("click.raty",function(t){this.scoreField.removeAttr("value"),this.opt.click&&this.opt.click.call(this.element,null,t)}.bind(this))},_bindOut:function(){this.self.on("mouseleave.raty",function(t){var e=+this.scoreField.val()||void 0;this._apply(e),this._target(e,t),this._resetTitle(),this.opt.mouseout&&this.opt.mouseout.call(this.element,e,t)}.bind(this))},_bindOutCancel:function(){var t=this;this.cancelButton.on("mouseleave.raty",(function(e){var i=t.opt.cancelOff;if("img"!==t.opt.starType&&(i=t.opt.cancelClass+" "+i),t._setIcon(this,i),t.opt.mouseout){var s=+t.scoreField.val()||void 0;t.opt.mouseout.call(t.element,s,e)}}))},_bindOver:function(){var t=this,e=t.opt.half?"mousemove.raty":"mouseover.raty";this.stars.on(e,(function(e){var i=t._getScoreByPosition(e,this);t._fill(i),t.opt.half&&(t._roundStars(i,e),t._setTitle(i,e),t.self.data("score",i)),t._target(i,e),t.opt.mouseover&&t.opt.mouseover.call(t.element,i,e)}))},_bindOverCancel:function(){var t=this;this.cancelButton.on("mouseover.raty",(function(e){if(!t.self.data("readonly")){var i=t.opt.path+t.opt.starOff,s=t.opt.cancelOn;"img"===t.opt.starType?t.stars.attr("src",i):(s=t.opt.cancelClass+" "+s,t.stars.attr("class",i)),t._setIcon(this,s),t._target(null,e),t.opt.mouseover&&t.opt.mouseover.call(t.element,null)}}))},_buildScoreField:function(){return t("",{name:this.opt.scoreName,type:"hidden"}).appendTo(this.self)},_createCancel:function(){var e=this.opt.path+this.opt.cancelOff,i=t("<"+this.opt.starType+" />",{title:this.opt.cancelHint,class:this.opt.cancelClass});"img"===this.opt.starType?i.attr({src:e,alt:"x"}):i.attr("data-alt","x").addClass(e),"left"===this.opt.cancelPlace?this.self.prepend(" ").prepend(i):this.self.append(" ").append(i),this.cancelButton=i},_createScore:function(){var e=t(this.opt.targetScore);this.scoreField=e.length?e:this._buildScoreField()},_createStars:function(){for(var e=1;e<=this.opt.number;e++){var i=this._attributesForIndex(e);t("<"+this.opt.starType+" />",i).appendTo(this.element),this.opt.space&&ee){var n=this.opt.iconRange[e];s=this._getRangeIcon(n,a),i<=n.range&&this._setIcon(o,s),i===n.range&&e++}else s=this.opt[a?"starOn":"starOff"],this._setIcon(o,s)}},_getDecimal:function(t,e){var i=t.toString().split(".")[1],s=0;return i&&(s=parseInt(i.slice(0,e),10),"9999"===i.slice(1,5)&&s++),s},_getRangeIcon:function(t,e){return e?t.on||this.opt.starOn:t.off||this.opt.starOff},_getScoreByPosition:function(e,i){var s=parseInt(i.alt||i.getAttribute("data-alt"),10);if(this.opt.half){var o=this._getWidth();s=s-1+parseFloat((e.pageX-t(i).offset().left)/o)}return s},_getHint:function(t,e){if(0!==t&&!t)return this.opt.noRatedMsg;var i=this._getDecimal(t,1),s=Math.ceil(t),o=this.opt.hints[(s||1)-1],a=o,n=!e||this.isMove;return this.opt.precision?(n&&(i=0===i?9:i-1),a=o[i]):(this.opt.halfShow||this.opt.half)&&(a=o[i=n&&0===i||i>5?1:0]),""===a?"":a||t},_getWidth:function(){var t=this.stars[0].width||parseFloat(this.stars.eq(0).css("font-size"));return t||this._error("Could not get the icon width!"),t},_lock:function(){var t=this._getHint(this.scoreField.val());this.element.style.cursor="",this.element.title=t,this.scoreField.prop("readonly",!0),this.stars.prop("title",t),this.cancelButton&&this.cancelButton.hide(),this.self.data("readonly",!0)},_nameForIndex:function(t){return this.opt.score&&this.opt.score>=t?"starOn":"starOff"},_resetTitle:function(){for(var t=0;t5?1:.5),e+i},_roundStars:function(t,e){var i=this._starName(t,e);if(i){var s=this.opt[i],o=this.stars[Math.ceil(t)-1];this._setIcon(o,s)}},_setIcon:function(t,e){t["img"===this.opt.starType?"src":"className"]=this.opt.path+e},_setPath:function(){this.opt.path=this.opt.path||"",this.opt.path&&"/"!==this.opt.path.slice(-1)[0]&&(this.opt.path+="/")},_setTarget:function(t,e){e&&(e=this.opt.targetFormat.toString().replace("{score}",e)),t.is(":input")?t.val(e):t.html(e)},_setTitle:function(t,e){if(t){var i=parseInt(Math.ceil(t),10);this.stars[i-1].title=this._getHint(t,e)}},_starName:function(t,e){var i=+(t%1).toFixed(2);return e||this.isMove?i>.5?"starOn":"starHalf":i<=this.opt.round.down?void 0:this.opt.halfShow&&i1?e:e[0]},move:function(e){var i=parseInt(e,10),s=this._getDecimal(e,1);i>=this.opt.number&&(i=this.opt.number-1,s=10);var o=this._getWidth()/10,a=t(this.stars[i]),n=a.offset().left+o*s,r=t.Event("mousemove",{pageX:n});this.isMove=!0,a.trigger(r),this.isMove=!1},readOnly:function(t){this.self.data("readonly")!==t&&(t?(this.self.off(".raty").children(this.opt.starType).off(".raty"),this._lock()):(this._binds(),this._unlock()),this.self.data("readonly",t))},score:function(){return arguments.length?this.setScore.apply(this,arguments):this.getScore()},setScore:function(t){!0!==this.self.data("readonly")&&(t=this._adjustedScore(t),this._apply(t),this._target(t))}},e)})); }); 'use strict'; var ReviewsApp = ReviewsApp || {}; ReviewsApp.Helpers = { getSettings: function getSettings(lang) { return { scoreName: 'rating', space: true, hints: lang === 'pt' ? ['Ruim', 'Regular', 'Bom', 'Muito Bom', 'Excelente'] : ['Malo', 'Regular', 'Bueno', 'Muy Bueno', 'Excelente'], starOff: 'data:image/svg+xml;utf8,', starOn: 'data:image/svg+xml;utf8,', starHalf: 'data:image/svg+xml;utf8,' }; }, loadRaty: function loadRaty($, lang) { var settings = ReviewsApp.Helpers.getSettings(lang); $('#reviewsapp-newReviewRating').each(function () { if ($(this).find('img').length > 0) { return; } $(this).raty(settings); }); }, loadRatyReadOnly: function loadRatyReadOnly($, lang) { $('.reviewsapp-rating.reviewsapp-readOnly').each(function () { if ($(this).find('img').length > 0) { return; } var settings = ReviewsApp.Helpers.getSettings(lang); settings.readOnly = true; $(this).raty(settings); }); } }; 'use strict'; (function (LS) { var appUrl = 'https://www.opinionesnube.com'; var settings = { store: null, appPrefix: 'reviewsapp', FIRST_RENDER_AMOUNT: 8 }; var urls = { reviews: appUrl + '/reviews/' + LS.store.id + '/' + (LS.product ? LS.product.id : ''), store: appUrl + '/stores/' + LS.store.id + '?lang=' + LS.langCode, images: appUrl + '/images' }; var padWithZero = function padWithZero(number) { return ('0' + number).slice(-2); }; var getQueryParam = function getQueryParam(param) { var queryString = window.location.search; var urlParams = new URLSearchParams(queryString); return urlParams.get(param); }; var getRatingTitleHtml = function getRatingTitleHtml(averageRating, totalRatings) { return "\n \n
\n (").concat(totalRatings, ")\n \n "); }; var getRatingStarsInProductListHtml = function getRatingStarsInProductListHtml(averageRating, totalRatings) { return "\n
\n
\n (").concat(totalRatings, ")\n
\n "); }; var getReviewItemHtml = function getReviewItemHtml(item, isForCustomPage) { var productName = isForCustomPage ? "") : ''; var reviewImage = item.images && item.images.length > 0 ? "
\n \n
") : ''; var reply = item.reply ? "
\n
".concat(settings.store.widgetReplyTitle, ":
\n
").concat(item.reply, "
\n
") : ''; var d = new Date(item.date); var formattedDate = "".concat(padWithZero(d.getDate()), "/").concat(padWithZero(d.getMonth() + 1), "/").concat(d.getFullYear()); return "\n
\n \n ".concat(!settings.store.hideDates ? formattedDate : '', " por ").concat(item.authorName, "\n \n ").concat(productName, "\n
\n
").concat(item.title, "
\n
").concat(item.text, "
\n ").concat(reviewImage, "\n ").concat(reply, "\n
\n "); }; var getReviewsSummaryHtml = function getReviewsSummaryHtml(summary) { var store = settings.store; if (summary.totalRatings === 0) { return "
".concat(store.widgetFirstReviewText, "
"); } return "\n ".concat(summary.averageRating, "\n
\n
\n ", "(".concat(store.widgetBasedOn, " ").concat(summary.totalRatings, " ").concat(summary.totalRatings === 1 ? store.widgetOpinion : store.widgetOpiniones, ")"), "\n
"); }; var getLegend = function getLegend() { if (LS.langCode === 'es') { return 'Usando App Trusty'; } else if (LS.langCode === 'pt') { return 'Usando App Trusty'; } return ''; }; var getReviewsWidgetHtml = function getReviewsWidgetHtml() { var store = settings.store; return "\n
\n\n \n
\n ×\n \n
\n\n \n\n
").concat(store.widgetThanksText, "
\n\n
\n
\n \n
\n\n
\n
\n
\n\n
\n \n
\n\n
\n \n \n
\n\n
\n \n
\n \n \n
\n
\n\n \n\n \n
\n\n
\n\n
\n\n ").concat(getLegend(), "\n\n \n\n \n
\n "); }; var getLsonLdForHighlightItem = function getLsonLdForHighlightItem(item) { return "\n "); }; var getJsonLdForReviews = function getJsonLdForReviews(data) { return "\n {\n \"@context\": \"http://schema.org/\",\n \"@type\": \"Product\",\n \"@id\": \"".concat(window.location.href, "\",\n \"name\": \"").concat(LS.product.name, "\",\n \"aggregateRating\": {\n \"@type\": \"AggregateRating\",\n \"ratingValue\": ").concat(data.summary.averageRating, ",\n \"reviewCount\": ").concat(data.summary.totalRatings, "\n }\n }"); }; var getReviewHighlightItemHtml = function getReviewHighlightItemHtml(item) { var firstLetter = item.authorName[0].toUpperCase(); var productPreposition = LS.langCode === 'es' ? 'en' : 'no'; return "\n
\n ".concat(getLsonLdForHighlightItem(item), "\n
\n
\n ").concat(firstLetter, "\n
\n
\n
por ").concat(item.authorName, " ").concat(productPreposition, " ").concat(item.productName, "
\n
\n
").concat(item.title, "
\n
").concat(item.text, "
\n ").concat(item.images && item.images.length > 0 ? "") : '', "\n
\n "); }; var getReviewHighlightsContainerHtml = function getReviewHighlightsContainerHtml(items) { return "\n
\n
\n ").concat(items, "\n
\n
>
\n
<
\n
\n "); }; var renderTitleHtmlContainer = function renderTitleHtmlContainer(averageRating, totalRatings) { if (!settings.store.starsInProductListForAllProducts && totalRatings === 0) { return; } var titleLocationSelector = { 'generic': '[data-store^="product-name"]', 'material': '[data-store^="product-price"]', 'uyuni': '[data-store^="product-price"]' }; var titleElementContainer = getRatingTitleHtml(averageRating, totalRatings); var selector = titleLocationSelector[LS.theme.code] || titleLocationSelector['generic']; var titleHtmlContainer = $(selector).first(); if (titleHtmlContainer.length === 0) { console.error('Trusty: No se pudo insertar las estrellas en el título del producto'); return; } titleHtmlContainer.after(titleElementContainer); }; var loadStylesheet = function loadStylesheet() { var style = document.createElement('style'); style.innerHTML = '.border-reset{border:1px solid #ABABAB;padding:4px}.reviewsapp{width:100%;clear:both}.reviewsapp input,.reviewsapp textarea,.reviewsapp label{margin:0}.reviewsapp .reviewsapp-separator{border-bottom:1px solid #eaeaea}.reviewsapp #reviewsapp-thankyou{display:none;font-size:18px;padding:20px 0;text-align:center}.reviewsapp .reviewsapp-showAll-button-container{margin-top:10px;text-align:center}.reviewsapp #reviewsapp-showAll-button{display:none;opacity:.7;text-decoration:underline;cursor:pointer}.reviewsapp #reviewsapp-showAll-button:hover{opacity:1;text-decoration:none}.reviewsapp #reviewsapp-summary{border-top:1px solid #eaeaea;padding:30px 10px}.reviewsapp #reviewsapp-summary #reviewsapp-addReview-button{float:right;margin-bottom:10px;text-decoration:underline;cursor:pointer}.reviewsapp #reviewsapp-summary #reviewsapp-addReview-button:hover{text-decoration:none}.reviewsapp #reviewsapp-summary .reviewsapp-summaryReviewsNumber{font-size:1.5em;font-weight:bolder}.reviewsapp #reviewsapp-summary #reviewsapp-summaryEmptyText{font-weight:bolder}.reviewsapp #reviewsapp-summary .reviewsapp-summaryRating{margin-left:8px;display:inline-block;line-height:23px}.reviewsapp #reviewsapp-summary .reviewsapp-summaryRating img{vertical-align:top}.reviewsapp .reviewsapp-reviewItem{padding:20px 5px;border-bottom:1px solid #eaeaea}.reviewsapp .reviewsapp-reviewItem .reviewsapp-title{font-size:15px;font-weight:bolder;margin-left:20px}.reviewsapp .reviewsapp-reviewItem .reviewsapp-rating{margin-bottom:10px;vertical-align:middle;display:inline-block}.reviewsapp .reviewsapp-reviewItem .reviewsapp-text{margin-left:20px;font-size:15px;float:none}.reviewsapp .reviewsapp-reviewItem .reviewsapp-date-author{font-size:16px;float:right;color:#90949c}.reviewsapp .reviewsapp-reviewItem .reviewsapp-image{cursor:zoom-in;border:1px solid #dddddd;border-radius:4px;padding:4px;margin-left:20px;margin-top:10px;display:inline-block}.reviewsapp .reviewsapp-reviewItem .reviewsapp-image img{max-height:100px}.reviewsapp .reviewsapp-reviewItem .reviewsapp-reply{margin-top:20px;padding:10px;background-color:#f9f9f9;border-radius:5px;margin-left:20px}.reviewsapp .reviewsapp-reviewItem .reviewsapp-reply-title{font-size:14px;font-weight:bold;margin-bottom:5px;color:#333}.reviewsapp .reviewsapp-reviewItem .reviewsapp-reply-text{font-size:13px;color:#666}@media only screen and (max-width: 480px){.reviewsapp .reviewsapp-reviewItem .reviewsapp-date-author{font-size:13px}.reviewsapp .reviewsapp-reviewItem .reviewsapp-text{margin-left:0px}.reviewsapp .reviewsapp-reviewItem .reviewsapp-title{margin-left:0px}}.reviewsapp.reviewsapp-widgetContainer{margin-bottom:30px}.reviewsapp.reviewsapp-widgetContainer.material{width:75%;margin:0 auto}.reviewsapp.reviewsapp-widgetContainer.minimal{padding-right:15px;padding-left:15px}.reviewsapp.reviewsapp-widgetContainer.idea{margin-top:20px}.reviewsapp.reviewsapp-widgetContainer.atlantico{background-color:white}.reviewsapp.reviewsapp-widgetContainer.amazonas{scroll-margin-top:130px}.reviewsapp.reviewsapp-widgetContainer.new_linkedman{scroll-margin-top:150px}@media only screen and (max-width: 480px){.reviewsapp.reviewsapp-widgetContainer.new_linkedman{scroll-margin-top:50px}}.reviewsapp.reviewsapp-widgetContainer.baires,.reviewsapp.reviewsapp-widgetContainer.morelia{scroll-margin-top:180px}.reviewsapp.reviewsapp-widgetContainer.recife{scroll-margin-top:140px}.reviewsapp.reviewsapp-widgetContainer.rio,.reviewsapp.reviewsapp-widgetContainer.bahia{scroll-margin-top:100px}.reviewsapp.reviewsapp-widgetContainer.uyuni,.reviewsapp.reviewsapp-widgetContainer.material{scroll-margin-top:60px}.reviewsapp.reviewsapp-widgetContainer.toluca{scroll-margin-top:120px}.reviewsapp.reviewsapp-widgetContainer.style{scroll-margin-top:80px}@media only screen and (max-width: 480px){.reviewsapp.reviewsapp-widgetContainer.style{scroll-margin-top:120px}}.reviewsapp #reviewsapp-newReview{display:none;width:75%;margin:-20px auto 2em auto}@media only screen and (max-width: 480px){.reviewsapp #reviewsapp-newReview{width:100%}}.reviewsapp #reviewsapp-newReview input,.reviewsapp #reviewsapp-newReview textarea,.reviewsapp #reviewsapp-newReview label{font-size:16px}.reviewsapp #reviewsapp-newReview #reviewsapp-submit:hover{opacity:1}.reviewsapp #reviewsapp-newReview #reviewsapp-submit{padding:2px 6px 3px;font-size:18px;opacity:.7;border:1px solid #ABABAB;text-transform:uppercase;background-color:white}@media only screen and (max-width: 480px){.reviewsapp #reviewsapp-newReview #reviewsapp-submit{color:black}}.reviewsapp #reviewsapp-newReview .reviewsapp-field{margin:12px 0}.reviewsapp #reviewsapp-newReview #reviewsapp-newReviewAuthorName{width:48%;height:100%;border:1px solid #ABABAB;padding:4px}@media only screen and (max-width: 480px){.reviewsapp #reviewsapp-newReview #reviewsapp-newReviewAuthorName{width:100%;margin-bottom:8px}}.reviewsapp #reviewsapp-newReview #reviewsapp-newReviewAuthorEmail{width:48%;height:100%;float:right;border:1px solid #ABABAB;padding:4px}@media only screen and (max-width: 480px){.reviewsapp #reviewsapp-newReview #reviewsapp-newReviewAuthorEmail{width:100%;float:none}}.reviewsapp #reviewsapp-newReview #reviewsapp-newReviewTitle{width:100%;height:100%;border:1px solid #ABABAB;padding:4px}.reviewsapp #reviewsapp-newReview #reviewsapp-newReviewText{width:100%;height:100px;display:block;box-sizing:border-box;border:1px solid #ABABAB;padding:4px}.reviewsapp #reviewsapp-newReview #reviewsapp-validation{color:#ff0000;display:inline-block;margin-left:10px}.reviewsapp #reviewsapp-newReview #reviewsapp-image-preview{max-height:100px}.reviewsapp #reviewsapp-newReview #reviewsapp-image-preview-container{margin:12px 0;position:relative;display:none}.reviewsapp #reviewsapp-newReview #reviewsapp-image-remove{position:absolute;cursor:pointer;top:0;border:0}.reviewsapp #reviewsapp-newReview #reviewsapp-image-submit{width:100%}.reviewsapp #reviewsapp-image-preview-modal{display:none;position:fixed;z-index:9999999;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,0.8)}.reviewsapp #reviewsapp-image-preview-modal-img{position:fixed;max-height:60%;top:50%;left:50%;transform:translate(-50%, -50%)}.reviewsapp #reviewsapp-image-preview-modal-close{position:absolute;right:0;color:white;font-size:40px;line-height:1.5;opacity:1;font-family:Verdana,sans-serif;background-color:#000;padding:0px 8px 2px 8px}.reviewsapp #reviewsapp-image-preview-modal-close:hover,.reviewsapp #reviewsapp-image-preview-modal-close:focus{color:#bbb;text-decoration:none;cursor:pointer}.reviewsapp .reviewsapp-legend{font-size:10px;float:right;color:#ABABAB}.reviewsapp .reviewsapp-legend a{color:#ABABAB}.reviewsapp.reviewsapp-productRatingInTitle{cursor:pointer}.reviewsapp.reviewsapp-productRatingInTitle span.reviewsapp-amount{text-decoration:underline}.reviewsapp.reviewsapp-productRatingInTitle div.reviewsapp-rating{display:inline-block;vertical-align:-3px}.reviewsapp.reviewsapp-productRatingInTitle.zen{display:block;text-align:center;margin-bottom:10px}.reviewsapp.reviewsapp-productRatingInTitle.gardener{float:right;margin-bottom:20px}.reviewsapp.reviewsapp-productRatingInTitle.gardener span{vertical-align:bottom}.reviewsapp.reviewsapp-productRatingInTitle.minimal{margin-bottom:20px}.reviewsapp.reviewsapp-productRatingInTitle.minimal span{vertical-align:bottom}.reviewsapp.reviewsapp-productRatingInTitle.style{margin-bottom:20px}.reviewsapp.reviewsapp-productRatingInTitle.style div{vertical-align:0}.reviewsapp.reviewsapp-productRatingInTitle.habitus div{vertical-align:0}.reviewsapp.reviewsapp-productRatingInTitle.material div{vertical-align:1px}.reviewsapp.reviewsapp-productRating div.reviewsapp-rating{display:inline-block;vertical-align:-2px;margin-left:auto;margin-right:auto}.reviewsapp.reviewsapp-productRating img{height:initial;width:initial;vertical-align:initial;display:initial;opacity:initial}.reviewsapp.reviewsapp-productRating.minimal{text-align:center}.reviewsapp.reviewsapp-productRating.luxury{text-align:center}.reviewsapp.reviewsapp-productRating.cubo,.reviewsapp.reviewsapp-productRating.lima,.reviewsapp.reviewsapp-productRating.toluca,.reviewsapp.reviewsapp-productRating.baires,.reviewsapp.reviewsapp-productRating.morelia,.reviewsapp.reviewsapp-productRating.recife{margin-top:.5rem !important}.reviewsapp.reviewsapp-productRating.new_linkedman{margin-top:.25rem}.reviewsapp.reviewsapp-productRating div.reviewsapp-rating.material{vertical-align:0}.reviewsapp.reviewsapp-productRating.uyuni{padding-left:1rem}.recife .item-name,.brasilia .product-item-name{-webkit-line-clamp:unset}.reviewsapp-highlights-container{display:block;position:relative;margin-top:2em;margin-bottom:4em;max-width:80%;margin-left:auto;margin-right:auto;padding-left:35px;padding-right:35px}@media only screen and (max-width: 480px){.reviewsapp-highlights-container{padding-left:35px;padding-right:35px;max-width:100%}}.reviewsapp-highlights-container .reviewsapp-highlights-nav{cursor:pointer;position:absolute;top:50%;font-size:3em;z-index:3;padding:12px}.reviewsapp-highlights-container .reviewsapp-highlights-nav.reviewsapp-highlights-nav-left{left:0}@media only screen and (max-width: 480px){.reviewsapp-highlights-container .reviewsapp-highlights-nav.reviewsapp-highlights-nav-left{padding-left:5px}}.reviewsapp-highlights-container .reviewsapp-highlights-nav.reviewsapp-highlights-nav-right{right:0}@media only screen and (max-width: 480px){.reviewsapp-highlights-container .reviewsapp-highlights-nav.reviewsapp-highlights-nav-right{padding-right:5px}}.reviewsapp-highlights-container.material{max-width:100%}.reviewsapp-highlights-container.new_linkedman{max-width:90%;margin-bottom:2em}@media only screen and (max-width: 480px){.reviewsapp-highlights-container.new_linkedman{max-width:80%}}.reviewsapp-highlights-container.new_linkedman .reviewsapp-highlights-item{flex:0 0 calc(30% - 33px)}@media only screen and (max-width: 480px){.reviewsapp-highlights-container.new_linkedman .reviewsapp-highlights-item{flex:0 0 calc(80%)}}.reviewsapp-highlights-container.atlantico{padding-top:40px}.reviewsapp-highlights-container.rio{padding-top:40px}.reviewsapp-highlights-container.style{max-width:100%}@media only screen and (max-width: 480px){.reviewsapp-highlights-container.zen,.reviewsapp-highlights-container.luxury{max-width:80%}}.reviewsapp-highlights-container.zen .reviewsapp-highlights-item,.reviewsapp-highlights-container.luxury .reviewsapp-highlights-item{flex:0 0 calc(28%)}@media only screen and (max-width: 480px){.reviewsapp-highlights-container.zen .reviewsapp-highlights-item,.reviewsapp-highlights-container.luxury .reviewsapp-highlights-item{flex:0 0 calc(80%)}}.reviewsapp-highlights{display:flex;text-align:center;justify-content:space-between;margin-left:auto;margin-right:auto;overflow:hidden;padding-top:5em;overflow-x:auto;scroll-behavior:smooth;-webkit-overflow-scrolling:touch}.reviewsapp-highlights .reviewsapp-author-initials-container{margin-top:-60px}.reviewsapp-highlights .reviewsapp-author-initials-container figure{width:80px;height:80px;margin:0 auto;padding:0;border-radius:50%;-webkit-border-radius:50%;-moz-border-radius:50%;overflow:hidden;background-color:#e6e6e6;position:relative;text-align:center}.reviewsapp-highlights .reviewsapp-author-initials-char{width:100%;font-size:30px;font-weight:600;line-height:inherit;color:#000;padding:18px 0 17px;display:inline-block;position:absolute;top:50%;left:0;-webkit-transform:translate(0, -50%);-ms-transform:translate(0, -50%);transform:translate(0, -50%)}.reviewsapp-highlights .reviewsapp-highlights-item{flex:0 0 calc(30%);padding:20px 20px;border-bottom:none;border:1px solid #eaeaea;margin:0 10px}@media only screen and (max-width: 480px){.reviewsapp-highlights .reviewsapp-highlights-item{flex:0 0 calc(95%);margin-top:4em}}.reviewsapp-highlights .reviewsapp-highlights-rating{margin-top:20px;margin-bottom:15px;margin-left:auto;margin-right:auto}.reviewsapp-highlights .reviewsapp-highlights-title{font-size:16px;font-weight:bolder}.reviewsapp-highlights .reviewsapp-highlights-author{color:#90949c;font-weight:bolder;margin-top:15px}.reviewsapp-highlights .reviewsapp-highlights-author a{color:#90949c}.reviewsapp-highlights .reviewsapp-highlights-image{margin-top:20px;max-width:100%}#reviewsapp-customReviewsList .reviewsapp-product-name{font-size:16px;font-weight:bolder}#reviewsapp-customReviewsList.style img{height:initial !important;width:initial !important;vertical-align:initial;display:initial}#reviewsapp-customReviewsList.new_linkedman p,#reviewsapp-customReviewsList.new_linkedman div{margin:0}'; document.head.appendChild(style); }; var getAppHtmlContainer = function getAppHtmlContainer() { var templateSelectors = { 'new_linkedman': 'body .container .row-fluid.producto', 'material': 'div#single-product', 'zen': 'body div.content-fluid .row-fluid:last-child .span8.offset2', 'luxury': '#single-product', 'style': 'div.comments-area', 'minimal': '.js-product-detail', 'habitus': 'body div.page-product.container > .row:last-child', 'gardener': 'div.comments-area', 'uyuni': '[data-store^="product-info"]' }; var bestEffort = 'body div#container, body div.container, body div#content, body > div:first-child'; var container = $('#' + settings.appPrefix); if (container.length !== 0) { return container; } if (templateSelectors[LS.theme.code]) { return $(templateSelectors[LS.theme.code]); } return container.length === 0 ? $(bestEffort).last() : null; }; var renderReviewsWidgetInProductPage = function renderReviewsWidgetInProductPage() { var reviewsPromise = $.get(urls.reviews); var appHtmlContainer = getAppHtmlContainer().first(); if (appHtmlContainer.length === 0) { throw new Error('Trusty: No se pudo encontrar una posición en la página donde insertar el widget'); } var markup = getReviewsWidgetHtml(); appHtmlContainer.append(markup); reviewsPromise.done(function (data) { renderReviews(data); var scrollToReviewParam = getQueryParam('scrollToTrustyApp'); if (scrollToReviewParam) { var widget = document.getElementById('reviewsapp-newReview'); widget.style.display = 'block'; widget.scrollIntoView({ behavior: 'smooth', block: 'end' }); } }).fail(function () { $('.' + settings.appPrefix).remove(); throw new Error('Trusty: No se pudo obtener el markup para las reviews'); }); }; var bindImageModal = function bindImageModal() { var elements = document.getElementsByClassName('reviewsapp-image'); Array.from(elements).forEach(function (el) { return el.addEventListener('click', function () { var previewModal = document.getElementById('reviewsapp-image-preview-modal'); var previewModalImage = document.getElementById('reviewsapp-image-preview-modal-img'); previewModal.style.display = 'block'; previewModalImage.src = $(this).children('img').attr('src'); }); }); document.getElementById('reviewsapp-image-preview-modal-close').addEventListener('click', function () { var previewModal = document.getElementById('reviewsapp-image-preview-modal'); previewModal.style.display = 'none'; }); }; var renderReviews = function renderReviews(data) { renderTitleHtmlContainer(data.summary.averageRating, data.summary.totalRatings); var initialReviewsToShow = data.reviews.slice(0, settings.FIRST_RENDER_AMOUNT); var initialReviewsMarkup = initialReviewsToShow.map(function (i) { return getReviewItemHtml(i); }).join(''); $('#reviewsapp-reviewsList').html(initialReviewsMarkup); $('#reviewsapp-summary-content').html(getReviewsSummaryHtml(data.summary)); $('#reviewsapp-jsonld').html(getJsonLdForReviews(data)); if (data.reviews.length > settings.FIRST_RENDER_AMOUNT) { $('#reviewsapp-showAll-button').show(); } $('#reviewsapp-showAll-button').click(function (event) { var allReviews = data.reviews.slice(settings.FIRST_RENDER_AMOUNT, data.reviews.length); var allReviewsMarkup = allReviews.map(function (i) { return getReviewItemHtml(i); }).join(''); $('#reviewsapp-reviewsList').append(allReviewsMarkup); $('#reviewsapp-showAll-button').hide(); ReviewsApp.Helpers.loadRatyReadOnly($, LS.langCode); bindImageModal(); event.preventDefault(); }); $('#reviewsapp-newReview').submit(function (event) { onNewReviewSubmitted(); event.preventDefault(); }); $('#reviewsapp-image-submit').change(function () { document.getElementById('reviewsapp-image-preview').src = window.URL.createObjectURL(this.files[0]); $('#reviewsapp-image-preview-container').show(); }); $('#reviewsapp-image-remove').click(function () { document.getElementById('reviewsapp-image-submit').value = ''; $('#reviewsapp-image-preview-container').hide(); }); ReviewsApp.Helpers.loadRaty($, LS.langCode); bindImageModal(); ReviewsApp.Helpers.loadRatyReadOnly($, LS.langCode); }; var validateForm = function validateForm() { var validationContainer = $('#reviewsapp-validation'); validationContainer.hide(); if (!$('#reviewsapp-newReviewRating input').val()) { var message = $('#reviewsapp-newReviewRating input').parent().attr('data-validation'); validationContainer.html(message); validationContainer.show(); return false; } return true; }; var onNewReviewSubmitted = function onNewReviewSubmitted() { if (!validateForm()) { return; } var formData = new FormData(document.querySelector('#reviewsapp-newReview')); formData.append('storeId', LS.store.id); formData.append('productName', LS.product.name); formData.append('productId', LS.product.id); formData.append('productLink', window.location.href); formData.append('date', new Date()); $('#reviewsapp-submit').val('...'); fetch("".concat(appUrl, "/reviews/").concat(LS.store.id, "/").concat(LS.product.id), { method: 'POST', body: formData }).then(function () { $('#reviewsapp-newReview').hide('fast', function () { $('#reviewsapp-thankyou').show(); }); }); }; var renderStarsInProductList = function renderStarsInProductList() { var specificTemplateContainers = { 'amazonas': '.item-description, [data-store^="product-item-info"]', 'idea': '.item-description', 'lima': '.item-description', 'toluca': '.item-description', 'baires': '.item-description', 'recife': '.item-description [data-store^="product-item-name"]', 'morelia': '.item-description', 'rio': '.item-description', 'cubo': '.item-description-container', 'material': '.item-info-container, [data-store^="product-item-info"]', 'zen': '.item-info-container', 'style': '.item-price-container', 'habitus': '.caption', 'gardener': '.item-info-container, [data-store^="product-item-info"]', 'luxury': '.item-info-container', 'atlantico': '[data-store^="product-item-info"]', 'flex': '[data-store^="product-item-price"]', 'brasilia': '[data-store^="product-item-name"]' }; $.get("".concat(appUrl, "/reviews/").concat(LS.store.id, "/summary")).done(function (data) { $('div[itemtype$="Product"]:visible, div[data-product-type$="list"]').each(function () { var container = $(this); var productId = container.data('product-id'); if (container.find('.reviewsapp-productRating').length > 0) { return; } var productReview = data.find(function (o) { return o.productId === productId; }); container.addClass(LS.theme.code); var ratingElement = null; if (productReview) { ratingElement = getRatingStarsInProductListHtml(productReview.averageRating, productReview.totalRatings); } else if (settings.store.starsInProductListForAllProducts) { ratingElement = getRatingStarsInProductListHtml(0, 0); } else { return; } if (specificTemplateContainers[LS.theme.code]) { var starsContainer = container.find(specificTemplateContainers[LS.theme.code]).first(); starsContainer.append(ratingElement); } else { container.append(ratingElement); } }); ReviewsApp.Helpers.loadRatyReadOnly($, LS.langCode); if (typeof $masonry_grid !== 'undefined' && typeof $masonry_grid.layout === 'function') { $masonry_grid.layout(); } }); }; var renderStarsInProductListWhenMoreProductsAreAdded = function renderStarsInProductListWhenMoreProductsAreAdded() { var callback = function callback(mutationsList, _observer) { var injectedSomething = false; for (var mutation of mutationsList) { if (mutation.type === 'childList') { for (var node of mutation.addedNodes) { if ($(node).is('div[data-product-type$="list"]') || $(node).find('div[data-product-type$="list"]').length > 0) { injectedSomething = true; } } } } if (injectedSomething) { renderStarsInProductList(); } }; var observer = new MutationObserver(callback); var table = document.getElementsByClassName('js-product-table')[0]; if (!table) { return console.log('Trusty: No se pudo agregar Observer para monitorear el agregado dínamico de nuevos productos'); } observer.observe(table, { childList: true }); }; var renderCustomReviewsList = function renderCustomReviewsList() { var container = $('#reviewsapp-customReviewsList'); if (container.length === 0) { return; } var limit = container.data('limit'); var productId = container.data('productid'); var params = new URLSearchParams(); if (limit) { params.append('limit', limit); } if (productId) { params.append('productId', productId); } $.get("".concat(appUrl, "/reviews/").concat(LS.store.id, "?").concat(params.toString())).done(function (data) { var items = data.map(function (i) { return getReviewItemHtml(i, true); }).join(''); container.addClass(LS.theme.code); container.html(items); ReviewsApp.Helpers.loadRatyReadOnly($, LS.langCode); bindImageModal(); }); }; var navigateHighlightsCarousel = function navigateHighlightsCarousel(direction) { var carousel = document.querySelector('.reviewsapp-highlights'); var itemWidth = document.querySelector('.reviewsapp-highlights-item').offsetWidth + 20; var scroll = direction === 'right' ? itemWidth : -itemWidth; carousel.scrollTo({ left: carousel.scrollLeft + scroll, behavior: 'smooth' }); }; var renderReviewsHighlights = function renderReviewsHighlights() { $.get("".concat(appUrl, "/reviews/").concat(LS.store.id, "/highlights")).done(function (data) { if (!data || data.length === 0) { return; } var containerSelector = settings.store.reviewsHighlightsSelector ? "".concat(settings.store.reviewsHighlightsSelector) : '[data-store="products-home-featured"], [data-store="home-products-featured"]'; var container = $(containerSelector).last(); if (container.length === 0) { console.error('Trusty: No se pudieron insertar las opiniones destacadas'); return; } var items = data.map(function (i) { return getReviewHighlightItemHtml(i); }).join(''); container.append(getReviewHighlightsContainerHtml(items)); var reviewsHighlightContainer = document.querySelector('.reviewsapp-highlights'); var showButtons = reviewsHighlightContainer.scrollWidth > reviewsHighlightContainer.clientWidth; var leftButton = document.querySelector('.reviewsapp-highlights-nav-left'); leftButton.addEventListener('click', function () { navigateHighlightsCarousel('left'); }); leftButton.style.display = showButtons ? 'block' : 'none'; var rightButton = document.querySelector('.reviewsapp-highlights-nav-right'); rightButton.addEventListener('click', function () { navigateHighlightsCarousel('right'); }); rightButton.style.display = showButtons ? 'block' : 'none'; ReviewsApp.Helpers.loadRatyReadOnly($, LS.langCode); }); }; var init = function init() { if (typeof $ === 'undefined' || !$.fn || !$.fn.jquery) { throw new Error('Trusty: No se pudo encontrar jQuery'); } loadStylesheet(); $.get(urls.store).done(function (store) { settings.store = store; if (LS.product) { renderReviewsWidgetInProductPage(); } if (store.starsInProductList) { renderStarsInProductList(); renderStarsInProductListWhenMoreProductsAreAdded(); ReviewsApp.Helpers.renderStarsInProductList = renderStarsInProductList; } if (LS.template === 'home' && store.showReviewsHighlights) { renderReviewsHighlights(); } renderCustomReviewsList(); }); }; useJquery().then(function () { return init(); }); })(LS);