Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function ($) {
- var ua = window.navigator.userAgent;
- var isIE = /MSIE|Trident/.test(ua);
- if ( !isIE ) {
- //IE specific code goes here
- "use strict";
- }
- /*** Adobe typekit font */
- try{Typekit.load({ async: true });}catch(e){};
- /*** Sticky header */
- $(window).scroll(function(){
- if($("body").scrollTop() > 0 || $("html").scrollTop() > 0) {
- $(".header").addClass("stop");
- } else {
- $(".header").removeClass("stop");
- }
- });
- /*** Sidr Menu */
- $('.navbar-toggle').sidr({
- name: 'sidr-main',
- side: 'left',
- source: '#sidr',
- displace: false,
- renaming: false,
- });
- $('.navbar-toggle.in').on('click', function(){
- $.sidr('close', 'sidr-main');
- });
- /*** Header Search */
- $(".search-bar .search-icon").click(function(e) {
- e.preventDefault();
- $(".search-box").toggle();
- // $("input.dgwt-wcas-search-input").focus();
- });
- /*** Click To scroll */
- $('.scrollDown').click(function() {
- var target = $('#primary');
- if (target.length) {
- $('html,body').animate({
- scrollTop: target.offset().top - 120
- }, 1000);
- }
- });
- /*** Header height = gutter height */
- function setGutterHeight(){
- var header = document.querySelector('.header'),
- gutter = document.querySelector('.header_gutter');
- if (gutter) {
- gutter.style.height = header.offsetHeight + 'px';
- }
- }
- window.onload = setGutterHeight;
- window.onresize = setGutterHeight;
- /*** SVG Separator */
- $('img.svg').each(function(){
- var $img = $(this);
- var imgID = $img.attr('id');
- var imgClass = $img.attr('class');
- var imgURL = $img.attr('src');
- var dataColor = $img.attr('data-color');
- $.get(imgURL, function(data) {
- // Get the SVG tag, ignore the rest
- var $svg = $(data).find('svg');
- // Add replaced image's ID to the new SVG
- if(typeof imgID !== 'undefined') {
- $svg = $svg.attr('id', imgID);
- }
- // Add replaced image's classes to the new SVG
- if(typeof imgClass !== 'undefined') {
- $svg = $svg.attr('class', imgClass+' replaced-svg');
- }
- // Add replaced image's classes to the new SVG
- if(typeof dataColor !== 'undefined') {
- $($svg[0].firstElementChild).css({ stroke : dataColor });
- }
- // Remove any invalid XML tags as per http://validator.w3.org
- $svg = $svg.removeAttr('xmlns:a');
- // Check if the viewport is set, else we gonna set it if we can.
- if(!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) {
- $svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'))
- }
- // Replace image with new SVG
- $img.replaceWith($svg);
- }, 'xml');
- });
- /*** Video Popup */
- $('.popup-video').magnificPopup({
- type: 'iframe',
- midClick: true,
- fixedBgPos: true,
- removalDelay: 500,
- removalDelay: 160,
- preloader: false,
- mainClass: 'mfp-fade',
- fixedContentPos: false,
- iframe: {
- markup: '<div class="mfp-iframe-scaler mfp-custom-figure">'+
- '<div class="mfp-top-bar"><div class="mfp-title"></div></div>'+
- '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
- '<div class="mfp-bottom-bar">'+
- '<div class="mfp-close popup-arrow"></div>'+
- '</div>'+
- '</div>',
- }
- });
- /*** Google map */
- var mapElement = document.getElementById("gmap");
- if( mapElement) {
- var map;
- google.maps.event.addDomListener(window, 'load', init);
- }
- function init() {
- var google_map_setting = {
- latitude: my_ajax_object.latitude,
- longitude: my_ajax_object.longitude
- };
- if (my_ajax_object.map_icon)
- {
- var image = my_ajax_object.map_icon;
- }
- else
- {
- var image = '../images/map-pin.png';
- }
- var mapOptions = {
- zoomControl: true,
- disableDefaultUI: true,
- draggable: true,
- scrollwheel: false,
- zoom: parseInt(my_ajax_object.map_zoom),
- center: new google.maps.LatLng( google_map_setting.latitude, google_map_setting.longitude),
- };
- var contentString = my_ajax_object.address;
- var infowindow = new google.maps.InfoWindow({
- content: contentString,
- maxWidth: 200
- });
- var map = new google.maps.Map(mapElement, mapOptions);
- var marker = new google.maps.Marker({
- position: new google.maps.LatLng( google_map_setting.latitude, google_map_setting.longitude),
- map: map,
- icon: image,
- });
- google.maps.event.addListener(marker, 'click', function() {
- infowindow.open(map, marker);
- });
- var center = map.getCenter();
- google.maps.event.addDomListener(window, 'resize', function() {
- map.setCenter(center);
- });
- }
- /*** Generated by CoffeeScript 1.9.2 */
- function stickyKit() {
- var reset_scroll;
- $(function() {
- return $("[data-sticky_column]").stick_in_parent({
- parent: "[data-sticky_parent]",
- offset_top: 130,
- bottoming: true,
- });
- });
- reset_scroll = function() {
- var scroller;
- scroller = $("body,html");
- scroller.stop(true);
- if ($(window).scrollTop() !== 0) {
- scroller.animate({
- scrollTop: 0
- }, "fast");
- }
- return scroller;
- };
- window.scroll_it = function() {
- var max;
- max = $(document).height() - $(window).height();
- return reset_scroll().animate({
- scrollTop: max
- }, max * 3).delay(100).animate({
- scrollTop: 0
- }, max * 3);
- };
- window.scroll_it_wobble = function() {
- var max, third;
- max = $(document).height() - $(window).height();
- third = Math.floor(max / 3);
- return reset_scroll().animate({
- scrollTop: third * 2
- }, max * 3).delay(100).animate({
- scrollTop: third
- }, max * 3).delay(100).animate({
- scrollTop: max
- }, max * 3).delay(100).animate({
- scrollTop: 0
- }, max * 3);
- };
- $(window).on("load", (function(_this) {
- return function(e) {
- return $(document.body).trigger("sticky_kit:recalc");
- };
- })(this));
- $(window).on("resize", (function(_this) {
- return function(e) {
- return $(document.body).trigger("sticky_kit:recalc");
- };
- })(this));
- }
- var window_width = $(window).width();
- if (window_width < 992) {
- $(document.body).trigger("sticky_kit:detach");
- } else {
- stickyKit();
- }
- $( window ).resize(function() {
- window_width = $( window ).width();
- if (window_width < 992) {
- $(document.body).trigger("sticky_kit:detach");
- } else {
- stickyKit();
- }
- });
- /*** Select Field Custom */
- $('select:not(#quantity, #pa_size, #pa_denomination, #quantity-type, #billing_country)').each(function(){
- var $this = $(this), numberOfOptions = $(this).children('option').length;
- var overflow = numberOfOptions > 5 ? 'overflow-y' : '';
- $this.addClass('select-hidden');
- $this.wrap('<div class="select"></div>');
- $this.after('<div class="select-styled"></div>');
- var $styledSelect = $this.next('div.select-styled');
- $styledSelect.text($this.children('option').eq(0).text());
- var $list = $('<ul />', {
- 'class': 'select-options'
- }).insertAfter($styledSelect);
- for (var i = 0; i < numberOfOptions; i++) {
- $('<li />', {
- text: $this.children('option').eq(i).text(),
- rel: $this.children('option').eq(i).val()
- }).appendTo($list);
- }
- var $listItems = $list.children('li');
- $styledSelect.click(function(e) {
- e.stopPropagation();
- $('div.select-styled.active').not(this).each(function(){
- $(this).removeClass('active').next('ul.select-options').hide();
- });
- $(this).toggleClass('active').next('ul.select-options').addClass(overflow).toggle();
- });
- $listItems.click(function(e) {
- e.stopPropagation();
- $styledSelect.text($(this).text()).removeClass('active');
- $this.val($(this).attr('rel'));
- $('select option').removeAttr('selected');
- $('select option[value="'+$(this).attr('rel')+'"]').attr('selected','selected');
- // Only Woo Orderby
- if ($this.hasClass('orderby')) {
- $(this).closest( 'form' ).submit();
- }
- $list.hide();
- });
- $(document).click(function() {
- $styledSelect.removeClass('active');
- $list.hide();
- });
- });
- /*** Custom Scrollbar */
- $(".select-options").niceScroll({
- cursorcolor:"#2497BD",
- cursorminheight: 50,
- cursorborder:"1px solid #2497BD",
- railpadding: { top: 0, right: 0, left: 0, bottom: 0 }
- });
- /** Shop page widget Categories after arrow */
- var arrow = $('<span class="arrow_plus icon-plus"></span>');
- $(".product-categories li.cat-parent > a").after(arrow);
- $(".product-categories li.cat-parent .arrow_plus").click(function() {
- $(this).parent().toggleClass('open');
- $(this).toggleClass('icon-plus icon-minus').next().toggle();
- });
- /*** WooCommerce Quantity Increment */
- $('.woocommerce .quantity').on('click', '.qty-minus', function (e) {
- console.log(this)
- var $inputQty = $(this).parent().parent().find('input.qty');
- var val = parseInt($inputQty.val());
- var step = $inputQty.attr('step');
- step = 'undefined' !== typeof(step) ? parseInt(step) : 1;
- if (val > 0) {
- $inputQty.val(val - step).change();
- }
- });
- $('.woocommerce .quantity').on('click', '.qty-plus', function (e) {
- console.log('minus')
- var $inputQty = $(this).parent().parent().find('input.qty');
- var val = parseInt($inputQty.val());
- var step = $inputQty.attr('step');
- step = 'undefined' !== typeof(step) ? parseInt(step) : 1;
- $inputQty.val(val + step).change();
- });
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement