1 2/*** Constant used by yasr 3 4yasrCommonData (postid, ajaxurl, loggedUser, visitorStatsEnabled, loaderHtml, tooltipValues) 5 6yasrMultiSetData (setType, nonce) 7 8 9***/ 10 11 12/****** Yasr shortcode page ******/ 13 14document.addEventListener('DOMContentLoaded', function(event) { 15 16 //if is defined yasrVisitorsVotesData means that the shortcode is used 17 if (typeof yasrVisitorsVotesData !== 'undefined') { 18 19 yasrVisitorsVotes (); 20 21 if (yasrCommonData.visitorStatsEnabled == 'yes') { 22 23 yasrDrawTipsProgress (); 24 25 } 26 27 } 28 29}); 30 31 32 /*** Yasr visitor Votes ***/ 33 34 function yasrVisitorsVotes () { 35 36 jQuery('.rateit').bind('over', function (event, value) { jQuery(this).attr('title', yasrCommonData.tooltipValues[value-1]); }); 37 38 //on vote... 39 jQuery('.yasr_visitor_votes_stars_div').on('rated', function() { 40 41 var el = jQuery(this); 42 var value = el.rateit('value'); 43 var value = value.toFixed(1); // 44 45 var postid = jQuery( this ).data('postid'); 46 var classSize = jQuery( this ).attr('class'); 47 48 var voteIfUserAlredyRated = jQuery('#yasr-user-vote-'+postid).data('yasr-already-voted'); 49 50 if (value < 1) { 51 jQuery('#yasr_visitor_votes_' + postid).html('You can\'t vote 0'); 52 } 53 54 else { 55 56 jQuery('#yasr_visitor_votes_' + postid).html(yasrCommonData.loaderHtml); 57 58 var data = { 59 action: 'yasr_send_visitor_rating', 60 rating: value, 61 post_id: postid, 62 size: classSize, 63 nonce_visitor: yasrVisitorsVotesData.nonceVisitor 64 }; 65 66 //Send value to the Server 67 jQuery.post(yasrCommonData.ajaxurl, data, function(response) { 68 //response 69 jQuery('#yasr_visitor_votes_' + postid).html(response); 70 jQuery('.rateit').rateit(); 71 72 }) ; 73 74 } //End else value <1 75 76 });//End function insert/update vote 77 78 79 } 80 /*** End Yasr Visitor Votes ***/ 81 82 83 function yasrVisitorsMultiSet (postId, setType, ajaxurl, nonce) { 84 85 //will have field id and vote 86 var ratingObject = ""; 87 88 //an array with all the ratingonjects 89 var ratingArray = []; 90 91 jQuery('.yasr-visitor-multi-'+postId+'-'+setType).on('rated', function() { 92 var el = jQuery(this); 93 var value = el.rateit('value'); 94 var value = value.toFixed(1); 95 var idField = el.attr('id'); 96 97 ratingObject = { 98 99 field: idField, 100 rating: value 101 102 }; 103 104 //creating rating array 105 ratingArray.push(ratingObject); 106 107 }); 108 109 jQuery('#yasr-send-visitor-multiset-'+postId+'-'+setType).on('click', function() { 110 111 jQuery('#yasr-send-visitor-multiset-'+postId+'-'+setType).hide(); 112 113 var cookiename = "yasr_multi_visitor_vote_" + postId+'_'+setType; 114 115 jQuery('#yasr-loader-multiset-visitor-'+postId+'-'+setType).show(); 116 117 var data = { 118 119 action: 'yasr_visitor_multiset_field_vote', 120 nonce: nonce, 121 post_id: postId, 122 rating: ratingArray, 123 set_type: setType 124 125 }; 126 127 //Send value to the Server 128 jQuery.post(ajaxurl, data, function(response) { 129 jQuery('#yasr-loader-multiset-visitor-'+postId+'-'+setType).text(response); 130 }); 131 132 }); 133 134 } //End function 135 136 137 function yasrMostOrHighestRatedChart () { 138 139 //By default, hide the highest rated chart 140 jQuery('#yasr-highest-rated-posts').hide(); 141 142 //On click on highest, hide most and show highest 143 jQuery('#yasr_multi_chart_highest').on("click", function () { 144 145 jQuery('#yasr-most-rated-posts').hide(); 146 147 jQuery('#yasr-highest-rated-posts').show(); 148 149 return false; // prevent default click action from happening! 150 151 }); 152 153 //Vice versa 154 jQuery('#yasr_multi_chart_most').on("click", function () { 155 156 jQuery('#yasr-highest-rated-posts').hide(); 157 158 jQuery('#yasr-most-rated-posts').show(); 159 160 return false; // prevent default click action from happening! 161 162 }); 163 164 } 165 166 167/****** End Yasr shortcode page ******/ 168 169 170/****** Tooltip function ******/ 171 172 //used in ajax page 173 function yasrDrawProgressBars (valueProgressbar, postId) { 174 175 var i = null; 176 177 var j = 0; //This is for the array 178 179 for (i=5; i>0; i--) { 180 181 jQuery( "#yasr-progress-bar-postid-"+postId+"-progress-bar-" + i).progressbar({ 182 value: valueProgressbar[j] 183 }); 184 185 j=j+1; 186 187 } 188 189 } 190 191 //used in shortcode page and ajax page 192 function yasrDrawTipsProgress () { 193 194 var varTipsContent = null; 195 196 jQuery('#yasr-total-average-dashicon-' + yasrCommonData.postid).tooltip({ 197 198 position: { 199 my: 'center bottom' , 200 at: 'center top-10', 201 }, 202 203 tooltipClass: "yasr-visitors-stats-tooltip", 204 205 content: function(tipsContent) { 206 207 if (!varTipsContent) { 208 209 var data = { 210 action: 'yasr_stats_visitors_votes', 211 post_id: yasrCommonData.postid 212 }; 213 214 jQuery.post(yasrCommonData.ajaxurl, data, function(response) { 215 varTipsContent = response; 216 tipsContent(response); 217 }); 218 219 } 220 221 else { 222 return varTipsContent; 223 } 224 225 }, 226 disabled: true, 227 228 }); 229 230 jQuery('#yasr-total-average-dashicon-' + yasrCommonData.postid).on("hover", function(){ 231 jQuery(this).tooltip('enable').tooltip('open'); 232 jQuery('.ui-helper-hidden-accessible').children(':first').removeAttr('style'); 233 jQuery('.ui-helper-hidden-accessible').children(':last', this).remove(); 234 }); 235 236 } 237 238 239 240/****** End tooltipfunction ******/ 241 242
243// this should give support for all plugin that add content with ajax 244jQuery( document ).ajaxComplete(function() { 245 246 jQuery('.rateit').rateit(); 247 248});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.