Initial commit
This commit is contained in:
474
js/bootstrap-datepicker.js
vendored
Normal file
474
js/bootstrap-datepicker.js
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
/* =========================================================
|
||||
* bootstrap-datepicker.js
|
||||
* http://www.eyecon.ro/bootstrap-datepicker
|
||||
* =========================================================
|
||||
* Copyright 2012 Stefan Petre
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================= */
|
||||
|
||||
!function( $ ) {
|
||||
|
||||
// Picker object
|
||||
|
||||
var Datepicker = function(element, options){
|
||||
this.element = $(element);
|
||||
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
|
||||
this.picker = $(DPGlobal.template)
|
||||
.appendTo('body')
|
||||
.on({
|
||||
click: $.proxy(this.click, this)//,
|
||||
//mousedown: $.proxy(this.mousedown, this)
|
||||
});
|
||||
this.isInput = this.element.is('input');
|
||||
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
|
||||
|
||||
if (this.isInput) {
|
||||
this.element.on({
|
||||
focus: $.proxy(this.show, this),
|
||||
//blur: $.proxy(this.hide, this),
|
||||
keyup: $.proxy(this.update, this)
|
||||
});
|
||||
} else {
|
||||
if (this.component){
|
||||
this.component.on('click', $.proxy(this.show, this));
|
||||
} else {
|
||||
this.element.on('click', $.proxy(this.show, this));
|
||||
}
|
||||
}
|
||||
|
||||
this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0;
|
||||
if (typeof this.minViewMode === 'string') {
|
||||
switch (this.minViewMode) {
|
||||
case 'months':
|
||||
this.minViewMode = 1;
|
||||
break;
|
||||
case 'years':
|
||||
this.minViewMode = 2;
|
||||
break;
|
||||
default:
|
||||
this.minViewMode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.viewMode = options.viewMode||this.element.data('date-viewmode')||0;
|
||||
if (typeof this.viewMode === 'string') {
|
||||
switch (this.viewMode) {
|
||||
case 'months':
|
||||
this.viewMode = 1;
|
||||
break;
|
||||
case 'years':
|
||||
this.viewMode = 2;
|
||||
break;
|
||||
default:
|
||||
this.viewMode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.startViewMode = this.viewMode;
|
||||
this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
|
||||
this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
|
||||
this.onRender = options.onRender;
|
||||
this.fillDow();
|
||||
this.fillMonths();
|
||||
this.update();
|
||||
this.showMode();
|
||||
};
|
||||
|
||||
Datepicker.prototype = {
|
||||
constructor: Datepicker,
|
||||
|
||||
show: function(e) {
|
||||
this.picker.show();
|
||||
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
|
||||
this.place();
|
||||
$(window).on('resize', $.proxy(this.place, this));
|
||||
if (e ) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
if (!this.isInput) {
|
||||
}
|
||||
var that = this;
|
||||
$(document).on('mousedown', function(ev){
|
||||
if ($(ev.target).closest('.datepicker').length == 0) {
|
||||
that.hide();
|
||||
}
|
||||
});
|
||||
this.element.trigger({
|
||||
type: 'show',
|
||||
date: this.date
|
||||
});
|
||||
},
|
||||
|
||||
hide: function(){
|
||||
this.picker.hide();
|
||||
$(window).off('resize', this.place);
|
||||
this.viewMode = this.startViewMode;
|
||||
this.showMode();
|
||||
if (!this.isInput) {
|
||||
$(document).off('mousedown', this.hide);
|
||||
}
|
||||
//this.set();
|
||||
this.element.trigger({
|
||||
type: 'hide',
|
||||
date: this.date
|
||||
});
|
||||
},
|
||||
|
||||
set: function() {
|
||||
var formated = DPGlobal.formatDate(this.date, this.format);
|
||||
if (!this.isInput) {
|
||||
if (this.component){
|
||||
this.element.find('input').prop('value', formated);
|
||||
}
|
||||
this.element.data('date', formated);
|
||||
} else {
|
||||
this.element.prop('value', formated);
|
||||
}
|
||||
},
|
||||
|
||||
setValue: function(newDate) {
|
||||
if (typeof newDate === 'string') {
|
||||
this.date = DPGlobal.parseDate(newDate, this.format);
|
||||
} else {
|
||||
this.date = new Date(newDate);
|
||||
}
|
||||
this.set();
|
||||
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
|
||||
this.fill();
|
||||
},
|
||||
|
||||
place: function(){
|
||||
var offset = this.component ? this.component.offset() : this.element.offset();
|
||||
this.picker.css({
|
||||
top: offset.top + this.height,
|
||||
left: offset.left
|
||||
});
|
||||
},
|
||||
|
||||
update: function(newDate){
|
||||
this.date = DPGlobal.parseDate(
|
||||
typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')),
|
||||
this.format
|
||||
);
|
||||
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
|
||||
this.fill();
|
||||
},
|
||||
|
||||
fillDow: function(){
|
||||
var dowCnt = this.weekStart;
|
||||
var html = '<tr>';
|
||||
while (dowCnt < this.weekStart + 7) {
|
||||
html += '<th class="dow">'+DPGlobal.dates.daysMin[(dowCnt++)%7]+'</th>';
|
||||
}
|
||||
html += '</tr>';
|
||||
this.picker.find('.datepicker-days thead').append(html);
|
||||
},
|
||||
|
||||
fillMonths: function(){
|
||||
var html = '';
|
||||
var i = 0
|
||||
while (i < 12) {
|
||||
html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>';
|
||||
}
|
||||
this.picker.find('.datepicker-months td').append(html);
|
||||
},
|
||||
|
||||
fill: function() {
|
||||
var d = new Date(this.viewDate),
|
||||
year = d.getFullYear(),
|
||||
month = d.getMonth(),
|
||||
currentDate = this.date.valueOf();
|
||||
this.picker.find('.datepicker-days th:eq(1)')
|
||||
.text(DPGlobal.dates.months[month]+' '+year);
|
||||
var prevMonth = new Date(year, month-1, 28,0,0,0,0),
|
||||
day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
|
||||
prevMonth.setDate(day);
|
||||
prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
|
||||
var nextMonth = new Date(prevMonth);
|
||||
nextMonth.setDate(nextMonth.getDate() + 42);
|
||||
nextMonth = nextMonth.valueOf();
|
||||
var html = [];
|
||||
var clsName,
|
||||
prevY,
|
||||
prevM;
|
||||
while(prevMonth.valueOf() < nextMonth) {
|
||||
if (prevMonth.getDay() === this.weekStart) {
|
||||
html.push('<tr>');
|
||||
}
|
||||
clsName = this.onRender(prevMonth);
|
||||
prevY = prevMonth.getFullYear();
|
||||
prevM = prevMonth.getMonth();
|
||||
if ((prevM < month && prevY === year) || prevY < year) {
|
||||
clsName += ' old';
|
||||
} else if ((prevM > month && prevY === year) || prevY > year) {
|
||||
clsName += ' new';
|
||||
}
|
||||
if (prevMonth.valueOf() === currentDate) {
|
||||
clsName += ' active';
|
||||
}
|
||||
html.push('<td class="day '+clsName+'">'+prevMonth.getDate() + '</td>');
|
||||
if (prevMonth.getDay() === this.weekEnd) {
|
||||
html.push('</tr>');
|
||||
}
|
||||
prevMonth.setDate(prevMonth.getDate()+1);
|
||||
}
|
||||
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
||||
var currentYear = this.date.getFullYear();
|
||||
|
||||
var months = this.picker.find('.datepicker-months')
|
||||
.find('th:eq(1)')
|
||||
.text(year)
|
||||
.end()
|
||||
.find('span').removeClass('active');
|
||||
if (currentYear === year) {
|
||||
months.eq(this.date.getMonth()).addClass('active');
|
||||
}
|
||||
|
||||
html = '';
|
||||
year = parseInt(year/10, 10) * 10;
|
||||
var yearCont = this.picker.find('.datepicker-years')
|
||||
.find('th:eq(1)')
|
||||
.text(year + '-' + (year + 9))
|
||||
.end()
|
||||
.find('td');
|
||||
year -= 1;
|
||||
for (var i = -1; i < 11; i++) {
|
||||
html += '<span class="year'+(i === -1 || i === 10 ? ' old' : '')+(currentYear === year ? ' active' : '')+'">'+year+'</span>';
|
||||
year += 1;
|
||||
}
|
||||
yearCont.html(html);
|
||||
},
|
||||
|
||||
click: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var target = $(e.target).closest('span, td, th');
|
||||
if (target.length === 1) {
|
||||
switch(target[0].nodeName.toLowerCase()) {
|
||||
case 'th':
|
||||
switch(target[0].className) {
|
||||
case 'switch':
|
||||
this.showMode(1);
|
||||
break;
|
||||
case 'prev':
|
||||
case 'next':
|
||||
this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call(
|
||||
this.viewDate,
|
||||
this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) +
|
||||
DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1)
|
||||
);
|
||||
this.fill();
|
||||
this.set();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'span':
|
||||
if (target.is('.month')) {
|
||||
var month = target.parent().find('span').index(target);
|
||||
this.viewDate.setMonth(month);
|
||||
} else {
|
||||
var year = parseInt(target.text(), 10)||0;
|
||||
this.viewDate.setFullYear(year);
|
||||
}
|
||||
if (this.viewMode !== 0) {
|
||||
this.date = new Date(this.viewDate);
|
||||
this.element.trigger({
|
||||
type: 'changeDate',
|
||||
date: this.date,
|
||||
viewMode: DPGlobal.modes[this.viewMode].clsName
|
||||
});
|
||||
}
|
||||
this.showMode(-1);
|
||||
this.fill();
|
||||
this.set();
|
||||
break;
|
||||
case 'td':
|
||||
if (target.is('.day') && !target.is('.disabled')){
|
||||
var day = parseInt(target.text(), 10)||1;
|
||||
var month = this.viewDate.getMonth();
|
||||
if (target.is('.old')) {
|
||||
month -= 1;
|
||||
} else if (target.is('.new')) {
|
||||
month += 1;
|
||||
}
|
||||
var year = this.viewDate.getFullYear();
|
||||
this.date = new Date(year, month, day,0,0,0,0);
|
||||
this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0);
|
||||
this.fill();
|
||||
this.set();
|
||||
this.element.trigger({
|
||||
type: 'changeDate',
|
||||
date: this.date,
|
||||
viewMode: DPGlobal.modes[this.viewMode].clsName
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mousedown: function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
showMode: function(dir) {
|
||||
if (dir) {
|
||||
this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
|
||||
}
|
||||
this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.datepicker = function ( option, val ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this),
|
||||
data = $this.data('datepicker'),
|
||||
options = typeof option === 'object' && option;
|
||||
if (!data) {
|
||||
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
|
||||
}
|
||||
if (typeof option === 'string') data[option](val);
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.datepicker.defaults = {
|
||||
onRender: function(date) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
$.fn.datepicker.Constructor = Datepicker;
|
||||
|
||||
var DPGlobal = {
|
||||
modes: [
|
||||
{
|
||||
clsName: 'days',
|
||||
navFnc: 'Month',
|
||||
navStep: 1
|
||||
},
|
||||
{
|
||||
clsName: 'months',
|
||||
navFnc: 'FullYear',
|
||||
navStep: 1
|
||||
},
|
||||
{
|
||||
clsName: 'years',
|
||||
navFnc: 'FullYear',
|
||||
navStep: 10
|
||||
}],
|
||||
dates:{
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||
},
|
||||
isLeapYear: function (year) {
|
||||
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
||||
},
|
||||
getDaysInMonth: function (year, month) {
|
||||
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
||||
},
|
||||
parseFormat: function(format){
|
||||
var separator = format.match(/[.\/\-\s].*?/),
|
||||
parts = format.split(/\W+/);
|
||||
if (!separator || !parts || parts.length === 0){
|
||||
throw new Error("Invalid date format.");
|
||||
}
|
||||
return {separator: separator, parts: parts};
|
||||
},
|
||||
parseDate: function(date, format) {
|
||||
var parts = date.split(format.separator),
|
||||
date = new Date(),
|
||||
val;
|
||||
date.setHours(0);
|
||||
date.setMinutes(0);
|
||||
date.setSeconds(0);
|
||||
date.setMilliseconds(0);
|
||||
if (parts.length === format.parts.length) {
|
||||
var year = date.getFullYear(), day = date.getDate(), month = date.getMonth();
|
||||
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
||||
val = parseInt(parts[i], 10)||1;
|
||||
switch(format.parts[i]) {
|
||||
case 'dd':
|
||||
case 'd':
|
||||
day = val;
|
||||
date.setDate(val);
|
||||
break;
|
||||
case 'mm':
|
||||
case 'm':
|
||||
month = val - 1;
|
||||
date.setMonth(val - 1);
|
||||
break;
|
||||
case 'yy':
|
||||
year = 2000 + val;
|
||||
date.setFullYear(2000 + val);
|
||||
break;
|
||||
case 'yyyy':
|
||||
year = val;
|
||||
date.setFullYear(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
date = new Date(year, month, day, 0 ,0 ,0);
|
||||
}
|
||||
return date;
|
||||
},
|
||||
formatDate: function(date, format){
|
||||
var val = {
|
||||
d: date.getDate(),
|
||||
m: date.getMonth() + 1,
|
||||
yy: date.getFullYear().toString().substring(2),
|
||||
yyyy: date.getFullYear()
|
||||
};
|
||||
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
||||
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
||||
var date = [];
|
||||
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
||||
date.push(val[format.parts[i]]);
|
||||
}
|
||||
return date.join(format.separator);
|
||||
},
|
||||
headTemplate: '<thead>'+
|
||||
'<tr>'+
|
||||
'<th class="prev">‹</th>'+
|
||||
'<th colspan="5" class="switch"></th>'+
|
||||
'<th class="next">›</th>'+
|
||||
'</tr>'+
|
||||
'</thead>',
|
||||
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
|
||||
};
|
||||
DPGlobal.template = '<div class="datepicker dropdown-menu">'+
|
||||
'<div class="datepicker-days">'+
|
||||
'<table class=" table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
'<tbody></tbody>'+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="datepicker-months">'+
|
||||
'<table class="table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
DPGlobal.contTemplate+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="datepicker-years">'+
|
||||
'<table class="table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
DPGlobal.contTemplate+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'</div>';
|
||||
|
||||
}( window.jQuery );
|
7
js/bootstrap.min.js
vendored
Normal file
7
js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
478
js/custom.js
Normal file
478
js/custom.js
Normal file
@ -0,0 +1,478 @@
|
||||
// Custom JS for the Theme
|
||||
|
||||
// Config
|
||||
//-------------------------------------------------------------
|
||||
|
||||
var companyName = "Car Rental Station"; // Enter your event title
|
||||
|
||||
|
||||
// Initialize Tooltip
|
||||
//-------------------------------------------------------------
|
||||
|
||||
$('.my-tooltip').tooltip();
|
||||
|
||||
|
||||
|
||||
// Initialize jQuery Placeholder
|
||||
//-------------------------------------------------------------
|
||||
|
||||
$('input, textarea').placeholder();
|
||||
|
||||
|
||||
|
||||
// Toggle Header / Nav
|
||||
//-------------------------------------------------------------
|
||||
|
||||
$(document).on("scroll",function(){
|
||||
if($(document).scrollTop()>39){
|
||||
$("header").removeClass("large").addClass("small");
|
||||
}
|
||||
else{
|
||||
$("header").removeClass("small").addClass("large");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Vehicles Tabs / Slider
|
||||
//-------------------------------------------------------------
|
||||
|
||||
$(".vehicle-data").hide();
|
||||
var activeVehicleData = $(".vehicle-nav .active a").attr("href");
|
||||
$(activeVehicleData).show();
|
||||
|
||||
$('.vehicle-nav-scroll').click(function(){
|
||||
var direction = $(this).data('direction');
|
||||
var scrollHeight = $('.vehicle-nav li').height() + 1;
|
||||
var navHeight = $('#vehicle-nav-container').height() + 1;
|
||||
var actTopPos = $(".vehicle-nav").position().top;
|
||||
var navChildHeight = $('#vehicle-nav-container').find('.vehicle-nav').height();
|
||||
var x = -(navChildHeight - navHeight);
|
||||
|
||||
var fullHeight = 0;
|
||||
$('.vehicle-nav li').each(function() {
|
||||
fullHeight += scrollHeight;
|
||||
});
|
||||
|
||||
navHeight = fullHeight - navHeight + scrollHeight;
|
||||
|
||||
// Scroll Down
|
||||
if ((direction == 'down') && (actTopPos > x) && (-navHeight <= (actTopPos - (scrollHeight * 2)))) {
|
||||
topPos = actTopPos - scrollHeight;
|
||||
$(".vehicle-nav").css('top', topPos);
|
||||
}
|
||||
|
||||
// Scroll Up
|
||||
if (direction == 'up' && 0 > actTopPos) {
|
||||
topPos = actTopPos + scrollHeight;
|
||||
$(".vehicle-nav").css('top', topPos);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(".vehicle-nav li").on("click", function(){
|
||||
|
||||
$(".vehicle-nav .active").removeClass("active");
|
||||
$(this).addClass('active');
|
||||
|
||||
$(activeVehicleData).fadeOut( "slow", function() {
|
||||
activeVehicleData = $(".vehicle-nav .active a").attr("href");
|
||||
$(activeVehicleData).fadeIn("slow", function() {});
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Vehicles Responsive Nav
|
||||
//-------------------------------------------------------------
|
||||
|
||||
$("<div />").appendTo("#vehicle-nav-container").addClass("styled-select-vehicle-data");
|
||||
$("<select />").appendTo(".styled-select-vehicle-data").addClass("vehicle-data-select");
|
||||
$("#vehicle-nav-container a").each(function() {
|
||||
var el = $(this);
|
||||
$("<option />", {
|
||||
"value" : el.attr("href"),
|
||||
"text" : el.text()
|
||||
}).appendTo("#vehicle-nav-container select");
|
||||
});
|
||||
|
||||
$(".vehicle-data-select").change(function(){
|
||||
$(activeVehicleData).fadeOut( "slow", function() {
|
||||
activeVehicleData = $(".vehicle-data-select").val();
|
||||
$(activeVehicleData).fadeIn("slow", function() {});
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Initialize Datepicker
|
||||
//-------------------------------------------------------------------------------
|
||||
var nowTemp = new Date();
|
||||
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
|
||||
|
||||
var checkin = $('#pick-up-date').datepicker({
|
||||
onRender: function (date) {
|
||||
return date.valueOf() < now.valueOf() ? 'disabled' : '';
|
||||
}
|
||||
}).on('changeDate', function (ev) {
|
||||
if (ev.date.valueOf() > checkout.date.valueOf()) {
|
||||
var newDate = new Date(ev.date)
|
||||
newDate.setDate(newDate.getDate() + 1);
|
||||
checkout.setValue(newDate);
|
||||
}
|
||||
checkin.hide();
|
||||
$('#drop-off-date')[0].focus();
|
||||
}).data('datepicker');
|
||||
var checkout = $('#drop-off-date').datepicker({
|
||||
onRender: function (date) {
|
||||
return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
|
||||
}
|
||||
}).on('changeDate', function (ev) {
|
||||
checkout.hide();
|
||||
}).data('datepicker');
|
||||
|
||||
|
||||
|
||||
// Toggle Drop-Off Location
|
||||
//-------------------------------------------------------------------------------
|
||||
$(".input-group.drop-off").hide();
|
||||
$(".different-drop-off").on("click", function(){
|
||||
$(".input-group.drop-off").toggle();
|
||||
$(".autocomplete-suggestions").css("width", $('.pick-up .autocomplete-location').outerWidth());
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Scroll to Top Button
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
$(window).scroll(function(){
|
||||
if ($(this).scrollTop() > 100) {
|
||||
$('.scrollup').removeClass("animated fadeOutRight");
|
||||
$('.scrollup').fadeIn().addClass("animated fadeInRight");
|
||||
} else {
|
||||
$('.scrollup').removeClass("animated fadeInRight");
|
||||
$('.scrollup').fadeOut().addClass("animated fadeOutRight");
|
||||
}
|
||||
});
|
||||
|
||||
$('.scrollup, .navbar-brand').click(function(){
|
||||
$("html, body").animate({ scrollTop: 0 }, 'slow', function(){
|
||||
$("nav li a").removeClass('active');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Location Map Function
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
function loadMap(addressData){
|
||||
|
||||
var path = document.URL;
|
||||
path = path.substring(0, path.lastIndexOf("/") + 1)
|
||||
|
||||
var locationContent = "<h2>"+companyName+"</h2>"
|
||||
+ "<p>"+addressData.value+"</p>";
|
||||
|
||||
var locationData = {
|
||||
map: {
|
||||
options: {
|
||||
maxZoom: 15,
|
||||
scrollwheel: false,
|
||||
}
|
||||
},
|
||||
infowindow:{
|
||||
options:{
|
||||
content: locationContent
|
||||
}
|
||||
},
|
||||
marker:{
|
||||
options: {
|
||||
icon: new google.maps.MarkerImage(
|
||||
path+"img/mapmarker.png",
|
||||
new google.maps.Size(59, 58, "px", "px"),
|
||||
new google.maps.Point(0, 0), //sets the origin point of the icon
|
||||
new google.maps.Point(29, 34) //sets the anchor point for the icon
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ($.isEmptyObject(addressData.latLng)) {
|
||||
locationData.infowindow.address = addressData.value;
|
||||
locationData.marker.address = addressData.value;
|
||||
}
|
||||
else{
|
||||
locationData.infowindow.latLng = addressData.latLng;
|
||||
locationData.marker.latLng = addressData.latLng;
|
||||
}
|
||||
|
||||
$('#locations .map').gmap3(locationData, "autofit" );
|
||||
}
|
||||
|
||||
loadMap(locations[0]);
|
||||
|
||||
|
||||
$("#location-map-select").append('<option value="'+locations[0].value+'">Please select a location</option>');
|
||||
$.each(locations, function( index, value ) {
|
||||
//console.log(index);
|
||||
var option = '<option value="'+index+'">'+value.value+'</option>';
|
||||
$("#location-map-select").append(option);
|
||||
});
|
||||
|
||||
$('#location-map-select').on('change', function() {
|
||||
$('#locations .map').gmap3('destroy');
|
||||
loadMap(locations[this.value]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Scroll To Animation
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
var scrollTo = $(".scroll-to");
|
||||
|
||||
scrollTo.click( function(event) {
|
||||
$('.modal').modal('hide');
|
||||
var position = $(document).scrollTop();
|
||||
var scrollOffset = 110;
|
||||
|
||||
if(position < 39)
|
||||
{
|
||||
scrollOffset = 260;
|
||||
}
|
||||
|
||||
var marker = $(this).attr('href');
|
||||
$('html, body').animate({ scrollTop: $(marker).offset().top - scrollOffset}, 'slow');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// setup autocomplete - pulling from locations-autocomplete.js
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
$('.autocomplete-location').autocomplete({
|
||||
lookup: locations
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Newsletter Form
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
$( "#newsletter-form" ).submit(function() {
|
||||
|
||||
$('#newsletter-form-msg').addClass('hidden');
|
||||
$('#newsletter-form-msg').removeClass('alert-success');
|
||||
$('#newsletter-form-msg').removeClass('alert-danger');
|
||||
|
||||
$('#newsletter-form input[type=submit]').attr('disabled', 'disabled');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "php/index.php",
|
||||
data: $("#newsletter-form").serialize(),
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
if('success' == data.result)
|
||||
{
|
||||
$('#newsletter-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-success');
|
||||
$('#newsletter-form-msg').html(data.msg[0]);
|
||||
$('#newsletter-form input[type=submit]').removeAttr('disabled');
|
||||
$('#newsletter-form')[0].reset();
|
||||
}
|
||||
|
||||
if('error' == data.result)
|
||||
{
|
||||
$('#newsletter-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-danger');
|
||||
$('#newsletter-form-msg').html(data.msg[0]);
|
||||
$('#newsletter-form input[type=submit]').removeAttr('disabled');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Contact Form
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
$( "#contact-form" ).submit(function() {
|
||||
|
||||
$('#contact-form-msg').addClass('hidden');
|
||||
$('#contact-form-msg').removeClass('alert-success');
|
||||
$('#contact-form-msg').removeClass('alert-danger');
|
||||
|
||||
$('#contact-form input[type=submit]').attr('disabled', 'disabled');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "php/index.php",
|
||||
data: $("#contact-form").serialize(),
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
if('success' == data.result)
|
||||
{
|
||||
$('#contact-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-success');
|
||||
$('#contact-form-msg').html(data.msg[0]);
|
||||
$('#contact-form input[type=submit]').removeAttr('disabled');
|
||||
$('#contact-form')[0].reset();
|
||||
}
|
||||
|
||||
if('error' == data.result)
|
||||
{
|
||||
$('#contact-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-danger');
|
||||
$('#contact-form-msg').html(data.msg[0]);
|
||||
$('#contact-form input[type=submit]').removeAttr('disabled');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Car Select Form
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
$( "#car-select-form" ).submit(function() {
|
||||
|
||||
var selectedCar = $("#car-select").find(":selected").text();
|
||||
var selectedCarVal = $("#car-select").find(":selected").val();
|
||||
var selectedCarImage = $("#car-select").val();
|
||||
var pickupLocation = $("#pick-up-location").val();
|
||||
var dropoffLocation = $("#drop-off-location").val();
|
||||
var pickUpDate = $("#pick-up-date").val();
|
||||
var pickUpTime = $("#pick-up-time").val();
|
||||
var dropOffDate = $("#drop-off-date").val();
|
||||
var dropOffTime = $("#drop-off-time").val();
|
||||
|
||||
var error = 0;
|
||||
|
||||
if(validateNotEmpty(selectedCarVal)) { error = 1; }
|
||||
if(validateNotEmpty(pickupLocation)) { error = 1; }
|
||||
if(validateNotEmpty(pickUpDate)) { error = 1; }
|
||||
if(validateNotEmpty(dropOffDate)) { error = 1; }
|
||||
|
||||
if(0 == error)
|
||||
{
|
||||
|
||||
$("#selected-car-ph").html(selectedCar);
|
||||
$("#selected-car").val(selectedCar);
|
||||
$("#selected-vehicle-image").attr('src', selectedCarImage);
|
||||
|
||||
$("#pickup-location-ph").html(pickupLocation);
|
||||
$("#pickup-location").val(pickupLocation);
|
||||
|
||||
if("" == dropoffLocation)
|
||||
{
|
||||
$("#dropoff-location-ph").html(pickupLocation);
|
||||
$("#dropoff-location").val(pickupLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#dropoff-location-ph").html(dropoffLocation);
|
||||
$("#dropoff-location").val(dropoffLocation);
|
||||
}
|
||||
|
||||
$("#pick-up-date-ph").html(pickUpDate);
|
||||
$("#pick-up-time-ph").html(pickUpTime);
|
||||
$("#pick-up").val(pickUpDate+' at '+pickUpTime);
|
||||
|
||||
$("#drop-off-date-ph").html(dropOffDate);
|
||||
$("#drop-off-time-ph").html(dropOffTime);
|
||||
$("#drop-off").val(dropOffDate+' at '+dropOffTime);
|
||||
|
||||
$('#checkoutModal').modal();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#car-select-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').delay(2000).fadeOut();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Check Out Form
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
$( "#checkout-form" ).submit(function() {
|
||||
|
||||
$('#checkout-form-msg').addClass('hidden');
|
||||
$('#checkout-form-msg').removeClass('alert-success');
|
||||
$('#checkout-form-msg').removeClass('alert-danger');
|
||||
|
||||
$('#checkout-form input[type=submit]').attr('disabled', 'disabled');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "php/index.php",
|
||||
data: $("#checkout-form").serialize(),
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
if('success' == data.result)
|
||||
{
|
||||
$('#checkout-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-success');
|
||||
$('#checkout-form-msg').html(data.msg[0]);
|
||||
$('#checkout-form input[type=submit]').removeAttr('disabled');
|
||||
|
||||
setTimeout(function(){
|
||||
$('.modal').modal('hide');
|
||||
$('#checkout-form-msg').addClass('hidden');
|
||||
$('#checkout-form-msg').removeClass('alert-success');
|
||||
|
||||
$('#checkout-form')[0].reset();
|
||||
$('#car-select-form')[0].reset();
|
||||
}, 5000);
|
||||
|
||||
}
|
||||
|
||||
if('error' == data.result)
|
||||
{
|
||||
$('#checkout-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-danger');
|
||||
$('#checkout-form-msg').html(data.msg[0]);
|
||||
$('#checkout-form input[type=submit]').removeAttr('disabled');
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Not Empty Validator Function
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
function validateNotEmpty(data){
|
||||
if (data == ''){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
10
js/gmap3.min.js
vendored
Normal file
10
js/gmap3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
js/jquery-1.11.0.min.js
vendored
Normal file
4
js/jquery-1.11.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
25
js/jquery.autocomplete.min.js
vendored
Normal file
25
js/jquery.autocomplete.min.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Ajax Autocomplete for jQuery, version 1.2.7
|
||||
* (c) 2013 Tomas Kirda
|
||||
*
|
||||
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
|
||||
* For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
|
||||
*
|
||||
*/
|
||||
(function(e){"function"===typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function g(a,b){var c=function(){},c={autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:g.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:c,onSearchComplete:c,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",lookupFilter:function(a,b,c){return-1!==
|
||||
a.value.toLowerCase().indexOf(c)},paramName:"query",transformResult:function(a){return"string"===typeof a?e.parseJSON(a):a}};this.element=a;this.el=e(a);this.suggestions=[];this.badQueries=[];this.selectedIndex=-1;this.currentValue=this.element.value;this.intervalId=0;this.cachedResponse=[];this.onChange=this.onChangeInterval=null;this.isLocal=this.ignoreValueChange=!1;this.suggestionsContainer=null;this.options=e.extend({},c,b);this.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"};
|
||||
this.initialize();this.setOptions(b)}var h={extend:function(a,b){return e.extend(a,b)},createNode:function(a){var b=document.createElement("div");b.innerHTML=a;return b.firstChild}};g.utils=h;e.Autocomplete=g;g.formatResult=function(a,b){var c="("+b.replace(RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)","g"),"\\$1")+")";return a.value.replace(RegExp(c,"gi"),"<strong>$1</strong>")};g.prototype={killerFn:null,initialize:function(){var a=this,b="."+a.classes.suggestion,c=a.classes.selected,
|
||||
d=a.options,f;a.element.setAttribute("autocomplete","off");a.killerFn=function(b){0===e(b.target).closest("."+a.options.containerClass).length&&(a.killSuggestions(),a.disableKillerFn())};if(!d.width||"auto"===d.width)d.width=a.el.outerWidth();a.suggestionsContainer=g.utils.createNode('<div class="'+d.containerClass+'" style="position: absolute; display: none;"></div>');f=e(a.suggestionsContainer);f.appendTo(d.appendTo).width(d.width);f.on("mouseover.autocomplete",b,function(){a.activate(e(this).data("index"))});
|
||||
f.on("mouseout.autocomplete",function(){a.selectedIndex=-1;f.children("."+c).removeClass(c)});f.on("click.autocomplete",b,function(){a.select(e(this).data("index"),!1)});a.fixPosition();if(window.opera)a.el.on("keypress.autocomplete",function(b){a.onKeyPress(b)});else a.el.on("keydown.autocomplete",function(b){a.onKeyPress(b)});a.el.on("keyup.autocomplete",function(b){a.onKeyUp(b)});a.el.on("blur.autocomplete",function(){a.onBlur()});a.el.on("focus.autocomplete",function(){a.fixPosition()})},onBlur:function(){this.enableKillerFn()},
|
||||
setOptions:function(a){var b=this.options;h.extend(b,a);if(this.isLocal=e.isArray(b.lookup))b.lookup=this.verifySuggestionsFormat(b.lookup);e(this.suggestionsContainer).css({"max-height":b.maxHeight+"px",width:b.width+"px","z-index":b.zIndex})},clearCache:function(){this.cachedResponse=[];this.badQueries=[]},clear:function(){this.clearCache();this.currentValue=null;this.suggestions=[]},disable:function(){this.disabled=!0},enable:function(){this.disabled=!1},fixPosition:function(){var a;"body"===this.options.appendTo&&
|
||||
(a=this.el.offset(),e(this.suggestionsContainer).css({top:a.top+this.el.outerHeight()+"px",left:a.left+"px"}))},enableKillerFn:function(){e(document).on("click.autocomplete",this.killerFn)},disableKillerFn:function(){e(document).off("click.autocomplete",this.killerFn)},killSuggestions:function(){var a=this;a.stopKillSuggestions();a.intervalId=window.setInterval(function(){a.hide();a.stopKillSuggestions()},300)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},onKeyPress:function(a){if(!this.disabled&&
|
||||
!this.visible&&40===a.keyCode&&this.currentValue)this.suggest();else if(!this.disabled&&this.visible){switch(a.keyCode){case 27:this.el.val(this.currentValue);this.hide();break;case 9:case 13:if(-1===this.selectedIndex){this.hide();return}this.select(this.selectedIndex,13===a.keyCode);if(9===a.keyCode&&!1===this.options.tabDisabled)return;break;case 38:this.moveUp();break;case 40:this.moveDown();break;default:return}a.stopImmediatePropagation();a.preventDefault()}},onKeyUp:function(a){var b=this;
|
||||
if(!b.disabled){switch(a.keyCode){case 38:case 40:return}clearInterval(b.onChangeInterval);if(b.currentValue!==b.el.val())if(0<b.options.deferRequestBy)b.onChangeInterval=setInterval(function(){b.onValueChange()},b.options.deferRequestBy);else b.onValueChange()}},onValueChange:function(){var a;clearInterval(this.onChangeInterval);this.currentValue=this.element.value;a=this.getQuery(this.currentValue);this.selectedIndex=-1;this.ignoreValueChange?this.ignoreValueChange=!1:a.length<this.options.minChars?
|
||||
this.hide():this.getSuggestions(a)},getQuery:function(a){var b=this.options.delimiter;if(!b)return e.trim(a);a=a.split(b);return e.trim(a[a.length-1])},getSuggestionsLocal:function(a){var b=a.toLowerCase(),c=this.options.lookupFilter;return{suggestions:e.grep(this.options.lookup,function(d){return c(d,a,b)})}},getSuggestions:function(a){var b,c=this,d=c.options,f=d.serviceUrl;(b=c.isLocal?c.getSuggestionsLocal(a):c.cachedResponse[a])&&e.isArray(b.suggestions)?(c.suggestions=b.suggestions,c.suggest()):
|
||||
c.isBadQuery(a)||(d.params[d.paramName]=a,!1!==d.onSearchStart.call(c.element,d.params)&&(e.isFunction(d.serviceUrl)&&(f=d.serviceUrl.call(c.element,a)),e.ajax({url:f,data:d.ignoreParams?null:d.params,type:d.type,dataType:d.dataType}).done(function(b){c.processResponse(b,a);d.onSearchComplete.call(c.element,a)})))},isBadQuery:function(a){for(var b=this.badQueries,c=b.length;c--;)if(0===a.indexOf(b[c]))return!0;return!1},hide:function(){this.visible=!1;this.selectedIndex=-1;e(this.suggestionsContainer).hide()},
|
||||
suggest:function(){if(0===this.suggestions.length)this.hide();else{var a=this.options.formatResult,b=this.getQuery(this.currentValue),c=this.classes.suggestion,d=this.classes.selected,f=e(this.suggestionsContainer),g="";e.each(this.suggestions,function(d,e){g+='<div class="'+c+'" data-index="'+d+'">'+a(e,b)+"</div>"});f.html(g).show();this.visible=!0;this.options.autoSelectFirst&&(this.selectedIndex=0,f.children().first().addClass(d))}},verifySuggestionsFormat:function(a){return a.length&&"string"===
|
||||
typeof a[0]?e.map(a,function(a){return{value:a,data:null}}):a},processResponse:function(a,b){var c=this.options,d=c.transformResult(a,b);d.suggestions=this.verifySuggestionsFormat(d.suggestions);c.noCache||(this.cachedResponse[d[c.paramName]]=d,0===d.suggestions.length&&this.badQueries.push(d[c.paramName]));b===this.getQuery(this.currentValue)&&(this.suggestions=d.suggestions,this.suggest())},activate:function(a){var b=this.classes.selected,c=e(this.suggestionsContainer),d=c.children();c.children("."+
|
||||
b).removeClass(b);this.selectedIndex=a;return-1!==this.selectedIndex&&d.length>this.selectedIndex?(a=d.get(this.selectedIndex),e(a).addClass(b),a):null},select:function(a,b){var c=this.suggestions[a];c&&(this.el.val(c),this.ignoreValueChange=b,this.hide(),this.onSelect(a))},moveUp:function(){-1!==this.selectedIndex&&(0===this.selectedIndex?(e(this.suggestionsContainer).children().first().removeClass(this.classes.selected),this.selectedIndex=-1,this.el.val(this.currentValue)):this.adjustScroll(this.selectedIndex-
|
||||
1))},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(a){var b=this.activate(a),c,d;b&&(b=b.offsetTop,c=e(this.suggestionsContainer).scrollTop(),d=c+this.options.maxHeight-25,b<c?e(this.suggestionsContainer).scrollTop(b):b>d&&e(this.suggestionsContainer).scrollTop(b-this.options.maxHeight+25),this.el.val(this.getValue(this.suggestions[a].value)))},onSelect:function(a){var b=this.options.onSelect;a=this.suggestions[a];
|
||||
this.el.val(this.getValue(a.value));e.isFunction(b)&&b.call(this.element,a)},getValue:function(a){var b=this.options.delimiter,c;if(!b)return a;c=this.currentValue;b=c.split(b);return 1===b.length?a:c.substr(0,c.length-b[b.length-1].length)+a},dispose:function(){this.el.off(".autocomplete").removeData("autocomplete");this.disableKillerFn();e(this.suggestionsContainer).remove()}};e.fn.autocomplete=function(a,b){return 0===arguments.length?this.first().data("autocomplete"):this.each(function(){var c=
|
||||
e(this),d=c.data("autocomplete");if("string"===typeof a){if(d&&"function"===typeof d[a])d[a](b)}else d&&d.dispose&&d.dispose(),d=new g(this,a),c.data("autocomplete",d)})}});
|
185
js/jquery.placeholder.js
Normal file
185
js/jquery.placeholder.js
Normal file
@ -0,0 +1,185 @@
|
||||
/*! http://mths.be/placeholder v2.0.8 by @mathias */
|
||||
;(function(window, document, $) {
|
||||
|
||||
// Opera Mini v7 doesn’t support placeholder although its DOM seems to indicate so
|
||||
var isOperaMini = Object.prototype.toString.call(window.operamini) == '[object OperaMini]';
|
||||
var isInputSupported = 'placeholder' in document.createElement('input') && !isOperaMini;
|
||||
var isTextareaSupported = 'placeholder' in document.createElement('textarea') && !isOperaMini;
|
||||
var prototype = $.fn;
|
||||
var valHooks = $.valHooks;
|
||||
var propHooks = $.propHooks;
|
||||
var hooks;
|
||||
var placeholder;
|
||||
|
||||
if (isInputSupported && isTextareaSupported) {
|
||||
|
||||
placeholder = prototype.placeholder = function() {
|
||||
return this;
|
||||
};
|
||||
|
||||
placeholder.input = placeholder.textarea = true;
|
||||
|
||||
} else {
|
||||
|
||||
placeholder = prototype.placeholder = function() {
|
||||
var $this = this;
|
||||
$this
|
||||
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
|
||||
.not('.placeholder')
|
||||
.bind({
|
||||
'focus.placeholder': clearPlaceholder,
|
||||
'blur.placeholder': setPlaceholder
|
||||
})
|
||||
.data('placeholder-enabled', true)
|
||||
.trigger('blur.placeholder');
|
||||
return $this;
|
||||
};
|
||||
|
||||
placeholder.input = isInputSupported;
|
||||
placeholder.textarea = isTextareaSupported;
|
||||
|
||||
hooks = {
|
||||
'get': function(element) {
|
||||
var $element = $(element);
|
||||
|
||||
var $passwordInput = $element.data('placeholder-password');
|
||||
if ($passwordInput) {
|
||||
return $passwordInput[0].value;
|
||||
}
|
||||
|
||||
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
|
||||
},
|
||||
'set': function(element, value) {
|
||||
var $element = $(element);
|
||||
|
||||
var $passwordInput = $element.data('placeholder-password');
|
||||
if ($passwordInput) {
|
||||
return $passwordInput[0].value = value;
|
||||
}
|
||||
|
||||
if (!$element.data('placeholder-enabled')) {
|
||||
return element.value = value;
|
||||
}
|
||||
if (value == '') {
|
||||
element.value = value;
|
||||
// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
|
||||
if (element != safeActiveElement()) {
|
||||
// We can't use `triggerHandler` here because of dummy text/password inputs :(
|
||||
setPlaceholder.call(element);
|
||||
}
|
||||
} else if ($element.hasClass('placeholder')) {
|
||||
clearPlaceholder.call(element, true, value) || (element.value = value);
|
||||
} else {
|
||||
element.value = value;
|
||||
}
|
||||
// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
|
||||
return $element;
|
||||
}
|
||||
};
|
||||
|
||||
if (!isInputSupported) {
|
||||
valHooks.input = hooks;
|
||||
propHooks.value = hooks;
|
||||
}
|
||||
if (!isTextareaSupported) {
|
||||
valHooks.textarea = hooks;
|
||||
propHooks.value = hooks;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// Look for forms
|
||||
$(document).delegate('form', 'submit.placeholder', function() {
|
||||
// Clear the placeholder values so they don't get submitted
|
||||
var $inputs = $('.placeholder', this).each(clearPlaceholder);
|
||||
setTimeout(function() {
|
||||
$inputs.each(setPlaceholder);
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
|
||||
// Clear placeholder values upon page reload
|
||||
$(window).bind('beforeunload.placeholder', function() {
|
||||
$('.placeholder').each(function() {
|
||||
this.value = '';
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function args(elem) {
|
||||
// Return an object of element attributes
|
||||
var newAttrs = {};
|
||||
var rinlinejQuery = /^jQuery\d+$/;
|
||||
$.each(elem.attributes, function(i, attr) {
|
||||
if (attr.specified && !rinlinejQuery.test(attr.name)) {
|
||||
newAttrs[attr.name] = attr.value;
|
||||
}
|
||||
});
|
||||
return newAttrs;
|
||||
}
|
||||
|
||||
function clearPlaceholder(event, value) {
|
||||
var input = this;
|
||||
var $input = $(input);
|
||||
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
|
||||
if ($input.data('placeholder-password')) {
|
||||
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
|
||||
// If `clearPlaceholder` was called from `$.valHooks.input.set`
|
||||
if (event === true) {
|
||||
return $input[0].value = value;
|
||||
}
|
||||
$input.focus();
|
||||
} else {
|
||||
input.value = '';
|
||||
$input.removeClass('placeholder');
|
||||
input == safeActiveElement() && input.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setPlaceholder() {
|
||||
var $replacement;
|
||||
var input = this;
|
||||
var $input = $(input);
|
||||
var id = this.id;
|
||||
if (input.value == '') {
|
||||
if (input.type == 'password') {
|
||||
if (!$input.data('placeholder-textinput')) {
|
||||
try {
|
||||
$replacement = $input.clone().attr({ 'type': 'text' });
|
||||
} catch(e) {
|
||||
$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
|
||||
}
|
||||
$replacement
|
||||
.removeAttr('name')
|
||||
.data({
|
||||
'placeholder-password': $input,
|
||||
'placeholder-id': id
|
||||
})
|
||||
.bind('focus.placeholder', clearPlaceholder);
|
||||
$input
|
||||
.data({
|
||||
'placeholder-textinput': $replacement,
|
||||
'placeholder-id': id
|
||||
})
|
||||
.before($replacement);
|
||||
}
|
||||
$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
|
||||
// Note: `$input[0] != input` now!
|
||||
}
|
||||
$input.addClass('placeholder');
|
||||
$input[0].value = $input.attr('placeholder');
|
||||
} else {
|
||||
$input.removeClass('placeholder');
|
||||
}
|
||||
}
|
||||
|
||||
function safeActiveElement() {
|
||||
// Avoid IE9 `document.activeElement` of death
|
||||
// https://github.com/mathiasbynens/jquery-placeholder/pull/99
|
||||
try {
|
||||
return document.activeElement;
|
||||
} catch (exception) {}
|
||||
}
|
||||
|
||||
}(this, document, jQuery));
|
9
js/locations-autocomplete.js
Normal file
9
js/locations-autocomplete.js
Normal file
@ -0,0 +1,9 @@
|
||||
var locations = [
|
||||
{ value: "Santa Monica - 2102 Lincoln Blvd"},
|
||||
{ value: "With Co-Ordinates - 5711 W Century Blvd", latLng: [33.946272, -118.381641]},
|
||||
{ value: "Las Vegas - 6401 Centennial Center Blvd"},
|
||||
{ value: "New York - 610 Warren St"},
|
||||
{ value: "Orlando - 2125 W Landstreet Rd"},
|
||||
{ value: "Washington - 50 Massachusetts Ave NE"},
|
||||
{ value: "Denver - 7800 E Tufts Ave"}
|
||||
];
|
Reference in New Issue
Block a user