/* global google, CarpressJS, _ */
jQuery(document).ready(function($) {
'use strict';
var realScreenWidth = function() {
return ( window.innerWidth > 0 ) ? window.innerWidth : screen.width;
};
// ==========
// = Smooth scroll to the top of the page =
// ==========
$('#to-the-top').click(function(e) {
e.preventDefault();
$('html, body').animate({ 'scrollTop' : 0 }, 1200);
});
// ==========
// = Collapse / accordion =
// ==========
$('.accordion-heading a').click(function(e) {
e.preventDefault();
$(this).parent().toggleClass('open').parent().find('.accordion-body').slideToggle();
});
// ==========
// = jQuery UI datepicker =
// ==========
/**
* For time format see: http://trentrichardson.com/examples/timepicker/
*/
$('.add-datepicker').datetimepicker({
stepMinute: 5,
hourMin: 6,
hourMax: 21,
dateFormat: CarpressJS.datetimepicker_date_format,
//timeFormat: '',
});
$('.add-datepicker-icon').click(function(ev) {
ev.preventDefault();
$('.add-datepicker').focus();
});
// ==========
// = Custom Google Maps =
// ==========
(function () {
if ( $('#gmaps-wide-container').length > 0 ) {
var createLatLng = function (argument) {
var latLng = argument.split(',');
for ( var i = 0; i < 2; i++ ) {
latLng[i] = parseFloat( latLng[i] );
}
return new google.maps.LatLng( latLng[0],latLng[1] );
};
var gmapsCenter = createLatLng( CarpressJS.latLng );
var mapOptions = {
zoom: parseInt( CarpressJS.zoomLevel, 10 ),
scrollwheel: false,
center: gmapsCenter,
mapTypeId: eval( 'google.maps.MapTypeId.' + CarpressJS.mapType ),
styles: eval( CarpressJS.mapStyle )
};
var map = new google.maps.Map(document.getElementById('gmaps-wide-container'), mapOptions);
var Infowindow = function(contentString) {
this.marker = null;
this.cont = new google.maps.InfoWindow({
content: contentString
});
return this;
};
Infowindow.prototype.setMarker = function( marker ) {
this.marker = marker;
google.maps.event.addListener(this.marker, 'click', $.proxy(function() {
this.cont.open(map,this.marker);
}, this ) );
return this;
};
_.forEach( CarpressJS.gmapsLocations, function ( val ) {
var image = '';
if( val.image.length > 0 ) {
image = '';
}
var contentString = '