plugins.init.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /* Template Name: Landrick - Saas & Software Landing Page Template
  2. Author: Shreethemes
  3. E-mail: support@shreethemes.in
  4. Created: August 2019
  5. Version: 3.5.0
  6. Updated: July 2021
  7. File Description: Common JS file of the template(plugins.init.js)
  8. */
  9. /*********************************/
  10. /* INDEX */
  11. /*================================
  12. * 01. Tiny Slider *
  13. * 02. Swiper slider *
  14. * 03. Countdown Js * (For Comingsoon pages)
  15. * 04. Maintenance js * (For Maintenance page)
  16. * 05. Data Counter *
  17. * 06. Datepicker js *
  18. * 07. Gallery filter js * (For Portfolio pages)
  19. * 08. Tobii lightbox * (For Portfolio pages)
  20. * 09. CK Editor * (For Compose mail)
  21. * 10. Fade Animation *
  22. * 11. Typed Text animation (animation) *
  23. * 12. Validation Form *
  24. * 13. Switcher Pricing Plan *
  25. ================================*/
  26. //=========================================//
  27. /* 01) Tiny slider */
  28. //=========================================//
  29. if(document.getElementsByClassName('tiny-single-item').length > 0) {
  30. var slider = tns({
  31. container: '.tiny-single-item',
  32. items: 1,
  33. controls: false,
  34. mouseDrag: true,
  35. loop: true,
  36. rewind: true,
  37. autoplay: true,
  38. autoplayButtonOutput: false,
  39. autoplayTimeout: 3000,
  40. navPosition: "bottom",
  41. speed: 400,
  42. gutter: 16,
  43. });
  44. };
  45. if(document.getElementsByClassName('tiny-two-item').length > 0) {
  46. var slider = tns({
  47. container: '.tiny-two-item',
  48. controls: false,
  49. mouseDrag: true,
  50. loop: true,
  51. rewind: true,
  52. autoplay: true,
  53. autoplayButtonOutput: false,
  54. autoplayTimeout: 3000,
  55. navPosition: "bottom",
  56. speed: 400,
  57. gutter: 12,
  58. responsive: {
  59. 992: {
  60. items: 2
  61. },
  62. 767: {
  63. items: 2
  64. },
  65. 320: {
  66. items: 1
  67. },
  68. },
  69. });
  70. };
  71. if(document.getElementsByClassName('tiny-three-item').length > 0) {
  72. var slider = tns({
  73. container: '.tiny-three-item',
  74. controls: false,
  75. mouseDrag: true,
  76. loop: true,
  77. rewind: true,
  78. autoplay: true,
  79. autoplayButtonOutput: false,
  80. autoplayTimeout: 3000,
  81. navPosition: "bottom",
  82. speed: 400,
  83. gutter: 12,
  84. responsive: {
  85. 992: {
  86. items: 3
  87. },
  88. 767: {
  89. items: 2
  90. },
  91. 320: {
  92. items: 1
  93. },
  94. },
  95. });
  96. };
  97. if(document.getElementsByClassName('tiny-four-item').length > 0) {
  98. var slider = tns({
  99. container: '.tiny-four-item',
  100. controls: false,
  101. mouseDrag: true,
  102. loop: true,
  103. rewind: true,
  104. autoplay: true,
  105. autoplayButtonOutput: false,
  106. autoplayTimeout: 3000,
  107. navPosition: "bottom",
  108. speed: 400,
  109. gutter: 12,
  110. responsive: {
  111. 992: {
  112. items: 4
  113. },
  114. 767: {
  115. items: 2
  116. },
  117. 320: {
  118. items: 1
  119. },
  120. },
  121. });
  122. };
  123. if(document.getElementsByClassName('roadmaps').length > 0) {
  124. var slider = tns({
  125. container: '.roadmaps',
  126. controls: false,
  127. mouseDrag: true,
  128. loop: true,
  129. rewind: true,
  130. autoplay: true,
  131. autoplayButtonOutput: false,
  132. autoplayTimeout: 3000,
  133. nav: false,
  134. speed: 400,
  135. gutter: 12,
  136. responsive: {
  137. 992: {
  138. items: 4
  139. },
  140. 767: {
  141. items: 2
  142. },
  143. 320: {
  144. items: 1
  145. },
  146. },
  147. });
  148. };
  149. if(document.getElementsByClassName('tiny-six-item').length > 0) {
  150. var slider = tns({
  151. container: '.tiny-six-item',
  152. controls: false,
  153. mouseDrag: true,
  154. loop: true,
  155. rewind: true,
  156. autoplay: true,
  157. autoplayButtonOutput: false,
  158. autoplayTimeout: 3000,
  159. navPosition: "bottom",
  160. speed: 400,
  161. gutter: 12,
  162. responsive: {
  163. 992: {
  164. items: 6
  165. },
  166. 767: {
  167. items: 3
  168. },
  169. 320: {
  170. items: 1
  171. },
  172. },
  173. });
  174. };
  175. if(document.getElementsByClassName('tiny-twelve-item').length > 0) {
  176. var slider = tns({
  177. container: '.tiny-twelve-item',
  178. controls: true,
  179. mouseDrag: true,
  180. loop: true,
  181. rewind: true,
  182. autoplay: true,
  183. autoplayButtonOutput: false,
  184. autoplayTimeout: 3000,
  185. navPosition: "bottom",
  186. controlsText: ['<i class="mdi mdi-chevron-left "></i>', '<i class="mdi mdi-chevron-right"></i>'],
  187. nav: false,
  188. speed: 400,
  189. gutter: 0,
  190. responsive: {
  191. 1025: {
  192. items: 10
  193. },
  194. 992: {
  195. items: 8
  196. },
  197. 767: {
  198. items: 6
  199. },
  200. 320: {
  201. items: 2
  202. },
  203. },
  204. });
  205. };
  206. //=========================================//
  207. /* 02) Swiper slider */
  208. //=========================================//
  209. try {
  210. var menu = [];
  211. var interleaveOffset = 0.5;
  212. var swiperOptions = {
  213. loop: true,
  214. speed: 1000,
  215. parallax: true,
  216. autoplay: {
  217. delay: 6500,
  218. disableOnInteraction: false,
  219. },
  220. watchSlidesProgress: true,
  221. pagination: {
  222. el: '.swiper-pagination',
  223. clickable: true,
  224. renderBullet: function (index, className) {
  225. return '<span class="' + className + '">' + 0 + (index + 1) + '</span>';
  226. },
  227. },
  228. navigation: {
  229. nextEl: '.swiper-button-next',
  230. prevEl: '.swiper-button-prev',
  231. },
  232. on: {
  233. progress: function () {
  234. var swiper = this;
  235. for (var i = 0; i < swiper.slides.length; i++) {
  236. var slideProgress = swiper.slides[i].progress;
  237. var innerOffset = swiper.width * interleaveOffset;
  238. var innerTranslate = slideProgress * innerOffset;
  239. swiper.slides[i].querySelector(".slide-inner").style.transform =
  240. "translate3d(" + innerTranslate + "px, 0, 0)";
  241. }
  242. },
  243. touchStart: function () {
  244. var swiper = this;
  245. for (var i = 0; i < swiper.slides.length; i++) {
  246. swiper.slides[i].style.transition = "";
  247. }
  248. },
  249. setTransition: function (speed) {
  250. var swiper = this;
  251. for (var i = 0; i < swiper.slides.length; i++) {
  252. swiper.slides[i].style.transition = speed + "ms";
  253. swiper.slides[i].querySelector(".slide-inner").style.transition =
  254. speed + "ms";
  255. }
  256. }
  257. }
  258. };
  259. // DATA BACKGROUND IMAGE
  260. var swiper = new Swiper(".swiper-container", swiperOptions);
  261. let data = document.querySelectorAll(".slide-bg-image")
  262. data.forEach((e) => {
  263. e.style.backgroundImage =
  264. `url(${e.getAttribute('data-background')})`;
  265. })
  266. } catch (err) {
  267. }
  268. //=========================================//
  269. /*/* 03) Countdown js */
  270. //=========================================//
  271. try {
  272. if(document.getElementById("days")){
  273. // The data/time we want to countdown to
  274. var eventCountDown = new Date("December 25, 2022 16:37:52").getTime();
  275. // Run myfunc every second
  276. var myfunc = setInterval(function () {
  277. var now = new Date().getTime();
  278. var timeleft = eventCountDown - now;
  279. // Calculating the days, hours, minutes and seconds left
  280. var days = Math.floor(timeleft / (1000 * 60 * 60 * 24));
  281. var hours = Math.floor((timeleft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  282. var minutes = Math.floor((timeleft % (1000 * 60 * 60)) / (1000 * 60));
  283. var seconds = Math.floor((timeleft % (1000 * 60)) / 1000);
  284. // Result is output to the specific element
  285. document.getElementById("days").innerHTML = days + "<p class='count-head'>Days</p> "
  286. document.getElementById("hours").innerHTML = hours + "<p class='count-head'>Hours</p> "
  287. document.getElementById("mins").innerHTML = minutes + "<p class='count-head'>Mins</p> "
  288. document.getElementById("secs").innerHTML = seconds + "<p class='count-head'>Secs</p> "
  289. // Display the message when countdown is over
  290. if (timeleft < 0) {
  291. clearInterval(myfunc);
  292. document.getElementById("days").innerHTML = ""
  293. document.getElementById("hours").innerHTML = ""
  294. document.getElementById("mins").innerHTML = ""
  295. document.getElementById("secs").innerHTML = ""
  296. document.getElementById("end").innerHTML = "00:00:00:00";
  297. }
  298. }, 1000);
  299. }
  300. } catch (err) {
  301. }
  302. //=========================================//
  303. /*/* 04) Maintenance js */
  304. //=========================================//
  305. try {
  306. if(document.getElementById("maintenance")){
  307. var seconds = 3599;
  308. function secondPassed() {
  309. var minutes = Math.round((seconds - 30) / 60);
  310. var remainingSeconds = seconds % 60;
  311. if (remainingSeconds < 10) {
  312. remainingSeconds = "0" + remainingSeconds;
  313. }
  314. document.getElementById('maintenance').innerHTML = minutes + ":" + remainingSeconds;
  315. if (seconds == 0) {
  316. clearInterval(countdownTimer);
  317. document.getElementById('maintenance').innerHTML = "Buzz Buzz";
  318. } else {
  319. seconds--;
  320. }
  321. }
  322. var countdownTimer = setInterval('secondPassed()', 1000);
  323. }
  324. } catch (err) {
  325. }
  326. //=========================================//
  327. /*/* 05) Data Counter */
  328. //=========================================//
  329. try {
  330. const counter = document.querySelectorAll('.counter-value');
  331. const speed = 2500; // The lower the slower
  332. counter.forEach(counter_value => {
  333. const updateCount = () => {
  334. const target = +counter_value.getAttribute('data-target');
  335. const count = +counter_value.innerText;
  336. // Lower inc to slow and higher to slow
  337. var inc = target / speed;
  338. if (inc < 1) {
  339. inc = 1;
  340. }
  341. // Check if target is reached
  342. if (count < target) {
  343. // Add inc to count and output in counter_value
  344. counter_value.innerText = (count + inc).toFixed(0);
  345. // Call function every ms
  346. setTimeout(updateCount, 1);
  347. } else {
  348. counter_value.innerText = target;
  349. }
  350. };
  351. updateCount();
  352. });
  353. } catch (err) {
  354. }
  355. //=========================================//
  356. /*/* 06) Datepicker js*/
  357. //=========================================//
  358. try {
  359. const start = datepicker('.start', { id: 1 })
  360. const end = datepicker('.end', { id: 1 })
  361. } catch (err) {
  362. }
  363. //=========================================//
  364. /*/* 07) Gallery filter js */
  365. //=========================================//
  366. try {
  367. var Shuffle = window.Shuffle;
  368. class Demo {
  369. constructor(element) {
  370. if(element){
  371. this.element = element;
  372. this.shuffle = new Shuffle(element, {
  373. itemSelector: '.picture-item',
  374. sizer: element.querySelector('.my-sizer-element'),
  375. });
  376. // Log events.
  377. this.addShuffleEventListeners();
  378. this._activeFilters = [];
  379. this.addFilterButtons();
  380. }
  381. }
  382. /**
  383. * Shuffle uses the CustomEvent constructor to dispatch events. You can listen
  384. * for them like you normally would (with jQuery for example).
  385. */
  386. addShuffleEventListeners() {
  387. this.shuffle.on(Shuffle.EventType.LAYOUT, (data) => {
  388. console.log('layout. data:', data);
  389. });
  390. this.shuffle.on(Shuffle.EventType.REMOVED, (data) => {
  391. console.log('removed. data:', data);
  392. });
  393. }
  394. addFilterButtons() {
  395. const options = document.querySelector('.filter-options');
  396. if (!options) {
  397. return;
  398. }
  399. const filterButtons = Array.from(options.children);
  400. const onClick = this._handleFilterClick.bind(this);
  401. filterButtons.forEach((button) => {
  402. button.addEventListener('click', onClick, false);
  403. });
  404. }
  405. _handleFilterClick(evt) {
  406. const btn = evt.currentTarget;
  407. const isActive = btn.classList.contains('active');
  408. const btnGroup = btn.getAttribute('data-group');
  409. this._removeActiveClassFromChildren(btn.parentNode);
  410. let filterGroup;
  411. if (isActive) {
  412. btn.classList.remove('active');
  413. filterGroup = Shuffle.ALL_ITEMS;
  414. } else {
  415. btn.classList.add('active');
  416. filterGroup = btnGroup;
  417. }
  418. this.shuffle.filter(filterGroup);
  419. }
  420. _removeActiveClassFromChildren(parent) {
  421. const { children } = parent;
  422. for (let i = children.length - 1; i >= 0; i--) {
  423. children[i].classList.remove('active');
  424. }
  425. }
  426. }
  427. document.addEventListener('DOMContentLoaded', () => {
  428. window.demo = new Demo(document.getElementById('grid'));
  429. });
  430. } catch (err) {
  431. }
  432. //=========================================//
  433. /*/* 08) Tobii lightbox */
  434. //=========================================//
  435. try {
  436. const tobii = new Tobii()
  437. } catch (err) {
  438. }
  439. //=========================================//
  440. /*/* 09) CK Editor */
  441. //=========================================//
  442. try {
  443. ClassicEditor
  444. .create(document.querySelector('#editor'))
  445. .catch(error => {
  446. console.error(error);
  447. });
  448. } catch(err) {
  449. }
  450. //=========================================//
  451. /*/* 10) Fade Animation */
  452. //=========================================//
  453. try {
  454. AOS.init({
  455. easing: 'ease-in-out-sine',
  456. duration: 1000
  457. });
  458. } catch (err) {
  459. }
  460. //=========================================//
  461. /*/* 11) Typed Text animation (animation) */
  462. //=========================================//
  463. try {
  464. var TxtType = function (el, toRotate, period) {
  465. this.toRotate = toRotate;
  466. this.el = el;
  467. this.loopNum = 0;
  468. this.period = parseInt(period, 10) || 2000;
  469. this.txt = '';
  470. this.tick();
  471. this.isDeleting = false;
  472. };
  473. TxtType.prototype.tick = function () {
  474. var i = this.loopNum % this.toRotate.length;
  475. var fullTxt = this.toRotate[i];
  476. if (this.isDeleting) {
  477. this.txt = fullTxt.substring(0, this.txt.length - 1);
  478. } else {
  479. this.txt = fullTxt.substring(0, this.txt.length + 1);
  480. }
  481. this.el.innerHTML = '<span class="wrap">' + this.txt + '</span>';
  482. var that = this;
  483. var delta = 200 - Math.random() * 100;
  484. if (this.isDeleting) { delta /= 2; }
  485. if (!this.isDeleting && this.txt === fullTxt) {
  486. delta = this.period;
  487. this.isDeleting = true;
  488. } else if (this.isDeleting && this.txt === '') {
  489. this.isDeleting = false;
  490. this.loopNum++;
  491. delta = 500;
  492. }
  493. setTimeout(function () {
  494. that.tick();
  495. }, delta);
  496. };
  497. function typewrite() {
  498. if (toRotate === 'undefined') {
  499. changeText()
  500. }
  501. else
  502. var elements = document.getElementsByClassName('typewrite');
  503. for (var i = 0; i < elements.length; i++) {
  504. var toRotate = elements[i].getAttribute('data-type');
  505. var period = elements[i].getAttribute('data-period');
  506. if (toRotate) {
  507. new TxtType(elements[i], JSON.parse(toRotate), period);
  508. }
  509. }
  510. // INJECT CSS
  511. var css = document.createElement("style");
  512. css.type = "text/css";
  513. css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid transparent}";
  514. document.body.appendChild(css);
  515. };
  516. window.onload(typewrite());
  517. } catch(err) {
  518. }
  519. //=========================================//
  520. /*/* 12) Validation Shop Checkouts */
  521. //=========================================//
  522. (function () {
  523. 'use strict'
  524. if(document.getElementsByClassName('needs-validation').length > 0) {
  525. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  526. var forms = document.querySelectorAll('.needs-validation')
  527. // Loop over them and prevent submission
  528. Array.prototype.slice.call(forms)
  529. .forEach(function (form) {
  530. form.addEventListener('submit', function (event) {
  531. if (!form.checkValidity()) {
  532. event.preventDefault()
  533. event.stopPropagation()
  534. }
  535. form.classList.add('was-validated')
  536. }, false)
  537. })
  538. }
  539. })()
  540. //=========================================//
  541. /*/* 13) Switcher Pricing Plans */
  542. //=========================================//
  543. try {
  544. var e = document.getElementById("filt-monthly"),
  545. d = document.getElementById("filt-yearly"),
  546. t = document.getElementById("switcher"),
  547. m = document.getElementById("monthly"),
  548. y = document.getElementById("yearly");
  549. e.addEventListener("click", function(){
  550. t.checked = false;
  551. e.classList.add("toggler--is-active");
  552. d.classList.remove("toggler--is-active");
  553. m.classList.remove("hide");
  554. y.classList.add("hide");
  555. });
  556. d.addEventListener("click", function(){
  557. t.checked = true;
  558. d.classList.add("toggler--is-active");
  559. e.classList.remove("toggler--is-active");
  560. m.classList.add("hide");
  561. y.classList.remove("hide");
  562. });
  563. t.addEventListener("click", function(){
  564. d.classList.toggle("toggler--is-active");
  565. e.classList.toggle("toggler--is-active");
  566. m.classList.toggle("hide");
  567. y.classList.toggle("hide");
  568. })
  569. } catch(err) {
  570. }