(function($){
$(function(){
$('.button-collapse').sideNav();
$('.parallax').parallax();
}); // end of document ready
})(jQuery); // end of jQuery name space
$(document).ready(function() {
$('select').material_select();
});
$('select').material_select('destroy');
$('.dropdown-button').dropdown({
inDuration: 300,
outDuration: 225,
constrain_width: false, // Does not change width of dropdown to that of the activator
hover: true, // Activate on hover
gutter: 0, // Spacing from edge
belowOrigin: false, // Displays dropdown below the button
alignment: 'left' // Displays dropdown with edge aligned to the left of button
}
);
$('.dropdown-button').dropdown('open');
$('.dropdown-button').dropdown('close');
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 50,
format: 'dd-mm-yyyy',
min: new Date(1960, 1, 1),
// `true` sets it to today. `false` removes any limits.
max: new Date(1998, 1, 1),
});
$('.datepickers').pickadate({
selectMonths: true,
selectYears: 50,
format: 'dd-mm-yyyy',
min: new Date(1960, 1, 1),
// `true` sets it to today. `false` removes any limits.
max: true,
});
(function () {
$('.carousel.carousel-slider')
.carousel({ full_width: true });
setInterval(function () {
$('.carousel').carousel('next');
}, 15000);
})();
/*------login form--------------------------------------------------*/
jQuery(document).ready(function($){
var formModal = $('.cd-user-modal'),
formLogin = formModal.find('#cd-login'),
formSignup = formModal.find('#cd-signup'),
formForgotPassword = formModal.find('#cd-reset-password'),
formModalTab = $('.cd-switcher'),
tabLogin = formModalTab.children('li').eq(0).children('a'),
tabSignup = formModalTab.children('li').eq(1).children('a'),
forgotPasswordLink = formLogin.find('.cd-form-bottom-message a'),
backToLoginLink = formForgotPassword.find('.cd-form-bottom-message a'),
mainNav = $('.navbar-nav,.loandetailsectls-favorites,.loandetailsectls-add,.reviewlogin,.sectls-favorites,.sectls-add,.sectls1-favorites,.sectls1-add,.msignbox');
//open modal
mainNav.on('click', function(event){
$(event.target).is(mainNav) && mainNav.children('ul').toggleClass('is-visible');
});
//open login-form form
mainNav.on('click', '.cd-signin', login_selected);
//close modal
formModal.on('click', function(event){
if( $(event.target).is(formModal) || $(event.target).is('.cd-close-form') ) {
formModal.removeClass('is-visible');
}
});
//close modal when clicking the esc keyboard button
$(document).keyup(function(event){
if(event.which=='27'){
formModal.removeClass('is-visible');
}
});
//switch from a tab to another
formModalTab.on('click', function(event) {
event.preventDefault();
( $(event.target).is( tabLogin ) ) ? login_selected() : signup_selected();
});
//hide or show password
$('.hide-password').on('click', function(){
var togglePass= $(this),
passwordField = togglePass.prev('input');
( 'password' == passwordField.attr('type') ) ? passwordField.attr('type', 'text') : passwordField.attr('type', 'password');
( 'Hide' == togglePass.text() ) ? togglePass.text('Show') : togglePass.text('Hide');
//focus and move cursor to the end of input field
passwordField.putCursorAtEnd();
});
//show forgot-password form
forgotPasswordLink.on('click', function(event){
event.preventDefault();
forgot_password_selected();
});
//back to login from the forgot-password form
backToLoginLink.on('click', function(event){
event.preventDefault();
login_selected();
});
function login_selected(){
mainNav.children('ul').removeClass('is-visible');
formModal.addClass('is-visible');
formLogin.addClass('is-selected');
formSignup.removeClass('is-selected');
formForgotPassword.removeClass('is-selected');
tabLogin.addClass('selected');
tabSignup.removeClass('selected');
}
function forgot_password_selected(){
formLogin.removeClass('is-selected');
formSignup.removeClass('is-selected');
formForgotPassword.addClass('is-selected');
}
//IE9 placeholder fallback
//credits http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html
if(!Modernizr.input.placeholder)
{
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.val(input.attr('placeholder'));
}
}).blur();
$('[placeholder]').parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
}
});
//credits http://css-tricks.com/snippets/jquery/move-cursor-to-end-of-textarea-or-input/
jQuery.fn.putCursorAtEnd = function() {
return this.each(function() {
// If this function exists...
if (this.setSelectionRange) {
// ... then use it (Doesn't work in IE)
// Double the length because Opera is inconsistent about whether a carriage return is one character or two. Sigh.
var len = $(this).val().length * 2;
this.focus();
this.setSelectionRange(len, len);
} else {
// ... otherwise replace the contents with itself
// (Doesn't work in Google Chrome)
$(this).val($(this).val());
}
});
};
$(document).ready(function(){
$('.tooltipped').tooltip({delay: 50});
});
jQuery(document).ready(function($){
// browser window scroll (in pixels) after which the "back to top" link is shown
var offset = 300,
//browser window scroll (in pixels) after which the "back to top" link opacity is reduced
offset_opacity = 1200,
//duration of the top scrolling animation (in ms)
scroll_top_duration = 800,
//grab the "back to top" link
$back_to_top = $('.cd-top');
//hide or show the "back to top" link
$(window).scroll(function(){
( $(this).scrollTop() > offset ) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
if( $(this).scrollTop() > offset_opacity ) {
$back_to_top.addClass('cd-fade-out');
}
});
//smooth scroll to top
$back_to_top.on('click', function(event){
event.preventDefault();
$('body,html').animate({
scrollTop: 0 ,
}, scroll_top_duration
);
});
});
$(document).ready(function(){
$('.collapsible').collapsible();
});
/**
* nlform.js v1.0.0
* http://www.codrops.com
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2013, Codrops
* http://www.codrops.com
*/
;( function( window ) {
'use strict';
var document = window.document;
if (!String.prototype.trim) {
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};
}
function NLForm( el ) {
this.el = el;
this.overlay = this.el.querySelector( '.nl-overlay' );
this.fields = [];
this.fldOpen = -1;
this._init();
}
NLForm.prototype = {
_init : function() {
var self = this;
Array.prototype.slice.call( this.el.querySelectorAll( 'select' ) ).forEach( function( el, i ) {
self.fldOpen++;
self.fields.push( new NLField( self, el, 'dropdown', self.fldOpen ) );
} );
Array.prototype.slice.call( this.el.querySelectorAll( 'input' ) ).forEach( function( el, i ) {
self.fldOpen++;
self.fields.push( new NLField( self, el, 'input', self.fldOpen ) );
} );
this.overlay.addEventListener( 'click', function(ev) { self._closeFlds(); } );
this.overlay.addEventListener('touchstart', function (ev) { self._closeFlds(); });
//this.overlay.addEventListener('blur', function (ev) { alert('hi'); });
},
_closeFlds : function() {
if( this.fldOpen !== -1 ) {
this.fields[ this.fldOpen ].close();
}
}
}
function NLField( form, el, type, idx ) {
this.form = form;
this.elOriginal = el;
this.pos = idx;
this.type = type;
this._create();
this._initEvents();
}
NLField.prototype = {
_create : function() {
if( this.type === 'dropdown' ) {
this._createDropDown();
}
else if( this.type === 'input' ) {
this._createInput();
}
},
_createDropDown : function() {
var self = this;
this.fld = document.createElement( 'div' );
this.fld.className = 'nl-field nl-dd';
this.toggle = document.createElement( 'a' );
this.toggle.innerHTML = this.elOriginal.options[ this.elOriginal.selectedIndex ].innerHTML;
this.toggle.className = 'nl-field-toggle';
this.optionsList = document.createElement( 'ul' );
var ihtml = '';
Array.prototype.slice.call( this.elOriginal.querySelectorAll( 'option' ) ).forEach( function( el, i ) {
ihtml += self.elOriginal.selectedIndex === i ? '
' + el.innerHTML + '' : '' + el.innerHTML + '';
// selected index value
if( self.elOriginal.selectedIndex === i ) {
self.selectedIdx = i;
}
} );
this.optionsList.innerHTML = ihtml;
this.fld.appendChild( this.toggle );
this.fld.appendChild( this.optionsList );
this.elOriginal.parentNode.insertBefore( this.fld, this.elOriginal );
this.elOriginal.style.display = 'none';
},
_createInput : function() {
var self = this;
this.fld = document.createElement( 'div' );
this.fld.className = 'nl-field nl-ti-text';
this.toggle = document.createElement( 'a' );
this.toggle.innerHTML = this.elOriginal.getAttribute( 'placeholder' );
this.toggle.className = 'nl-field-toggle';
this.optionsList = document.createElement( 'ul' );
this.getinput = document.createElement( 'input' );
this.getinput.setAttribute( 'type', 'text','number' );
this.getinput.setAttribute('placeholder', this.elOriginal.getAttribute('placeholder'));
this.getinput.setAttribute('list', this.elOriginal.getAttribute('list'));
this.getinput.setAttribute('autofocus', "autofocus");
this.getinputWrapper = document.createElement( 'li' );
this.getinputWrapper.className = 'nl-ti-input';
this.inputsubmit = document.createElement( 'button') ;
this.inputsubmit.className = 'nl-field-go';
this.inputsubmit.innerHTML = '';
this.getinputWrapper.appendChild( this.getinput );
this.getinputWrapper.appendChild( this.inputsubmit );
this.example = document.createElement( 'li' );
this.example.className = 'nl-ti-example';
this.example.innerHTML = this.elOriginal.getAttribute( 'data-subline' );
this.optionsList.appendChild( this.getinputWrapper );
this.optionsList.appendChild( this.example );
this.fld.appendChild( this.toggle );
this.fld.appendChild( this.optionsList );
this.elOriginal.parentNode.insertBefore( this.fld, this.elOriginal );
this.elOriginal.style.display = 'none';
},
_initEvents : function() {
var self = this;
this.toggle.addEventListener( 'click', function( ev ) { ev.preventDefault(); ev.stopPropagation(); self._open(); } );
this.toggle.addEventListener( 'touchstart', function( ev ) { ev.preventDefault(); ev.stopPropagation(); self._open(); } );
if( this.type === 'dropdown' ) {
var opts = Array.prototype.slice.call( this.optionsList.querySelectorAll( 'li' ) );
opts.forEach( function( el, i ) {
el.addEventListener('click', function (ev) { ev.preventDefault(); getBankInfoData(); self.close(el, opts.indexOf(el)); });
el.addEventListener( 'touchstart', function( ev ) { ev.preventDefault(); self.close( el, opts.indexOf( el ) ); } );
} );
}
else if( this.type === 'input' ) {
this.getinput.addEventListener('keydown', function (ev) {
if (ev.keyCode == 13) {
getBankInfoData();
self.close();
}
});
this.getinput.addEventListener('keyup', function (ev) {
if (this.value.length > 0) {
getAutoPredictData(this.value);
}
});
this.inputsubmit.addEventListener('click', function (ev) { ev.preventDefault(); self.close(); });
this.inputsubmit.addEventListener('touchstart', function (ev) { ev.preventDefault(); self.close(); });
this.inputsubmit.addEventListener('blur', function (ev) { getBankInfoData(); });
}
},
_open : function() {
if( this.open ) {
return false;
}
this.open = true;
this.form.fldOpen = this.pos;
var self = this;
this.fld.className += ' nl-field-open';
//if (this.getinput.value.trim() == '') {
// this.getinput.value = this.getinput.getAttribute('placeholder');
// this.elOriginal.value = this.getinput.value;
//}
},
close : function( opt, idx ) {
if( !this.open ) {
return false;
}
this.open = false;
this.form.fldOpen = -1;
this.fld.className = this.fld.className.replace(/\b nl-field-open\b/,'');
if( this.type === 'dropdown' ) {
if( opt ) {
// remove class nl-dd-checked from previous option
var selectedopt = this.optionsList.children[ this.selectedIdx ];
selectedopt.className = '';
opt.className = 'nl-dd-checked';
this.toggle.innerHTML = opt.innerHTML;
// update selected index value
this.selectedIdx = idx;
// update original select element´s value
this.elOriginal.value = this.elOriginal.children[ this.selectedIdx ].value;
}
}
else if (this.type === 'input') {
//alert(this.getinput);
//alert(this.getinput.value);
//alert(this.toggle.innerHTML);
//alert(this.elOriginal.value);
//alert(this.getinput.getAttribute('placeholder'));
if (this.getinput.value.trim() == '') {
this.getinput.value = this.getinput.getAttribute('placeholder');
}
this.toggle.innerHTML = this.getinput.value.trim() !== '' ? this.getinput.value : this.getinput.getAttribute('placeholder');
this.elOriginal.value = this.getinput.value;
}
}
}
// add to global namespace
window.NLForm = NLForm;
} )( window );
$(document).ready(function(){
$('ul.tabs').tabs();
});
/* $(function() {
$('input.autocomplete').autocomplete({
data: {
"10 + 2": null,"10th Pass": null,"7th Pass": null,"8th Pass": null,"Agricultural Sciences": null,"Architecture": null,"B.E": null,"B.Ed": null,"B.Sc": null,"B.Tech": null,"BA": null,"Bachelor in Optometry": null,"Bachelor in Psychology": null,"Bachelor of Ayurvedic Medicine and Surgery – BAMS": null,"Bachelor of Fire Engineering": null,"Bachelor of Homoeopathic Medicine and Surgery (BHMS)": null,"Bachelor of Law": null,"BCA": null,"BSW": null,"CA": null,"CAIIB": null,"Chemical/Refinery and Petrochemical Engineering": null,
"Computer Programming": null,"Degree in Aeronautical Engineering": null,"Degree in Biotechnology": null,"Degree in Chemistry": null,"Degree in Fishery Science": null,"Degree in Guitar": null,"Degree in Harmonium": null,"Degree in Home Science": null,
"Degree in Library Science": null,"Degree in Mandolin": null,"Degree in Nutrition": null,"Degree in Physiotherapy": null,"Degree in Synthesizer": null,"Dental Studies": null,"Diploma in Agriculture": null,"Diploma in Catering": null,"Diploma in Civil Engineering": null,
"Diploma in Conservation": null,"Diploma in Electrical Communication": null,"Diploma in Electronic Communication": null,"Diploma in Engineering": null,"Diploma in Engineering": null,"Diploma in Film and Video Editing": null,"Diploma in Finance and Accounts": null,
"Diploma in Mechanical or Electrical Engineering": null,"Diploma in Nursing": null,"Diploma in Surveying": null,"Diploma in Telecommunication": null,"Diploma in Thermal Power Plant Engineering": null,"Diploma in TV/Radio Production": null,"DM": null,
"DNB": null,"Electrical Engineering": null,"Graduate": null,"ICAI": null,"ICWA": null,"ITI": null,"LLB": null,"M. Phil in Physical Education": null,"M.B.B.S": null,"M.Ch": null,
}
});
}); */
// Pushpin Demo Init
if ($('.pushpin-demo-nav').length) {
$('.pushpin-demo-nav').each(function() {
var $this = $(this);
var $target = $('#' + $(this).attr('data-target'));
$this.pushpin({
top: $target.offset().top,
bottom: $target.offset().top + $target.outerHeight() - $this.height()
});
});
}
// BuySellAds Detection
var $bsa = $(".buysellads"),
$timesToCheck = 3;
function checkForChanges() {
if (!$bsa.find('#carbonads').length) {
$timesToCheck -= 1;
if ($timesToCheck >= 0) {
setTimeout(checkForChanges, 100);
}
else {
var notifiAd = $('');
$bsa.append(notifiAd);
}
}
}
checkForChanges();
// BuySellAds Demos close button.
$('.buysellads.buysellads-demo .close').on('click', function() {
$(this).parent().remove();
});
//-------- TIMELINE---------------------------------------
jQuery(document).ready(function($){
var timelineBlocks = $('.cd-timeline-block'),
offset = 0.8;
//hide timeline blocks which are outside the viewport
hideBlocks(timelineBlocks, offset);
//on scolling, show/animate timeline blocks when enter the viewport
$(window).on('scroll', function(){
(!window.requestAnimationFrame)
? setTimeout(function(){ showBlocks(timelineBlocks, offset); }, 100)
: window.requestAnimationFrame(function(){ showBlocks(timelineBlocks, offset); });
});
function hideBlocks(blocks, offset) {
blocks.each(function(){
( $(this).offset().top > $(window).scrollTop()+$(window).height()*offset ) && $(this).find('.cd-timeline-img, .cd-timeline-content').addClass('is-hidden');
});
}
function showBlocks(blocks, offset) {
blocks.each(function(){
( $(this).offset().top <= $(window).scrollTop()+$(window).height()*offset && $(this).find('.cd-timeline-img').hasClass('is-hidden') ) && $(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden').addClass('bounce-in');
});
}
});
$('.modal-trigger').leanModal({
dismissible: true, // Modal can be dismissed by clicking outside of the modal
opacity: .5, // Opacity of modal background
in_duration: 300, // Transition in duration
out_duration: 200, // Transition out duration
}
);
document.addEventListener("DOMContentLoaded", function(){
$('.preloader-background').delay(500).fadeOut('slow');
$('#loader-wrapper')
.delay(500)
.fadeOut();
});
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
});
/* jQuery Nice Select - v1.0
https://github.com/hernansartorio/jquery-nice-select
Made by Hernán Sartorio */
!function (e) { e.fn.niceSelect = function (t) { function s(t) { t.after(e("").addClass("nice-select").addClass(t.attr("class") || "").addClass(t.attr("disabled") ? "disabled" : "").attr("tabindex", t.attr("disabled") ? null : "0").html('')); var s = t.next(), n = t.find("option"), i = t.find("option:selected"); s.find(".current").html(i.data("display") || i.text()), n.each(function (t) { var n = e(this), i = n.data("display"); s.find("ul").append(e("").attr("data-value", n.val()).attr("data-display", i || null).addClass("option" + (n.is(":selected") ? " selected" : "") + (n.is(":disabled") ? " disabled" : "")).html(n.text())) }) } if ("string" == typeof t) return "update" == t ? this.each(function () { var t = e(this), n = e(this).next(".nice-select"), i = n.hasClass("open"); n.length && (n.remove(), s(t), i && t.next().trigger("click")) }) : "destroy" == t ? (this.each(function () { var t = e(this), s = e(this).next(".nice-select"); s.length && (s.remove(), t.css("display", "")) }), 0 == e(".nice-select").length && e(document).off(".nice_select")) : console.log('Method "' + t + '" does not exist.'), this; this.hide(), this.each(function () { var t = e(this); t.next().hasClass("nice-select") || s(t) }), e(document).off(".nice_select"), e(document).on("click.nice_select", ".nice-select", function (t) { var s = e(this); e(".nice-select").not(s).removeClass("open"), s.toggleClass("open"), s.hasClass("open") ? (s.find(".option"), s.find(".focus").removeClass("focus"), s.find(".selected").addClass("focus")) : s.focus() }), e(document).on("click.nice_select", function (t) { 0 === e(t.target).closest(".nice-select").length && e(".nice-select").removeClass("open").find(".option") }), e(document).on("click.nice_select", ".nice-select .option:not(.disabled)", function (t) { var s = e(this), n = s.closest(".nice-select"); n.find(".selected").removeClass("selected"), s.addClass("selected"); var i = s.data("display") || s.text(); n.find(".current").text(i), n.prev("select").val(s.data("value")).trigger("change") }), e(document).on("keydown.nice_select", ".nice-select", function (t) { var s = e(this), n = e(s.find(".focus") || s.find(".list .option.selected")); if (32 == t.keyCode || 13 == t.keyCode) return s.hasClass("open") ? n.trigger("click") : s.trigger("click"), !1; if (40 == t.keyCode) { if (s.hasClass("open")) { var i = n.nextAll(".option:not(.disabled)").first(); i.length > 0 && (s.find(".focus").removeClass("focus"), i.addClass("focus")) } else s.trigger("click"); return !1 } if (38 == t.keyCode) { if (s.hasClass("open")) { var l = n.prevAll(".option:not(.disabled)").first(); l.length > 0 && (s.find(".focus").removeClass("focus"), l.addClass("focus")) } else s.trigger("click"); return !1 } if (27 == t.keyCode) s.hasClass("open") && s.trigger("click"); else if (9 == t.keyCode && s.hasClass("open")) return !1 }); var n = document.createElement("a").style; return n.cssText = "pointer-events:auto", "auto" !== n.pointerEvents && e("html").addClass("no-csspointerevents"), this } }(jQuery);
/*
* File: jquery-selectify.js
* Version: 0.2
* Author: Vincent Keizer (www.vicreative.nl)
* Info: www.vicreative.nl/projects/selectify
*
* Copyright 2012-2013 Vincent Keizer, all rights reserved.
*
* Dual licensed under the MIT or GPL Version 2 licenses.
*
*/
(function ($) {
// Helper methods for selectify
var helper = {
checkText: function (select, text) {
// Checks if current text is still valid for keyboard input.
if (select.data("selectify").text == text) {
select.data("selectify").text = "";
}
}
};
// Events for selectify
var events = {
// Event fired when select element is activated.
activate: function (event) {
$(this).addClass("focus")
.unbind("keydown")
.keydown(function (e) {
switch (e.which) {
case 40:
var hover = $(this).find(".option.hover");
if (!hover.length) {
hover = $(this).find(".option.active");
}
var next = hover.next();
if (!next.length) {
next = $(this).find(".option:first");
}
$(this).trigger("select", next);
e.preventDefault();
return false;
case 38:
var hover = $(this).find(".option.hover");
if (!hover.length) {
hover = $(this).find(".option.active");
}
var prev = hover.prev();
if (!prev.length) {
prev = $(this).find(".option:last");
}
$(this).trigger("select", prev);
e.preventDefault();
return false;
case 13:
$(this).trigger("close");
break;
case 9:
$(this).trigger("removefocus");
break;
default:
var data = event.data.select.data("selectify");
var char = String.fromCharCode(e.which);
if (!char) {
data.text = "";
break;
}
var text = data.text || "";
text = text + char.toLowerCase();
data.text = text;
setTimeout(function () {
helper.checkText(event.data.select, text);
}, 1000);
var found = $(this).find(".option[data-text^='" + text + "']:first");
if (found.length) {
$(this).trigger("select", found);
}
break;
}
});
},
// Event fired when select receives focus.
focus: function (event) {
target = event.originalEvent ? event.originalEvent.explicitOriginalTarget || event.originalEvent.srcElement : null;
if ($(this).hasClass("focus") && $(this).hasClass("open")) {
return;
}
else if (!$(this).hasClass("open") && (target == null || !event.data.select.has($(target)))) {
$(this).trigger("open");
}
$(this).trigger("activate");
},
// Event fired when select loses focus.
blur: function (event) {
var select = $(this);
if (event.data && event.data.select) {
select = event.data.select;
}
if (select.hasClass("open")) {
select.removeClass("focus")
.trigger("close")
.unbind("keydown");
$(document).unbind("click", events.blur);
}
},
// Event fired when select is opened.
open: function (event) {
if (!$(this).hasClass("open"));
{
// IE 10 gives us problems when scrollbar is clicked, it sends an focusout event.
$(document).click({ select: $(this) }, events.blur);
event.preventDefault();
$(this).find(".options").slideDown("fast", function () {
$(this).parents(".selectify").addClass("open");
$(this).trigger("scrollTo", $(this).children(".option.active"));
});
return false;
}
},
// Event fired when select is closed.
close: function () {
if ($(this).hasClass("open"));
{
$(this).removeClass("open")
.find(".options").slideUp();
}
},
// Event fired when select is scrolled.
scroll: function (selector, element) {
if (!element || typeof element != "object" || !$(element).length) { return; }
var $element = $(element);
var currentPos = $(this).find(".options").scrollTop();
var selectedPos = $element.position().top + currentPos;
var containerHeight = $(this).find(".options").height();
if (selectedPos < currentPos) {
$(this).find(".options").scrollTop(selectedPos);
}
else if (selectedPos + $element.outerHeight() >= currentPos + containerHeight) {
$(this).find(".options").scrollTop(selectedPos - (containerHeight - $element.outerHeight()));
}
},
// Event fired when an option in select is selected.
select: function (event, selected) {
if (!selected) {
return;
}
if (typeof selected == "string") {
$(this).find(".option[data-id='" + selected + "']:not(.active)").click();
return;
}
if (typeof selected == "object") {
var $selected = $(selected);
var id = $selected.attr("data-id");
event.data.select.val(id);
$(this).find(".selected").attr("data-id", id)
.text($selected.text());
$(this).find(".option.active").removeClass("active");
$selected.addClass("active");
$(this).find(".option.hover").removeClass("hover");
$(this).trigger("scrollTo", $selected);
// Call change event on select to trigger other bound events.
event.data.select.change();
}
},
// Event fired when change event on original element is triggered.
change: function () {
$(this).data("selectify").selectify.trigger("select", $(this).val());
}
};
var methods = {
init: function (args) {
var settings = $.extend({
'maxItems': 10
}, args);
return $(this).each(function () {
var $this = $(this);
var data = $this.data('selectify');
// If the plugin hasn't been initialized yet
if (!data) {
var select = $('', {
"class": 'selectify',
"tabindex": "0"
}).bind("focus", { select: $this }, events.focus)
.bind("removefocus", events.blur)
.bind("close", events.close)
.bind("open", events.open)
.bind("scrollTo", events.scroll)
.bind("activate", { select: $this }, events.activate)
.bind("select", { select: $this }, events.select);
var options = $("", {
"class": 'options'
});
var selected = $("", {
"class": 'selected',
"data-id": $this.children(":selected").val(),
text: $this.children(":selected").text()
});
var header = $("", {
"class": "header",
click: function () {
if ($(this).parent().hasClass("open")
&& $(this).parent().hasClass("focus")) {
$(this).trigger("close");
}
else if (!$(this).parent().hasClass("focus")) {
$(this).trigger("activate");
}
else {
$(this).trigger("open");
}
},
mouseover: function () {
$(this).addClass("hover");
},
mouseout: function () {
$(this).removeClass("hover");
}
});
var icon = $("", {
"class": "icon"
});
$this.children().each(function () {
var option = $('', {
"class": "option",
"data-id": $(this).val(),
"data-text": $(this).text().toLowerCase(),
text: $(this).text(),
click: function () {
$(this).trigger("select", this)
.trigger("close");
},
mouseover: function () {
$(this).siblings().removeClass("hover");
$(this).addClass("hover");
},
mouseout: function () {
$(this).removeClass("hover");
}
});
options.append(option);
});
select.append(header.append(selected)
.append(icon))
.append(options);
$this.before(select);
var width = options.outerWidth() + icon.outerWidth();
options.width(width);
select.width(width);
options.css("max-height", settings.maxItems * options.children().outerHeight()).hide();
$this.data('selectify', {
target: $this,
selectify: select,
text: ""
}).change(events.change).hide();
}
});
},
destroy: function () {
return this.each(function () {
var $this = $(this),
data = $this.data('selectify');
if (data) {
$(window).unbind('.selectify');
data.selectify.remove();
$this.removeData('selectify')
.unbind("change", events.change)
.show();
}
});
},
open: function () {
return this.each(function () {
var data = $(this).data("selectify");
if (data) {
data.selectify.focus();
}
});
},
close: function () {
return this.each(function () {
var data = $(this).data('selectify');
if (data) {
data.selectify.trigger("removefocus");
}
});
},
update: function (content) {
return this.each(function () {
var data = $(this).data('selectify');
if (data) {
data.selectify.trigger("select", content);
}
});
}
};
$.fn.selectify = function (options) {
var method = options;
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.selectify');
}
};
})(jQuery);
(function ($) {
"use strict";
$.fn.ysExit = function (o) {
var $self = this;
var defaults = {
width: '60%', //popup width
height: '30%', //popup height
target: '#ys-container', //popup selector
cookieValidity: 1, //days
closeOnOutsideClick: true, //close popup if user clicks outside
delay: 0, //delay in ms until the popup is registered
debug: false, //if true, the cookie will not be set
cookieName: 'ysExit',
},
content = insertContent(),
options = fixOptions(o),
element = document.querySelector(options.target),
layer = document.querySelector('.ys-layer'),
closeBt = document.querySelector(options.target + ' .ys-popup-close'),
inner = document.querySelector(options.target + ' .ys-box'),
exitBt = document.querySelector(options.target + ' .ys-exit'),
//cookies management helper
cookies = {
set: function (name, value, days) {
var components = [name + '=' + value];
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 3600 * 1000));
components.push('expires=' + date.toGMTString());
}
components.push('path=/');
document.cookie = components.join('; ');
},
get: function (name) {
var start = name + '=',
arr = document.cookie.split(';'),
i;
for (i = 0; i < arr.length; i++) {
var item = arr[i].trim();
if (item.indexOf(start) === 0) {
return item.substring(start.length);
}
}
return null;
}
},
//the popup object
pop = {
active: false,
mouseLeftWindow: function (e) {
var from, to;
e = e ? e : window.event;
from = e.relatedTarget || e.toElement;
if (!from || from.nodeName === "HTML") {
pop.open();
}
},
setDimension: function (dimension, value) {
if (value.toString().indexOf('%') === -1) {
value = value + 'px';
}
inner.style[dimension] = value;
},
attachEvents: function () {
function close(e) {
pop.destroy();
e.preventDefault();
}
document.addEventListener('mouseout', pop.mouseLeftWindow, false);
closeBt.addEventListener('click', close);
if (exitBt) {
exitBt.addEventListener('click', close);
}
if (options.closeOnOutsideClick) {
element.addEventListener('click', close);
inner.addEventListener('click', function (e) {
e.stopPropagation();
});
}
this.active = true;
},
detachEvents: function () {
document.removeEventListener('mouseout', pop.mouseLeftWindow);
},
open: function () {
var self = this;
element.classList.add('visible');
layer.classList.add('visible');
self.detachEvents();
setTimeout(function () {
self.setDimension('width', options.width);
self.setDimension('height', 'auto');
}, 20);
setTimeout(function () {
element.classList.add('finished');
}, 200);
},
destroy: function () {
if (this.active) {
pop.detachEvents();
setTimeout(function () {
element.parentNode.removeChild(element);
layer.classList.remove('visible');
}, 200);
if (!options.debug) {
cookies.set(options.cookieName, 1, options.cookieValidity);
}
}
}
};
function insertContent() {
// console.log($self);
var body = $('body').append(' ');
$('.ys-popup-content').append($self[0].outerHTML);
$self.hide();
return true;
}
//helper functions
function fixOptions(options) {
var newOptions = {};
Object.keys(defaults).forEach(function (key) {
newOptions[key] = options.hasOwnProperty(key) ? options[key] : defaults[key];
});
return newOptions;
}
function delegate(obj, func) {
return function () {
func.apply(obj, arguments);
};
}
//start logic
if (!cookies.get(options.cookieName)) {
if (typeof options.delay !== 'number') {
throw new Error('options.delay must be a numeric value');
}
if (!element) {
throw new Error('Could not find element with selector: ' + options.target);
}
if (element.parentNode !== document.body) {
throw new Error(options.target + ' element must be placed directly inside of the element');
}
setTimeout(delegate(pop, pop.attachEvents), options.delay);
}
//return object with public interface
return {
open: delegate(pop, pop.open),
destroy: delegate(pop, pop.destroy),
getElement: function () {
return element;
}
};
};
})(jQuery);
//================================Home Exit===============================================
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory(require,exports,module);
} else {
root.ouibounce = factory();
}
}(this, function(require,exports,module) {
return function ouibounce(el, custom_config) {
"use strict";
var config = custom_config || {},
aggressive = config.aggressive || false,
sensitivity = setDefault(config.sensitivity, 20),
timer = setDefault(config.timer, 1000),
delay = setDefault(config.delay, 0),
callback = config.callback || function() {},
cookieExpire = setDefaultCookieExpire(config.cookieExpire) || '',
cookieDomain = config.cookieDomain ? ';domain=' + config.cookieDomain : '',
cookieName = config.cookieName ? config.cookieName : 'viewedOuibounceModal',
sitewide = config.sitewide === true ? ';path=/' : '',
_delayTimer = null,
_html = document.documentElement;
function setDefault(_property, _default) {
return typeof _property === 'undefined' ? _default : _property;
}
function setDefaultCookieExpire(days) {
// transform days to milliseconds
var ms = days*24*60*60*1000;
var date = new Date();
date.setTime(date.getTime() + ms);
return "; expires=" + date.toUTCString();
}
setTimeout(attachOuiBounce, timer);
function attachOuiBounce() {
if (isDisabled()) { return; }
_html.addEventListener('mouseleave', handleMouseleave);
_html.addEventListener('mouseenter', handleMouseenter);
_html.addEventListener('keydown', handleKeydown);
}
function handleMouseleave(e) {
if (e.clientY > sensitivity) { return; }
_delayTimer = setTimeout(fire, delay);
}
function handleMouseenter() {
if (_delayTimer) {
clearTimeout(_delayTimer);
_delayTimer = null;
}
}
var disableKeydown = false;
function handleKeydown(e) {
if (disableKeydown) { return; }
else if(!e.metaKey || e.keyCode !== 76) { return; }
disableKeydown = true;
_delayTimer = setTimeout(fire, delay);
}
function checkCookieValue(cookieName, value) {
return parseCookies()[cookieName] === value;
}
function parseCookies() {
// cookies are separated by '; '
var cookies = document.cookie.split('; ');
var ret = {};
for (var i = cookies.length - 1; i >= 0; i--) {
var el = cookies[i].split('=');
ret[el[0]] = el[1];
}
return ret;
}
function isDisabled() {
return checkCookieValue(cookieName, 'true') && !aggressive;
}
// You can use ouibounce without passing an element
// https://github.com/carlsednaoui/ouibounce/issues/30
function fire() {
if (isDisabled()) { return; }
if (el) { el.style.display = 'block'; }
callback();
disable();
}
function disable(custom_options) {
var options = custom_options || {};
// you can pass a specific cookie expiration when using the OuiBounce API
// ex: _ouiBounce.disable({ cookieExpire: 5 });
if (typeof options.cookieExpire !== 'undefined') {
cookieExpire = setDefaultCookieExpire(options.cookieExpire);
}
// you can pass use sitewide cookies too
// ex: _ouiBounce.disable({ cookieExpire: 5, sitewide: true });
if (options.sitewide === true) {
sitewide = ';path=/';
}
// you can pass a domain string when the cookie should be read subdomain-wise
// ex: _ouiBounce.disable({ cookieDomain: '.example.com' });
if (typeof options.cookieDomain !== 'undefined') {
cookieDomain = ';domain=' + options.cookieDomain;
}
if (typeof options.cookieName !== 'undefined') {
cookieName = options.cookieName;
}
document.cookie = cookieName + '=true' + cookieExpire + cookieDomain + sitewide;
// remove listeners
_html.removeEventListener('mouseleave', handleMouseleave);
_html.removeEventListener('mouseenter', handleMouseenter);
_html.removeEventListener('keydown', handleKeydown);
}
return {
fire: fire,
disable: disable,
isDisabled: isDisabled
};
}
/*exported ouibounce */
;
}));