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.

996 lines
33 KiB

  1. /*
  2. Template Name: Shreyu - Responsive Admin Dashboard
  3. Author: CoderThemes
  4. Website: https://coderthemes.com/
  5. Contact: support@coderthemes.com
  6. File: Layout
  7. */
  8. /**
  9. * LeftSidebar
  10. * @param {*} $
  11. */
  12. !function ($) {
  13. 'use strict';
  14. var LeftSidebar = function () {
  15. this.body = $('body'),
  16. this.window = $(window)
  17. };
  18. /**
  19. * Reset the theme
  20. */
  21. LeftSidebar.prototype._reset = function() {
  22. this.body.removeAttr('data-sidebar-color');
  23. this.body.removeAttr('data-sidebar-size');
  24. this.body.removeAttr('data-sidebar-showuser');
  25. },
  26. /**
  27. * Changes the color of sidebar
  28. * @param {*} color
  29. */
  30. LeftSidebar.prototype.changeColor = function(color) {
  31. this.body.attr('data-sidebar-color', color);
  32. this.parent.updateConfig("sidebar", { "color": color });
  33. },
  34. /**
  35. * Changes the size of sidebar
  36. * @param {*} size
  37. */
  38. LeftSidebar.prototype.changeSize = function(size) {
  39. this.body.attr('data-sidebar-size', size);
  40. this.parent.updateConfig("sidebar", { "size": size });
  41. },
  42. /**
  43. * Toggle User information
  44. * @param {*} showUser
  45. */
  46. LeftSidebar.prototype.showUser = function(showUser) {
  47. this.body.attr('data-sidebar-showuser', showUser);
  48. this.parent.updateConfig("sidebar", { "showuser": showUser });
  49. },
  50. /**
  51. * Initilizes the menu
  52. */
  53. LeftSidebar.prototype.initMenu = function() {
  54. var self = this;
  55. var layout = $.LayoutThemeApp.getConfig();
  56. var sidebar = $.extend({}, layout ? layout.sidebar: {});
  57. var defaultSidebarSize = sidebar.size ? sidebar.size : 'default';
  58. // resets everything
  59. this._reset();
  60. // Left menu collapse
  61. $('.button-menu-mobile').on('click', function (event) {
  62. event.preventDefault();
  63. var sidebarSize = self.body.attr('data-sidebar-size');
  64. if (self.window.width() >= 993) {
  65. if (sidebarSize === 'condensed') {
  66. self.changeSize(defaultSidebarSize !== 'condensed' ? defaultSidebarSize : 'default');
  67. } else {
  68. self.changeSize('condensed');
  69. }
  70. } else {
  71. self.changeSize(defaultSidebarSize);
  72. self.body.toggleClass('sidebar-enable');
  73. }
  74. });
  75. // sidebar - main menu
  76. if ($("#side-menu").length) {
  77. var navCollapse = $('#side-menu li .collapse');
  78. // open one menu at a time only
  79. navCollapse.on({
  80. 'show.bs.collapse': function (event) {
  81. var parent = $(event.target).parents('.collapse.show');
  82. $('#side-menu .collapse.show').not(parent).collapse('hide');
  83. }
  84. });
  85. // activate the menu in left side bar (Vertical Menu) based on url
  86. $("#side-menu a").each(function () {
  87. var pageUrl = window.location.href.split(/[?#]/)[0];
  88. if (this.href == pageUrl) {
  89. $(this).addClass("active");
  90. $(this).parent().addClass("menuitem-active");
  91. $(this).parent().parent().parent().addClass("show");
  92. $(this).parent().parent().parent().parent().addClass("menuitem-active"); // add active to li of the current link
  93. var firstLevelParent = $(this).parent().parent().parent().parent().parent().parent();
  94. if (firstLevelParent.attr('id') !== 'sidebar-menu')
  95. firstLevelParent.addClass("show");
  96. $(this).parent().parent().parent().parent().parent().parent().parent().addClass("menuitem-active");
  97. var secondLevelParent = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent();
  98. if (secondLevelParent.attr('id') !== 'wrapper')
  99. secondLevelParent.addClass("show");
  100. var upperLevelParent = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent();
  101. if (!upperLevelParent.is('body'))
  102. upperLevelParent.addClass("menuitem-active");
  103. }
  104. });
  105. }
  106. // handling two columns menu if present
  107. var twoColSideNav = $("#two-col-sidenav-main");
  108. if (twoColSideNav.length) {
  109. var twoColSideNavItems = $("#two-col-sidenav-main .nav-link");
  110. var sideSubMenus = $(".twocolumn-menu-item");
  111. // showing/displaying tooltip based on screen size
  112. // if (this.window.width() >= 585) {
  113. // twoColSideNavItems.tooltip('enable');
  114. // } else {
  115. // twoColSideNavItems.tooltip('disable');
  116. // }
  117. var nav = $('.twocolumn-menu-item .nav-second-level');
  118. var navCollapse = $('#two-col-menu li .collapse');
  119. // open one menu at a time only
  120. navCollapse.on({
  121. 'show.bs.collapse': function () {
  122. var nearestNav = $(this).closest(nav).closest(nav).find(navCollapse);
  123. if (nearestNav.length)
  124. nearestNav.not($(this)).collapse('hide');
  125. else
  126. navCollapse.not($(this)).collapse('hide');
  127. }
  128. });
  129. twoColSideNavItems.on('click', function (e) {
  130. var target = $($(this).attr('href'));
  131. if (target.length) {
  132. e.preventDefault();
  133. twoColSideNavItems.removeClass('active');
  134. $(this).addClass('active');
  135. sideSubMenus.removeClass("d-block");
  136. target.addClass("d-block");
  137. // showing full sidebar if menu item is clicked
  138. $.LayoutThemeApp.leftSidebar.changeSize('default');
  139. return false;
  140. }
  141. return true;
  142. });
  143. // activate menu with no child
  144. var pageUrl = window.location.href.split(/[?#]/)[0];
  145. twoColSideNavItems.each(function () {
  146. if (this.href == pageUrl) {
  147. $(this).addClass('active');
  148. }
  149. });
  150. // activate the menu in left side bar (Two column) based on url
  151. $("#two-col-menu a").each(function () {
  152. if (this.href == pageUrl) {
  153. $(this).addClass("active");
  154. $(this).parent().addClass("menuitem-active");
  155. $(this).parent().parent().parent().addClass("show");
  156. $(this).parent().parent().parent().parent().addClass("menuitem-active"); // add active to li of the current link
  157. var firstLevelParent = $(this).parent().parent().parent().parent().parent().parent();
  158. if (firstLevelParent.attr('id') !== 'sidebar-menu')
  159. firstLevelParent.addClass("show");
  160. $(this).parent().parent().parent().parent().parent().parent().parent().addClass("menuitem-active");
  161. var secondLevelParent = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent();
  162. if (secondLevelParent.attr('id') !== 'wrapper')
  163. secondLevelParent.addClass("show");
  164. var upperLevelParent = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().parent();
  165. if (!upperLevelParent.is('body'))
  166. upperLevelParent.addClass("menuitem-active");
  167. // opening menu
  168. var matchingItem = null;
  169. var targetEl = '#' + $(this).parents('.twocolumn-menu-item').attr("id");
  170. $("#two-col-sidenav-main .nav-link").each(function () {
  171. if ($(this).attr('href') === targetEl) {
  172. matchingItem = $(this);
  173. }
  174. });
  175. if (matchingItem) matchingItem.trigger('click');
  176. }
  177. });
  178. }
  179. },
  180. /**
  181. * Initilize the left sidebar size based on screen size
  182. */
  183. LeftSidebar.prototype.initLayout = function() {
  184. // in case of small size, activate the small menu
  185. if ((this.window.width() >= 768 && this.window.width() <= 1028) || this.body.data('keep-enlarged')) {
  186. this.changeSize('condensed');
  187. } else {
  188. this.changeSize('default');
  189. }
  190. },
  191. /**
  192. * Initilizes the menu
  193. */
  194. LeftSidebar.prototype.init = function() {
  195. var self = this;
  196. this.initMenu();
  197. this.initLayout();
  198. // on window resize, make menu flipped automatically
  199. this.window.on('resize', function (e) {
  200. e.preventDefault();
  201. self.initLayout();
  202. });
  203. },
  204. $.LeftSidebar = new LeftSidebar, $.LeftSidebar.Constructor = LeftSidebar
  205. }(window.jQuery),
  206. /**
  207. * Topbar
  208. * @param {*} $
  209. */
  210. function ($) {
  211. 'use strict';
  212. var Topbar = function () {
  213. this.body = $('body'),
  214. this.window = $(window)
  215. };
  216. /**
  217. * Initilizes the menu
  218. */
  219. Topbar.prototype.initMenu = function() {
  220. // Serach Toggle
  221. $('#top-search').on('click', function (e) {
  222. $('#search-dropdown').addClass('d-block');
  223. });
  224. // hide search on opening other dropdown
  225. $('.topbar-dropdown').on('show.bs.dropdown', function () {
  226. $('#search-dropdown').removeClass('d-block');
  227. });
  228. //activate the menu in topbar(horizontal menu) based on url
  229. $(".navbar-nav a").each(function () {
  230. var pageUrl = window.location.href.split(/[?#]/)[0];
  231. if (this.href == pageUrl) {
  232. $(this).addClass("active");
  233. $(this).parent().addClass("active");
  234. $(this).parent().parent().addClass("active");
  235. $(this).parent().parent().parent().addClass("active");
  236. $(this).parent().parent().parent().parent().addClass("active");
  237. var el = $(this).parent().parent().parent().parent().addClass("active").prev();
  238. if (el.hasClass("nav-link"))
  239. el.addClass('active');
  240. }
  241. });
  242. // Topbar - main menu
  243. $('.navbar-toggle').on('click', function (event) {
  244. $(this).toggleClass('open');
  245. $('#navigation').slideToggle(400);
  246. });
  247. },
  248. /**
  249. * Changes the color of topbar
  250. * @param {*} color
  251. */
  252. Topbar.prototype.changeColor = function(color) {
  253. this.body.attr('data-topbar-color', color);
  254. this.parent.updateConfig("topbar", { "color": color });
  255. },
  256. /**
  257. * Initilizes the menu
  258. */
  259. Topbar.prototype.init = function() {
  260. this.initMenu();
  261. },
  262. $.Topbar = new Topbar, $.Topbar.Constructor = Topbar
  263. }(window.jQuery),
  264. /**
  265. * RightBar
  266. * @param {*} $
  267. */
  268. function ($) {
  269. 'use strict';
  270. var RightBar = function () {
  271. this.body = $('body'),
  272. this.window = $(window)
  273. };
  274. /**
  275. * Select the option based on saved config
  276. */
  277. RightBar.prototype.selectOptionsFromConfig = function() {
  278. var self = this;
  279. var config = self.layout.getConfig();
  280. if (config) {
  281. $('.right-bar input[type=checkbox]').prop('checked',false);
  282. $('input[type=checkbox][name=color-scheme-mode][value=' + config.mode + ']').prop('checked', true);
  283. $('input[type=checkbox][name=width][value=' + config.width + ']').prop('checked', true);
  284. $('input[type=checkbox][name=menus-position][value=' + config.menuPosition + ']').prop('checked', true);
  285. $('input[type=checkbox][name=leftsidebar-color][value=' + config.sidebar.color + ']').prop('checked', true);
  286. $('input[type=checkbox][name=leftsidebar-size][value=' + config.sidebar.size + ']').prop('checked', true);
  287. $('input[type=checkbox][name=leftsidebar-user]').prop('checked', config.sidebar.showuser);
  288. $('input[type=checkbox][name=topbar-color][value=' + config.topbar.color + ']').prop('checked', true);
  289. }
  290. },
  291. /**
  292. * Toggles the right sidebar
  293. */
  294. RightBar.prototype.toggleRightSideBar = function() {
  295. var self = this;
  296. self.body.toggleClass('right-bar-enabled');
  297. self.selectOptionsFromConfig();
  298. },
  299. /**
  300. * Initilizes the right side bar
  301. */
  302. RightBar.prototype.init = function() {
  303. var self = this;
  304. // right side-bar toggle
  305. $(document).on('click', '.right-bar-toggle', function () {
  306. self.toggleRightSideBar();
  307. });
  308. $(document).on('click', 'body', function (e) {
  309. // hiding search bar
  310. if($(e.target).closest('#top-search').length !== 1) {
  311. $('#search-dropdown').removeClass('d-block');
  312. }
  313. if ($(e.target).closest('.right-bar-toggle, .right-bar').length > 0) {
  314. return;
  315. }
  316. if ($(e.target).closest('.left-side-menu, .side-nav').length > 0 || $(e.target).hasClass('button-menu-mobile')
  317. || $(e.target).closest('.button-menu-mobile').length > 0) {
  318. return;
  319. }
  320. $('body').removeClass('right-bar-enabled');
  321. $('body').removeClass('sidebar-enable');
  322. return;
  323. });
  324. // overall color scheme
  325. $('input[type=checkbox][name=color-scheme-mode]').change(function () {
  326. self.layout.changeMode($(this).val(), true);
  327. });
  328. // width mode
  329. $('input[type=checkbox][name=width]').change(function () {
  330. self.layout.changeLayoutWidth($(this).val());
  331. });
  332. // menus-position
  333. $('input[type=checkbox][name=menus-position]').change(function () {
  334. self.layout.changeMenuPositions($(this).val());
  335. self.selectOptionsFromConfig();
  336. });
  337. // left sidebar color
  338. $('input[type=checkbox][name=leftsidebar-color]').change(function () {
  339. self.layout.leftSidebar.changeColor($(this).val());
  340. self.selectOptionsFromConfig();
  341. });
  342. // left sidebar size
  343. $('input[type=checkbox][name=leftsidebar-size]').change(function () {
  344. self.layout.leftSidebar.changeSize($(this).val());
  345. self.selectOptionsFromConfig();
  346. });
  347. // left sidebar user information
  348. $('input[type=checkbox][name=leftsidebar-user]').change(function (e) {
  349. self.layout.leftSidebar.showUser(e.target.checked);
  350. self.selectOptionsFromConfig();
  351. });
  352. // topbar
  353. $('input[type=checkbox][name=topbar-color]').change(function () {
  354. self.layout.topbar.changeColor($(this).val());
  355. self.selectOptionsFromConfig();
  356. });
  357. // reset
  358. $('#resetBtn').on('click', function (e) {
  359. e.preventDefault();
  360. // reset to default
  361. self.layout.reset();
  362. self.selectOptionsFromConfig();
  363. });
  364. },
  365. $.RightBar = new RightBar, $.RightBar.Constructor = RightBar
  366. }(window.jQuery),
  367. /**
  368. * Layout and theme manager
  369. * @param {*} $
  370. */
  371. function ($) {
  372. 'use strict';
  373. // Layout and theme manager
  374. var LayoutThemeApp = function () {
  375. this.body = $('body'),
  376. this.window = $(window),
  377. this.config = {},
  378. // styles
  379. this.defaultBSStyle = $("#bs-default-stylesheet"),
  380. this.defaultAppStyle = $("#app-default-stylesheet"),
  381. this.darkBSStyle = $("#bs-dark-stylesheet"),
  382. this.darkAppStyle = $("#app-dark-stylesheet");
  383. };
  384. /**
  385. * Preserves the config in memory
  386. */
  387. LayoutThemeApp.prototype._saveConfig = function(newConfig) {
  388. this.config = $.extend(this.config, newConfig);
  389. // NOTE: You can make ajax call here to save preference on server side or localstorage as well
  390. },
  391. /**
  392. * Update the config for given config
  393. * @param {*} param
  394. * @param {*} config
  395. */
  396. LayoutThemeApp.prototype.updateConfig = function(param, config) {
  397. var newObj = {};
  398. if (typeof config === 'object' && config !== null) {
  399. var originalParam = this.config[param];
  400. newObj[param] = $.extend(originalParam, config);
  401. } else {
  402. newObj[param] = config;
  403. }
  404. this._saveConfig(newObj);
  405. }
  406. /**
  407. * Loads the config - takes from body if available else uses default one
  408. */
  409. LayoutThemeApp.prototype.loadConfig = function() {
  410. var bodyConfig = JSON.parse(this.body.attr('data-layout') ? this.body.attr('data-layout') : '{}');
  411. console.log(bodyConfig);
  412. var config = $.extend({}, {
  413. mode: "light",
  414. width: "fluid",
  415. menuPosition: 'fixed',
  416. sidebar: {
  417. color: "light",
  418. size: "default",
  419. showuser: false
  420. },
  421. topbar: {
  422. color: "dark"
  423. },
  424. showRightSidebarOnPageLoad: false
  425. });
  426. if (bodyConfig) {
  427. config = $.extend({}, config, bodyConfig);
  428. };
  429. return config;
  430. },
  431. /**
  432. * Apply the config
  433. */
  434. LayoutThemeApp.prototype.applyConfig = function() {
  435. // getting the saved config if available
  436. this.config = this.loadConfig();
  437. // activate menus
  438. this.leftSidebar.init();
  439. this.topbar.init();
  440. this.leftSidebar.parent = this;
  441. this.topbar.parent = this;
  442. // mode
  443. this.changeMode(this.config.mode);
  444. // width
  445. this.changeLayoutWidth(this.config.width);
  446. // menu position
  447. this.changeMenuPositions(this.config.menuPosition);
  448. // left sidebar
  449. var sidebarConfig = $.extend({}, this.config.sidebar);
  450. this.leftSidebar.changeColor(sidebarConfig.color);
  451. this.leftSidebar.changeSize(sidebarConfig.size);
  452. this.leftSidebar.showUser(sidebarConfig.showuser);
  453. // topbar
  454. var topbarConfig = $.extend({}, this.config.topbar);
  455. this.topbar.changeColor(topbarConfig.color);
  456. },
  457. /**
  458. * Toggle dark or light mode
  459. * @param {*} mode
  460. */
  461. LayoutThemeApp.prototype.changeMode = function(mode, withSidebar = false) {
  462. // sets the theme
  463. switch (mode) {
  464. case "dark": {
  465. this.defaultBSStyle.attr("disabled", true);
  466. this.defaultAppStyle.attr("disabled", true);
  467. this.darkBSStyle.attr("disabled", false);
  468. this.darkAppStyle.attr("disabled", false);
  469. // this.leftSidebar.changeColor("dark");
  470. if(withSidebar){
  471. this.leftSidebar.changeColor("dark");
  472. this._saveConfig({ mode: mode, sidebar: $.extend({}, this.config.sidebar, { color: 'dark' }) });
  473. }else{
  474. this._saveConfig({ mode: mode});
  475. }
  476. break;
  477. }
  478. default: {
  479. this.defaultBSStyle.attr("disabled", false);
  480. this.defaultAppStyle.attr("disabled", false);
  481. this.darkBSStyle.attr("disabled", true);
  482. this.darkAppStyle.attr("disabled", true);
  483. if(withSidebar){
  484. this.leftSidebar.changeColor("light");
  485. this._saveConfig({ mode: mode, sidebar: $.extend({}, this.config.sidebar, { color: 'light' }) });
  486. }else{
  487. this._saveConfig({ mode: mode});
  488. }
  489. break;
  490. }
  491. }
  492. this.rightBar.selectOptionsFromConfig();
  493. }
  494. /**
  495. * Changes the width of layout
  496. */
  497. LayoutThemeApp.prototype.changeLayoutWidth = function(width) {
  498. switch (width) {
  499. case "boxed": {
  500. this.body.attr('data-layout-width', 'boxed');
  501. // automatically activating condensed
  502. $.LeftSidebar.changeSize("condensed");
  503. this._saveConfig({ width: width });
  504. break;
  505. }
  506. default: {
  507. this.body.attr('data-layout-width', 'fluid');
  508. // automatically activating provided size
  509. var bodyConfig = JSON.parse(this.body.attr('data-layout') ? this.body.attr('data-layout') : '{}');
  510. $.LeftSidebar.changeSize(bodyConfig && bodyConfig.sidebar ? bodyConfig.sidebar.size : "default");
  511. this._saveConfig({ width: width });
  512. break;
  513. }
  514. }
  515. this.rightBar.selectOptionsFromConfig();
  516. }
  517. /**
  518. * Changes menu positions
  519. */
  520. LayoutThemeApp.prototype.changeMenuPositions = function(position) {
  521. this.body.attr("data-layout-menu-position", position);
  522. this._saveConfig({ menuPosition: position });
  523. }
  524. /**
  525. * Clear out the saved config
  526. */
  527. LayoutThemeApp.prototype.clearSavedConfig = function() {
  528. this.config = {};
  529. },
  530. /**
  531. * Gets the config
  532. */
  533. LayoutThemeApp.prototype.getConfig = function() {
  534. return this.config;
  535. },
  536. /**
  537. * Reset to default
  538. */
  539. LayoutThemeApp.prototype.reset = function() {
  540. this.clearSavedConfig();
  541. this.applyConfig();
  542. },
  543. /**
  544. * Init
  545. */
  546. LayoutThemeApp.prototype.init = function() {
  547. this.leftSidebar = $.LeftSidebar;
  548. this.topbar = $.Topbar;
  549. this.leftSidebar.parent = this;
  550. this.topbar.parent = this;
  551. // initilize the menu
  552. this.applyConfig();
  553. },
  554. $.LayoutThemeApp = new LayoutThemeApp, $.LayoutThemeApp.Constructor = LayoutThemeApp
  555. }(window.jQuery);
  556. /*
  557. Template Name: Shreyu - Responsive Bootstrap 5 Admin Dashboard
  558. Author: CoderThemes
  559. Website: https://coderthemes.com/
  560. Contact: support@coderthemes.com
  561. File: Main Js File
  562. */
  563. !function ($) {
  564. "use strict";
  565. var Components = function () { };
  566. //initializing tooltip
  567. Components.prototype.initTooltipPlugin = function () {
  568. $.fn.tooltip && $('[data-bs-toggle="tooltip"]').tooltip()
  569. },
  570. //initializing popover
  571. Components.prototype.initPopoverPlugin = function () {
  572. $.fn.popover && $('[data-bs-toggle="popover"]').popover()
  573. },
  574. //initializing toast
  575. Components.prototype.initToastPlugin = function() {
  576. $.fn.toast && $('[data-bs-toggle="toast"]').toast()
  577. },
  578. //initializing form validation
  579. Components.prototype.initFormValidation = function () {
  580. $(".needs-validation").on('submit', function (event) {
  581. $(this).addClass('was-validated');
  582. if ($(this)[0].checkValidity() === false) {
  583. event.preventDefault();
  584. event.stopPropagation();
  585. return false;
  586. }
  587. return true;
  588. });
  589. },
  590. // Counterup
  591. Components.prototype.initCounterUp = function() {
  592. var delay = $(this).attr('data-delay')?$(this).attr('data-delay'):100; //default is 100
  593. var time = $(this).attr('data-time')?$(this).attr('data-time'):1200; //default is 1200
  594. $('[data-plugin="counterup"]').each(function(idx, obj) {
  595. $(this).counterUp({
  596. delay: delay,
  597. time: time
  598. });
  599. });
  600. },
  601. //peity charts
  602. Components.prototype.initPeityCharts = function() {
  603. $('[data-plugin="peity-pie"]').each(function(idx, obj) {
  604. var colors = $(this).attr('data-colors')?$(this).attr('data-colors').split(","):[];
  605. var width = $(this).attr('data-width')?$(this).attr('data-width'):20; //default is 20
  606. var height = $(this).attr('data-height')?$(this).attr('data-height'):20; //default is 20
  607. $(this).peity("pie", {
  608. fill: colors,
  609. width: width,
  610. height: height
  611. });
  612. });
  613. //donut
  614. $('[data-plugin="peity-donut"]').each(function(idx, obj) {
  615. var colors = $(this).attr('data-colors')?$(this).attr('data-colors').split(","):[];
  616. var width = $(this).attr('data-width')?$(this).attr('data-width'):20; //default is 20
  617. var height = $(this).attr('data-height')?$(this).attr('data-height'):20; //default is 20
  618. $(this).peity("donut", {
  619. fill: colors,
  620. width: width,
  621. height: height
  622. });
  623. });
  624. $('[data-plugin="peity-donut-alt"]').each(function(idx, obj) {
  625. $(this).peity("donut");
  626. });
  627. // line
  628. $('[data-plugin="peity-line"]').each(function(idx, obj) {
  629. $(this).peity("line", $(this).data());
  630. });
  631. // bar
  632. $('[data-plugin="peity-bar"]').each(function(idx, obj) {
  633. var colors = $(this).attr('data-colors')?$(this).attr('data-colors').split(","):[];
  634. var width = $(this).attr('data-width')?$(this).attr('data-width'):20; //default is 20
  635. var height = $(this).attr('data-height')?$(this).attr('data-height'):20; //default is 20
  636. $(this).peity("bar", {
  637. fill: colors,
  638. width: width,
  639. height: height
  640. });
  641. });
  642. },
  643. Components.prototype.initKnob = function() {
  644. $('[data-plugin="knob"]').each(function(idx, obj) {
  645. $(this).knob();
  646. });
  647. },
  648. Components.prototype.initTippyTooltips = function () {
  649. if($('[data-plugin="tippy"]').length > 0)
  650. tippy('[data-plugin="tippy"]');
  651. },
  652. Components.prototype.initShowPassword = function () {
  653. $("[data-password]").on('click', function() {
  654. if($(this).attr('data-password') == "false"){
  655. $(this).siblings("input").attr("type", "text");
  656. $(this).attr('data-password', 'true');
  657. $(this).addClass("show-password");
  658. } else {
  659. $(this).siblings("input").attr("type", "password");
  660. $(this).attr('data-password', 'false');
  661. $(this).removeClass("show-password");
  662. }
  663. });
  664. },
  665. Components.prototype.initMultiDropdown = function () {
  666. $('.dropdown-menu a.dropdown-toggle').on('click', function(e) {
  667. if (!$(this).next().hasClass('show')) {
  668. $(this).parents('.dropdown-menu').first().find('.show').removeClass("show");
  669. }
  670. var $subMenu = $(this).next(".dropdown-menu");
  671. $subMenu.toggleClass('show');
  672. return false;
  673. });
  674. },
  675. //initilizing
  676. Components.prototype.init = function () {
  677. this.initTooltipPlugin(),
  678. this.initPopoverPlugin(),
  679. this.initToastPlugin(),
  680. this.initFormValidation(),
  681. this.initCounterUp(),
  682. this.initPeityCharts(),
  683. this.initKnob();
  684. this.initTippyTooltips();
  685. this.initShowPassword();
  686. this.initMultiDropdown();
  687. },
  688. $.Components = new Components, $.Components.Constructor = Components
  689. }(window.jQuery),
  690. function($) {
  691. "use strict";
  692. /**
  693. Portlet Widget
  694. */
  695. var Portlet = function() {
  696. this.$body = $("body"),
  697. this.$portletIdentifier = ".card",
  698. this.$portletCloser = '.card a[data-toggle="remove"]',
  699. this.$portletRefresher = '.card a[data-toggle="reload"]'
  700. };
  701. //on init
  702. Portlet.prototype.init = function() {
  703. // Panel closest
  704. var $this = this;
  705. $(document).on("click",this.$portletCloser, function (ev) {
  706. ev.preventDefault();
  707. var $portlet = $(this).closest($this.$portletIdentifier);
  708. var $portlet_parent = $portlet.parent();
  709. $portlet.remove();
  710. if ($portlet_parent.children().length == 0) {
  711. $portlet_parent.remove();
  712. }
  713. });
  714. // Panel Reload
  715. $(document).on("click",this.$portletRefresher, function (ev) {
  716. ev.preventDefault();
  717. var $portlet = $(this).closest($this.$portletIdentifier);
  718. // This is just a simulation, nothing is going to be reloaded
  719. $portlet.append('<div class="card-disabled"><div class="card-portlets-loader"></div></div>');
  720. var $pd = $portlet.find('.card-disabled');
  721. setTimeout(function () {
  722. $pd.fadeOut('fast', function () {
  723. $pd.remove();
  724. });
  725. }, 500 + 300 * (Math.random() * 5));
  726. });
  727. },
  728. //
  729. $.Portlet = new Portlet, $.Portlet.Constructor = Portlet
  730. }(window.jQuery),
  731. function ($) {
  732. 'use strict';
  733. var App = function () {
  734. this.$body = $('body'),
  735. this.$window = $(window)
  736. };
  737. /**
  738. * Initlizes the controls
  739. */
  740. App.prototype.initControls = function () {
  741. // remove loading
  742. setTimeout(function() {
  743. document.body.classList.remove('loading');
  744. }, 400);
  745. // Preloader
  746. $(window).on('load', function () {
  747. $('#status').fadeOut();
  748. $('#preloader').delay(350).fadeOut('slow');
  749. });
  750. $('[data-toggle="fullscreen"]').on("click", function (e) {
  751. e.preventDefault();
  752. $('body').toggleClass('fullscreen-enable');
  753. if (!document.fullscreenElement && /* alternative standard method */ !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
  754. if (document.documentElement.requestFullscreen) {
  755. document.documentElement.requestFullscreen();
  756. } else if (document.documentElement.mozRequestFullScreen) {
  757. document.documentElement.mozRequestFullScreen();
  758. } else if (document.documentElement.webkitRequestFullscreen) {
  759. document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  760. }
  761. } else {
  762. if (document.cancelFullScreen) {
  763. document.cancelFullScreen();
  764. } else if (document.mozCancelFullScreen) {
  765. document.mozCancelFullScreen();
  766. } else if (document.webkitCancelFullScreen) {
  767. document.webkitCancelFullScreen();
  768. }
  769. }
  770. });
  771. document.addEventListener('fullscreenchange', exitHandler );
  772. document.addEventListener("webkitfullscreenchange", exitHandler);
  773. document.addEventListener("mozfullscreenchange", exitHandler);
  774. function exitHandler() {
  775. if (!document.webkitIsFullScreen && !document.mozFullScreen && !document.msFullscreenElement) {
  776. console.log('pressed');
  777. $('body').removeClass('fullscreen-enable');
  778. }
  779. }
  780. },
  781. //initilizing
  782. App.prototype.init = function () {
  783. $.Portlet.init();
  784. $.Components.init();
  785. this.initControls();
  786. // init layout
  787. this.layout = $.LayoutThemeApp;
  788. this.rightBar = $.RightBar;
  789. this.rightBar.layout = this.layout;
  790. this.layout.rightBar = this.rightBar;
  791. this.layout.init();
  792. this.rightBar.init(this.layout);
  793. // showing the sidebar on load if user is visiting the page first time only
  794. var bodyConfig = this.$body.data('layout');
  795. if (window.sessionStorage && bodyConfig && bodyConfig.hasOwnProperty('showRightSidebarOnPageLoad') && bodyConfig['showRightSidebarOnPageLoad']) {
  796. var alreadyVisited = sessionStorage.getItem("_UBOLD_VISITED_");
  797. if (!alreadyVisited) {
  798. $.RightBar.toggleRightSideBar();
  799. sessionStorage.setItem("_UBOLD_VISITED_", true);
  800. }
  801. }
  802. // toast
  803. var toastElList = [].slice.call(document.querySelectorAll('.toast'))
  804. var toastList = toastElList.map(function (toastEl) {
  805. return new bootstrap.Toast(toastEl)
  806. })
  807. // popover
  808. var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
  809. var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
  810. return new bootstrap.Popover(popoverTriggerEl)
  811. })
  812. // tooltip
  813. var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
  814. var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  815. return new bootstrap.Tooltip(tooltipTriggerEl)
  816. })
  817. // RTL support js
  818. if(document.getElementById('app-default-stylesheet').href.includes('rtl.min.css')){
  819. document.getElementsByTagName('html')[0].dir="rtl";
  820. }
  821. if(document.getElementById('app-dark-stylesheet').href.includes('rtl.min.css')){
  822. document.getElementsByTagName('html')[0].dir="rtl";
  823. }
  824. },
  825. $.App = new App, $.App.Constructor = App
  826. }(window.jQuery),
  827. //initializing main application module
  828. function ($) {
  829. "use strict";
  830. $.App.init();
  831. }(window.jQuery);
  832. // Feather Icons
  833. feather.replace()
  834. //# sourceMappingURL=app.min.js.map