説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. (function ($) {
  2. ('use strict');
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Template Name: Sattiyas
  6. | Author: Laralink
  7. | Version: 1.0.0
  8. |--------------------------------------------------------------------------
  9. |--------------------------------------------------------------------------
  10. | TABLE OF CONTENTS:
  11. |--------------------------------------------------------------------------
  12. |
  13. | 1. Preloader
  14. | 2. Mobile Menu
  15. | 3. Sticky Header
  16. | 4. Dynamic Background
  17. | 5. Modal Video
  18. | 6. Isotop Initialize
  19. | 7. Scroll Up
  20. | 8. Tabs
  21. | 9. Review
  22. | 10. Slick Slider
  23. | 11. Price Range Slider
  24. | 12. Single product slider
  25. | 13. Shop General
  26. |
  27. */
  28. /*--------------------------------------------------------------
  29. Scripts initialization
  30. --------------------------------------------------------------*/
  31. $.exists = function (selector) {
  32. return $(selector).length > 0;
  33. };
  34. $(window).on('load', function () {
  35. preloader();
  36. isotopInit();
  37. });
  38. $(function () {
  39. mainNav();
  40. stickyHeader();
  41. dynamicBackground();
  42. modalVideo();
  43. isotopInit();
  44. slickInit();
  45. scrollUp();
  46. tabs();
  47. review();
  48. priceInit();
  49. singleProductSlider();
  50. shopGeneral();
  51. });
  52. $(window).on('scroll', function () {
  53. showScrollUp();
  54. });
  55. /*--------------------------------------------------------------
  56. 1. Preloader
  57. --------------------------------------------------------------*/
  58. function preloader() {
  59. $('.cs_perloader').fadeOut();
  60. $('cs_perloader_in').delay(150).fadeOut('slow');
  61. }
  62. /*--------------------------------------------------------------
  63. 2. Mobile Menu
  64. --------------------------------------------------------------*/
  65. function mainNav() {
  66. $('.cs_nav').append('<span class="cs_menu_toggle"><span></span></span>');
  67. $('.menu-item-has-children').append(
  68. '<span class="cs_menu_dropdown_toggle"><span></span></span>',
  69. );
  70. $('.cs_menu_toggle').on('click', function () {
  71. $(this)
  72. .toggleClass('cs_toggle_active')
  73. .siblings('.cs_nav_list')
  74. .slideToggle();
  75. });
  76. $('.cs_menu_toggle')
  77. .parents('body')
  78. .find('.cs_side_header')
  79. .addClass('cs_has_main_nav');
  80. $('.cs_menu_toggle')
  81. .parents('body')
  82. .find('.cs_toolbox')
  83. .addClass('cs_has_main_nav');
  84. $('.cs_menu_dropdown_toggle').on('click', function () {
  85. $(this).toggleClass('active').siblings('ul').slideToggle();
  86. $(this).parent().toggleClass('active');
  87. });
  88. $('.cs_header_search_btn').on('click', function () {
  89. $('.cs_header_search_wrap').addClass('active');
  90. });
  91. $('.cs_header_search_close').on('click', function () {
  92. $('.cs_header_search_wrap').removeClass('active');
  93. });
  94. }
  95. /*--------------------------------------------------------------
  96. 3. Sticky Header
  97. --------------------------------------------------------------*/
  98. function stickyHeader() {
  99. var $window = $(window);
  100. var lastScrollTop = 0;
  101. var $header = $('.cs_sticky_header');
  102. var headerHeight = $header.outerHeight() + 30;
  103. $window.scroll(function () {
  104. var windowTop = $window.scrollTop();
  105. if (windowTop >= headerHeight) {
  106. $header.addClass('cs_gescout_sticky');
  107. } else {
  108. $header.removeClass('cs_gescout_sticky');
  109. $header.removeClass('cs_gescout_show');
  110. }
  111. if ($header.hasClass('cs_gescout_sticky')) {
  112. if (windowTop < lastScrollTop) {
  113. $header.addClass('cs_gescout_show');
  114. } else {
  115. $header.removeClass('cs_gescout_show');
  116. }
  117. }
  118. lastScrollTop = windowTop;
  119. });
  120. }
  121. /*--------------------------------------------------------------
  122. 4. Dynamic Background
  123. --------------------------------------------------------------*/
  124. function dynamicBackground() {
  125. $('[data-src]').each(function () {
  126. var src = $(this).attr('data-src');
  127. $(this).css({
  128. 'background-image': 'url(' + src + ')',
  129. });
  130. });
  131. }
  132. /*--------------------------------------------------------------
  133. 5. Modal Video
  134. --------------------------------------------------------------*/
  135. function modalVideo() {
  136. if ($.exists('.cs_video_open')) {
  137. $('body').append(`
  138. <div class="cs_video_popup">
  139. <div class="cs_video_popup_overlay"></div>
  140. <div class="cs_video_popup_content">
  141. <div class="cs_video_popup_layer"></div>
  142. <div class="cs_video_popup_container">
  143. <div class="cs_video_popup_align">
  144. <div class="embed_responsive embed_responsive_16by9">
  145. <iframe class="embed_responsive_item" src="about:blank"></iframe>
  146. </div>
  147. </div>
  148. <div class="cs_video_popup_close"></div>
  149. </div>
  150. </div>
  151. </div>
  152. `);
  153. $(document).on('click', '.cs_video_open', function (e) {
  154. e.preventDefault();
  155. var video = $(this).attr('href');
  156. $('.cs_video_popup_container iframe').attr('src', `${video}`);
  157. $('.cs_video_popup').addClass('active');
  158. });
  159. $('.cs_video_popup_close, .cs_video_popup_layer').on(
  160. 'click',
  161. function (e) {
  162. $('.cs_video_popup').removeClass('active');
  163. $('html').removeClass('overflow-hidden');
  164. $('.cs_video_popup_container iframe').attr('src', 'about:blank');
  165. e.preventDefault();
  166. },
  167. );
  168. }
  169. }
  170. /*--------------------------------------------------------------
  171. 6. Isotop Initialize
  172. --------------------------------------------------------------*/
  173. function isotopInit() {
  174. if ($.exists('.cs_isotope')) {
  175. $('.cs_isotope').isotope({
  176. itemSelector: '.cs_isotope_item',
  177. transitionDuration: '0.60s',
  178. percentPosition: true,
  179. masonry: {
  180. columnWidth: '.cs_grid_sizer',
  181. },
  182. });
  183. /* Active Class of Portfolio*/
  184. $('.cs_isotope_filter ul li').on('click', function (event) {
  185. $(this).siblings('.active').removeClass('active');
  186. $(this).addClass('active');
  187. event.preventDefault();
  188. });
  189. /*=== Portfolio filtering ===*/
  190. $('.cs_isotope_filter ul').on('click', 'a', function () {
  191. var filterElement = $(this).attr('data-filter');
  192. $('.cs_isotope').isotope({
  193. filter: filterElement,
  194. });
  195. });
  196. }
  197. }
  198. /*-----------------------------------------------------------
  199. 7. Scroll Up
  200. ------------------------------------------------------------*/
  201. function scrollUp() {
  202. $('#cs_scroll_btn').on('click', function (e) {
  203. e.preventDefault();
  204. $('html,body').animate(
  205. {
  206. scrollTop: 0,
  207. },
  208. 0,
  209. );
  210. });
  211. }
  212. // For Show Scroll Up
  213. function showScrollUp() {
  214. let scroll = $(window).scrollTop();
  215. if (scroll >= 350) {
  216. $('#cs_scroll_btn').addClass('cs_scrollup_show');
  217. } else {
  218. $('#cs_scroll_btn').removeClass('cs_scrollup_show');
  219. }
  220. }
  221. /*---------------------------------------------------------
  222. 8. Tabs
  223. ------------------------------------------------------------*/
  224. function tabs() {
  225. $('.cs_tab_links a').on('click', function (e) {
  226. var currentAttrValue = $(this).attr('href');
  227. $('.cs_tabs_fade ' + currentAttrValue)
  228. .fadeIn(400)
  229. .siblings()
  230. .hide();
  231. //Tab and slider both activation code
  232. $('.cs_tabs ' + currentAttrValue)
  233. .addClass('active')
  234. .siblings()
  235. .removeClass('active');
  236. $(this).parents('li').addClass('active').siblings().removeClass('active');
  237. e.preventDefault();
  238. });
  239. }
  240. /*-----------------------------------------------------------
  241. 9. Review
  242. --------------------------------------------------------------*/
  243. function review() {
  244. $('.cs_rating').each(function () {
  245. var review = $(this).data('rating');
  246. var reviewVal = review * 20 + '%';
  247. $(this).find('.cs_rating_percentage').css('width', reviewVal);
  248. });
  249. }
  250. /*-----------------------------------------------------------
  251. 10. Slick Slider
  252. --------------------------------------------------------------*/
  253. var helpers = {
  254. addZeros: function (n) {
  255. return n < 10 ? '0' + n : '' + n;
  256. },
  257. };
  258. function slickInit() {
  259. if ($.exists('.cs_slider')) {
  260. $('.cs_slider').each(function () {
  261. // Slick Variable
  262. var $ts = $(this).find('.cs_slider_container');
  263. var $slickActive = $(this).find('.cs_slider_wrapper');
  264. // Auto Play
  265. var autoPlayVar = parseInt($ts.attr('data-autoplay'), 10);
  266. // Auto Play Time Out
  267. var autoplaySpdVar = 3000;
  268. if (autoPlayVar > 1) {
  269. autoplaySpdVar = autoPlayVar;
  270. autoPlayVar = 1;
  271. }
  272. // Slide Change Speed
  273. var speedVar = parseInt($ts.attr('data-speed'), 10);
  274. // Slider Loop
  275. var loopVar = Boolean(parseInt($ts.attr('data-loop'), 10));
  276. // Slider Center
  277. var centerVar = Boolean(parseInt($ts.attr('data-center'), 10));
  278. // Variable Width
  279. var variableWidthVar = Boolean(
  280. parseInt($ts.attr('data-variable-width'), 10),
  281. );
  282. // Pagination
  283. var paginaiton = $(this)
  284. .find('.cs_pagination')
  285. .hasClass('cs_pagination');
  286. // Slide Per View
  287. var slidesPerView = $ts.attr('data-slides-per-view');
  288. if (slidesPerView == 1) {
  289. slidesPerView = 1;
  290. }
  291. if (slidesPerView == 'responsive') {
  292. var slidesPerView = parseInt($ts.attr('data-add-slides'), 10);
  293. var lgPoint = parseInt($ts.attr('data-lg-slides'), 10);
  294. var mdPoint = parseInt($ts.attr('data-md-slides'), 10);
  295. var smPoint = parseInt($ts.attr('data-sm-slides'), 10);
  296. var xsPoint = parseInt($ts.attr('data-xs-slides'), 10);
  297. var xxsPoint = parseInt($ts.attr('data-xxs-slides'), 10);
  298. }
  299. // Fade Slider
  300. var fadeVar = parseInt($($ts).attr('data-fade-slide'));
  301. fadeVar === 1 ? (fadeVar = true) : (fadeVar = false);
  302. // Slick Active Code
  303. $slickActive.slick({
  304. centerMode: centerVar,
  305. autoplay: autoPlayVar,
  306. dots: paginaiton,
  307. speed: speedVar,
  308. infinite: loopVar,
  309. autoplaySpeed: autoplaySpdVar,
  310. fade: fadeVar,
  311. prevArrow: $(this).find('.cs_left_arrow'),
  312. nextArrow: $(this).find('.cs_right_arrow'),
  313. appendDots: $(this).find('.cs_pagination'),
  314. slidesToShow: slidesPerView,
  315. variableWidth: variableWidthVar,
  316. responsive: [
  317. {
  318. breakpoint: 1600,
  319. settings: {
  320. slidesToShow: lgPoint,
  321. },
  322. },
  323. {
  324. breakpoint: 1200,
  325. settings: {
  326. slidesToShow: mdPoint,
  327. },
  328. },
  329. {
  330. breakpoint: 992,
  331. settings: {
  332. slidesToShow: smPoint,
  333. },
  334. },
  335. {
  336. breakpoint: 768,
  337. settings: {
  338. slidesToShow: xsPoint,
  339. },
  340. },
  341. {
  342. breakpoint: 180,
  343. settings: {
  344. slidesToShow: xxsPoint,
  345. },
  346. },
  347. ],
  348. });
  349. // Slider Number
  350. if ($(this).find('.slick_slide_in').length > 1) {
  351. $(this).siblings('.cs_slides_numbers').show();
  352. }
  353. $(this).on('afterChange', function (event, slick, currentSlide) {
  354. $(this)
  355. .find('.cs_slides_numbers .active')
  356. .html(helpers.addZeros(currentSlide + 1));
  357. });
  358. var sliderItemsNum = $(this)
  359. .find('.slick-slide')
  360. .not('.slick-cloned').length;
  361. $(this)
  362. .find('.cs_slides_numbers .cs_total_slide')
  363. .html(helpers.addZeros(sliderItemsNum));
  364. });
  365. }
  366. }
  367. /*-----------------------------------------------------------
  368. 11. Price Range Slider
  369. ------------------------------------------------------------*/
  370. function priceInit() {
  371. if ($.exists('#slider_range')) {
  372. $('#slider_range').slider({
  373. range: true,
  374. min: 0,
  375. max: 1000,
  376. values: [100, 600],
  377. slide: function (event, ui) {
  378. $('#amount').val(
  379. 'Price: $' + ui.values[0] + '.00 - $' + ui.values[1] + '.00',
  380. );
  381. },
  382. });
  383. }
  384. if ($.exists('#amount')) {
  385. $('#amount').val(
  386. 'Price: $' +
  387. $('#slider_range').slider('values', 0) +
  388. '.00 - $' +
  389. $('#slider_range').slider('values', 1) +
  390. '.00',
  391. );
  392. }
  393. }
  394. /*----------------------------------------------------------
  395. 12. Single product slider
  396. ------------------------------------------------------------*/
  397. function singleProductSlider() {
  398. // Product Single Slider
  399. $('.cs_single_product_thumb').slick({
  400. slidesToShow: 1,
  401. slidesToScroll: 1,
  402. arrows: false,
  403. asNavFor: '.cs_single_product_nav',
  404. vertical: true,
  405. });
  406. $('.cs_single_product_nav').slick({
  407. slidesToShow: 4,
  408. slidesToScroll: 1,
  409. asNavFor: '.cs_single_product_thumb',
  410. focusOnSelect: true,
  411. arrows: false,
  412. vertical: true,
  413. });
  414. }
  415. /*----------------------------------------------------------
  416. 13. Shop General
  417. ------------------------------------------------------------*/
  418. function shopGeneral() {
  419. // List and Grid View Toggle
  420. $('.cs_grid_btn').on('click', function () {
  421. $(this).addClass('active').siblings().removeClass('active');
  422. $('.cs_product_grid')
  423. .addClass('cs_grid_view')
  424. .removeClass('cs_list_view');
  425. });
  426. $('.cs_list_btn').on('click', function () {
  427. $(this).addClass('active').siblings().removeClass('active');
  428. $('.cs_product_grid')
  429. .addClass('cs_list_view')
  430. .removeClass('cs_grid_view');
  431. });
  432. // Filter Widget Toggle
  433. $('.cs_filter_widget_title').on('click', function () {
  434. $(this).toggleClass('active').siblings().slideToggle();
  435. });
  436. // Filter Sidebar Show And Hide
  437. $('.cs_filter_btn').on('click', function () {
  438. $('.cs_shop_filter').addClass('active');
  439. });
  440. $('.cs_filter_close, .cs_filter_overlay').on('click', function () {
  441. $('.cs_shop_filter').removeClass('active');
  442. });
  443. // Star Rating Input
  444. $('.cs_input_rating i').on('click', function () {
  445. $(this).siblings().removeClass('fa-solid');
  446. $(this).addClass('fa-solid').prevAll().addClass('fa-solid');
  447. });
  448. // Quantity Increment and Decrement
  449. $('.cs_increment').click(function () {
  450. var countElement = $(this).siblings('.cs_quantity_input');
  451. var count = parseInt(countElement.text());
  452. count++;
  453. countElement.text(count);
  454. });
  455. $('.cs_decrement').click(function () {
  456. var countElement = $(this).siblings('.cs_quantity_input');
  457. var count = parseInt(countElement.text());
  458. if (count > 0) {
  459. count--;
  460. countElement.text(count);
  461. }
  462. });
  463. }
  464. })(jQuery); // End of use strict