/*
* Author: Matthijs Molhoek, 66Themes
* URL: http://themeforest.net/user/66themes
*
* Project Name: Coffea - Site Template
* Version: 1.0
* Date: 06-02-2014
* Last update: 06-02-2014
* URL: -
*/
(function () {
"use strict";
/*jslint browser:true*/
/*global $, jQuery, Spinner, google*/
$(document).ready(function () {
var free;
if (typeof isFree === 'undefined') free = 0;
else free = isFree;
if (free == 1 || free == true || free == 'true') {
window.intercomSettings = {
hide_default_launcher: true
};
$('.securly-free').show();
$('li.securly-free').css('display','inline-block');
$('.head-top').removeClass('move-down');
$('.on-boarding .box .questions.securly-free').css('display', 'inline-block');
$('.icon-que.securly-free').css('display','block');
$('.main-nav li.securly-free').css('display', 'inline-block')
$('.normal-securly').hide();
// For home page
$('#Parent-Reports .middle-row').addClass('brdr-btm-nn');
$('.hero-img').addClass('free-hero-img');
$('body').addClass('securly-free-pages');
$('.big-blue-button.btn-hero').on('click', function(e){
e.preventDefault();
window.location.href = '/app/try-securly-free'
})
}
$("body").css({visibility:'visible'});
var mainUrl = mainUrl || 'www.securly.com';
$('.inputLink').val( mainUrl + $('.inputLink').val());
/*$('#hero-para').parallax("50%", 0.22);*/
var wpOffset = 80,
$portfolioContainer = $('.portfolio-container'),
$articleContainer = $('.article-container'),
isMobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
/*Login functions for Parents*/
$("#parent-login").submit(function(e){
$('.pass-error').remove();
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$/;
if (re.test($('#login-password').val()) && e.target.checkValidity()) {
$.ajax({
type: "POST",
url: gUrlHome + "/_login.php",
data: {email: $('#cemail').val(), password: $('#login-password').val()},
dataType: JSON,
complete: function(xhr, textStatus){
if(xhr.status == 200) {
window.location.href="/app/#/";
} else if (xhr.status == 500) {
$("#normal-login h3").append('Inncorrect email or password');
} else if (xhr.status == 401) {
$("#normal-login h3").append('Inncorrect email or password');
}
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
} else if (!re.test($('#login-password').val())){
$('pass-error').remove();
$('#normal-login h3').append('Password or Username is invalid.');
}
return false;
});
$("#reset-login").submit(function(e){
$('.pass-error').remove();
if (e.target.checkValidity()) {
$.ajax({
type: "GET",
url: gUrlHome + "/_passwordReset?email=" + encodeURIComponent($('#reset-email').val()),
complete: function(xhr, textStatus){
if(xhr.status == 200) {
$('#reset-login').append('An email has been sent to ' + $('#reset-email').val() + '
Please click the link in that email to reset your password in the next 72 hours.
');
$('#reset-password-button').remove();
$('.reset-input').remove();
} else if (xhr.status == 500) {
$('#reset h3').append('This email is not registered.');
}
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
}
return false;
});
$("#reset-password").submit(function(e){
if ($('#confirm').val() != '') {
return false;
}
$('.pass-error').remove();
if($('#password-reset').val() != $('#password-reset-conf').val()) {
$('#reset-password').append('Password mismatch');
return false;
};
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$/;
if (re.test($('#password-reset').val()) && e.target.checkValidity()) {
var token = getUrlParameter('token');
if(!token) {
window.location.href="/app/#/";
}
$.ajax({
type: "POST",
url: gUrlHome + "/_passwordReset",
data: {password: $('#password-reset').val(), token: token},
complete: function(xhr, textStatus){
if(xhr.status == 200) {
/*go to login page*/
window.location.href="/app/#/";
/*document.getElementById('login-btn').click();*/
} else if (xhr.status == 500) {
$('.forgot-password').append('Inncorrect email or password');
}
},
success: function(xhr, textStatus){
//console.log(xhr, textStatus, 'status scuccs');
},
error: function(jqXHR, textStatus, errorThrown) {
}
});
} else if (!re.test($('#parent-password').val())){
$('#reset-password').append('Password must contain at least one capital and one lowercase letter along with a number.');
}
return false;
});
/*Signup functions for Parents*/
var d = new Date();
var tzOff = d.getTimezoneOffset();
/*$('#sign-up').submit(function(e){
if ($('#confirm').val() != '') {
return false;
}
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$/;
if (re.test($('#parent-password').val()) && e.target.checkValidity()) {
$.ajax({
type: "POST",
url: gUrlHome + "/_signupconsumer.php",
data: {email: $('#parent-email').val(), password: $('#parent-password').val(), tzOffset: tzOff, tzName: timezone.name()},
dataType: JSON,
complete: function(xhr, textStatus){
if(xhr.status == 200) {
window.location.href= '/app/#/';
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR, textStatus, errorThrown);
if(jqXHR.status == 409) {
$('.pass-error').remove();
$('#parent-signup-form .no-credit').append('This email is already registered.');
}
return false
}
});
} else if (!re.test($('#parent-password').val())){
$('.pass-error').remove();
$('#parent-signup-form .no-credit').append('Password must contain at least one capital and one lowercase letter along with a number.');
}
return false;
});*/
// Fade in body on page load (JS enabled only!)
$('body').addClass('loaded');
$('input').on('focus', function() {
$('.head-top').addClass('input-selected');
})
$('input').on('blur', function() {
$('.head-top').removeClass('input-selected');
})
//News and Events Tab
$('ul.tabs').each(function(){
var $active, $content, $links = $(this).find('a');
$active = $($links.filter('[href="'+location.hash+'"]')[0] || $links[0]);
$active.addClass('active');
$content = $($active[0].hash);
$links.not($active).each(function () {
$(this.hash).hide();
});
$(this).on('click', 'a', function(e){
$active.removeClass('active');
$content.hide();
$active = $(this);
$content = $(this.hash);
$active.addClass('active');
$content.show();
e.preventDefault();
});
});
$('input').blur( function() {
if ($(this).val().length != 0) {
$(this).addClass('white-input');
}
});
//Calculate Quote Functions
function calc () {
var undiscounted_price=6;
var seats= 0;
var seat_tiers=[500, 1000, 2500, 5000, 10000, 25000];
var discount_tiers=[0, .22, .39, .61, .58, .69];
var total_price=0;
var idx_seats, idx_tiers;
seats= $('.num-students').val();
if (seats >= 25001) {
$('.quote-parent').addClass('hidden');
$('.calculate-message').removeClass('hidden');
$('.calculate-message').html('Get in touch with sales@securly.com for a custom quote');
return;
}
for (idx_seats=1; idx_seats<=seats; idx_seats++)
{
for (idx_tiers=0; idx_tiers<6; idx_tiers++)
{
if (idx_seats<=seat_tiers[idx_tiers])
{
break;
}
}
total_price+=1*(1-discount_tiers[idx_tiers]) * undiscounted_price;
}
total_price=0.75*total_price; // (3-year plan) with 25% discount always to prevent people from getting scared
$('.calculate-message').addClass('hidden');
$('.quote-parent').removeClass('hidden');
if ((Math.round(total_price)) < 1200) {
total_price = 1200
}
$('.quote-price').text(Math.round(total_price));
};
$('.get-quote').on('click', function() {
calc();
});
//Show Take Home Checkboxes
$( ".th-check" ).change(function() {
var show = $('.take-home-options').css('display');
if (show == 'none') {
$('.take-home-options').show(200);
} else {
$('.take-home-options').hide(300);
}
});
//Show Hints
var timer;
$(".ipadd").on("mouseenter", function(){
timer = setTimeout(function () {
$(".ipadd + .bubble").removeClass("hidden");
}, 500);
}).on("mouseleave", function(){
clearTimeout(timer);
$(".bubble").addClass("hidden");
});
$(".sources").on("mouseenter", function(){
timer = setTimeout(function () {
$(".sources .bubble").removeClass("hidden");
}, 500);
}).on("mouseleave", function(){
clearTimeout(timer);
$(".bubble").addClass("hidden");
});
//Numeric
/*$('input.numeric').numeric();*/
// Init Superslides
$('#main-superslides').superslides({
play: 8000,
animation: 'fade',
slide_easing: 'easeInOutCubic',
slide_speed: 800,
pagination: true,
hashchange: false,
scrollable: true
});
$('#testimonial-superslides').superslides({
play: 8000,
animation: 'fade',
slide_easing: 'easeInOutCubic',
slide_speed: 800,
pagination: false,
hashchange: false,
scrollable: true
});
// POPUPs
$('#forgot-password').on('click', function() {
$('#normal-login').addClass('hidden');
$('#reset').removeClass('hidden');
});
$('#retun-login').on('click', function() {
$('#normal-login').removeClass('hidden');
$('#reset').addClass('hidden');
});
$('.popup-vimeo').magnificPopup({type:'iframe'});
$('#login-btn').magnificPopup({
items: {
src: '#login',
type: 'inline'
}
});
$('#parent-video-btn').magnificPopup({
items: {
src: '#parent-video',
type: 'inline'
}
});
$('.already').magnificPopup({
items: {
src: '#login',
type: 'inline'
}
});
$('.get-started-link').magnificPopup({
items: {
src: '#sign-up',
type: 'inline'
}
});
$('.get-started').magnificPopup({
items: {
src: '#sign-up',
type: 'inline'
}
});
$('.login-btn').on('click', function() {
$('.main-nav').removeClass('trigger-active');
});
//NEWSLETTER POPUP
$('.newsletter-btn').magnificPopup({
items: {
src: '#freetrial_inline',
type: 'inline'
}
});
//WHITE PAPER POPUP
$('.whitepaper-btn').magnificPopup({
items: {
src: '#whitepaper_inline',
type: 'inline'
}
});
//LEARN MORE POPUP
$('.learn-more-btn').magnificPopup({
items: {
src: '#learn-more-form',
type: 'inline'
}
});
// FORM VALIDATOR
/*$("form").validate();*/
// Shrink top bar size on scroll
function checkPosition() {
var targetOffset = $(".page-content").offset().top + 65,
topBar = $('.head-top');
if ($(window).scrollTop() > 0) {
topBar.addClass('shrink');
} else {
topBar.removeClass('shrink');
}
if ($(window).scrollTop() >= targetOffset) {
topBar.addClass('darken');
} else {
topBar.removeClass('darken');
}
}
var hasContent = $(".page-content").length;
if(hasContent>0){
checkPosition();
$(document).scroll(function () {
checkPosition();
});
}
// Toggle side-active class, show/hide meta menu
$(document).on("click", ".side-active .page-content, .side-active .page-top, body:not(.side-active) .side-meta, body:not(.side-active) .toggle-side, .close-side", function () {
$('body').toggleClass('side-active');
});
// Mobile: open menu on nav trigger tap
$(document).on("click", ".nav-trigger", function () {
$(this).toggleClass('active');
$('.main-nav').toggleClass('trigger-active');
});
$(document).on("click", "#login-btn", function () {
$(this).toggleClass('active');
$('.main-nav').toggleClass('trigger-active');
});
// Fluid embed heights
$("#main").fitVids();
// Vertical tabs move to tab content top on nav click
$(document).on("click", '.vertical-tabs .tab-nav a', function () {
$('html, body').stop(true, true).animate({
scrollTop: $(this).closest('.vertical-tabs').find('.tab-content').offset().top
}, 200);
});
// Main header enter button click, move wrap to top
$(document).on("click", ".to-top", function () {
$('html, body').animate({
scrollTop: 0
}, 1000);
return false;
});
// Init parallax effect on page header backgrounds
function initParallax() {
if (!isMobile) {
$('.page-head, .parallax').each(function () {
$(this).css('background-attachment', 'fixed').parallax("50%", 0.5, true);
});
}
}
initParallax();
// Create header top bar blur effect
function createHeaderBlur() {
var headImage = $('.page-head').css('background-image');
if (headImage !== undefined) {
$('.cssfilters .head-top').append('