1/* global jQuery */ 2jQuery( function ( $ ) { 3 'use strict'; 4 5 function rateyoReivew() { 6 if ( ! $( ".penci_rateyo_reivew" ).length ) { 7 return false; 8 } 9 10 11 $( ".penci_rateyo_reivew" ).each( function( ){ 12 13 var $this = $( this ), 14 rate = parseFloat( $this.data( 'rate' ) ), 15 allow = $this.data( 'allow' ), 16 total = $this.data( 'total' ), 17 people_numb = parseInt( $this.data( 'people' ) ); 18 19 if( rate ){ 20 $this.rateYo( { 21 rating: rate, 22 fullStar: false, 23 starWidth: "14px", 24 spacing: "3px", 25 readOnly: true, 26 normalFill: PENCI.normalFill, 27 ratedFill: PENCI.ratedFill, 28 } ); 29 }else{ 30 $this.rateYo( { 31 rating: rate, 32 fullStar: true, 33 starWidth: "14px", 34 spacing: "3px", 35 normalFill: PENCI.normalFill, 36 ratedFill: PENCI.ratedFill, 37 onSet: function ( rating, rateYoInstance ) { 38 jQuery( this ).rateYo( "option", "readOnly", true ); 39 var postid = jQuery( this ).data( 'postid' ); 40 41 jQuery.ajax( { 42 type: "POST", 43 url: PENCI.ajaxUrl, 44 dataType: 'html', 45 data: {action: 'penci_pennews_rateyo_reivew', nonce: PENCI.nonce, postid: postid, rating: rating}, 46 success: function ( response ) { 47 var parent = jQuery( this ).closest( '.penci-review-text' ), 48 new_rate = ( 49 total + rating 50 ) / ( 51 people_numb + 1 52 ), 53 thisParent = $this.closest( '.penci-review-text' ); 54 55 jQuery( '.penci-rate-number', parent ).html( new_rate ); 56 57 $this.rateYo( "rating", new_rate ); 58 thisParent.find( '.penci-rate-number' ).html( new_rate.toPrecision( 2 ) ); 59 thisParent.find( '.penci-number-people' ).html( people_numb + 1 ); 60 thisParent.find( '.penci-text-votes' ).removeClass( 'penci-hide-text-votes' ); 61 } 62 } ); 63 } 64 } ); 65 } 66 67 68 if ( allow == '0' ) { 69 $this.rateYo( "option", "readOnly", true ); 70 } 71 } ); 72 } 73 74 75 function userrateyoReivew() { 76 if ( ! $( ".penci-reivew-star-rateYo" ).length ) { 77 return false; 78 } 79 80 $( ".penci-reivew-star-rateYo" ).each( function( ){ 81 82 var $rateYo = $( this ), 83 rating = $rateYo.attr( 'data-rating' ); 84 85 if( rating ){ 86 $rateYo.rateYo( { 87 rating: rating, 88 fullStar: true, 89 starWidth: "18px", 90 spacing: "3px", 91 readOnly: true, 92 normalFill: PENCI.normalFill, 93 ratedFill: PENCI.ratedFill, 94 } ); 95 }else{ 96 var $input = $rateYo.next( '.penci-reivew-star-value' ), 97 value = $input.val(); 98 99 $rateYo.rateYo( { 100 rating: value, 101 fullStar: true, 102 starWidth: "18px", 103 spacing: "3px", 104 normalFill: PENCI.normalFill, 105 ratedFill: PENCI.ratedFill, 106 } ).on( "rateyo.change", function ( e, data ) { 107 var rating = data.rating; 108 $( this ).next().val( rating ); 109 } ); 110 } 111 } ); 112 113 } 114 115 function saveUserReview(){ 116 var $reviewFrom = $( '#penci-review-form' ); 117 118 if( ! $reviewFrom.length ){ 119 return false; 120 } 121 122 $reviewFrom.submit( function( e ){ 123 e.preventDefault(); 124 125 var $this = $( this ), 126 $spinner = $this.find( '.penci-review-spinner' ), 127 $mess = $this.next( '.penci-review-mess' ); 128 129 $spinner.addClass( 'active' ); 130 $mess.html('').hide(); 131 132 $.ajax( { 133 type: "POST", 134 url: PENCI.ajaxUrl, 135 data: { 136 action: 'penci_review_user_rating', 137 nonce: PENCI.nonce, 138 data: $this.serialize() 139 }, 140 success: function ( response ) { 141 142 $spinner.removeClass( 'active' ); 143 144 if( response.data.mess ){ 145 $mess.html( response.data.mess ).slideDown( ); 146 } 147 148 if( response.success ){ 149 setTimeout(function() { 150 var linkReload = window.location.href; 151 if ( 'undefined' != typeof(response.data.link_reload) && response.data.link_reload ) { 152 linkReload = response.data.link_reload; 153 } 154 window.location.assign(linkReload); 155 }, 3000 ); 156 }else{ 157 $mess.addClass( 'error' ); 158 } 159 } 160 } ); 161 } ); 162 } 163 164 function GetURLParameter( sParam ){ 165 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 166 sURLVariables = sPageURL.split('&'), 167 sParameterName, 168 i; 169 170 for (i = 0; i < sURLVariables.length; i++) { 171 sParameterName = sURLVariables[i].split('='); 172 173 if (sParameterName[0] === sParam) { 174 return sParameterName[1] === undefined ? true : sParameterName[1]; 175 } 176 } 177 } 178 179 function scrollToReview(){ 180 var viewru = GetURLParameter( 'user_review_id' ), 181 $viewruID = $('.penci-ur-'+ viewru ), 182 $tabNav = $( '.penci-tab-nav' ), 183 idTabReview = '#review-' + PENCI.postID + '-comment'; 184 185 if( $tabNav.length && ( $viewruID.length || idTabReview === window.location.hash ) ){ 186 $tabNav.find( 'li' ).removeClass( 'active' ); 187 $tabNav.find( '.review-comment' ).addClass( 'active' ); 188 $( '.penci-tab-content .penci-tab-pane' ).removeClass( 'active' ); 189 $( '.penci-tab-content .multi-review-comment' ).addClass( 'active' ); 190 } 191 192 if( $viewruID.length ){ 193 var $offset = $viewruID.offset().top; 194 195 $('html, body').animate({ 196 scrollTop: $offset - 100 197 }, 'slow'); 198 } 199 } 200 201 function userReviewLike(){ 202 var $urLike = $( '.penci-ur-like' ); 203 204 if( ! $urLike.length ){ 205 return false; 206 } 207 208 $urLike.each( function( e ){ 209 var $this = $( this ); 210 211 $this.on( 'click', function(){ 212 event.preventDefault(); 213 var $this = $( this ), 214 likeCount = $this.attr( 'data-count' ), 215 $commentID = $this.attr( 'data-comment_id' ), 216 $parent = $this.parent(), 217 $spinner = $parent.find( '.penci-review-spinner' ), 218 $mess = $parent.find( '.penci-review-judge-mess' ); 219 220 $mess.html('').hide(); 221 $spinner.addClass( 'active' ); 222 223 $.ajax( { 224 type: "POST", 225 url: PENCI.ajaxUrl, 226 data: { 227 action: 'penci_review_user_like', 228 nonce: PENCI.nonce, 229 commentID: $commentID, 230 likeCount: likeCount 231 }, 232 success: function ( response ) { 233 234 $spinner.removeClass( 'active' ); 235 236 if( response.success && typeof response.data.likeCount !== 'undefined' ){ 237 $this.find( '.penci-share-number' ).html( response.data.likeCount ); 238 $this.attr( 'data-count', response.data.likeCount ); 239 } 240 241 if( response.data.mess ){ 242 $mess.html( response.data.mess ).slideDown(); 243 } 244 } 245 } ); 246 247 } ); 248 } ); 249 } 250 251 function userReviewDisLike(){ 252 var $urLike = $( '.penci-ur-dislike' ); 253 254 if( ! $urLike.length ){ 255 return false; 256 } 257 258 $urLike.each( function( e ){ 259 var $this = $( this ); 260 261 $this.on( 'click', function(){ 262 event.preventDefault(); 263 var $this = $( this ), 264 likeCount = $this.attr( 'data-count' ), 265 $commentID = $this.attr( 'data-comment_id' ), 266 $parent = $this.parent(), 267 $spinner = $parent.find( '.penci-review-spinner' ), 268 $mess = $parent.find( '.penci-review-judge-mess' ); 269 270 $mess.html('').hide(); 271 $spinner.addClass( 'active' ); 272 273 $.ajax( { 274 type: "POST", 275 url: PENCI.ajaxUrl, 276 data: { 277 action: 'penci_review_user_dislike', 278 nonce: PENCI.nonce, 279 commentID: $commentID, 280 likeCount: likeCount 281 }, 282 success: function ( response ) { 283 284 $spinner.removeClass( 'active' ); 285 286 if( response.success && typeof response.data.likeCount !== 'undefined' ){ 287 $this.find( '.penci-share-number' ).html( response.data.likeCount ); 288 $this.attr( 'data-count', response.data.likeCount ); 289 } 290 291 if( response.data.mess ){ 292 $mess.html( response.data.mess ).slideDown(); 293 } 294 } 295 } ); 296 297 } ); 298 } ); 299 } 300 301 302 $( document ).ready( function () { 303 rateyoReivew(); 304 userrateyoReivew(); 305 saveUserReview(); 306 scrollToReview(); 307 userReviewLike(); 308 userReviewDisLike(); 309 } ); 310} );
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.