PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/js/functions.js

https://bitbucket.org/maxthemesbd/bizness
JavaScript | 436 lines | 332 code | 62 blank | 42 comment | 31 complexity | 024a0e399010d6ce2fb69d9af9661e58 MD5 | raw file
  1. /* -------------------------------------- */
  2. // Page Loader
  3. /* -------------------------------------- */
  4. jQuery(window).on("load", function () {
  5. "use strict";
  6. jQuery(".loader").fadeOut(800);
  7. jQuery(".rev_slider_wrapper").css({"left": "0"});
  8. });
  9. jQuery(function ($) {
  10. "use strict";
  11. /* -------------------------------------- */
  12. // Pretty Social
  13. /* -------------------------------------- */
  14. $('.prettySocial').prettySocial();
  15. /* -------------------------------------- */
  16. // magnificPopup Initialize popup as usual
  17. /* -------------------------------------- */
  18. $('.cloud-zoom').magnificPopup({
  19. type: 'image',
  20. mainClass: 'product-img-zoomin',
  21. gallery: { enabled: true },
  22. zoom: {
  23. enabled: true, // By default it's false, so don't forget to enable it
  24. duration: 400, // duration of the effect, in milliseconds
  25. easing: 'ease-in-out', // CSS transition easing function
  26. opener: function(openerElement) {
  27. return openerElement.is('img') ? openerElement : openerElement.find('img');
  28. }
  29. }
  30. });
  31. /* -------------------------------------- */
  32. // Scroll To Top
  33. /* -------------------------------------- */
  34. var amountScrolled = 700;
  35. var backBtn = $("a.scrollToTop");
  36. $(window).on("scroll", function () {
  37. if ($(window).scrollTop() > amountScrolled) {
  38. backBtn.fadeIn("slow");
  39. } else {
  40. backBtn.fadeOut("slow");
  41. }
  42. });
  43. backBtn.on("click", function () {
  44. $("html, body").animate({
  45. scrollTop: 0
  46. }, 700);
  47. return false;
  48. });
  49. // Push Menus
  50. var $menuRight = $(".pushmenu-right");
  51. var $toggleright = $("#menu_bars.right");
  52. if ($("#menu_bars").length) {
  53. $("body").addClass("pushmenu-push");
  54. $toggleright.on("click", function () {
  55. $(this).toggleClass("active");
  56. $(".pushmenu-push").toggleClass("pushmenu-push-toleft");
  57. $menuRight.toggleClass("pushmenu-open");
  58. return false;
  59. });
  60. }
  61. //push DropDowns
  62. var side_drop = $('.push_nav .dropdown');
  63. side_drop.on('show.bs.dropdown', function (e) {
  64. $(this).find('.dropdown-menu').first().stop(true, true).slideDown();
  65. });
  66. side_drop.on('hide.bs.dropdown', function (e) {
  67. $(this).find('.dropdown-menu').first().stop(true, true).slideUp();
  68. });
  69. // ************ Accordions
  70. $(".items > li:first-child .sub-items").fadeIn();
  71. $(".items > li:first-child >").addClass("expanded");
  72. $(".items > li > a").on('click', function (e) {
  73. e.preventDefault();
  74. var $this = $(this);
  75. if ($this.hasClass("expanded")) {
  76. $this.removeClass("expanded");
  77. } else {
  78. $(".items a.expanded").removeClass("expanded");
  79. $this.addClass("expanded");
  80. $(".sub-items").filter(":visible").slideUp("normal");
  81. }
  82. $this.parent().children("ul").stop(true, true).slideToggle("normal");
  83. });
  84. // ************ Search On Click
  85. $(".search_btn").on("click", function (event) {
  86. event.preventDefault();
  87. $("#xsearch").addClass("open");
  88. $("#xsearch > form > input[type='search']").focus();
  89. });
  90. $("#xsearch, #xsearch button.close").on("click keyup", function (event) {
  91. if (event.target == this || event.target.className == "close" || event.keyCode == 27) {
  92. $(this).removeClass("open");
  93. }
  94. });
  95. /*Equal Heights*/
  96. if($(".equalheight").length){
  97. $(".equalheight").matchHeight({ property: 'height' });
  98. }
  99. // ************ tabbed content
  100. $(".tab_content").hide();
  101. $(".tab_content:first").show();
  102. /* tab mode */
  103. $("ul.tabs li").on('click', function () {
  104. $(".tab_content").hide();
  105. var activeTab = $(this).attr("rel");
  106. $("#" + activeTab).fadeIn();
  107. $("ul.tabs li").removeClass("active");
  108. $(this).addClass("active");
  109. $(".tab_drawer_heading").removeClass("d_active");
  110. $(".tab_drawer_heading[rel^='" + activeTab + "']").addClass("d_active");
  111. });
  112. /*drawer mode on Mobile Version*/
  113. $(".tab_drawer_heading").on("click", function () {
  114. $(".tab_content").hide();
  115. var d_activeTab = $(this).attr("rel");
  116. $("#" + d_activeTab).fadeIn(1200);
  117. $(".tab_drawer_heading").removeClass("d_active");
  118. $(this).addClass("d_active");
  119. $("ul.tabs li").removeClass("active");
  120. $("ul.tabs li[rel^='" + d_activeTab + "']").addClass("active");
  121. });
  122. //contact form
  123. $("#btn_submit").on("click", function () {
  124. //get input field values
  125. var user_name = $('input[name=name]').val();
  126. var user_email = $('input[name=email]').val();
  127. var user_website = $('input[name=website]').val();
  128. var user_message = $('textarea[name=message]').val();
  129. var post_data, output;
  130. //simple validation at client's end
  131. var proceed = true;
  132. if (user_name == "") {
  133. proceed = false;
  134. }
  135. if (user_email == "") {
  136. proceed = false;
  137. }
  138. if (user_message == "") {
  139. proceed = false;
  140. }
  141. //everything looks good! proceed...
  142. if (proceed) {
  143. //alert(proceed);
  144. //data to be sent to server
  145. post_data = {
  146. 'userName': user_name,
  147. 'userEmail': user_email,
  148. 'userWebsite': user_website,
  149. 'userMessage': user_message
  150. };
  151. //Ajax post data to server
  152. $.post('contact_me.php', post_data, function (response) {
  153. //load json data from server and output message
  154. if (response.type == 'error') {
  155. output = '<div class="alert-danger" style="padding:10px; margin-bottom:10px;">' + response.text + '</div>';
  156. } else {
  157. output = '<div class="alert-success" style="padding:10px; margin-bottom:10px;">' + response.text + '</div>';
  158. //reset values in all input fields
  159. $('.form-inline input').val('');
  160. $('.form-inline textarea').val('');
  161. $('#btn_submit').val('Submit');
  162. }
  163. $("#result").hide().html(output).slideDown();
  164. }, 'json');
  165. }
  166. });
  167. //reset previously set border colors and hide all message on .keyup()
  168. $(".form-inline input, .form-inline textarea").keyup(function () {
  169. $("#result").slideUp();
  170. });
  171. // ************ Fun Facts
  172. $(".number-counters").appear(function () {
  173. $(".number-counters [data-to]").each(function () {
  174. var e = $(this).attr("data-to");
  175. $(this).delay(6e3).countTo({
  176. from: 1,
  177. to: e,
  178. speed: 3500,
  179. refreshInterval: 50
  180. })
  181. })
  182. });
  183. // ************Owl Carousel
  184. $("#news_slider").owlCarousel({
  185. autoPlay: false,
  186. items: 3,
  187. pagination: false,
  188. stopOnHover: true,
  189. navigationText: ["<i class='icon-chevron-thin-left'></i>", "<i class=' icon-chevron-thin-right'></i>"],
  190. navigation: true,
  191. itemsDesktop: [1199, 2],
  192. itemsDesktopSmall: [979, 2],
  193. itemsMobile: [479, 1],
  194. });
  195. $("#expert_slider").owlCarousel({
  196. autoPlay: true,
  197. items: 4,
  198. pagination: false,
  199. stopOnHover: true,
  200. navigationText: ["<i class='icon-chevron-thin-left'></i>", "<i class=' icon-chevron-thin-right'></i>"],
  201. navigation: true,
  202. itemsDesktop: [1199, 2],
  203. itemsDesktopSmall: [979, 2],
  204. itemsMobile: [479, 1],
  205. });
  206. //Fading testimonial content
  207. $("#review_slider, #text_rotator").owlCarousel({
  208. autoPlay: 3000,
  209. navigation: false,
  210. slideSpeed: 300,
  211. singleItem: true,
  212. transitionStyle: "fade"
  213. });
  214. // ============= Revolution Slider =============
  215. //Full Screen
  216. var revapi = $("#rev_slider_full").revolution({
  217. sliderType: "standard",
  218. sliderLayout: "fullscreen",
  219. scrollbarDrag: "true",
  220. delay: 9000,
  221. spinner: "off",
  222. navigation: {
  223. arrows: {
  224. enable: true
  225. },
  226. mouseScrollNavigation: "off",
  227. keyboardNavigation: "off",
  228. touch: {
  229. touchenabled: "on",
  230. swipe_threshold: 75,
  231. swipe_min_touches: 1,
  232. swipe_direction: "horizontal",
  233. drag_block_vertical: false
  234. }
  235. },
  236. parallax: {
  237. type: "mouse",
  238. origo: "slidercenter",
  239. speed: 9000,
  240. levels: [2, 3, 4, 5, 6, 7, 12, 16, 10, 50],
  241. },
  242. responsiveLevels: [4096, 1024, 778, 480],
  243. gridwidth: [1170, 960, 750, 480],
  244. gridheight: [670, 600, 500, 390],
  245. });
  246. var revVideo = $("#rev_slider_video").revolution({
  247. sliderType: "standard",
  248. sliderLayout: "fullscreen",
  249. scrollbarDrag: "true",
  250. delay: 9000,
  251. spinner: "off",
  252. navigation: {
  253. arrows: {
  254. enable: false
  255. },
  256. mouseScrollNavigation: "off",
  257. keyboardNavigation: "off",
  258. touch: {
  259. touchenabled: "on",
  260. swipe_threshold: 75,
  261. swipe_min_touches: 1,
  262. swipe_direction: "horizontal",
  263. drag_block_vertical: false
  264. }
  265. },
  266. parallax: {
  267. type: "mouse",
  268. origo: "slidercenter",
  269. speed: 9000,
  270. levels: [2, 3, 4, 5, 6, 7, 12, 16, 10, 50],
  271. },
  272. responsiveLevels: [4096, 1024, 778, 480],
  273. gridwidth: [1170, 960, 767, 480],
  274. gridheight: [600, 550, 450, 320],
  275. });
  276. // ============= Parallax=============
  277. $(".page_header").parallax("50%", 0.3);
  278. $("#parallax").parallax("50%", 0.2);
  279. $("#counter").parallax("50%", -0.02);
  280. // ======= Cubeportfolio ======
  281. //Project Filter
  282. $("#projects").cubeportfolio({
  283. filters: "#project-filter",
  284. layoutMode: 'grid',
  285. defaultFilter: '*',
  286. animationType: 'slideDelay',
  287. gapHorizontal: 20,
  288. gapVertical: 20,
  289. gridAdjustment: 'responsive',
  290. displayTypeSpeed: 100,
  291. });
  292. //testimonial
  293. $('#js-grid-masonry').cubeportfolio({
  294. layoutMode: 'grid',
  295. gapHorizontal: 50,
  296. gapVertical: 20,
  297. gridAdjustment: 'responsive',
  298. mediaQueries: [{
  299. width: 1500,
  300. cols: 4
  301. }, {
  302. width: 1100,
  303. cols: 4
  304. }, {
  305. width: 800,
  306. cols: 3
  307. }, {
  308. width: 480,
  309. cols: 2
  310. }, {
  311. width: 320,
  312. cols: 1
  313. }],
  314. });
  315. // +++++ WOW Transitions
  316. if ($(window).width() > 767) {
  317. new WOW().init();
  318. }
  319. //Contact Map
  320. if ($("#map").length) {
  321. var map;
  322. map = new GMaps({
  323. el: '#map',
  324. lat: 51.507309,
  325. lng: -0.127448
  326. });
  327. map.drawOverlay({
  328. lat: map.getCenter().lat(),
  329. lng: map.getCenter().lng(),
  330. layer: 'overlayLayer',
  331. content: '<div class="overlay_map"><i class="icon-location-pin"></i></div>',
  332. verticalAlign: 'top',
  333. horizontalAlign: 'center'
  334. });
  335. }
  336. //Custom Code
  337. jQuery('.page-numbers').addClass('pagination').removeClass('page-numbers');
  338. jQuery('.pagination li a').removeClass('pagination');
  339. jQuery('.pagination li span').removeClass('pagination');
  340. jQuery('.pagination li span').removeClass('current');
  341. jQuery('#icon-submit').on('click', function(){
  342. jQuery('#bizness-sidebar-search').submit();
  343. });
  344. function isEmpty(obj) {
  345. for(var prop in obj) {
  346. if(obj.hasOwnProperty(prop))
  347. return false;
  348. }
  349. return true;
  350. }
  351. var regExp = /\(([^)]+)\)/;
  352. jQuery('.widget_archive ul li').each(function(){
  353. var total_post = regExp.exec(jQuery(this).text());
  354. if(isEmpty(total_post)) {
  355. jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p></a></li>");
  356. } else {
  357. jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p><span>"+total_post[1]+"</span></a></li>");
  358. }
  359. });
  360. var regExp = /\(([^)]+)\)/;
  361. jQuery('.widget_layered_nav ul li').each(function(){
  362. var total_post = regExp.exec(jQuery(this).text());
  363. if(isEmpty(total_post)) {
  364. jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p></a></li>");
  365. } else {
  366. jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p><span>"+total_post[1]+"</span></a></li>");
  367. }
  368. });
  369. var get_megamenu = jQuery(".megamenu-fw").length;
  370. if( get_megamenu > 0 ){
  371. jQuery(".megamenu-fw .dropdown-menu").addClass("megamenu-content");
  372. jQuery('.megamenu-fw .dropdown-menu').attr('role', 'menu');
  373. }
  374. });