custom.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. (function ($) {
  2. "use strict";
  3. // PAGE LOADING
  4. $(window).on("load", function (e) {
  5. $("#global-loader").fadeOut("slow");
  6. })
  7. // FULL SCREEN
  8. $(document).on("click", ".fullscreen-button", function toggleFullScreen() {
  9. $('.fullscreen-button').addClass('fullscreen-button');
  10. if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
  11. if (document.documentElement.requestFullScreen) {
  12. document.documentElement.requestFullScreen();
  13. } else if (document.documentElement.mozRequestFullScreen) {
  14. document.documentElement.mozRequestFullScreen();
  15. } else if (document.documentElement.webkitRequestFullScreen) {
  16. document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  17. } else if (document.documentElement.msRequestFullscreen) {
  18. document.documentElement.msRequestFullscreen();
  19. }
  20. } else {
  21. $('html').removeClass('fullscreen-button');
  22. if (document.cancelFullScreen) {
  23. document.cancelFullScreen();
  24. } else if (document.mozCancelFullScreen) {
  25. document.mozCancelFullScreen();
  26. } else if (document.webkitCancelFullScreen) {
  27. document.webkitCancelFullScreen();
  28. } else if (document.msExitFullscreen) {
  29. document.msExitFullscreen();
  30. }
  31. }
  32. })
  33. // BACK TO TOP BUTTON
  34. $(window).on("scroll", function (e) {
  35. if ($(this).scrollTop() > 0) {
  36. $('#back-to-top').fadeIn('slow');
  37. } else {
  38. $('#back-to-top').fadeOut('slow');
  39. }
  40. });
  41. $(document).on("click", "#back-to-top", function (e) {
  42. $("html, body").animate({
  43. scrollTop: 0
  44. }, 0);
  45. return false;
  46. });
  47. // QUANTITY CART INCREASE AND DECREASE
  48. $('.add').on('click', function () {
  49. var $qty = $(this).closest('div').find('.qty');
  50. var currentVal = parseInt($qty.val());
  51. if (!isNaN(currentVal)) {
  52. $qty.val(currentVal + 1);
  53. }
  54. });
  55. $('.minus').on('click', function () {
  56. var $qty = $(this).closest('div').find('.qty');
  57. var currentVal = parseInt($qty.val());
  58. if (!isNaN(currentVal) && currentVal > 0) {
  59. $qty.val(currentVal - 1);
  60. }
  61. });
  62. // CHART CIRCLE
  63. if ($('.chart-circle').length) {
  64. $('.chart-circle').each(function () {
  65. let $this = $(this);
  66. $this.circleProgress({
  67. fill: {
  68. color: $this.attr('data-bs-color')
  69. },
  70. size: $this.height(),
  71. startAngle: -Math.PI / 4 * 2,
  72. emptyFill: '#edf0f5',
  73. lineCap: 'round'
  74. });
  75. });
  76. }
  77. // MODAL
  78. // SHOWING MODAL WITH EFFECT
  79. $('.modal-effect').on('click', function (e) {
  80. e.preventDefault();
  81. var effect = $(this).attr('data-bs-effect');
  82. $('#modaldemo8').addClass(effect);
  83. });
  84. // HIDE MODAL WITH EFFECT
  85. $('#modaldemo8').on('hidden.bs.modal', function (e) {
  86. $(this).removeClass(function (index, className) {
  87. return (className.match(/(^|\s)effect-\S+/g) || []).join(' ');
  88. });
  89. });
  90. // CARD
  91. const DIV_CARD = 'div.card';
  92. // TOOLTIP
  93. var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
  94. var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  95. return new bootstrap.Tooltip(tooltipTriggerEl)
  96. })
  97. // POPOVER
  98. var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
  99. var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
  100. return new bootstrap.Popover(popoverTriggerEl)
  101. })
  102. // BY DEFAULT, BOOTSTRAP DOESN'T AUTO CLOSE POPOVER AFTER APPEARING IN THE PAGE
  103. $(document).on('click', function (e) {
  104. $('[data-bs-toggle="popover"],[data-original-title]').each(function () {
  105. //the 'is' for buttons that trigger popups
  106. //the 'has' for icons within a button that triggers a popup
  107. if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
  108. (($(this).popover('hide').data('bs.popover') || {}).inState || {}).click = false // fix for BS 3.3.6
  109. }
  110. });
  111. });
  112. // TOAST
  113. var toastElList = [].slice.call(document.querySelectorAll('.toast'))
  114. var toastList = toastElList.map(function (toastEl) {
  115. return new bootstrap.Toast(toastEl)
  116. })
  117. $(document).on("click", '#liveToastBtn', function () {
  118. $('.toast').toast('show');
  119. })
  120. // FUNCTION FOR REMOVE CARD
  121. $(document).on('click', '[data-bs-toggle="card-remove"]', function (e) {
  122. let $card = $(this).closest(DIV_CARD);
  123. $card.remove();
  124. e.preventDefault();
  125. return false;
  126. });
  127. // FUNCTIONS FOR COLLAPSED CARD
  128. $(document).on('click', '[data-bs-toggle="card-collapse"]', function (e) {
  129. let $card = $(this).closest(DIV_CARD);
  130. $card.toggleClass('card-collapsed');
  131. e.preventDefault();
  132. return false;
  133. });
  134. // CARD FULL SCREEN
  135. $(document).on('click', '[data-bs-toggle="card-fullscreen"]', function (e) {
  136. let $card = $(this).closest(DIV_CARD);
  137. $card.toggleClass('card-fullscreen').removeClass('card-collapsed');
  138. e.preventDefault();
  139. return false;
  140. });
  141. // INPUT FILE BROWSER
  142. $(document).on('change', '.file-browserinput', function () {
  143. var input = $(this),
  144. numFiles = input.get(0).files ? input.get(0).files.length : 1,
  145. label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
  146. input.trigger('fileselect', [numFiles, label]);
  147. }); // We can watch for our custom `fileselect` event like this
  148. // FILE UPLOAD
  149. $('.file-browserinput').on('fileselect', function (event, numFiles, label) {
  150. var input = $(this).parents('.input-group').find(':text'),
  151. log = numFiles > 1 ? numFiles + ' files selected' : label;
  152. if (input.length) {
  153. input.val(log);
  154. } else {
  155. if (log) alert(log);
  156. }
  157. });
  158. // ______________ SWITCHER-toggle ______________//
  159. $('.layout-setting').on("click", function (e) {
  160. if (!(document.querySelector('body').classList.contains('dark-mode'))) {
  161. $('body').addClass('dark-mode');
  162. $('body').removeClass('light-mode');
  163. $('body').removeClass('transparent-mode');
  164. $('body')?.removeClass('color-menu');
  165. $('body')?.removeClass('gradient-menu');
  166. $('body')?.removeClass('light-menu');
  167. $('body')?.removeClass('color-header');
  168. $('body')?.removeClass('gradient-header');
  169. $('body')?.removeClass('header-light');
  170. $('#myonoffswitch5').prop('checked', true);
  171. $('#myonoffswitch8').prop('checked', true);
  172. localStorage.setItem('sashdarkMode', true);
  173. localStorage.removeItem('sashlightMode');
  174. localStorage.removeItem('sashtransparentMode');
  175. $('#myonoffswitch2').prop('checked', true);
  176. } else {
  177. $('body').removeClass('dark-mode');
  178. $('body').addClass('light-mode');
  179. $('#myonoffswitch3').prop('checked', true);
  180. $('#myonoffswitch6').prop('checked', true);
  181. localStorage.setItem('sashlightMode', true);
  182. localStorage.removeItem('sashtransparentMode');
  183. localStorage.removeItem('sashdarkMode');
  184. $('#myonoffswitch1').prop('checked', true);
  185. }
  186. });
  187. // ACCORDION STYLE
  188. $(document).on("click", '[data-bs-toggle="collapse"]', function () {
  189. $(this).toggleClass('active').siblings().removeClass('active');
  190. });
  191. // EMAIL INBOX
  192. $(".clickable-row").on('click', function () {
  193. window.location = $(this).data("href");
  194. });
  195. })(jQuery);
  196. // REPLY
  197. function replay() {
  198. "use strict";
  199. let replayButtom = document.querySelectorAll('.reply a')
  200. // Creating Div
  201. let Div = document.createElement('div')
  202. Div.setAttribute('class', "comment mt-5 d-grid")
  203. // creating textarea
  204. let textArea = document.createElement('textarea')
  205. textArea.setAttribute('class', "form-control")
  206. textArea.setAttribute('rows', "5")
  207. textArea.innerText = "Your Comment";
  208. // creating Cancel buttons
  209. let cancelButton = document.createElement('button');
  210. cancelButton.setAttribute('class', "btn btn-danger");
  211. cancelButton.innerText = "Cancel";
  212. let buttonDiv = document.createElement('div')
  213. buttonDiv.setAttribute('class', "btn-list ms-auto mt-2")
  214. // Creating submit button
  215. let submitButton = document.createElement('button');
  216. submitButton.setAttribute('class', "btn btn-success ms-3");
  217. submitButton.innerText = "Submit";
  218. // appending text are to div
  219. Div.append(textArea)
  220. Div.append(buttonDiv);
  221. buttonDiv.append(cancelButton);
  222. buttonDiv.append(submitButton);
  223. replayButtom.forEach((element, index) => {
  224. element.addEventListener('click', () => {
  225. let replay = $(element).parent()
  226. replay.append(Div)
  227. cancelButton.addEventListener('click', () => {
  228. Div.remove()
  229. })
  230. })
  231. })
  232. }
  233. replay()
  234. // OFF-CANVAS STYLE
  235. $('.off-canvas').on('click', function () {
  236. $('body').addClass('overflow-y-scroll');
  237. $('body').addClass('pe-0');
  238. });
  239. // FOOTER
  240. if (!document.querySelector('.login-img')) {
  241. document.getElementById("year").innerHTML = new Date().getFullYear();
  242. }