'; }, 6000); } }, checkIosBgFix: function() { var pattern = /iPad|iPhone|iPod/; var iOS = pattern.test(navigator.platform); if(iOS) { var elements = base.getBySelector('.bg-fixed'); if(elements) { var length = elements.length; elements = (length)? elements : [elements]; for(var i = 0, maxLength = elements.length; i < maxLength; i++) { var element = elements[i]; base.addClass(element, 'ios-bg-fixed'); } } } } }) ); var lazyLoader; function setupLazyLoader() { return (lazyLoader = new LazyAnimator()); } window.checkLazyLoader = function() { if(lazyLoader) { lazyLoader.update(); } }; app.addModule(Module.extend( { setup: function() { this.setupLazyAnimations(); }, setupLazyAnimations: function() { this.lazyLoader = setupLazyLoader(); } }) ); app.addModule(Module.extend( { setup: function() { this.addVideos(); this.addDemos(); this.addMeeting(); }, foreach: function(attrName, callBack) { var elements = this.getByAttr(attrName); if(elements) { for(var i = 0, maxLength = elements.length; i < maxLength; i++) { var element = elements[i]; callBack.call(this, i, element); } } }, addVideos: function(attrName) { attrName = attrName || 'data-video'; this.foreach(attrName, function(index, element) { var src = base.attr(element, 'data-src'); if(src) { var title = base.attr(element, 'data-title'); var callBack = base.createCallBack(this, this.viewVideo, [title, src]); base.on('click', element, callBack); if(base.attr(element, 'data-autoplay')) { this.viewVideo(title, src); } } }); }, viewVideo: function(title, src) { var vid = { title: title, source: src }; var panel = new VideoModal(vid, '', document.body); panel.setup(); panel.display(); }, addDemos: function(attrName) { attrName = attrName || 'data-demo-request'; var callBack = base.bind(this, this.requestDemo); this.foreach(attrName, function(index, element) { base.on('click', element, callBack); }); }, requestDemo: function() { var location = app.location; var panel = new DemoRequestModal(location,'', document.body); panel.setup(); panel.display(); }, addMeeting: function(attrName) { attrName = attrName || 'data-join-me'; var self = this; this.foreach(attrName, function(index, element) { var type = base.data(element, 'data-type') || 'goto'; base.on('click', element, function(e) { if(e) { base.preventDefault(e); } self.createJoinMePanel(type); }); }); }, createJoinMePanel: function(type) { var panel = new JoinMeModal(type); panel.setup(); panel.display(); }, addBenefits: function(attrName) { attrName = attrName || 'data-benefits'; var callBack = base.bind(this, this.createBenefitsPanel); this.foreach(attrName, function(index, element) { base.on('click', element, callBack); }); }, createBenefitsPanel: function(e) { var panel = new BenefitsModal(); panel.setup(); panel.display(); } }) ); var TopButton = base.Component.extend( { getLayout: function() { return { node: 'button', className: 'bttn scroll-to-top', click: base.bind(this, this.scroll) }; }, scroll: function() { function scrollTop(element) { base.addAnimation({ duration: 200, element: element, property: 'scrollTop', endValue: 0 }); } scrollTop(document.body); scrollTop(document.documentElement); } }); var scrollTopModules = []; window.addScrollModule = function(module) { scrollTopModules.push(module); }; window.removeScrollModule = function(module) { var index = base.inArray(scrollTopModules, module); if(index > -1) { scrollTopModules.splice(index, 1); } }; var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame || function(callback){ setTimeout(callback, 0) }; app.addModule(Module.extend( { setup: function() { this.modules = scrollTopModules; this.addEvents(); this.checkScroll(); }, ticking: false, scroll: function(e) { if(!this.ticking) { var self = this; requestAnimationFrame(function() { self.checkScroll(e); self.ticking = false; }); this.ticking = true; } }, addEvents: function() { var self = this; base.on(['scroll', 'resize'], window, function(e) { self.scroll(e); }); }, updateModules: function(scrollTop) { var modules = this.modules; for(var i = 0, length = modules.length; i < length; i++) { var module = modules[i]; module.check(scrollTop); } }, checkScroll: function() { var scrollTop = window.scrollY; this.updateModules(scrollTop); } }) ); var ScrollModule = window.scrollModule = base.Class.extend( { check: function(scrollTop) { }, mobileSize: 840, isMobile: function() { var windowWidth = base.getWindowWidth(); if(typeof windowWidth !== 'undefined') { return (windowWidth > this.mobileSize)? false : true; } return false; } }); var ScrollHeader = ScrollModule.extend( { distance: 15, headerStyled: false, constructor: function(header, headerStyle) { ScrollModule.call(this); this.header = header; this.headerStyle = headerStyle || ''; }, check: function(scrollTop) { var headerDistance = this.distance, header = this.header; if(header) { if(scrollTop >= headerDistance && this.headerStyled === false) { base.addClass(header, 'overlay'); this.headerStyled = true; } else if(scrollTop < headerDistance && this.headerStyled !== false) { base.removeClass(header, 'overlay'); this.headerStyled = false; } } } }); var header = document.getElementById('main-header'); window.addScrollModule(new ScrollHeader(header, 'minimized')); var TopScroll = ScrollModule.extend( { distance: 300, constructor: function() { ScrollModule.call(this); this.createButton(); this.check(); }, createButton: function() { var button = this.button = new TopButton(document.body); button.setup(); }, buttonVisible: false, check: function(scrollTop) { var button = this.button.panel, isMobile = this.isMobile(); if(typeof button === 'undefined') { return true; } if(isMobile) { if(this.buttonVisible === true) { this.buttonVisible = false; base.animate.out(button, 'fadeOut', 800); } } else { if(scrollTop >= this.distance) { if(this.buttonVisible === false) { base.animate._in(button, 'fadeInSlow', 2000); this.buttonVisible = true; } } else { if(this.buttonVisible === true) { this.buttonVisible = false; base.animate.out(button, 'fadeOut', 800); } } } } }); window.addScrollModule(new TopScroll()); })(app); "use strict"; var Modal = base.Component.extend( { constructor: function(container) { base.Component.call(this, container); }, mainPanelClass: '', getLayout: function() { return { className: 'modal ' + this.mainPanelClass, header: this.addHeader(), body: this.addBody(), footer: this.addFooter() }; }, addHeader: function() { return { className: 'title-container', title: { className: 'title title-text left dark', textContent: this.getTitle() } }; }, getTitle: function() { return ''; }, addBody: function() { return this.cache('mainContainer', { className: 'body-container', content: this.addBodyContent() }); }, addBodyContent: function() { return { }; }, addFooter: function() { return { className: 'button-container', children: this.addFooterButtons() }; }, addFooterButton: function(label, className, callBack) { return { node: 'button', textContent: label, className: 'bttn ' + className, click: callBack }; }, addFooterButtons: function() { return [ this.addFooterButton('Close', 'bttn-decline', base.bind(this, this.decline)) ]; }, addRow: function(label, model, prop, validate) { var layout = { className: 'list-row light left' }; if(this.usePlaceholders !== true) { layout.label = { node: 'label', textContent: label }; label = ''; } layout.field = this.addInput(label, 'text', model, prop, validate); return layout; }, addInput: function(placeholder, type, model, prop, validate) { var className = (validate == true)? 'val' : ''; var layout = { node: 'input', type: type, className: className }; if(this.usePlaceholders && placeholder) { layout.placeholder = placeholder; } if(model) { this.bindLayout(layout, model, prop); } return layout; }, bindLayout: function(layout, model, prop) { var id = this.getId(base.uncamelCase(prop, '-')); layout.id = id; layout.bind = this.bind(model, prop); }, confirmAction: function() { var settings = this.validate(); if(settings.status === true) { var mpalert = new Alert('confirm', 'Confirm Action', 'Do you want to submit this request?', base.bind(this, this.accept)); mpalert.start(); } else { var mpalert = new Alert('alert', 'Error', 'The following corrections need to be made before saving.
' + settings.message); mpalert.start(); } }, validateForm: function() { var id = this.id; var form = this.form; if(form) { return base.formValidator.validateForm(form, id); } return false; }, validate: function() { var response = { status: true, message: '', error: 'no' }; var result = this.validateForm(); if(result && result.number !== 0) { response.status = false; response.message = result.message; } return response; }, returnCallBack: function(data) { var callBack = this.callBackFn; if(typeof this.callBackFn === 'function') { callBack(data); } }, removeAndCallBack: function(data) { this.returnCallBack(data); window.setTimeout(base.bind(this, this.display), 200); }, accept: function() { this.removeAndCallBack(); }, decline: function() { this.display(); }, display: function() { this.toggleDisplay(); }, backdropClassName: '', addBackdrop: function() { var callBack = base.bind(this, this.decline); var backdrop = this.backdrop = new BackdropPanel(this.backdropClassName, callBack, this.container); backdrop.setup(); }, toggleMode: 'none', toggleDisplay: function() { var obj = this.panel, display = obj.style.display; if(!display || display === 'none') { obj.style.display = 'block'; this.toggleMode = 'block'; this.addBackdrop(); base.addClass(document.body.parentElement, 'locked'); } else { obj.style.display = 'none'; this.toggleMode = 'none'; this.backdrop.destroy(); this.destroy(); base.removeClass(document.body.parentElement, 'locked'); } } }); "use strict"; var JoinMeModal = Modal.extend( { constructor: function(type, callBackFn) { Modal.call(this, document.body); this.response = null; this.type = type; this.callBackFn = callBackFn; }, setup: function() { this.initialize(); this.meetingNumber.focus(); }, getLayout: function() { return { className: 'alert join-me-panel floatDownZ', header: this.addHeader(), body: this.addBody(), footer: this.addFooter() }; }, addHeader: function() { return { node: 'header', className: 'title-container', h2: { className: 'title left dark title-text', textContent: 'Join a ' + (this.getTypeLabel()) + ' Meeting' } }; }, addBody: function() { var callBack = base.bind(this, this.formatNumber); return { className: 'description center dark', groupPanel: { className: 'group-panel', row: { className: 'dark', label: { node: 'label', className: 'right', textContent: '9 Digit Code' }, field: this.cache('meetingNumber', { node: 'input', type: 'text', className: 'center', textContent: '9 Digit Code', keyup: callBack, blur: callBack }) } } }; }, addFooter: function() { var self = this; return { node: 'footer', className: 'buttons', align: { className: 'button-group', children: [ this.addFooterButton('Cancel', 'bttn-decline', function(){self.changeResponse(false);}), this.addFooterButton('Submit', 'bttn-approve', function(){self.changeResponse(true);}) ] } }; }, getResponse: function() { return this.response; }, updateResponse: function(tmpResponse) { this.response = tmpResponse; }, changeResponse: function(tmpResponse) { this.updateResponse(tmpResponse); if(this.response == true) { this.checkMeetingNumber(); } else { this.decline(); } }, checkResponse: function() { return this.response; }, toggleDisplay: function() { var obj = this.panel, display = obj.style.display; if(!display || display === 'none') { obj.style.display = 'table'; this.toggleMode = 'block'; this.addBackdrop(); } else { obj.style.display = 'none'; this.toggleMode = 'none'; this.backdrop.destroy(); this.destroy(); } }, formatNumber: function() { var obj = this.meetingNumber; var number = obj.value; var pattern = /\D/g; var filtered = number.replace(pattern, ''); var num = ''; for(var i = 0, maxLength = filtered.length; i < maxLength; i++) { if(i % 3 == 0 && i != 0) { num += '-'; } num += filtered[i]; } obj.value = num; }, getTypeLabel: function() { return (this.type === 'join-me')? 'Join Me' : 'GoTo'; }, checkMeetingNumber: function() { var meetingNumber = this.meetingNumber; var pattern = /[^0-9]/g; meetingNumber = meetingNumber.value.replace(pattern, ''); var label = this.getTypeLabel(); if(meetingNumber.length > 9) { var mpalert = new Alert('alert', label + ' Meeting Error', 'The meeting number is too long. Please check the number and try again.'); mpalert.start(); } else if(meetingNumber.length < 9) { var mpalert = new Alert('alert', label + ' Meeting Error', 'The meeting number is too short. Please check the number and try again.'); mpalert.start(); } else { this.accept(meetingNumber); } }, accept: function(meetingNumber) { !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script','https://connect.facebook.net/en_US/fbevents.js'); if(typeof meetingNumber !== 'undefined') { var link = (this.type === 'join-me')? 'https://join.me/' : 'https://global.gotomeeting.com/join/'; window.open(link + meetingNumber, '_new'); fbq('track', 'ViewContent', { content_name: 'Corp Site Lead', content_category: 'Sales', content_ids: ['1234'], content_type: 'product' }); this.removeAndCallBack(); } else { var mpalert = new Alert('alert', this.getTypeLabel() + ' Meeting Error', 'No meeting number was submitted'); mpalert.start(); } }, decline: function() { this.display(); } }); "use strict"; var VideoModal = Modal.extend( { constructor: function(video, callBackFn, container) { Modal.call(this, container); this.callBackFn = callBackFn; this.video = video; this.delayClose = false; }, mainPanelClass: 'video-panel', getTitle: function() { return base.getValue(this.video, 'title'); }, addBodyContent: function() { return this.addIframe(); }, addIframe: function() { return this.cache('iframeEle', { node: 'iframe', src: this.video.source, width: '100%', height: '100%', frameBorder: '0' }); }, addFooterButton: function(label, className, callBack) { return { node: 'button', innerHTML: label, className: 'bttn close ' + className, click: callBack }; }, addFooterButtons: function() { return [ this.addFooterButton('', 'bttn-decline', base.bind(this, this.decline)) ]; }, backdropClassName: 'video-shadow', toggleDisplay: function() { var obj = this.panel, display = obj.style.display; if(!display || display === 'none') { obj.style.display = 'block'; this.toggleMode = 'block'; this.addBackdrop(); } else { this.returnCallBack(); if(this.delayClose !== true) { obj.style.display = 'none'; this.toggleMode = 'none'; this.backdrop.destroy(); this.destroy(); } } } }); "use strict"; var LeadModel = base.Model.extend({ url: '/api/lead', xhr: { objectType: 'lead', getDefaultParams: function() { return ""; }, upload: function(instanceParams, callBack) { var params = 'op=upload'; return this.request(params, instanceParams, callBack); }, deleteAll: function(instanceParams, callBack) { var params = 'op=deleteAll'; return this.request(params, instanceParams, callBack); }, claim: function(instanceParams, callBack) { var id = this.model.get('id'); var params = 'op=claim' + '&id=' + id; return this.request(params, instanceParams, callBack); }, requestQuote: function(instanceParams, callBack) { var id = this.model.get('id'); var params = 'op=requestQuote' + '&id=' + id; return this.request(params, instanceParams, callBack); }, search: function(instanceParams, callBack) { var params = 'op=search'; return this.request(params, instanceParams, callBack); }, all: function(callBack, filter, start, count, source) { filter = filter || ''; start = !isNaN(start) ? start : 0; count = !isNaN(count) ? count : 50; var params = 'op=all' + '&filter=' + filter + '&start=' + start + '&stop=' + count + '&source=' + source; return this.request(params, '', callBack); } } }); "use strict"; var DemoRequestModal = Modal.extend( { constructor: function(origin, callBack, container) { Modal.call(this, container); this.model = new LeadModel(); this.origin = origin; this.callBackFn = callBack; }, mainPanelClass: 'demo-request', getTitle: function() { return 'Sign Up Request'; }, addBodyContent: function() { return this.addMainForm(); }, addMainForm: function() { return this.cache('form', { node: 'form', method: 'POST', autocomplete: 'off', novalidate: true, h1: { node: 'h1', textContent: 'We get it. Commitments aren’t easy.' }, p: { node: 'p', textContent: 'That’s why we have a performance guarantee!' }, body: this.addFormContent() }); }, addFooterButtons: function() { return [ this.addFooterButton('Close', 'bttn-decline', base.bind(this, this.decline)), this.addFooterButton('Submit', 'bttn-gradient', base.bind(this, this.confirmAction)) ]; }, addFormContent: function() { var model = this.model; return { className: 'content', children: [ { node: 'h4', textContent: 'Contact Info' }, this.addRow('First Name*', model, 'firstName', true), this.addRow('Last Name*', model, 'lastName', true), this.addRow('Company*', model, 'company', true), this.addRow('Email*', model, 'email', true), this.addRow('Phone*', model, 'phone', true) ] }; }, confirmAction: function() { var settings = this.validate(); if(settings.status === true) { var mpalert = new Alert('confirm', 'Confirm Action', 'Do you want to submit this request?', base.bind(this, this.accept)); mpalert.start(); } else { var mpalert = new Alert('alert', 'Error', 'The following corrections need to be made before saving.
' + settings.message); mpalert.start(); } }, accept: function() { this.request(); }, resetForm: function() { var form = this.form; if (form) { form.reset(); } }, updateModel: function() { var model = this.model; if(app && app.tracker) { model.set('referrer', app.tracker.getReferrer()); } model.set('name', model.get('lastName') + ', ' + model.get('firstName')); model.set('origin', this.origin); }, request: function() { this.updateModel(); var model = this.model; model.xhr.add('', base.bind(this, this.requestResponse)); }, requestResponse: function(response) { if(response) { var result = response; if (result.error === 'no') { var mpalert = new Alert('alert', 'Request Sent', 'Your request has been sent. You will be contacted shortly. ' + result.message); mpalert.start(); if(app && app.tracker) { app.tracker.clear(); } this.resetForm(); this.removeAndCallBack(); } else { var mpalert = new Alert('alert', 'Error', 'There was an error adding the request. ' + result.message); mpalert.start(); } } }, decline: function() { this.display(); }, display: function() { this.toggleDisplay(); } }); "use strict"; var Data = { storage: null, setup: function() { this.supported = this.checkSupport(); if(this.isSupported() === true) { this.storage = window.localStorage; } return this; }, supported: false, isSupported: function() { return this.supported; }, checkSupport: function() { if(typeof window.Storage !== "undefined" && window.localStorage) { return true; } return false; }, get: function(key) { if(this.isSupported() === true) { var value = this.storage.getItem(key); if(typeof value !== 'undefined') { return JSON.parse(value); } } return null; }, set: function(key, value) { if(this.isSupported() === true) { value = JSON.stringify(value); this.storage.setItem(key, value); } }, clear: function() { if(this.isSupported() === true) { this.storage.clear(); } } }.setup(); "use strict"; var BackdropPanel = base.Component.extend( { constructor: function(className, callBackFn, container) { base.Component.call(this, container); this.className = className; this.callBackFn = callBackFn; }, getLayout: function() { return { className: 'panel-shadow modal-shadow fadeIn ' + this.className, click: this.callBackFn }; }, setup: function() { this.render(); } }); "use strict"; var Alert = base.Component.extend( { constructor: function(type, title, description, callback, tmpArgArray) { base.Component.call(this, document.body); this.type = type; this.title = title; this.description = description; this.response = null; this.callback = callback; this.arg = tmpArgArray; this.returnDecline = false; }, getLayout: function() { return { className: 'alert floatDownZ', header: this.addHeader(), body: this.addBody(), footer: this.addFooter() }; }, addHeader: function() { return this.cache('titleContainer', { node: 'header', className: 'title-container', title: { className: 'title left dark', innerHTML: this.title } }); }, addBody: function() { return { className: 'description center dark', text: { node: 'p', innerHTML: this.description } }; }, addFooter: function() { return { node: 'footer', className: 'button-container', buttons: this.addButtons() }; }, addFooterButton: function(label, className, callBack) { return { node: 'button', className: className, textContent: label, click: callBack || '' }; }, addButtons: function() { var layout = { className: 'button-group', buttons: [] }; var buttons = layout.buttons; var self = this; var callBackAccept = function(){self.changeResponse(true);}; var callBackDecline = function(){self.changeResponse(false);}; switch(this.type) { case 'alert': buttons.push( this.cache('button', this.addFooterButton('OK', 'bttn', callBackAccept)) ); break; case 'confirm': buttons.push(this.addFooterButton('No', 'bttn-decline', callBackDecline)); buttons.push( this.cache('button', this.addFooterButton('Yes', 'bttn-approve', callBackAccept)) ); break; case 'confirm-cancel': buttons.push(this.addFooterButton('Cancel', 'bttn', function(){self.cancel();})); buttons.push(this.addFooterButton('No', 'bttn-decline', callBackDecline)); buttons.push( this.cache('button', this.addFooterButton('Yes', 'bttn-approve', callBackAccept)) ); break; } return layout; }, setup: function() { this.createShadow(); this.initialize(); this.button.focus(); }, start: function() { this.setup(); }, createShadow: function() { this.shadow = this.addButton('div', this.id + '_shadow', 'alert-shadow fadeIn', '', base.bind(this, this.declineByShadow), this.container); }, declineByShadow: function() { if(this.type !== 'confirm-cancel') { this.decline(); } else { this.stop(); } }, destroy: function() { this.remove(); var panel = this.shadow; if(panel) { this.removeElement(panel); } }, stop: function() { this.destroy(); }, getResponse: function() { return this.response; }, updateResponse: function(tmpResponse) { this.response = tmpResponse; }, changeResponse: function(tmpResponse) { this.updateResponse(tmpResponse); if(this.response == true) { this.accept(); } else { this.decline(); } }, checkResponse: function() { return this.response; }, makeCallBack: function(response) { var callBack = this.callback; if(typeof callBack === 'function') { var args = this.arg; if(args) { callBack(response, args.valueOf()); } else { callBack(response); } } }, accept: function() { this.makeCallBack(true); this.stop(); }, decline: function() { if(this.returnDecline) { this.makeCallBack(false); } this.stop(); }, cancel: function() { this.stop(); } }); "use strict"; var Tracker = base.Class.extend( { constructor: function(data) { this.data = data; this.setup(); }, setup: function() { this.validate(); }, validate: function() { var referrer = false; var hash = window.location.hash; if(hash) { var parse = this.parse(hash); if(parse) { referrer = parse['referrer'] || false; if(referrer !== false) { this.set('referrer', referrer); } } } }, set: function(key, value) { this.data.set(key, value); }, get: function(key) { return this.data.get(key); }, clear: function() { return this.data.clear(); }, parse: function(str) { var objURL = {}; if(str) { var regExp = /([^?=]+)(=([^&]*))?/g; str.replace(regExp, function(a, b, c, d) { objURL[b] = d; }); } return (base.isEmpty(objURL) === false) ? objURL : false; }, getReferrer: function() { return this.get('referrer'); }, check: function(url) { return true; } }); "use strict"; var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame || function(callback){ setTimeout(callback, 0) }; var LazyAnimator = base.Class.extend( { constructor: function(attrName) { this.attrName = (typeof attrName === 'string')? attrName : 'data-animate'; this.size = {width: 0, height: 0}; this.cacheElements = true; this.options = []; this.setup(); }, setup: function() { this.setupEvents(); this.update(); return this; }, resize: function() { this.size = base.getWindowSize(); this.updateOptionPositions(); }, isMobile: function() { return (this.phoneSize >= this.size.width); }, update: function() { this.getElements(); this.resize(); this.checkScroll(); return this; }, updatePosition: function(option) { var element = option.element; option.position = base.position(element, 0); option.size = base.getSize(element); }, updateOptionPositions: function() { var options = this.options, length = options.length; for(var i = 0; i < length; i++) { this.updatePosition(options[i]); } }, getElements: function() { var elements; try { elements = document.querySelectorAll('[' + this.attrName + ']:not(.animated)'); } catch(e){} if(elements) { return this.addOptions(Array.prototype.slice.call(elements)); } return []; }, addOptions: function(elements) { var length = elements.length; if(length) { var element; for(var i = 0; i < length; i++) { element = elements[i]; this.addOption(element); } } return this.options; }, addOption: function(element) { var animation = base.attr(element, this.attrName); animation = animation || 'pullUp'; var delay, timer = 0; var parts = animation.split(';'); if(parts.length > 1) { animation = parts[0]; delay = parseInt(parts[1]); timer = parseInt(parts[2]); } else { delay = parseInt(base.data(element, 'delay')); } var option = { element: element, position: {x: 0, y: 0}, size: {width: 0, height: 0}, delay: delay, animation: animation, timer: timer }; this.updatePosition(option); this.options.push(option); }, removeOption: function(option) { var options = this.options; var index = base.inArray(options, option); if(index > -1) { options.splice(index, 1); } return this; }, checkScroll: function(e) { var options = (this.cacheElements === true)? this.options : this.getElements(); var length = options.length; if(length > 0) { options = options.slice(0); var viewPortSize = this.size; var viewPortTop = (window.pageYOffset || window.scrollY || 0); var viewPortBottom = viewPortSize.height + viewPortTop; var isMobile = this.isMobile(); var option, element, delay, positionY, optionTop, optionBottom; for(var i = 0; i < length; i++) { option = options[i]; element = option.element; if(element) { delay = option.delay || 20; positionY = option.position.y; optionTop = positionY + delay; optionBottom = positionY + option.size.height; var timer = (!isMobile)? option.timer : 0; if(optionTop < viewPortBottom && optionTop >= viewPortTop) { this.animate(option, timer); } else if(optionBottom >= viewPortTop && optionBottom <= viewPortBottom) { this.animate(option, timer); } } } } return this; }, phoneSize: 600, animate: function(option, timer) { timer = timer || 0; var element = option.element; var animation = option.animation; window.setTimeout(function() { base.addClass(element, animation) .addClass(element, 'animated'); }, timer); this.removeOption(option); return this; }, ticking: false, scroll: function(e) { if(!this.ticking) { var self = this; requestAnimationFrame(function() { self.checkScroll(e); self.ticking = false; }); this.ticking = true; } }, setupEvents: function() { var callBack = this.callBack = base.bind(this, this.checkScroll); var scrollCallBack = base.bind(this, this.scroll); var resizeCallBack = base.bind(this, this.resize); var w = window; var params = false; this.addEvents = function() { base.on('scroll', w, scrollCallBack, params); base.on('resize', w, resizeCallBack); }; this.removeEvents = function() { base.off('scroll', w, scrollCallBack, params); base.off('resize', w, resizeCallBack); }; this.addEvents(); return this; } }); "use strict"; (function(app) { app.addModule(Module.extend( { setup: function() { this.setupTest(); this.etupReviewController(); }, setupTest: function() { var test = document.getElementById('test-site'); base.on('submit', test, base.bind(this, this.submitToTest)); var field = document.getElementById('test_url'); base.on('keyup', field, base.bind(this, this.keyup), true); }, keyup: function(e) { e = e || window.event; var field = document.getElementById('test_url'), url = field.value; var keyCode = e.keyCode || e.charCode; if(keyCode === 13) { if(url.substring(0, 4) !== 'http') { field.value = 'http://' + url; this.submitToTest(e); } } }, submitToTest: function(e) { e = e || window.event; base.preventDefault(e); var url = document.getElementById('test_url').value; if(url) { url = (url.substring(0, 4) !== 'http')? 'http://' + url : url; window.location = '/test-my-site?url=' + encodeURI(url); } else { var panel = new Alert('alert', 'Error', 'Please check the url'); panel.start(); } }, etupReviewController: function() { var reviewsContainer = document.getElementById('review-slides'); this.reviewSlide = new ReviewSlideController(reviewsContainer); this.reviewSlide.setup(); } }) ); })(app); "use strict"; var ReviewSlide = base.Component.extend( { constructor: function(fullName, reveiw, container) { base.Component.call(this, container); this.fullName = fullName; this.review = reveiw; }, getLayout: function() { return { className: 'single-review', children: [ { node: 'img', src: '/images/pages/home/stars.png', alt: 'Five stars', className: 'stars' }, { node: 'h3', textContent: this.fullName }, { node: 'blockquote', textContent: this.review } ] }; }, activeClass: 'showing', unselect: function() { var element = this.panel; base.removeClass(element, this.activeClass); }, select: function(number) { var element = this.panel; base.addClass(element, this.activeClass); } }); var ReviewSlideController = base.Component.extend( { beforeSetup: function() { this.slides = []; this.currentSlide = 0; this.playing = false; this.timer = null; }, getLayout: function() { return { className: 'slide-container', children: [ this.addSingleReview( 'Joseph Savery', '“I love working with Business Promotion! Their staff is amazing! They are all very knowledgeable and helpful, and they are there when we need them! I recommend Business Promotion to all of my colleagues and anyone searching for website development and online marketing services!”' ), this.addSingleReview( 'Max Morgan', '“I enjoy working with Business Promotion. Their savvy & common sense approach to business is effective & refreshing. I wouldn\'t have a problem recommending them to anyone/business in need of their services.”' ), this.addSingleReview( 'Soul Hernandez', '“My experience has been absolutely amazing! I would highly recommend it.”' ), this.addSingleReview( 'Charles B.', '“Business Promotions has been fantastic to work with! They listen to our ideas and then use their outstanding expertise to make them better. I highly recommend them to any and all business that are looking for out standing websites and support.”' ), this.addSingleReview( 'Aaron W.', '“BP is very professional and capable. They are accommodating to my business\' needs. I highly recommend them.”' ), this.addSingleReview( 'Megan Garcia', '“The entire team is very responsive and provide excellent customer service. We have been using them for our SEO for my company and they have done an excellent job.”' ), this.addSingleReview( 'Ashley Chavarria', '“Everyone I have talked to has been amazing, everything has been easy to do even if you’re not tech savvy. Our new website is such a step up from what we had”' ), this.addSingleReview( 'Grace', '“Business Promotion take care of their clients. They are always professional and aim high at giving us their undivided attention regarding all of our marketing needs!”' ), { className: 'slide-controls', children: [ this.cache('pauseButton', this.addButton('pause', 'Pause', this.togglePlay)), this.addButton('previous', '', this.previousSlide), this.addButton('next', '', this.nextSlide) ] } ] }; }, addButton: function(id, label, callBack) { return { node: 'button', className: 'bttn controls', id: id, textContent: label, click: base.bind(this, callBack) }; }, afterSetup: function() { this.selectSlide(this.currentSlide); }, addSingleReview: function(fullName, review) { var self = this; return this.addChild(ReviewSlide, [fullName, review], null, function(component) { self.slides.push(component); }); }, togglePlay: function() { if(this.playing) { this.pause(); } else { this.play(); } }, nextSlide: function() { this.goToSlide(this.currentSlide + 1); }, previousSlide: function() { this.goToSlide(this.currentSlide - 1); }, goToSlide: function(number) { var slides = this.slides; var currentSlide = ((number + slides.length) % slides.length); this.selectSlide(currentSlide); }, unselectPrevious: function() { var previous = this.slides[this.currentSlide]; if(previous) { previous.unselect(); } }, selectSlide: function(number) { this.unselectPrevious(); var slide = this.slides[number]; if(slide) { this.currentSlide = number; slide.select(); } this.play(); }, play: function() { this.pause(); this.pauseButton.innerHTML = 'Pause'; this.playing = true; this.timer = window.setInterval(base.bind(this, this.nextSlide), 4000); }, pause: function() { this.pauseButton.innerHTML = 'Play'; this.playing = false; window.clearInterval(this.timer); } });