/* #Configuration Parameters
================================================== */
var captionAnimated;
var imageHoveringIcon;
var imageHoveringIconPos;
var useAutoMap;
var address;
jQuery(document).ready(function($) {
/* #Configuration
================================================== */
// Animate the banner caption?
captionAnimated = ThemeSettings.caption_movement == '' ? false : true;
// Show notification icon for any clickable image?
imageHoveringIcon = true;
/* Position of the icon:
* rt = Right Top
* lt = Left Top
* rb = Right Bottom
* lb = Left Bottom
*/
imageHoveringIconPos = ThemeSettings.hovering_icon_position;
/* #Start calling required functions
================================================== */
initConfig();
initEvents();
initWidgetsShortcodes();
initPlugins();
initDropdownMenu();
/* #Initialize Configuration
================================================== */
function initConfig() {
if (!captionAnimated) {
$('.banner-caption.left').css({
opacity : '1',
left : '0'
});
$('.banner-caption.right').css({
opacity : '1',
right : '0'
});
}
if (imageHoveringIcon) {
var hoverignItems = $('.hover');
hoverignItems.append('+');
}
}
/* #Initialize Event Handlers
================================================== */
function initEvents() {
// Assign each submenu's prefix
var subMenu = $('ul.sub-menu');
for(var i=0; i' + level + '- ' + menuText);
}
}
// Read-more image hovering
var readmore = $('.readmore');
var readmoreText = $('.readmore span.text');
readmore.animate({
opacity : '0'
}, 10);
// View-photo image hovering
var photo = $('.photo');
var photoText = $('.photo span.text');
photo.animate({
opacity : '0'
}, 10);
var startPosition, endPosition;
// Image hovering function
$('.hover').hover(function() {
var img = $(this).find('div');
var imgHeight = img.height();
var imgWidth = img.width();
startPosition = (imgHeight / 2 + 30);
endPosition = (imgHeight / 2 + 20);
readmore.css({
backgroundPosition : (imgWidth / 2 - 10) + 'px ' + (imgHeight / 2 - 15) + 'px',
display : 'block'
});
readmoreText.css('top', startPosition + 'px');
photo.css({
backgroundPosition : (imgWidth / 2 - 15) + 'px ' + (imgHeight / 2 - 20) + 'px',
display : 'block'
});
photoText.css('top', startPosition + 'px');
$(this).find(readmore).stop().animate({
opacity : '.7'
}, 500, 'easeOutQuint');
$(this).find(readmore).find(readmoreText).stop().animate({
top : endPosition + 'px'
}, 500);
$(this).find(photo).stop().animate({
opacity : '.7'
}, 500, 'easeOutQuint');
$(this).find(photo).find(photoText).stop().animate({
top : endPosition + 'px'
}, 500);
}, function() {
$(this).find(readmore).stop().animate({
opacity : '0'
}, 500, 'easeOutQuint');
$(this).find(readmore).find(readmoreText).stop().animate({
top : startPosition + 'px'
}, 500);
$(this).find(photo).stop().animate({
opacity : '0'
}, 500, 'easeOutQuint');
$(this).find(photo).find(photoText).stop().animate({
top : startPosition + 'px'
}, 500);
})
// Submitting comment form
if ($('form#commentform').length > 0) {
var commentForm = $('form#commentform');
commentForm.attr('class', 'validate');
commentForm.submit(function() {
if (!commentForm.validationEngine('validate')) {
return;
}
});
}
if ($('form#commentform #submit').length > 0) {
$('form#commentform #submit').attr('class', 'medium gray button');
}
/* Lamoon v2.2 */
// Fixed weird submit button display for some plugins like Contact Form 7
$('input[type="submit"]').addClass('medium gray button');
// Fixed line-through-headings for custom/plugin headings
var headings = $('#content').find('h1, h2, h3, h4, h5').not(':has(span)');
for(var i=0; i 0) {
$(contactFormId).validationEngine('attach', {
autoHidePrompt : 'false',
autoHideDelay : '7000',
fixed : true,
scroll : false,
binded : false,
promptPosition : 'centerRight'
});
if ($(contactFormId).length > 0) {
var contactForm = $(contactFormId);
var nonce = contactForm.attr('data-nonce');
contactForm.submit(function() {
if (contactForm.validationEngine('validate')) {
$submitButton = $(this).find('input[type="submit"]');
$submitButton.removeClass().addClass('medium gray button disabled');
$submitButton.attr('value', 'Submitting...');
$.ajax({
type : 'POST',
dataType : 'json',
url : ThemeAjax.ajaxURL,
data : contactForm.serialize() + '&action=submit_contact_form&nonce=' + nonce,
success : function(result) {
if (result.status == 'true') {
contactForm.stop().animate({
opacity : '0'
}, 400, function() {
contactForm.css('display', 'none');
var id = '#success_' + contactFormId.replace('#', '');
$(id).css('display', 'block');
$(id).stop().animate({
opacity : '1'
}, 900);
});
} else {
var id = '#error_' + contactFormId.replace('#', '');
$(id).css('display', 'block');
$(id).stop().animate({
opacity : '1'
}, 1000);
alert('Error Message: ' + result);
}
},
error : function(xmlHttpRequest, textStatus, errorThrown) {
var id = '#error_' + contactFormId.replace('#', '');
$(id).css('display', 'block');
$(id).stop().animate({
opacity : '1'
}, 1000);
alert(xmlHttpRequest.responseText);
alert(errorThrown);
}
});
return false;
}
});
}
}
}
/* #Reservation Form Event Handlers
================================================== */
function bindReservationFormSubmitEvent(reservatioinFormId) {
if ($(reservatioinFormId).length > 0) {
$(reservatioinFormId).validationEngine('attach', {
autoHidePrompt : 'false',
autoHideDelay : '7000',
fixed : true,
scroll : false,
binded : false,
promptPosition : 'centerRight'
});
if ($(reservatioinFormId).length > 0) {
var reservationForm = $(reservatioinFormId);
var nonce = reservationForm.attr('data-nonce');
reservationForm.submit(function() {
if (reservationForm.validationEngine('validate')) {
$submitButton = $(this).find('input[type="submit"]');
$submitButton.removeClass().addClass('medium gray button disabled');
$submitButton.attr('value', 'Submitting...');
$.ajax({
type : "POST",
dataType : 'json',
url : ThemeAjax.ajaxURL,
data : reservationForm.serialize() + '&action=submit_reservation_form&nonce=' + nonce,
success : function(result) {
if (result.status == 'true') {
$('body').animate({
scrollTop : 0
}, 1500, 'easeOutQuint', function() {
reservationForm.stop().animate({
opacity : '0'
}, 400, function() {
reservationForm.css('display', 'none');
var id = '#success_' + reservatioinFormId.replace('#', '');
$(id).css('display', 'block');
$(id).stop().animate({
opacity : '1'
}, 900);
});
});
} else {
var id = '#error_' + reservatioinFormId.replace('#', '');
$(id).css('display', 'block');
$(id).stop().animate({
opacity : '1'
}, 1000);
alert('Error Message: ' + result);
}
},
error : function(xmlHttpRequest, textStatus, errorThrown) {
var id = '#error_' + reservatioinFormId.replace('#', '');
$(id).css('display', 'block');
$(id).stop().animate({
opacity : '1'
}, 1000);
alert(xmlHttpRequest.responseText);
alert(errorThrown);
}
});
return false;
}
});
}
}
}
/* #Initialize Widgets and Shortcodes
================================================== */
function initWidgetsShortcodes() {
// Contact Form
var contactFormList = $('form[id^="contact-form_"]');
var contactFormCount = contactFormList.length;
if(contactFormCount > 0) {
for(var i=0; i 0) {
for(var i=0; i 0) {
$('.widget-testimonials').cycle({
timeout: testimonialSpeed,
});
}
if($('.shortcode-testimonials').length > 0) {
$('.shortcode-testimonials').cycle({
timeout: testimonialSpeed,
});
}
}
/* #Initialize Plugins
================================================== */
function initPlugins() {
if(ThemeSettings.to_top != '') {
$().UItoTop({
easingType : 'easeOutQuart'
});
}
// FlexSlider
$('#banner-slider').flexslider({
animation: ThemeSettings.slider_animation,
//easing: ThemeSettings.slider_animation_easing,
//direction: ThemeSettings.slider_direction,
slideshow: ThemeSettings.slider_auto_animated,
animationSpeed : parseInt(ThemeSettings.slider_animation_speed),
useCSS: true,
slideshowSpeed : 6000,
pauseOnAction : false,
pauseOnHover : true,
controlNav : false,
start : function() {
showBannerCaptions();
},
before : function() {
if (captionAnimated) {
$('.banner-caption.left').stop().animate({
opacity : '0',
left : '0'
}, 10);
$('.banner-caption.right').stop().animate({
opacity : '0',
right : '0'
}, 10);
}
},
after : function() {
showBannerCaptions();
}
});
$('.page-content').flexslider({
startAt : 0,
animationSpeed : 800,
slideshowSpeed : 4000,
pauseOnAction : true,
pauseOnHover : true,
directionNav : false
});
// Superfish
var subs = $('ul.sf-menu').supersubs({
minWidth: 14,
maxWidth: 30,
extraWidth: 2
});
if(ThemeSettings.submenu_appearance == 'fade') {
subs.superfish({
animation : {
opacity: 'show'
},
delay : 1000,
speed : ThemeSettings.submenu_appearance_speed
});
} else if(ThemeSettings.submenu_appearance == 'slide'){
subs.superfish({
animation : {
opacity: 'show',
height: 'show'
},
delay : 1000,
speed : ThemeSettings.submenu_appearance_speed
});
}
// jQuery Cycle
$('#home-testimonial').cycle();
// v3.0: Add lightbox for WP Gallery. Must call this before FancyBox usage below
var lightbox_enabled = ThemeSettings.enable_lightbox_wp_gallery;// == '' ? false : true;
if(lightbox_enabled) {
registerFancyBoxToWPGallery();
}
// FancyBox
$('.image-box').fancybox({
padding : '0',
centerOnScroll : true,
overlayOpacity : '0.9',
overlayColor : '#222',
transitionIn : 'elastic',
transitionOut : 'elastic',
speedIn : 500,
speedOut : 300,
showNavArrows : true
});
// FancyBox caption
$('.image-box.caption').fancybox({
titlePosition : 'over',
padding : '0',
centerOnScroll : true,
overlayOpacity : '0.9',
overlayColor : '#222',
transitionIn : 'elastic',
transitionOut : 'elastic',
speedIn : 500,
speedOut : 300,
showNavArrows : true
});
// Validation Engine
if ($('form.validate').length > 0) {
$('form.validate').validationEngine('attach', {
autoHidePrompt : 'false',
autoHideDelay : '7000',
fixed : true,
scroll : false,
binded : false,
promptPosition : 'centerRight'
});
}
// Date Picker
if ($('.datepicker').length > 0) {
$('.datepicker').datepicker();
}
// Numeric Spinner
if ($('.spinner').length > 0) {
$('.spinner').spinner({
min : 1,
max : 100
});
$('.spinner-min0').spinner({
min : 0,
max : 100
});
}
// v3.0: Updated code
// Accordion/Toggle
var animateObj = {
animate: 'easeOutQuint',
duration: 600,
};
if ($('.accordion').length > 0) {
$('.accordion').each(function() {
$(this).accordion({
autoHeight: false,
icons: false,
collapsible: false,
animate: animateObj,
active: parseInt($(this).attr('data-active-index'))
});
});
}
if ($('.toggle').length > 0) {
$('.toggle').accordion({
autoHeight: false,
icons: false,
animate: animateObj,
collapsible: true,
active: false,
});
if($('.toggle').hasClass('active')) {
$('.toggle.active').accordion({
heightStyle: 'content',
autoHeight: false,
icons: false,
animate: animateObj,
collapsible: true,
active: 0,
});
$('body').scrollTop(0);
}
}
}
/* #Banner Caption
================================================== */
function showBannerCaptions() {
if (captionAnimated) {
var leftCaption = $('.banner-caption.left');
leftCaption.css({
opacity : '0',
left : '100px'
});
leftCaption.stop().animate({
opacity : '1',
left : '0'
}, 2500, 'easeOutQuint');
var rightCaption = $('.banner-caption.right');
rightCaption.css({
opacity : '0',
right : '100px'
});
rightCaption.stop().animate({
opacity : '1',
right : '0'
}, 2500, 'easeOutQuint');
}
}
// v3.0: Added lightbox support for WP Gallery shortcode
function registerFancyBoxToWPGallery() {
// WP Gallery shortcode
var $wpGallery = $('.gallery');
$wpGallery.each(function() {
var mainId = $(this).attr('id');
var items = $(this).find('.gallery-item').find('a');
items.each(function() {
var href = $(this).attr('href');
if(href.toLowerCase().indexOf('.jpg') >= 0 ||
href.toLowerCase().indexOf('.jpeg') >= 0 ||
href.toLowerCase().indexOf('.png') >= 0 ||
href.toLowerCase().indexOf('.gif') >= 0) {
$(this).addClass('clickable-image photo image-box');
$(this).attr('rel', mainId);
} else {
$(this).addClass('clickable-image link');
}
});
});
}
/* #Dropdown Menu for Showing on Small Devices
================================================== */
// v3.0: Updated code
function initDropdownMenu() {
// Create the dropdown bases
var sel = $('').appendTo('#menu');
// Create default option
sel.append($('