1( function ( $ ) { 2'use strict'; 3 4jQuery(document).ready(function($) { 5 6 var post_url = ''; 7 8 var response = ''; 9 10 $('.helpful-block-content a').click(function(event) { 11 12 event.preventDefault(); 13 14 post_url = $(this).data('post-url'); 15 16 var post_id = $(this).data('post'); 17 18 var post_title = $(this).data('post-title'); 19 20 response = $(this).data('response'); 21 22 var show_positive_message = false; 23 24 var show_negative_message = false; 25 26 var main = $(this).parent(); 27 28 main.find('.wth-title').remove(); 29 30 main.find('.wth-message').remove(); 31 32 main.find('.wth-submit').remove(); 33 34 35 36 var title_message = ''; 37 38 if (wth_js_lang.positive_feedback == 'true') { 39 40 show_positive_message = true; 41 42 title_message = wth_js_lang.wth_title_yesthank; 43 44 } 45 46 if (wth_js_lang.negative_feedback == 'true') { 47 48 show_negative_message = true; 49 50 title_message = wth_js_lang.wth_title_nothank; 51 52 } 53 54 55 56 if (response == '1') { 57 58 title_message = wth_js_lang.wth_title_yesthank; 59 60 main.find(".wth-red-btn").addClass('fc-disabled'); 61 62 wth_ga_event( wth_js_lang.wth_ga_positive, post_title ); 63 64 } else if (response == '0') { 65 66 title_message = wth_js_lang.wth_title_nothank; 67 68 main.find(".wth-green-btn").addClass('fc-disabled'); 69 70 wth_ga_event( wth_js_lang.wth_ga_negative, post_title ); 71 72 } 73 74 if((show_positive_message == true && response == '1')){ 75 76 if (main.find(".wth-share-box").length > 0) { return; } 77 78 if(wth_js_lang.positive_feedback_option == 'feedback_share'){ 79 80 var facebook_button = ' <a class="wth-fb-share-button wth-share" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u='+post_url+'">'+wth_js_lang.wth_fb_share+'</a> '; 81 82 var tweeter_button = ' <a class="wth-tweeter-share-button wth-share" href="#">'+wth_js_lang.wth_twitter_share+'</a> '; 83 84 var wth_share_title = '<span class="wth-share-title">'+wth_js_lang.wth_share_ask+' </span>'; 85 86 var wth_share_box = $('<div class="wth-share-box"> '+ wth_share_title + facebook_button + tweeter_button +'</div>'); 87 88 main.append(wth_share_box); 89 90 wth_pre_send_feedback($(this), show_positive_message, show_negative_message); 91 92 }else{ 93 94 var title_box = $('<div class="wth-title">' + title_message + '</div>'); 95 96 var mess_box = $('<textarea class="wth-message" rows="3" cols="30"></textarea>'); 97 98 var negative_btn = $('<input data-response="' + response + '" data-post="' + post_id + '" type="button" name="wth-submit" class="wth-submit" value="' + wth_js_lang.submit_text + '"/>'); 99 100 main.append(title_box); 101 102 main.append(mess_box); 103 104 main.append(negative_btn); 105 106 if( wth_js_lang.positive_feedback_required != 'true'){ 107 108 wth_pre_send_feedback($(this), show_positive_message, show_negative_message); 109 110 } 111 112 } 113 114 115 116 }else if((show_negative_message == true && response == '0') ){ 117 118 var title_box = $('<div class="wth-title">' + title_message + '</div>'); 119 120 var mess_box = $('<textarea class="wth-message" rows="3" cols="30"></textarea>'); 121 122 var negative_btn = $('<input data-response="' + response + '" data-post="' + post_id + '" type="button" name="wth-submit" class="wth-submit" value="' + wth_js_lang.submit_text + '"/>'); 123 124 main.append(title_box); 125 126 main.append(mess_box); 127 128 main.append(negative_btn); 129 130 if( wth_js_lang.negative_feedback_required != 'true'){ 131 132 wth_pre_send_feedback($(this), show_positive_message, show_negative_message); 133 134 } 135 136 } else { 137 138 wth_send_feedback($(this)); 139 140 } 141 142 143 144 }); 145 146 147 148 function wth_send_feedback(obj) { 149 150 151 152 var post_id = $(obj).data('post'); 153 154 var response = $(obj).data('response'); 155 156 var wth_feedback_id = $('#wth_feedback_id').val(); 157 158 var message = $(obj).parent().find('.wth-message').val(); 159 160 var title = $(obj).parent().parent().parent().data('title'); 161 162 var ajax_url = wth_js_lang.ajax_url; 163 164 var data = { 165 166 post_id: post_id, 167 168 response: response, 169 170 wth_feedback_id: wth_feedback_id, 171 172 message: message, 173 174 title: title, 175 176 action: 'wth_ajax_call', 177 178 operation: 'wthp_log_feedback', 179 180 nonce: wth_js_lang.nonce 181 182 }; 183 184 var main = $(obj).parent(); 185 186 187 188 $.ajax({ 189 190 url: ajax_url, 191 192 data: data, 193 194 dataType: 'json', 195 196 type: 'POST', 197 198 beforeSend: function() { 199 200 main.append('<div class="wth-loader"></div>'); 201 202 }, 203 204 complete: function() { 205 206 //main.find('.wth_loader').remove(); 207 208 }, 209 210 success: function(resp) { 211 212 213 214 var elem = $('<p>').hide(); 215 216 if (resp.success == true) { 217 218 elem.addClass('wth-success'); 219 220 } else if (resp.error == true) { 221 222 elem.addClass('wth-error'); 223 224 } 225 226 main.parent().html(elem); 227 228 elem.html(resp.message).fadeIn(500); 229 230 }, 231 232 }); 233 234 } 235 236 237 238 function wth_pre_send_feedback(obj){ 239 240 var post_id = $(obj).data('post'); 241 242 var response = $(obj).data('response'); 243 244 var wth_feedback_id = $('#wth_feedback_id').val(); 245 246 var message = $(obj).parent().find('.wth-message').val(); 247 248 var title = $(obj).parent().parent().parent().data('title'); 249 250 var ajax_url = wth_js_lang.ajax_url; 251 252 var data = { 253 254 post_id: post_id, 255 256 response: response, 257 258 message: message, 259 260 title: title, 261 262 action: 'wth_ajax_call', 263 264 operation: 'wthp_log_feedback', 265 266 nonce: wth_js_lang.nonce 267 268 }; 269 270 var main = $(obj).parent(); 271 272 if ( ! wth_feedback_id ){ 273 274 $.ajax({ 275 276 url: ajax_url, 277 278 data: data, 279 280 dataType: 'json', 281 282 type: 'POST', 283 284 success: function(resp) { 285 286 var wth_feedback_element = $('<input type="hidden" id="wth_feedback_id" name="wth_feedback_id" value="' + resp.id + '" />'); 287 288 $(".wth-submit").before(wth_feedback_element); 289 290 }, 291 292 }); 293 294 } 295 296 } 297 298 $('body').on('click', '.wth-submit', function(event) { 299 300 301 302 event.preventDefault(); 303 304 if ( 305 306 ((response == '1' && wth_js_lang.positive_feedback_required == 'true') || (response == '0' && wth_js_lang.negative_feedback_required == 'true')) 307 308 && !$.trim($(".wth-message").val()) 309 310 ) 311 312 { 313 $(".wth-message").addClass('wth-feedback-error') ; 314 }else{ 315 wth_send_feedback($(this)); 316 } 317 318 }); 319 320 $('body').on('click','.wth-fb-share-button', function(){ 321 window.open(this.href,'targetWindow','toolbar=no,location=0,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=250'); 322 return false; 323 324 }); 325 326 $('body').on('click','.wth-tweeter-share-button', function(){ 327 328 var fbpopup = window.open("https://twitter.com/intent/tweet?text="+post_url, "pop", "width=600, height=400, scrollbars=no"); 329 330 return false;
331 332 }); 333 334 335 336 /** 337 338 * Check wheather a number exist or not 339 340 * @param string func_name Name of the function 341 342 * @return boolean true/false 343 344 */ 345 346 function function_exists(func_name) { 347 348 if (typeof func_name === 'string') { 349 if(!(typeof window[func_name] !== undefined)) { 350 func_name = this.window[func_name]; 351 } 352 } 353 354 return typeof func_name === 'function'; 355 356 } 357 358 359 360 function wth_ga_event( eventAction, eventLabel ){ 361 362 if(wth_js_lang.wth_ga_enable != true ) { 363 364 return; 365 366 } 367 368 var eventCategory = wth_js_lang.wth_ga_category; 369 370 if ( function_exists( 'ga' ) ){ 371 372 ga( 'send', 'event', eventCategory, eventAction, eventLabel ); 373 374 } else if ( function_exists( '_trackEvent' ) ){ 375 376 _trackEvent( eventCategory, eventAction, eventLabel ); 377 378 } else { 379 380 return; 381 382 } 383 384 } 385 386}); 387 388} (jQuery)); 389 390
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.