Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/devcows/hugo-universal-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorAdrián Moreno <adrian@morenomartinez.com>2016-10-11 17:08:32 +0300
committerGitHub <noreply@github.com>2016-10-11 17:08:32 +0300
commit808caed6c859aea638db09f536b42459693031f0 (patch)
tree7268ccca5d57fbe09880a641a683107b6df3c3be /static
parent78b1b7765476bd07c8c452963fb8ace675918cf8 (diff)
parent31790561847f8a64bd52f5b873eea07e53ee87e2 (diff)
Merge pull request #14 from devcows/feature_contact_ajax
Post contact form via ajax with jquery.
Diffstat (limited to 'static')
-rw-r--r--static/js/front.js391
1 files changed, 208 insertions, 183 deletions
diff --git a/static/js/front.js b/static/js/front.js
index 07980c1..053302d 100644
--- a/static/js/front.js
+++ b/static/js/front.js
@@ -17,62 +17,87 @@ $(function () {
animations();
counters();
demo();
+ contactForm();
});
+//Ajax contact
+function contactForm() {
+ var form = $('.contact-form');
+ form.submit(function () {
+ $this = $(this);
+ $.post($(this).attr('action'),
+ $this.serialize(),
+ function(data) {
+ $this[0].reset(); // clear form
+ $('#contact-message')
+ .html('<div class="alert alert-success" role="alert"> \
+ <button type="button" class="close" data-dismiss="alert"> \
+ <span aria-hidden="true">×</span> \
+ <span class="sr-only">Close</span> \
+ </button> \
+ Thank you for getting in touch. We will get back to you soon! \
+ </div>')
+ .fadeIn();
+ }
+ ,'json');
+ return false;
+ });
+}
+
/* for demo purpose only - can be deleted */
function demo() {
if ($.cookie("theme_csspath")) {
- $('link#theme-stylesheet').attr("href", $.cookie("theme_csspath"));
+ $('link#theme-stylesheet').attr("href", $.cookie("theme_csspath"));
}
$("#colour").change(function () {
- if ($(this).val() !== '') {
+ if ($(this).val() !== '') {
- var theme_csspath = 'css/style.' + $(this).val() + '.css';
+ var theme_csspath = 'css/style.' + $(this).val() + '.css';
- $('link#theme-stylesheet').attr("href", theme_csspath);
+ $('link#theme-stylesheet').attr("href", theme_csspath);
- $.cookie("theme_csspath", theme_csspath, {expires: 365, path: '/'});
- }
+ $.cookie("theme_csspath", theme_csspath, {expires: 365, path: '/'});
+ }
- return false;
+ return false;
});
-
+
$("#layout").change(function () {
- if ($(this).val() !== '') {
+ if ($(this).val() !== '') {
var theme_layout = $(this).val();
$('body').removeClass('wide');
$('body').removeClass('boxed');
-
+
$('body').addClass(theme_layout);
- $.cookie("theme_layout", theme_layout, {expires: 365, path: '/'});
- }
+ $.cookie("theme_layout", theme_layout, {expires: 365, path: '/'});
+ }
- return false;
- });
+ return false;
+ });
}
/* slider homepage */
function sliderHomepage() {
if ($('#slider').length) {
- var owl = $("#slider");
-
- $("#slider").owlCarousel({
- autoPlay: 3000,
- items: 4,
- itemsDesktopSmall: [900, 3],
- itemsTablet: [600, 3],
- itemsMobile: [500, 2]
- });
+ var owl = $("#slider");
+
+ $("#slider").owlCarousel({
+ autoPlay: 3000,
+ items: 4,
+ itemsDesktopSmall: [900, 3],
+ itemsTablet: [600, 3],
+ itemsMobile: [500, 2]
+ });
}
}
@@ -81,49 +106,49 @@ function sliderHomepage() {
function sliders() {
if ($('.owl-carousel').length) {
- $(".customers").owlCarousel({
- items: 6,
- itemsDesktopSmall: [990, 4],
- itemsTablet: [768, 2],
- itemsMobile: [480, 1]
- });
-
- $(".testimonials").owlCarousel({
- items: 4,
- itemsDesktopSmall: [990, 3],
- itemsTablet: [768, 2],
- itemsMobile: [480, 1]
- });
-
- $('.project').owlCarousel({
- navigation: true, // Show next and prev buttons
- navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
- slideSpeed: 300,
- paginationSpeed: 400,
- autoPlay: true,
- stopOnHover: true,
- singleItem: true,
- afterInit: '',
- lazyLoad: true
- });
-
- $('.homepage').owlCarousel({
- navigation: false, // Show next and prev buttons
- navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
- slideSpeed: 2000,
- paginationSpeed: 1000,
- autoPlay: true,
- stopOnHover: true,
- singleItem: true,
- lazyLoad: false,
- addClassActive: true,
- afterInit: function () {
- //animationsSlider();
- },
- afterMove: function () {
- //animationsSlider();
- }
- });
+ $(".customers").owlCarousel({
+ items: 6,
+ itemsDesktopSmall: [990, 4],
+ itemsTablet: [768, 2],
+ itemsMobile: [480, 1]
+ });
+
+ $(".testimonials").owlCarousel({
+ items: 4,
+ itemsDesktopSmall: [990, 3],
+ itemsTablet: [768, 2],
+ itemsMobile: [480, 1]
+ });
+
+ $('.project').owlCarousel({
+ navigation: true, // Show next and prev buttons
+ navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
+ slideSpeed: 300,
+ paginationSpeed: 400,
+ autoPlay: true,
+ stopOnHover: true,
+ singleItem: true,
+ afterInit: '',
+ lazyLoad: true
+ });
+
+ $('.homepage').owlCarousel({
+ navigation: false, // Show next and prev buttons
+ navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
+ slideSpeed: 2000,
+ paginationSpeed: 1000,
+ autoPlay: true,
+ stopOnHover: true,
+ singleItem: true,
+ lazyLoad: false,
+ addClassActive: true,
+ afterInit: function () {
+ //animationsSlider();
+ },
+ afterMove: function () {
+ //animationsSlider();
+ }
+ });
}
}
@@ -137,23 +162,23 @@ function menuSliding() {
$('.dropdown').on('show.bs.dropdown', function (e) {
- if ($(window).width() > 750) {
- $(this).find('.dropdown-menu').first().stop(true, true).slideDown();
+ if ($(window).width() > 750) {
+ $(this).find('.dropdown-menu').first().stop(true, true).slideDown();
- }
- else {
- $(this).find('.dropdown-menu').first().stop(true, true).show();
- }
+ }
+ else {
+ $(this).find('.dropdown-menu').first().stop(true, true).show();
+ }
}
);
$('.dropdown').on('hide.bs.dropdown', function (e) {
- if ($(window).width() > 750) {
- $(this).find('.dropdown-menu').first().stop(true, true).slideUp();
- }
- else {
- $(this).find('.dropdown-menu').first().stop(true, true).hide();
- }
+ if ($(window).width() > 750) {
+ $(this).find('.dropdown-menu').first().stop(true, true).slideUp();
+ }
+ else {
+ $(this).find('.dropdown-menu').first().stop(true, true).hide();
+ }
});
}
@@ -164,29 +189,29 @@ function animations() {
delayTime = 0;
$('[data-animate]').css({opacity: '0'});
$('[data-animate]').waypoint(function (direction) {
- delayTime += 150;
- $(this).delay(delayTime).queue(function (next) {
- $(this).toggleClass('animated');
- $(this).toggleClass($(this).data('animate'));
- delayTime = 0;
- next();
- //$(this).removeClass('animated');
- //$(this).toggleClass($(this).data('animate'));
- });
+ delayTime += 150;
+ $(this).delay(delayTime).queue(function (next) {
+ $(this).toggleClass('animated');
+ $(this).toggleClass($(this).data('animate'));
+ delayTime = 0;
+ next();
+ //$(this).removeClass('animated');
+ //$(this).toggleClass($(this).data('animate'));
+ });
},
- {
- offset: '90%',
- triggerOnce: true
- });
+ {
+ offset: '90%',
+ triggerOnce: true
+ });
$('[data-animate-hover]').hover(function () {
- $(this).css({opacity: 1});
- $(this).addClass('animated');
- $(this).removeClass($(this).data('animate'));
- $(this).addClass($(this).data('animate-hover'));
+ $(this).css({opacity: 1});
+ $(this).addClass('animated');
+ $(this).removeClass($(this).data('animate'));
+ $(this).addClass($(this).data('animate-hover'));
}, function () {
- $(this).removeClass('animated');
- $(this).removeClass($(this).data('animate-hover'));
+ $(this).removeClass('animated');
+ $(this).removeClass($(this).data('animate-hover'));
});
}
@@ -197,22 +222,22 @@ function animationsSlider() {
$('.owl-item:not(.active) [data-animate-always]').each(function () {
- $(this).removeClass('animated');
- $(this).removeClass($(this).data('animate-always'));
- $(this).stop(true, true, true).css({opacity: 0});
+ $(this).removeClass('animated');
+ $(this).removeClass($(this).data('animate-always'));
+ $(this).stop(true, true, true).css({opacity: 0});
});
$('.owl-item.active [data-animate-always]').each(function () {
- delayTimeSlider += 500;
+ delayTimeSlider += 500;
- $(this).delay(delayTimeSlider).queue(function (next) {
- $(this).addClass('animated');
- $(this).addClass($(this).data('animate-always'));
+ $(this).delay(delayTimeSlider).queue(function (next) {
+ $(this).addClass('animated');
+ $(this).addClass($(this).data('animate-always'));
- console.log($(this).data('animate-always'));
+ console.log($(this).data('animate-always'));
- });
+ });
});
@@ -224,8 +249,8 @@ function animationsSlider() {
function counters() {
$('.counter').counterUp({
- delay: 10,
- time: 1000
+ delay: 10,
+ time: 1000
});
}
@@ -236,8 +261,8 @@ function counters() {
function pictureZoom() {
$('.product .image, .post .image, .photostream div').each(function () {
- var imgHeight = $(this).find('img').height();
- $(this).height(imgHeight);
+ var imgHeight = $(this).find('img').height();
+ $(this).height(imgHeight);
});
}
@@ -248,16 +273,16 @@ function fullScreenContainer() {
var screenWidth = $(window).width() + "px";
if ($(window).height() > 500) {
- var screenHeight = $(window).height() + "px";
+ var screenHeight = $(window).height() + "px";
}
else {
- var screenHeight = "500px";
+ var screenHeight = "500px";
}
$("#intro, #intro .item").css({
- width: screenWidth,
- height: screenHeight
+ width: screenWidth,
+ height: screenHeight
});
}
function utils() {
@@ -269,46 +294,46 @@ function utils() {
/* click on the box activates the radio */
$('#checkout').on('click', '.box.shipping-method, .box.payment-method', function (e) {
- var radio = $(this).find(':radio');
- radio.prop('checked', true);
+ var radio = $(this).find(':radio');
+ radio.prop('checked', true);
});
/* click on the box activates the link in it */
$('.box.clickable').on('click', function (e) {
- window.location = $(this).find('a').attr('href');
+ window.location = $(this).find('a').attr('href');
});
/* external links in new window*/
$('.external').on('click', function (e) {
- e.preventDefault();
- window.open($(this).attr("href"));
+ e.preventDefault();
+ window.open($(this).attr("href"));
});
/* animated scrolling */
$('.scroll-to, .scroll-to-top').click(function (event) {
- var full_url = this.href;
- var parts = full_url.split("#");
- if (parts.length > 1) {
+ var full_url = this.href;
+ var parts = full_url.split("#");
+ if (parts.length > 1) {
- scrollTo(full_url);
- event.preventDefault();
- }
+ scrollTo(full_url);
+ event.preventDefault();
+ }
});
function scrollTo(full_url) {
- var parts = full_url.split("#");
- var trgt = parts[1];
- var target_offset = $("#" + trgt).offset();
- var target_top = target_offset.top - 100;
- if (target_top < 0) {
- target_top = 0;
- }
-
- $('html, body').animate({
- scrollTop: target_top
- }, 1000);
+ var parts = full_url.split("#");
+ var trgt = parts[1];
+ var target_offset = $("#" + trgt).offset();
+ var target_top = target_offset.top - 100;
+ if (target_top < 0) {
+ target_top = 0;
+ }
+
+ $('html, body').animate({
+ scrollTop: target_top
+ }, 1000);
}
}
@@ -319,31 +344,31 @@ function productDetailGallery(confDetailSwitch) {
timer = setInterval(autoSwitch, confDetailSwitch);
$(".thumb").click(function (e) {
- switchImage($(this));
- clearInterval(timer);
- timer = setInterval(autoSwitch, confDetailSwitch);
- e.preventDefault();
+ switchImage($(this));
+ clearInterval(timer);
+ timer = setInterval(autoSwitch, confDetailSwitch);
+ e.preventDefault();
}
);
$('#mainImage').hover(function () {
- clearInterval(timer);
+ clearInterval(timer);
}, function () {
- timer = setInterval(autoSwitch, confDetailSwitch);
+ timer = setInterval(autoSwitch, confDetailSwitch);
});
function autoSwitch() {
- var nextThumb = $('.thumb.active').closest('div').next('div').find('.thumb');
- if (nextThumb.length == 0) {
- nextThumb = $('.thumb:first');
- }
- switchImage(nextThumb);
+ var nextThumb = $('.thumb.active').closest('div').next('div').find('.thumb');
+ if (nextThumb.length == 0) {
+ nextThumb = $('.thumb:first');
+ }
+ switchImage(nextThumb);
}
function switchImage(thumb) {
- $('.thumb').removeClass('active');
- var bigUrl = thumb.attr('href');
- thumb.addClass('active');
- $('#mainImage img').attr('src', bigUrl);
+ $('.thumb').removeClass('active');
+ var bigUrl = thumb.attr('href');
+ thumb.addClass('active');
+ $('#mainImage img').attr('src', bigUrl);
}
}
@@ -351,11 +376,11 @@ function productDetailGallery(confDetailSwitch) {
function productDetailSizes() {
$('.sizes a').click(function (e) {
- e.preventDefault();
- $('.sizes a').removeClass('active');
- $('.size-input').prop('checked', false);
- $(this).addClass('active');
- $(this).next('input').prop('checked', true);
+ e.preventDefault();
+ $('.sizes a').removeClass('active');
+ $('.size-input').prop('checked', false);
+ $(this).addClass('active');
+ $(this).next('input').prop('checked', true);
});
}
@@ -363,27 +388,27 @@ function productDetailSizes() {
$.fn.alignElementsSameHeight = function () {
$('.same-height-row').each(function () {
- var maxHeight = 0;
- var children = $(this).find('.same-height');
- children.height('auto');
- if ($(window).width() > 768) {
- children.each(function () {
- if ($(this).innerHeight() > maxHeight) {
- maxHeight = $(this).innerHeight();
- }
- });
- children.innerHeight(maxHeight);
- }
-
- maxHeight = 0;
- children = $(this).find('.same-height-always');
- children.height('auto');
- children.each(function () {
- if ($(this).height() > maxHeight) {
- maxHeight = $(this).innerHeight();
- }
- });
- children.innerHeight(maxHeight);
+ var maxHeight = 0;
+ var children = $(this).find('.same-height');
+ children.height('auto');
+ if ($(window).width() > 768) {
+ children.each(function () {
+ if ($(this).innerHeight() > maxHeight) {
+ maxHeight = $(this).innerHeight();
+ }
+ });
+ children.innerHeight(maxHeight);
+ }
+
+ maxHeight = 0;
+ children = $(this).find('.same-height-always');
+ children.height('auto');
+ children.each(function () {
+ if ($(this).height() > maxHeight) {
+ maxHeight = $(this).innerHeight();
+ }
+ });
+ children.innerHeight(maxHeight);
});
}
@@ -400,12 +425,12 @@ $(window).resize(function () {
newWindowWidth = $(window).width();
if (windowWidth !== newWindowWidth) {
- setTimeout(function () {
- $(this).alignElementsSameHeight();
- fullScreenContainer();
- pictureZoom();
- }, 205);
- windowWidth = newWindowWidth;
+ setTimeout(function () {
+ $(this).alignElementsSameHeight();
+ fullScreenContainer();
+ pictureZoom();
+ }, 205);
+ windowWidth = newWindowWidth;
}
});