1if($('.phone').length) { 2 $.when(add_js(shared_root+'/js/jquery/jquery.autotab/jquery.autotab-1.1b.js')).done(function() { 3 $("input.phone").autotab_magic().autotab_filter("numeric"); 4 }); 5} 6 7if($('.datepicker').length) { 8 add_css(shared_root+'/css/smoothness/jquery-ui-1.8.custom.css'); 9} 10 11if($('.hidden-address-field').length) { 12 $.when( 13 add_js( 14 '//maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyBhu5ibJC_Df3aYWZW_ryElSDtrQbvg9HA&libraries=places', 15 shared_root+'/js/json/json2.js' 16 ) 17 ).done(function() { 18 add_js(shared_root+'/js/google-address-lookup2.js',1); 19 }); 20} 21 22$(document).on('click','.schedule-time-selector .timeslot-selector',function() { 23 $('.timeslot-selector').removeClass('engaged'); 24 $(this).addClass('engaged'); 25}); 26 27 28// ------------ 29// Stripe stuff 30// ------------ 31if($('#card-number').length) { 32 $.when( 33 add_js('https://js.stripe.com/v2/',1) 34 ).done(function() { 35 Stripe.setPublishableKey($('#card-number').attr('data-stripe-key')); 36 37 /* ----------------------------------------------------------------------------------------------------------------------- */ 38 /* Form Submission Handling ---------------------------------------------------------------------------------------------- */ 39 /* ----------------------------------------------------------------------------------------------------------------------- */ 40 var form = $("#scheduler-form"); 41 42 $(form).submit(function() { 43 $("#form-loading").remove(); 44 45 var amount = parseFloat($('#card-number').attr('data-payment-amount')); 46 47 var error = ''; 48 $(form).find('.required').each(function() { 49 if(!$(this).val()) { 50 var field_name = $(this).closest('.field-wrap').find('label').html().replace('<em>*</em>','').replace(':',''); 51 error += field_name+' is required.<br />'; 52 } 53 }); 54 55 if(!amount) error += 'Please enter an amount.<br />'; 56 if($("#card-number").val().length < 10) error += 'Please enter a credit card number.<br />'; 57 if(!$("#card-expiry-month").val()) error += 'Please enter a credit card expiration month.<br />'; 58 if(!$("#card-expiry-year").val()) error += 'Please enter a credit card expiration year.<br />'; 59 if(!$("#card-cvc").val()) error += 'Please enter a credit card CVC.<br />'; 60 61 if(!error) { 62 $('body').append('<div id="form-loading"></div>'); 63 do_card_submit($(form)); 64 } 65 66 if(error) { 67 showAlert(error,'bad'); 68 $("#form-loading").remove(); 69 } 70 71 return false; 72 }); 73 74 function do_card_submit(form) { 75 if(!$(form).hasClass("dosubmit")) { 76 // disable the submit button to ensure we dont have a double submit 77 // $(this).find("input[type=submit]").attr("disabled",1); 78 79 Stripe.card.createToken({ 80 number: $("#card-number").val(), 81 cvc: $("#card-cvc").val(), 82 exp_month: $("#card-expiry-month").val(), 83 exp_year: $("#card-expiry-year").val() 84 }, stripeResponseHandler); 85 return false; 86 } 87 } 88 89 stripeResponseHandler = function(status, response) { 90 if (response.error) { 91 // show the errors on the form 92 showAlert(response.error.message,"bad"); 93 $("#form-loading").remove(); 94 95 } else { 96 var $form = $("form#scheduler-form"); 97 // token contains id, last4, and card type 98 var token = response["id"]; 99 // insert the token into the form so it gets submitted to the server 100 $form.append('<input type="hidden" name="stripe_token" value="' + token + '"/>'); 101 $form.addClass("dosubmit"); 102 // add submit 103 $form.get(0).submit(); 104 } 105 }; 106 107 }); 108} 109 110 111/* ----------------------------------------------------------------------------------------------------------------------- */ 112/* Signature Pad Handling ------------------------------------------------------------------------------------------------ */ 113/* ----------------------------------------------------------------------------------------------------------------------- */ 114if($('.m-signature-pad').length) { 115 $.when(add_js(shared_root+'/js/signature-pad/signature_pad.js')).done(function() { 116 $('.m-signature-pad').each(function() { 117 var wrapper = $(this), 118 clearButton = $(wrapper).find('.clear'), 119 canvas = $(wrapper).find('canvas')[0], 120 signature = $(wrapper).find('textarea.signature'); 121 signaturePad; 122 123 if($(signature).val()) { 124 var ctx = canvas.getContext("2d"); 125 var image = new Image(); 126 image.onload = function() {
127 ctx.drawImage(image, 0, 0); 128 }; 129 image.src = $(signature).val(); 130 } 131 132 // Adjust canvas coordinate space taking into account pixel ratio, 133 // to make it look crisp on mobile devices. 134 // This also causes canvas to be cleared. 135 function resizeSignatureCanvas() { 136 // When zoomed out to less than 100%, for some very strange reason, 137 // some browsers report devicePixelRatio as less than 1 138 // and only part of the canvas is cleared then. 139 var ratio = Math.max(window.devicePixelRatio || 1, 1); 140 canvas.width = canvas.offsetWidth * ratio; 141 canvas.height = canvas.offsetHeight * ratio; 142 canvas.getContext("2d").scale(ratio, ratio); 143 } 144 145 window.onresize = resizeSignatureCanvas; 146 resizeSignatureCanvas(); 147 148 var signaturePad = new SignaturePad(canvas,{ 149 onEnd: function() { 150 $(signature).val(canvas.toDataURL()).change(); 151 } 152 }); 153 154 $(clearButton).on('click',function() { 155 signaturePad.clear(); 156 $(signature).val('').change(); 157 }); 158 }); 159 }); 160} 161 162 163/* ----------------------------------------------------------------------------------------------------------------------- */ 164/* Chosen Dropdown Replace Handling (for multi-selects) ------------------------------------------------------------------ */ 165/* ----------------------------------------------------------------------------------------------------------------------- */ 166function do_chosen() { 167 if($('.do-chosen').length) { 168 add_css(shared_root+'/js/jquery/jquery.chosen/chosen.min.css'); 169 $.when(add_js(shared_root+'/js/jquery/jquery.chosen/chosen.jquery.min.js')).done(function() { 170 $('.do-chosen').chosen(); 171 }); 172 } 173} 174do_chosen(); 175 176 177/* ----------------------------------------------------------------------------------------------------------------------- */ 178/* User Timezone Handling ------------------------------------------------------------------------------------------------ */ 179/* ----------------------------------------------------------------------------------------------------------------------- */ 180$('#scheduler-timezone-selector').change(function() { 181 var url_arr = window.location.href.split('&tzo='); 182 var url = url_arr[0]; 183 window.location.href = url+(url.indexOf('?') >= 0?'&':'?&')+'tzo='+$(this).val(); 184}); 185 186if(window.location.href.indexOf('tzo=') < 0 && typeof(timezones_arr) != 'undefined') { 187 var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; 188 if(timezone) { 189 for(var idx in timezones_arr) { 190 if(timezones_arr[idx] == timezone) { 191 if($('#scheduler-timezone-selector').val() != idx) { 192 $('#scheduler-timezone-selector').val(idx).change(); 193 } 194 } 195 } 196 } 197} 198 199 200/* ----------------------------------------------------------------------------------------------------------------------- */ 201/* AJAX Handling --------------------------------------------------------------------------------------------------------- */ 202/* ----------------------------------------------------------------------------------------------------------------------- */ 203if(window.location.href.indexOf('embed=') < 0) { 204 var cal_loader_timeout; 205 var last_url = window.location.search; 206 207 $(document).on('click',".event-links-bar .button",function() { 208 if($(this).attr('href')) { 209 var href = $(this).attr('href'); 210 ajax_load_events_calendar_page(href,false,false); 211 return false; 212 } 213 }); 214 215 $(document).on('click',".calendar-filter-link",function() { 216 $(this).toggleClass('selected'); 217 ajax_load_events_calendar_page(window.location.pathname+window.location.search,false,false); 218 return false; 219 }); 220 221 $(document).on('click',".calendar .inner, .calendar-detail-page > .button-wrap > .button, .schedule-time-selector .timeslot-selector .button",function() { 222 if($(this).attr('href')) { 223 var href = $(this).attr('href'); 224 ajax_load_events_calendar_page(href,false,true); 225 return false; 226 } 227 }); 228 229 function ajax_load_events_calendar_page(href,no_push_state,do_scroll) { 230 var scheduler_wrap = $('#scheduler-outer-wrap'); 231 232 $(scheduler_wrap).css({'opacity':'0.5','pointer-events':'none'}); 233 234 if($('.calendar-filter-link').length) { 235 // figure out url params for the calendar-filter-links 236 var deselected_calendars_href = ''; 237 $('.calendar-filter-link:not(.selected)').each(function() { 238 deselected_calendars_href += '&dcid[]='+$(this).data('calendar-id'); 239 }); 240 241 // remove existing calendar filter links from the href 242 href = href.replace(/&dcid\[\]=[0-9]+/g,''); 243 244 // add the deselected calendars to the href 245 if(deselected_calendars_href) { 246 if(href.indexOf('?') >= 0) { 247 href += deselected_calendars_href; 248 } else { 249 href += '?'+deselected_calendars_href.substr(1); 250 } 251 } 252 } 253 254 if(!no_push_state) history.pushState(null, null, href); 255 last_url = window.location.search; 256 257 $.ajax({
258 type: "GET", 259 url: href+(href.indexOf('?')>=0?'&':'?')+'ajax_scheduler_load=1', 260 success: function(html,textStatus) { 261 $(scheduler_wrap).after(html).css({'opacity':'','pointer-events':''}); 262 $(scheduler_wrap).remove(); 263 if(do_scroll) { 264 var scroll_amt = $('#scheduler-outer-wrap').offset().top; 265 if($('#header').length) { 266 scroll_amt -= $('#header').outerHeight(); 267 } else if($('.header').length) { 268 scroll_amt -= $('.header').outerHeight(); 269 } 270 scroll_amt -= 50; 271 $('body,html').stop(1,1).animate({'scrollTop':scroll_amt+'px'},750,'easeInOutQuad'); 272 $.when(add_js('//www.google.com/recaptcha/api.js?onload=render_ss_captchas')).done(function() { 273 render_ss_captchas(); 274 }); 275 } 276 do_timeslot_resorts(); 277 } 278 }); 279 } 280 281 setInterval(function() { 282 if(window.location.search != last_url) { 283 var href = window.location.search; 284 ajax_load_events_calendar_page(href,1); 285 } 286 },250); 287} 288 289function do_timeslot_resorts() { 290 if($('.timeslots-ul-list').length) { 291 $('.timeslots-ul-list').each(function() { 292 var $list = $(this); 293 var $items = $list.find('.timeslot-selector').get(); 294 295 $items.sort(function(a, b) { 296 var timeA = parseInt($(a).find('.time').data('time')); 297 var timeB = parseInt($(b).find('.time').data('time')); 298 return timeA - timeB; 299 }); 300 301 $list.empty().append($items); 302 303 // if there are more than 8, aadd a "more" button and hide the rest 304 if($items.length > 8) { 305 // Hide all but the first 8 items 306 $list.find('.timeslot-selector').slice(8).hide(); 307 308 $list.append('<li class="more-timeslots"><a href="#" class="small-action-button more-times-button">More Times +</a></li>'); 309 $list.find('.more-timeslots a').on('click',function() { 310 $list.find('.timeslot-selector').show(); 311 $(this).remove(); 312 return false; 313 }); 314 } 315 }); 316 317 } 318} 319 320do_timeslot_resorts(); 321 322 323/* ----------------------------------------------------------------------------------------------------------------------- */ 324/* Cancel Confirmation Handling ------------------------------------------------------------------------------------------ */ 325/* ----------------------------------------------------------------------------------------------------------------------- */ 326if($('.cancel-meeting-link').length) { 327 $(document).on('click','.cancel-meeting-link',function(e) { 328 e.preventDefault(); 329 var thehref = $(this).attr('href'); 330 331 swal({ 332 title: 'Are you sure you want to cancel this meeting?', 333 text: 'This cannot be undone!', 334 type: 'warning', 335 showCancelButton: true, 336 confirmButtonColor: "#DD6B55", 337 confirmButtonText: "Yes, cancel it!", 338 closeOnConfirm: true 339 },function(){ 340 window.location.href = thehref; 341 }); 342 343 return false; 344 }); 345}
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.