1jQuery(document).ready(function($){ 2 "use strict" 3 function show_element( element, callback ){ 4 var main_parent = element.parents('.poller_master_poll'); 5 var easing = main_parent.data('in_easing'); 6 var effect = main_parent.data('in_effect'); 7 8 if( effect == 'slide' ){ 9 element.hide().slideDown( 500, easing, function(){ 10 if( callback ){ 11 callback(); 12 } 13 } ); 14 } 15 else if( effect == 'fade' ){ 16 element.hide().fadeIn( 500, easing, function(){ 17 if( callback ){ 18 callback(); 19 } 20 } ); 21 } 22 else{ 23 element.hide().show( 500, easing, function(){ 24 if( callback ){ 25 callback(); 26 } 27 } ); 28 } 29 } 30 31 function hide_element( element, callback ){ 32 var main_parent = element.parents('.poller_master_poll'); 33 var easing = main_parent.data('out_easing'); 34 var effect = main_parent.data('out_effect'); 35 36 if( effect == 'slide' ){ 37 element.slideUp( 500, easing, function(){ 38 if( callback ){ 39 callback(); 40 } 41 } ); 42 } 43 else if( effect == 'fade' ){ 44 element.fadeOut( 500, easing, function(){ 45 if( callback ){ 46 callback(); 47 } 48 } ); 49 } 50 else{ 51 element.hide( 500, easing, function(){ 52 if( callback ){ 53 callback(); 54 } 55 } ); 56 } 57 } 58 59 /* conect with close results button */ 60 $(document).on( 'click', '.poller_master_close_res button', function(e){ 61 e.preventDefault(); 62 63 hide_element( $(this).parents('.poller_master_results') ); 64 }); 65 66 /* slow close the alerts */ 67 $(document).on( 'click', '.pm-alert .close', function(e){ 68 e.preventDefault(); 69 70 hide_element( $(this).parents('.pm-alert'), function(){ $(this).remove(); } ); 71 }); 72 73 function show_success( message, parent_object ){ 74 var container = parent_object.find('.poller_master_message'); 75 container.append( 76 '<div class="pm-alert pm-alert-success pm-alert-dismissable">'+ 77 '<span class="glyphicon glyphicon-ok-sign"></span>'+ 78 '<button type="button" class="close" aria-hidden="true">×</button>'+ 79 message+ 80 '</div>' 81 ); 82 show_element( container.find( '.pm-alert:last' ) ); 83 } 84 85 function show_error( message, parent_object ){ 86 var container = parent_object.find('.poller_master_message'); 87 container.append( 88 '<div class="pm-alert pm-alert-danger pm-alert-dismissable">'+ 89 '<span class="glyphicon glyphicon-remove-sign"></span>'+ 90 '<button type="button" class="close" aria-hidden="true">×</button>'+ 91 message+ 92 '</div>' 93 ); 94 95 show_element( container.find( '.pm-alert:last' ) ); 96 } 97 98 function show_loading( parent_object ){ 99 var height = parent_object.find('.poller_master_question_box').outerHeight( true ); 100 var width = parent_object.find('.poller_master_question_box').outerWidth( true ); 101 parent_object.find('.poller_master_results').html( '<div class="loading"></div>' ).css({height: height, width: width} ); 102 show_element( parent_object.find('.poller_master_results') ); 103 } 104 105 function hide_loading( parent_object ){ 106 parent_object.find('.poller_master_results').slideUp( 500, 'easeOutBounce' ); 107 } 108 109 function show_results( results_html, parent_object ){ 110 parent_object.find('.loading').fadeOut( 111 1000, 112 function(){ 113 var obj = parent_object.find('.poller_master_results'); 114 obj.html( '<div class="results_box">'+results_html+'</div>' ); 115 var progress_height = 87 / ( obj.find('.poller_master_bar').length ); 116 obj.find( '.poller_master_bar' ).css({ height: progress_height+'%'}); 117 obj.find('.results_box').fadeIn( 500, function(){ 118 obj.find( '.pm-progress-bar' ).loadbar(); 119 } ); 120 } 121 ); 122 } 123 124 if( $('#poller_master_vote').length > 0 ){ 125 $(document).on( 'click', '#poller_master_vote', function(e){ 126 e.preventDefault(); 127 var $this = $(this); 128 var parent_object = $(this).parents('.poller_master_poll'); 129 var poll_id = parent_object.data('poll_id'); 130 var form = parent_object.find('.poller_master_form'); 131 var votes = []; 132 133 form.find('input').each(function(){ 134 if( $(this).prop('checked') ){ 135 votes.push( $(this).val() ); 136 } 137 }); 138 if( votes.length > 0 ){ 139 show_loading( parent_object ); 140 $.ajax({
141 url: ajaxurl, 142 dataType: "JSON", 143 type: "POST", 144 data: { 145 poll_id: poll_id, 146 votes: votes, 147 action: "vote_the_poll" 148 }, 149 success: function(response){ 150 if( !response.error ){ 151 show_success( response.success, parent_object ); 152 show_results( response.results_html, parent_object ); 153 if( !response.can_vote ){ 154 $this.fadeOut( 500 ); 155 } 156 parent_object.find( '#poller_master_results' ).fadeIn( 500 ); 157 if( response.countdown_vote !== "" ){ 158 parent_object.append( response.countdown_vote ); 159 countdown_vote( parent_object.find( '.poller_master_vote_countdown' ) ); 160 } 161 } 162 else{ 163 hide_loading( parent_object ); 164 show_error( response.error, parent_object ); 165 } 166 }, 167 error: function(){ 168 hide_loading( parent_object ); 169 }, 170 complete: function(){ 171 172 } 173 }); 174 } 175 else{ 176 hide_loading( parent_object ); 177 show_error( form.data('error_empty_text'), parent_object ); 178 } 179 }); 180 } 181 182 if( $('#poller_master_results').length > 0 ){ 183 $(document).on( 'click', '#poller_master_results', function(e){ 184 e.preventDefault(); 185 var parent_object = $(this).parents('.poller_master_poll'); 186 var poll_id = parent_object.data('poll_id'); 187 show_loading( parent_object ); 188 $.ajax({ 189 url: ajaxurl, 190 dataType: "JSON", 191 type: "POST", 192 data: { 193 poll_id: poll_id, 194 action: "get_poll_results" 195 }, 196 success: function( response ){ 197 if( !response.error ){ 198 show_results( response.results_html, parent_object ); 199 } 200 else{ 201 hide_loading( parent_object ); 202 show_error( response.error, parent_object ); 203 } 204 }, 205 error: function(){ 206 hide_loading( parent_object ); 207 }, 208 complete: function(){ 209 210 } 211 }); 212 }); 213 } 214 215 /* style for checkboxes and radio buttons */ 216 $('.poller_master_form').each(function(){ 217 var parent = $(this); 218 var input_class = parent.data('input_class'); 219 parent.find('input').iCheck({ 220 checkboxClass: input_class, 221 radioClass: input_class, 222 labelHover: true, 223 cursor: true 224 }); 225 }); 226 227 if( $('.poller_master_poll_countdown').length > 0 ){ 228 $('.poller_master_poll_countdown').each(function(){ 229 var $this = $(this); 230 $this.kkcountdown({ 231 dayText : $this.data('day_text'), 232 daysText : $this.data('days_text'), 233 hoursText : $this.data('hours_text'), 234 minutesText : $this.data('minutes_text'), 235 secondsText : $this.data('seconds_text'), 236 addClass : 'poll_countdown', 237 displayZeroDays : true, 238 displayTexts : $this.data('show_texts'), 239 rusNumbers : false 240 }); 241 }); 242 } 243 244 245 function countdown_vote( $this ){ 246 $this.kkcountdown({ 247 dayText : $this.data('day_text'), 248 daysText : $this.data('days_text'), 249 hoursText : $this.data('hours_text'), 250 minutesText : $this.data('minutes_text'), 251 secondsText : $this.data('seconds_text'), 252 addClass : 'vote_countdown', 253 displayZeroDays : true, 254 displayTexts : $this.data('show_texts'), 255 rusNumbers : false 256 }); 257 } 258 if( $('.poller_master_vote_countdown').length > 0 ){ 259 $('.poller_master_vote_countdown').each(function(){ 260 countdown_vote( $(this) ); 261 }); 262 } 263 264 /* show messages which are present on page load */ 265 if( $('.poller_master_message').html() !== "" ){ 266 $('.poller_master_message .pm-alert').each(function(){ 267 show_element( $(this) ); 268 }); 269 } 270 271});
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.