You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

300 lines
9.1 KiB

1 year ago
  1. (function ($) {
  2. "use strict";
  3. // Preloader
  4. $(window).on('load', function () {
  5. $('[data-loader="circle-side"]').fadeOut(); // will first fade out the loading animation
  6. $('#preloader').delay(333).fadeOut('slow'); // will fade out the white DIV that covers the website.
  7. $('body').delay(333);
  8. });
  9. /*---------------------------------------------------
  10. Primary Menu
  11. ----------------------------------------------------- */
  12. // Dropdown show on hover
  13. $('.primary-menu ul.navbar-nav li.dropdown, .login-signup ul.navbar-nav li.dropdown').on("mouseover", function() {
  14. if ($(window).width() > 991) {
  15. $(this).find('> .dropdown-menu').stop().slideDown('fast');
  16. $(this).bind('mouseleave', function() {
  17. $(this).find('> .dropdown-menu').stop().css('display', 'none');
  18. });
  19. // When dropdown going off to the out of the screen.
  20. $('.primary-menu ul.navbar-nav > li.dropdown > .dropdown-menu').each(function() {
  21. var menu = $('#header .header-row').offset();
  22. var dropdown = $(this).parent().offset();
  23. if ($("html").attr("dir") == 'rtl') {
  24. var rd = ($(window).width() - (dropdown.left + $(this).parent().outerWidth()));
  25. var i = (rd + $(this).outerWidth()) - (menu.left + $('#header .header-row').outerWidth());
  26. }else{
  27. var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#header .header-row').outerWidth());
  28. }
  29. if (i > 0) {
  30. if ($("html").attr("dir") == 'rtl') {
  31. $(this).css('margin-right', '-' + (i) + 'px');
  32. }else{
  33. $(this).css('margin-left', '-' + (i) + 'px');
  34. }
  35. }
  36. });
  37. }
  38. });
  39. $(function () {
  40. $(".dropdown li").on('mouseenter mouseleave', function (e) {
  41. if ($(window).width() > 991) {
  42. if ($('.dropdown-menu', this).length) {
  43. var elm = $('.dropdown-menu', this);
  44. var off = elm.offset();
  45. var l = off.left;
  46. var w = elm.width();
  47. var docW = $(window).width();
  48. var lr = ($(window).width() - (off.left + elm.outerWidth())); //offset right
  49. if ($("html").attr("dir") == 'rtl') {
  50. var isEntirelyVisible = (lr + w + 30 <= docW);
  51. }else{
  52. var isEntirelyVisible = (l + w + 30 <= docW);
  53. }
  54. if (!isEntirelyVisible) {
  55. $(elm).addClass('dropdown-menu-end');
  56. $(elm).parents('.dropdown:first').find('> a.dropdown-toggle > .arrow').addClass('arrow-end');
  57. } else {
  58. $(elm).removeClass('dropdown-menu-end');
  59. $(elm).parents('.dropdown:first').find('> a.dropdown-toggle > .arrow').removeClass('arrow-end');
  60. }
  61. }
  62. }
  63. });
  64. });
  65. // Login-signup dropdown
  66. $('.login-signup ul.navbar-nav > li.dropdown > .dropdown-menu').each(function() {
  67. var menu = $('#header .header-row').offset();
  68. var dropdown = $(this).parent().offset();
  69. if ($("html").attr("dir") == 'rtl') {
  70. var rd = ($(window).width() - (dropdown.left + $(this).parent().outerWidth()));
  71. var i = (rd + $(this).outerWidth()) - (menu.left + $('#header .header-row').outerWidth());
  72. }else{
  73. var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#header .header-row').outerWidth());
  74. }
  75. if (i > 0) {
  76. if ($("html").attr("dir") == 'rtl') {
  77. $(this).css('margin-right', '-' + (i) + 'px');
  78. }else{
  79. $(this).css('margin-left', '-' + (i) + 'px');
  80. }
  81. }
  82. });
  83. $(function () {
  84. $(".login-signup .dropdown li").on('click', function (e) {
  85. if ($('.dropdown-menu', this).length) {
  86. var elm = $('.dropdown-menu', this);
  87. var off = elm.offset();
  88. var l = off.left;
  89. var w = elm.width();
  90. var docW = $(window).width();
  91. var lr = ($(window).width() - (off.left + elm.outerWidth())); //offset right
  92. if ($("html").attr("dir") == 'rtl') {
  93. var isEntirelyVisible = (lr + w + 30 <= docW);
  94. }else{
  95. var isEntirelyVisible = (l + w + 30 <= docW);
  96. }
  97. if (!isEntirelyVisible) {
  98. $(elm).toggleClass('dropdown-menu-end');
  99. $(elm).parents('.dropdown:first').find('> a.dropdown-toggle > .arrow').toggleClass('arrow-end');
  100. }
  101. }
  102. });
  103. });
  104. // DropDown Arrow
  105. $('.primary-menu, .login-signup').find('a.dropdown-toggle').append($('<i />').addClass('arrow'));
  106. // Mobile Collapse Nav
  107. $('.primary-menu .dropdown-toggle[href="#"], .primary-menu .dropdown-toggle[href!="#"] .arrow, .login-signup .dropdown-toggle[href="#"], .login-signup .dropdown-toggle[href!="#"] .arrow').on('click', function(e) {
  108. if ($(window).width() < 991) {
  109. e.preventDefault();
  110. var $parentli = $(this).closest('li');
  111. $parentli.siblings('li').find('.dropdown-menu:visible').slideUp();
  112. $parentli.find('> .dropdown-menu').stop().slideToggle();
  113. $parentli.siblings('li').find('a .arrow.open').toggleClass('open');
  114. $parentli.find('> a .arrow').toggleClass('open');
  115. }
  116. });
  117. // Mobile Menu Button Icon
  118. $('.navbar-toggler').on('click', function() {
  119. $(this).toggleClass('open');
  120. });
  121. /*---------------------------------
  122. Carousel (Owl Carousel)
  123. ----------------------------------- */
  124. $(".owl-carousel").each(function (index) {
  125. var a = $(this);
  126. if ($("html").attr("dir") == 'rtl') {
  127. var rtlVal = true
  128. }else{
  129. var rtlVal = false
  130. }
  131. $(this).owlCarousel({
  132. rtl: rtlVal,
  133. autoplay: a.data('autoplay'),
  134. center: a.data('center'),
  135. autoplayTimeout: a.data('autoplaytimeout'),
  136. autoplayHoverPause: a.data('autoplayhoverpause'),
  137. loop: a.data('loop'),
  138. speed: a.data('speed'),
  139. nav: a.data('nav'),
  140. dots: a.data('dots'),
  141. autoHeight: a.data('autoheight'),
  142. autoWidth: a.data('autowidth'),
  143. margin: a.data('margin'),
  144. stagePadding: a.data('stagepadding'),
  145. slideBy: a.data('slideby'),
  146. lazyLoad: a.data('lazyload'),
  147. navText:['<i class="fa fa-chevron-left"></i>', '<i class="fa fa-chevron-right"></i>'],
  148. animateOut: a.data('animateout'),
  149. animateIn: a.data('animatein'),
  150. video: a.data('video'),
  151. items: a.data('items'),
  152. responsive:{
  153. 0:{items: a.data('items-xs'),},
  154. 576:{items: a.data('items-sm'),},
  155. 768:{items: a.data('items-md'),},
  156. 992:{items: a.data('items-lg'),}
  157. }
  158. });
  159. });
  160. function accordionFun(e) {
  161. var collBTN = e + " .accordion-item h5";
  162. var colbody = e + " .accordion-item";
  163. $(collBTN).on("click", function() {
  164. // console.log('HI', colbody);
  165. $(colbody).removeClass("active");
  166. $(this)
  167. .parent(".accordion-item")
  168. .addClass("active");
  169. });
  170. }
  171. accordionFun("#accordion");
  172. accordionFun("#accordion1");
  173. accordionFun("#accordion2");
  174. accordionFun("#accordion3");
  175. accordionFun("#accordion4");
  176. accordionFun("#accordion5");
  177. accordionFun("#accordion6");
  178. /*---------------------------------------------------
  179. YouTube video to autoplay in modal
  180. ----------------------------------------------------- */
  181. // Gets the video src from the data-src on each button
  182. var $videoSrc;
  183. $('.video-btn').on('click', function() {
  184. $videoSrc = $(this).data( "src" );
  185. });
  186. // when the modal is opened autoplay it
  187. $('#videoModal').on('shown.bs.modal', function (e) {
  188. // set the video src to autoplay and not to show related video. Youtube related video is like a box of chocolates...you never know what you're gonna get
  189. $("#video").attr('src',$videoSrc + "?autoplay=1&amp;modestbranding=1&amp;showinfo=0&amp;rel=0" );
  190. })
  191. // stop playing the youtube video when I close the modal
  192. $('#videoModal').on('hide.bs.modal', function (e) {
  193. $("#video").attr('src',$videoSrc);
  194. })
  195. /*------------------------
  196. tooltips
  197. -------------------------- */
  198. var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
  199. var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  200. return new bootstrap.Tooltip(tooltipTriggerEl)
  201. })
  202. /*------------------------
  203. Scroll to top
  204. ------------------------ */
  205. $(function () {
  206. $(window).on('scroll', function(){
  207. if ($(this).scrollTop() > 150) {
  208. $('#back-to-top').fadeIn();
  209. } else {
  210. $('#back-to-top').fadeOut();
  211. }
  212. });
  213. });
  214. $('#back-to-top').on("click", function() {
  215. $('html, body').animate({scrollTop:0}, 'slow');
  216. return false;
  217. });
  218. $('.smooth-scroll a').on("click", function() {
  219. var sectionTo = $(this).attr('href');
  220. $('html, body').animate({
  221. scrollTop: $(sectionTo).offset().top - 50}, 600);
  222. });
  223. /* --- Form - Datepicker -- */
  224. function loadDatePicker(){
  225. $('.date-of-birth').datepicker({
  226. language: 'en',
  227. dateFormat: 'dd/mm/yyyy',
  228. });
  229. $('.issue-date').datepicker({
  230. language: 'en',
  231. dateFormat: 'dd/mm/yyyy',
  232. });
  233. $('.expire-date').datepicker({
  234. language: 'en',
  235. dateFormat: 'dd/mm/yyyy',
  236. });
  237. $('.from-date').datepicker({
  238. language: 'en',
  239. dateFormat: 'dd/mm/yyyy',
  240. });
  241. $('.to-date').datepicker({
  242. language: 'en',
  243. dateFormat: 'dd/mm/yyyy',
  244. });
  245. }
  246. function bs_input_file() {
  247. $(".input-file").before(
  248. function() {
  249. if ( ! $(this).prev().hasClass('input-ghost') ) {
  250. var element = $("<input type='file' style='visibility:hidden; display:none; height:0'>");
  251. element.attr("name",$(this).attr("name"));
  252. element.change(function(){
  253. element.next(element).find('input').val((element.val()).split('\\').pop());
  254. });
  255. $(this).find(".btn-choose").click(function(){
  256. element.click();
  257. });
  258. $(this).find('input').css("cursor","pointer");
  259. $(this).find('input').mousedown(function() {
  260. $(this).parents('.input-file').prev().click();
  261. return false;
  262. });
  263. return element;
  264. }
  265. }
  266. );
  267. }
  268. $(function() {
  269. bs_input_file();
  270. });
  271. })(jQuery);