broker clean up
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
11 changed files
with
33 additions
and
1598 deletions
| ... | @@ -168,8 +168,7 @@ if (function_exists(clean_custom_menus())) { | ... | @@ -168,8 +168,7 @@ if (function_exists(clean_custom_menus())) { |
| 168 | </div> | 168 | </div> |
| 169 | <script> | 169 | <script> |
| 170 | (function($) { | 170 | (function($) { |
| 171 | jQuery(document).ready( | 171 | jQuery( document ).ready(function( $ ) { |
| 172 | function($) { | ||
| 173 | console.log($.cookie('dialog_cookie_new')); | 172 | console.log($.cookie('dialog_cookie_new')); |
| 174 | if ($.cookie('dialog_cookie_new') == null) { | 173 | if ($.cookie('dialog_cookie_new') == null) { |
| 175 | $(window).resize( | 174 | $(window).resize( |
| ... | @@ -333,36 +332,7 @@ if (function_exists(clean_custom_menus())) { | ... | @@ -333,36 +332,7 @@ if (function_exists(clean_custom_menus())) { |
| 333 | } | 332 | } |
| 334 | }); | 333 | }); |
| 335 | 334 | ||
| 336 | // $('.bxslider2').bxSlider({ | 335 | |
| 337 | // mode: 'fade', | ||
| 338 | // captions: true, | ||
| 339 | // auto: true, | ||
| 340 | // autoStart: true, | ||
| 341 | // pause: 9000, | ||
| 342 | // controls: false | ||
| 343 | // }); | ||
| 344 | |||
| 345 | // $('.bxslider').bxSlider({ | ||
| 346 | // mode: 'fade', | ||
| 347 | // captions: true, | ||
| 348 | // auto: true, | ||
| 349 | // autoStart: true, | ||
| 350 | // pause: 9000, | ||
| 351 | // onSlideBefore: function($slideElement, oldIndex, newIndex) { | ||
| 352 | // var $bxControls = $('.bx-controls'); | ||
| 353 | // $bxControls.fadeOut(10); | ||
| 354 | // }, | ||
| 355 | // onSlideAfter: function($slideElement, oldIndex, newIndex) { | ||
| 356 | // setTimeout(function() { | ||
| 357 | // setSliderControlPosition(newIndex); | ||
| 358 | // }, 100); | ||
| 359 | // }, | ||
| 360 | // onSliderLoad: function(currentIndex) { | ||
| 361 | // setTimeout(function() { | ||
| 362 | // setSliderControlPosition(currentIndex); | ||
| 363 | // }, 100); | ||
| 364 | // } | ||
| 365 | // }); | ||
| 366 | 336 | ||
| 367 | $(window).resize(function() { | 337 | $(window).resize(function() { |
| 368 | if ($(this).width() < 701) { | 338 | if ($(this).width() < 701) { |
| ... | @@ -384,29 +354,6 @@ if (function_exists(clean_custom_menus())) { | ... | @@ -384,29 +354,6 @@ if (function_exists(clean_custom_menus())) { |
| 384 | smallMenu.css('zIndex', 0); | 354 | smallMenu.css('zIndex', 0); |
| 385 | }, 500); | 355 | }, 500); |
| 386 | }); | 356 | }); |
| 387 | } | ||
| 388 | ); | ||
| 389 | |||
| 390 | function setSliderControlPosition(index) { | ||
| 391 | var currentItem = $('.bxslider li').eq(index); | ||
| 392 | var $wrapper = $(currentItem).find('.video-wrapper'); | ||
| 393 | var height = $wrapper.height(); | ||
| 394 | var $sliderControls = $('.slider-controls'); | ||
| 395 | $sliderControls.height(height); | ||
| 396 | |||
| 397 | var dummyControlPosition = $sliderControls.find('.slider-controls-direction').position().top; | ||
| 398 | var dummyPagerPosition = $sliderControls.find('.slider-pager').position().top; | ||
| 399 | var $bxControls = $('.bx-controls'); | ||
| 400 | var $bxControlsDirectionPrev = $bxControls.find('.bx-controls-direction .bx-prev'); | ||
| 401 | var $bxControlsDirectionNext = $bxControls.find('.bx-controls-direction .bx-next'); | ||
| 402 | var $bxPager = $('.bx-pager'); | ||
| 403 | |||
| 404 | $bxControlsDirectionPrev.css('top', dummyControlPosition); | ||
| 405 | $bxControlsDirectionNext.css('top', dummyControlPosition); | ||
| 406 | $bxPager.css('top', dummyPagerPosition); | ||
| 407 | $bxControls.fadeIn(10); | ||
| 408 | } | ||
| 409 | |||
| 410 | 357 | ||
| 411 | $("#read-more-dialog").dialog({ | 358 | $("#read-more-dialog").dialog({ |
| 412 | width: "auto", | 359 | width: "auto", |
| ... | @@ -435,6 +382,31 @@ if (function_exists(clean_custom_menus())) { | ... | @@ -435,6 +382,31 @@ if (function_exists(clean_custom_menus())) { |
| 435 | $(".ui-dialog-title").hide(); | 382 | $(".ui-dialog-title").hide(); |
| 436 | }); | 383 | }); |
| 437 | 384 | ||
| 385 | } | ||
| 386 | ); | ||
| 387 | |||
| 388 | function setSliderControlPosition(index) { | ||
| 389 | var currentItem = $('.bxslider li').eq(index); | ||
| 390 | var $wrapper = $(currentItem).find('.video-wrapper'); | ||
| 391 | var height = $wrapper.height(); | ||
| 392 | var $sliderControls = $('.slider-controls'); | ||
| 393 | $sliderControls.height(height); | ||
| 394 | |||
| 395 | var dummyControlPosition = $sliderControls.find('.slider-controls-direction').position().top; | ||
| 396 | var dummyPagerPosition = $sliderControls.find('.slider-pager').position().top; | ||
| 397 | var $bxControls = $('.bx-controls'); | ||
| 398 | var $bxControlsDirectionPrev = $bxControls.find('.bx-controls-direction .bx-prev'); | ||
| 399 | var $bxControlsDirectionNext = $bxControls.find('.bx-controls-direction .bx-next'); | ||
| 400 | var $bxPager = $('.bx-pager'); | ||
| 401 | |||
| 402 | $bxControlsDirectionPrev.css('top', dummyControlPosition); | ||
| 403 | $bxControlsDirectionNext.css('top', dummyControlPosition); | ||
| 404 | $bxPager.css('top', dummyPagerPosition); | ||
| 405 | $bxControls.fadeIn(10); | ||
| 406 | } | ||
| 407 | |||
| 408 | |||
| 409 | |||
| 438 | 410 | ||
| 439 | 411 | ||
| 440 | })(jQuery); | 412 | })(jQuery); | ... | ... |
| ... | @@ -34,25 +34,15 @@ function theme_broker_enqueue_scripts() | ... | @@ -34,25 +34,15 @@ function theme_broker_enqueue_scripts() |
| 34 | wp_enqueue_style('fontawsome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css'); | 34 | wp_enqueue_style('fontawsome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css'); |
| 35 | wp_enqueue_style('Material', 'https://fonts.googleapis.com/icon?family=Material+Icons'); | 35 | wp_enqueue_style('Material', 'https://fonts.googleapis.com/icon?family=Material+Icons'); |
| 36 | wp_enqueue_style('bxslider', get_bloginfo('template_url') . '/styles/vendor/jquery.bxslider.css'); | 36 | wp_enqueue_style('bxslider', get_bloginfo('template_url') . '/styles/vendor/jquery.bxslider.css'); |
| 37 | wp_enqueue_script( | 37 | |
| 38 | 'bxslider', | 38 | |
| 39 | get_bloginfo('template_url') . '/scripts/vendor/jquery.bxslider.js', | 39 | wp_enqueue_script( 'bxslider', get_bloginfo('template_url') . '/scripts/vendor/jquery.bxslider.js',[], "0.0.1", true ); |
| 40 | [], | ||
| 41 | "0.0.1", | ||
| 42 | true | ||
| 43 | ); | ||
| 44 | wp_enqueue_script('cookies', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js'); | 40 | wp_enqueue_script('cookies', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js'); |
| 45 | wp_enqueue_script('moblie_menu', get_bloginfo('template_url') . '/scripts/moblie_menu.js'); | 41 | wp_enqueue_script('moblie_menu', get_bloginfo('template_url') . '/scripts/moblie_menu.js'); |
| 46 | wp_enqueue_script('jQmobile', get_bloginfo('template_url') . '/scripts/vendor/jquery.mobile.custom.min.js'); | 42 | wp_enqueue_script('jQmobile', get_bloginfo('template_url') . '/scripts/vendor/jquery.mobile.custom.min.js'); |
| 47 | wp_enqueue_script('colorbox', '//cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.6.4/jquery.colorbox.js'); | 43 | wp_enqueue_script('colorbox', '//cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.6.4/jquery.colorbox.js'); |
| 48 | wp_enqueue_script( | 44 | wp_enqueue_script('bootstrap','https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js',[], false, true ); |
| 49 | 'bootstrap', | 45 | wp_enqueue_script('jquery-ui', get_bloginfo('template_url') . '/scripts/jquery-ui.min.js', [], false, true); |
| 50 | 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', | ||
| 51 | [], | ||
| 52 | false, | ||
| 53 | true | ||
| 54 | ); | ||
| 55 | |||
| 56 | // qTip | 46 | // qTip |
| 57 | wp_enqueue_style('qtip', get_bloginfo('template_url') . '/styles/vendor/jquery.qtip.css'); | 47 | wp_enqueue_style('qtip', get_bloginfo('template_url') . '/styles/vendor/jquery.qtip.css'); |
| 58 | wp_enqueue_script('qtip', get_bloginfo('template_url') . '/scripts/vendor/jquery.qtip.js', [], "0.0.1", true); | 48 | wp_enqueue_script('qtip', get_bloginfo('template_url') . '/scripts/vendor/jquery.qtip.js', [], "0.0.1", true); |
| ... | @@ -69,13 +59,7 @@ function theme_broker_enqueue_scripts() | ... | @@ -69,13 +59,7 @@ function theme_broker_enqueue_scripts() |
| 69 | 59 | ||
| 70 | // Tooltipster | 60 | // Tooltipster |
| 71 | wp_enqueue_style('tooltipster', get_bloginfo('template_url') . '/styles/vendor/tooltipster.bundle.min.css'); | 61 | wp_enqueue_style('tooltipster', get_bloginfo('template_url') . '/styles/vendor/tooltipster.bundle.min.css'); |
| 72 | wp_enqueue_script( | 62 | wp_enqueue_script( 'tooltipster', get_bloginfo('template_url') . '/scripts/vendor/tooltipster.bundle.min.js',[], "0.0.1",true ); |
| 73 | 'tooltipster', | ||
| 74 | get_bloginfo('template_url') . '/scripts/vendor/tooltipster.bundle.min.js', | ||
| 75 | [], | ||
| 76 | "0.0.1", | ||
| 77 | true | ||
| 78 | ); | ||
| 79 | wp_enqueue_script('show-more', get_bloginfo('template_url') . '/scripts/show-more.js', [], "0.0.3", true); | 63 | wp_enqueue_script('show-more', get_bloginfo('template_url') . '/scripts/show-more.js', [], "0.0.3", true); |
| 80 | wp_enqueue_script('accessibility_script', get_bloginfo('template_url') . '/scripts/accessibility.js', true); | 64 | wp_enqueue_script('accessibility_script', get_bloginfo('template_url') . '/scripts/accessibility.js', true); |
| 81 | 65 | ||
| ... | @@ -150,34 +134,7 @@ function theme_broker_enqueue_scripts() | ... | @@ -150,34 +134,7 @@ function theme_broker_enqueue_scripts() |
| 150 | 134 | ||
| 151 | } | 135 | } |
| 152 | 136 | ||
| 153 | add_action('wp_enqueue_scripts', 'theme_enqueue_scripts'); | ||
| 154 | function theme_enqueue_scripts() | ||
| 155 | { | ||
| 156 | |||
| 157 | 137 | ||
| 158 | if ( | ||
| 159 | is_page_template("broker_landing_page.php") | ||
| 160 | || is_page_template("broker_pages.php") | ||
| 161 | || is_page_template("login-page.php") | ||
| 162 | || is_page_template("default.php") | ||
| 163 | || is_page_template("general.php") | ||
| 164 | || is_page_template("SearchWpResult.php") | ||
| 165 | || is_page_template("broker_notifications_archive.php") | ||
| 166 | || is_page_template("broker_account_pages.php") | ||
| 167 | || is_page_template("marketing_masters.php") | ||
| 168 | || get_post_type() == 'notifications' | ||
| 169 | || get_post_type() == 'sfwd-courses' | ||
| 170 | || get_post_type() == 'sfwd-lessons' | ||
| 171 | || get_post_type() == 'sfwd-quiz' | ||
| 172 | || get_post_type() == 'badges' | ||
| 173 | |||
| 174 | ) { | ||
| 175 | |||
| 176 | wp_enqueue_script('require', get_bloginfo('template_url') . '/scripts/vendor/r.js', [], false, true); | ||
| 177 | } | ||
| 178 | wp_enqueue_script('global', get_bloginfo('template_url') . '/scripts/optimized.min.js', ['require'], false, true); | ||
| 179 | wp_enqueue_style('global', get_bloginfo('template_url') . '/styles/global.css'); | ||
| 180 | } | ||
| 181 | if (is_page_template("badge-share.php")) | 138 | if (is_page_template("badge-share.php")) |
| 182 | { | 139 | { |
| 183 | wp_enqueue_script('sharerbox', get_bloginfo('template_url') . '/scripts/sharerbox.js', [], false, true); | 140 | wp_enqueue_script('sharerbox', get_bloginfo('template_url') . '/scripts/sharerbox.js', [], false, true); | ... | ... |
| 1 | jQuery( document ).ready(function($) { | ||
| 2 | |||
| 3 | if($('#bambora').is(":visible") ){ | ||
| 4 | |||
| 5 | $('#bambora').wrap('<form id="checkout-form" class="form-inline"></form>'); | ||
| 6 | |||
| 7 | /* global customcheckout */ | ||
| 8 | "use strict"; | ||
| 9 | |||
| 10 | |||
| 11 | var customCheckout = customcheckout(); | ||
| 12 | var customForm = $('#GeneratedTable_wrapper'); | ||
| 13 | var isCardNumberComplete = false; | ||
| 14 | var isCVVComplete = false; | ||
| 15 | var isExpiryComplete = false; | ||
| 16 | var processTokenCount = 0; | ||
| 17 | |||
| 18 | var customCheckoutController = { | ||
| 19 | |||
| 20 | |||
| 21 | init: function () { | ||
| 22 | console.log('checkout.init()'); | ||
| 23 | this.createInputs(); | ||
| 24 | this.addListeners(); | ||
| 25 | }, | ||
| 26 | createInputs: function () { | ||
| 27 | console.log('checkout.createInputs()'); | ||
| 28 | var style = { | ||
| 29 | base: { | ||
| 30 | color: '#6c757d', | ||
| 31 | fontWeight: "400", | ||
| 32 | fontSize: '1rem' | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | |||
| 36 | var options = { | ||
| 37 | style: style, | ||
| 38 | }; | ||
| 39 | |||
| 40 | // Create and mount the inputs | ||
| 41 | options.placeholder = ''; | ||
| 42 | customCheckout.create('card-number', options).mount('#card-number'); | ||
| 43 | |||
| 44 | options.placeholder = 'CVV'; | ||
| 45 | customCheckout.create('cvv', options).mount('#card-cvv'); | ||
| 46 | |||
| 47 | options.placeholder = 'MM / YY'; | ||
| 48 | customCheckout.create('expiry', options).mount('#card-expiry'); | ||
| 49 | }, | ||
| 50 | addListeners: function () { | ||
| 51 | var self = this; | ||
| 52 | |||
| 53 | // listen for submit button | ||
| 54 | if (document.getElementById('checkout-form') !== null) { | ||
| 55 | document | ||
| 56 | .getElementById('checkout-form') | ||
| 57 | .addEventListener('submit', self.onSubmit.bind(self)); | ||
| 58 | } | ||
| 59 | |||
| 60 | customCheckout.on('brand', function (event) { | ||
| 61 | console.log('brand: ' + JSON.stringify(event)); | ||
| 62 | |||
| 63 | var cardLogo = 'none'; | ||
| 64 | if (event.brand && event.brand !== 'unknown') { | ||
| 65 | var filePath = | ||
| 66 | 'https://cdn.na.bambora.com/downloads/images/cards/' + | ||
| 67 | event.brand + | ||
| 68 | '.svg'; | ||
| 69 | cardLogo = 'url(' + filePath + ')'; | ||
| 70 | } | ||
| 71 | document.getElementById('card-number').style.backgroundImage = cardLogo; | ||
| 72 | |||
| 73 | |||
| 74 | }); | ||
| 75 | |||
| 76 | customCheckout.on('blur', function (event) { | ||
| 77 | console.log('blur: ' + JSON.stringify(event)); | ||
| 78 | }); | ||
| 79 | |||
| 80 | customCheckout.on('focus', function (event) { | ||
| 81 | console.log('focus: ' + JSON.stringify(event)); | ||
| 82 | }); | ||
| 83 | |||
| 84 | customCheckout.on('empty', function (event) { | ||
| 85 | console.log('empty: ' + JSON.stringify(event)); | ||
| 86 | |||
| 87 | if (event.empty) { | ||
| 88 | if (event.field === 'card-number') { | ||
| 89 | isCardNumberComplete = false; | ||
| 90 | } else if (event.field === 'cvv') { | ||
| 91 | isCVVComplete = false; | ||
| 92 | } else if (event.field === 'expiry') { | ||
| 93 | isExpiryComplete = false; | ||
| 94 | } | ||
| 95 | self.setPayButton(false); | ||
| 96 | } | ||
| 97 | }); | ||
| 98 | |||
| 99 | var required = document.getElementsByClassName('required'); | ||
| 100 | |||
| 101 | customCheckout.on('complete', function (event) { | ||
| 102 | console.log('complete: ' + JSON.stringify(event)); | ||
| 103 | |||
| 104 | if (event.field === 'card-number') { | ||
| 105 | isCardNumberComplete = true; | ||
| 106 | self.hideErrorForId('card-number'); | ||
| 107 | } else if (event.field === 'cvv') { | ||
| 108 | isCVVComplete = true; | ||
| 109 | self.hideErrorForId('card-cvv'); | ||
| 110 | } else if (event.field === 'expiry') { | ||
| 111 | isExpiryComplete = true; | ||
| 112 | self.hideErrorForId('card-expiry'); | ||
| 113 | } | ||
| 114 | |||
| 115 | self.setPayButton( | ||
| 116 | isCardNumberComplete && isCVVComplete && isExpiryComplete | ||
| 117 | ); | ||
| 118 | }); | ||
| 119 | |||
| 120 | customCheckout.on('error', function (event) { | ||
| 121 | console.log('error: ' + JSON.stringify(event)); | ||
| 122 | |||
| 123 | if (event.field === 'card-number') { | ||
| 124 | isCardNumberComplete = false; | ||
| 125 | self.showErrorForId('card-number', event.message); | ||
| 126 | } else if (event.field === 'cvv') { | ||
| 127 | isCVVComplete = false; | ||
| 128 | self.showErrorForId('card-cvv', event.message); | ||
| 129 | } else if (event.field === 'expiry') { | ||
| 130 | isExpiryComplete = false; | ||
| 131 | self.showErrorForId('card-expiry', event.message); | ||
| 132 | } | ||
| 133 | self.setPayButton(false); | ||
| 134 | }); | ||
| 135 | }, | ||
| 136 | onSubmit: function (event) { | ||
| 137 | var self = this; | ||
| 138 | event.preventDefault(); | ||
| 139 | var non_valid = false; | ||
| 140 | $('.required').css("border-color", "#a4a5a8"); | ||
| 141 | $('.non-valid').remove(); | ||
| 142 | if ($('#policy_holders_name').val() ==""){ | ||
| 143 | $('#policy_holders_name').css("border-color", "red"); | ||
| 144 | $('[data-name=policy_holders_name]').append('<div class="non-valid">Required</div>') | ||
| 145 | non_valid = true; | ||
| 146 | } | ||
| 147 | if ($('#policy_holders_name').val() !="" && !$('#policy_holders_name').val().match(/^[A-Za-z0-9 ]+$/)){ | ||
| 148 | $('#policy_holders_name').css("border-color", "red"); | ||
| 149 | $('[data-name=policy_holders_name]').append('<div class="non-valid">Policyholder\'s name should not contain special characters.</div>') | ||
| 150 | non_valid = true; | ||
| 151 | } | ||
| 152 | |||
| 153 | if ($('#card_holder').val() ==""){ | ||
| 154 | $('#card_holder').css("border-color", "red"); | ||
| 155 | $('[data-name=card_holder]').append('<div class="non-valid">Required</div>') | ||
| 156 | non_valid = true; | ||
| 157 | } | ||
| 158 | var policy_number = $('#policy_number').val(); | ||
| 159 | if (policy_number =="" || policy_number.length != 11 || !policy_number.match(/^[a-zA-Z]{1}[0-9]{10}/s) || !policy_number.match(/^[\w&.-]+$/)){ | ||
| 160 | $('#policy_number').css("border-color", "red"); | ||
| 161 | if( policy_number !="" && policy_number.length != 11){ | ||
| 162 | $('[data-name=policy_number]').append('<div class="non-valid">Policy numbers are 11 digits.</div>'); | ||
| 163 | }else if(policy_number !="" && !policy_number.match(/^[a-zA-Z]{1}[0-9]{10}/s)){ | ||
| 164 | $('[data-name=policy_number]').append('<div class="non-valid">Policy number begins with a letter followed by a series of numbers.</div>'); | ||
| 165 | }else if(policy_number !="" && !policy_number.match(/^[\w&.-]+$/)){ | ||
| 166 | $('[data-name=policy_number]').append('<div class="non-valid">Policy number should not contain special characters.</div>'); | ||
| 167 | }else{ | ||
| 168 | $('[data-name=policy_number]').append('<div class="non-valid">Required</div>'); | ||
| 169 | } | ||
| 170 | non_valid = true; | ||
| 171 | } | ||
| 172 | |||
| 173 | if ($('#payment_amount').val() ==""){ | ||
| 174 | $('#payment_amount').css("border-color", "red"); | ||
| 175 | $('[data-name=payment_amount]').append('<div class="non-valid">Required</div>') | ||
| 176 | non_valid = true; | ||
| 177 | } | ||
| 178 | |||
| 179 | if ($('#user_phone').val() ==""){ | ||
| 180 | $('#user_phone').css("border-color", "red"); | ||
| 181 | $('[data-name=user_phone]').append('<div class="non-valid">Required</div>'); | ||
| 182 | non_valid = true; | ||
| 183 | } | ||
| 184 | |||
| 185 | if ($('#user_phone').val() !=""){ | ||
| 186 | var phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/; | ||
| 187 | if(!phoneno.test($('#user_phone').val())){ | ||
| 188 | $('[data-name=user_phone]').append('<div class="non-valid">Please enter a valid telephone number.</div>'); | ||
| 189 | non_valid = true; | ||
| 190 | } | ||
| 191 | } | ||
| 192 | |||
| 193 | |||
| 194 | |||
| 195 | if ($('#user_email').val() !=""){ | ||
| 196 | var re = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/; | ||
| 197 | if(!re.test($('#user_email').val())){ | ||
| 198 | $('#user_email').css("border-color", "red"); | ||
| 199 | $('[data-name=user_email]').append('<div class="non-valid">Please enter a valid email address.</div>') | ||
| 200 | non_valid = true; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | if (non_valid){ | ||
| 204 | $('html, body').animate({ | ||
| 205 | scrollTop: $('.non-valid:visible:first').offset().top - 180 | ||
| 206 | }, 1000); | ||
| 207 | } | ||
| 208 | if (!non_valid){ | ||
| 209 | |||
| 210 | console.log('checkout.onSubmit()'); | ||
| 211 | $('.overlay').css('display','flex'); | ||
| 212 | |||
| 213 | self.setPayButton(false); | ||
| 214 | self.toggleProcessingScreen(); | ||
| 215 | $.ajax({ | ||
| 216 | type: 'POST', | ||
| 217 | url: '/wp-admin/admin-ajax.php', | ||
| 218 | dataType: 'json', | ||
| 219 | data: { | ||
| 220 | action: 'submited', | ||
| 221 | policy_holders_name: $('#policy_holders_name').val(), | ||
| 222 | card_holder: $('#card_holder').val(), | ||
| 223 | policy_number: $('#policy_number').val(), | ||
| 224 | payment_amount: $('#payment_amount').val(), | ||
| 225 | user_phone: $('#user_phone').val(), | ||
| 226 | user_email: $('#user_email').val(), | ||
| 227 | }, | ||
| 228 | success: function(data) { | ||
| 229 | console.log(data.data.ID); | ||
| 230 | $('#postId').val(data.data.ID); | ||
| 231 | |||
| 232 | var callback = function (result) { | ||
| 233 | console.log('token result : ' + JSON.stringify(result)); | ||
| 234 | if (result.error) { | ||
| 235 | self.processTokenError(result.error); | ||
| 236 | } else { | ||
| 237 | self.processTokenSuccess(result.token); | ||
| 238 | } | ||
| 239 | }; | ||
| 240 | |||
| 241 | console.log('checkout.createToken()'); | ||
| 242 | customCheckout.createToken(callback); | ||
| 243 | |||
| 244 | }, | ||
| 245 | error: function(err) { | ||
| 246 | console.error(err); | ||
| 247 | } | ||
| 248 | }) | ||
| 249 | } | ||
| 250 | }, | ||
| 251 | hideErrorForId: function (id) { | ||
| 252 | console.log('hideErrorForId: ' + id); | ||
| 253 | |||
| 254 | var element = document.getElementById(id); | ||
| 255 | |||
| 256 | if (element !== null) { | ||
| 257 | var errorElement = document.getElementById(id + '-error'); | ||
| 258 | if (errorElement !== null) { | ||
| 259 | errorElement.innerHTML = ''; | ||
| 260 | } | ||
| 261 | |||
| 262 | var bootStrapParent = document.getElementById(id + '-bootstrap'); | ||
| 263 | if (bootStrapParent !== null) { | ||
| 264 | bootStrapParent.classList.remove('has-error'); | ||
| 265 | bootStrapParent.classList.add('has-success'); | ||
| 266 | } | ||
| 267 | } else { | ||
| 268 | console.log('showErrorForId: Could not find ' + id); | ||
| 269 | } | ||
| 270 | }, | ||
| 271 | showErrorForId: function (id, message) { | ||
| 272 | console.log('showErrorForId: ' + id + ' ' + message); | ||
| 273 | |||
| 274 | var element = document.getElementById(id); | ||
| 275 | |||
| 276 | if (element !== null) { | ||
| 277 | var errorElement = document.getElementById(id + '-error'); | ||
| 278 | if (errorElement !== null) { | ||
| 279 | errorElement.innerHTML = message; | ||
| 280 | } | ||
| 281 | |||
| 282 | var bootStrapParent = document.getElementById(id + '-bootstrap'); | ||
| 283 | if (bootStrapParent !== null) { | ||
| 284 | bootStrapParent.classList.add('has-error'); | ||
| 285 | bootStrapParent.classList.remove('has-success'); | ||
| 286 | } | ||
| 287 | } else { | ||
| 288 | console.log('showErrorForId: Could not find ' + id); | ||
| 289 | } | ||
| 290 | }, | ||
| 291 | setPayButton: function (enabled) { | ||
| 292 | console.log('checkout.setPayButton() disabled: ' + !enabled); | ||
| 293 | |||
| 294 | var payButton = document.getElementById('pay-button'); | ||
| 295 | if (enabled) { | ||
| 296 | payButton.disabled = false; | ||
| 297 | payButton.className = 'btn btn-primary'; | ||
| 298 | } else { | ||
| 299 | payButton.disabled = true; | ||
| 300 | payButton.className = 'btn btn-primary disabled'; | ||
| 301 | } | ||
| 302 | }, | ||
| 303 | toggleProcessingScreen: function () { | ||
| 304 | var processingScreen = document.getElementById('processing-screen'); | ||
| 305 | if (processingScreen) { | ||
| 306 | processingScreen.classList.toggle('visible'); | ||
| 307 | } | ||
| 308 | }, | ||
| 309 | showErrorFeedback: function (message) { | ||
| 310 | var xMark = '\u2718'; | ||
| 311 | this.feedback = document.getElementById('feedback'); | ||
| 312 | this.feedback.innerHTML = xMark + ' ' + message; | ||
| 313 | this.feedback.classList.add('error'); | ||
| 314 | }, | ||
| 315 | showSuccessFeedback: function (message) { | ||
| 316 | var checkMark = '\u2714'; | ||
| 317 | this.feedback = document.getElementById('feedback'); | ||
| 318 | this.feedback.innerHTML = checkMark + ' ' + message; | ||
| 319 | this.feedback.classList.add('success'); | ||
| 320 | }, | ||
| 321 | processTokenError: function (error) { | ||
| 322 | error = JSON.stringify(error, undefined, 2); | ||
| 323 | console.log('processTokenError: ' + error); | ||
| 324 | |||
| 325 | this.showErrorFeedback( | ||
| 326 | 'Error creating token: </br>' + JSON.stringify(error, null, 4) | ||
| 327 | ); | ||
| 328 | this.setPayButton(true); | ||
| 329 | this.toggleProcessingScreen(); | ||
| 330 | }, | ||
| 331 | logTimeoutErrorOnAjax: function (token) { | ||
| 332 | console.log('logErrorOnAjax: token' + token); | ||
| 333 | var formdata = $('#checkout-form').serialize(); | ||
| 334 | |||
| 335 | |||
| 336 | }, | ||
| 337 | |||
| 338 | processTokenSuccess: function (token) { | ||
| 339 | |||
| 340 | |||
| 341 | console.log('processTokenSuccess: ' + token); | ||
| 342 | |||
| 343 | this.showSuccessFeedback('Success! Created token: ' + token); | ||
| 344 | this.setPayButton(false); | ||
| 345 | this.toggleProcessingScreen(); | ||
| 346 | |||
| 347 | var that = this; | ||
| 348 | |||
| 349 | $('#feedback').empty(); | ||
| 350 | |||
| 351 | |||
| 352 | $.ajax({ | ||
| 353 | type: 'POST', | ||
| 354 | async: false, | ||
| 355 | dataType: "json", | ||
| 356 | timeout: 3000, | ||
| 357 | url: 'https://api.na.bambora.com/v1/payments', | ||
| 358 | contentType: 'application/json', | ||
| 359 | data: JSON.stringify({ | ||
| 360 | 'token': { 'code': token, 'name': $('#card_holder').val(), 'complete': true }, | ||
| 361 | 'amount': $('#payment_amount').val(), 'payment_method': 'token', 'custom': {'ref1': $('#policy_number').val(), 'ref2': $('#policy_holders_name').val(), 'ref3': $('#postId').val() } | ||
| 362 | }), | ||
| 363 | beforeSend: function (xhr) { | ||
| 364 | |||
| 365 | xhr.setRequestHeader("Authorization", "Passcode " + btoa(bambora.merchant_id + ":" + bambora.api_id)); | ||
| 366 | }, | ||
| 367 | success: function (data) { | ||
| 368 | console.log(data); | ||
| 369 | if (data && typeof data.message !== 'undefined') { | ||
| 370 | if (data.message == 'Approved') { | ||
| 371 | |||
| 372 | var today = new Date(); | ||
| 373 | var dd = String(today.getDate()).padStart(2, '0'); | ||
| 374 | var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0! | ||
| 375 | var yyyy = today.getFullYear(); | ||
| 376 | var time = today.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true }) | ||
| 377 | |||
| 378 | const formatter = new Intl.NumberFormat('en-US', { | ||
| 379 | style: 'currency', | ||
| 380 | currency: 'USD', | ||
| 381 | |||
| 382 | }); | ||
| 383 | |||
| 384 | $('#payment_confirmed').val('true'); | ||
| 385 | $('#order_number').val(data.order_number); | ||
| 386 | $('#transId').val(data.id); | ||
| 387 | $('#bambora').html('<br><br><h3>Payment Completed</h3>'); | ||
| 388 | //$('#complete').attr('style',"display:inline-block !important;"); | ||
| 389 | $('#feedback').hide(); | ||
| 390 | $('#complete').click(); | ||
| 391 | $('<div id="approve"></div>').insertAfter('.wpcf7'); | ||
| 392 | $('#approve').append('<div class="container">'+ | ||
| 393 | '<div class="row"><div class="col-md-12 col-lg-12 "><h2>Your transaction has been approved</h2></div></div>'+ | ||
| 394 | '<div class="row"><div class="col-md-12 col-lg-6 bold">Policyholder’s Name</div><div class="col-md-12 col-lg-6 ">'+$('#policy_holders_name').val()+'</div></div>'+ | ||
| 395 | '<div class="row"><div class="col-md-12 col-lg-6 bold">Policy Number</div><div class="col-md-12 col-lg-6 ">'+$('#policy_number').val()+'</div></div>'+ | ||
| 396 | '<div class="row"><div class="col-md-12 col-lg-6 bold">Authorization Number</div><div class="col-md-12 col-lg-6 ">'+data.order_number+'</div></div>'+ | ||
| 397 | '<div class="row"><div class="col-md-12 col-lg-6 bold">Amount Paid</div><div class="col-md-12 col-lg-6 ">'+formatter.format($('#payment_amount').val())+'</div></div>'+ | ||
| 398 | '<div class="row"><div class="col-md-12 col-lg-6 bold">Date</div><div class="col-md-12 col-lg-6 ">'+ yyyy + '-' + mm + '-' + dd+' '+time+'</div></div>'+ | ||
| 399 | '</div>'); | ||
| 400 | $('html, body').animate({ | ||
| 401 | scrollTop: $('#approve').offset().top - 180 | ||
| 402 | }, 100); | ||
| 403 | |||
| 404 | |||
| 405 | } else { | ||
| 406 | $('#feedback').html('<span id="alert"> Card Not Approved.</span>'); | ||
| 407 | $('html, body').animate({ | ||
| 408 | scrollTop: $('#alert').offset().top - 180 | ||
| 409 | }, 100); | ||
| 410 | } | ||
| 411 | |||
| 412 | } | ||
| 413 | }, | ||
| 414 | error: function (request, textstatus) { | ||
| 415 | |||
| 416 | if (textstatus === "timeout") { | ||
| 417 | that.processTokenSuccess(token); | ||
| 418 | } else { | ||
| 419 | var declined_message = "<p>Your transaction has been declined. Please try again later. If the problem persists please call our billing department at 1-844-267-7577.</p>"; | ||
| 420 | |||
| 421 | $('.overlay').css('display','none'); | ||
| 422 | that.setPayButton(true); | ||
| 423 | if (request && typeof request.responseJSON !== 'undefined') { | ||
| 424 | $('#feedback').addClass('error'); | ||
| 425 | if (request.responseJSON.message == 'DECLINE') { | ||
| 426 | $('#feedback').html('<span id="alert"> Card Declined.</span>'+declined_message); | ||
| 427 | } else if (request.responseJSON.message == 'Invalid Card No') { | ||
| 428 | $('#feedback').html('<span id="alert"> Invalid Card No.</span>'+declined_message); | ||
| 429 | } else { | ||
| 430 | $('#feedback').html('<span id="alert">' + request.responseJSON.message + '</span>'+declined_message); | ||
| 431 | } | ||
| 432 | } | ||
| 433 | } | ||
| 434 | |||
| 435 | $.ajax({ | ||
| 436 | type: 'POST', | ||
| 437 | url: '/wp-admin/admin-ajax.php', | ||
| 438 | dataType: 'json', | ||
| 439 | data: { | ||
| 440 | action: 'submit_declined', | ||
| 441 | policy_holders_name: $('#policy_holders_name').val(), | ||
| 442 | card_holder: $('#card_holder').val(), | ||
| 443 | policy_number: $('#policy_number').val(), | ||
| 444 | payment_amount: $('#payment_amount').val(), | ||
| 445 | user_phone: $('#user_phone').val(), | ||
| 446 | user_email: $('#user_email').val(), | ||
| 447 | postId: $('#postId').val(), | ||
| 448 | response_message: request.responseJSON.message, | ||
| 449 | }, | ||
| 450 | success: function(res) { | ||
| 451 | $('#postId').val(); | ||
| 452 | }, | ||
| 453 | error: function(err) { | ||
| 454 | console.error(err); | ||
| 455 | } | ||
| 456 | }) | ||
| 457 | } | ||
| 458 | |||
| 459 | }); | ||
| 460 | |||
| 461 | |||
| 462 | }, | ||
| 463 | }; | ||
| 464 | |||
| 465 | customCheckoutController.init(); | ||
| 466 | } | ||
| 467 | |||
| 468 | }); | ||
| 469 | |||
| 470 | jQuery(document).ready( function($) { | ||
| 471 | |||
| 472 | |||
| 473 | |||
| 474 | var dataTable = $('#payments').DataTable( {dom: 'Bfrtip', | ||
| 475 | buttons: [ | ||
| 476 | 'excelHtml5', | ||
| 477 | 'csvHtml5', | ||
| 478 | ], | ||
| 479 | initComplete: function (settings, json) { | ||
| 480 | console.log('draw') | ||
| 481 | $('.status-dropdown').appendTo('#payments_filter'); | ||
| 482 | } | ||
| 483 | }); | ||
| 484 | |||
| 485 | $('.status-dropdown').on('change', function(e){ | ||
| 486 | var status = $(this).val(); | ||
| 487 | $('.status-dropdown').val(status) | ||
| 488 | |||
| 489 | dataTable.column(1).search(status).draw(); | ||
| 490 | }); | ||
| 491 | |||
| 492 | |||
| 493 | |||
| 494 | document.addEventListener( 'wpcf7mailsent', function( event ) { | ||
| 495 | if(event.detail.contactFormId == 65254) { | ||
| 496 | $('.wpcf7').hide(); | ||
| 497 | } | ||
| 498 | }, false ); | ||
| 499 | }); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | require.config({ | ||
| 2 | "baseUrl": "/wp-content/themes/commonwell-corp/js/", | ||
| 3 | "paths": { | ||
| 4 | "jquery": "../components/jquery/jquery.min", | ||
| 5 | "hoverIntent" : "../components/superfish/dist/js/hoverIntent", | ||
| 6 | "superfish": "../components/superfish/dist/js/superfish.min", | ||
| 7 | "fittext": "vendor/jquery.fittext", | ||
| 8 | "superclick": "vendor/superclick", | ||
| 9 | "featherlight": "vendor/featherlight.min" | ||
| 10 | }, | ||
| 11 | "shim": { | ||
| 12 | jquery: { | ||
| 13 | exports: 'jquery' | ||
| 14 | }, | ||
| 15 | hoverIntent: { | ||
| 16 | deps: ['jquery'] | ||
| 17 | }, | ||
| 18 | superfish: { | ||
| 19 | deps: ['jquery'] | ||
| 20 | }, | ||
| 21 | fittext: { | ||
| 22 | deps: ['jquery'] | ||
| 23 | }, | ||
| 24 | superclick: { | ||
| 25 | deps: ['jquery'] | ||
| 26 | }, | ||
| 27 | featherlight: { | ||
| 28 | deps: ['jquery'] | ||
| 29 | } | ||
| 30 | } | ||
| 31 | }); | ||
| 32 | |||
| 33 | require(['jquery', 'src/menu', 'fittext', 'src/sizing', 'src/care_form', 'src/facebook_extensible', 'src/canada-post'], function ($, Menu) { | ||
| 34 | $.fn.extend({ | ||
| 35 | limiter: function (max, counter) { | ||
| 36 | $(this).on("keyup focus", function () { | ||
| 37 | var self = this; | ||
| 38 | var words = (self.value.length > 0) ? ($.trim(self.value).replace(/['";:,.?¿\-!¡]+/g, '').match(/\S+/g)).length : 0; | ||
| 39 | if (typeof(counter) != 'undefined') { | ||
| 40 | counter.html(max - words); | ||
| 41 | } | ||
| 42 | }); | ||
| 43 | } | ||
| 44 | }); | ||
| 45 | |||
| 46 | function noscroll(event) { | ||
| 47 | event.preventDefault(); | ||
| 48 | } | ||
| 49 | |||
| 50 | var App = { | ||
| 51 | menu: null, | ||
| 52 | init: function () { | ||
| 53 | this.menu = new Menu($('#primary-nav')); | ||
| 54 | this.menu.setup(); | ||
| 55 | $("#area").limiter(250, $("#chars")); | ||
| 56 | $('.mobile-menu-btn').on('click', function (event) { | ||
| 57 | event.preventDefault(); | ||
| 58 | $('body').toggleClass('menu-on'); | ||
| 59 | console.log('menu on'); | ||
| 60 | // lock scrolling when nav is open | ||
| 61 | // if ($('body').hasClass('menu-on')) { | ||
| 62 | // $(document).on('touchmove', noscroll); | ||
| 63 | // } else { | ||
| 64 | // $(document).off('touchmove', noscroll); | ||
| 65 | // } | ||
| 66 | return false; | ||
| 67 | }); | ||
| 68 | |||
| 69 | // Change --- word to please select one | ||
| 70 | $('form .form-control').find('select[name="community"] option').eq(0).html('Please select one'); | ||
| 71 | $('form .form-control').find('select[name="referral"] option').eq(0).html('Please select one'); | ||
| 72 | |||
| 73 | } | ||
| 74 | }; | ||
| 75 | |||
| 76 | $(document).ready(function() { | ||
| 77 | App.init(); | ||
| 78 | |||
| 79 | // we should use RAF for smooth moving | ||
| 80 | window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.oRequestAnimationFrame; | ||
| 81 | function createMapCloseBtn() { | ||
| 82 | var $map = $('#map'); | ||
| 83 | $map.hide(); | ||
| 84 | // inject the close button | ||
| 85 | $map.append('<a href="#" class="close-map"></a>'); | ||
| 86 | // hide the map when its clicked | ||
| 87 | $map.find('.close-map').on('click', function (event) { | ||
| 88 | event.preventDefault(); | ||
| 89 | $map.hide(); | ||
| 90 | return false; | ||
| 91 | }); | ||
| 92 | // show the map when markers are clicked on | ||
| 93 | $('#sl_div').find('.marker').on('click', function () { | ||
| 94 | $map.show(); | ||
| 95 | }); | ||
| 96 | } | ||
| 97 | |||
| 98 | function setMapStart() { | ||
| 99 | // are we mobile? | ||
| 100 | var mobile = (window.innerWidth < 960); | ||
| 101 | // different lefts for different screens | ||
| 102 | var mapLeft = mobile ? '53px' : '8px'; | ||
| 103 | // when should the map stop moving up? | ||
| 104 | var minTop = $('#other-header').outerHeight() + $('#primary-nav').outerHeight() + 40; | ||
| 105 | if(window.isBrokerPage) { | ||
| 106 | minTop = (mobile) ? 50 : 0; | ||
| 107 | } | ||
| 108 | var is_safari = navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0; | ||
| 109 | //if(is_safari) { | ||
| 110 | var smallMobile = (window.innerWidth < 600); | ||
| 111 | var mapWidth = smallMobile ? 0 : $('#map').outerWidth() + 8; | ||
| 112 | $('#map').css({ | ||
| 113 | top: minTop, | ||
| 114 | left: mapLeft, | ||
| 115 | opacity: 1, | ||
| 116 | zIndex: 1, | ||
| 117 | marginLeft: -mapWidth | ||
| 118 | }); | ||
| 119 | |||
| 120 | $(window).resize(function() { | ||
| 121 | var smallMobile = (window.innerWidth < 600); | ||
| 122 | var mapWidth = smallMobile ? 0 : $('#map').outerWidth() + 8; | ||
| 123 | var mapLeft = smallMobile ? '53px' : '8px'; | ||
| 124 | |||
| 125 | $('#map').css({ | ||
| 126 | left: mapLeft, | ||
| 127 | marginLeft: -mapWidth | ||
| 128 | }); | ||
| 129 | }).resize(); | ||
| 130 | //} else { | ||
| 131 | // // if the screen is mobile, and we havent injected the button | ||
| 132 | // $('#map').css({ | ||
| 133 | // top: minTop, | ||
| 134 | // left: mapLeft, | ||
| 135 | // opacity: 1, | ||
| 136 | // zIndex: 1 | ||
| 137 | // }); | ||
| 138 | //} | ||
| 139 | |||
| 140 | if ($('.close-map').length === 0) { | ||
| 141 | createMapCloseBtn(); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | // scroller function to move the map | ||
| 146 | function moveMap() { | ||
| 147 | var mobile = (window.innerWidth < 960); | ||
| 148 | var pos = (mobile) ? $(document).scrollTop() + 200 : $(document).scrollTop(); | ||
| 149 | var minTop = $('#other-header').outerHeight() + $('#primary-nav').outerHeight() + 20; | ||
| 150 | if(window.isBrokerPage) { | ||
| 151 | minTop = 0; | ||
| 152 | pos = (mobile) ? $(document).scrollTop() + 50 : $(document).scrollTop(); | ||
| 153 | } | ||
| 154 | |||
| 155 | if (pos > minTop) { | ||
| 156 | $('#map').css('top', pos); | ||
| 157 | // call this function with RAF | ||
| 158 | requestAnimationFrame(moveMap); | ||
| 159 | } else { | ||
| 160 | $('#map').css('top', minTop); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | // use a dom ready function for these events | ||
| 165 | $(function () { | ||
| 166 | var searchCat = $('#sl_div').find('#cat').attr('textvalue'); | ||
| 167 | if(searchCat && searchCat != 'broker') { | ||
| 168 | $('#div_nameSearch #nameSearch').attr('placeholder', 'Company Name'); | ||
| 169 | } | ||
| 170 | |||
| 171 | // when the search is clicked | ||
| 172 | // and if the screensize is correct | ||
| 173 | // move the map under the nav on the left side | ||
| 174 | $('#addressSubmit').on('click', function () { | ||
| 175 | // timeout for the delayed map loading | ||
| 176 | setTimeout(function () { | ||
| 177 | setMapStart(); | ||
| 178 | }, 1000); | ||
| 179 | // feebback to let people know that the form is actually working | ||
| 180 | //$('#address_search').append('<p id="searching-feedback">Searching...</p>'); | ||
| 181 | $(this).attr('value', 'Searching...'); | ||
| 182 | }); | ||
| 183 | // used to avoid multiple listeners | ||
| 184 | var scrollListener = false; | ||
| 185 | // this event is trigger whenever the map is updated according to | ||
| 186 | // the slp.js file in the store-locator-le plugin | ||
| 187 | $('#map_sidebar').on('contentchanged', function () { | ||
| 188 | //$('#searching-feedback').remove(); | ||
| 189 | $('#addressSubmit').attr('value', 'Search'); | ||
| 190 | |||
| 191 | setMapStart(); | ||
| 192 | if (!scrollListener) { | ||
| 193 | $(window).scroll(function () { | ||
| 194 | requestAnimationFrame(moveMap); | ||
| 195 | }); | ||
| 196 | scrollListener = true; | ||
| 197 | } | ||
| 198 | |||
| 199 | // Check if the store has site url | ||
| 200 | var url = $(this).parent().find('.slp_result_website > a').attr('href'); | ||
| 201 | if(url === undefined) { | ||
| 202 | $('.results_entry').find('.results_row_top .location_name').css('color', '#706f73'); | ||
| 203 | } | ||
| 204 | |||
| 205 | //$(this).parent().find('.results_row_top').click(function() { | ||
| 206 | // var companyName = $(this).find('.location_name').text(); | ||
| 207 | // var hasURL = $(this).find('.storelocatorlink'); | ||
| 208 | // if(hasURL) { | ||
| 209 | // ga('send', 'event', 'broker', 'click', companyName); | ||
| 210 | // } | ||
| 211 | //}); | ||
| 212 | }); | ||
| 213 | }); | ||
| 214 | }); | ||
| 215 | |||
| 216 | |||
| 217 | }); |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
| 1 | jQuery(document).ready(function($) { | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | var term03 = $(".wheel-03 .term03"); | ||
| 6 | var term04 = $(".wheel-03 .term04"); | ||
| 7 | var term05 = $(".wheel-03 .term05"); | ||
| 8 | var term06 = $(".wheel-03 .term06"); | ||
| 9 | var term07 = $(".wheel-03 .term07"); | ||
| 10 | |||
| 11 | var stepFrame = 5; | ||
| 12 | |||
| 13 | tl03 = new TimelineLite(); | ||
| 14 | tl03 | ||
| 15 | .to(term03, stepFrame, { | ||
| 16 | css: { className: "term term02" }, | ||
| 17 | attr: { y: "-=50" }, | ||
| 18 | ease: Linear.easeNone | ||
| 19 | }) | ||
| 20 | .to(term03, stepFrame, { | ||
| 21 | css: { className: "term term01" }, | ||
| 22 | attr: { y: "-=50" }, | ||
| 23 | ease: Linear.easeNone | ||
| 24 | }) | ||
| 25 | .to(term03, stepFrame, { | ||
| 26 | css: { className: "term term00" }, | ||
| 27 | attr: { y: "-=50" }, | ||
| 28 | ease: Linear.easeNone | ||
| 29 | }); | ||
| 30 | |||
| 31 | tl04 = new TimelineLite(); | ||
| 32 | tl04 | ||
| 33 | .to(term04, stepFrame, { | ||
| 34 | css: { className: "term term03" }, | ||
| 35 | attr: { y: "-=50" }, | ||
| 36 | ease: Linear.easeNone | ||
| 37 | }) | ||
| 38 | .to(term04, stepFrame, { | ||
| 39 | css: { className: "term term02" }, | ||
| 40 | attr: { y: "-=50" }, | ||
| 41 | ease: Linear.easeNone | ||
| 42 | }) | ||
| 43 | .to(term04, stepFrame, { | ||
| 44 | css: { className: "term term01" }, | ||
| 45 | attr: { y: "-=50" }, | ||
| 46 | ease: Linear.easeNone | ||
| 47 | }) | ||
| 48 | .to(term04, stepFrame, { | ||
| 49 | css: { className: "term term00" }, | ||
| 50 | attr: { y: "-=50" }, | ||
| 51 | ease: Linear.easeNone | ||
| 52 | }); | ||
| 53 | |||
| 54 | tl05 = new TimelineLite(); | ||
| 55 | tl05 | ||
| 56 | .to(term05, stepFrame, { | ||
| 57 | css: { className: "term term04" }, | ||
| 58 | attr: { y: "-=50" }, | ||
| 59 | ease: Linear.easeNone | ||
| 60 | }) | ||
| 61 | .to(term05, stepFrame, { | ||
| 62 | css: { className: "term term03" }, | ||
| 63 | attr: { y: "-=50" }, | ||
| 64 | ease: Linear.easeNone | ||
| 65 | }) | ||
| 66 | .to(term05, stepFrame, { | ||
| 67 | css: { className: "term term02" }, | ||
| 68 | attr: { y: "-=50" }, | ||
| 69 | ease: Linear.easeNone | ||
| 70 | }) | ||
| 71 | .to(term05, stepFrame, { | ||
| 72 | css: { className: "term term01" }, | ||
| 73 | attr: { y: "-=50" }, | ||
| 74 | ease: Linear.easeNone | ||
| 75 | }) | ||
| 76 | ; | ||
| 77 | |||
| 78 | tl06 = new TimelineLite(); | ||
| 79 | tl06 | ||
| 80 | .to(term06, stepFrame, { | ||
| 81 | css: { className: "term term05" }, | ||
| 82 | attr: { y: "-=50" }, | ||
| 83 | ease: Linear.easeNone | ||
| 84 | }) | ||
| 85 | .to(term06, stepFrame, { | ||
| 86 | css: { className: "term term04" }, | ||
| 87 | attr: { y: "-=50" }, | ||
| 88 | ease: Linear.easeNone | ||
| 89 | }) | ||
| 90 | .to(term06, stepFrame, { | ||
| 91 | css: { className: "term term03" }, | ||
| 92 | attr: { y: "-=50" }, | ||
| 93 | ease: Linear.easeNone | ||
| 94 | }) | ||
| 95 | .to(term06, stepFrame, { | ||
| 96 | css: { className: "term term02" }, | ||
| 97 | attr: { y: "-=50" }, | ||
| 98 | ease: Linear.easeNone | ||
| 99 | }) | ||
| 100 | ; | ||
| 101 | |||
| 102 | tl07 = new TimelineLite(); | ||
| 103 | tl07 | ||
| 104 | .to(term07, stepFrame, { | ||
| 105 | css: { className: "term term06" }, | ||
| 106 | attr: { y: "-=50" }, | ||
| 107 | ease: Linear.easeNone | ||
| 108 | }) | ||
| 109 | .to(term07, stepFrame, { | ||
| 110 | css: { className: "term term05" }, | ||
| 111 | attr: { y: "-=50" }, | ||
| 112 | ease: Linear.easeNone | ||
| 113 | }) | ||
| 114 | .to(term07, stepFrame, { | ||
| 115 | css: { className: "term term04" }, | ||
| 116 | attr: { y: "-=50" }, | ||
| 117 | ease: Linear.easeNone | ||
| 118 | }) | ||
| 119 | .to(term07, stepFrame, { | ||
| 120 | css: { className: "term term03" }, | ||
| 121 | attr: { y: "-=50" }, | ||
| 122 | ease: Linear.easeNone | ||
| 123 | }); | ||
| 124 | |||
| 125 | wheel03 = new TimelineMax({ repeat: 100, timeScale: 10, yoyo:true }); | ||
| 126 | |||
| 127 | wheel03.add(tl03, 0); | ||
| 128 | wheel03.add(tl04, 0); | ||
| 129 | wheel03.add(tl05, 0); | ||
| 130 | wheel03.add(tl06, 0); | ||
| 131 | wheel03.add(tl07, 0); | ||
| 132 | |||
| 133 | |||
| 134 | wheel03.pause(); | ||
| 135 | setInterval(myTimer, 1000); | ||
| 136 | |||
| 137 | function myTimer() { | ||
| 138 | // | ||
| 139 | if(!$('.full-screen').hasClass('paused')){ | ||
| 140 | wheel03.play(); | ||
| 141 | // | ||
| 142 | //$('canvas').remove(); | ||
| 143 | setTimeout(() => { | ||
| 144 | wheel03.pause(); | ||
| 145 | }, 500); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | TweenMax.to(wheel03, 0.1, { timeScale: 10, ease: Circ.easeOut }); | ||
| 150 | |||
| 151 | $(document).on('click', '.video-thumb', function(){ | ||
| 152 | $('.full-screen').hide(); | ||
| 153 | var video = document.getElementsByTagName('video')[0]; | ||
| 154 | var sources = video.getElementsByTagName('source'); | ||
| 155 | var track = video.getElementsByTagName('track'); | ||
| 156 | sources[0].src = $(this).data('video'); | ||
| 157 | track[0].src = $(this).data('cc'); | ||
| 158 | video.load(); | ||
| 159 | video.muted = false; | ||
| 160 | video.removeAttribute("loop"); | ||
| 161 | $('.play').hide(); | ||
| 162 | $('.pause').hide(); | ||
| 163 | $('.product-header-image').css('background-image','none').css('background-color','#000'); | ||
| 164 | $('#myVideo').css('position','relative').css('right','unset').css('min-width','unset').css('max-width','100vw').css('max-height','99.8%');; | ||
| 165 | video.setAttribute("controls","controls") | ||
| 166 | // if (video.requestFullscreen) { | ||
| 167 | // video.requestFullscreen(); | ||
| 168 | // } else if (video.msRequestFullscreen) { | ||
| 169 | // video.msRequestFullscreen(); | ||
| 170 | // } else if (video.mozRequestFullScreen) { | ||
| 171 | // video.mozRequestFullScreen(); | ||
| 172 | // } else if (video.webkitRequestFullscreen) { | ||
| 173 | // video.webkitRequestFullscreen(); | ||
| 174 | // } | ||
| 175 | |||
| 176 | }); | ||
| 177 | |||
| 178 | |||
| 179 | $(document).on('click', '.pause', function(){ | ||
| 180 | $('.full-screen').addClass('paused'); | ||
| 181 | $(this).hide(); | ||
| 182 | $('.play').show(); | ||
| 183 | var video = document.getElementsByTagName('video')[0]; | ||
| 184 | video.pause(); | ||
| 185 | wheel03.pause(); | ||
| 186 | |||
| 187 | }); | ||
| 188 | |||
| 189 | $(document).on('click', '.play', function(){ | ||
| 190 | $('.full-screen').removeClass('paused'); | ||
| 191 | $(this).hide(); | ||
| 192 | $('.pause').show(); | ||
| 193 | var video = document.getElementsByTagName('video')[0]; | ||
| 194 | video.play(); | ||
| 195 | wheel03.play(); | ||
| 196 | |||
| 197 | }); | ||
| 198 | |||
| 199 | $('.video-thumb-title').sameHeight(); | ||
| 200 | |||
| 201 | $(window).resize(function(){ | ||
| 202 | $('.video-thumb-title').css('height','unset'); | ||
| 203 | $('.video-thumb-title').sameHeight(); | ||
| 204 | }); | ||
| 205 | |||
| 206 | |||
| 207 | }); | ||
| 208 | |||
| 209 | (function(document, history, location) { | ||
| 210 | var HISTORY_SUPPORT = !!(history && history.pushState); | ||
| 211 | |||
| 212 | var anchorScrolls = { | ||
| 213 | ANCHOR_REGEX: /^#[^ ]+$/, | ||
| 214 | OFFSET_HEIGHT_PX: 150, | ||
| 215 | |||
| 216 | /** | ||
| 217 | * Establish events, and fix initial scroll position if a hash is provided. | ||
| 218 | */ | ||
| 219 | init: function() { | ||
| 220 | this.scrollToCurrent(); | ||
| 221 | window.addEventListener('hashchange', this.scrollToCurrent.bind(this)); | ||
| 222 | document.body.addEventListener('click', this.delegateAnchors.bind(this)); | ||
| 223 | }, | ||
| 224 | |||
| 225 | /** | ||
| 226 | * Return the offset amount to deduct from the normal scroll position. | ||
| 227 | * Modify as appropriate to allow for dynamic calculations | ||
| 228 | */ | ||
| 229 | getFixedOffset: function() { | ||
| 230 | return this.OFFSET_HEIGHT_PX; | ||
| 231 | }, | ||
| 232 | |||
| 233 | /** | ||
| 234 | * If the provided href is an anchor which resolves to an element on the | ||
| 235 | * page, scroll to it. | ||
| 236 | * @param {String} href | ||
| 237 | * @return {Boolean} - Was the href an anchor. | ||
| 238 | */ | ||
| 239 | scrollIfAnchor: function(href, pushToHistory) { | ||
| 240 | var match, rect, anchorOffset; | ||
| 241 | |||
| 242 | if(!this.ANCHOR_REGEX.test(href)) { | ||
| 243 | return false; | ||
| 244 | } | ||
| 245 | |||
| 246 | match = document.getElementById(href.slice(1)); | ||
| 247 | |||
| 248 | if(match) { | ||
| 249 | rect = match.getBoundingClientRect(); | ||
| 250 | anchorOffset = window.pageYOffset + rect.top - this.getFixedOffset(); | ||
| 251 | window.scrollTo(window.pageXOffset, anchorOffset); | ||
| 252 | |||
| 253 | // Add the state to history as-per normal anchor links | ||
| 254 | if(HISTORY_SUPPORT && pushToHistory) { | ||
| 255 | history.pushState({}, document.title, location.pathname + href); | ||
| 256 | } | ||
| 257 | } | ||
| 258 | |||
| 259 | return !!match; | ||
| 260 | }, | ||
| 261 | |||
| 262 | /** | ||
| 263 | * Attempt to scroll to the current location's hash. | ||
| 264 | */ | ||
| 265 | scrollToCurrent: function() { | ||
| 266 | this.scrollIfAnchor(window.location.hash); | ||
| 267 | }, | ||
| 268 | |||
| 269 | /** | ||
| 270 | * If the click event's target was an anchor, fix the scroll position. | ||
| 271 | */ | ||
| 272 | delegateAnchors: function(e) { | ||
| 273 | var elem = e.target; | ||
| 274 | |||
| 275 | if( | ||
| 276 | elem.nodeName === 'A' && | ||
| 277 | this.scrollIfAnchor(elem.getAttribute('href'), true) | ||
| 278 | ) { | ||
| 279 | e.preventDefault(); | ||
| 280 | } | ||
| 281 | } | ||
| 282 | }; | ||
| 283 | |||
| 284 | window.addEventListener( | ||
| 285 | 'DOMContentLoaded', anchorScrolls.init.bind(anchorScrolls) | ||
| 286 | ); | ||
| 287 | })(window.document, window.history, window.location); | ||
| 288 | |||
| 289 | |||
| 290 | |||
| 291 | (function( $ ) { | ||
| 292 | // the sameHeight functions makes all the selected elements of the same height | ||
| 293 | $.fn.sameHeight = function() { | ||
| 294 | var selector = this; | ||
| 295 | var heights = []; | ||
| 296 | |||
| 297 | // Save the heights of every element into an array | ||
| 298 | selector.each(function(){ | ||
| 299 | var height = $(this).height(); | ||
| 300 | heights.push(height); | ||
| 301 | }); | ||
| 302 | |||
| 303 | // Get the biggest height | ||
| 304 | var maxHeight = Math.max.apply(null, heights); | ||
| 305 | // Show in the console to verify | ||
| 306 | console.log(heights,maxHeight); | ||
| 307 | |||
| 308 | // Set the maxHeight to every selected element | ||
| 309 | selector.each(function(){ | ||
| 310 | $(this).height(maxHeight); | ||
| 311 | }); | ||
| 312 | }; | ||
| 313 | |||
| 314 | }( jQuery )); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | jQuery(document).ready( function($) { | ||
| 2 | |||
| 3 | // in case of bootstrap modal example: | ||
| 4 | $('.modal').on('shown.bs.modal', function () { | ||
| 5 | |||
| 6 | var documentScrollTop = $(document).scrollTop(); | ||
| 7 | $(document).on('scroll.noScroll', function() { | ||
| 8 | $(document).scrollTop(documentScrollTop); | ||
| 9 | return false; | ||
| 10 | }); | ||
| 11 | |||
| 12 | }).on('hidden.bs.modal', function() { | ||
| 13 | |||
| 14 | $(document).off('scroll.noScroll'); | ||
| 15 | |||
| 16 | }); | ||
| 17 | |||
| 18 | $('input').iCheck({ | ||
| 19 | checkboxClass: 'icheckbox_square-green', | ||
| 20 | radioClass: 'iradio_square-green', | ||
| 21 | increaseArea: '20%' // optional | ||
| 22 | }); | ||
| 23 | |||
| 24 | function scrollScripts() { | ||
| 25 | |||
| 26 | if(!jQuery('#content-wrap').hasClass('retract')) { | ||
| 27 | if(jQuery(window).scrollTop() >= 150) { | ||
| 28 | jQuery('#content-wrap').addClass('retract'); | ||
| 29 | jQuery('#page-header-seedit').addClass('retract'); | ||
| 30 | jQuery('#mySidenav').addClass('retract'); | ||
| 31 | jQuery('#page-header-part').addClass('retract'); | ||
| 32 | jQuery('#myTopnav').css('top', '40px'); | ||
| 33 | jQuery('#menu-seedit-main').css('margin-top', '15px'); | ||
| 34 | jQuery('.tag-line').hide(); | ||
| 35 | |||
| 36 | } | ||
| 37 | } else { | ||
| 38 | if(jQuery(window).scrollTop() < 170) { | ||
| 39 | jQuery('#content-wrap').removeClass('retract'); | ||
| 40 | jQuery('#page-header-seedit').removeClass('retract'); | ||
| 41 | jQuery('#mySidenav').removeClass('retract'); | ||
| 42 | jQuery('#page-header-part').removeClass('retract'); | ||
| 43 | jQuery('#menu-seedit-main').css('margin-top', '50px'); | ||
| 44 | jQuery('.tag-line').show(); | ||
| 45 | jQuery('#myTopnav').css('top', '100px'); | ||
| 46 | |||
| 47 | } | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | |||
| 52 | jQuery( ".rect" ).each(function( index ) { | ||
| 53 | |||
| 54 | var rec = $(this); | ||
| 55 | setTimeout(function() { | ||
| 56 | $(rec).css('visibility','visible'); | ||
| 57 | |||
| 58 | }, index * 500); | ||
| 59 | |||
| 60 | }); | ||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | $(document).on("click",".btn.story",function() { | ||
| 67 | $('.sub-header').show(); | ||
| 68 | $('.modal-title').show(); | ||
| 69 | $('.modal-thanks').hide(); | ||
| 70 | $('.form').children().show(); | ||
| 71 | $('.load').hide(); | ||
| 72 | $('[name="project_id"]').val($('[name="post_id"]').val()); | ||
| 73 | $('[name="post_date"]').val( $('#date').val()); | ||
| 74 | $('#exampleModalAddStory').modal('show'); | ||
| 75 | }); | ||
| 76 | $(document).on("click",".btn.photo",function() { | ||
| 77 | $('.sub-header').show(); | ||
| 78 | $('.modal-title').show(); | ||
| 79 | $('.modal-thanks').hide(); | ||
| 80 | $('.form').children().show(); | ||
| 81 | $('.load').hide(); | ||
| 82 | $('[name="project_id"]').val($('[name="post_id"]').val()); | ||
| 83 | $('[name="post_date"]').val( $('#date').val()); | ||
| 84 | $('#exampleModalAddPhoto').modal('show'); | ||
| 85 | }); | ||
| 86 | $(document).on("click",".btn.comment",function() { | ||
| 87 | $('.sub-header').show(); | ||
| 88 | $('.modal-title').show(); | ||
| 89 | $('.modal-thanks').hide(); | ||
| 90 | $('.form').children().show(); | ||
| 91 | $('.load').hide(); | ||
| 92 | $('[name="project_id"]').val($('[name="post_id"]').val()); | ||
| 93 | $('[name="post_date"]').val( $('#date').val()); | ||
| 94 | $('#exampleModalAddComment').modal('show'); | ||
| 95 | |||
| 96 | }); | ||
| 97 | |||
| 98 | $(document).on("click",".wpcf7-submit",function() { | ||
| 99 | $('.load').show(); | ||
| 100 | }); | ||
| 101 | |||
| 102 | document.addEventListener( 'wpcf7submit', function( event ) { | ||
| 103 | |||
| 104 | setTimeout(function(){ | ||
| 105 | if(jQuery('.wpcf7-not-valid').length > 0) { | ||
| 106 | jQuery('html,body').animate({scrollTop: jQuery('.wpcf7-not-valid').first().offset().top -150}, 'linear') | ||
| 107 | } | ||
| 108 | }, 1000); | ||
| 109 | |||
| 110 | setTimeout(function(){ | ||
| 111 | $('.load').hide(); | ||
| 112 | }, 1000); | ||
| 113 | |||
| 114 | }, false ); | ||
| 115 | |||
| 116 | document.addEventListener( 'wpcf7mailsent', function( event ) { | ||
| 117 | $('.load').hide(); | ||
| 118 | $('.sub-header').hide(); | ||
| 119 | $('.modal-title').hide(); | ||
| 120 | $('.form').children().hide(); | ||
| 121 | $('.modal-thanks').show(); | ||
| 122 | |||
| 123 | $('.wpcf7-response-output').show(); | ||
| 124 | if($('.modal.fade.in').length == 0) { | ||
| 125 | setTimeout(function(){ | ||
| 126 | $([document.documentElement, document.body]).animate({ | ||
| 127 | scrollTop: $('.wpcf7-response-output').offset().top - 150 | ||
| 128 | }, 2000); | ||
| 129 | }, 1000); | ||
| 130 | } | ||
| 131 | |||
| 132 | }); | ||
| 133 | |||
| 134 | $(".moreBox").slice(0, 3).show(); | ||
| 135 | if ($(".blogBox:hidden").length != 0) { | ||
| 136 | $("#loadMore").show(); | ||
| 137 | } | ||
| 138 | |||
| 139 | jQuery(document).on("click", "#loadMore", function(e) { | ||
| 140 | e.preventDefault(); | ||
| 141 | $(".moreBox:hidden").slice(0, 3).slideDown(); | ||
| 142 | if ($(".moreBox:hidden").length == 0) { | ||
| 143 | $("#loadMore").fadeOut('slow'); | ||
| 144 | } | ||
| 145 | }); | ||
| 146 | |||
| 147 | $(document).on("click",".btn.fb",function() { | ||
| 148 | window.open('http://facebook.com/sharer/sharer.php?u='+encodeURIComponent(window.location.href), '', 'left=0,top=0,width=650,height=420,personalbar=0,toolbar=0,scrollbars=0,resizable=0'); | ||
| 149 | }); | ||
| 150 | |||
| 151 | jQuery(document).on("click",".share_read_more",function(evt) { | ||
| 152 | evt.preventDefault(); | ||
| 153 | |||
| 154 | $(".modal-body.story").html('<img class="loading" src="https://thecommonwell.ca/wp-content/themes/commonwell-corp/images/loading.svg"/>'); | ||
| 155 | $('.sub-header').show(); | ||
| 156 | $('.modal-title').show(); | ||
| 157 | $("#exampleModalLong").modal("show"); | ||
| 158 | var id = $(this).data('id'); | ||
| 159 | console.log(id); | ||
| 160 | $.ajax({ | ||
| 161 | type: 'POST', | ||
| 162 | url: '../../wp-admin/admin-ajax.php', | ||
| 163 | dataType: 'json', | ||
| 164 | data: { | ||
| 165 | 'post_id': id, | ||
| 166 | 'action': 'ajax_request' //this is the name of the AJAX method called in WordPress | ||
| 167 | }, success: function (data) { | ||
| 168 | $(".sub-header.story").html(data['date']+'<br/>Submitted by '+data['post'].post_title); | ||
| 169 | $(".modal-body.story").html(data['post'].post_content); | ||
| 170 | |||
| 171 | console.log(data['post']); | ||
| 172 | }, | ||
| 173 | error: function () { | ||
| 174 | alert("error"); | ||
| 175 | } | ||
| 176 | }); | ||
| 177 | |||
| 178 | |||
| 179 | return false; | ||
| 180 | }); | ||
| 181 | |||
| 182 | jQuery(document).on("click","#menu-seedit-main li a",function(evt) { | ||
| 183 | jQuery('#mySidenav').removeClass('mobile-open'); | ||
| 184 | }); | ||
| 185 | |||
| 186 | document.addEventListener('dblclick', (event) => { | ||
| 187 | event.preventDefault() | ||
| 188 | }, { passive: false }); | ||
| 189 | |||
| 190 | var scrolling = false; | ||
| 191 | |||
| 192 | jQuery( window ).scroll( function() { | ||
| 193 | scrolling = true; | ||
| 194 | }); | ||
| 195 | |||
| 196 | jQuery('#side-window').scroll(function() { | ||
| 197 | scrolling = true; | ||
| 198 | }); | ||
| 199 | |||
| 200 | setInterval( function() { | ||
| 201 | if ( scrolling ) { | ||
| 202 | scrolling = false; | ||
| 203 | scrollScripts(); | ||
| 204 | } | ||
| 205 | }, 250 ); | ||
| 206 | |||
| 207 | // or for modern browsers | ||
| 208 | document.addEventListener( 'wheel', function( evt ) { | ||
| 209 | scrolling = true; | ||
| 210 | }, { capture: false, passive: true }); | ||
| 211 | |||
| 212 | scrollScripts(); | ||
| 213 | |||
| 214 | var el = document.getElementById('commonwell-link'); | ||
| 215 | var style = window.getComputedStyle(el, null).getPropertyValue('font-size'); | ||
| 216 | var fontSize = style; | ||
| 217 | var fontSizePercentage = parseFloat(style) / 12 * 100; | ||
| 218 | if( fontSizePercentage > 100){ | ||
| 219 | document.body.className += ' large_font'; | ||
| 220 | // $('.menu-item-220 a').attr('href','/news/'); | ||
| 221 | } | ||
| 222 | if( fontSizePercentage > 125){ | ||
| 223 | document.body.className += ' xlarge_font'; | ||
| 224 | } | ||
| 225 | |||
| 226 | console.log(style, fontSizePercentage); | ||
| 227 | |||
| 228 | }); | ||
| 229 | |||
| 230 | jQuery(window).load(function() { | ||
| 231 | if(location.hash) { | ||
| 232 | var id = jQuery(location.hash); | ||
| 233 | jQuery('html,body').animate({scrollTop: id.offset().top -150}, 'linear') | ||
| 234 | } | ||
| 235 | }); |
| 1 | jQuery(document).ready( function() { | ||
| 2 | |||
| 3 | |||
| 4 | function scrollScripts() { | ||
| 5 | |||
| 6 | if(!jQuery('#content-wrap').hasClass('retract')) { | ||
| 7 | if(jQuery(window).scrollTop() >= 150) { | ||
| 8 | jQuery('#content-wrap').addClass('retract'); | ||
| 9 | jQuery('#page-header-seedit').addClass('retract'); | ||
| 10 | jQuery('#mySidenav').addClass('retract'); | ||
| 11 | jQuery('#page-header-part').addClass('retract'); | ||
| 12 | jQuery('#myTopnav').css('top', '40px'); | ||
| 13 | jQuery('#menu-seedit-main').css('margin-top', '15px'); | ||
| 14 | |||
| 15 | |||
| 16 | jQuery('.tag-line').hide(); | ||
| 17 | |||
| 18 | document.querySelector(".otherpage-logo").getSVGDocument().getElementById("Community_Nutrition_Resources_Food_Security").setAttribute("fill-opacity", "0"); | ||
| 19 | |||
| 20 | } | ||
| 21 | } else { | ||
| 22 | if(jQuery(window).scrollTop() < 170) { | ||
| 23 | jQuery('#content-wrap').removeClass('retract'); | ||
| 24 | jQuery('#page-header-seedit').removeClass('retract'); | ||
| 25 | jQuery('#mySidenav').removeClass('retract'); | ||
| 26 | jQuery('#page-header-part').removeClass('retract'); | ||
| 27 | jQuery('#menu-seedit-main').css('margin-top', '50px'); | ||
| 28 | jQuery('.tag-line').show(); | ||
| 29 | jQuery('#myTopnav').css('top', '100px'); | ||
| 30 | document.querySelector(".otherpage-logo").getSVGDocument().getElementById("Community_Nutrition_Resources_Food_Security").setAttribute("fill-opacity", "1"); | ||
| 31 | |||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | jQuery(document).on("click","#menu-seedit-main li a",function(evt) { | ||
| 37 | jQuery('#mySidenav').removeClass('mobile-open'); | ||
| 38 | }); | ||
| 39 | |||
| 40 | document.addEventListener('dblclick', (event) => { | ||
| 41 | event.preventDefault() | ||
| 42 | }, { passive: false }); | ||
| 43 | |||
| 44 | var scrolling = false; | ||
| 45 | |||
| 46 | jQuery( window ).scroll( function() { | ||
| 47 | scrolling = true; | ||
| 48 | }); | ||
| 49 | |||
| 50 | jQuery('#side-window').scroll(function() { | ||
| 51 | scrolling = true; | ||
| 52 | }); | ||
| 53 | |||
| 54 | setInterval( function() { | ||
| 55 | if ( scrolling ) { | ||
| 56 | scrolling = false; | ||
| 57 | scrollScripts(); | ||
| 58 | } | ||
| 59 | }, 250 ); | ||
| 60 | |||
| 61 | // or for modern browsers | ||
| 62 | document.addEventListener( 'wheel', function( evt ) { | ||
| 63 | scrolling = true; | ||
| 64 | }, { capture: false, passive: true }); | ||
| 65 | |||
| 66 | scrollScripts(); | ||
| 67 | |||
| 68 | var el = document.getElementById('commonwell-link'); | ||
| 69 | var style = window.getComputedStyle(el, null).getPropertyValue('font-size'); | ||
| 70 | var fontSize = style; | ||
| 71 | var fontSizePercentage = parseFloat(style) / 12 * 100; | ||
| 72 | if( fontSizePercentage > 100){ | ||
| 73 | document.body.className += ' large_font'; | ||
| 74 | // $('.menu-item-220 a').attr('href','/news/'); | ||
| 75 | } | ||
| 76 | if( fontSizePercentage > 125){ | ||
| 77 | document.body.className += ' xlarge_font'; | ||
| 78 | } | ||
| 79 | |||
| 80 | console.log(style, fontSizePercentage); | ||
| 81 | |||
| 82 | }); | ||
| 83 | |||
| 84 | |||
| 85 |
| 1 | define( | ||
| 2 | ['jquery', 'featherlight'], function ($) { | ||
| 3 | $(document).ready( | ||
| 4 | function () { | ||
| 5 | var $canadaPostButton = $('.canada-post-icon-button'); | ||
| 6 | var tl = new TimelineMax( | ||
| 7 | { | ||
| 8 | repeat: -1, | ||
| 9 | repeatDelay: 10 | ||
| 10 | } | ||
| 11 | ); | ||
| 12 | |||
| 13 | tl | ||
| 14 | .to( | ||
| 15 | $canadaPostButton, 0.25, { | ||
| 16 | scaleX: 1.1, | ||
| 17 | scaleY: 1.1, | ||
| 18 | force3D: true, | ||
| 19 | ease: Linear.easeNone | ||
| 20 | } | ||
| 21 | ) | ||
| 22 | .to( | ||
| 23 | $canadaPostButton, 0.25, { | ||
| 24 | scaleX: 0.95, | ||
| 25 | scaleY: 0.95, | ||
| 26 | force3D: true, | ||
| 27 | ease: Linear.easeNone | ||
| 28 | } | ||
| 29 | ) | ||
| 30 | .to( | ||
| 31 | $canadaPostButton, 0.25, { | ||
| 32 | scaleX: 1, | ||
| 33 | scaleY: 1, | ||
| 34 | force3D: true, | ||
| 35 | ease: Linear.easeNone | ||
| 36 | } | ||
| 37 | ); | ||
| 38 | } | ||
| 39 | ); | ||
| 40 | } | ||
| 41 | ); |
| 1 | define( | ||
| 2 | ['jquery'], function ($) { | ||
| 3 | $(document).ready( | ||
| 4 | function () { | ||
| 5 | // Check if browser supports HTML5 input placeholder | ||
| 6 | function supports_input_placeholder() { | ||
| 7 | var i = document.createElement('input'); | ||
| 8 | return 'placeholder' in i; | ||
| 9 | } | ||
| 10 | |||
| 11 | // Change input text on focus | ||
| 12 | if (!supports_input_placeholder()) { | ||
| 13 | jQuery('.wpcf7-text').each( | ||
| 14 | function () { | ||
| 15 | var self = jQuery(this); | ||
| 16 | var value = jQuery.trim(self.val()); | ||
| 17 | if (value == '') self.val(self.attr('placeholder')); | ||
| 18 | } | ||
| 19 | ); | ||
| 20 | jQuery('.wpcf7-text').focus( | ||
| 21 | function () { | ||
| 22 | var self = jQuery(this); | ||
| 23 | if (self.val() == self.attr('placeholder')) self.val(''); | ||
| 24 | } | ||
| 25 | ).blur( | ||
| 26 | function () { | ||
| 27 | var self = jQuery(this); | ||
| 28 | var value = jQuery.trim(self.val()); | ||
| 29 | if (value == '') self.val(self.attr('placeholder')); | ||
| 30 | } | ||
| 31 | ); | ||
| 32 | } | ||
| 33 | |||
| 34 | //functionality for add-file link | ||
| 35 | $('a.add_file').on( | ||
| 36 | 'click', function (e) { | ||
| 37 | //show by click the first one from hidden inputs | ||
| 38 | $('p.hide:not(:visible):first').show('slow'); | ||
| 39 | e.preventDefault(); | ||
| 40 | } | ||
| 41 | ); | ||
| 42 | |||
| 43 | //functionality for del-file link | ||
| 44 | $('a.del_file').on( | ||
| 45 | 'click', function (e) { | ||
| 46 | //var init | ||
| 47 | var input_parent = $(this).parent(); | ||
| 48 | var input_wrap = input_parent.find('span'); | ||
| 49 | //reset field value | ||
| 50 | input_wrap.html(input_wrap.html()); | ||
| 51 | //hide by click | ||
| 52 | input_parent.hide('slow'); | ||
| 53 | e.preventDefault(); | ||
| 54 | } | ||
| 55 | ); | ||
| 56 | |||
| 57 | $('a.first-file').on( | ||
| 58 | 'click', function (e) { | ||
| 59 | //reset field value | ||
| 60 | $('.wpcf7-file').eq(0).replaceWith($('.wpcf7-file').eq(0).val('').clone(true)); | ||
| 61 | $(this).hide(); | ||
| 62 | e.preventDefault(); | ||
| 63 | } | ||
| 64 | ); | ||
| 65 | |||
| 66 | $('.wpcf7-file').eq(0).change( | ||
| 67 | function () { | ||
| 68 | var fileName = $(this).val(); | ||
| 69 | if (fileName != '') { | ||
| 70 | $('a.first-file').show(); | ||
| 71 | } else { | ||
| 72 | $('a.first-file').hide(); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | ); | ||
| 76 | |||
| 77 | var eventFields = $('input[name="event-date"], input[name="event-location"], textarea[name="purpose-event"], input[name="role"], textarea[name="recognize-event"]'); | ||
| 78 | eventFields.removeClass('wpcf7-validates-as-required'); | ||
| 79 | eventFields.parents('.form-control').hide(); | ||
| 80 | |||
| 81 | $('input[name="donation"]').click( | ||
| 82 | function () { | ||
| 83 | var value = $(this).attr('value'); | ||
| 84 | var isDonation = value.indexOf('donation') > 0; | ||
| 85 | var requiredClassName = 'wpcf7-validates-as-required'; | ||
| 86 | var requiredAttr = "aria-required"; | ||
| 87 | var eventFields = $('input[name="event-date"], input[name="event-location"], textarea[name="purpose-event"], input[name="role"], textarea[name="recognize-event"]'); | ||
| 88 | |||
| 89 | // Check if it is donation or event | ||
| 90 | if (!isDonation) { | ||
| 91 | eventFields.addClass(requiredClassName).attr(requiredAttr, true); | ||
| 92 | eventFields.parents('.form-control').slideDown(); | ||
| 93 | } else { | ||
| 94 | eventFields.removeClass(requiredClassName).attr(requiredAttr, false); | ||
| 95 | eventFields.parents('.form-control').slideUp(); | ||
| 96 | |||
| 97 | } | ||
| 98 | } | ||
| 99 | ); | ||
| 100 | } | ||
| 101 | ); | ||
| 102 | } | ||
| 103 | ); |
-
Please register or sign in to post a comment