source: resources/assets/js/custom.js@ c6b84df

develop
Last change on this file since c6b84df was c6b84df, checked in by beratkjufliju <kufliju@…>, 3 years ago

added fileTypes controller, notifications, excel export, edited views

  • Property mode set to 100644
File size: 8.6 KB
Line 
1'use strict';
2
3(function ($) {
4
5 $(document).on('click', '.layout-builder .layout-builder-toggle', function () {
6 $('.layout-builder').toggleClass('show');
7 });
8
9 $(".edit_folder_deparment").change(function() {
10 var archId = $("input[name='arch_id']");
11 var currentText = archId.val().split("/")[1];
12 var selectedId = $(this).find('option:selected').data('dept-code');
13
14 if(currentText)
15 archId.val(selectedId + "/" + currentText);
16 else
17 archId.val(selectedId + "/");
18 });
19
20 $(".new_folder_deparment").change(function() {
21 var archId = $("input[name='arch_id']");
22 var selectedId = $(this).find('option:selected').data('dept-code');
23
24 archId.val(selectedId + "/");
25 });
26
27 $(window).on('load', function () {
28 setTimeout(function () {
29 $('.layout-builder').removeClass('show');
30 }, 500);
31 });
32
33 $('.body').append(`
34 <div class="layout-builder show">
35 <div class="layout-builder-toggle shw">
36 <i class="ti-settings"></i>
37 </div>
38 <div class="layout-builder-toggle hdn">
39 <i class="ti-close"></i>
40 </div>
41 <div class="layout-builder-body">
42 <h5>Customizer</h5>
43 <div class="mb-3">
44 <p>Layout</p>
45 <div class="custom-control custom-radio">
46 <input type="radio" class="custom-control-input" name="layout" id="horizontal-side-menu" data-layout="horizontal-side-menu">
47 <label class="custom-control-label" for="horizontal-side-menu">Horizontal Menu</label>
48 </div>
49 <div class="custom-control custom-radio">
50 <input type="radio" class="custom-control-input" name="layout" id="icon-side-menu" data-layout="icon-side-menu">
51 <label class="custom-control-label" for="icon-side-menu">Icon Menu</label>
52 </div>
53 <div class="custom-control custom-radio">
54 <input type="radio" class="custom-control-input" name="layout" id="hidden-side-menu" data-layout="hidden-side-menu">
55 <label class="custom-control-label" for="hidden-side-menu">Hidden Menu</label>
56 </div>
57 <div class="custom-control custom-radio">
58 <input type="radio" class="custom-control-input" name="layout" id="layout-container-1" data-layout="layout-container icon-side-menu">
59 <label class="custom-control-label" for="layout-container-1">Container Layout 1</label>
60 </div>
61 <div class="custom-control custom-radio">
62 <input type="radio" class="custom-control-input" name="layout" id="layout-container-2" data-layout="layout-container horizontal-side-menu">
63 <label class="custom-control-label" for="layout-container-2">Container Layout 2</label>
64 </div>
65 <div class="custom-control custom-radio">
66 <input type="radio" class="custom-control-input" name="layout" id="layout-container-3" data-layout="layout-container hidden-side-menu">
67 <label class="custom-control-label" for="layout-container-3">Container Layout 3</label>
68 </div>
69 <div class="custom-control custom-radio">
70 <input type="radio" class="custom-control-input" name="layout" id="dark-1" data-layout="dark">
71 <label class="custom-control-label" for="dark-1">Dark Layout 1</label>
72 </div>
73 <div class="custom-control custom-radio">
74 <input type="radio" class="custom-control-input" name="layout" id="dark-2" data-layout="layout-container dark icon-side-menu">
75 <label class="custom-control-label" for="dark-2">Dark Layout 2</label>
76 </div>
77 <div class="custom-control custom-radio">
78 <input type="radio" class="custom-control-input" name="layout" id="dark-3" data-layout="layout-container dark horizontal-side-menu">
79 <label class="custom-control-label" for="dark-3">Dark Layout 3</label>
80 </div>
81 <div class="custom-control custom-radio">
82 <input type="radio" class="custom-control-input" name="layout" id="dark-4" data-layout="layout-container dark hidden-side-menu">
83 <label class="custom-control-label" for="dark-4">Dark Layout 4</label>
84 </div>
85 </div>
86 <button id="btn-layout-builder-reset" class="btn btn-danger btn-uppercase">Reset</button>
87 <div class="layout-alert mt-3">
88 <i class="fa fa-warning m-r-5 text-warning"></i>Some theme options can not be displayed in case of combined when they are not relevant each other. For that reason, you are adviced to try all theme options seperately.
89 </div>
90 </div>
91 </div>`);
92
93 var site_layout = localStorage.getItem('site_layout');
94 $('body').addClass(site_layout);
95
96 $('.layout-builder .layout-builder-body input[type="radio"][data-layout="' + $('body').attr('class') + '"]').prop('checked', true);
97
98 $('.layout-builder .layout-builder-body input[type="radio"]').click(function () {
99 var class_names = '';
100
101 $('.layout-builder .layout-builder-body input[type="radio"]:checked').each(function () {
102 class_names += ' ' + $(this).data('layout');
103 });
104
105 localStorage.setItem('site_layout', class_names);
106
107 window.location.href = (window.location.href).replace('#', '');
108 });
109
110 function notifications() {
111
112 var url = "/dashboard/get-notifications";
113 var _token = $("meta[name='csrf-token']").attr("content");
114
115 $.ajax({
116 url: url,
117 type: "post",
118 dataType: "json",
119 data: {
120 _token : _token,
121 },
122 success: function(response) {
123
124 $(".dropdown-notifications a:not(:last)").remove();
125 $(".dropdown-notifications-unread .nav-unread").hide();
126
127 var l = response.length;
128
129 if(hasNew(response)) {
130 $(".dropdown-notifications .unreadNotificationsInfo").hide();
131 $(".dropdown-notifications-unread .nav-unread").show();
132 }
133
134 if(l == 0) {
135 $(".dropdown-notifications .unreadNotificationsInfo").show();
136 }
137
138 if(l > 0) {
139 $(".dropdown-notifications .unreadNotificationsInfo").hide();
140 }
141
142 for(var i=0; i<l; i++) {
143
144 var style = response[i].isRead ? "" : "background: #efefef; color: black;";
145
146 var notificationItem = `
147 <a href="` + response[i].url + `" class="dropdown-item d-flex" style="` + style + `;">
148 <div>
149 ` + response[i].message + `
150 <div class="small text-muted">` + response[i].ago + `</div>
151 </div>
152 </a>`;
153
154 $(".dropdown-notifications").prepend(notificationItem);
155 }
156 },
157 error: function(response) {
158 console.log(response);
159 }
160 });
161 }
162
163 $(document).on('click', '#btn-layout-builder', function () {
164
165 });
166
167 $(document).on('click', '#btn-layout-builder-reset', function () {
168 localStorage.removeItem('site_layout');
169 localStorage.removeItem('site_layout_dark');
170
171 window.location.href = (window.location.href).replace('#', '');
172 });
173
174 $(window).on('load', function () {
175 if ($('body').hasClass('horizontal-side-menu') && $(window).width() > 768) {
176 if ($('body').hasClass('layout-container')) {
177 $('.side-menu .side-menu-body').wrap('<div class="container"></div>');
178 } else {
179 $('.side-menu .side-menu-body').wrap('<div class="container"></div>');
180 }
181 setTimeout(function () {
182 $('.side-menu .side-menu-body > ul').append('<li><a href="#"><span>Other</span></a><ul></ul></li>');
183 }, 100);
184 $('.side-menu .side-menu-body > ul > li').each(function () {
185 var index = $(this).index(),
186 $this = $(this);
187 if (index > 7) {
188 setTimeout(function () {
189 $('.side-menu .side-menu-body > ul > li:last-child > ul').append($this.clone());
190 $this.addClass('d-none');
191 }, 100);
192 }
193 });
194 }
195 });
196
197 $(document).on('click', '[data-attr="layout-builder-toggle"]', function () {
198 $('.layout-builder').toggleClass('show');
199 return false;
200 });
201
202})(jQuery);
Note: See TracBrowser for help on using the repository browser.