Created
September 3, 2017 02:56
-
-
Save shiftenterdev/fdbb5bf76098ca3e6a2279bf3fb62119 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/legoqil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
/** | |
* Modal Login | |
*/ | |
var loginParentDiv = $('.user-auth-section'); | |
var signInTitle = $('.sign-in-title').html(); | |
var signUpTitle = $('.sign-up-title').html(); | |
var signInForm = $('.lg-frm').html(); | |
var signUpForm = $('.signup-form').html(); | |
var resetForm = $('.reset-form').html(); | |
var place = $('.signup-form'); | |
$('body').on('click', '.sgn-in', function (e) { | |
e.preventDefault(); | |
$('.sgn-in').removeClass('hidden'); | |
place.html(signInForm); | |
$('.sign-up-title').html(signInTitle); | |
$('#signup').modal('show'); | |
}); | |
$('body').on('click', '.sgn-up', function (e) { | |
e.preventDefault(); | |
$('.sgn-in').removeClass('hidden'); | |
place.html(signUpForm); | |
$('.sign-up-title').html(signUpTitle); | |
$('.user-auth-section').on('input', '.m-num', function () { | |
$(this).val($(this).val().replace(/[^0-9]/g, '')); | |
}); | |
$("#signup").modal({ | |
backdrop: false | |
}); | |
}); | |
loginParentDiv.on('click', '.forgot-password', function (e) { | |
e.preventDefault(); | |
place.html(resetForm); | |
$('.user-auth-section').on('input', '.m-num', function () { | |
$(this).val($(this).val().replace(/[^0-9]/g, '')); | |
}); | |
$('#signup').modal('show'); | |
}); | |
$('body').on('click', '.cancel', function (e) { | |
e.preventDefault(); | |
place.html(signInForm); | |
}); | |
loginParentDiv.on('submit', '#loginForm', function (e) { | |
e.preventDefault(); | |
$('.signup-form').addClass('loading'); | |
var data = $(this).serializeArray(); | |
var url = $(this).attr('action'); | |
$.post(url, data).done(function (r) { | |
if (r[0] == 200) { | |
//console.log($.urlParam('redirect')); | |
if($.urlParam('redirect')==null) { | |
location.reload(); | |
}else{ | |
window.location = $.urlParam('redirect'); | |
} | |
} else { | |
$('.signup-form').removeClass('loading'); | |
$('#loginForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
}); | |
loginParentDiv.on('submit', '#signupForm', function (e) { | |
e.preventDefault(); | |
var url; | |
var data; | |
if ($('.step__1').hasClass('hidden')) { | |
data = $('.step__2').find(':input').serializeArray(); | |
url = 'authenticate/complete-signup'; | |
$('.signup-form').addClass('loading'); | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
$('.signup-form').removeClass('loading'); | |
location.reload(); | |
} else { | |
$('#signupForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
} else { | |
url = 'authenticate/signup'; | |
data = $('.step__1').find(':input').serializeArray(); | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
$('#signupForm .step__1').addClass('hidden'); | |
$('#signupForm .step__2').removeClass('hidden'); | |
$('#signup .sgn-in').addClass('hidden'); | |
$('#signupForm .message').html('A verification code sent to your mobile'); | |
clearMessage(); | |
} else { | |
$('#signupForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
} | |
}); | |
loginParentDiv.on('submit', '#passwordResetForm', function (e) { | |
e.preventDefault(); | |
var data = $(this).serializeArray(); | |
var url = 'authenticate/request-new-password'; | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
place.html(signInForm); | |
$('#loginForm .message').html('<div class="alert alert-danger">A Temporary password is sent to your mobile</div>'); | |
//clearMessage(); | |
} else { | |
$('#passwordResetForm .message').html('<div class="alert alert-danger">' + r[1] + '</div>'); | |
} | |
}); | |
}); | |
var clearMessage = function () { | |
$('.user-auth-section .message').html(''); | |
}; | |
/******************** | |
* main Navbar | |
*******************/ | |
var timer; | |
var delay = 150; | |
var _ind = 0; | |
var _dropDown = $('li.dropdown'); | |
$(document).mouseup(function (e) { | |
var container = $("li.dropdown"); | |
if (!container.is(e.target) // if the target of the click isn't the container... | |
&& container.has(e.target).length === 0) // ... nor a descendant of the container | |
{ | |
$('.drop-icon').css('opacity', 0); | |
} | |
}); | |
_dropDown.on('click', function () { | |
$('li.dropdown').children('.drop-icon').css('opacity', 0); | |
$(this).children('.drop-icon').css('opacity', 1); | |
}); | |
_dropDown.hover(function() { | |
// on mouse in, start a timeout | |
_ind = $(this).index(); | |
timer = setTimeout(function() { | |
// console.log(_ind); | |
_dropDown.children('.dropdown-menu').eq(_ind).fadeIn(); | |
_dropDown.children('.drop-icon').eq(_ind).css('opacity', 1); | |
_dropDown.children('a').eq(_ind).addClass('orange'); | |
$(".mainnav").css("border-bottom", "1px solid #EAEAEA"); | |
$(".white-bg,.faded-bg").stop(true, true).fadeIn(); | |
$('body').addClass('no-scroll'); | |
}, delay); | |
}, function() { | |
// on mouse out, cancel the timer | |
clearTimeout(timer); | |
_dropDown.children('.dropdown-menu').hide(); | |
_dropDown.children('.drop-icon').css('opacity', 0); | |
_dropDown.children('a').removeClass('orange'); | |
$(".mainnav").css("border-bottom", "1px solid #fff"); | |
$(".white-bg,.faded-bg").stop(true, true).hide(); | |
$('body').removeClass('no-scroll'); | |
}); | |
/** | |
* Other js | |
*/ | |
$(function () { | |
$.get('shopping/cart-count').done(function (r) { | |
$('.cart-count').text(r); | |
}); | |
$('.b-logo-list').load('content/menu-brand'); | |
$('.b-logo-list-all').load('content/menu-all-brand'); | |
}); | |
//$('#mainSearch').on('input', function (e) { | |
// if(e.keyCode != 40 && e.keyCode != 38) { | |
// var keyword = $(this).val(); | |
// if (keyword.trim() != '') { | |
// keyword = encodeURI(keyword); | |
// $('search-list').html('<div class="s__list"><div class="__p loading"></div></div>'); | |
// $('search-list').load('search?query=' + keyword, function () { | |
//$('search-list').removeClass('loading'); | |
//$('.__p').eq(0).addClass('h-light'); | |
//upDown(); | |
//}); | |
//} else { | |
// $('search-list').html(''); | |
//} | |
//} | |
//}); | |
var delayTimer=100; | |
//var src = $('#mainSearch'); | |
$('#mainSearch').on('input', function (e) { | |
clearTimeout(delayTimer); | |
$('search-list').html('<div class="s__list"><div class="__p loading"></div></div>'); | |
delayTimer = setTimeout(function () { | |
if(e.keyCode != 40 && e.keyCode != 38) { | |
var keyword = $('#mainSearch').val(); | |
//console.log($('#mainSearch').val()); | |
if (keyword.trim() != '') { | |
keyword = encodeURI(keyword); | |
$('search-list').load('ajax-search?q=' + keyword, function () { | |
}); | |
} else { | |
$('search-list').html(''); | |
} | |
} | |
}, 100); | |
}); | |
var set_search_text = function(text){ | |
$('#mainSearch').val(text.trim()); | |
}; | |
var upDown = function(){ | |
$(document).keyup(function(e) { | |
//console.log(e.keyCode); | |
var current = $('.__p.h-light'), list = $('.__p'),ind = current.index(); | |
console.log(ind); | |
if (e.keyCode === 40) { | |
current.removeClass('h-light'); | |
list.eq(ind+1).addClass('h-light'); | |
set_search_text($('.__p.h-light').find('a').text()); | |
if (list.eq(ind+1).length == 0) { | |
list.eq(0).addClass('h-light'); | |
set_search_text($('.__p.h-light').find('a').text()); | |
//return; | |
} | |
} else if (e.keyCode === 38) { | |
current.removeClass('h-light'); | |
if (list.eq(ind-1).length == 0) { | |
list.eq(0).addClass('h-light'); | |
}else{ | |
list.eq(ind-1).addClass('h-light'); | |
} | |
} | |
}) | |
} | |
/* | |
wishlist | |
*/ | |
//$('.my-wishlist').on('click',function(e){ | |
// e.preventDefault(); | |
// if($(this).hasClass('auth-user')){ | |
// var url = $(this).attr('href'); | |
// window.location = url; | |
// }else{ | |
// $('.sgn-in').trigger('click'); | |
// history.pushState(null,null,'?redirect=my-wishlist') | |
// } | |
//}); | |
$.urlParam = function(name){ | |
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); | |
if (results==null){ | |
return null; | |
}else{ | |
return results[1] || 0; | |
} | |
}; | |
$('.guest-user').on('click',function(e){ | |
e.preventDefault(); | |
var url = $(this).attr('href'); | |
history.pushState(null,null,'?redirect='+url); | |
$('.sgn-in').trigger('click'); | |
}); | |
$('#signup').on('hide.bs.modal', function (e) { | |
history.replaceState(null,null,'/'); | |
}); | |
// web notification | |
document.addEventListener('DOMContentLoaded', function () { | |
if (!Notification) { | |
alert('Desktop notifications not available in your browser. Try Chromium.'); | |
return; | |
} | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
}); | |
//var pusher = new Pusher('5340812be854f4873b44', { | |
// encrypted: true | |
//}); | |
//var channel = pusher.subscribe('itb-chn'); | |
// | |
//channel.bind('itb-evt', function(data) { | |
// webNotify(data.url,data.title,data.body); | |
//}); | |
var webNotify = function(url,title,body){ | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
else { | |
var notification = new Notification(title, { | |
icon: 'https://www.itbazaar.com.bd/public/assets/sq_itbazaar.png', | |
body: body | |
}); | |
notification.onclick = function () { | |
window.open(url); | |
}; | |
} | |
}; | |
$('.search-btn').on('click',function(){ | |
if($('.s__list .__p strong a').length){ | |
window.location = $('.s__list .__p strong a').eq(0).attr('href'); | |
} | |
}); | |
$(function(){ | |
$('.message-box').delay(3000).fadeOut(); | |
}); | |
$(document).click(function(event) { | |
if(!$(event.target).closest('#mainSearch').length) { | |
$('.s__list').css('display','none'); | |
} | |
}); | |
$('.subscription-form').on('submit',function(){ | |
var e = $('.subscription-form .email').val(); | |
if(e.trim() == ''){ | |
$('span.req').text('The Email is required'); | |
}else{ | |
e = e.trim(); | |
$.post('home/subscription',{email:e}).done(function(r){ | |
if(r==1){ | |
$('span.req').text('Thank you for Subscription'); | |
} | |
if(r==2){ | |
$('span.req').text('This email already Subscribed'); | |
} | |
}); | |
//console.log(e.trim()); | |
} | |
}); | |
$(function(){ | |
//var xx=0; | |
//setInterval(function(){ | |
// if(xx==0){ | |
// console.log($('#intercom-container').length); | |
// if($('#intercom-container').length == 1){ | |
// $('.call-center-number').css('display','block'); | |
// xx = 1; | |
// } | |
// } | |
// }, 100); | |
// | |
// $(".phonecell").click(function(){ | |
// window.location.href="tel://09612484848"; | |
// }); | |
$("#phonecell").click(function(){ | |
window.location.href="tel://09612484848"; | |
}); | |
$("#livechat").click(function(){ | |
javascript:void(Tawk_API.toggle()) | |
}); | |
}); | |
$('.dropdown-toggle.link').on('click',function(){ | |
var href = $(this).attr('href'); | |
if(href != '#' || href != 'javascript:') { | |
window.location.href = href; | |
} | |
}); | |
// $(function(){ | |
// setInterval(function(){ | |
// $("[data-src]").each(function (i, e) { | |
// var src = $(this).attr('data-src'); | |
// if ($(this).attr('data-src')) { | |
// if(isElementInViewport($(this))) { | |
// $(this).attr('src', src); | |
// $(this).on('load', function () { | |
// $(this).removeClass('img-blur'); | |
// }); | |
// } | |
// | |
// } | |
// }); | |
// }, 1000); | |
// | |
// | |
// }); | |
function isElementInViewport (el) { | |
//special bonus for those using jQuery | |
if (typeof jQuery === "function" && el instanceof jQuery) { | |
el = el[0]; | |
} | |
var rect = el.getBoundingClientRect(); | |
return ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ | |
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ | |
); | |
} | |
function getTimeRemaining(endtime) { | |
var t = Date.parse(endtime) - Date.parse(new Date()); | |
var seconds = Math.floor((t / 1000) % 60); | |
var minutes = Math.floor((t / 1000 / 60) % 60); | |
var hours = Math.floor((t / (1000 * 60 * 60)) % 24); | |
var days = Math.floor(t / (1000 * 60 * 60 * 24)); | |
return { | |
'total': t, | |
'days': days, | |
'hours': hours, | |
'minutes': minutes, | |
'seconds': seconds | |
}; | |
} | |
function initializeClock(id, endtime) { | |
var clock = document.getElementById(id); | |
var hoursSpan = clock.querySelector('.hours'); | |
var minutesSpan = clock.querySelector('.minutes'); | |
var secondsSpan = clock.querySelector('.seconds'); | |
function updateClock() { | |
var t = getTimeRemaining(endtime); | |
hoursSpan.innerHTML = ('0' + t.hours).slice(-2); | |
minutesSpan.innerHTML = ('0' + t.minutes).slice(-2); | |
secondsSpan.innerHTML = ('0' + t.seconds).slice(-2); | |
if (t.total <= 0) { | |
clearInterval(timeinterval); | |
} | |
} | |
updateClock(); | |
var timeinterval = setInterval(updateClock, 1000); | |
} | |
$(".affix-head").affix({offset: {top: 27}}); | |
$(".affix-head").on('affix.bs.affix', function () { | |
$(".faded-bg").css("top", "114"); | |
}); | |
$(".affix-head").on('affix-top.bs.affix', function () { | |
$(".faded-bg").css("top", "149"); | |
}); | |
if ($(".affix-head").hasClass("affix")) { | |
$(".faded-bg").css("top", "114"); | |
} | |
$(".container, .faded-bg, .logoarea, .topbar").hover( | |
function () { | |
$(".white-bg,.faded-bg").stop(true, true).hide(); | |
} | |
); | |
function number_format(number, decimals, decPoint, thousandsSep) { | |
decimals = decimals || 0; | |
number = parseFloat(number); | |
if (!decPoint || !thousandsSep) { | |
decPoint = '.'; | |
thousandsSep = ','; | |
} | |
var roundedNumber = Math.round(Math.abs(number) * ('1e' + decimals)) + ''; | |
var numbersString = decimals ? roundedNumber.slice(0, decimals * -1) : roundedNumber; | |
var decimalsString = decimals ? roundedNumber.slice(decimals * -1) : ''; | |
var formattedNumber = ""; | |
while (numbersString.length > 3) { | |
formattedNumber += thousandsSep + numbersString.slice(-3) | |
numbersString = numbersString.slice(0, -3); | |
} | |
return (number < 0 ? '-' : '') + numbersString + formattedNumber + (decimalsString ? (decPoint + decimalsString) : ''); | |
} | |
function isNumber(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
$('#sendapplink').on('click', function () { | |
var number=$("#appnumber").val(); | |
if (number=="") { | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
} | |
else if (!isNumber(number)){ | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
} | |
else if (number.length!=11){ | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
}else{ | |
$(".appnumdiv").removeClass("has-error"); | |
$(".appnumerror").text(""); | |
$("#appnumber").prop("disable",true); | |
$("#sendapplink").text("Please wait...").prop("disable",true); | |
} | |
$.get("home/getTheApp?number="+number, function( data ) { | |
if (data=="SUCCESS") { | |
$("#appnumber").val("").prop("disable", false); | |
$("#sendapplink").text("Send me Link").prop("disable", false); | |
$('#gettheapp').modal('hide'); | |
alert("We have sent you an sms with app download link"); | |
} | |
}); | |
//console.log($("#appnumber").val()); | |
}); | |
function replaceImage(){ | |
} | |
// var imageLoaded = function(img,imgurl) { | |
// //console.log("HI IM LOADED"); | |
// //console.log(img + imgurl); | |
// //$(img).addClass('loaded'); | |
// $(img).attr("src",imgurl); | |
// | |
// } | |
//$('.image-blur').each(function(){ | |
// var img = $(this); | |
//$(img).wrap("<div class='div-blur'></div>"); | |
//var parentContainer = $(this).parent(); | |
//parentContainer.addClass('blurry-load-container'); | |
//img.addClass('img-blur'); | |
// var img = new Image(); | |
// img.src = imageContainer.attr('src'); | |
// | |
// //imageContainer | |
// | |
// | |
// var imgLarge = new Image(); | |
// imgLarge.src = imageContainer.attr('data-large'); | |
// | |
// imgLarge.onload = function () { | |
// console.info("Image loaded !"+imgLarge.src); | |
// //$(this).attr('src',imgLarge.src); | |
// //do something... | |
// } | |
// imgLarge.onerror = function () { | |
// console.error("Cannot load image"); | |
// //do something else... | |
// } | |
// var imgurl = img.attr("data-large"); | |
// var imgLarge = new Image(); | |
// imgLarge.onload = imageLoaded(img,imgurl); | |
// imgLarge.src = imgurl; | |
//}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">/** | |
* Modal Login | |
*/ | |
var loginParentDiv = $('.user-auth-section'); | |
var signInTitle = $('.sign-in-title').html(); | |
var signUpTitle = $('.sign-up-title').html(); | |
var signInForm = $('.lg-frm').html(); | |
var signUpForm = $('.signup-form').html(); | |
var resetForm = $('.reset-form').html(); | |
var place = $('.signup-form'); | |
$('body').on('click', '.sgn-in', function (e) { | |
e.preventDefault(); | |
$('.sgn-in').removeClass('hidden'); | |
place.html(signInForm); | |
$('.sign-up-title').html(signInTitle); | |
$('#signup').modal('show'); | |
}); | |
$('body').on('click', '.sgn-up', function (e) { | |
e.preventDefault(); | |
$('.sgn-in').removeClass('hidden'); | |
place.html(signUpForm); | |
$('.sign-up-title').html(signUpTitle); | |
$('.user-auth-section').on('input', '.m-num', function () { | |
$(this).val($(this).val().replace(/[^0-9]/g, '')); | |
}); | |
$("#signup").modal({ | |
backdrop: false | |
}); | |
}); | |
loginParentDiv.on('click', '.forgot-password', function (e) { | |
e.preventDefault(); | |
place.html(resetForm); | |
$('.user-auth-section').on('input', '.m-num', function () { | |
$(this).val($(this).val().replace(/[^0-9]/g, '')); | |
}); | |
$('#signup').modal('show'); | |
}); | |
$('body').on('click', '.cancel', function (e) { | |
e.preventDefault(); | |
place.html(signInForm); | |
}); | |
loginParentDiv.on('submit', '#loginForm', function (e) { | |
e.preventDefault(); | |
$('.signup-form').addClass('loading'); | |
var data = $(this).serializeArray(); | |
var url = $(this).attr('action'); | |
$.post(url, data).done(function (r) { | |
if (r[0] == 200) { | |
//console.log($.urlParam('redirect')); | |
if($.urlParam('redirect')==null) { | |
location.reload(); | |
}else{ | |
window.location = $.urlParam('redirect'); | |
} | |
} else { | |
$('.signup-form').removeClass('loading'); | |
$('#loginForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
}); | |
loginParentDiv.on('submit', '#signupForm', function (e) { | |
e.preventDefault(); | |
var url; | |
var data; | |
if ($('.step__1').hasClass('hidden')) { | |
data = $('.step__2').find(':input').serializeArray(); | |
url = 'authenticate/complete-signup'; | |
$('.signup-form').addClass('loading'); | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
$('.signup-form').removeClass('loading'); | |
location.reload(); | |
} else { | |
$('#signupForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
} else { | |
url = 'authenticate/signup'; | |
data = $('.step__1').find(':input').serializeArray(); | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
$('#signupForm .step__1').addClass('hidden'); | |
$('#signupForm .step__2').removeClass('hidden'); | |
$('#signup .sgn-in').addClass('hidden'); | |
$('#signupForm .message').html('A verification code sent to your mobile'); | |
clearMessage(); | |
} else { | |
$('#signupForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
} | |
}); | |
loginParentDiv.on('submit', '#passwordResetForm', function (e) { | |
e.preventDefault(); | |
var data = $(this).serializeArray(); | |
var url = 'authenticate/request-new-password'; | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
place.html(signInForm); | |
$('#loginForm .message').html('<div class="alert alert-danger">A Temporary password is sent to your mobile</div>'); | |
//clearMessage(); | |
} else { | |
$('#passwordResetForm .message').html('<div class="alert alert-danger">' + r[1] + '</div>'); | |
} | |
}); | |
}); | |
var clearMessage = function () { | |
$('.user-auth-section .message').html(''); | |
}; | |
/******************** | |
* main Navbar | |
*******************/ | |
var timer; | |
var delay = 150; | |
var _ind = 0; | |
var _dropDown = $('li.dropdown'); | |
$(document).mouseup(function (e) { | |
var container = $("li.dropdown"); | |
if (!container.is(e.target) // if the target of the click isn't the container... | |
&& container.has(e.target).length === 0) // ... nor a descendant of the container | |
{ | |
$('.drop-icon').css('opacity', 0); | |
} | |
}); | |
_dropDown.on('click', function () { | |
$('li.dropdown').children('.drop-icon').css('opacity', 0); | |
$(this).children('.drop-icon').css('opacity', 1); | |
}); | |
_dropDown.hover(function() { | |
// on mouse in, start a timeout | |
_ind = $(this).index(); | |
timer = setTimeout(function() { | |
// console.log(_ind); | |
_dropDown.children('.dropdown-menu').eq(_ind).fadeIn(); | |
_dropDown.children('.drop-icon').eq(_ind).css('opacity', 1); | |
_dropDown.children('a').eq(_ind).addClass('orange'); | |
$(".mainnav").css("border-bottom", "1px solid #EAEAEA"); | |
$(".white-bg,.faded-bg").stop(true, true).fadeIn(); | |
$('body').addClass('no-scroll'); | |
}, delay); | |
}, function() { | |
// on mouse out, cancel the timer | |
clearTimeout(timer); | |
_dropDown.children('.dropdown-menu').hide(); | |
_dropDown.children('.drop-icon').css('opacity', 0); | |
_dropDown.children('a').removeClass('orange'); | |
$(".mainnav").css("border-bottom", "1px solid #fff"); | |
$(".white-bg,.faded-bg").stop(true, true).hide(); | |
$('body').removeClass('no-scroll'); | |
}); | |
/** | |
* Other js | |
*/ | |
$(function () { | |
$.get('shopping/cart-count').done(function (r) { | |
$('.cart-count').text(r); | |
}); | |
$('.b-logo-list').load('content/menu-brand'); | |
$('.b-logo-list-all').load('content/menu-all-brand'); | |
}); | |
//$('#mainSearch').on('input', function (e) { | |
// if(e.keyCode != 40 && e.keyCode != 38) { | |
// var keyword = $(this).val(); | |
// if (keyword.trim() != '') { | |
// keyword = encodeURI(keyword); | |
// $('search-list').html('<div class="s__list"><div class="__p loading"></div></div>'); | |
// $('search-list').load('search?query=' + keyword, function () { | |
//$('search-list').removeClass('loading'); | |
//$('.__p').eq(0).addClass('h-light'); | |
//upDown(); | |
//}); | |
//} else { | |
// $('search-list').html(''); | |
//} | |
//} | |
//}); | |
var delayTimer=100; | |
//var src = $('#mainSearch'); | |
$('#mainSearch').on('input', function (e) { | |
clearTimeout(delayTimer); | |
$('search-list').html('<div class="s__list"><div class="__p loading"></div></div>'); | |
delayTimer = setTimeout(function () { | |
if(e.keyCode != 40 && e.keyCode != 38) { | |
var keyword = $('#mainSearch').val(); | |
//console.log($('#mainSearch').val()); | |
if (keyword.trim() != '') { | |
keyword = encodeURI(keyword); | |
$('search-list').load('ajax-search?q=' + keyword, function () { | |
}); | |
} else { | |
$('search-list').html(''); | |
} | |
} | |
}, 100); | |
}); | |
var set_search_text = function(text){ | |
$('#mainSearch').val(text.trim()); | |
}; | |
var upDown = function(){ | |
$(document).keyup(function(e) { | |
//console.log(e.keyCode); | |
var current = $('.__p.h-light'), list = $('.__p'),ind = current.index(); | |
console.log(ind); | |
if (e.keyCode === 40) { | |
current.removeClass('h-light'); | |
list.eq(ind+1).addClass('h-light'); | |
set_search_text($('.__p.h-light').find('a').text()); | |
if (list.eq(ind+1).length == 0) { | |
list.eq(0).addClass('h-light'); | |
set_search_text($('.__p.h-light').find('a').text()); | |
//return; | |
} | |
} else if (e.keyCode === 38) { | |
current.removeClass('h-light'); | |
if (list.eq(ind-1).length == 0) { | |
list.eq(0).addClass('h-light'); | |
}else{ | |
list.eq(ind-1).addClass('h-light'); | |
} | |
} | |
}) | |
} | |
/* | |
wishlist | |
*/ | |
//$('.my-wishlist').on('click',function(e){ | |
// e.preventDefault(); | |
// if($(this).hasClass('auth-user')){ | |
// var url = $(this).attr('href'); | |
// window.location = url; | |
// }else{ | |
// $('.sgn-in').trigger('click'); | |
// history.pushState(null,null,'?redirect=my-wishlist') | |
// } | |
//}); | |
$.urlParam = function(name){ | |
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); | |
if (results==null){ | |
return null; | |
}else{ | |
return results[1] || 0; | |
} | |
}; | |
$('.guest-user').on('click',function(e){ | |
e.preventDefault(); | |
var url = $(this).attr('href'); | |
history.pushState(null,null,'?redirect='+url); | |
$('.sgn-in').trigger('click'); | |
}); | |
$('#signup').on('hide.bs.modal', function (e) { | |
history.replaceState(null,null,'/'); | |
}); | |
// web notification | |
document.addEventListener('DOMContentLoaded', function () { | |
if (!Notification) { | |
alert('Desktop notifications not available in your browser. Try Chromium.'); | |
return; | |
} | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
}); | |
//var pusher = new Pusher('5340812be854f4873b44', { | |
// encrypted: true | |
//}); | |
//var channel = pusher.subscribe('itb-chn'); | |
// | |
//channel.bind('itb-evt', function(data) { | |
// webNotify(data.url,data.title,data.body); | |
//}); | |
var webNotify = function(url,title,body){ | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
else { | |
var notification = new Notification(title, { | |
icon: 'https://www.itbazaar.com.bd/public/assets/sq_itbazaar.png', | |
body: body | |
}); | |
notification.onclick = function () { | |
window.open(url); | |
}; | |
} | |
}; | |
$('.search-btn').on('click',function(){ | |
if($('.s__list .__p strong a').length){ | |
window.location = $('.s__list .__p strong a').eq(0).attr('href'); | |
} | |
}); | |
$(function(){ | |
$('.message-box').delay(3000).fadeOut(); | |
}); | |
$(document).click(function(event) { | |
if(!$(event.target).closest('#mainSearch').length) { | |
$('.s__list').css('display','none'); | |
} | |
}); | |
$('.subscription-form').on('submit',function(){ | |
var e = $('.subscription-form .email').val(); | |
if(e.trim() == ''){ | |
$('span.req').text('The Email is required'); | |
}else{ | |
e = e.trim(); | |
$.post('home/subscription',{email:e}).done(function(r){ | |
if(r==1){ | |
$('span.req').text('Thank you for Subscription'); | |
} | |
if(r==2){ | |
$('span.req').text('This email already Subscribed'); | |
} | |
}); | |
//console.log(e.trim()); | |
} | |
}); | |
$(function(){ | |
//var xx=0; | |
//setInterval(function(){ | |
// if(xx==0){ | |
// console.log($('#intercom-container').length); | |
// if($('#intercom-container').length == 1){ | |
// $('.call-center-number').css('display','block'); | |
// xx = 1; | |
// } | |
// } | |
// }, 100); | |
// | |
// $(".phonecell").click(function(){ | |
// window.location.href="tel://09612484848"; | |
// }); | |
$("#phonecell").click(function(){ | |
window.location.href="tel://09612484848"; | |
}); | |
$("#livechat").click(function(){ | |
javascript:void(Tawk_API.toggle()) | |
}); | |
}); | |
$('.dropdown-toggle.link').on('click',function(){ | |
var href = $(this).attr('href'); | |
if(href != '#' || href != 'javascript:') { | |
window.location.href = href; | |
} | |
}); | |
// $(function(){ | |
// setInterval(function(){ | |
// $("[data-src]").each(function (i, e) { | |
// var src = $(this).attr('data-src'); | |
// if ($(this).attr('data-src')) { | |
// if(isElementInViewport($(this))) { | |
// $(this).attr('src', src); | |
// $(this).on('load', function () { | |
// $(this).removeClass('img-blur'); | |
// }); | |
// } | |
// | |
// } | |
// }); | |
// }, 1000); | |
// | |
// | |
// }); | |
function isElementInViewport (el) { | |
//special bonus for those using jQuery | |
if (typeof jQuery === "function" && el instanceof jQuery) { | |
el = el[0]; | |
} | |
var rect = el.getBoundingClientRect(); | |
return ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ | |
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ | |
); | |
} | |
function getTimeRemaining(endtime) { | |
var t = Date.parse(endtime) - Date.parse(new Date()); | |
var seconds = Math.floor((t / 1000) % 60); | |
var minutes = Math.floor((t / 1000 / 60) % 60); | |
var hours = Math.floor((t / (1000 * 60 * 60)) % 24); | |
var days = Math.floor(t / (1000 * 60 * 60 * 24)); | |
return { | |
'total': t, | |
'days': days, | |
'hours': hours, | |
'minutes': minutes, | |
'seconds': seconds | |
}; | |
} | |
function initializeClock(id, endtime) { | |
var clock = document.getElementById(id); | |
var hoursSpan = clock.querySelector('.hours'); | |
var minutesSpan = clock.querySelector('.minutes'); | |
var secondsSpan = clock.querySelector('.seconds'); | |
function updateClock() { | |
var t = getTimeRemaining(endtime); | |
hoursSpan.innerHTML = ('0' + t.hours).slice(-2); | |
minutesSpan.innerHTML = ('0' + t.minutes).slice(-2); | |
secondsSpan.innerHTML = ('0' + t.seconds).slice(-2); | |
if (t.total <= 0) { | |
clearInterval(timeinterval); | |
} | |
} | |
updateClock(); | |
var timeinterval = setInterval(updateClock, 1000); | |
} | |
$(".affix-head").affix({offset: {top: 27}}); | |
$(".affix-head").on('affix.bs.affix', function () { | |
$(".faded-bg").css("top", "114"); | |
}); | |
$(".affix-head").on('affix-top.bs.affix', function () { | |
$(".faded-bg").css("top", "149"); | |
}); | |
if ($(".affix-head").hasClass("affix")) { | |
$(".faded-bg").css("top", "114"); | |
} | |
$(".container, .faded-bg, .logoarea, .topbar").hover( | |
function () { | |
$(".white-bg,.faded-bg").stop(true, true).hide(); | |
} | |
); | |
function number_format(number, decimals, decPoint, thousandsSep) { | |
decimals = decimals || 0; | |
number = parseFloat(number); | |
if (!decPoint || !thousandsSep) { | |
decPoint = '.'; | |
thousandsSep = ','; | |
} | |
var roundedNumber = Math.round(Math.abs(number) * ('1e' + decimals)) + ''; | |
var numbersString = decimals ? roundedNumber.slice(0, decimals * -1) : roundedNumber; | |
var decimalsString = decimals ? roundedNumber.slice(decimals * -1) : ''; | |
var formattedNumber = ""; | |
while (numbersString.length > 3) { | |
formattedNumber += thousandsSep + numbersString.slice(-3) | |
numbersString = numbersString.slice(0, -3); | |
} | |
return (number < 0 ? '-' : '') + numbersString + formattedNumber + (decimalsString ? (decPoint + decimalsString) : ''); | |
} | |
function isNumber(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
$('#sendapplink').on('click', function () { | |
var number=$("#appnumber").val(); | |
if (number=="") { | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
} | |
else if (!isNumber(number)){ | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
} | |
else if (number.length!=11){ | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
}else{ | |
$(".appnumdiv").removeClass("has-error"); | |
$(".appnumerror").text(""); | |
$("#appnumber").prop("disable",true); | |
$("#sendapplink").text("Please wait...").prop("disable",true); | |
} | |
$.get("home/getTheApp?number="+number, function( data ) { | |
if (data=="SUCCESS") { | |
$("#appnumber").val("").prop("disable", false); | |
$("#sendapplink").text("Send me Link").prop("disable", false); | |
$('#gettheapp').modal('hide'); | |
alert("We have sent you an sms with app download link"); | |
} | |
}); | |
//console.log($("#appnumber").val()); | |
}); | |
function replaceImage(){ | |
} | |
// var imageLoaded = function(img,imgurl) { | |
// //console.log("HI IM LOADED"); | |
// //console.log(img + imgurl); | |
// //$(img).addClass('loaded'); | |
// $(img).attr("src",imgurl); | |
// | |
// } | |
//$('.image-blur').each(function(){ | |
// var img = $(this); | |
//$(img).wrap("<div class='div-blur'></div>"); | |
//var parentContainer = $(this).parent(); | |
//parentContainer.addClass('blurry-load-container'); | |
//img.addClass('img-blur'); | |
// var img = new Image(); | |
// img.src = imageContainer.attr('src'); | |
// | |
// //imageContainer | |
// | |
// | |
// var imgLarge = new Image(); | |
// imgLarge.src = imageContainer.attr('data-large'); | |
// | |
// imgLarge.onload = function () { | |
// console.info("Image loaded !"+imgLarge.src); | |
// //$(this).attr('src',imgLarge.src); | |
// //do something... | |
// } | |
// imgLarge.onerror = function () { | |
// console.error("Cannot load image"); | |
// //do something else... | |
// } | |
// var imgurl = img.attr("data-large"); | |
// var imgLarge = new Image(); | |
// imgLarge.onload = imageLoaded(img,imgurl); | |
// imgLarge.src = imgurl; | |
//}); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Modal Login | |
*/ | |
var loginParentDiv = $('.user-auth-section'); | |
var signInTitle = $('.sign-in-title').html(); | |
var signUpTitle = $('.sign-up-title').html(); | |
var signInForm = $('.lg-frm').html(); | |
var signUpForm = $('.signup-form').html(); | |
var resetForm = $('.reset-form').html(); | |
var place = $('.signup-form'); | |
$('body').on('click', '.sgn-in', function (e) { | |
e.preventDefault(); | |
$('.sgn-in').removeClass('hidden'); | |
place.html(signInForm); | |
$('.sign-up-title').html(signInTitle); | |
$('#signup').modal('show'); | |
}); | |
$('body').on('click', '.sgn-up', function (e) { | |
e.preventDefault(); | |
$('.sgn-in').removeClass('hidden'); | |
place.html(signUpForm); | |
$('.sign-up-title').html(signUpTitle); | |
$('.user-auth-section').on('input', '.m-num', function () { | |
$(this).val($(this).val().replace(/[^0-9]/g, '')); | |
}); | |
$("#signup").modal({ | |
backdrop: false | |
}); | |
}); | |
loginParentDiv.on('click', '.forgot-password', function (e) { | |
e.preventDefault(); | |
place.html(resetForm); | |
$('.user-auth-section').on('input', '.m-num', function () { | |
$(this).val($(this).val().replace(/[^0-9]/g, '')); | |
}); | |
$('#signup').modal('show'); | |
}); | |
$('body').on('click', '.cancel', function (e) { | |
e.preventDefault(); | |
place.html(signInForm); | |
}); | |
loginParentDiv.on('submit', '#loginForm', function (e) { | |
e.preventDefault(); | |
$('.signup-form').addClass('loading'); | |
var data = $(this).serializeArray(); | |
var url = $(this).attr('action'); | |
$.post(url, data).done(function (r) { | |
if (r[0] == 200) { | |
//console.log($.urlParam('redirect')); | |
if($.urlParam('redirect')==null) { | |
location.reload(); | |
}else{ | |
window.location = $.urlParam('redirect'); | |
} | |
} else { | |
$('.signup-form').removeClass('loading'); | |
$('#loginForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
}); | |
loginParentDiv.on('submit', '#signupForm', function (e) { | |
e.preventDefault(); | |
var url; | |
var data; | |
if ($('.step__1').hasClass('hidden')) { | |
data = $('.step__2').find(':input').serializeArray(); | |
url = 'authenticate/complete-signup'; | |
$('.signup-form').addClass('loading'); | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
$('.signup-form').removeClass('loading'); | |
location.reload(); | |
} else { | |
$('#signupForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
} else { | |
url = 'authenticate/signup'; | |
data = $('.step__1').find(':input').serializeArray(); | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
$('#signupForm .step__1').addClass('hidden'); | |
$('#signupForm .step__2').removeClass('hidden'); | |
$('#signup .sgn-in').addClass('hidden'); | |
$('#signupForm .message').html('A verification code sent to your mobile'); | |
clearMessage(); | |
} else { | |
$('#signupForm .message').html('<div class="alert alert-danger i_alert">' + r[1] + '</div>'); | |
} | |
}); | |
} | |
}); | |
loginParentDiv.on('submit', '#passwordResetForm', function (e) { | |
e.preventDefault(); | |
var data = $(this).serializeArray(); | |
var url = 'authenticate/request-new-password'; | |
$.post(url, data).done(function (r) { | |
$('.signup-form').removeClass('loading'); | |
if (r[0] == 200) { | |
place.html(signInForm); | |
$('#loginForm .message').html('<div class="alert alert-danger">A Temporary password is sent to your mobile</div>'); | |
//clearMessage(); | |
} else { | |
$('#passwordResetForm .message').html('<div class="alert alert-danger">' + r[1] + '</div>'); | |
} | |
}); | |
}); | |
var clearMessage = function () { | |
$('.user-auth-section .message').html(''); | |
}; | |
/******************** | |
* main Navbar | |
*******************/ | |
var timer; | |
var delay = 150; | |
var _ind = 0; | |
var _dropDown = $('li.dropdown'); | |
$(document).mouseup(function (e) { | |
var container = $("li.dropdown"); | |
if (!container.is(e.target) // if the target of the click isn't the container... | |
&& container.has(e.target).length === 0) // ... nor a descendant of the container | |
{ | |
$('.drop-icon').css('opacity', 0); | |
} | |
}); | |
_dropDown.on('click', function () { | |
$('li.dropdown').children('.drop-icon').css('opacity', 0); | |
$(this).children('.drop-icon').css('opacity', 1); | |
}); | |
_dropDown.hover(function() { | |
// on mouse in, start a timeout | |
_ind = $(this).index(); | |
timer = setTimeout(function() { | |
// console.log(_ind); | |
_dropDown.children('.dropdown-menu').eq(_ind).fadeIn(); | |
_dropDown.children('.drop-icon').eq(_ind).css('opacity', 1); | |
_dropDown.children('a').eq(_ind).addClass('orange'); | |
$(".mainnav").css("border-bottom", "1px solid #EAEAEA"); | |
$(".white-bg,.faded-bg").stop(true, true).fadeIn(); | |
$('body').addClass('no-scroll'); | |
}, delay); | |
}, function() { | |
// on mouse out, cancel the timer | |
clearTimeout(timer); | |
_dropDown.children('.dropdown-menu').hide(); | |
_dropDown.children('.drop-icon').css('opacity', 0); | |
_dropDown.children('a').removeClass('orange'); | |
$(".mainnav").css("border-bottom", "1px solid #fff"); | |
$(".white-bg,.faded-bg").stop(true, true).hide(); | |
$('body').removeClass('no-scroll'); | |
}); | |
/** | |
* Other js | |
*/ | |
$(function () { | |
$.get('shopping/cart-count').done(function (r) { | |
$('.cart-count').text(r); | |
}); | |
$('.b-logo-list').load('content/menu-brand'); | |
$('.b-logo-list-all').load('content/menu-all-brand'); | |
}); | |
//$('#mainSearch').on('input', function (e) { | |
// if(e.keyCode != 40 && e.keyCode != 38) { | |
// var keyword = $(this).val(); | |
// if (keyword.trim() != '') { | |
// keyword = encodeURI(keyword); | |
// $('search-list').html('<div class="s__list"><div class="__p loading"></div></div>'); | |
// $('search-list').load('search?query=' + keyword, function () { | |
//$('search-list').removeClass('loading'); | |
//$('.__p').eq(0).addClass('h-light'); | |
//upDown(); | |
//}); | |
//} else { | |
// $('search-list').html(''); | |
//} | |
//} | |
//}); | |
var delayTimer=100; | |
//var src = $('#mainSearch'); | |
$('#mainSearch').on('input', function (e) { | |
clearTimeout(delayTimer); | |
$('search-list').html('<div class="s__list"><div class="__p loading"></div></div>'); | |
delayTimer = setTimeout(function () { | |
if(e.keyCode != 40 && e.keyCode != 38) { | |
var keyword = $('#mainSearch').val(); | |
//console.log($('#mainSearch').val()); | |
if (keyword.trim() != '') { | |
keyword = encodeURI(keyword); | |
$('search-list').load('ajax-search?q=' + keyword, function () { | |
}); | |
} else { | |
$('search-list').html(''); | |
} | |
} | |
}, 100); | |
}); | |
var set_search_text = function(text){ | |
$('#mainSearch').val(text.trim()); | |
}; | |
var upDown = function(){ | |
$(document).keyup(function(e) { | |
//console.log(e.keyCode); | |
var current = $('.__p.h-light'), list = $('.__p'),ind = current.index(); | |
console.log(ind); | |
if (e.keyCode === 40) { | |
current.removeClass('h-light'); | |
list.eq(ind+1).addClass('h-light'); | |
set_search_text($('.__p.h-light').find('a').text()); | |
if (list.eq(ind+1).length == 0) { | |
list.eq(0).addClass('h-light'); | |
set_search_text($('.__p.h-light').find('a').text()); | |
//return; | |
} | |
} else if (e.keyCode === 38) { | |
current.removeClass('h-light'); | |
if (list.eq(ind-1).length == 0) { | |
list.eq(0).addClass('h-light'); | |
}else{ | |
list.eq(ind-1).addClass('h-light'); | |
} | |
} | |
}) | |
} | |
/* | |
wishlist | |
*/ | |
//$('.my-wishlist').on('click',function(e){ | |
// e.preventDefault(); | |
// if($(this).hasClass('auth-user')){ | |
// var url = $(this).attr('href'); | |
// window.location = url; | |
// }else{ | |
// $('.sgn-in').trigger('click'); | |
// history.pushState(null,null,'?redirect=my-wishlist') | |
// } | |
//}); | |
$.urlParam = function(name){ | |
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); | |
if (results==null){ | |
return null; | |
}else{ | |
return results[1] || 0; | |
} | |
}; | |
$('.guest-user').on('click',function(e){ | |
e.preventDefault(); | |
var url = $(this).attr('href'); | |
history.pushState(null,null,'?redirect='+url); | |
$('.sgn-in').trigger('click'); | |
}); | |
$('#signup').on('hide.bs.modal', function (e) { | |
history.replaceState(null,null,'/'); | |
}); | |
// web notification | |
document.addEventListener('DOMContentLoaded', function () { | |
if (!Notification) { | |
alert('Desktop notifications not available in your browser. Try Chromium.'); | |
return; | |
} | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
}); | |
//var pusher = new Pusher('5340812be854f4873b44', { | |
// encrypted: true | |
//}); | |
//var channel = pusher.subscribe('itb-chn'); | |
// | |
//channel.bind('itb-evt', function(data) { | |
// webNotify(data.url,data.title,data.body); | |
//}); | |
var webNotify = function(url,title,body){ | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
else { | |
var notification = new Notification(title, { | |
icon: 'https://www.itbazaar.com.bd/public/assets/sq_itbazaar.png', | |
body: body | |
}); | |
notification.onclick = function () { | |
window.open(url); | |
}; | |
} | |
}; | |
$('.search-btn').on('click',function(){ | |
if($('.s__list .__p strong a').length){ | |
window.location = $('.s__list .__p strong a').eq(0).attr('href'); | |
} | |
}); | |
$(function(){ | |
$('.message-box').delay(3000).fadeOut(); | |
}); | |
$(document).click(function(event) { | |
if(!$(event.target).closest('#mainSearch').length) { | |
$('.s__list').css('display','none'); | |
} | |
}); | |
$('.subscription-form').on('submit',function(){ | |
var e = $('.subscription-form .email').val(); | |
if(e.trim() == ''){ | |
$('span.req').text('The Email is required'); | |
}else{ | |
e = e.trim(); | |
$.post('home/subscription',{email:e}).done(function(r){ | |
if(r==1){ | |
$('span.req').text('Thank you for Subscription'); | |
} | |
if(r==2){ | |
$('span.req').text('This email already Subscribed'); | |
} | |
}); | |
//console.log(e.trim()); | |
} | |
}); | |
$(function(){ | |
//var xx=0; | |
//setInterval(function(){ | |
// if(xx==0){ | |
// console.log($('#intercom-container').length); | |
// if($('#intercom-container').length == 1){ | |
// $('.call-center-number').css('display','block'); | |
// xx = 1; | |
// } | |
// } | |
// }, 100); | |
// | |
// $(".phonecell").click(function(){ | |
// window.location.href="tel://09612484848"; | |
// }); | |
$("#phonecell").click(function(){ | |
window.location.href="tel://09612484848"; | |
}); | |
$("#livechat").click(function(){ | |
javascript:void(Tawk_API.toggle()) | |
}); | |
}); | |
$('.dropdown-toggle.link').on('click',function(){ | |
var href = $(this).attr('href'); | |
if(href != '#' || href != 'javascript:') { | |
window.location.href = href; | |
} | |
}); | |
// $(function(){ | |
// setInterval(function(){ | |
// $("[data-src]").each(function (i, e) { | |
// var src = $(this).attr('data-src'); | |
// if ($(this).attr('data-src')) { | |
// if(isElementInViewport($(this))) { | |
// $(this).attr('src', src); | |
// $(this).on('load', function () { | |
// $(this).removeClass('img-blur'); | |
// }); | |
// } | |
// | |
// } | |
// }); | |
// }, 1000); | |
// | |
// | |
// }); | |
function isElementInViewport (el) { | |
//special bonus for those using jQuery | |
if (typeof jQuery === "function" && el instanceof jQuery) { | |
el = el[0]; | |
} | |
var rect = el.getBoundingClientRect(); | |
return ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ | |
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ | |
); | |
} | |
function getTimeRemaining(endtime) { | |
var t = Date.parse(endtime) - Date.parse(new Date()); | |
var seconds = Math.floor((t / 1000) % 60); | |
var minutes = Math.floor((t / 1000 / 60) % 60); | |
var hours = Math.floor((t / (1000 * 60 * 60)) % 24); | |
var days = Math.floor(t / (1000 * 60 * 60 * 24)); | |
return { | |
'total': t, | |
'days': days, | |
'hours': hours, | |
'minutes': minutes, | |
'seconds': seconds | |
}; | |
} | |
function initializeClock(id, endtime) { | |
var clock = document.getElementById(id); | |
var hoursSpan = clock.querySelector('.hours'); | |
var minutesSpan = clock.querySelector('.minutes'); | |
var secondsSpan = clock.querySelector('.seconds'); | |
function updateClock() { | |
var t = getTimeRemaining(endtime); | |
hoursSpan.innerHTML = ('0' + t.hours).slice(-2); | |
minutesSpan.innerHTML = ('0' + t.minutes).slice(-2); | |
secondsSpan.innerHTML = ('0' + t.seconds).slice(-2); | |
if (t.total <= 0) { | |
clearInterval(timeinterval); | |
} | |
} | |
updateClock(); | |
var timeinterval = setInterval(updateClock, 1000); | |
} | |
$(".affix-head").affix({offset: {top: 27}}); | |
$(".affix-head").on('affix.bs.affix', function () { | |
$(".faded-bg").css("top", "114"); | |
}); | |
$(".affix-head").on('affix-top.bs.affix', function () { | |
$(".faded-bg").css("top", "149"); | |
}); | |
if ($(".affix-head").hasClass("affix")) { | |
$(".faded-bg").css("top", "114"); | |
} | |
$(".container, .faded-bg, .logoarea, .topbar").hover( | |
function () { | |
$(".white-bg,.faded-bg").stop(true, true).hide(); | |
} | |
); | |
function number_format(number, decimals, decPoint, thousandsSep) { | |
decimals = decimals || 0; | |
number = parseFloat(number); | |
if (!decPoint || !thousandsSep) { | |
decPoint = '.'; | |
thousandsSep = ','; | |
} | |
var roundedNumber = Math.round(Math.abs(number) * ('1e' + decimals)) + ''; | |
var numbersString = decimals ? roundedNumber.slice(0, decimals * -1) : roundedNumber; | |
var decimalsString = decimals ? roundedNumber.slice(decimals * -1) : ''; | |
var formattedNumber = ""; | |
while (numbersString.length > 3) { | |
formattedNumber += thousandsSep + numbersString.slice(-3) | |
numbersString = numbersString.slice(0, -3); | |
} | |
return (number < 0 ? '-' : '') + numbersString + formattedNumber + (decimalsString ? (decPoint + decimalsString) : ''); | |
} | |
function isNumber(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
$('#sendapplink').on('click', function () { | |
var number=$("#appnumber").val(); | |
if (number=="") { | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
} | |
else if (!isNumber(number)){ | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
} | |
else if (number.length!=11){ | |
$(".appnumdiv").addClass("has-error"); | |
$(".appnumerror").text("Please enter your valid mobile number."); | |
return false; | |
}else{ | |
$(".appnumdiv").removeClass("has-error"); | |
$(".appnumerror").text(""); | |
$("#appnumber").prop("disable",true); | |
$("#sendapplink").text("Please wait...").prop("disable",true); | |
} | |
$.get("home/getTheApp?number="+number, function( data ) { | |
if (data=="SUCCESS") { | |
$("#appnumber").val("").prop("disable", false); | |
$("#sendapplink").text("Send me Link").prop("disable", false); | |
$('#gettheapp').modal('hide'); | |
alert("We have sent you an sms with app download link"); | |
} | |
}); | |
//console.log($("#appnumber").val()); | |
}); | |
function replaceImage(){ | |
} | |
// var imageLoaded = function(img,imgurl) { | |
// //console.log("HI IM LOADED"); | |
// //console.log(img + imgurl); | |
// //$(img).addClass('loaded'); | |
// $(img).attr("src",imgurl); | |
// | |
// } | |
//$('.image-blur').each(function(){ | |
// var img = $(this); | |
//$(img).wrap("<div class='div-blur'></div>"); | |
//var parentContainer = $(this).parent(); | |
//parentContainer.addClass('blurry-load-container'); | |
//img.addClass('img-blur'); | |
// var img = new Image(); | |
// img.src = imageContainer.attr('src'); | |
// | |
// //imageContainer | |
// | |
// | |
// var imgLarge = new Image(); | |
// imgLarge.src = imageContainer.attr('data-large'); | |
// | |
// imgLarge.onload = function () { | |
// console.info("Image loaded !"+imgLarge.src); | |
// //$(this).attr('src',imgLarge.src); | |
// //do something... | |
// } | |
// imgLarge.onerror = function () { | |
// console.error("Cannot load image"); | |
// //do something else... | |
// } | |
// var imgurl = img.attr("data-large"); | |
// var imgLarge = new Image(); | |
// imgLarge.onload = imageLoaded(img,imgurl); | |
// imgLarge.src = imgurl; | |
//}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment