Advertisement
Uranbold

themewaves.js

Mar 2nd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.76 KB | None | 0 0
  1. jQuery(window).load(function () {
  2. // One page
  3. 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');
  4.  
  5. // Tooltip
  6. jQuery("[data-toggle=tooltip]").tooltip();
  7. jQuery(window).resize();
  8. });
  9. jQuery(window).resize(function ($) {
  10. var $f_height = jQuery('.fixed-footer').height();
  11. var $f_bottom = parseInt(jQuery('body').css('margin-bottom').replace('px', ''), 10);
  12. $f_height += $f_bottom;
  13. if (jQuery(window).width() > 800 && (jQuery(window).height() - 100) > $f_height) {
  14. jQuery('.fixed-footer').css('position', '');
  15. if ($f_bottom > 0) {
  16. jQuery('.fixed-footer').css('margin-bottom', $f_bottom);
  17. }
  18. if ($f_height > 0) {
  19. jQuery('#main').css('margin-bottom', $f_height);
  20. }
  21. } else {
  22. jQuery('#main').css('margin-bottom', '');
  23. jQuery('.fixed-footer').css('position', 'static');
  24. }
  25. });
  26. jQuery(document).ready(function ($) {
  27. var defLogoH = jQuery('.tw-logo img').height();
  28. // One Page
  29. jQuery('body.page-template-page-onepage-php a').click(function (e) {
  30. if ($(this).attr('href')) {
  31. //get current
  32. var targetSection = $(this).attr('href').split("#")[1];
  33. if (targetSection || targetSection !== '') {
  34. targetSection = '#' + targetSection;
  35. if ($(targetSection).attr('id') !== '' && $(targetSection).attr('id') !== 'undefined' && $(targetSection).attr('id') !== undefined) {
  36. e.preventDefault();
  37. //get pos of target section
  38. var targetOffset = Math.floor($(targetSection).offset().top - $('#header').height());
  39.  
  40. //scroll
  41. $('html,body').animate({scrollTop: targetOffset}, 1000);
  42. }
  43. }
  44. }
  45. });
  46. // One Page - Mobile Menu
  47. jQuery('body.page-template-page-onepage-php nav#mobile-menu a').click(function () {
  48. var $target = jQuery(this).attr('href');
  49. setTimeout(function () {
  50. jQuery('body.page-template-page-onepage-php ul#menu a[href="' + $target + '"]').click();
  51. }, 500);
  52. return false;
  53. });
  54.  
  55.  
  56.  
  57. /*nav handling
  58. -------------------*/
  59. $(function () {
  60. jQuery('.page-template-page-onepage-php .row-container').waypoint({
  61. handler: function (direction) {
  62. var activeSection = jQuery(this);
  63.  
  64. if (direction === "up") {
  65. activeSection = activeSection.prev();
  66. }
  67.  
  68. var activeMenuLink = jQuery('ul#menu a[href$="#' + activeSection.attr('id') + '"]');
  69. if (activeMenuLink.html()) {
  70. jQuery('ul#menu a').parent('li').removeClass('tw-menu-active');
  71. activeMenuLink.parent('li').addClass('tw-menu-active');
  72. }
  73. // One Page - Mobile Menu
  74. if (!jQuery('html').hasClass('mm-opened')) {
  75. jQuery('nav#mobile-menu a').parent('li').removeClass('mm-selected');
  76. jQuery('nav#mobile-menu a[href$="#' + activeSection.attr('id') + '"]').parent('li').addClass('mm-selected');
  77. }
  78. },
  79. offset: $('#header').height() //when it should switch on consecutive page
  80. });
  81. });
  82.  
  83. /* navigation */
  84. $('ul#menu').superfish({
  85. delay: 200,
  86. animation: {
  87. opacity: 'show',
  88. height: 'show'
  89. },
  90. speed: 'fast',
  91. autoArrows: false,
  92. dropShadows: false
  93. });
  94.  
  95. /* mobile navigation */
  96. jQuery('nav#mobile-menu').mmenu({
  97. position: "right",
  98. searchfield: {
  99. add: true,
  100. search: true,
  101. placeholder: "Search from Menu",
  102. noResults: "No results found.",
  103. showLinksOnly: true
  104. },
  105. configuration: {
  106. pageSelector: "#theme-layout"
  107. }
  108. });
  109. jQuery('#wpadminbar').prependTo('body');
  110.  
  111. jQuery(window).scroll(function () {
  112. var $header = jQuery('#header');
  113. var $menuContainer = jQuery('#header nav.menu-container');
  114. var $menuParents = $menuContainer.find('ul.sf-menu>li>a');
  115. var $scrollTop = jQuery(window).scrollTop();
  116.  
  117. // START - One Page Home
  118. if ($scrollTop <= 50 && jQuery('body.page-template-page-onepage-php ul#menu a[href$="#one-page-home"]').closest('li').hasClass('menu-item')) {
  119. jQuery('ul#menu li.tw-menu-active').removeClass('tw-menu-active');
  120. jQuery('ul#menu a[href$="#one-page-home"]').closest('li').addClass('tw-menu-active');
  121. // One Page - Mobile Menu
  122. if (!jQuery('html').hasClass('mm-opened')) {
  123. jQuery('nav#mobile-menu li.mm-selected').removeClass('mm-selected');
  124. jQuery('nav#mobile-menu a[href$="#one-page-home"]').closest('li').addClass('mm-selected');
  125. }
  126. }
  127. // END - One Page Home
  128.  
  129. // START - Header resize
  130. if (jQuery('#theme-layout').hasClass('menu-fixed')) {
  131.  
  132. var $bodyOffsetTop = jQuery('body').offset().top;
  133. var $addH = 0;
  134. if (jQuery('.tw-top-bar').hasClass('tw-top-bar')) {
  135. $addH += jQuery('.tw-top-bar').height();
  136. }
  137. if (jQuery('#wpadminbar').attr('id') === 'wpadminbar') {
  138. $addH -= jQuery('#wpadminbar').height();
  139. }
  140.  
  141. var $menuPaddingSmall = waves_script_data.menu_padding;
  142. var $headerheight = waves_script_data.header_height;
  143. if ($bodyOffsetTop + $addH < $scrollTop) {
  144. if ($header.hasClass('header-large')) {
  145. $menuParents.stop().animate({paddingTop: ($menuPaddingSmall - 10) + 'px', paddingBottom: ($menuPaddingSmall - 10) + 'px'}, 300);
  146. jQuery('.tw-logo').stop().animate({height: ($headerheight - 20) + 'px', lineHeight: ($headerheight - 20) + 'px'}, 300);
  147. if (defLogoH > 40) {
  148. var $oldH = jQuery('.tw-logo img').height();
  149. var $oldW = jQuery('.tw-logo img').width();
  150. var $newH = $oldH - 10;
  151. var $newW = $newH * ($oldW / $oldH);
  152. jQuery('.tw-logo img').stop().animate({height: $newH + 'px', width: $newW + 'px'}, 300);
  153. }
  154. $header.removeClass('header-large').addClass('header-small');
  155. $header.siblings('.header-clone').css('height', $header.height() + 'px').stop().animate({height: ($header.height() - 20) + 'px'}, 300);
  156. }
  157. } else {
  158. if ($header.hasClass('header-small')) {
  159. $menuParents.stop().animate({paddingTop: $menuPaddingSmall + 'px', paddingBottom: $menuPaddingSmall + 'px'}, 300);
  160. jQuery('.tw-logo').stop().animate({height: $headerheight + 'px', lineHeight: $headerheight + 'px'}, 300);
  161. if (defLogoH > 40) {
  162. var $oldH = jQuery('.tw-logo img').height();
  163. var $oldW = jQuery('.tw-logo img').width();
  164. var $newH = $oldH + 10;
  165. var $newW = $newH * ($oldW / $oldH);
  166. jQuery('.tw-logo img').stop().animate({height: $newH + 'px', width: $newW + 'px'}, 300);
  167. }
  168. $header.removeClass('header-small').addClass('header-large');
  169. $header.siblings('.header-clone').css('height', '').stop();
  170. }
  171. }
  172. }
  173. // END - Header resize
  174.  
  175. if (jQuery(this).scrollTop() > $header.height()) {
  176. jQuery('#scrollUp').fadeIn();
  177. } else {
  178. jQuery('#scrollUp').fadeOut();
  179. }
  180. });
  181. jQuery(window).scroll();
  182. jQuery('#scrollUp, .divider-top').click(function () {
  183. jQuery("html, body").animate({scrollTop: 0}, 500);
  184. return false;
  185. });
  186.  
  187. var isMobile = {
  188. Android: function () {
  189. return navigator.userAgent.match(/Android/i);
  190. },
  191. BlackBerry: function () {
  192. return navigator.userAgent.match(/BlackBerry/i);
  193. },
  194. iOS: function () {
  195. return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  196. },
  197. Opera: function () {
  198. return navigator.userAgent.match(/Opera Mini/i);
  199. },
  200. Windows: function () {
  201. return navigator.userAgent.match(/IEMobile/i);
  202. },
  203. any: function () {
  204. return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  205. }
  206. };
  207. if (!isMobile.any()) {
  208.  
  209. if (jQuery().parallax) {
  210. jQuery('.bg-parallax').each(function () {
  211. jQuery(this).parallax("30%", 0.6);
  212. });
  213. }
  214. }
  215.  
  216. //portfolio like
  217. jQuery('.likeit').live('click', function () {
  218. var $this = jQuery(this);
  219. jQuery.post($this.data('ajaxurl'), {liked_pid: $this.data('pid')})
  220. .done(function (response) {
  221. var $aa = jQuery(response).find('#portfolio_liked');
  222. if ($aa.attr('id') == 'portfolio_liked') {
  223. $this.addClass('liked');
  224. var $val = $aa.text();
  225. $this.find('span').text($val);
  226. }
  227. });
  228. });
  229.  
  230. //facebook
  231. function facebookShare() {
  232. 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");
  233. return false;
  234. }
  235. $('.facebook-share > a').click(facebookShare);
  236.  
  237. //twitter
  238. function twitterShare() {
  239. 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");
  240. return false;
  241. }
  242. $('.twitter-share > a').click(twitterShare);
  243.  
  244. //pinterest
  245. function pinterestShare() {
  246. 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");
  247. return false;
  248. }
  249. $('.pinterest-share > a').click(pinterestShare);
  250.  
  251.  
  252. //google
  253.  
  254. function googleShare(e) {
  255. e.preventDefault();
  256. 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");
  257. }
  258. $('.googleplus-share > a').click(googleShare);
  259.  
  260.  
  261. //Add to Cart Loader
  262. $('.tw_product_container>.tw_cart_buttons>.add_to_cart_button').click(function () {
  263. jQuery(this).closest('.tw_cart_buttons').siblings('a').addClass('loading-cart');
  264. });
  265.  
  266. //Cart On Menu
  267. $('.tw-top-widget[id^="woocommerce_widget_cart"]').hover(function () {
  268. $(this).children('.widget_shopping_cart_content').addClass('opened').stop().fadeIn('fast');
  269. }, function () {
  270. $(this).children('.widget_shopping_cart_content').removeClass('opened').stop().fadeOut('fast');
  271. });
  272.  
  273. setTimeout(function () {
  274. wcWidgetTitle();
  275. }, 1);
  276. setTimeout(function () {
  277. wcWidgetTitle();
  278. }, 500);
  279. jQuery(document).ajaxComplete(function () {
  280. wcWidgetTitle();
  281. });
  282. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement