/** * * Custom JS for JACTET operations * Author: Abhijeet K. [https://about.me/abhijeet_in] * */ (function($){ "use strict"; var $win = $(window), $doc = $(document); escapeHashAnchors(); // setFooterPosition('.footer'); // floatNavigation(); // homeJx(); // copyAddress(); allCaps(); function allCaps(){ $('input[type="text"]:not(:disabled)').on('keyup', function(e){ if($(this).hasClass('normal-transform')){ return true; } if(e.which >= 65 && e.which <= 90) $(this).val($(this).val().toUpperCase()); $(this).val($(this).val().replace(/\s+/g, ' ')); }).on('blur', function(e){ if($(this).hasClass('normal-transform')){ return true; } $(this).val($.trim($(this).val())); }) } function copyAddress(){ $('#address-line-1-1, #address-line-2-1, #state-1, #pin-1, #country-1').on('change keydown', function(){ $('#copy-address').attr('checked', false); }); $('#copy-address').on('click', function(e){ var addArr = { 'address1': $('#address-line-1-1').val().trim(), 'address2': $('#address-line-2-1').val().trim(), 'state': $('#state-1 option:selected').val(), 'pin': $('#pin-1').val().trim(), 'country': $('#country-1 option:selected').val() }, $t = $(this); if( $t.is(':checked') ){ $('#address-line-1-2').val(addArr['address1']); $('#address-line-2-2').val(addArr['address2']); $('#pin-2').val(addArr['pin']); $('#state-2 option').each(function(){ if( $(this).val() == addArr['state'] ) $(this).attr('selected', 'selected'); }) $('#country-2 option').each(function(){ if( $(this).val() == addArr['country'] ) $(this).attr('selected', 'selected'); }) } }); } function homeJx(){ $('#user-id').on('keyup', function(e){ var $t = $(this), sid = $t.val().trim(); if(sid != ''){ var u = 'process/operations.php'; $.ajax({ url: u, type: 'GET', dataType: 'json', async: true, cache: false, data: {jx: true, scid: sid, getSchool: true}, success: function(h){ console.log(h); if( h['data'] != "0" ){ $('.alert-success .message').html(h['data']); $('.alert-success').removeClass('hidden'); $('#user-pass').removeAttr('disabled').focus(); switchSubmit(); }else{ $('.alert-success .message').html(''); $('.alert-success').addClass('hidden'); $('#user-pass').attr('disabled', 'disabled'); } } }); } }); } function switchSubmit(){ $('#user-pass').off().on('keyup', function(e){ var $t = $(this), sid = $t.val().trim(); if(sid != ''){ $('#submit-login').removeAttr('disabled'); }else{ $('#submit-login').attr('disabled', 'disabled'); } }); } function floatNavigation(){ $(window).on('scroll', function(){ var scrollTop = $win.scrollTop(), $targetElem = $('.fixed-navigation'); if( scrollTop > 300 ){ $targetElem.stop(true, true).animate({'margin-top': -180}, 500); } if( scrollTop < 300 ){ $targetElem.stop(true, true).animate({'margin-top': 0}, 500); } }); $('.page-content').css('min-height', $win.height() - ($('.header').height() + $('.footer').height()) ) } function setFooterPosition(elm){ if($doc.height() > $win.height()){ $(elm).css('position', 'relative'); } } function escapeHashAnchors(){ $('a[href="#"]').attr('href', 'javascript:;'); } })(jQuery);