Version Description
- FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
- TWEAKED: css minor changes
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 2.7.8 |
Comparing to | |
See all releases |
Code changes from version 2.7.7 to 2.7.8
- admin/js/yasr-settings.js +1 -1
- includes/css/yasr.css +3 -0
- includes/js/src/yasr-front.js +19 -12
- includes/js/yasr-front.js +1 -1
- includes/shortcodes/classes/YasrVisitorVotes.php +1 -0
- includes/yasr-includes-functions.php +2 -3
- readme.txt +6 -2
- yet-another-stars-rating.php +2 -2
admin/js/yasr-settings.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(2)},function(t,e){var r;if(document.getElementsByClassName("nav-tab-active").length>0&&(r=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===r){var a=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===a&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===r&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===r){var s=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===s){var o=jQuery("#yasr-edit-form-number-elements").attr("value");o++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(o>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+o+' <input type="text" name="edit-multi-set-element-'+o+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),o++}))}else s>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===r&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,r){"use strict";var a,n;r.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};for(var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return c(a)},y=wp.i18n.__,g=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],p=0;p<g.length;p++)v(g[p]);function v(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;f(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),s=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=_(n),s=_(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),d=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v=document.getElementById(m),f=document.getElementById(g),b=document.getElementById(p),E="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var k={action:"yasr_load_vv",post_id:o,nonce_visitor:d};document.getElementById(i).innerHTML=yasrCommonData.loaderHtml,jQuery.get(yasrCommonData.ajaxurl,k).done((function(t){var e,r=JSON.parse(t);e=!0===n||r.yasr_visitor_votes.stars_attributes.read_only,a=(a=r.yasr_visitor_votes.number_of_votes>0?r.yasr_visitor_votes.sum_votes/r.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),h(u,a,o,e,i,l,d,c,v,f,E,b),!0!==n&&(null!==v&&(v.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==f&&(f.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==b&&(b.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,b.style.display=""))})).fail((function(t,e,r,m){console.info(y("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(u,a,o,s,i,l,d,c,v,f,E,b),!0!==n&&(b.style.display="")}))}else h(u,a,o,s,i,l,d,c,v,f,E,b)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e,r,a=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(r=window.getComputedStyle(e[0],null).getPropertyValue("color")),r)&&(document.getElementById(t.item(n).id).style.fill=r);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){s!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){a=s}})}(n)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),s=n.id,o=n.getAttribute("data-rater-readonly");o=_(o);f(16,s,n,1,o,!1,(function(t,a){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function f(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,r,a,n,s,o,i,l,u,d,c){e=parseFloat(e),a=_(a);var m=document.getElementById(n);document.getElementById(n).innerHTML="";f(t,n,m,1,a,e,(function(t,e){document.getElementById(d).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==c&&(c.innerHTML=t.rating_saved_text,c.style.display=""),document.getElementById(d).innerHTML=""})),e()}))}function _(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function b(t){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=B(t);if(e){var n=B(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return w(this,r)}}function w(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var j=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return f(r,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",j("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",j("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function L(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function T(t){var e="after",r=j("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:r}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:r}))}function Q(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(L,{colClass:e,post:t.post}),React.createElement(T,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(Q,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,r,a,n=I(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=s,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(j("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(j("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(j(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(j(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:j("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:a},j("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},j("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},j("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},j("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,j("Order By","yet-another-stars-rating-pro"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,s="most-rated-posts-"+r,o="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(S,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(o=u.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,j("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var N,A=function(t){var e=G.value,r=document.getElementById("yasr-builder-shortcode").textContent,a=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];a=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",a),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+r).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.style.display="",r.style.display="none",a.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,r,a,n,s,o,i){n.style.display="",t.style.display="none",r.style.display="none",a.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},U=function(t,e,r,a,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8];s.style.display="",e.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display=""),!0===l?(r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var J=[],q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""};N=q.name,document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!1):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!0):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!1),q.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!0),q.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),q.name=t.target.value,N=q.name+q.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(q.setid=" setid="+t.target.value),J=wp.hooks.applyFilters("yasrBuilderFilterShortcode",q);for(var e=2;q.length;e++)J.hasOwnProperty(q[e])&&(q[e]=J[e]);N=q.name+q.setid+q.rows+q.view+q.minvotesmost+q.minvoteshg+q.size+q.txtPosition+q.txt+q.display+q.category+q.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]"),!0===it&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&A()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){A(),it=!0}}}]);
|
1 |
+
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(2)},function(t,e){var r;if(document.getElementsByClassName("nav-tab-active").length>0&&(r=document.getElementsByClassName("nav-tab-active")[0].id),"general_settings"===r){var a=document.getElementById("yasr_auto_insert_switch").checked,n=document.getElementById("yasr-general-options-stars-title-switch").checked;!1===a&&jQuery(".yasr-auto-insert-options-class").prop("disabled",!0),!1===n&&jQuery(".yasr-stars-title-options-class").prop("disabled",!0),document.getElementById("yasr_auto_insert_switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-auto-insert-options-class").prop("disabled",!1):jQuery(".yasr-auto-insert-options-class").prop("disabled",!0)})),document.getElementById("yasr-general-options-stars-title-switch").addEventListener("change",(function(){this.checked?jQuery(".yasr-stars-title-options-class").prop("disabled",!1):jQuery(".yasr-stars-title-options-class").prop("disabled",!0)})),document.getElementById("yasr-settings-custom-texts").addEventListener("click",(function(){document.getElementById("yasr-settings-custom-text-before-overall").value="Our Score",document.getElementById("yasr-settings-custom-text-before-visitor").value="Click to rate this post!",document.getElementById("yasr-settings-custom-text-after-visitor").value="[Total: %total_count% Average: %average%]",document.getElementById("yasr-settings-custom-text-must-sign-in").value="You must sign in to vote",document.getElementById("yasr-settings-custom-text-already-rated").value="You have already voted for this article with %rating%"}))}if("style_options"===r&&(wp.codeEditor.initialize(document.getElementById("yasr_style_options_textarea"),yasr_cm_settings),jQuery("#yasr-color-scheme-preview-link").on("click",(function(){return jQuery("#yasr-color-scheme-preview").toggle("slow"),!1})),wp.hooks.doAction("yasrStyleOptions")),"manage_multi"===r){var s=parseInt(document.getElementById("n-multiset").value);if(jQuery("#yasr-multi-set-doc-link").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),jQuery("#yasr-multi-set-doc-link-hide").on("click",(function(){jQuery("#yasr-multi-set-doc-box").toggle("slow")})),1===s){var o=jQuery("#yasr-edit-form-number-elements").attr("value");o++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(o>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var t=jQuery(document.createElement("tr"));t.html('<td colspan="2">Element #'+o+' <input type="text" name="edit-multi-set-element-'+o+'" value="" ></td>'),t.appendTo("#yasr-table-form-edit-multi-set"),o++}))}else s>1&&(jQuery("#yasr-button-select-set-edit-form").on("click",(function(){var t={action:"yasr_get_multi_set",set_id:jQuery("#yasr_select_edit_set").val()};return jQuery.post(ajaxurl,t,(function(t){jQuery("#yasr-multi-set-response").show(),jQuery("#yasr-multi-set-response").html(t)})),!1})),jQuery(document).ajaxComplete((function(){var t=jQuery("#yasr-edit-form-number-elements").attr("value");t++,jQuery("#yasr-add-field-edit-multiset").on("click",(function(){if(t>9)return jQuery("#yasr-element-limit").show(),jQuery("#yasr-add-field-edit-multiset").hide(),!1;var e=jQuery(document.createElement("tr"));e.html('<td colspan="2">Element #'+t+' <input type="text" name="edit-multi-set-element-'+t+'" value="" ></td>'),e.appendTo("#yasr-table-form-edit-multi-set"),t++}))})))}"migration_tools"===r&&(jQuery("#yasr-import-ratemypost-submit").on("click",(function(){document.getElementById("yasr-import-ratemypost-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_ratemypost",nonce:document.getElementById("yasr-import-rmp-nonce").value};jQuery.post(ajaxurl,t,(function(t){t=JSON.parse(t),document.getElementById("yasr-import-ratemypost-answer").innerHTML=t}))})),jQuery("#yasr-import-wppr-submit").on("click",(function(){document.getElementById("yasr-import-wppr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_wppr",nonce:document.getElementById("yasr-import-wppr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-wppr-answer").innerHTML=t}))})),jQuery("#yasr-import-kksr-submit").on("click",(function(){document.getElementById("yasr-import-kksr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_kksr",nonce:document.getElementById("yasr-import-kksr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-kksr-answer").innerHTML=t}))})),jQuery("#yasr-import-mr-submit").on("click",(function(){document.getElementById("yasr-import-mr-answer").innerHTML='<img src="'+yasrCommonData.loaderHtml+'"</img>';var t={action:"yasr_import_mr",nonce:document.getElementById("yasr-import-mr-nonce").value};jQuery.post(ajaxurl,t,(function(t){document.getElementById("yasr-import-mr-answer").innerHTML=t}))})))},function(t,e,r){"use strict";var a,n;r.r(e);var s=new Uint8Array(16);function o(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],d=0;d<256;++d)u.push((d+256).toString(16).substr(1));var c=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};for(var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return c(a)},y=wp.i18n.__,g=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],p=0;p<g.length;p++)v(g[p]);function v(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;f(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),s=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=_(n),s=_(s),!0===n&&(s=!0);var o=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),d=r.getAttribute("data-rater-nonce"),c=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,g="yasr-vv-average-container-"+l,p="yasr-vv-bottom-container-"+l,v="yasr-vv-loader-"+l,f=document.getElementById(m),b=document.getElementById(g),E=document.getElementById(p),k=document.getElementById(v);if("yes"===yasrCommonData.ajaxEnabled){var I={action:"yasr_load_vv",post_id:o,nonce_visitor:d};null!==k&&(k.innerHTML=yasrCommonData.loaderHtml),jQuery.get(yasrCommonData.ajaxurl,I).done((function(t){var e,r=JSON.parse(t);e=!0===n||r.yasr_visitor_votes.stars_attributes.read_only,a=(a=r.yasr_visitor_votes.number_of_votes>0?r.yasr_visitor_votes.sum_votes/r.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),h(u,a,o,e,i,l,d,c,f,b,k,E),!0!==n&&(null!==f&&(f.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==b&&(b.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==E&&(E.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,E.style.display=""))})).fail((function(t,e,r,m){console.info(y("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),h(u,a,o,s,i,l,d,c,f,b,k,E),!0!==n&&(E.style.display="")}))}else h(u,a,o,s,i,l,d,c,f,b,k,E)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e,r,a=!1,n=0;n<t.length;n++)!function(n){var s="#"+t.item(n).id,o=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(r=window.getComputedStyle(e[0],null).getPropertyValue("color")),r)&&(document.getElementById(t.item(n).id).style.fill=r);var i={action:"yasr_stats_visitors_votes",post_id:o};tippy(s,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){s!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){a=s}})}(n)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),s=n.id,o=n.getAttribute("data-rater-readonly");o=_(o);f(16,s,n,1,o,!1,(function(t,a){var s=n.getAttribute("data-rater-postid"),o=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:s,setid:o,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function f(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:s,rating:o,rateCallback:i})}function h(t,e,r,a,n,s,o,i,l,u,d,c){e=parseFloat(e),a=_(a);var m=document.getElementById(n);null!==d&&(d.innerHTML="");f(t,n,m,1,a,e,(function(t,e){null!==d&&(d.innerHTML=yasrCommonData.loaderHtml);var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:o,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==c&&(c.innerHTML=t.rating_saved_text,c.style.display=""),null!==d&&(d.innerHTML="")})),e()}))}function _(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}function b(t){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function E(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=B(t);if(e){var n=B(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return w(this,r)}}function w(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}M();var j=wp.i18n.__,R=wp.element.render;function x(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return f(r,e,!1,.1,!0,t.rating)}})}function C(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",j("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",j("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function L(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function T(t){var e="after",r=j("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(C,{post:t.post,tableId:t.tableId,text:r}),React.createElement(x,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(x,{rating:t.post.rating,tableId:t.tableId}),React.createElement(C,{post:t.post,tableId:t.tableId,text:r}))}function Q(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(L,{colClass:e,post:t.post}),React.createElement(T,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function S(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(Q,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var H=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}(s,React.Component);var e,r,a,n=I(s);function s(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=s,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(j("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(j("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(j(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(j(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:j("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var s=new URLSearchParams(e);null!==s.get("order_by")&&(n+="order_by="+s.get("order_by")),null!==s.get("limit")&&(n+="&limit="+s.get("limit")),null!==s.get("ctg")?n+="&ctg="+s.get("ctg"):null!==s.get("cpt")&&(n+="&cpt="+s.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==s.get("setid")&&(n+="&setid="+s.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var o="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(o="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+o,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var s=React.createElement("span",null,React.createElement("span",{id:a},j("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},j("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(s=React.createElement("span",null,React.createElement("span",{id:n},j("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},j("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,j("Order By","yet-another-stars-rating-pro"),": ",s)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,s="most-rated-posts-"+r,o="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(S,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,s=e.highest,o="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(o=u.get("view")),"highest"===o&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,o),React.createElement(S,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(S,{data:s,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,j("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&E(e.prototype,r),a&&E(e,a),s}();function M(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),s=document.getElementById(r);R(React.createElement(H,{source:a,tableId:r,params:n}),s)}}var O,P=wp.i18n.__;if(document.getElementsByClassName("nav-tab-active").length>0&&(O=document.getElementsByClassName("nav-tab-active")[0].id),"rankings"===O){var N,A=function(t){var e=G.value,r=document.getElementById("yasr-builder-shortcode").textContent,a=["yasr_ov_ranking","yasr_most_or_highest_rated_posts","yasr_multi_set_ranking","yasr_visitor_multi_set_ranking"];a=wp.hooks.applyFilters("yasrBuilderDrawRankingsShortcodes",a),fetch(ajaxurl+"?action=yasr_rankings_preview_shortcode&shortcode="+e+"&full_shortcode="+r).then((function(t){return!0===t.ok?t.json():(console.info(P("Ajax Call Failed. Shortcode preview can't be done","yet-another-stars-rating")),"KO")})).catch((function(t){console.info(t)})).then((function(t){if("KO"!==t){var e=document.createElement("div");e.innerHTML=t,Y.childNodes.length>0?Y.replaceChild(e,Y.childNodes[0]):Y.appendChild(e)}})).then((function(t){a.forEach((function(t){e===t&&M()}))}))},D=function(t,e,r,a,n,s,o,i){W.className="",W.classList.add("yasr-settings-row-24"),t.style.display="",e.style.display="",s.style.display="",r.style.display="none",a.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},F=function(t,e,r,a,n,s,o,i){r.style.display="",a.style.display="",e.style.display="",s.style.display="",t.style.display="none",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display="none")},z=function(t,e,r,a,n,s,o,i){n.style.display="",t.style.display="none",r.style.display="none",a.style.display="none",e.style.display="none",s.style.display="none",null!==o&&(o.style.display="none"),null!==i&&(i.style.display="none")},U=function(t,e,r,a,n,s,o,i){var l=arguments.length>8&&void 0!==arguments[8]&&arguments[8];s.style.display="",e.style.display="",n.style.display="none",null!==o&&(o.style.display=""),null!==i&&(i.style.display=""),!0===l?(r.style.display="",a.style.display="",t.style.display="none"):(r.style.display="none",a.style.display="none",t.style.display="")};jQuery(".yasr-builder-elements-parents").prop("disabled",!0),jQuery(".yasr-builder-elements-childs").prop("disabled",!0),wp.hooks.doAction("yasrBuilderBegin",".yasr-builder-elements-parents",".yasr-builder-elements-childs");var J=[],q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""};N=q.name,document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]");var V=document.getElementById("yasr-builder-button-preview"),K=document.getElementById("yasr-builder-copy-shortcode"),Y=document.getElementById("yasr-builder-preview"),G=document.getElementById("yasr-ranking-source"),$=document.getElementById("yasr-ranking-multiset-select"),W=document.getElementById("yasr-builder-params-container"),X=document.getElementById("builder-vv-default-view"),Z=document.getElementById("builder-vv-required-votes"),tt=document.getElementById("builder-stars-size"),et=document.getElementById("builder-overall-text"),rt=document.getElementById("builder-username-options"),at=document.getElementById("builder-category"),nt=document.getElementById("builder-cpt"),st=document.getElementById("yasr-ranking-multiset"),ot=G.value,it=!1;"yasr_ov_ranking"===ot?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===ot||"yasr_top_reviewers"===ot?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!1):"yasr_visitor_multi_set_ranking"===ot?U(et,tt,X,Z,rt,at,nt,st,!0):F(et,tt,X,Z,rt,at,nt,st),document.addEventListener("change",(function(t){if("yasr-ranking-source"===t.target.id)W.className="",W.classList.add("yasr-settings-row-33"),Y.innerHTML="",q={name:"yasr_most_or_highest_rated_posts",setid:"",rows:"",size:"",view:"",minvotesmost:"",minvoteshg:"",txtPosition:"",txt:"",display:"",category:"",cpt:""},"yasr_ov_ranking"===t.target.value?D(et,tt,X,Z,rt,at,nt,st):"yasr_most_active_users"===t.target.value||"yasr_top_reviewers"===t.target.value?z(et,tt,X,Z,rt,at,nt,st):"yasr_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!1),q.setid=" setid="+$[0].value):"yasr_visitor_multi_set_ranking"===t.target.value?(U(et,tt,X,Z,rt,at,nt,st,!0),q.setid=" setid="+$[0].value):F(et,tt,X,Z,rt,at,nt,st),q.name=t.target.value,N=q.name+q.setid;else{"yasr-ranking-multiset-select"===t.target.id&&(q.setid=" setid="+t.target.value),J=wp.hooks.applyFilters("yasrBuilderFilterShortcode",q);for(var e=2;q.length;e++)J.hasOwnProperty(q[e])&&(q[e]=J[e]);N=q.name+q.setid+q.rows+q.view+q.minvotesmost+q.minvoteshg+q.size+q.txtPosition+q.txt+q.display+q.category+q.cpt}document.getElementById("yasr-builder-shortcode").textContent="["+N+"]",document.getElementById("yasr-builder-copy-shortcode").setAttribute("data-shortcode","["+N+"]"),!0===it&&"yasr-ranking-source"!==t.target.id&&"yasr-builder-category-radio"!==t.target.name&&A()})),K.onclick=function(t){var e=document.getElementById(t.target.id);copyToClipboard(e.getAttribute("data-shortcode"))},V.onclick=function(t){A(),it=!0}}}]);
|
includes/css/yasr.css
CHANGED
@@ -66,14 +66,17 @@
|
|
66 |
|
67 |
.yasr-vv-second-row-container {
|
68 |
line-height: normal;
|
|
|
69 |
}
|
70 |
|
71 |
.yasr-vv-stats-text-container {
|
72 |
display: inline-block;
|
|
|
73 |
}
|
74 |
|
75 |
.yasr-dashicons-visitor-stats {
|
76 |
cursor: pointer;
|
|
|
77 |
vertical-align: bottom;
|
78 |
}
|
79 |
|
66 |
|
67 |
.yasr-vv-second-row-container {
|
68 |
line-height: normal;
|
69 |
+
display: inline-block;
|
70 |
}
|
71 |
|
72 |
.yasr-vv-stats-text-container {
|
73 |
display: inline-block;
|
74 |
+
vertical-align: bottom;
|
75 |
}
|
76 |
|
77 |
.yasr-dashicons-visitor-stats {
|
78 |
cursor: pointer;
|
79 |
+
display: inline-block;
|
80 |
vertical-align: bottom;
|
81 |
}
|
82 |
|
includes/js/src/yasr-front.js
CHANGED
@@ -193,11 +193,11 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
193 |
let containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
|
194 |
let containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
|
195 |
let bottomContainerName = 'yasr-vv-bottom-container-' + uniqueId;
|
|
|
196 |
const containerVotesNumber = document.getElementById(containerVotesNumberName);
|
197 |
const containerAverageNumber = document.getElementById(containerAverageNumberName);
|
198 |
const bottomContainer = document.getElementById(bottomContainerName);
|
199 |
-
|
200 |
-
let loaderContainer = 'yasr-vv-loader-' + uniqueId;
|
201 |
|
202 |
if(yasrCommonData.ajaxEnabled === 'yes') {
|
203 |
let data = {
|
@@ -207,7 +207,9 @@ function yasrVisitorVotesFront (yasrRaterVVInDom) {
|
|
207 |
};
|
208 |
|
209 |
//show the loader
|
210 |
-
|
|
|
|
|
211 |
|
212 |
jQuery.get(yasrCommonData.ajaxurl, data).done(
|
213 |
function (response) {
|
@@ -297,11 +299,14 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
|
|
297 |
const elem = document.getElementById(htmlId);
|
298 |
|
299 |
//Be sure the loader is hidden
|
300 |
-
|
301 |
-
|
|
|
302 |
let rateCallback = function (rating, done) {
|
303 |
//show the loader
|
304 |
-
|
|
|
|
|
305 |
|
306 |
//Creating an object with data to send
|
307 |
var data = {
|
@@ -309,7 +314,7 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
|
|
309 |
rating: rating,
|
310 |
post_id: postId,
|
311 |
nonce_visitor: nonce,
|
312 |
-
is_singular
|
313 |
};
|
314 |
|
315 |
this.setRating(rating);
|
@@ -320,20 +325,22 @@ function yasrSetVisitorVotesRater (starSize, rating, postId, readonly, htmlId, u
|
|
320 |
//decode json
|
321 |
response = JSON.parse(response);
|
322 |
//hide the loader
|
323 |
-
if(containerVotesNumber !== null) {
|
324 |
-
containerVotesNumber.innerHTML
|
325 |
}
|
326 |
-
if(containerAverageNumber !== null) {
|
327 |
containerAverageNumber.innerHTML = response.average_rating;
|
328 |
}
|
329 |
-
if(bottomContainer !== null) {
|
330 |
bottomContainer.innerHTML = response.rating_saved_text;
|
331 |
//Be sure the bottom container is showed
|
332 |
bottomContainer.style.display = '';
|
333 |
}
|
334 |
|
335 |
//empty loader gif
|
336 |
-
|
|
|
|
|
337 |
|
338 |
});
|
339 |
done();
|
193 |
let containerVotesNumberName = 'yasr-vv-votes-number-container-' + uniqueId;
|
194 |
let containerAverageNumberName = 'yasr-vv-average-container-' + uniqueId;
|
195 |
let bottomContainerName = 'yasr-vv-bottom-container-' + uniqueId;
|
196 |
+
let loaderContainerName = 'yasr-vv-loader-' + uniqueId;
|
197 |
const containerVotesNumber = document.getElementById(containerVotesNumberName);
|
198 |
const containerAverageNumber = document.getElementById(containerAverageNumberName);
|
199 |
const bottomContainer = document.getElementById(bottomContainerName);
|
200 |
+
const loaderContainer = document.getElementById(loaderContainerName);
|
|
|
201 |
|
202 |
if(yasrCommonData.ajaxEnabled === 'yes') {
|
203 |
let data = {
|
207 |
};
|
208 |
|
209 |
//show the loader
|
210 |
+
if(loaderContainer !== null) {
|
211 |
+
loaderContainer.innerHTML = yasrCommonData.loaderHtml;
|
212 |
+
}
|
213 |
|
214 |
jQuery.get(yasrCommonData.ajaxurl, data).done(
|
215 |
function (response) {
|
299 |
const elem = document.getElementById(htmlId);
|
300 |
|
301 |
//Be sure the loader is hidden
|
302 |
+
if (loaderContainer !== null) {
|
303 |
+
loaderContainer.innerHTML = '';
|
304 |
+
}
|
305 |
let rateCallback = function (rating, done) {
|
306 |
//show the loader
|
307 |
+
if (loaderContainer !== null) {
|
308 |
+
loaderContainer.innerHTML = yasrCommonData.loaderHtml;
|
309 |
+
}
|
310 |
|
311 |
//Creating an object with data to send
|
312 |
var data = {
|
314 |
rating: rating,
|
315 |
post_id: postId,
|
316 |
nonce_visitor: nonce,
|
317 |
+
is_singular: isSingular
|
318 |
};
|
319 |
|
320 |
this.setRating(rating);
|
325 |
//decode json
|
326 |
response = JSON.parse(response);
|
327 |
//hide the loader
|
328 |
+
if (containerVotesNumber !== null) {
|
329 |
+
containerVotesNumber.innerHTML = response.number_of_votes;
|
330 |
}
|
331 |
+
if (containerAverageNumber !== null) {
|
332 |
containerAverageNumber.innerHTML = response.average_rating;
|
333 |
}
|
334 |
+
if (bottomContainer !== null) {
|
335 |
bottomContainer.innerHTML = response.rating_saved_text;
|
336 |
//Be sure the bottom container is showed
|
337 |
bottomContainer.style.display = '';
|
338 |
}
|
339 |
|
340 |
//empty loader gif
|
341 |
+
if (loaderContainer !== null) {
|
342 |
+
loaderContainer.innerHTML = '';
|
343 |
+
}
|
344 |
|
345 |
});
|
346 |
done();
|
includes/js/yasr-front.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return L})),r.d(e,"yasrSetRaterValue",(function(){return j}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return d(a)};function y(t){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function g(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==y(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return j(r,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function I(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function k(t){var e="after",r=b("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:r}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:r}))}function w(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,r,a,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=o,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:a},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),": ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,r),a&&g(e,a),o}();for(var B=wp.i18n.__,T=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],x=0;x<T.length;x++)L(T[x]);function L(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;j(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),c=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,y="yasr-vv-average-container-"+l,g="yasr-vv-bottom-container-"+l,f=document.getElementById(m),p=document.getElementById(y),v=document.getElementById(g),h="yasr-vv-loader-"+l;if("yes"===yasrCommonData.ajaxEnabled){var b={action:"yasr_load_vv",post_id:s,nonce_visitor:c};document.getElementById(i).innerHTML=yasrCommonData.loaderHtml,jQuery.get(yasrCommonData.ajaxurl,b).done((function(t){var e,r=JSON.parse(t);e=!0===n||r.yasr_visitor_votes.stars_attributes.read_only,a=(a=r.yasr_visitor_votes.number_of_votes>0?r.yasr_visitor_votes.sum_votes/r.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),P(u,a,s,e,i,l,c,d,f,p,h,v),!0!==n&&(null!==f&&(f.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==p&&(p.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==v&&(v.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,v.style.display=""))})).fail((function(t,e,r,m){console.info(B("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,f,p,h,v),!0!==n&&(v.style.display="")}))}else P(u,a,s,o,i,l,c,d,f,p,h,v)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e,r,a=!1,n=0;n<t.length;n++)!function(n){var o="#"+t.item(n).id,s=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(r=window.getComputedStyle(e[0],null).getPropertyValue("color")),r)&&(document.getElementById(t.item(n).id).style.fill=r);var i={action:"yasr_stats_visitors_votes",post_id:s};tippy(o,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){o!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){a=o}})}(n)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);j(16,o,n,1,s,!1,(function(t,a){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function j(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,u,c,d){e=parseFloat(e),a=O(a);var m=document.getElementById(n);document.getElementById(n).innerHTML="";j(t,n,m,1,a,e,(function(t,e){document.getElementById(c).innerHTML=yasrCommonData.loaderHtml;var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==d&&(d.innerHTML=t.rating_saved_text,d.style.display=""),document.getElementById(c).innerHTML=""})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
|
1 |
+
!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";var a,n;r.r(e),r.d(e,"yasrSearchStarsDom",(function(){return j})),r.d(e,"yasrSetRaterValue",(function(){return B}));var o=new Uint8Array(16);function s(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(o)}var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var l=function(t){return"string"==typeof t&&i.test(t)},u=[],c=0;c<256;++c)u.push((c+256).toString(16).substr(1));var d=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!l(r))throw TypeError("Stringified UUID is invalid");return r};var m=function(t,e,r){var a=(t=t||{}).random||(t.rng||s)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=a[n];return e}return d(a)};function y(t){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function g(t,e){for(var r=0;r<e.length;r++){var a=e[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,a=h(t);if(e){var n=h(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return v(this,r)}}function v(t,e){return!e||"object"!==y(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,_=wp.element.render;function E(t){var e="yasr-ranking-element-"+m(),r=document.getElementById(t.tableId).dataset.rankingSize;return React.createElement("div",{id:e,ref:function(){return B(r,e,!1,.1,!0,t.rating)}})}function R(t){if(void 0!==t.post.number_of_votes)return React.createElement("span",{className:"yasr-most-rated-text"},"[",b("Total:","yet-another-stars-rating")," ",t.post.number_of_votes," ",b("Average:","yet-another-stars-rating")," ",t.post.rating,"]");var e=t.text;return React.createElement("span",{className:"yasr-highest-rated-text"},e," ",t.post.rating)}function I(t){return React.createElement("td",{className:t.colClass},React.createElement("a",{href:t.post.link},function(t){if("string"!=typeof t||-1===t.indexOf("&"))return t;void 0===a&&(a=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),a.innerHTML=t;var e=a.textContent;return a.innerHTML="",e}(t.post.title)))}function k(t){var e="after",r=b("Rating:","yet-another-stars-rating"),a=new URLSearchParams(t.rankingParams);return null!==a.get("text_position")&&(e=a.get("text_position")),null!==a.get("custom_txt")&&(r=a.get("custom_txt")),"before"===e?React.createElement("td",{className:t.colClass},React.createElement(R,{post:t.post,tableId:t.tableId,text:r}),React.createElement(E,{rating:t.post.rating,tableId:t.tableId})):React.createElement("td",{className:t.colClass},React.createElement(E,{rating:t.post.rating,tableId:t.tableId}),React.createElement(R,{post:t.post,tableId:t.tableId,text:r}))}function w(t){var e="",r="";return"author_ranking"===t.source?(e="yasr-top-10-overall-left",r="yasr-top-10-overall-right"):"visitor_votes"===t.source&&(e="yasr-top-10-most-highest-left",r="yasr-top-10-most-highest-right"),React.createElement("tr",{className:t.trClass},React.createElement(I,{colClass:e,post:t.post}),React.createElement(k,{colClass:r,post:t.post,tableId:t.tableId,rankingParams:t.rankingParams}))}function C(t){return React.createElement("tbody",{id:t.tBodyId,style:{display:t.show}},t.data.map((function(e,r){var a="yasr-rankings-td-colored";return"author_ranking"===t.source&&(a="yasr-rankings-td-white"),r%2==0&&(a="yasr-rankings-td-white","author_ranking"===t.source&&(a="yasr-rankings-td-colored")),React.createElement(w,{key:e.post_id,source:t.source,tableId:t.tableId,rankingParams:t.rankingParams,post:e,trClass:a})})))}var S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(o,React.Component);var e,r,a,n=p(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=n.call(this,t)).state={error:null,isLoaded:!1,data:[],tableId:t.tableId,source:t.source,rankingParams:t.params},e}return e=o,(r=[{key:"componentDidMount",value:function(){var t=this,e=JSON.parse(document.getElementById(this.state.tableId).dataset.rankingData),r={};if("yes"!==yasrCommonData.ajaxEnabled)console.info(b("Ajax Disabled, getting data from source","yet-another-stars-rating")),this.setState({isLoaded:!0,data:e});else if(this.state.source){var a=this.returnRestUrl();Promise.all(a.map((function(t){return fetch(t).then((function(t){return!0===t.ok?t.json():(console.info(b("Ajax Call Failed. Getting data from source")),"KO")})).then((function(t){"KO"===t?r=e:"overall_rating"===t.source||"author_multi"===t.source?r="overall_rating"===t.source?t.data_overall:t.data_mv:r[t.show]=t.data_vv})).catch((function(t){r=e,console.info(b(t))}))}))).then((function(e){t.setState({isLoaded:!0,data:r})})).catch((function(e){console.info(b(e)),t.setState({isLoaded:!0,data:r})}))}else this.setState({error:b("Invalid Data Source","yet-another-stars-rating")})}},{key:"returnRestUrl",value:function(){var t,e=""!==this.state.rankingParams?this.state.rankingParams:"",r=this.state.source,a="yet-another-stars-rating/v1/yasr-rankings/",n="";if(""!==e&&!1!==e){var o=new URLSearchParams(e);null!==o.get("order_by")&&(n+="order_by="+o.get("order_by")),null!==o.get("limit")&&(n+="&limit="+o.get("limit")),null!==o.get("ctg")?n+="&ctg="+o.get("ctg"):null!==o.get("cpt")&&(n+="&cpt="+o.get("cpt")),""!==n&&(n="&"+(n=n.replace(/\s+/g,""))),"visitor_multi"!==r&&"author_multi"!==r||null!==o.get("setid")&&(n+="&setid="+o.get("setid"))}else n="";if("author_ranking"===r||"author_multi"===r)t=[yasrCommonData.restEndpoint+a+"?source="+r+n];else{var s="",i="";if(""!==e){var l=new URLSearchParams(e);null!==l.get("required_votes[most]")&&(s="&required_votes="+l.get("required_votes[most]")),null!==l.get("required_votes[highest]")&&(i="&required_votes="+l.get("required_votes[highest]"))}t=[yasrCommonData.restEndpoint+a+"?show=most&source="+r+n+s,yasrCommonData.restEndpoint+a+"?show=highest&source="+r+n+i]}return t}},{key:"rankingTableHead",value:function(t,e){var r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r;if("author_ranking"!==t){var o=React.createElement("span",null,React.createElement("span",{id:a},b("Most Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:n,onClick:this.switchTBody.bind(this)},b("Highest Rated","yet-another-stars-rating")));return"highest"===e&&(o=React.createElement("span",null,React.createElement("span",{id:n},b("Highest Rated","yet-another-stars-rating"))," | ",React.createElement("a",{href:"#",id:a,onClick:this.switchTBody.bind(this)},b("Most Rated","yet-another-stars-rating")))),React.createElement("thead",null,React.createElement("tr",{className:"yasr-rankings-td-colored yasr-rankings-heading"},React.createElement("th",null,"Post"),React.createElement("th",null,b("Order By","yet-another-stars-rating-pro"),": ",o)))}return React.createElement(React.Fragment,null)}},{key:"switchTBody",value:function(t){t.preventDefault();var e=t.target.id,r=this.state.tableId,a="link-most-rated-posts-"+r,n="link-highest-rated-posts-"+r,o="most-rated-posts-"+r,s="highest-rated-posts-"+r,i=document.getElementById(e),l=document.createElement("span");l.innerHTML=i.innerHTML,l.id=i.id,i.parentNode.replaceChild(l,i),e===a&&(document.getElementById(s).style.display="none",document.getElementById(o).style.display="",l=document.getElementById(n),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l)),e===n&&(document.getElementById(o).style.display="none",document.getElementById(s).style.display="",l=document.getElementById(a),i.innerHTML=l.innerHTML,i.id=l.id,l.parentNode.replaceChild(i,l))}},{key:"rankingTableBody",value:function(){var t=this.state,e=t.data,r=t.source,a=t.rankingParams;if("overall_rating"===r||"author_multi"===r)return React.createElement(C,{data:e,tableId:this.state.tableId,tBodyId:"overall_"+this.state.tableId,rankingParams:a,show:"table-row-group",source:r});var n=e.most,o=e.highest,s="most",i="table-row-group",l="none",u=new URLSearchParams(a);return null!==u.get("view")&&(s=u.get("view")),"highest"===s&&(i="none",l="table-row-group"),React.createElement(React.Fragment,null,this.rankingTableHead(r,s),React.createElement(C,{data:n,tableId:this.state.tableId,tBodyId:"most-rated-posts-"+this.state.tableId,rankingParams:a,show:i,source:r}),React.createElement(C,{data:o,tableId:this.state.tableId,tBodyId:"highest-rated-posts-"+this.state.tableId,rankingParams:a,show:l,source:r}))}},{key:"render",value:function(){var t=this.state,e=t.error,r=t.isLoaded;return e?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,console.log(e),"Error"))):!1===r?React.createElement("tbody",null,React.createElement("tr",null,React.createElement("td",null,b("Loading Charts","yet-another-stars-rating")))):React.createElement(React.Fragment,null,this.rankingTableBody())}}])&&g(e.prototype,r),a&&g(e,a),o}();for(var T=wp.i18n.__,x=["yasr-rater-stars","yasr-rater-stars-vv","yasr-multiset-visitors-rater"],L=0;L<x.length;L++)j(x[L]);function j(t){var e=document.getElementsByClassName(t);if(e.length>0){if("yasr-rater-stars"!==t&&"yasr-ranking-stars"!==t||function(t){for(var e=0;e<t.length;e++)if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.id;B(r.getAttribute("data-rater-starsize"),a,r)}}(e),"yasr-rater-stars-vv"===t&&(function(t){for(var e=0;e<t.length;e++)!function(e){if(!1===t.item(e).classList.contains("yasr-star-rating")){var r=t.item(e),a=r.getAttribute("data-rating"),n=r.getAttribute("data-readonly-attribute"),o=r.getAttribute("data-rater-readonly");null===n&&(n=!1),n=O(n),o=O(o),!0===n&&(o=!0);var s=r.getAttribute("data-rater-postid"),i=r.id,l=i.replace("yasr-visitor-votes-rater-",""),u=parseInt(r.getAttribute("data-rater-starsize")),c=r.getAttribute("data-rater-nonce"),d=r.getAttribute("data-issingular"),m="yasr-vv-votes-number-container-"+l,y="yasr-vv-average-container-"+l,g="yasr-vv-bottom-container-"+l,f="yasr-vv-loader-"+l,p=document.getElementById(m),v=document.getElementById(y),h=document.getElementById(g),b=document.getElementById(f);if("yes"===yasrCommonData.ajaxEnabled){var _={action:"yasr_load_vv",post_id:s,nonce_visitor:c};null!==b&&(b.innerHTML=yasrCommonData.loaderHtml),jQuery.get(yasrCommonData.ajaxurl,_).done((function(t){var e,r=JSON.parse(t);e=!0===n||r.yasr_visitor_votes.stars_attributes.read_only,a=(a=r.yasr_visitor_votes.number_of_votes>0?r.yasr_visitor_votes.sum_votes/r.yasr_visitor_votes.number_of_votes:0).toFixed(1),a=parseFloat(a),P(u,a,s,e,i,l,c,d,p,v,b,h),!0!==n&&(null!==p&&(p.innerHTML=r.yasr_visitor_votes.number_of_votes),null!==v&&(v.innerHTML=a),!1!==r.yasr_visitor_votes.stars_attributes.span_bottom&&null!==h&&(h.innerHTML=r.yasr_visitor_votes.stars_attributes.span_bottom,h.style.display=""))})).fail((function(t,e,r,m){console.info(T("YASR ajax call failed. Showing ratings from html","yet-another-stars-rating")),P(u,a,s,o,i,l,c,d,p,v,b,h),!0!==n&&(h.style.display="")}))}else P(u,a,s,o,i,l,c,d,p,v,b,h)}}(e)}(e),"yes"===yasrCommonData.visitorStatsEnabled)){var r=document.getElementsByClassName("yasr-dashicons-visitor-stats");r&&function(t){for(var e,r,a=!1,n=0;n<t.length;n++)!function(n){var o="#"+t.item(n).id,s=t.item(n).getAttribute("data-postid");(0===n&&null!==(e=document.getElementsByClassName("yasr-vv-text-container"))&&(r=window.getComputedStyle(e[0],null).getPropertyValue("color")),r)&&(document.getElementById(t.item(n).id).style.fill=r);var i={action:"yasr_stats_visitors_votes",post_id:s};tippy(o,{content:'<span style="color: #0a0a0a">Loading...</span>',theme:"yasr",arrow:"true",arrowType:"round",onShow:function(t){o!==a&&jQuery.post(yasrCommonData.ajaxurl,i,(function(e){e=JSON.parse(e),t.setContent(e)}))},onHidden:function(){a=o}})}(n)}(r)}"yasr-multiset-visitors-rater"===t&&function(t){for(var e="",r=[],a=0;a<t.length;a++)!function(a){if(!1===t.item(a).classList.contains("yasr-star-rating")){var n=t.item(a),o=n.id,s=n.getAttribute("data-rater-readonly");s=O(s);B(16,o,n,1,s,!1,(function(t,a){var o=n.getAttribute("data-rater-postid"),s=n.getAttribute("data-rater-setid"),i=n.getAttribute("data-rater-set-field-id");t=t.toFixed(1);var l=parseInt(t);this.setRating(l),e={postid:o,setid:s,field:i,rating:l},r.push(e),a()}))}}(a);jQuery(".yasr-send-visitor-multiset").on("click",(function(){var t=this.getAttribute("data-postid"),e=this.getAttribute("data-setid"),a=this.getAttribute("data-nonce");jQuery("#yasr-send-visitor-multiset-"+t+"-"+e).hide(),jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).show();var n={action:"yasr_visitor_multiset_field_vote",nonce:a,post_id:t,rating:r,set_id:e};jQuery.post(yasrCommonData.ajaxurl,n,(function(r){jQuery("#yasr-loader-multiset-visitor-"+t+"-"+e).text(r)}))}))}(e)}}function B(t,e){var r,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.1,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],i=arguments.length>6&&void 0!==arguments[6]&&arguments[6];r=a||document.getElementById(e),t=parseInt(t),raterJs({starSize:t,showToolTip:!1,element:r,step:n,readOnly:o,rating:s,rateCallback:i})}function P(t,e,r,a,n,o,s,i,l,u,c,d){e=parseFloat(e),a=O(a);var m=document.getElementById(n);null!==c&&(c.innerHTML="");B(t,n,m,1,a,e,(function(t,e){null!==c&&(c.innerHTML=yasrCommonData.loaderHtml);var a={action:"yasr_send_visitor_rating",rating:t,post_id:r,nonce_visitor:s,is_singular:i};this.setRating(t),this.disable(),jQuery.post(yasrCommonData.ajaxurl,a,(function(t){t=JSON.parse(t),null!==l&&(l.innerHTML=t.number_of_votes),null!==u&&(u.innerHTML=t.average_rating),null!==d&&(d.innerHTML=t.rating_saved_text,d.style.display=""),null!==c&&(c.innerHTML="")})),e()}))}function O(t){return null!=t&&""!==t||(t=!0),"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1),t}!function(){var t=document.getElementsByClassName("yasr-stars-rankings");if(t.length>0)for(var e=0;e<t.length;e++){var r=t.item(e).id,a=JSON.parse(t.item(e).dataset.rankingSource),n=JSON.parse(t.item(e).dataset.rankingParams),o=document.getElementById(r);_(React.createElement(S,{source:a,tableId:r,params:n}),o)}}()}]);
|
includes/shortcodes/classes/YasrVisitorVotes.php
CHANGED
@@ -129,6 +129,7 @@ class YasrVisitorVotes extends YasrShortcode {
|
|
129 |
data-rater-postid='$this->post_id'
|
130 |
data-rater-readonly='true'
|
131 |
data-readonly-attribute='true'
|
|
|
132 |
></div>";
|
133 |
|
134 |
$end_container = '</div>'; //close yasr-vv-stars-stats-container
|
129 |
data-rater-postid='$this->post_id'
|
130 |
data-rater-readonly='true'
|
131 |
data-readonly-attribute='true'
|
132 |
+
data-rater-nonce='$this->ajax_nonce_visitor'
|
133 |
></div>";
|
134 |
|
135 |
$end_container = '</div>'; //close yasr-vv-stars-stats-container
|
includes/yasr-includes-functions.php
CHANGED
@@ -46,9 +46,8 @@ function yasr_add_scripts_includes() {
|
|
46 |
true
|
47 |
);
|
48 |
|
49 |
-
$yasr_visitor_votes_loader = '<div id="loader-visitor-rating" style="display: inline"> '.
|
50 |
-
' <img src=' . YASR_IMG_DIR . 'loader.gif title="yasr-loader" alt="yasr-loader">
|
51 |
-
</div>';
|
52 |
|
53 |
if(is_admin()) {
|
54 |
define ('YASR_HANDLE_SCRIPT', 'yasradmin');
|
46 |
true
|
47 |
);
|
48 |
|
49 |
+
$yasr_visitor_votes_loader = '<div id="loader-visitor-rating" style="display: inline-block"> '.
|
50 |
+
' <img src=' . YASR_IMG_DIR . 'loader.gif title="yasr-loader" alt="yasr-loader"></div>';
|
|
|
51 |
|
52 |
if(is_admin()) {
|
53 |
define ('YASR_HANDLE_SCRIPT', 'yasradmin');
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Requires at least: 5.0
|
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.7.2
|
7 |
Requires PHP: 5.4
|
8 |
-
Stable tag: 2.7.
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
@@ -191,8 +191,12 @@ If doesn't, you should work on your seo reputation.
|
|
191 |
|
192 |
The full changelog can be found in the plugin's directory. Recent entries:
|
193 |
|
|
|
|
|
|
|
|
|
194 |
= 2.7.7 =
|
195 |
-
* TWEAKED: When "Load results with AJAX?
|
196 |
* TWEAKED: most of caching plugins are automatically detected: if one is found, "load results with ajax" is enabled by default.
|
197 |
* Minor changes
|
198 |
|
5 |
Contributors: Dudo
|
6 |
Tested up to: 5.7.2
|
7 |
Requires PHP: 5.4
|
8 |
+
Stable tag: 2.7.8
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
191 |
|
192 |
The full changelog can be found in the plugin's directory. Recent entries:
|
193 |
|
194 |
+
= 2.7.8 =
|
195 |
+
* FIXED: error when "Load results with AJAX?" is enabled, and the attribute "readonly" is set to yasr_visitor_votes shortcode
|
196 |
+
* TWEAKED: css minor changes
|
197 |
+
|
198 |
= 2.7.7 =
|
199 |
+
* TWEAKED: When "Load results with AJAX?" is enabled, data is loaded through admin-ajax.php instead of REST API.
|
200 |
* TWEAKED: most of caching plugins are automatically detected: if one is found, "load results with ajax" is enabled by default.
|
201 |
* Minor changes
|
202 |
|
yet-another-stars-rating.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
-
* Version: 2.7.
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
@@ -76,7 +76,7 @@ if ( !function_exists( 'yasr_fs' ) ) {
|
|
76 |
yasr_fs();
|
77 |
// Signal that SDK was initiated.
|
78 |
do_action( 'yasr_fs_loaded' );
|
79 |
-
define( 'YASR_VERSION_NUM', '2.7.
|
80 |
//Plugin absolute path
|
81 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
82 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|
4 |
* Plugin Name: Yet Another Stars Rating
|
5 |
* Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
|
6 |
* Description: Boost the way people interact with your site with an easy WordPress stars rating system! With schema.org rich snippets YASR will improve your SEO
|
7 |
+
* Version: 2.7.8
|
8 |
* Author: Dario Curvino
|
9 |
* Author URI: https://dariocurvino.it/
|
10 |
* Text Domain: yet-another-stars-rating
|
76 |
yasr_fs();
|
77 |
// Signal that SDK was initiated.
|
78 |
do_action( 'yasr_fs_loaded' );
|
79 |
+
define( 'YASR_VERSION_NUM', '2.7.8' );
|
80 |
//Plugin absolute path
|
81 |
//e.g. /var/www/html/plugin_development/wp-content/plugins/yet-another-stars-rating
|
82 |
define( 'YASR_ABSOLUTE_PATH', __DIR__ );
|