1jQuery(document).ready(function($) { 2 console.log('doc ready1'); 3 var post_url = ''; 4 var response = ''; 5 $('.helpful-block-content a').click(function(event) { 6 console.log('click a-tag'); 7 event.preventDefault(); 8 post_url = $(this).data('post-url'); 9 var post_id = $(this).data('post'); 10 var post_title = $(this).data('post-title'); 11 response = $(this).data('response'); 12 var show_positive_message = false; 13 var show_negative_message = false; 14 var main = $(this).parent(); 15 main.find('.wth-title').remove(); 16 main.find('.wth-message').remove(); 17 main.find('.wth-submit').remove(); 18 19 var title_message = ''; 20 if (wth_js_lang.positive_feedback == 'true') { 21 show_positive_message = true; 22 title_message = wth_js_lang.wth_title_yesthank; 23 } 24 if (wth_js_lang.negative_feedback == 'true') { 25 show_negative_message = true; 26 title_message = wth_js_lang.wth_title_nothank; 27 } 28 29 if (response == '1') { 30 title_message = wth_js_lang.wth_title_yesthank; 31 main.find(".wth-red-btn").addClass('fc-disabled'); 32 wth_ga_event( wth_js_lang.wth_ga_positive, post_title ); 33 } else if (response == '0') { 34 title_message = wth_js_lang.wth_title_nothank; 35 main.find(".wth-green-btn").addClass('fc-disabled'); 36 wth_ga_event( wth_js_lang.wth_ga_negative, post_title ); 37 } 38 if((show_positive_message == true && response == '1')){ 39 if (main.find(".wth-share-box").length > 0) { return; } 40 if(wth_js_lang.positive_feedback_option == 'feedback_share'){ 41 var facebook_button = ' <a class="wth-fb-share-button wth-share" href="#">'+wth_js_lang.wth_fb_share+'</a> '; 42 var tweeter_button = ' <a class="wth-tweeter-share-button wth-share" href="#">'+wth_js_lang.wth_twitter_share+'</a> '; 43 var wth_share_title = '<span class="wth-share-title">'+wth_js_lang.wth_share_ask+' </span>'; 44 var wth_share_box = $('<div class="wth-share-box"> '+ wth_share_title + facebook_button + tweeter_button +'</div>'); 45 main.append(wth_share_box); 46 wth_pre_send_feedback($(this), show_positive_message, show_negative_message); 47 }else{ 48 var title_box = $('<div class="wth-title">' + title_message + '</div>'); 49 var mess_box = $('<textarea class="wth-message" rows="3" cols="30"></textarea>'); 50 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 + '"/>'); 51 main.append(title_box); 52 main.append(mess_box); 53 main.append(negative_btn); 54 if( wth_js_lang.positive_feedback_required != 'true'){ 55 wth_pre_send_feedback($(this), show_positive_message, show_negative_message); 56 } 57 } 58 59 }else if((show_negative_message == true && response == '0') ){ 60 var title_box = $('<div class="wth-title">' + title_message + '</div>'); 61 var mess_box = $('<textarea class="wth-message" rows="3" cols="30"></textarea>'); 62 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 + '"/>'); 63 main.append(title_box); 64 main.append(mess_box); 65 main.append(negative_btn); 66 if( wth_js_lang.negative_feedback_required != 'true'){ 67 wth_pre_send_feedback($(this), show_positive_message, show_negative_message); 68 } 69 } else { 70 wth_send_feedback($(this)); 71 } 72 73 }); 74 75 function wth_send_feedback(obj) { 76 77 var post_id = $(obj).data('post'); 78 var response = $(obj).data('response'); 79 var wth_feedback_id = $('#wth_feedback_id').val(); 80 var message = $(obj).parent().find('.wth-message').val(); 81 var title = $(obj).parent().parent().parent().data('title'); 82 var ajax_url = wth_js_lang.ajax_url; 83 var data = { 84 post_id: post_id, 85 response: response, 86 wth_feedback_id: wth_feedback_id, 87 message: message, 88 title: title, 89 action: 'wth_ajax_call', 90 operation: 'wthp_log_feedback', 91 nonce: wth_js_lang.nonce 92 }; 93 var main = $(obj).parent(); 94 95 $.ajax({ 96 url: ajax_url, 97 data: data, 98 dataType: 'json', 99 type: 'POST', 100 beforeSend: function() { 101 main.append('<div class="wth-loader"></div>'); 102 }, 103 complete: function() { 104 //main.find('.wth_loader').remove(); 105 }, 106 success: function(resp) { 107 108 elem = $('<p>').hide(); 109 if (resp.success == true) { 110 elem.addClass('wth-success'); 111 } else if (resp.error == true) { 112 elem.addClass('wth-error'); 113 } 114 main.parent().html(elem); 115 elem.html(resp.message).fadeIn(500); 116 }, 117 }); 118 } 119 120 function wth_pre_send_feedback(obj){ 121 var post_id = $(obj).data('post'); 122 var response = $(obj).data('response'); 123 var wth_feedback_id = $('#wth_feedback_id').val(); 124 var message = $(obj).parent().find('.wth-message').val(); 125 var title = $(obj).parent().parent().parent().data('title'); 126 var ajax_url = wth_js_lang.ajax_url; 127 128 // if ( (response == '1' && wth_js_lang.positive_feedback_required == 'true') 129 // || (response == '0' && wth_js_lang.negative_feedback_required == 'true') ) { 130 // return; 131 // }; 132 133 var data = { 134 post_id: post_id, 135 response: response, 136 message: message, 137 title: title, 138 action: 'wth_ajax_call', 139 operation: 'wthp_log_feedback', 140 nonce: wth_js_lang.nonce 141 }; 142 var main = $(obj).parent(); 143 if ( ! wth_feedback_id ){ 144 $.ajax({ 145 url: ajax_url, 146 data: data, 147 dataType: 'json', 148 type: 'POST', 149 success: function(resp) { 150 wth_feedback_element = $('<input type="hidden" id="wth_feedback_id" name="wth_feedback_id" value="' + resp.id + '" />'); 151 $(".wth-submit").before(wth_feedback_element); 152 }, 153 }); 154 } 155 } 156 $('body').on('click', '.wth-submit', function(event) { 157 158 event.preventDefault(); 159 if ( 160 ((response == '1' && wth_js_lang.positive_feedback_required == 'true') || (response == '0' && wth_js_lang.negative_feedback_required == 'true')) 161 && !$.trim($(".wth-message").val()) 162 ) 163 { 164 $(".wth-message").addClass('wth-feedback-error') ; 165 }else{ 166 wth_send_feedback($(this)); 167 } 168 169 // if (wth_js_lang.positive_feedback_required == 'true' && !$.trim($(".wth-message").val())) { 170 171 // }else{ 172 // wth_send_feedback($(this)); 173 // } 174 }); 175 $('body').on('click','.wth-fb-share-button', function(){ 176 var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u="+post_url+"&redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer", "pop", "width=600, height=400, scrollbars=no"); 177 return false;
178 }); 179 $('body').on('click','.wth-tweeter-share-button', function(){ 180 var fbpopup = window.open("https://twitter.com/intent/tweet?text="+post_url, "pop", "width=600, height=400, scrollbars=no"); 181 return false; 182 }); 183 184 /** 185 * Check wheather a number exist or not 186 * @param string func_name Name of the function 187 * @return boolean true/false 188 */ 189 function function_exists(func_name) { 190 if (typeof func_name === 'string') { 191 func_name = this.window[func_name]; 192 } 193 return typeof func_name === 'function'; 194 } 195 196 function wth_ga_event( eventAction, eventLabel ){ 197 if(wth_js_lang.wth_ga_enable != true ) { 198 return; 199 } 200 var eventCategory = wth_js_lang.wth_ga_category; 201 if ( function_exists( 'ga' ) ){ 202 ga( 'send', 'event', eventCategory, eventAction, eventLabel ); 203 } else if ( function_exists( '_trackEvent' ) ){ 204 _trackEvent( eventCategory, eventAction, eventLabel ); 205 } else { 206 return; 207 } 208 } 209 210 211});
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.