Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(window).load(function () {
- // One page
- jQuery('body.page-template-page-onepage-php ul#menu li,body.page-template-page-onepage-php nav#mobile-menu li').removeClass('current-menu-item current_page_item current-menu-ancestor sfHover');
- // Tooltip
- jQuery("[data-toggle=tooltip]").tooltip();
- jQuery(window).resize();
- });
- jQuery(window).resize(function ($) {
- var $f_height = jQuery('.fixed-footer').height();
- var $f_bottom = parseInt(jQuery('body').css('margin-bottom').replace('px', ''), 10);
- $f_height += $f_bottom;
- if (jQuery(window).width() > 800 && (jQuery(window).height() - 100) > $f_height) {
- jQuery('.fixed-footer').css('position', '');
- if ($f_bottom > 0) {
- jQuery('.fixed-footer').css('margin-bottom', $f_bottom);
- }
- if ($f_height > 0) {
- jQuery('#main').css('margin-bottom', $f_height);
- }
- } else {
- jQuery('#main').css('margin-bottom', '');
- jQuery('.fixed-footer').css('position', 'static');
- }
- });
- jQuery(document).ready(function ($) {
- var defLogoH = jQuery('.tw-logo img').height();
- // One Page
- jQuery('body.page-template-page-onepage-php a').click(function (e) {
- if ($(this).attr('href')) {
- //get current
- var targetSection = $(this).attr('href').split("#")[1];
- if (targetSection || targetSection !== '') {
- targetSection = '#' + targetSection;
- if ($(targetSection).attr('id') !== '' && $(targetSection).attr('id') !== 'undefined' && $(targetSection).attr('id') !== undefined) {
- e.preventDefault();
- //get pos of target section
- var targetOffset = Math.floor($(targetSection).offset().top - $('#header').height());
- //scroll
- $('html,body').animate({scrollTop: targetOffset}, 1000);
- }
- }
- }
- });
- // One Page - Mobile Menu
- jQuery('body.page-template-page-onepage-php nav#mobile-menu a').click(function () {
- var $target = jQuery(this).attr('href');
- setTimeout(function () {
- jQuery('body.page-template-page-onepage-php ul#menu a[href="' + $target + '"]').click();
- }, 500);
- return false;
- });
- /*nav handling
- -------------------*/
- $(function () {
- jQuery('.page-template-page-onepage-php .row-container').waypoint({
- handler: function (direction) {
- var activeSection = jQuery(this);
- if (direction === "up") {
- activeSection = activeSection.prev();
- }
- var activeMenuLink = jQuery('ul#menu a[href$="#' + activeSection.attr('id') + '"]');
- if (activeMenuLink.html()) {
- jQuery('ul#menu a').parent('li').removeClass('tw-menu-active');
- activeMenuLink.parent('li').addClass('tw-menu-active');
- }
- // One Page - Mobile Menu
- if (!jQuery('html').hasClass('mm-opened')) {
- jQuery('nav#mobile-menu a').parent('li').removeClass('mm-selected');
- jQuery('nav#mobile-menu a[href$="#' + activeSection.attr('id') + '"]').parent('li').addClass('mm-selected');
- }
- },
- offset: $('#header').height() //when it should switch on consecutive page
- });
- });
- /* navigation */
- $('ul#menu').superfish({
- delay: 200,
- animation: {
- opacity: 'show',
- height: 'show'
- },
- speed: 'fast',
- autoArrows: false,
- dropShadows: false
- });
- /* mobile navigation */
- jQuery('nav#mobile-menu').mmenu({
- position: "right",
- searchfield: {
- add: true,
- search: true,
- placeholder: "Search from Menu",
- noResults: "No results found.",
- showLinksOnly: true
- },
- configuration: {
- pageSelector: "#theme-layout"
- }
- });
- jQuery('#wpadminbar').prependTo('body');
- jQuery(window).scroll(function () {
- var $header = jQuery('#header');
- var $menuContainer = jQuery('#header nav.menu-container');
- var $menuParents = $menuContainer.find('ul.sf-menu>li>a');
- var $scrollTop = jQuery(window).scrollTop();
- // START - One Page Home
- if ($scrollTop <= 50 && jQuery('body.page-template-page-onepage-php ul#menu a[href$="#one-page-home"]').closest('li').hasClass('menu-item')) {
- jQuery('ul#menu li.tw-menu-active').removeClass('tw-menu-active');
- jQuery('ul#menu a[href$="#one-page-home"]').closest('li').addClass('tw-menu-active');
- // One Page - Mobile Menu
- if (!jQuery('html').hasClass('mm-opened')) {
- jQuery('nav#mobile-menu li.mm-selected').removeClass('mm-selected');
- jQuery('nav#mobile-menu a[href$="#one-page-home"]').closest('li').addClass('mm-selected');
- }
- }
- // END - One Page Home
- // START - Header resize
- if (jQuery('#theme-layout').hasClass('menu-fixed')) {
- var $bodyOffsetTop = jQuery('body').offset().top;
- var $addH = 0;
- if (jQuery('.tw-top-bar').hasClass('tw-top-bar')) {
- $addH += jQuery('.tw-top-bar').height();
- }
- if (jQuery('#wpadminbar').attr('id') === 'wpadminbar') {
- $addH -= jQuery('#wpadminbar').height();
- }
- var $menuPaddingSmall = waves_script_data.menu_padding;
- var $headerheight = waves_script_data.header_height;
- if ($bodyOffsetTop + $addH < $scrollTop) {
- if ($header.hasClass('header-large')) {
- $menuParents.stop().animate({paddingTop: ($menuPaddingSmall - 10) + 'px', paddingBottom: ($menuPaddingSmall - 10) + 'px'}, 300);
- jQuery('.tw-logo').stop().animate({height: ($headerheight - 20) + 'px', lineHeight: ($headerheight - 20) + 'px'}, 300);
- if (defLogoH > 40) {
- var $oldH = jQuery('.tw-logo img').height();
- var $oldW = jQuery('.tw-logo img').width();
- var $newH = $oldH - 10;
- var $newW = $newH * ($oldW / $oldH);
- jQuery('.tw-logo img').stop().animate({height: $newH + 'px', width: $newW + 'px'}, 300);
- }
- $header.removeClass('header-large').addClass('header-small');
- $header.siblings('.header-clone').css('height', $header.height() + 'px').stop().animate({height: ($header.height() - 20) + 'px'}, 300);
- }
- } else {
- if ($header.hasClass('header-small')) {
- $menuParents.stop().animate({paddingTop: $menuPaddingSmall + 'px', paddingBottom: $menuPaddingSmall + 'px'}, 300);
- jQuery('.tw-logo').stop().animate({height: $headerheight + 'px', lineHeight: $headerheight + 'px'}, 300);
- if (defLogoH > 40) {
- var $oldH = jQuery('.tw-logo img').height();
- var $oldW = jQuery('.tw-logo img').width();
- var $newH = $oldH + 10;
- var $newW = $newH * ($oldW / $oldH);
- jQuery('.tw-logo img').stop().animate({height: $newH + 'px', width: $newW + 'px'}, 300);
- }
- $header.removeClass('header-small').addClass('header-large');
- $header.siblings('.header-clone').css('height', '').stop();
- }
- }
- }
- // END - Header resize
- if (jQuery(this).scrollTop() > $header.height()) {
- jQuery('#scrollUp').fadeIn();
- } else {
- jQuery('#scrollUp').fadeOut();
- }
- });
- jQuery(window).scroll();
- jQuery('#scrollUp, .divider-top').click(function () {
- jQuery("html, body").animate({scrollTop: 0}, 500);
- return false;
- });
- var isMobile = {
- Android: function () {
- return navigator.userAgent.match(/Android/i);
- },
- BlackBerry: function () {
- return navigator.userAgent.match(/BlackBerry/i);
- },
- iOS: function () {
- return navigator.userAgent.match(/iPhone|iPad|iPod/i);
- },
- Opera: function () {
- return navigator.userAgent.match(/Opera Mini/i);
- },
- Windows: function () {
- return navigator.userAgent.match(/IEMobile/i);
- },
- any: function () {
- return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
- }
- };
- if (!isMobile.any()) {
- if (jQuery().parallax) {
- jQuery('.bg-parallax').each(function () {
- jQuery(this).parallax("30%", 0.6);
- });
- }
- }
- //portfolio like
- jQuery('.likeit').live('click', function () {
- var $this = jQuery(this);
- jQuery.post($this.data('ajaxurl'), {liked_pid: $this.data('pid')})
- .done(function (response) {
- var $aa = jQuery(response).find('#portfolio_liked');
- if ($aa.attr('id') == 'portfolio_liked') {
- $this.addClass('liked');
- var $val = $aa.text();
- $this.find('span').text($val);
- }
- });
- });
- //facebook
- function facebookShare() {
- window.open('https://www.facebook.com/sharer/sharer.php?u=' + window.location, "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0");
- return false;
- }
- $('.facebook-share > a').click(facebookShare);
- //twitter
- function twitterShare() {
- window.open('http://twitter.com/intent/tweet?text=' + $(this).data('title') + ' ' + window.location, "twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0");
- return false;
- }
- $('.twitter-share > a').click(twitterShare);
- //pinterest
- function pinterestShare() {
- window.open('http://pinterest.com/pin/create/button/?url=' + window.location + '&media=' + $('#post-area img').first().attr('src') + '&description=' + $('.section-title h1').text(), "pinterestWindow", "height=640,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0");
- return false;
- }
- $('.pinterest-share > a').click(pinterestShare);
- //google
- function googleShare(e) {
- e.preventDefault();
- window.open('https://plus.google.com/share?url={' + window.location + '}', "googleWindow", "height=640,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0");
- }
- $('.googleplus-share > a').click(googleShare);
- //Add to Cart Loader
- $('.tw_product_container>.tw_cart_buttons>.add_to_cart_button').click(function () {
- jQuery(this).closest('.tw_cart_buttons').siblings('a').addClass('loading-cart');
- });
- //Cart On Menu
- $('.tw-top-widget[id^="woocommerce_widget_cart"]').hover(function () {
- $(this).children('.widget_shopping_cart_content').addClass('opened').stop().fadeIn('fast');
- }, function () {
- $(this).children('.widget_shopping_cart_content').removeClass('opened').stop().fadeOut('fast');
- });
- setTimeout(function () {
- wcWidgetTitle();
- }, 1);
- setTimeout(function () {
- wcWidgetTitle();
- }, 500);
- jQuery(document).ajaxComplete(function () {
- wcWidgetTitle();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement