/* mousetrap v1.4.6 craig.is/killing/mice */ (function(J,r,f){function s(a,b,d){a.addEventListener?a.addEventListener(b,d,!1):a.attachEvent("on"+b,d)}function A(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return h[a.which]?h[a.which]:B[a.which]?B[a.which]:String.fromCharCode(a.which).toLowerCase()}function t(a){a=a||{};var b=!1,d;for(d in n)a[d]?b=!0:n[d]=0;b||(u=!1)}function C(a,b,d,c,e,v){var g,k,f=[],h=d.type;if(!l[a])return[];"keyup"==h&&w(a)&&(b=[a]);for(g=0;gg||h.hasOwnProperty(g)&&(p[h[g]]=g)}e=p[d]?"keydown":"keypress"}"keypress"==e&&f.length&&(e="keydown");return{key:c,modifiers:f,action:e}}function F(a,b,d,c,e){q[a+":"+d]=b;a=a.replace(/\s+/g," ");var f=a.split(" ");1":".","?":"/","|":"\\"},G={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p,l={},q={},n={},D,z=!1,I=!1,u=!1;for(f=1;20>f;++f)h[111+f]="f"+f;for(f=0;9>=f;++f)h[f+96]=f;s(r,"keypress",y);s(r,"keydown",y);s(r,"keyup",y);var m={bind:function(a,b,d){a=a instanceof Array?a:[a];for(var c=0;c 1 || e.targetTouches && e.targetTouches.length > 1 ){ return false; } var coords = getCoords( e ); startX = coords[ 0 ]; startY = coords[ 1 ]; } // any touchscroll that results in > tolerance should cancel the tap function move( e ){ if( !cancel ){ var coords = getCoords( e ); if( coords && ( Math.abs( startY - coords[ 1 ] ) > scrollTolerance || Math.abs( startX - coords[ 0 ] ) > scrollTolerance ) ){ cancel = true; } } } function end( e ){ clearTimeout( resetTimer ); resetTimer = setTimeout( function(){ w.tapHandling = false; cancel = false; }, 1000 ); // make sure no modifiers are present. thx http://www.jacklmoore.com/notes/click-events/ if( ( e.which && e.which > 1 ) || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey ){ return; } e.preventDefault(); // this part prevents a double callback from touch and mouse on the same tap // if a scroll happened between touchstart and touchend if( cancel || w.tapHandling && w.tapHandling !== e.type ){ cancel = false; return; } w.tapHandling = e.type; trigger( e ); } $el .bind( "touchstart.tappy MSPointerDown.tappy", start ) .bind( "touchmove.tappy MSPointerMove.tappy", move ) .bind( "touchend.tappy MSPointerUp.tappy", end ) .bind( "click.tappy", end ); }); }; var untap = function( $els ){ return $els.unbind( ".tappy" ); }; // use special events api if( $.event && $.event.special ){ $.event.special.tap = { add: function( handleObj ) { tap( $( this ) ); }, remove: function( handleObj ) { untap( $( this ) ); } }; } else{ // monkeybind var oldBind = $.fn.bind, oldUnbind = $.fn.unbind; $.fn.bind = function( evt ){ if( /(^| )tap( |$)/.test( evt ) ){ tap( this ); } return oldBind.apply( this, arguments ); }; $.fn.unbind = function( evt ){ if( /(^| )tap( |$)/.test( evt ) ){ untap( this ); } return oldUnbind.apply( this, arguments ); }; } }( this, jQuery )); // --------------------------------------------------------------- // Access Map // --------------------------------------------------------------- var AccessMap = { settings: { subjectProp: 'Park 80 West', subjectLoc: [40.9049416,-74.1036092], mapBox: $('.google-map'), modeNav: $('.access-mode-nav a'), legendNav: $('.access-legend-nav a'), panel: $('.access-map-panel'), resetBtn: $('.access-btn-reset'), mode: 'drive', destinations: [ { "Name":"Manhattan", "Loc":[40.750552, -73.993616], "Marker":'marker-pin' }, { "Name":"Newark Airport", "Loc":[40.692456, -74.183226], "Marker":'marker-plane' }, { "Name":"Teterboro Airport", "Loc":[40.849014, -74.063104], "Marker":'marker-plane' }, { "Name":"Plauderville Station", "Loc":[40.884791, -74.102817], "Marker":'marker-rail' }, { "Name":"Ridgewood", "Loc":[40.979207, -74.116519], "Marker":'marker-pin' }, { "Name":"Parsippany", "Loc":[40.866525, -74.418282], "Marker":'marker-pin' }, { "Name":"Morristown", "Loc":[40.797096, -74.481159], "Marker":'marker-pin' }, { "Name":"Chatham", "Loc":[40.741001, -74.384156], "Marker":'marker-pin' }, { "Name":"Florham Park", "Loc":[40.787793, -74.388399], "Marker":'marker-pin' }, { "Name":"Hackensack", "Loc":[40.885731, -74.043557], "Marker":'marker-pin' }, { "Name":"Westchester, NY", "Loc":[41.098560, -73.800672], "Marker":'marker-pin' }, { "Name":"Stamford, CT", "Loc":[41.053367, -73.538649], "Marker":'marker-pin' } ] }, init: function() { var s = this.settings; if ($(window).width() < 800) { s.mapZoom = 9; } else { s.mapZoom = 10; } AccessMap.createMapStyle(s); AccessMap.loadMap(s); AccessMap.bindUIActions(s); }, bindUIActions: function(s) { s.modeNav.click(function(e) { e.preventDefault(); if ( $(this).hasClass('active') ) { return false; } else { s.modeNav.toggleClass('active'); s.mode = $(this).attr('href').split('#')[1]; $('.access-legend-nav a.active').removeClass('active').click(); } }); s.legendNav.click(function(e) { e.preventDefault(); if ( $(this).hasClass('active') ) { return false; } else { s.legendNav.removeClass('active'); AccessMap.calcRoute(s, $(this).parent().index()); $(this).addClass('active'); } }); s.resetBtn.click(function(e) { e.preventDefault(); s.legendNav.removeClass('active'); $('.access-mode-nav li:first-child a').click(); s.panel.html(''); AccessMap.loadMap(s); }); }, loadMap: function(s) { var propLoc = new google.maps.LatLng(s.subjectLoc[0], s.subjectLoc[1]); var mapCenter = propLoc; var mapZoom = s.mapZoom; var mapOptions = { center: mapCenter, zoom: mapZoom, panControl: false, draggable: true, scrollwheel: false, streetViewControl: false, styles: s.mapstyle, mapTypeControlOptions: { mapTypeIds: [ ] }, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL, position: google.maps.ControlPosition.TOP_RIGHT } }; s.map = new google.maps.Map(document.getElementById('google-map'), mapOptions); var transitLayer = new google.maps.TransitLayer(); //transitLayer.setMap(s.map); s.directionsDisplay; s.directionsService = new google.maps.DirectionsService(); s.directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true}); s.directionsDisplay.setMap(s.map); s.directionsDisplay.setPanel(document.getElementById("panel")); google.maps.event.addDomListener(window, 'resize', function() { s.map.setCenter(mapCenter); }); var subjectIcon = { url: '../../assets/svg/subject-marker.svg', anchor: new google.maps.Point(52,70), scaledSize: new google.maps.Size(104,70) } var subjectMarker = new google.maps.Marker({ position: propLoc, map: s.map, icon: subjectIcon, title: s.subjectProp, //animation: google.maps.Animation.DROP }); s.infowindow = new google.maps.InfoWindow(); AccessMap.plotDestinations(s); }, plotDestinations: function(s) { $.each(s.destinations, function( key, value ) { var dest = value; var pos = key; var icon = { url: '../../assets/svg/' + dest.Marker + '.svg', anchor: new google.maps.Point(15,50), scaledSize: new google.maps.Size(30,50), } var marker = new google.maps.Marker({ position: new google.maps.LatLng(dest.Loc[0], dest.Loc[1]), map: s.map, icon: icon, title: dest.Name, //animation: google.maps.Animation.DROP }); google.maps.event.addListener(marker, 'click', function() { s.infowindow.setContent( '
' + '

' + dest.Name + '

' + '
' ); s.legendNav.eq(pos).click(); s.infowindow.open(s.map,marker); }); }); }, calcRoute: function(s, destination) { var start = new google.maps.LatLng(s.subjectLoc[0], s.subjectLoc[1]); if ( s.mode === 'drive' ) { var travelMode = google.maps.TravelMode.DRIVING } else { var travelMode = google.maps.TravelMode.TRANSIT } var end = s.destinations[destination].Loc[0] + ', ' + s.destinations[destination].Loc[1]; var request = { origin: start, destination: end, travelMode: travelMode, transitOptions: { //modes: [google.maps.TransitMode.BUS], //routingPreference: google.maps.TransitRoutePreference.FEWER_TRANSFERS //routingPreference: google.maps.TransitRoutePreference.LESS_WALKING } }; s.directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { s.directionsDisplay.setDirections(response); } }); }, createMapStyle: function(s) { s.mapstyle = [ { "featureType":"administrative", "elementType":"labels.text.fill", "stylers":[ { "color":"#444444" } ] }, { "featureType":"landscape", "elementType":"all", "stylers":[ { "color":"#f2f2f2" } ] }, { "featureType":"poi", "elementType":"all", "stylers":[ { "visibility":"off" } ] }, { "featureType":"poi.business", "elementType":"geometry.fill", "stylers":[ { "visibility":"on" } ] }, { "featureType":"road", "elementType":"geometry", "stylers":[ { "saturation":-100 }, { "lightness":35 } ] }, { "featureType":"road.highway", "elementType":"all", "stylers":[ { "lightness":35 }, { //"saturation":-100 }, { "visibility":"simplified" } ] }, { "featureType": "road.highway", "elementType": "labels.icon", "stylers": [ { "saturation": 0 } ] }, { "featureType": "road.highway", "elementType": "labels.text", "stylers": [ { "saturation": -100 } ] }, { "featureType":"road.arterial", "elementType":"all", "stylers":[ { "lightness":35 }, { "saturation":-100 } ] }, { "featureType":"road.local", "elementType":"all", "stylers":[ { "lightness":35 }, { "saturation":-100 } ] }, { "featureType":"road.arterial", "elementType":"labels.icon", "stylers":[ { "visibility":"off" } ] }, { "featureType":"transit", "elementType":"all", "stylers":[ { //"visibility":"off" } ] }, { "featureType":"water", "elementType":"all", "stylers":[ { "color":"#b4d4e1" }, { "visibility":"on" } ] } ] } }; // --------------------------------------------------------------- // Amenities Map // --------------------------------------------------------------- var AmenitiesMap = { settings: { subjectProp: 'Park 80 West', subjectLoc: [40.9049416,-74.1036092], mapBox: $('#google-map'), legendNav: $('.amenities-legend-nav a'), legend: $('.amenities-legend-list') }, init: function() { var s = this.settings; if ($(window).width() < 800) { s.mapZoom = 12; } else { s.mapZoom = 13; } AmenitiesMap.bindUIActions(s); AmenitiesMap.loadAmens(s); AmenitiesMap.createMapStyle(s); }, bindUIActions: function(s) { s.legendNav.click(function(e) { e.preventDefault(); if ( $(this).hasClass('active') ) { return false; } else { s.legendNav.removeClass('active'); AmenitiesMap.plotAmens(s, $(this).attr('href').split('#')[1], $(this).attr('color')); AmenitiesMap.loadLegend(s, $(this).attr('href').split('#')[1]); $(this).addClass('active'); } }); }, loadAmens: function(s) { $.ajax({ type: 'GET', url: '../../assets/js/data/amenities.js', dataType: 'json', success: function(list) { s.amensList = list; AmenitiesMap.loadMap(s); }, error: function() { console.log('FAIL: Error loading amenities.'); } }); }, loadMap: function(s) { var propLoc = new google.maps.LatLng(s.subjectLoc[0], s.subjectLoc[1]); var mapCenter = propLoc; var mapZoom = s.mapZoom; var mapOptions = { center: mapCenter, zoom: mapZoom, panControl: false, draggable: true, scrollwheel: false, streetViewControl: false, styles: s.mapstyle, mapTypeControlOptions: { mapTypeIds: [ ] }, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL, position: google.maps.ControlPosition.TOP_RIGHT } }; s.map = new google.maps.Map(document.getElementById('google-map'), mapOptions); google.maps.event.addDomListener(window, 'resize', function() { s.map.setCenter(mapCenter); }); var subjectIcon = { url: '../../assets/svg/subject-marker.svg', anchor: new google.maps.Point(52,70), scaledSize: new google.maps.Size(104,70) } var subjectMarker = new google.maps.Marker({ position: propLoc, map: s.map, icon: subjectIcon, title: s.subjectProp, //animation: google.maps.Animation.DROP }); s.infowindow = new google.maps.InfoWindow(); s.bounds = new google.maps.LatLngBounds(); s.amenMarkers = []; s.legendNav.eq(0).click(); }, plotAmens: function(s, category, color) { var category = category.substring(0, 1).toUpperCase() + category.substring(1); if (s.amenMarkers.length > 0 ) { $.each(s.amenMarkers, function( key, value ) { value.setMap(null); }); s.amenMarkers = [] } var i = 1; $.each(s.amensList['amenities'], function( key, value ) { var amenity = value; if (amenity.Category == category) { setTimeout(function() { addMarker(); }, i * 30); i += 1; } function addMarker() { var icon = { url: '../../assets/svg/marker-' + color + '.svg', anchor: new google.maps.Point(15,50), scaledSize: new google.maps.Size(30,50), } var marker = new google.maps.Marker({ position: new google.maps.LatLng(amenity.Lat, amenity.Long), map: s.map, icon: icon, title: amenity.Name, //animation: google.maps.Animation.DROP }); s.amenMarkers.push(marker); google.maps.event.addListener(marker, 'click', function() { s.infowindow.setContent( '
' + '

' + amenity.Name + '

' + '

' + amenity.Address.split(',')[0] + '
' + amenity.Address.split(',')[1] + ', ' + amenity.Address.split(',')[2] + '

' + '
' ); s.infowindow.open(s.map,marker); }); }; }); }, loadLegend: function(s, category) { var category = category.substring(0, 1).toUpperCase() + category.substring(1); var i = 0; var legendInsert = ''; $.each(s.amensList['amenities'], function( key, value ) { var amenity = value; if (amenity.Category == category) { legendInsert += '
  • ' + amenity.Name + '
  • '; i+=1; } }); s.legend.fadeOut(200, function() { s.legend.html(legendInsert) $(this).fadeIn(200); AmenitiesMap.legendUIActions(s); }); }, legendUIActions: function(s) { s.legend.find('a').click(function(e) { e.preventDefault(); var x = $(this).attr('href').split('#')[1]; google.maps.event.trigger(s.amenMarkers[x], 'click'); }); }, createMapStyle: function(s) { s.mapstyle = [ { "featureType":"administrative", "elementType":"labels.text.fill", "stylers":[ { "color":"#444444" } ] }, { "featureType":"landscape", "elementType":"all", "stylers":[ { "color":"#f2f2f2" } ] }, { "featureType":"poi", "elementType":"all", "stylers":[ { "visibility":"off" } ] }, { "featureType":"poi.business", "elementType":"geometry.fill", "stylers":[ { "visibility":"on" } ] }, { "featureType":"road", "elementType":"geometry", "stylers":[ { "saturation":-100 }, { //"lightness":35 } ] }, { "featureType":"road.highway", "elementType":"all", "stylers":[ { "lightness":5 }, { "visibility":"simplified" } ] }, { "featureType": "road.highway", "elementType": "labels.icon", "stylers": [ { "saturation": 1 } ] }, { "featureType":"road.arterial", "elementType":"all", "stylers":[ { "lightness":35 }, { "saturation":-100 } ] }, { "featureType":"road.local", "elementType":"all", "stylers":[ { "lightness":35 }, { "saturation":-100 } ] }, { "featureType":"road.arterial", "elementType":"labels.icon", "stylers":[ { "visibility":"off" } ] }, { "featureType":"transit", "elementType":"all", "stylers":[ { "visibility":"off" } ] }, { "featureType":"water", "elementType":"all", "stylers":[ { "color":"#b4d4e1" }, { "visibility":"on" } ] } ] } }; // --------------------------------------------------------------- // Floorplan PopUp // --------------------------------------------------------------- var FloorplanPopup = { settings: { popup: $('.floorplan-popup'), launcher: $('.availability-table__launcher'), close: $('.floorplan-popup__close-btn'), heading: $('.floorplan-popup__heading'), floorplan: $('.floorplan-popup__floorplan') }, init: function() { var s = this.settings; FloorplanPopup.launchGallery(s); FloorplanPopup.closeGallery(s); }, launchGallery: function(s) { s.launcher.click(function(e) { e.preventDefault(); var plan = $(this).attr('href'); var suite = $(this).parent().siblings().eq(0).text(); var size = $(this).parent().siblings().eq(1).text(); s.heading.text('Suite ' + suite + ' | ' + size); s.floorplan.find('img').attr('src', plan); s.popup.fadeIn(500); $('body').css('overflow', 'hidden'); if ( $('html').hasClass('ie') ) { window.scrollTo(0, 0); } }); }, closeGallery: function(s) { s.close.click(function(e) { e.preventDefault(); s.popup.fadeOut(500); $('body').css('overflow', 'visible'); }); } }; // --------------------------------------------------------------- // Gallery // --------------------------------------------------------------- var Gallery = { settings: { launcher: $('a.launcher'), gallery: $('.gallery'), slides: $('.gallery__slides img'), btn: $('.gallery__btn-nav'), close: $('.gallery__btn-close'), current: 0 }, init: function() { var s = this.settings; Gallery.launchGallery(s); Gallery.closeGallery(s); Gallery.keyboardActions(s); }, windowSizeChecker: function(s, id) { s.slides.each(function(i){ var topOffset = -($(this).height() / 2); var leftOffset = -($(this).width() / 2); $(this).css({'margin-left': leftOffset, 'margin-top': topOffset}); }); }, dotCounter: function(s, id) { $('.gallery__dot-nav').remove(); var insert = ''; s.gallery.find('.gallery__wrapper').append(insert); }, launchGallery: function(s) { s.launcher.click(function(e) { e.preventDefault(); var id = $(this).attr('href').split('#')[1]; Gallery.dotCounter(s, id); Gallery.runGallery(s, id); if ( $('#' + id + ' img').length < 2 ) { s.btn.add('.dots').css('display', 'none'); } else { s.btn.add('.dots').attr('style', ''); } if ( typeof $('#' + id + ' img').attr('alt') != 'undefined' ) { s.gallery.append('

    ' + $('#' + id + ' img').attr('alt') + '

    '); } s.gallery.fadeIn(500); $('body').css('overflow', 'hidden'); if ( $('html').hasClass('ie') ) { window.scrollTo(0, 0); } $(window).resize(function() { Gallery.windowSizeChecker(s, id); }); $(window).resize(); }); }, runGallery: function(s, id) { var slideGroup = $('#' + id + ' img'); var numSlides = slideGroup.length; var dots = $('.gallery__dot-nav').find('li a'); var currentSlide = 0; dots.removeClass('active').eq(currentSlide).addClass('active'); $('.gallery__slides').css('display', 'none'); $('#' + id).css('display', 'block'); slideGroup.css('opacity', '0').eq(0).fadeTo(500, 1); s.btn.click(function(e) { e.preventDefault(); if ( $(this).hasClass('-next')){ if ( currentSlide < (numSlides - 1) ) { var nextSlide = currentSlide + 1; } else { var nextSlide = 0; } } else { if ( currentSlide == 0 ) { var nextSlide = numSlides - 1; } else { var nextSlide = currentSlide - 1; } } slideGroup.eq(currentSlide).fadeTo(500, 0); slideGroup.eq(nextSlide).fadeTo(500, 1); if (slideGroup.eq(nextSlide).attr('alt') === undefined ) { $('.gallery__caption').fadeOut(); } else { $('.gallery__caption').html(slideGroup.eq(nextSlide).attr('alt')); $('.gallery__caption').fadeIn(); } currentSlide = nextSlide; s.current = currentSlide; dots.removeClass('active').eq(currentSlide).addClass('active'); }); dots.click(function(e) { e.preventDefault(); if ( $(this).hasClass('active') ) { return false; } else { var nextSlide = parseInt($(this).attr('href').split('#')[1]); slideGroup.eq(currentSlide).fadeTo(500, 0); slideGroup.eq(nextSlide).fadeTo(500, 1);; currentSlide = nextSlide; dots.removeClass('active').eq(currentSlide).addClass('active'); } }); }, closeGallery: function(s) { s.close.click(function(e) { e.preventDefault(); s.gallery.fadeOut(500); s.btn.unbind(); $('body').css('overflow', 'visible'); }); }, keyboardActions: function(s) { Mousetrap.bind('right', function(e) { s.btn.filter('.-next').click(); }); Mousetrap.bind('left', function(e) { s.btn.filter('.-prev').click(); }); } }; // --------------------------------------------------------------- // Page Set Up // --------------------------------------------------------------- var PageSetUp = { settings: { pageName: $('body').attr('class') }, init: function() { SiteNav.init(); if ( $('body').hasClass('page-home') ) { Gallery.init(); } else if ( $('body').hasClass('page-location-access') ) { AccessMap.init(); } else if ( $('body').hasClass('page-location-amenities') ) { AmenitiesMap.init(); } else if ( $('body').hasClass('page-property') ) { Gallery.init(); } else if ( $('body').hasClass('page-availability') ) { FloorplanPopup.init(); } } }; // --------------------------------------------------------------- // Site Nav // --------------------------------------------------------------- var SiteNav = { settings: { trigger: $('.nav-trigger'), body: $('body'), header: $('.site-header'), navLink: $('.main-nav__link') }, init: function() { var s = this.settings; SiteNav.bindUIActions(s); SiteNav.scrollAction(s); }, bindUIActions: function(s) { s.trigger.bind('tap', function(e) { s.body.toggleClass('hide-nav show-nav'); }); s.body.click(function(){ $('.-triggered').removeClass('-triggered'); $('.sub-nav.-open').removeClass('-open'); }); s.navLink.bind('tap', function(e) { if ( $(this).hasClass('-triggered') || !$(this).parent().hasClass('-has-sub') ) { window.location.href = $(this).attr('href'); } else { $('.-triggered').removeClass('-triggered'); $('.sub-nav.-open').removeClass('-open'); $(this).addClass('-triggered'); $(this).parent().find('.sub-nav').addClass('-open'); } }); $('.sub-nav').click(function(e){ e.stopPropagation(); }); }, scrollAction: function(s) { var didScroll; var lastScrollTop = 0; var delta = 5; var headerHeight = s.header.outerHeight() * 0.5; $(window).scroll(function(event){ didScroll = true; }); setInterval(function() { if ( didScroll ) { hasScrolled(); didScroll = false; } }, 250); function hasScrolled() { var st = $(this).scrollTop(); if ( Math.abs(lastScrollTop - st) <= delta) return; if (st > lastScrollTop && st > headerHeight) { s.header.removeClass('down').addClass('up'); } else { if (st + $(window).height() < $(document).height()) { s.header.removeClass('up').addClass('down'); } } lastScrollTop = st; } } }; // --------------------------------------------------------------- // Copyright (C)2015 CBRE | Property Marketing Center // --------------------------------------------------------------- (function() { PageSetUp.init(); })();