isite 2024.6.9 → 2024.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1387 -1387
  3. package/apps/charts/site_files/html/PieChart.html +35 -35
  4. package/apps/charts/site_files/html/PieChart2.html +35 -35
  5. package/apps/charts/site_files/html/XYChart.html +42 -42
  6. package/apps/charts/site_files/html/column.html +60 -60
  7. package/apps/charts/site_files/html/gauge.html +44 -44
  8. package/apps/charts/site_files/html/index.html +92 -92
  9. package/apps/charts/site_files/html/line-graph.html +42 -42
  10. package/apps/charts/site_files/html/pie-chart-rounded-corners.html +38 -38
  11. package/apps/charts/site_files/html/simple-3D-pie-chart.html +43 -43
  12. package/apps/charts/site_files/js/chart-animated.js +2 -2
  13. package/apps/charts/site_files/json/PieChart.json +41 -41
  14. package/apps/charts/site_files/json/PieChart2.json +23 -23
  15. package/apps/charts/site_files/json/XYChart.json +74 -74
  16. package/apps/charts/site_files/json/bar-chart.json +99 -99
  17. package/apps/charts/site_files/json/column-chart.json +80 -80
  18. package/apps/charts/site_files/json/gauge.json +36 -36
  19. package/apps/charts/site_files/json/line-graph.json +1867 -1867
  20. package/apps/charts/site_files/json/pie-chart-rounded-corners.json +42 -42
  21. package/apps/charts/site_files/json/simple-3D-pie-chart.json +50 -50
  22. package/apps/client-side/package-lock.json +5 -5
  23. package/apps/client-side/package.json +21 -21
  24. package/apps/client-side/site_files/css/bootstrap3.css +5 -5
  25. package/apps/client-side/site_files/css/bootstrap4.css +6 -6
  26. package/apps/client-side/site_files/css/bootstrap5-addon.css +2 -2
  27. package/apps/client-side/site_files/css/bootstrap5.css +6 -6
  28. package/apps/client-side/site_files/css/checkbox.css +125 -125
  29. package/apps/client-side/site_files/css/font-awesome.css +4616 -4616
  30. package/apps/client-side/site_files/css/font-awesome.min.css +4 -4
  31. package/apps/client-side/site_files/css/fonts.css +85 -85
  32. package/apps/client-side/site_files/css/help.css +51 -51
  33. package/apps/client-side/site_files/css/images.css +4 -3
  34. package/apps/client-side/site_files/css/main-menu.css +66 -66
  35. package/apps/client-side/site_files/css/print.css +144 -144
  36. package/apps/client-side/site_files/css/prism.css +139 -139
  37. package/apps/client-side/site_files/css/progress.css +7 -7
  38. package/apps/client-side/site_files/css/radio.css +103 -103
  39. package/apps/client-side/site_files/css/scrollbar.css +13 -13
  40. package/apps/client-side/site_files/css/semantic.css +363 -363
  41. package/apps/client-side/site_files/css/table.css +87 -87
  42. package/apps/client-side/site_files/css/treeview.css +84 -84
  43. package/apps/client-side/site_files/css/ui.css +28 -28
  44. package/apps/client-side/site_files/fonts/fontawesome-webfont.svg +2671 -2671
  45. package/apps/client-side/site_files/fonts/glyphicons-halflings-regular.svg +287 -287
  46. package/apps/client-side/site_files/fonts/icons.svg +684 -684
  47. package/apps/client-side/site_files/js/angular-animate.js +4179 -4179
  48. package/apps/client-side/site_files/js/angular.js +36599 -36599
  49. package/apps/client-side/site_files/js/angular.min.js +351 -351
  50. package/apps/client-side/site_files/js/angular.min.js.map +8 -8
  51. package/apps/client-side/site_files/js/barcode.js +1 -1
  52. package/apps/client-side/site_files/js/base64.js +319 -319
  53. package/apps/client-side/site_files/js/bootstrap-5-directive.js +1456 -1456
  54. package/apps/client-side/site_files/js/bootstrap3.js +6 -6
  55. package/apps/client-side/site_files/js/bootstrap4.js +6 -6
  56. package/apps/client-side/site_files/js/bootstrap5.js +6 -6
  57. package/apps/client-side/site_files/js/custom.js +149 -149
  58. package/apps/client-side/site_files/js/directive.min.js +1 -1
  59. package/apps/client-side/site_files/js/hijri.js +965 -965
  60. package/apps/client-side/site_files/js/jquery.js +2 -2
  61. package/apps/client-side/site_files/js/moment.js +4511 -4511
  62. package/apps/client-side/site_files/js/prism.js +6 -6
  63. package/apps/client-side/site_files/js/qrcode.js +1398 -1398
  64. package/apps/client-side/site_files/js/semantic.js +10 -10
  65. package/apps/client-side/site_files/js/xlsx.js +23 -23
  66. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/brand-icons.svg +1008 -1008
  67. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/icons.svg +1518 -1518
  68. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/outline-icons.svg +366 -366
  69. package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -3717
  70. package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -801
  71. package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -5034
  72. package/apps/security/README.md +12 -12
  73. package/apps/security/app.js +288 -288
  74. package/apps/security/libs/notifications.js +89 -89
  75. package/apps/security/site_files/html/add_modal.html +36 -36
  76. package/apps/security/site_files/html/content.html +36 -36
  77. package/apps/security/site_files/html/delete_modal.html +31 -31
  78. package/apps/security/site_files/html/head.html +7 -7
  79. package/apps/security/site_files/html/index.html +80 -80
  80. package/apps/security/site_files/html/login_modal.html +24 -24
  81. package/apps/security/site_files/html/logout_modal.html +21 -21
  82. package/apps/security/site_files/html/navbar.html +8 -8
  83. package/apps/security/site_files/html/register_modal.html +32 -32
  84. package/apps/security/site_files/html/update_modal.html +28 -28
  85. package/apps/security/site_files/html/view.html +74 -74
  86. package/apps/security/site_files/html/view_modal.html +32 -32
  87. package/apps/security/site_files/js/app.js +1 -1
  88. package/apps/security/site_files/js/index.js +278 -278
  89. package/apps/security/site_files/js/login.js +35 -35
  90. package/apps/security/site_files/js/logout.js +22 -22
  91. package/apps/security/site_files/js/navbar.js +26 -26
  92. package/apps/security/site_files/js/register.js +30 -30
  93. package/apps/security/site_files/json/permissions.json +7 -7
  94. package/apps/security/site_files/json/roles.json +33 -33
  95. package/apps/security/site_files/json/words.json +28 -28
  96. package/gulpfile.js +17 -17
  97. package/index.js +1 -0
  98. package/isite.postman_collection.json +7 -7
  99. package/isite_files/css/bootstrap.css +5 -5
  100. package/isite_files/css/font-awesome.css +4 -4
  101. package/isite_files/css/prism.css +139 -139
  102. package/isite_files/fonts/fontawesome-webfont.svg +2671 -2671
  103. package/isite_files/fonts/glyphicons-halflings-regular.svg +287 -287
  104. package/isite_files/html/files.html +9 -9
  105. package/isite_files/html/head.html +12 -12
  106. package/isite_files/html/index.html +30 -30
  107. package/isite_files/html/installing.html +27 -27
  108. package/isite_files/html/navbar.html +51 -51
  109. package/isite_files/html/routes.html +13 -13
  110. package/isite_files/html/sessions.html +13 -13
  111. package/isite_files/html/vars.html +9 -9
  112. package/isite_files/js/angular.js +334 -334
  113. package/isite_files/js/bootstrap.js +6 -6
  114. package/isite_files/js/custom.js +149 -149
  115. package/isite_files/js/jquery.js +4 -4
  116. package/isite_files/js/prism.js +6 -6
  117. package/lib/README.md +1 -1
  118. package/lib/cookie.js +81 -81
  119. package/lib/dashboard.js +189 -189
  120. package/lib/mongodb.js +686 -686
  121. package/lib/parser.js +910 -910
  122. package/lib/session.js +158 -158
  123. package/lib/storage.js +6 -0
  124. package/lib/ws.js +4 -26
  125. package/object-options/lib/isite.code-workspace +10 -10
  126. package/object-options/lib/safty.js +13 -16
  127. package/package.json +55 -54
  128. package/ssl/create_ssl.sh +3 -3
@@ -1,1456 +1,1456 @@
1
- app.directive('iControl', function () {
2
- return {
3
- restrict: 'E',
4
- require: 'ngModel',
5
- scope: {
6
- v: '@',
7
- id2: '@',
8
- label: '@',
9
- type: '@',
10
- class2: '@',
11
- disabled: '@',
12
- ngModel: '=',
13
- ngChange: '&',
14
- ngKeydown: '&',
15
- },
16
- link: function ($scope, element, attrs, ctrl) {
17
- attrs.type = attrs.type || 'text';
18
- $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
19
- $scope.v = $scope.v || '';
20
- $scope.requird = '';
21
- if ($scope.v.like('*r*')) {
22
- $scope.requird = '*';
23
- }
24
- if (typeof attrs.disabled !== 'undefined') {
25
- attrs.disabled = 'disabled';
26
- } else {
27
- attrs.disabled = '';
28
- }
29
- $scope.class2 = $scope.class2 || '';
30
- $(element)
31
- .find('input')
32
- .focus(() => {
33
- $('.i-list .dropdown-content').css('display', 'none');
34
- });
35
- },
36
- template: `/*##client-side/directive/i-control.html*/`,
37
- };
38
- });
39
-
40
- app.directive('iTextarea', function () {
41
- return {
42
- restrict: 'E',
43
- require: 'ngModel',
44
- scope: {
45
- v: '@',
46
- label: '@',
47
- id2: '@',
48
- disabled: '@',
49
- rows: '@',
50
- ngModel: '=',
51
- ngChange: '&',
52
- },
53
- link: function ($scope, element, attrs, ctrl) {
54
- if (typeof attrs.disabled !== 'undefined') {
55
- attrs.disabled = 'disabled';
56
- } else {
57
- attrs.disabled = '';
58
- }
59
- $scope.rows = $scope.rows || 10;
60
- $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
61
- $(element)
62
- .find('textarea')
63
- .focus(() => {
64
- $('.popup').hide();
65
- });
66
- },
67
- template: `/*##client-side/directive/i-textarea.html*/`,
68
- };
69
- });
70
- app.directive('iContent', function ($timeout, $interval) {
71
- return {
72
- restrict: 'E',
73
- scope: {
74
- v: '@',
75
- label: '@',
76
- id2: '@',
77
- disabled: '@',
78
- rows: '@',
79
- ngModel: '=',
80
- ngChange: '&',
81
- },
82
- link: function ($scope, element, attrs, ctrl) {
83
- if (typeof attrs.disabled !== 'undefined') {
84
- attrs.disabled = 'disabled';
85
- } else {
86
- attrs.disabled = '';
87
- }
88
- $scope.stopReading = false;
89
- $scope.rows = $scope.rows || 10;
90
- $scope.id2 = $scope.id2 || 'textarea_' + Math.random().toString().replace('0.', '');
91
- $(element).find('textarea').id = $scope.id2;
92
- $(element)
93
- .find('textarea')
94
- .focus(() => {
95
- $('.popup').hide();
96
- });
97
- $scope.handelContentElement = function () {
98
- if (!document.querySelector('#' + $scope.id2)) {
99
- $timeout(() => {
100
- $scope.handelContentElement();
101
- }, 1000);
102
- return false;
103
- }
104
- window['content_' + $scope.id2] = WebShareEditor.create($scope.id2, {
105
- toolbarItem: [
106
- ['undo', 'redo'],
107
- ['font', 'fontSize', 'formatBlock'],
108
- ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
109
- ['removeFormat'],
110
- ['fontColor', 'hiliteColor'],
111
- ['outdent', 'indent'],
112
- ['align', 'horizontalRule', 'list', 'table'],
113
- ['link', 'image', 'video'],
114
- ['preview', 'print'],
115
- /* ['fullScreen', 'showBlocks', 'codeView'],
116
- ['save', 'template'],*/
117
- ],
118
- width: '100%',
119
- minHeight: '300px',
120
- });
121
- if ($scope.ngModel && window['content_' + $scope.id2]) {
122
- window['content_' + $scope.id2].setContents($scope.ngModel);
123
- }
124
- $scope.readingNow();
125
- };
126
-
127
- $scope.readingNow = function () {
128
- $scope.intravalReading = $interval(() => {
129
- if (window['content_' + $scope.id2]) {
130
- $scope.ngModel2 = window['content_' + $scope.id2].getContents();
131
- if ($scope.ngModel !== $scope.ngModel2) {
132
- $scope.ngModel = $scope.ngModel2;
133
- $scope.changed();
134
- }
135
- }
136
- }, 1000);
137
- };
138
- $scope.handelContentElement();
139
-
140
- $scope.changed = function () {
141
- $timeout(() => {
142
- if ($scope.ngChange) {
143
- $scope.ngChange();
144
- }
145
- }, 100);
146
- };
147
-
148
- $scope.$watch('ngModel', (ngModel) => {
149
- clearInterval($scope.intravalReading);
150
-
151
- if (ngModel && window['content_' + $scope.id2]) {
152
- if ($scope.ngModel2 && $scope.ngModel !== $scope.ngModel2) {
153
- $scope.ngModel = ngModel;
154
- window['content_' + $scope.id2].setContents($scope.ngModel);
155
- }
156
- }
157
- $scope.readingNow();
158
- });
159
- },
160
- template: `/*##client-side/directive/i-content.html*/`,
161
- };
162
- });
163
-
164
- app.directive('iCheckbox', function ($timeout) {
165
- return {
166
- restrict: 'E',
167
- require: 'ngModel',
168
- scope: {
169
- label: '@',
170
- id2: '@',
171
- ngDisabled: '@',
172
- ngModel: '=',
173
- ngChange: '&',
174
- },
175
- link: function ($scope, element, attrs, ctrl) {
176
- $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
177
- $scope.changed = function () {
178
- $timeout(() => {
179
- if ($scope.ngChange) {
180
- $scope.ngChange();
181
- }
182
- }, 100);
183
- };
184
- },
185
- template: `/*##client-side/directive/i-checkbox.html*/`,
186
- };
187
- });
188
-
189
- app.directive('iRadio', function () {
190
- return {
191
- restrict: 'E',
192
- require: 'ngModel',
193
- scope: {
194
- label: '@',
195
- group: '@',
196
- id2: '@',
197
- ngValue: '@',
198
- ngModel: '=',
199
- ngChange: '&',
200
- },
201
- link: function ($scope, element, attrs, ctrl) {
202
- if (typeof attrs.disabled !== 'undefined') {
203
- attrs.disabled = 'disabled';
204
- } else {
205
- attrs.disabled = '';
206
- }
207
-
208
- $scope.group = $scope.group || attrs.ngModel.replaceAll('.', '_');
209
- $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
210
- },
211
- template: `/*##client-side/directive/i-radio.html*/`,
212
- };
213
- });
214
-
215
- app.directive('iButton', [
216
- '$interval',
217
- '$timeout',
218
- function ($interval, $timeout) {
219
- return {
220
- restrict: 'E',
221
- scope: {
222
- label: '@',
223
- type: '@',
224
- class2: '@',
225
- loading: '@',
226
- click: '&',
227
- fa: '@',
228
- },
229
- link: function ($scope, element, attrs, ctrl) {
230
- $scope.type = $scope.type || '';
231
- $scope.class = $scope.class = 'btn-light';
232
- $scope.fa = $scope.fa || $scope.label ? '' : 'fas fa-mouse-pointer';
233
-
234
- if ($scope.type.like('*add*|*new*')) {
235
- $scope.fa = 'fas fa-plus';
236
- $scope.class = 'btn-primary';
237
- } else if ($scope.type.like('*update*|*edit*')) {
238
- $scope.fa = 'fas fa-edit';
239
- $scope.class = 'btn-warning';
240
- } else if ($scope.type.like('*save*')) {
241
- $scope.fa = 'fas fa-save';
242
- $scope.class = 'btn-success';
243
- } else if ($scope.type.like('*list*')) {
244
- $scope.fa = 'fas fa-list';
245
- $scope.class = 'btn-info';
246
- } else if ($scope.type.like('unapprove')) {
247
- $scope.fa = 'fas fa-eject';
248
- $scope.class = 'btn-danger';
249
- } else if ($scope.type.like('approve')) {
250
- $scope.fa = 'fas fa-check-double';
251
- $scope.class = 'btn-primary';
252
- } else if ($scope.type.like('*view*|*details*|*show*')) {
253
- $scope.fa = 'fas fa-eye';
254
- $scope.class = 'btn-info';
255
- } else if ($scope.type.like('*delete*|*remove*|*clear*')) {
256
- $scope.fa = 'fas fa-trash';
257
- $scope.class = 'btn-danger';
258
- } else if ($scope.type.like('*exit*|*close*')) {
259
- $scope.fa = 'fas fa-times-circle';
260
- $scope.class = 'btn-danger';
261
- } else if ($scope.type.like('*print*')) {
262
- $scope.fa = 'fas fa-print';
263
- $scope.class = 'btn-secondary';
264
- } else if ($scope.type.like('*export*|*excel*')) {
265
- $scope.fa = 'fas fa-file-export';
266
- $scope.class = 'btn-light';
267
- } else if ($scope.type.like('*import*')) {
268
- $scope.fa = 'fas fa-file-upload';
269
- $scope.class = 'btn-light';
270
- } else if ($scope.type.like('*search*|*find*')) {
271
- $scope.fa = 'fas fa-search';
272
- $scope.class = 'btn-light';
273
- } else if ($scope.type.like('*login*|*signin*')) {
274
- $scope.fa = 'fas fa-sign-in-alt';
275
- $scope.class = 'btn-light';
276
- } else if ($scope.type.like('*logout*|*signout*')) {
277
- $scope.fa = 'fas fa-sign-out-alt';
278
- $scope.class = 'btn-light';
279
- } else if ($scope.type.like('*push*')) {
280
- $scope.fa = 'fas fa-plus-circle';
281
- $scope.class = 'btn-primary';
282
- } else if ($scope.type.like('*cancel*')) {
283
- $scope.fa = 'fas fa-minus-circle';
284
- $scope.class = 'btn-danger';
285
- } else if ($scope.type.like('*upload*')) {
286
- $scope.fa = 'fas fa-upload';
287
- $scope.class = 'btn-light';
288
- } else if ($scope.type.like('*up*')) {
289
- $scope.fa = 'fas fa-long-arrow-alt-up';
290
- $scope.class = 'btn-light';
291
- } else if ($scope.type.like('*down*')) {
292
- $scope.fa = 'fas fa-long-arrow-alt-down';
293
- $scope.class = 'btn-light';
294
- } else if ($scope.type.like('*reset*')) {
295
- $scope.fa = 'fas fa-sync-alt';
296
- $scope.class = 'btn-light';
297
- } else if ($scope.type.like('*stop*')) {
298
- $scope.fa = 'fas fa-stop';
299
- $scope.class = 'btn-light';
300
- } else if ($scope.type.like('*play*')) {
301
- $scope.fa = 'far fa-play-circle';
302
- $scope.class = 'btn-light';
303
- } else if ($scope.type.like('*copy*')) {
304
- $scope.fa = 'fas fa-copy';
305
- $scope.class = 'btn-light';
306
- }
307
- if ($scope.type.like('*default*')) {
308
- $scope.class = '';
309
- }
310
- if ($scope.class2) {
311
- $scope.class = $scope.class2;
312
- }
313
- $scope.onclick = function () {
314
- $scope.clickBusy = true;
315
- $timeout(() => {
316
- $scope.clickBusy = false;
317
- }, 250);
318
- };
319
- $scope.$watch('loading', (loading) => {
320
- if (loading === 'true') {
321
- $scope.busy = true;
322
- } else {
323
- $scope.busy = false;
324
- }
325
- });
326
- },
327
- template: `/*##client-side/directive/i-button.html*/`,
328
- };
329
- },
330
- ]);
331
- app.directive('iList', [
332
- '$interval',
333
- '$timeout',
334
- 'isite',
335
- function ($interval, $timeout, isite) {
336
- return {
337
- restrict: 'E',
338
- require: 'ngModel',
339
- scope: {
340
- v: '@',
341
- label: '@',
342
- display: '@',
343
- display2: '@',
344
- disabled: '@',
345
- css: '@',
346
- space: '@',
347
- primary: '@',
348
- ngValue: '@',
349
- ngModel: '=',
350
- ngSearch: '=',
351
- ngChange: '&',
352
- ngGet: '&',
353
- ngAdd: '&',
354
- items: '=',
355
- activeValue: '=',
356
- },
357
- link: function ($scope, element, attrs, ctrl) {
358
- $scope.primary = $scope.primary || 'id';
359
- $scope.display = $scope.display || 'name';
360
- $scope.display2 = $scope.display2 || '';
361
- $scope.space = $scope.space || ' - ';
362
- attrs.ngValue = attrs.ngValue || '';
363
- $scope.v = $scope.v || '';
364
- $scope.requird = '';
365
- if ($scope.v.like('*r*')) {
366
- $scope.requird = '*';
367
- }
368
- $scope.searchElement = $(element).find('.dropdown .search');
369
- $scope.popupElement = $(element).find('.dropdown .dropdown-content');
370
-
371
- if (typeof attrs.disabled !== 'undefined') {
372
- attrs.disabled = 'disabled';
373
- } else {
374
- attrs.disabled = '';
375
- }
376
-
377
- if (typeof attrs.ngAdd == 'undefined') {
378
- $scope.fa_add = 'fa-search';
379
- } else {
380
- $scope.fa_add = 'fa-plus';
381
- }
382
-
383
- if ($scope.ngSearch) {
384
- $scope.showSearch = !0;
385
- }
386
- if ($scope.ngGet) {
387
- $scope.showSearch = !0;
388
- }
389
-
390
- let input = $(element).find('input.dropdown-text');
391
- $(element).hover(
392
- () => {
393
- if (attrs.disabled !== 'disabled') {
394
- $scope.popupElement.css('display', 'block');
395
- }
396
- },
397
- () => {
398
- $scope.popupElement.css('display', 'none');
399
- }
400
- );
401
- $scope.focus = function () {
402
- $('.i-list .dropdown-content').css('display', 'none');
403
- $scope.popupElement.css('display', 'block');
404
- $scope.searchElement.focus();
405
- };
406
- $scope.hide = function () {
407
- $scope.popupElement.css('display', 'none');
408
- };
409
-
410
- $scope.getValue = function (item) {
411
- let v = isite.getValue(item, $scope.display);
412
- return v || '';
413
- };
414
-
415
- $scope.getValue2 = function (item) {
416
- if ($scope.display2) {
417
- return isite.getValue(item, $scope.display2) || '';
418
- }
419
- return '';
420
- };
421
-
422
- $scope.getNgModelValue = function (ngModel) {
423
- if (ngModel && $scope.display && $scope.ngValue) {
424
- return isite.getValue(ngModel, $scope.display.replace($scope.ngValue + '.', '')) || '';
425
- } else if (ngModel && $scope.display) {
426
- return isite.getValue(ngModel, $scope.display) || '';
427
- }
428
- return '';
429
- };
430
-
431
- $scope.getNgModelValue2 = function (ngModel) {
432
- if (ngModel && $scope.display2 && $scope.ngValue) {
433
- return isite.getValue(ngModel, $scope.display2.replace($scope.ngValue + '.', '')) || '';
434
- } else if (ngModel && $scope.display2) {
435
- return isite.getValue(ngModel, $scope.display2) || '';
436
- }
437
- return '';
438
- };
439
-
440
- $scope.getNgValue = function (item) {
441
- if (item && $scope.ngValue) {
442
- return isite.getValue(item, $scope.ngValue);
443
- }
444
- return item;
445
- };
446
-
447
- $scope.$watch('items', (items) => {
448
- input.val('');
449
-
450
- if (items) {
451
- items.forEach((item) => {
452
- if ($scope.display2) {
453
- item.$display = $scope.getValue(item) + $scope.space + $scope.getValue2(item);
454
- } else {
455
- item.$display = $scope.getValue(item);
456
- }
457
- });
458
- }
459
-
460
- if (items && $scope.ngModel) {
461
- items.forEach((item) => {
462
- if (isite.getValue(item, $scope.primary) == isite.getValue($scope.ngModel, $scope.primary)) {
463
- $scope.ngModel = item;
464
- if ($scope.display2) {
465
- item.$display = $scope.getValue(item) + $scope.space + $scope.getValue2(item);
466
- } else {
467
- item.$display = $scope.getValue(item);
468
- }
469
-
470
- input.val(item.$display);
471
- }
472
- });
473
- }
474
- });
475
-
476
- $scope.$watch('ngModel', (ngModel) => {
477
- input.val('');
478
-
479
- $scope.ngModel = ngModel;
480
-
481
- if (ngModel) {
482
- if ($scope.display2) {
483
- input.val(' ' + $scope.getNgModelValue(ngModel) + $scope.space + $scope.getNgModelValue2(ngModel));
484
- } else {
485
- input.val(' ' + $scope.getNgModelValue(ngModel));
486
- }
487
- }
488
- });
489
-
490
- $scope.searchElement.on('input', () => {
491
- $timeout(() => {
492
- if (attrs.ngGet) {
493
- $scope.ngGet({ $search: $scope.searchElement.val() });
494
- } else {
495
- $scope.$filter = $scope.searchElement.val();
496
- }
497
- }, 100);
498
- });
499
-
500
- $scope.updateModel = function (item) {
501
- if (item) {
502
- $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
503
- if ($scope.display2) {
504
- input.val($scope.getNgModelValue($scope.ngModel) + $scope.space + $scope.getNgModelValue2($scope.ngModel));
505
- } else {
506
- input.val($scope.getNgModelValue($scope.ngModel));
507
- }
508
- } else {
509
- $scope.ngModel = null;
510
- input.val('');
511
- }
512
-
513
- $timeout(() => {
514
- if ($scope.ngChange) {
515
- $scope.ngChange();
516
- }
517
- }, 100);
518
- $scope.hide();
519
- };
520
- },
521
- template: `/*##client-side/directive/i-list.html*/`,
522
- };
523
- },
524
- ]);
525
- app.directive('iChecklist', [
526
- '$interval',
527
- '$timeout',
528
- function ($interval, $timeout) {
529
- return {
530
- restrict: 'E',
531
- required: 'ngModel',
532
- scope: {
533
- label: '@',
534
- primary: '@',
535
- display: '@',
536
- class2: '@',
537
- ngModel: '=',
538
- items: '=',
539
- like: '&',
540
- ngChange: '&',
541
- },
542
- link: function ($scope, element, attrs, ctrl) {
543
- $scope.primary = $scope.primary || 'id';
544
- $scope.display = $scope.display || 'name';
545
- $scope.class2 = $scope.class2 || 'col3';
546
- $scope.selectedItems = [];
547
-
548
- $scope.$watch('ngModel', (ngModel) => {
549
- $scope.reload();
550
- });
551
- $scope.$watch('items', (ngModel) => {
552
- $scope.reload();
553
- });
554
- $scope.reload = function () {
555
- $scope.selectedItems = [];
556
-
557
- if ($scope.ngModel) {
558
- $scope.ngModel.forEach((mitem) => {
559
- $scope.selectedItems.push(mitem);
560
- });
561
-
562
- if ($scope.items) {
563
- $scope.items.forEach((mitem) => {
564
- let exist = !1;
565
- $scope.selectedItems.forEach((sitem) => {
566
- if (mitem[$scope.primary] === sitem[$scope.primary]) {
567
- exist = !0;
568
- }
569
- });
570
- if (exist) {
571
- mitem.$selected = !0;
572
- } else {
573
- mitem.$selected = !1;
574
- }
575
- });
576
- }
577
- }
578
- if (!$scope.ngModel) {
579
- $scope.selectedItems = [];
580
- if ($scope.items) {
581
- $scope.items.forEach((mitem) => {
582
- mitem.$selected = !1;
583
- });
584
- }
585
- }
586
- };
587
-
588
- $scope.change = function (item) {
589
- if (item.$selected) {
590
- let exsits = !1;
591
- $scope.selectedItems.forEach((sitem) => {
592
- if (sitem[$scope.primary] === item[$scope.primary]) {
593
- exsits = !0;
594
- }
595
- });
596
- if (!exsits) {
597
- let nitem = { ...item };
598
- delete nitem.$selected;
599
- delete nitem.$$hashKey;
600
- $scope.selectedItems.push(nitem);
601
- }
602
- } else {
603
- $scope.selectedItems.forEach((sitem, index) => {
604
- if (sitem[$scope.primary] === item[$scope.primary]) {
605
- $scope.selectedItems.splice(index, 1);
606
- }
607
- });
608
- }
609
-
610
- $scope.ngModel = $scope.selectedItems;
611
- $timeout(() => {
612
- if ($scope.ngChange) {
613
- $scope.ngChange();
614
- }
615
- }, 100);
616
- };
617
- },
618
- template: `/*##client-side/directive/i-checklist.html*/`,
619
- };
620
- },
621
- ]);
622
-
623
- app.directive('iDate', function ($timeout) {
624
- return {
625
- restrict: 'E',
626
- required: 'ngModel',
627
- scope: {
628
- v: '@',
629
- id2: '@',
630
- label: '@',
631
- type: '@',
632
- class2: '@',
633
- disabled: '@',
634
- ngModel: '=',
635
- ngChange: '&',
636
- ngKeydown: '&',
637
- },
638
- link: function ($scope, element, attrs) {
639
- $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
640
- $scope.v = $scope.v || '';
641
- $scope.requird = '';
642
- if ($scope.v.like('*r*')) {
643
- $scope.requird = '*';
644
- }
645
- if (typeof attrs.disabled !== 'undefined') {
646
- attrs.disabled = 'disabled';
647
- } else {
648
- attrs.disabled = '';
649
- }
650
- $scope.class2 = $scope.class2 || '';
651
-
652
- $scope.model = {};
653
-
654
- $scope.lang = site.session ? site.session.lang : 'en';
655
- if ($scope.lang === 'ar') {
656
- $scope.monthes = [
657
- { id: 0, name: 'يناير' },
658
- { id: 1, name: 'فبراير' },
659
- { id: 2, name: 'مارس' },
660
- { id: 3, name: 'ابريل' },
661
- { id: 4, name: 'مايو' },
662
- { id: 5, name: 'يونيو' },
663
- { id: 6, name: 'يوليو' },
664
- { id: 7, name: 'اغسطس' },
665
- { id: 8, name: 'سبتمبر' },
666
- { id: 9, name: 'اكتوبر' },
667
- { id: 10, name: 'نوفمبر' },
668
- { id: 11, name: 'ديسمبر' },
669
- ];
670
- } else {
671
- $scope.monthes = [
672
- { id: 0, name: 'January' },
673
- { id: 1, name: 'February' },
674
- { id: 2, name: 'March' },
675
- { id: 3, name: 'April' },
676
- { id: 4, name: 'May' },
677
- { id: 5, name: 'June' },
678
- { id: 6, name: 'July' },
679
- { id: 7, name: 'August' },
680
- { id: 8, name: 'September' },
681
- { id: 9, name: 'October' },
682
- { id: 10, name: 'November' },
683
- { id: 11, name: 'December' },
684
- ];
685
- }
686
-
687
- $scope.$watch('ngModel', function (ngModel) {
688
- if (ngModel) {
689
- ngModel = new Date(ngModel);
690
- $scope.model = $scope.model || {};
691
- $scope.model.selectedDay = site.addZero(ngModel.getDate(), 2);
692
- $scope.model.selectedMonth = $scope.monthes.find((m) => m.id == ngModel.getMonth());
693
- $scope.model.selectedYear = ngModel.getFullYear();
694
- $(element).attr('value', ngModel.getTime());
695
- $scope.ngModel1 = new Date(ngModel);
696
- } else {
697
- $scope.model = $scope.model || {};
698
- $scope.model.selectedDay = null;
699
- $scope.model.selectedMonth = null;
700
- $scope.model.selectedYear = null;
701
- $(element).attr('value', '');
702
- }
703
- });
704
-
705
- $scope.setDay = function () {
706
- $scope.ngModel = new Date();
707
- };
708
- $scope.updateDate = function (date) {
709
- if ($scope.ngModel1) {
710
- $scope.ngModel = $scope.ngModel1;
711
- $scope.editOnly = false;
712
-
713
- if ($scope.ngChange) {
714
- $scope.ngChange();
715
- }
716
- }
717
- };
718
- },
719
- restrict: 'E',
720
- require: 'ngModel',
721
- scope: {
722
- v: '@',
723
- disabled: '@',
724
- label: '@',
725
- ngModel: '=',
726
- },
727
- template: `/*##client-side/directive/i-date.html*/`,
728
- };
729
- });
730
-
731
- app.directive('iDatetime', function () {
732
- return {
733
- restrict: 'E',
734
- required: 'ngModel',
735
- scope: {
736
- v: '@',
737
- id2: '@',
738
- label: '@',
739
- type: '@',
740
- class2: '@',
741
- disabled: '@',
742
- ngModel: '=',
743
- ngChange: '&',
744
- ngKeydown: '&',
745
- },
746
- link: function ($scope, element, attrs) {
747
- $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
748
- $scope.v = $scope.v || '';
749
- $scope.requird = '';
750
- if ($scope.v.like('*r*')) {
751
- $scope.requird = '*';
752
- }
753
- if (typeof attrs.disabled !== 'undefined') {
754
- attrs.disabled = 'disabled';
755
- } else {
756
- attrs.disabled = '';
757
- }
758
- $scope.class2 = $scope.class2 || '';
759
-
760
- $scope.model = {};
761
-
762
- $scope.lang = site.session ? site.session.lang : 'en';
763
- if ($scope.lang === 'ar') {
764
- $scope.monthes = [
765
- { id: 0, name: 'يناير' },
766
- { id: 1, name: 'فبراير' },
767
- { id: 2, name: 'مارس' },
768
- { id: 3, name: 'ابريل' },
769
- { id: 4, name: 'مايو' },
770
- { id: 5, name: 'يونيو' },
771
- { id: 6, name: 'يوليو' },
772
- { id: 7, name: 'اغسطس' },
773
- { id: 8, name: 'سبتمبر' },
774
- { id: 9, name: 'اكتوبر' },
775
- { id: 10, name: 'نوفمبر' },
776
- { id: 11, name: 'ديسمبر' },
777
- ];
778
- } else {
779
- $scope.monthes = [
780
- { id: 0, name: 'January' },
781
- { id: 1, name: 'February' },
782
- { id: 2, name: 'March' },
783
- { id: 3, name: 'April' },
784
- { id: 4, name: 'May' },
785
- { id: 5, name: 'June' },
786
- { id: 6, name: 'July' },
787
- { id: 7, name: 'August' },
788
- { id: 8, name: 'September' },
789
- { id: 9, name: 'October' },
790
- { id: 10, name: 'November' },
791
- { id: 11, name: 'December' },
792
- ];
793
- }
794
-
795
- $scope.$watch('ngModel', function (ngModel) {
796
- if (ngModel) {
797
- ngModel = new Date(ngModel);
798
- $scope.model = $scope.model || {};
799
- $scope.model.selectedDay = site.addZero(ngModel.getDate(), 2);
800
- $scope.model.selectedMonth = $scope.monthes.find((m) => m.id == ngModel.getMonth());
801
- $scope.model.selectedYear = ngModel.getFullYear();
802
- $scope.model.selectedHour = site.addZero(ngModel.getHours(), 2);
803
- $scope.model.selectedMinute = site.addZero(ngModel.getMinutes(), 2);
804
-
805
- $scope.ngModel1 = new Date(ngModel);
806
- $scope.ngModel2 = new Date(0, 0, 0, ngModel.getHours(), ngModel.getMinutes());
807
- $(element).attr('value', ngModel.getTime());
808
- } else {
809
- $scope.model = $scope.model || {};
810
- $scope.model.selectedDay = null;
811
- $scope.model.selectedMonth = null;
812
- $scope.model.selectedYear = null;
813
- $scope.model.selectedHour = null;
814
- $scope.model.selectedMinute = null;
815
- $(element).attr('value', '');
816
- }
817
- });
818
-
819
- $scope.setDay = function () {
820
- $scope.ngModel = new Date();
821
- };
822
-
823
- $scope.updateDate = function (date) {
824
- let time = $('#time_' + $scope.id2).val();
825
-
826
- if ($scope.ngModel1 && time) {
827
- $scope.ngModel = new Date($scope.ngModel1.getFullYear(), $scope.ngModel1.getMonth(), $scope.ngModel1.getDate(), time.split(':')[0], time.split(':')[1], 0);
828
- $scope.editOnly = false;
829
- $(element).attr('value', $scope.ngModel.getTime());
830
- if ($scope.ngChange) {
831
- $scope.ngChange();
832
- }
833
- }
834
- };
835
- },
836
- restrict: 'E',
837
- require: 'ngModel',
838
- scope: {
839
- v: '@',
840
- disabled: '@',
841
- label: '@',
842
- ngModel: '=',
843
- },
844
- template: `/*##client-side/directive/i-datetime.html*/`,
845
- };
846
- });
847
-
848
- app.directive('iFile', [
849
- '$interval',
850
- 'isite',
851
- '$timeout',
852
- function ($interval, isite, $timeout) {
853
- return {
854
- restrict: 'E',
855
- required: 'ngModel',
856
- scope: {
857
- label: '@',
858
- view: '@',
859
- accept: '@',
860
- folder: '@',
861
- ngModel: '=',
862
- ngClick: '&',
863
- onSelected: '&',
864
- ngChange: '&',
865
- },
866
- link: function ($scope, element, attrs, ctrl) {
867
- $scope.label = $scope.label || '';
868
- $scope.folder = $scope.folder || 'default';
869
- $scope.accept = $scope.accept ? $scope.accept : '';
870
- $scope.viewOnly = $scope.view === undefined ? false : true;
871
-
872
- let input = $(element).find('input')[0];
873
- let button = $(element).find('i-button')[0];
874
-
875
- let progress = $(element).find('.progress')[0];
876
- let progressBar = $(element).find('.progress-bar')[0];
877
- $(progress).hide();
878
-
879
- $scope.id = Math.random().toString().replace('.', '_');
880
-
881
- if (!$scope.viewOnly) {
882
- button.addEventListener('click', function () {
883
- input.click();
884
- });
885
- }
886
-
887
- input.addEventListener('change', function () {
888
- isite.uploadFile(
889
- this.files,
890
- {
891
- folder: $scope.folder,
892
- },
893
- (err, file, e) => {
894
- if (e) {
895
- $(progress).show();
896
- $scope.value = (e.loaded / e.total) * 100;
897
- progressBar.style.width = $scope.value + '%';
898
- $scope.max = e.total;
899
- if ($scope.value === 100) {
900
- $(progress).hide();
901
- }
902
- }
903
-
904
- if (file) {
905
- $scope.ngModel = file;
906
- $scope.changed();
907
- }
908
- }
909
- );
910
- $scope.ngModel = this.files[0].path;
911
- $scope.onSelected(this.files[0].path);
912
- $scope.$applyAsync();
913
- });
914
-
915
- $scope.$watch('ngModel', (ngModel) => {
916
- if (ngModel) {
917
- button.setAttribute('url', ngModel);
918
- }
919
- });
920
-
921
- $scope.changed = function () {
922
- $timeout(() => {
923
- if ($scope.ngChange) {
924
- $scope.ngChange();
925
- }
926
- }, 200);
927
- };
928
- },
929
- template: `/*##client-side/directive/i-file.html*/`,
930
- };
931
- },
932
- ]);
933
-
934
- app.directive('iImage', [
935
- '$interval',
936
- 'isite',
937
- '$timeout',
938
- function ($interval, isite, $timeout) {
939
- return {
940
- restrict: 'E',
941
- required: 'ngModel',
942
- scope: {
943
- folder: '@',
944
- view: '@',
945
- accept: '@',
946
- ngModel: '=',
947
- ngClick: '&',
948
- ngChange: '&',
949
- },
950
- link: function ($scope, element, attrs, ctrl) {
951
- $scope.accept = $scope.accept ? $scope.accept : 'image/*';
952
- $scope.viewOnly = $scope.view === undefined ? false : true;
953
-
954
- let input = $(element).find('input')[0];
955
- let img = $(element).find('img')[0];
956
- let progress = $(element).find('.progress')[0];
957
- $(progress).hide();
958
-
959
- $scope.upload = function () {
960
- if (!$scope.viewOnly) {
961
- input.click();
962
- }
963
- };
964
- $scope.delete = function () {
965
- img.src = null;
966
- $scope.ngModel = null;
967
- };
968
-
969
- input.addEventListener('change', function () {
970
- isite.uploadImage(
971
- this.files,
972
- {
973
- folder: $scope.folder,
974
- },
975
- (err, image, e) => {
976
- if (e) {
977
- $(progress).show();
978
- $scope.value = (e.loaded / e.total) * 100;
979
- $scope.max = e.total;
980
- $(progress).css('width', $scope.value);
981
- if ($scope.value === 100) {
982
- $(progress).hide();
983
- }
984
- }
985
-
986
- if (image) {
987
- $scope.ngModel = image;
988
- if ($scope.ngChange) {
989
- $timeout(() => {
990
- $scope.ngChange();
991
- }, 200);
992
- }
993
- }
994
- }
995
- );
996
- });
997
-
998
- $scope.$watch('ngModel', (ngModel) => {
999
- if (ngModel) {
1000
- img.setAttribute('src', ngModel.url);
1001
- }
1002
- });
1003
- },
1004
- template: `/*##client-side/directive/i-image.html*/`,
1005
- };
1006
- },
1007
- ]);
1008
-
1009
- app.directive('iAudio', [
1010
- '$interval',
1011
- 'isite',
1012
- '$timeout',
1013
- function ($interval, isite, $timeout) {
1014
- return {
1015
- restrict: 'E',
1016
- required: 'ngModel',
1017
- scope: {
1018
- folder: '@',
1019
- view: '@',
1020
- accept: '@',
1021
- ngModel: '=',
1022
- ngClick: '&',
1023
- ngChange: '&',
1024
- },
1025
- link: function ($scope, element, attrs, ctrl) {
1026
- $scope.folder = $scope.folder || 'default';
1027
- $scope.accept = $scope.accept ? $scope.accept : '.mp3';
1028
- $scope.viewOnly = $scope.view === undefined ? false : true;
1029
-
1030
- let input = $(element).find('input')[0];
1031
- let audio = $(element).find('audio')[0];
1032
- let progress = $(element).find('.progress')[0];
1033
- $(progress).hide();
1034
-
1035
- $scope.upload = function () {
1036
- if (!$scope.viewOnly) {
1037
- input.click();
1038
- }
1039
- };
1040
- $scope.delete = function () {
1041
- $scope.ngModel = null;
1042
- audio.setAttribute('src', null);
1043
- };
1044
-
1045
- input.addEventListener('change', function () {
1046
- isite.uploadAudio(
1047
- this.files,
1048
- {
1049
- folder: $scope.folder,
1050
- },
1051
- (err, audio, e) => {
1052
- if (e) {
1053
- $(progress).show();
1054
- $scope.value = (e.loaded / e.total) * 100;
1055
- $scope.max = e.total;
1056
- $(progress).css('width', $scope.value);
1057
- if ($scope.value === 100) {
1058
- $(progress).hide();
1059
- }
1060
- }
1061
-
1062
- if (audio) {
1063
- $scope.ngModel = audio;
1064
- if ($scope.ngChange) {
1065
- $timeout(() => {
1066
- $scope.ngChange();
1067
- }, 200);
1068
- }
1069
- }
1070
- }
1071
- );
1072
- });
1073
-
1074
- $scope.$watch('ngModel', (ngModel) => {
1075
- if (ngModel) {
1076
- audio.setAttribute('src', ngModel.url);
1077
- audio.setAttribute('type', 'audio/mpeg');
1078
- }
1079
- });
1080
- },
1081
- template: `/*##client-side/directive/i-audio.html*/`,
1082
- };
1083
- },
1084
- ]);
1085
-
1086
- app.directive('iVideo', [
1087
- '$interval',
1088
- 'isite',
1089
- '$timeout',
1090
- function ($interval, isite, $timeout) {
1091
- return {
1092
- restrict: 'E',
1093
- required: 'ngModel',
1094
- scope: {
1095
- folder: '@',
1096
- view: '@',
1097
- accept: '@',
1098
- ngModel: '=',
1099
- ngClick: '&',
1100
- ngChange: '&',
1101
- },
1102
- link: function ($scope, element, attrs, ctrl) {
1103
- $scope.folder = $scope.folder || 'default';
1104
- $scope.accept = $scope.accept ? $scope.accept : '.mp4';
1105
- $scope.viewOnly = $scope.view === undefined ? false : true;
1106
-
1107
- let input = $(element).find('input')[0];
1108
- let video = $(element).find('video')[0];
1109
- let progress = $(element).find('.progress')[0];
1110
- $(progress).hide();
1111
-
1112
- $scope.upload = function () {
1113
- if (!$scope.viewOnly) {
1114
- input.click();
1115
- }
1116
- };
1117
- $scope.delete = function () {
1118
- $scope.ngModel = null;
1119
- video.setAttribute('src', null);
1120
- };
1121
-
1122
- input.addEventListener('change', function () {
1123
- isite.uploadVideo(
1124
- this.files,
1125
- {
1126
- folder: $scope.folder,
1127
- },
1128
- (err, video, e) => {
1129
- if (e) {
1130
- $(progress).show();
1131
- $scope.value = (e.loaded / e.total) * 100;
1132
- $scope.max = e.total;
1133
- $(progress).css('width', $scope.value);
1134
- if ($scope.value === 100) {
1135
- $(progress).hide();
1136
- }
1137
- }
1138
-
1139
- if (video) {
1140
- $scope.ngModel = video;
1141
- if ($scope.ngChange) {
1142
- $timeout(() => {
1143
- $scope.ngChange();
1144
- }, 200);
1145
- }
1146
- }
1147
- }
1148
- );
1149
- });
1150
-
1151
- $scope.capture = function () {
1152
- let canvas = document.createElement('canvas');
1153
- canvas.width = video.videoWidth / 4;
1154
- canvas.height = video.videoHeight / 4;
1155
- canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
1156
- $scope.ngModel.imageURL = canvas.toDataURL('image/jpeg');
1157
- };
1158
-
1159
- video.addEventListener(
1160
- 'canplay',
1161
- function (e) {
1162
- $timeout(() => {
1163
- $scope.capture();
1164
- }, 2000);
1165
- },
1166
- false
1167
- );
1168
-
1169
- $scope.$watch('ngModel', (ngModel) => {
1170
- if (ngModel) {
1171
- video.setAttribute('src', ngModel.url);
1172
- video.setAttribute('type', 'video/mp4');
1173
- video.load();
1174
- }
1175
- });
1176
- },
1177
- template: `/*##client-side/directive/i-video.html*/`,
1178
- };
1179
- },
1180
- ]);
1181
-
1182
- app.directive('iUpload', [
1183
- '$interval',
1184
- 'isite',
1185
- function ($interval, isite) {
1186
- return {
1187
- restrict: 'E',
1188
- scope: {
1189
- label: '@',
1190
- api: '@',
1191
- type: '@',
1192
- view: '@',
1193
- ngClick: '&',
1194
- onUploaded: '&',
1195
- },
1196
- link: function ($scope, element, attrs, ctrl) {
1197
- let input = $(element).find('input')[0];
1198
- let a = $(element).find('button')[0];
1199
- let progress = $(element).find('progress')[0];
1200
- $(progress).hide();
1201
-
1202
- if (attrs.view !== '') {
1203
- a.addEventListener('click', function () {
1204
- input.click();
1205
- });
1206
- }
1207
-
1208
- input.addEventListener('change', function () {
1209
- if ($scope.api) {
1210
- isite.upload(
1211
- this.files,
1212
- {
1213
- api: $scope.api,
1214
- },
1215
- (err, data, e) => {
1216
- if (e) {
1217
- $(progress).show();
1218
- progress.value = e.loaded;
1219
- progress.max = e.total;
1220
- } else if (data) {
1221
- if ($scope.onUploaded) {
1222
- $scope.onUploaded({ $data: data });
1223
- }
1224
- }
1225
- }
1226
- );
1227
- }
1228
- });
1229
- },
1230
- template: `/*##client-side/directive/i-upload.html*/`,
1231
- };
1232
- },
1233
- ]);
1234
-
1235
- app.directive('iTreeview', [
1236
- '$interval',
1237
- '$timeout',
1238
- 'isite',
1239
- function ($interval, $timeout, isite) {
1240
- return {
1241
- restrict: 'E',
1242
- require: 'ngModel',
1243
- scope: {
1244
- v: '@',
1245
- label: '@',
1246
- display: '@',
1247
- display2: '@',
1248
- disabled: '@',
1249
- space: '@',
1250
- primary: '@',
1251
- ngValue: '@',
1252
- ngModel: '=',
1253
- ngSearch: '=',
1254
- ngChange: '&',
1255
- ngClick: '&',
1256
- ngAdd: '&',
1257
- ngNode: '&',
1258
- ngEdit: '&',
1259
- ngDelete: '&',
1260
- nodes: '=',
1261
- },
1262
- link: function ($scope, element, attrs, ctrl) {
1263
- attrs.display = attrs.display || 'name';
1264
- attrs.primary = attrs.primary || 'id';
1265
- attrs.space = attrs.space || ' ';
1266
- attrs.ngValue = attrs.ngValue || '';
1267
-
1268
- $scope.source = {};
1269
-
1270
- $scope.setNodes = function (v_node) {
1271
- v_node.nodes.forEach((v_node2) => {
1272
- v_node2.nodes = v_node2.nodes || [];
1273
- $scope.nodes.forEach((node) => {
1274
- if (node.$parent_id == v_node2.id) {
1275
- node.v_display = node.v_display || '';
1276
- node.v_display += node[attrs.display];
1277
-
1278
- let exist = !1;
1279
- v_node2.nodes.forEach((n) => {
1280
- if (n.id == node.id) {
1281
- exist = !0;
1282
- }
1283
- });
1284
- if (!exist) {
1285
- v_node2.nodes.push(node);
1286
- }
1287
- }
1288
- });
1289
- $scope.setNodes(v_node2);
1290
- });
1291
- };
1292
-
1293
- $scope.v_nodes = [];
1294
-
1295
- $scope.$watch('ngModel', (ngModel) => {
1296
- if (ngModel) {
1297
- $scope.ngModel = ngModel;
1298
- $scope.ngModel.v_display = $scope.ngModel.v_display || ngModel[attrs.display];
1299
- }
1300
- });
1301
-
1302
- $scope.$watch('nodes', (nodes) => {
1303
- $scope.v_nodes = [];
1304
- if (nodes) {
1305
- nodes.forEach((node) => {
1306
- node.$parent_id = node.parent_id || node.parentId || 0;
1307
- node.v_display = node.v_display || '';
1308
- node.v_display += node[attrs.display];
1309
- if (node.$parent_id == 0) {
1310
- let exist = !1;
1311
- $scope.v_nodes.forEach((n) => {
1312
- if (n.id == node.id) {
1313
- exist = !0;
1314
- }
1315
- });
1316
- if (!exist) {
1317
- $scope.v_nodes.push(node);
1318
- }
1319
- }
1320
- });
1321
-
1322
- $scope.v_nodes.forEach((v_node) => {
1323
- v_node.nodes = v_node.nodes || [];
1324
-
1325
- nodes.forEach((node) => {
1326
- node.$parent_id = node.parent_id || node.parentId || 0;
1327
- if (node.$parent_id == v_node.id) {
1328
- node.v_display = node.v_display || '';
1329
- node.v_display += node[attrs.display];
1330
-
1331
- let exist = !1;
1332
- v_node.nodes.forEach((n) => {
1333
- if (n.id == node.id) {
1334
- exist = !0;
1335
- }
1336
- });
1337
- if (!exist) {
1338
- v_node.nodes.push(node);
1339
- }
1340
- }
1341
- });
1342
-
1343
- $scope.setNodes(v_node);
1344
- });
1345
- }
1346
- });
1347
- },
1348
- template: `/*##client-side/directive/i-treeview.html*/`,
1349
- };
1350
- },
1351
- ]);
1352
-
1353
- app.directive('iTreenode', [
1354
- '$interval',
1355
- '$timeout',
1356
- 'isite',
1357
- function ($interval, $timeout, isite) {
1358
- return {
1359
- restrict: 'E',
1360
- require: 'ngModel',
1361
- scope: {
1362
- v: '@',
1363
- label: '@',
1364
- display: '@',
1365
- display2: '@',
1366
- disabled: '@',
1367
- space: '@',
1368
- primary: '@',
1369
- ngValue: '@',
1370
- ngChange: '&',
1371
- ngClick: '&',
1372
- ngAdd: '&',
1373
- ngEdit: '&',
1374
- ngDelete: '&',
1375
- ngModel: '=',
1376
- ngSearch: '=',
1377
- nodes: '=',
1378
- nodes: '=',
1379
- },
1380
- link: function ($scope, element, attrs, ctrl) {
1381
- attrs.display = attrs.display || 'name';
1382
- attrs.primary = attrs.primary || 'id';
1383
- attrs.space = attrs.space || ' ';
1384
- attrs.ngValue = attrs.ngValue || '';
1385
- $scope.nodes = $scope.nodes || [];
1386
-
1387
- $scope.v_nodes = [];
1388
-
1389
- $scope.$watch('nodes', (nodes) => {
1390
- $scope.v_nodes = [];
1391
- if (nodes) {
1392
- nodes.forEach((node, i) => {
1393
- if (node.nodes) {
1394
- node.nodes.forEach((node2, i) => {
1395
- node2.$parent_id = node2.parent_id || node.id;
1396
- node2.v_display = node.v_display || ' ';
1397
- node2.v_display += ' - ' + node2[attrs.display];
1398
- });
1399
- }
1400
- });
1401
- }
1402
- });
1403
-
1404
- $scope.updateParentModal = function (parent, node) {
1405
- if (parent) {
1406
- parent.ngModel = node;
1407
- if (parent.$parent) {
1408
- $scope.updateParentModal(parent.$parent, node);
1409
- }
1410
- }
1411
- };
1412
-
1413
- $scope.unSelectParent = function (parent) {
1414
- if (parent && parent.nodes) {
1415
- parent.nodes.forEach((node) => {
1416
- node.$selected = !1;
1417
- });
1418
- if (parent.$parent) {
1419
- $scope.unSelectParent(parent.$parent);
1420
- }
1421
- }
1422
- };
1423
-
1424
- $scope.unSelectNodes = function (nodes) {
1425
- if (nodes) {
1426
- nodes.forEach((node) => {
1427
- node.$selected = !1;
1428
- if (node.nodes) {
1429
- $scope.unSelectNodes(node.nodes);
1430
- }
1431
- });
1432
- }
1433
- };
1434
-
1435
- $scope.updateModal = function (node) {
1436
- $scope.ngModel = node;
1437
- $scope.updateParentModal($scope.$parent, node);
1438
- };
1439
-
1440
- $scope.selected = function (node) {
1441
- $scope.unSelectParent($scope.$parent);
1442
- $scope.unSelectNodes($scope.nodes);
1443
-
1444
- if (node.nodes) {
1445
- node.nodes.forEach((itm) => {
1446
- itm.$selected = !1;
1447
- });
1448
- }
1449
-
1450
- node.$selected = !0;
1451
- };
1452
- },
1453
- template: `/*##client-side/directive/i-treenode.html*/`,
1454
- };
1455
- },
1456
- ]);
1
+ app.directive('iControl', function () {
2
+ return {
3
+ restrict: 'E',
4
+ require: 'ngModel',
5
+ scope: {
6
+ v: '@',
7
+ id2: '@',
8
+ label: '@',
9
+ type: '@',
10
+ class2: '@',
11
+ disabled: '@',
12
+ ngModel: '=',
13
+ ngChange: '&',
14
+ ngKeydown: '&',
15
+ },
16
+ link: function ($scope, element, attrs, ctrl) {
17
+ attrs.type = attrs.type || 'text';
18
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
19
+ $scope.v = $scope.v || '';
20
+ $scope.requird = '';
21
+ if ($scope.v.like('*r*')) {
22
+ $scope.requird = '*';
23
+ }
24
+ if (typeof attrs.disabled !== 'undefined') {
25
+ attrs.disabled = 'disabled';
26
+ } else {
27
+ attrs.disabled = '';
28
+ }
29
+ $scope.class2 = $scope.class2 || '';
30
+ $(element)
31
+ .find('input')
32
+ .focus(() => {
33
+ $('.i-list .dropdown-content').css('display', 'none');
34
+ });
35
+ },
36
+ template: `/*##client-side/directive/i-control.html*/`,
37
+ };
38
+ });
39
+
40
+ app.directive('iTextarea', function () {
41
+ return {
42
+ restrict: 'E',
43
+ require: 'ngModel',
44
+ scope: {
45
+ v: '@',
46
+ label: '@',
47
+ id2: '@',
48
+ disabled: '@',
49
+ rows: '@',
50
+ ngModel: '=',
51
+ ngChange: '&',
52
+ },
53
+ link: function ($scope, element, attrs, ctrl) {
54
+ if (typeof attrs.disabled !== 'undefined') {
55
+ attrs.disabled = 'disabled';
56
+ } else {
57
+ attrs.disabled = '';
58
+ }
59
+ $scope.rows = $scope.rows || 10;
60
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
61
+ $(element)
62
+ .find('textarea')
63
+ .focus(() => {
64
+ $('.popup').hide();
65
+ });
66
+ },
67
+ template: `/*##client-side/directive/i-textarea.html*/`,
68
+ };
69
+ });
70
+ app.directive('iContent', function ($timeout, $interval) {
71
+ return {
72
+ restrict: 'E',
73
+ scope: {
74
+ v: '@',
75
+ label: '@',
76
+ id2: '@',
77
+ disabled: '@',
78
+ rows: '@',
79
+ ngModel: '=',
80
+ ngChange: '&',
81
+ },
82
+ link: function ($scope, element, attrs, ctrl) {
83
+ if (typeof attrs.disabled !== 'undefined') {
84
+ attrs.disabled = 'disabled';
85
+ } else {
86
+ attrs.disabled = '';
87
+ }
88
+ $scope.stopReading = false;
89
+ $scope.rows = $scope.rows || 10;
90
+ $scope.id2 = $scope.id2 || 'textarea_' + Math.random().toString().replace('0.', '');
91
+ $(element).find('textarea').id = $scope.id2;
92
+ $(element)
93
+ .find('textarea')
94
+ .focus(() => {
95
+ $('.popup').hide();
96
+ });
97
+ $scope.handelContentElement = function () {
98
+ if (!document.querySelector('#' + $scope.id2)) {
99
+ $timeout(() => {
100
+ $scope.handelContentElement();
101
+ }, 1000);
102
+ return false;
103
+ }
104
+ window['content_' + $scope.id2] = WebShareEditor.create($scope.id2, {
105
+ toolbarItem: [
106
+ ['undo', 'redo'],
107
+ ['font', 'fontSize', 'formatBlock'],
108
+ ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
109
+ ['removeFormat'],
110
+ ['fontColor', 'hiliteColor'],
111
+ ['outdent', 'indent'],
112
+ ['align', 'horizontalRule', 'list', 'table'],
113
+ ['link', 'image', 'video'],
114
+ ['preview', 'print'],
115
+ /* ['fullScreen', 'showBlocks', 'codeView'],
116
+ ['save', 'template'],*/
117
+ ],
118
+ width: '100%',
119
+ minHeight: '300px',
120
+ });
121
+ if ($scope.ngModel && window['content_' + $scope.id2]) {
122
+ window['content_' + $scope.id2].setContents($scope.ngModel);
123
+ }
124
+ $scope.readingNow();
125
+ };
126
+
127
+ $scope.readingNow = function () {
128
+ $scope.intravalReading = $interval(() => {
129
+ if (window['content_' + $scope.id2]) {
130
+ $scope.ngModel2 = window['content_' + $scope.id2].getContents();
131
+ if ($scope.ngModel !== $scope.ngModel2) {
132
+ $scope.ngModel = $scope.ngModel2;
133
+ $scope.changed();
134
+ }
135
+ }
136
+ }, 1000);
137
+ };
138
+ $scope.handelContentElement();
139
+
140
+ $scope.changed = function () {
141
+ $timeout(() => {
142
+ if ($scope.ngChange) {
143
+ $scope.ngChange();
144
+ }
145
+ }, 100);
146
+ };
147
+
148
+ $scope.$watch('ngModel', (ngModel) => {
149
+ clearInterval($scope.intravalReading);
150
+
151
+ if (ngModel && window['content_' + $scope.id2]) {
152
+ if ($scope.ngModel2 && $scope.ngModel !== $scope.ngModel2) {
153
+ $scope.ngModel = ngModel;
154
+ window['content_' + $scope.id2].setContents($scope.ngModel);
155
+ }
156
+ }
157
+ $scope.readingNow();
158
+ });
159
+ },
160
+ template: `/*##client-side/directive/i-content.html*/`,
161
+ };
162
+ });
163
+
164
+ app.directive('iCheckbox', function ($timeout) {
165
+ return {
166
+ restrict: 'E',
167
+ require: 'ngModel',
168
+ scope: {
169
+ label: '@',
170
+ id2: '@',
171
+ ngDisabled: '@',
172
+ ngModel: '=',
173
+ ngChange: '&',
174
+ },
175
+ link: function ($scope, element, attrs, ctrl) {
176
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
177
+ $scope.changed = function () {
178
+ $timeout(() => {
179
+ if ($scope.ngChange) {
180
+ $scope.ngChange();
181
+ }
182
+ }, 100);
183
+ };
184
+ },
185
+ template: `/*##client-side/directive/i-checkbox.html*/`,
186
+ };
187
+ });
188
+
189
+ app.directive('iRadio', function () {
190
+ return {
191
+ restrict: 'E',
192
+ require: 'ngModel',
193
+ scope: {
194
+ label: '@',
195
+ group: '@',
196
+ id2: '@',
197
+ ngValue: '@',
198
+ ngModel: '=',
199
+ ngChange: '&',
200
+ },
201
+ link: function ($scope, element, attrs, ctrl) {
202
+ if (typeof attrs.disabled !== 'undefined') {
203
+ attrs.disabled = 'disabled';
204
+ } else {
205
+ attrs.disabled = '';
206
+ }
207
+
208
+ $scope.group = $scope.group || attrs.ngModel.replaceAll('.', '_');
209
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
210
+ },
211
+ template: `/*##client-side/directive/i-radio.html*/`,
212
+ };
213
+ });
214
+
215
+ app.directive('iButton', [
216
+ '$interval',
217
+ '$timeout',
218
+ function ($interval, $timeout) {
219
+ return {
220
+ restrict: 'E',
221
+ scope: {
222
+ label: '@',
223
+ type: '@',
224
+ class2: '@',
225
+ loading: '@',
226
+ click: '&',
227
+ fa: '@',
228
+ },
229
+ link: function ($scope, element, attrs, ctrl) {
230
+ $scope.type = $scope.type || '';
231
+ $scope.class = $scope.class = 'btn-light';
232
+ $scope.fa = $scope.fa || $scope.label ? '' : 'fas fa-mouse-pointer';
233
+
234
+ if ($scope.type.like('*add*|*new*')) {
235
+ $scope.fa = 'fas fa-plus';
236
+ $scope.class = 'btn-primary';
237
+ } else if ($scope.type.like('*update*|*edit*')) {
238
+ $scope.fa = 'fas fa-edit';
239
+ $scope.class = 'btn-warning';
240
+ } else if ($scope.type.like('*save*')) {
241
+ $scope.fa = 'fas fa-save';
242
+ $scope.class = 'btn-success';
243
+ } else if ($scope.type.like('*list*')) {
244
+ $scope.fa = 'fas fa-list';
245
+ $scope.class = 'btn-info';
246
+ } else if ($scope.type.like('unapprove')) {
247
+ $scope.fa = 'fas fa-eject';
248
+ $scope.class = 'btn-danger';
249
+ } else if ($scope.type.like('approve')) {
250
+ $scope.fa = 'fas fa-check-double';
251
+ $scope.class = 'btn-primary';
252
+ } else if ($scope.type.like('*view*|*details*|*show*')) {
253
+ $scope.fa = 'fas fa-eye';
254
+ $scope.class = 'btn-info';
255
+ } else if ($scope.type.like('*delete*|*remove*|*clear*')) {
256
+ $scope.fa = 'fas fa-trash';
257
+ $scope.class = 'btn-danger';
258
+ } else if ($scope.type.like('*exit*|*close*')) {
259
+ $scope.fa = 'fas fa-times-circle';
260
+ $scope.class = 'btn-danger';
261
+ } else if ($scope.type.like('*print*')) {
262
+ $scope.fa = 'fas fa-print';
263
+ $scope.class = 'btn-secondary';
264
+ } else if ($scope.type.like('*export*|*excel*')) {
265
+ $scope.fa = 'fas fa-file-export';
266
+ $scope.class = 'btn-light';
267
+ } else if ($scope.type.like('*import*')) {
268
+ $scope.fa = 'fas fa-file-upload';
269
+ $scope.class = 'btn-light';
270
+ } else if ($scope.type.like('*search*|*find*')) {
271
+ $scope.fa = 'fas fa-search';
272
+ $scope.class = 'btn-light';
273
+ } else if ($scope.type.like('*login*|*signin*')) {
274
+ $scope.fa = 'fas fa-sign-in-alt';
275
+ $scope.class = 'btn-light';
276
+ } else if ($scope.type.like('*logout*|*signout*')) {
277
+ $scope.fa = 'fas fa-sign-out-alt';
278
+ $scope.class = 'btn-light';
279
+ } else if ($scope.type.like('*push*')) {
280
+ $scope.fa = 'fas fa-plus-circle';
281
+ $scope.class = 'btn-primary';
282
+ } else if ($scope.type.like('*cancel*')) {
283
+ $scope.fa = 'fas fa-minus-circle';
284
+ $scope.class = 'btn-danger';
285
+ } else if ($scope.type.like('*upload*')) {
286
+ $scope.fa = 'fas fa-upload';
287
+ $scope.class = 'btn-light';
288
+ } else if ($scope.type.like('*up*')) {
289
+ $scope.fa = 'fas fa-long-arrow-alt-up';
290
+ $scope.class = 'btn-light';
291
+ } else if ($scope.type.like('*down*')) {
292
+ $scope.fa = 'fas fa-long-arrow-alt-down';
293
+ $scope.class = 'btn-light';
294
+ } else if ($scope.type.like('*reset*')) {
295
+ $scope.fa = 'fas fa-sync-alt';
296
+ $scope.class = 'btn-light';
297
+ } else if ($scope.type.like('*stop*')) {
298
+ $scope.fa = 'fas fa-stop';
299
+ $scope.class = 'btn-light';
300
+ } else if ($scope.type.like('*play*')) {
301
+ $scope.fa = 'far fa-play-circle';
302
+ $scope.class = 'btn-light';
303
+ } else if ($scope.type.like('*copy*')) {
304
+ $scope.fa = 'fas fa-copy';
305
+ $scope.class = 'btn-light';
306
+ }
307
+ if ($scope.type.like('*default*')) {
308
+ $scope.class = '';
309
+ }
310
+ if ($scope.class2) {
311
+ $scope.class = $scope.class2;
312
+ }
313
+ $scope.onclick = function () {
314
+ $scope.clickBusy = true;
315
+ $timeout(() => {
316
+ $scope.clickBusy = false;
317
+ }, 250);
318
+ };
319
+ $scope.$watch('loading', (loading) => {
320
+ if (loading === 'true') {
321
+ $scope.busy = true;
322
+ } else {
323
+ $scope.busy = false;
324
+ }
325
+ });
326
+ },
327
+ template: `/*##client-side/directive/i-button.html*/`,
328
+ };
329
+ },
330
+ ]);
331
+ app.directive('iList', [
332
+ '$interval',
333
+ '$timeout',
334
+ 'isite',
335
+ function ($interval, $timeout, isite) {
336
+ return {
337
+ restrict: 'E',
338
+ require: 'ngModel',
339
+ scope: {
340
+ v: '@',
341
+ label: '@',
342
+ display: '@',
343
+ display2: '@',
344
+ disabled: '@',
345
+ css: '@',
346
+ space: '@',
347
+ primary: '@',
348
+ ngValue: '@',
349
+ ngModel: '=',
350
+ ngSearch: '=',
351
+ ngChange: '&',
352
+ ngGet: '&',
353
+ ngAdd: '&',
354
+ items: '=',
355
+ activeValue: '=',
356
+ },
357
+ link: function ($scope, element, attrs, ctrl) {
358
+ $scope.primary = $scope.primary || 'id';
359
+ $scope.display = $scope.display || 'name';
360
+ $scope.display2 = $scope.display2 || '';
361
+ $scope.space = $scope.space || ' - ';
362
+ attrs.ngValue = attrs.ngValue || '';
363
+ $scope.v = $scope.v || '';
364
+ $scope.requird = '';
365
+ if ($scope.v.like('*r*')) {
366
+ $scope.requird = '*';
367
+ }
368
+ $scope.searchElement = $(element).find('.dropdown .search');
369
+ $scope.popupElement = $(element).find('.dropdown .dropdown-content');
370
+
371
+ if (typeof attrs.disabled !== 'undefined') {
372
+ attrs.disabled = 'disabled';
373
+ } else {
374
+ attrs.disabled = '';
375
+ }
376
+
377
+ if (typeof attrs.ngAdd == 'undefined') {
378
+ $scope.fa_add = 'fa-search';
379
+ } else {
380
+ $scope.fa_add = 'fa-plus';
381
+ }
382
+
383
+ if ($scope.ngSearch) {
384
+ $scope.showSearch = !0;
385
+ }
386
+ if ($scope.ngGet) {
387
+ $scope.showSearch = !0;
388
+ }
389
+
390
+ let input = $(element).find('input.dropdown-text');
391
+ $(element).hover(
392
+ () => {
393
+ if (attrs.disabled !== 'disabled') {
394
+ $scope.popupElement.css('display', 'block');
395
+ }
396
+ },
397
+ () => {
398
+ $scope.popupElement.css('display', 'none');
399
+ }
400
+ );
401
+ $scope.focus = function () {
402
+ $('.i-list .dropdown-content').css('display', 'none');
403
+ $scope.popupElement.css('display', 'block');
404
+ $scope.searchElement.focus();
405
+ };
406
+ $scope.hide = function () {
407
+ $scope.popupElement.css('display', 'none');
408
+ };
409
+
410
+ $scope.getValue = function (item) {
411
+ let v = isite.getValue(item, $scope.display);
412
+ return v || '';
413
+ };
414
+
415
+ $scope.getValue2 = function (item) {
416
+ if ($scope.display2) {
417
+ return isite.getValue(item, $scope.display2) || '';
418
+ }
419
+ return '';
420
+ };
421
+
422
+ $scope.getNgModelValue = function (ngModel) {
423
+ if (ngModel && $scope.display && $scope.ngValue) {
424
+ return isite.getValue(ngModel, $scope.display.replace($scope.ngValue + '.', '')) || '';
425
+ } else if (ngModel && $scope.display) {
426
+ return isite.getValue(ngModel, $scope.display) || '';
427
+ }
428
+ return '';
429
+ };
430
+
431
+ $scope.getNgModelValue2 = function (ngModel) {
432
+ if (ngModel && $scope.display2 && $scope.ngValue) {
433
+ return isite.getValue(ngModel, $scope.display2.replace($scope.ngValue + '.', '')) || '';
434
+ } else if (ngModel && $scope.display2) {
435
+ return isite.getValue(ngModel, $scope.display2) || '';
436
+ }
437
+ return '';
438
+ };
439
+
440
+ $scope.getNgValue = function (item) {
441
+ if (item && $scope.ngValue) {
442
+ return isite.getValue(item, $scope.ngValue);
443
+ }
444
+ return item;
445
+ };
446
+
447
+ $scope.$watch('items', (items) => {
448
+ input.val('');
449
+
450
+ if (items) {
451
+ items.forEach((item) => {
452
+ if ($scope.display2) {
453
+ item.$display = $scope.getValue(item) + $scope.space + $scope.getValue2(item);
454
+ } else {
455
+ item.$display = $scope.getValue(item);
456
+ }
457
+ });
458
+ }
459
+
460
+ if (items && $scope.ngModel) {
461
+ items.forEach((item) => {
462
+ if (isite.getValue(item, $scope.primary) == isite.getValue($scope.ngModel, $scope.primary)) {
463
+ $scope.ngModel = item;
464
+ if ($scope.display2) {
465
+ item.$display = $scope.getValue(item) + $scope.space + $scope.getValue2(item);
466
+ } else {
467
+ item.$display = $scope.getValue(item);
468
+ }
469
+
470
+ input.val(item.$display);
471
+ }
472
+ });
473
+ }
474
+ });
475
+
476
+ $scope.$watch('ngModel', (ngModel) => {
477
+ input.val('');
478
+
479
+ $scope.ngModel = ngModel;
480
+
481
+ if (ngModel) {
482
+ if ($scope.display2) {
483
+ input.val(' ' + $scope.getNgModelValue(ngModel) + $scope.space + $scope.getNgModelValue2(ngModel));
484
+ } else {
485
+ input.val(' ' + $scope.getNgModelValue(ngModel));
486
+ }
487
+ }
488
+ });
489
+
490
+ $scope.searchElement.on('input', () => {
491
+ $timeout(() => {
492
+ if (attrs.ngGet) {
493
+ $scope.ngGet({ $search: $scope.searchElement.val() });
494
+ } else {
495
+ $scope.$filter = $scope.searchElement.val();
496
+ }
497
+ }, 100);
498
+ });
499
+
500
+ $scope.updateModel = function (item) {
501
+ if (item) {
502
+ $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
503
+ if ($scope.display2) {
504
+ input.val($scope.getNgModelValue($scope.ngModel) + $scope.space + $scope.getNgModelValue2($scope.ngModel));
505
+ } else {
506
+ input.val($scope.getNgModelValue($scope.ngModel));
507
+ }
508
+ } else {
509
+ $scope.ngModel = null;
510
+ input.val('');
511
+ }
512
+
513
+ $timeout(() => {
514
+ if ($scope.ngChange) {
515
+ $scope.ngChange();
516
+ }
517
+ }, 100);
518
+ $scope.hide();
519
+ };
520
+ },
521
+ template: `/*##client-side/directive/i-list.html*/`,
522
+ };
523
+ },
524
+ ]);
525
+ app.directive('iChecklist', [
526
+ '$interval',
527
+ '$timeout',
528
+ function ($interval, $timeout) {
529
+ return {
530
+ restrict: 'E',
531
+ required: 'ngModel',
532
+ scope: {
533
+ label: '@',
534
+ primary: '@',
535
+ display: '@',
536
+ class2: '@',
537
+ ngModel: '=',
538
+ items: '=',
539
+ like: '&',
540
+ ngChange: '&',
541
+ },
542
+ link: function ($scope, element, attrs, ctrl) {
543
+ $scope.primary = $scope.primary || 'id';
544
+ $scope.display = $scope.display || 'name';
545
+ $scope.class2 = $scope.class2 || 'col3';
546
+ $scope.selectedItems = [];
547
+
548
+ $scope.$watch('ngModel', (ngModel) => {
549
+ $scope.reload();
550
+ });
551
+ $scope.$watch('items', (ngModel) => {
552
+ $scope.reload();
553
+ });
554
+ $scope.reload = function () {
555
+ $scope.selectedItems = [];
556
+
557
+ if ($scope.ngModel) {
558
+ $scope.ngModel.forEach((mitem) => {
559
+ $scope.selectedItems.push(mitem);
560
+ });
561
+
562
+ if ($scope.items) {
563
+ $scope.items.forEach((mitem) => {
564
+ let exist = !1;
565
+ $scope.selectedItems.forEach((sitem) => {
566
+ if (mitem[$scope.primary] === sitem[$scope.primary]) {
567
+ exist = !0;
568
+ }
569
+ });
570
+ if (exist) {
571
+ mitem.$selected = !0;
572
+ } else {
573
+ mitem.$selected = !1;
574
+ }
575
+ });
576
+ }
577
+ }
578
+ if (!$scope.ngModel) {
579
+ $scope.selectedItems = [];
580
+ if ($scope.items) {
581
+ $scope.items.forEach((mitem) => {
582
+ mitem.$selected = !1;
583
+ });
584
+ }
585
+ }
586
+ };
587
+
588
+ $scope.change = function (item) {
589
+ if (item.$selected) {
590
+ let exsits = !1;
591
+ $scope.selectedItems.forEach((sitem) => {
592
+ if (sitem[$scope.primary] === item[$scope.primary]) {
593
+ exsits = !0;
594
+ }
595
+ });
596
+ if (!exsits) {
597
+ let nitem = { ...item };
598
+ delete nitem.$selected;
599
+ delete nitem.$$hashKey;
600
+ $scope.selectedItems.push(nitem);
601
+ }
602
+ } else {
603
+ $scope.selectedItems.forEach((sitem, index) => {
604
+ if (sitem[$scope.primary] === item[$scope.primary]) {
605
+ $scope.selectedItems.splice(index, 1);
606
+ }
607
+ });
608
+ }
609
+
610
+ $scope.ngModel = $scope.selectedItems;
611
+ $timeout(() => {
612
+ if ($scope.ngChange) {
613
+ $scope.ngChange();
614
+ }
615
+ }, 100);
616
+ };
617
+ },
618
+ template: `/*##client-side/directive/i-checklist.html*/`,
619
+ };
620
+ },
621
+ ]);
622
+
623
+ app.directive('iDate', function ($timeout) {
624
+ return {
625
+ restrict: 'E',
626
+ required: 'ngModel',
627
+ scope: {
628
+ v: '@',
629
+ id2: '@',
630
+ label: '@',
631
+ type: '@',
632
+ class2: '@',
633
+ disabled: '@',
634
+ ngModel: '=',
635
+ ngChange: '&',
636
+ ngKeydown: '&',
637
+ },
638
+ link: function ($scope, element, attrs) {
639
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
640
+ $scope.v = $scope.v || '';
641
+ $scope.requird = '';
642
+ if ($scope.v.like('*r*')) {
643
+ $scope.requird = '*';
644
+ }
645
+ if (typeof attrs.disabled !== 'undefined') {
646
+ attrs.disabled = 'disabled';
647
+ } else {
648
+ attrs.disabled = '';
649
+ }
650
+ $scope.class2 = $scope.class2 || '';
651
+
652
+ $scope.model = {};
653
+
654
+ $scope.lang = site.session ? site.session.lang : 'en';
655
+ if ($scope.lang === 'ar') {
656
+ $scope.monthes = [
657
+ { id: 0, name: 'يناير' },
658
+ { id: 1, name: 'فبراير' },
659
+ { id: 2, name: 'مارس' },
660
+ { id: 3, name: 'ابريل' },
661
+ { id: 4, name: 'مايو' },
662
+ { id: 5, name: 'يونيو' },
663
+ { id: 6, name: 'يوليو' },
664
+ { id: 7, name: 'اغسطس' },
665
+ { id: 8, name: 'سبتمبر' },
666
+ { id: 9, name: 'اكتوبر' },
667
+ { id: 10, name: 'نوفمبر' },
668
+ { id: 11, name: 'ديسمبر' },
669
+ ];
670
+ } else {
671
+ $scope.monthes = [
672
+ { id: 0, name: 'January' },
673
+ { id: 1, name: 'February' },
674
+ { id: 2, name: 'March' },
675
+ { id: 3, name: 'April' },
676
+ { id: 4, name: 'May' },
677
+ { id: 5, name: 'June' },
678
+ { id: 6, name: 'July' },
679
+ { id: 7, name: 'August' },
680
+ { id: 8, name: 'September' },
681
+ { id: 9, name: 'October' },
682
+ { id: 10, name: 'November' },
683
+ { id: 11, name: 'December' },
684
+ ];
685
+ }
686
+
687
+ $scope.$watch('ngModel', function (ngModel) {
688
+ if (ngModel) {
689
+ ngModel = new Date(ngModel);
690
+ $scope.model = $scope.model || {};
691
+ $scope.model.selectedDay = site.addZero(ngModel.getDate(), 2);
692
+ $scope.model.selectedMonth = $scope.monthes.find((m) => m.id == ngModel.getMonth());
693
+ $scope.model.selectedYear = ngModel.getFullYear();
694
+ $(element).attr('value', ngModel.getTime());
695
+ $scope.ngModel1 = new Date(ngModel);
696
+ } else {
697
+ $scope.model = $scope.model || {};
698
+ $scope.model.selectedDay = null;
699
+ $scope.model.selectedMonth = null;
700
+ $scope.model.selectedYear = null;
701
+ $(element).attr('value', '');
702
+ }
703
+ });
704
+
705
+ $scope.setDay = function () {
706
+ $scope.ngModel = new Date();
707
+ };
708
+ $scope.updateDate = function (date) {
709
+ if ($scope.ngModel1) {
710
+ $scope.ngModel = $scope.ngModel1;
711
+ $scope.editOnly = false;
712
+
713
+ if ($scope.ngChange) {
714
+ $scope.ngChange();
715
+ }
716
+ }
717
+ };
718
+ },
719
+ restrict: 'E',
720
+ require: 'ngModel',
721
+ scope: {
722
+ v: '@',
723
+ disabled: '@',
724
+ label: '@',
725
+ ngModel: '=',
726
+ },
727
+ template: `/*##client-side/directive/i-date.html*/`,
728
+ };
729
+ });
730
+
731
+ app.directive('iDatetime', function () {
732
+ return {
733
+ restrict: 'E',
734
+ required: 'ngModel',
735
+ scope: {
736
+ v: '@',
737
+ id2: '@',
738
+ label: '@',
739
+ type: '@',
740
+ class2: '@',
741
+ disabled: '@',
742
+ ngModel: '=',
743
+ ngChange: '&',
744
+ ngKeydown: '&',
745
+ },
746
+ link: function ($scope, element, attrs) {
747
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
748
+ $scope.v = $scope.v || '';
749
+ $scope.requird = '';
750
+ if ($scope.v.like('*r*')) {
751
+ $scope.requird = '*';
752
+ }
753
+ if (typeof attrs.disabled !== 'undefined') {
754
+ attrs.disabled = 'disabled';
755
+ } else {
756
+ attrs.disabled = '';
757
+ }
758
+ $scope.class2 = $scope.class2 || '';
759
+
760
+ $scope.model = {};
761
+
762
+ $scope.lang = site.session ? site.session.lang : 'en';
763
+ if ($scope.lang === 'ar') {
764
+ $scope.monthes = [
765
+ { id: 0, name: 'يناير' },
766
+ { id: 1, name: 'فبراير' },
767
+ { id: 2, name: 'مارس' },
768
+ { id: 3, name: 'ابريل' },
769
+ { id: 4, name: 'مايو' },
770
+ { id: 5, name: 'يونيو' },
771
+ { id: 6, name: 'يوليو' },
772
+ { id: 7, name: 'اغسطس' },
773
+ { id: 8, name: 'سبتمبر' },
774
+ { id: 9, name: 'اكتوبر' },
775
+ { id: 10, name: 'نوفمبر' },
776
+ { id: 11, name: 'ديسمبر' },
777
+ ];
778
+ } else {
779
+ $scope.monthes = [
780
+ { id: 0, name: 'January' },
781
+ { id: 1, name: 'February' },
782
+ { id: 2, name: 'March' },
783
+ { id: 3, name: 'April' },
784
+ { id: 4, name: 'May' },
785
+ { id: 5, name: 'June' },
786
+ { id: 6, name: 'July' },
787
+ { id: 7, name: 'August' },
788
+ { id: 8, name: 'September' },
789
+ { id: 9, name: 'October' },
790
+ { id: 10, name: 'November' },
791
+ { id: 11, name: 'December' },
792
+ ];
793
+ }
794
+
795
+ $scope.$watch('ngModel', function (ngModel) {
796
+ if (ngModel) {
797
+ ngModel = new Date(ngModel);
798
+ $scope.model = $scope.model || {};
799
+ $scope.model.selectedDay = site.addZero(ngModel.getDate(), 2);
800
+ $scope.model.selectedMonth = $scope.monthes.find((m) => m.id == ngModel.getMonth());
801
+ $scope.model.selectedYear = ngModel.getFullYear();
802
+ $scope.model.selectedHour = site.addZero(ngModel.getHours(), 2);
803
+ $scope.model.selectedMinute = site.addZero(ngModel.getMinutes(), 2);
804
+
805
+ $scope.ngModel1 = new Date(ngModel);
806
+ $scope.ngModel2 = new Date(0, 0, 0, ngModel.getHours(), ngModel.getMinutes());
807
+ $(element).attr('value', ngModel.getTime());
808
+ } else {
809
+ $scope.model = $scope.model || {};
810
+ $scope.model.selectedDay = null;
811
+ $scope.model.selectedMonth = null;
812
+ $scope.model.selectedYear = null;
813
+ $scope.model.selectedHour = null;
814
+ $scope.model.selectedMinute = null;
815
+ $(element).attr('value', '');
816
+ }
817
+ });
818
+
819
+ $scope.setDay = function () {
820
+ $scope.ngModel = new Date();
821
+ };
822
+
823
+ $scope.updateDate = function (date) {
824
+ let time = $('#time_' + $scope.id2).val();
825
+
826
+ if ($scope.ngModel1 && time) {
827
+ $scope.ngModel = new Date($scope.ngModel1.getFullYear(), $scope.ngModel1.getMonth(), $scope.ngModel1.getDate(), time.split(':')[0], time.split(':')[1], 0);
828
+ $scope.editOnly = false;
829
+ $(element).attr('value', $scope.ngModel.getTime());
830
+ if ($scope.ngChange) {
831
+ $scope.ngChange();
832
+ }
833
+ }
834
+ };
835
+ },
836
+ restrict: 'E',
837
+ require: 'ngModel',
838
+ scope: {
839
+ v: '@',
840
+ disabled: '@',
841
+ label: '@',
842
+ ngModel: '=',
843
+ },
844
+ template: `/*##client-side/directive/i-datetime.html*/`,
845
+ };
846
+ });
847
+
848
+ app.directive('iFile', [
849
+ '$interval',
850
+ 'isite',
851
+ '$timeout',
852
+ function ($interval, isite, $timeout) {
853
+ return {
854
+ restrict: 'E',
855
+ required: 'ngModel',
856
+ scope: {
857
+ label: '@',
858
+ view: '@',
859
+ accept: '@',
860
+ folder: '@',
861
+ ngModel: '=',
862
+ ngClick: '&',
863
+ onSelected: '&',
864
+ ngChange: '&',
865
+ },
866
+ link: function ($scope, element, attrs, ctrl) {
867
+ $scope.label = $scope.label || '';
868
+ $scope.folder = $scope.folder || 'default';
869
+ $scope.accept = $scope.accept ? $scope.accept : '';
870
+ $scope.viewOnly = $scope.view === undefined ? false : true;
871
+
872
+ let input = $(element).find('input')[0];
873
+ let button = $(element).find('i-button')[0];
874
+
875
+ let progress = $(element).find('.progress')[0];
876
+ let progressBar = $(element).find('.progress-bar')[0];
877
+ $(progress).hide();
878
+
879
+ $scope.id = Math.random().toString().replace('.', '_');
880
+
881
+ if (!$scope.viewOnly) {
882
+ button.addEventListener('click', function () {
883
+ input.click();
884
+ });
885
+ }
886
+
887
+ input.addEventListener('change', function () {
888
+ isite.uploadFile(
889
+ this.files,
890
+ {
891
+ folder: $scope.folder,
892
+ },
893
+ (err, file, e) => {
894
+ if (e) {
895
+ $(progress).show();
896
+ $scope.value = (e.loaded / e.total) * 100;
897
+ progressBar.style.width = $scope.value + '%';
898
+ $scope.max = e.total;
899
+ if ($scope.value === 100) {
900
+ $(progress).hide();
901
+ }
902
+ }
903
+
904
+ if (file) {
905
+ $scope.ngModel = file;
906
+ $scope.changed();
907
+ }
908
+ }
909
+ );
910
+ $scope.ngModel = this.files[0].path;
911
+ $scope.onSelected(this.files[0].path);
912
+ $scope.$applyAsync();
913
+ });
914
+
915
+ $scope.$watch('ngModel', (ngModel) => {
916
+ if (ngModel) {
917
+ button.setAttribute('url', ngModel);
918
+ }
919
+ });
920
+
921
+ $scope.changed = function () {
922
+ $timeout(() => {
923
+ if ($scope.ngChange) {
924
+ $scope.ngChange();
925
+ }
926
+ }, 200);
927
+ };
928
+ },
929
+ template: `/*##client-side/directive/i-file.html*/`,
930
+ };
931
+ },
932
+ ]);
933
+
934
+ app.directive('iImage', [
935
+ '$interval',
936
+ 'isite',
937
+ '$timeout',
938
+ function ($interval, isite, $timeout) {
939
+ return {
940
+ restrict: 'E',
941
+ required: 'ngModel',
942
+ scope: {
943
+ folder: '@',
944
+ view: '@',
945
+ accept: '@',
946
+ ngModel: '=',
947
+ ngClick: '&',
948
+ ngChange: '&',
949
+ },
950
+ link: function ($scope, element, attrs, ctrl) {
951
+ $scope.accept = $scope.accept ? $scope.accept : 'image/*';
952
+ $scope.viewOnly = $scope.view === undefined ? false : true;
953
+
954
+ let input = $(element).find('input')[0];
955
+ let img = $(element).find('img')[0];
956
+ let progress = $(element).find('.progress')[0];
957
+ $(progress).hide();
958
+
959
+ $scope.upload = function () {
960
+ if (!$scope.viewOnly) {
961
+ input.click();
962
+ }
963
+ };
964
+ $scope.delete = function () {
965
+ img.src = null;
966
+ $scope.ngModel = null;
967
+ };
968
+
969
+ input.addEventListener('change', function () {
970
+ isite.uploadImage(
971
+ this.files,
972
+ {
973
+ folder: $scope.folder,
974
+ },
975
+ (err, image, e) => {
976
+ if (e) {
977
+ $(progress).show();
978
+ $scope.value = (e.loaded / e.total) * 100;
979
+ $scope.max = e.total;
980
+ $(progress).css('width', $scope.value);
981
+ if ($scope.value === 100) {
982
+ $(progress).hide();
983
+ }
984
+ }
985
+
986
+ if (image) {
987
+ $scope.ngModel = image;
988
+ if ($scope.ngChange) {
989
+ $timeout(() => {
990
+ $scope.ngChange();
991
+ }, 200);
992
+ }
993
+ }
994
+ }
995
+ );
996
+ });
997
+
998
+ $scope.$watch('ngModel', (ngModel) => {
999
+ if (ngModel) {
1000
+ img.setAttribute('src', ngModel.url);
1001
+ }
1002
+ });
1003
+ },
1004
+ template: `/*##client-side/directive/i-image.html*/`,
1005
+ };
1006
+ },
1007
+ ]);
1008
+
1009
+ app.directive('iAudio', [
1010
+ '$interval',
1011
+ 'isite',
1012
+ '$timeout',
1013
+ function ($interval, isite, $timeout) {
1014
+ return {
1015
+ restrict: 'E',
1016
+ required: 'ngModel',
1017
+ scope: {
1018
+ folder: '@',
1019
+ view: '@',
1020
+ accept: '@',
1021
+ ngModel: '=',
1022
+ ngClick: '&',
1023
+ ngChange: '&',
1024
+ },
1025
+ link: function ($scope, element, attrs, ctrl) {
1026
+ $scope.folder = $scope.folder || 'default';
1027
+ $scope.accept = $scope.accept ? $scope.accept : '.mp3';
1028
+ $scope.viewOnly = $scope.view === undefined ? false : true;
1029
+
1030
+ let input = $(element).find('input')[0];
1031
+ let audio = $(element).find('audio')[0];
1032
+ let progress = $(element).find('.progress')[0];
1033
+ $(progress).hide();
1034
+
1035
+ $scope.upload = function () {
1036
+ if (!$scope.viewOnly) {
1037
+ input.click();
1038
+ }
1039
+ };
1040
+ $scope.delete = function () {
1041
+ $scope.ngModel = null;
1042
+ audio.setAttribute('src', null);
1043
+ };
1044
+
1045
+ input.addEventListener('change', function () {
1046
+ isite.uploadAudio(
1047
+ this.files,
1048
+ {
1049
+ folder: $scope.folder,
1050
+ },
1051
+ (err, audio, e) => {
1052
+ if (e) {
1053
+ $(progress).show();
1054
+ $scope.value = (e.loaded / e.total) * 100;
1055
+ $scope.max = e.total;
1056
+ $(progress).css('width', $scope.value);
1057
+ if ($scope.value === 100) {
1058
+ $(progress).hide();
1059
+ }
1060
+ }
1061
+
1062
+ if (audio) {
1063
+ $scope.ngModel = audio;
1064
+ if ($scope.ngChange) {
1065
+ $timeout(() => {
1066
+ $scope.ngChange();
1067
+ }, 200);
1068
+ }
1069
+ }
1070
+ }
1071
+ );
1072
+ });
1073
+
1074
+ $scope.$watch('ngModel', (ngModel) => {
1075
+ if (ngModel) {
1076
+ audio.setAttribute('src', ngModel.url);
1077
+ audio.setAttribute('type', 'audio/mpeg');
1078
+ }
1079
+ });
1080
+ },
1081
+ template: `/*##client-side/directive/i-audio.html*/`,
1082
+ };
1083
+ },
1084
+ ]);
1085
+
1086
+ app.directive('iVideo', [
1087
+ '$interval',
1088
+ 'isite',
1089
+ '$timeout',
1090
+ function ($interval, isite, $timeout) {
1091
+ return {
1092
+ restrict: 'E',
1093
+ required: 'ngModel',
1094
+ scope: {
1095
+ folder: '@',
1096
+ view: '@',
1097
+ accept: '@',
1098
+ ngModel: '=',
1099
+ ngClick: '&',
1100
+ ngChange: '&',
1101
+ },
1102
+ link: function ($scope, element, attrs, ctrl) {
1103
+ $scope.folder = $scope.folder || 'default';
1104
+ $scope.accept = $scope.accept ? $scope.accept : '.mp4';
1105
+ $scope.viewOnly = $scope.view === undefined ? false : true;
1106
+
1107
+ let input = $(element).find('input')[0];
1108
+ let video = $(element).find('video')[0];
1109
+ let progress = $(element).find('.progress')[0];
1110
+ $(progress).hide();
1111
+
1112
+ $scope.upload = function () {
1113
+ if (!$scope.viewOnly) {
1114
+ input.click();
1115
+ }
1116
+ };
1117
+ $scope.delete = function () {
1118
+ $scope.ngModel = null;
1119
+ video.setAttribute('src', null);
1120
+ };
1121
+
1122
+ input.addEventListener('change', function () {
1123
+ isite.uploadVideo(
1124
+ this.files,
1125
+ {
1126
+ folder: $scope.folder,
1127
+ },
1128
+ (err, video, e) => {
1129
+ if (e) {
1130
+ $(progress).show();
1131
+ $scope.value = (e.loaded / e.total) * 100;
1132
+ $scope.max = e.total;
1133
+ $(progress).css('width', $scope.value);
1134
+ if ($scope.value === 100) {
1135
+ $(progress).hide();
1136
+ }
1137
+ }
1138
+
1139
+ if (video) {
1140
+ $scope.ngModel = video;
1141
+ if ($scope.ngChange) {
1142
+ $timeout(() => {
1143
+ $scope.ngChange();
1144
+ }, 200);
1145
+ }
1146
+ }
1147
+ }
1148
+ );
1149
+ });
1150
+
1151
+ $scope.capture = function () {
1152
+ let canvas = document.createElement('canvas');
1153
+ canvas.width = video.videoWidth / 4;
1154
+ canvas.height = video.videoHeight / 4;
1155
+ canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
1156
+ $scope.ngModel.imageURL = canvas.toDataURL('image/jpeg');
1157
+ };
1158
+
1159
+ video.addEventListener(
1160
+ 'canplay',
1161
+ function (e) {
1162
+ $timeout(() => {
1163
+ $scope.capture();
1164
+ }, 2000);
1165
+ },
1166
+ false
1167
+ );
1168
+
1169
+ $scope.$watch('ngModel', (ngModel) => {
1170
+ if (ngModel) {
1171
+ video.setAttribute('src', ngModel.url);
1172
+ video.setAttribute('type', 'video/mp4');
1173
+ video.load();
1174
+ }
1175
+ });
1176
+ },
1177
+ template: `/*##client-side/directive/i-video.html*/`,
1178
+ };
1179
+ },
1180
+ ]);
1181
+
1182
+ app.directive('iUpload', [
1183
+ '$interval',
1184
+ 'isite',
1185
+ function ($interval, isite) {
1186
+ return {
1187
+ restrict: 'E',
1188
+ scope: {
1189
+ label: '@',
1190
+ api: '@',
1191
+ type: '@',
1192
+ view: '@',
1193
+ ngClick: '&',
1194
+ onUploaded: '&',
1195
+ },
1196
+ link: function ($scope, element, attrs, ctrl) {
1197
+ let input = $(element).find('input')[0];
1198
+ let a = $(element).find('button')[0];
1199
+ let progress = $(element).find('progress')[0];
1200
+ $(progress).hide();
1201
+
1202
+ if (attrs.view !== '') {
1203
+ a.addEventListener('click', function () {
1204
+ input.click();
1205
+ });
1206
+ }
1207
+
1208
+ input.addEventListener('change', function () {
1209
+ if ($scope.api) {
1210
+ isite.upload(
1211
+ this.files,
1212
+ {
1213
+ api: $scope.api,
1214
+ },
1215
+ (err, data, e) => {
1216
+ if (e) {
1217
+ $(progress).show();
1218
+ progress.value = e.loaded;
1219
+ progress.max = e.total;
1220
+ } else if (data) {
1221
+ if ($scope.onUploaded) {
1222
+ $scope.onUploaded({ $data: data });
1223
+ }
1224
+ }
1225
+ }
1226
+ );
1227
+ }
1228
+ });
1229
+ },
1230
+ template: `/*##client-side/directive/i-upload.html*/`,
1231
+ };
1232
+ },
1233
+ ]);
1234
+
1235
+ app.directive('iTreeview', [
1236
+ '$interval',
1237
+ '$timeout',
1238
+ 'isite',
1239
+ function ($interval, $timeout, isite) {
1240
+ return {
1241
+ restrict: 'E',
1242
+ require: 'ngModel',
1243
+ scope: {
1244
+ v: '@',
1245
+ label: '@',
1246
+ display: '@',
1247
+ display2: '@',
1248
+ disabled: '@',
1249
+ space: '@',
1250
+ primary: '@',
1251
+ ngValue: '@',
1252
+ ngModel: '=',
1253
+ ngSearch: '=',
1254
+ ngChange: '&',
1255
+ ngClick: '&',
1256
+ ngAdd: '&',
1257
+ ngNode: '&',
1258
+ ngEdit: '&',
1259
+ ngDelete: '&',
1260
+ nodes: '=',
1261
+ },
1262
+ link: function ($scope, element, attrs, ctrl) {
1263
+ attrs.display = attrs.display || 'name';
1264
+ attrs.primary = attrs.primary || 'id';
1265
+ attrs.space = attrs.space || ' ';
1266
+ attrs.ngValue = attrs.ngValue || '';
1267
+
1268
+ $scope.source = {};
1269
+
1270
+ $scope.setNodes = function (v_node) {
1271
+ v_node.nodes.forEach((v_node2) => {
1272
+ v_node2.nodes = v_node2.nodes || [];
1273
+ $scope.nodes.forEach((node) => {
1274
+ if (node.$parent_id == v_node2.id) {
1275
+ node.v_display = node.v_display || '';
1276
+ node.v_display += node[attrs.display];
1277
+
1278
+ let exist = !1;
1279
+ v_node2.nodes.forEach((n) => {
1280
+ if (n.id == node.id) {
1281
+ exist = !0;
1282
+ }
1283
+ });
1284
+ if (!exist) {
1285
+ v_node2.nodes.push(node);
1286
+ }
1287
+ }
1288
+ });
1289
+ $scope.setNodes(v_node2);
1290
+ });
1291
+ };
1292
+
1293
+ $scope.v_nodes = [];
1294
+
1295
+ $scope.$watch('ngModel', (ngModel) => {
1296
+ if (ngModel) {
1297
+ $scope.ngModel = ngModel;
1298
+ $scope.ngModel.v_display = $scope.ngModel.v_display || ngModel[attrs.display];
1299
+ }
1300
+ });
1301
+
1302
+ $scope.$watch('nodes', (nodes) => {
1303
+ $scope.v_nodes = [];
1304
+ if (nodes) {
1305
+ nodes.forEach((node) => {
1306
+ node.$parent_id = node.parent_id || node.parentId || 0;
1307
+ node.v_display = node.v_display || '';
1308
+ node.v_display += node[attrs.display];
1309
+ if (node.$parent_id == 0) {
1310
+ let exist = !1;
1311
+ $scope.v_nodes.forEach((n) => {
1312
+ if (n.id == node.id) {
1313
+ exist = !0;
1314
+ }
1315
+ });
1316
+ if (!exist) {
1317
+ $scope.v_nodes.push(node);
1318
+ }
1319
+ }
1320
+ });
1321
+
1322
+ $scope.v_nodes.forEach((v_node) => {
1323
+ v_node.nodes = v_node.nodes || [];
1324
+
1325
+ nodes.forEach((node) => {
1326
+ node.$parent_id = node.parent_id || node.parentId || 0;
1327
+ if (node.$parent_id == v_node.id) {
1328
+ node.v_display = node.v_display || '';
1329
+ node.v_display += node[attrs.display];
1330
+
1331
+ let exist = !1;
1332
+ v_node.nodes.forEach((n) => {
1333
+ if (n.id == node.id) {
1334
+ exist = !0;
1335
+ }
1336
+ });
1337
+ if (!exist) {
1338
+ v_node.nodes.push(node);
1339
+ }
1340
+ }
1341
+ });
1342
+
1343
+ $scope.setNodes(v_node);
1344
+ });
1345
+ }
1346
+ });
1347
+ },
1348
+ template: `/*##client-side/directive/i-treeview.html*/`,
1349
+ };
1350
+ },
1351
+ ]);
1352
+
1353
+ app.directive('iTreenode', [
1354
+ '$interval',
1355
+ '$timeout',
1356
+ 'isite',
1357
+ function ($interval, $timeout, isite) {
1358
+ return {
1359
+ restrict: 'E',
1360
+ require: 'ngModel',
1361
+ scope: {
1362
+ v: '@',
1363
+ label: '@',
1364
+ display: '@',
1365
+ display2: '@',
1366
+ disabled: '@',
1367
+ space: '@',
1368
+ primary: '@',
1369
+ ngValue: '@',
1370
+ ngChange: '&',
1371
+ ngClick: '&',
1372
+ ngAdd: '&',
1373
+ ngEdit: '&',
1374
+ ngDelete: '&',
1375
+ ngModel: '=',
1376
+ ngSearch: '=',
1377
+ nodes: '=',
1378
+ nodes: '=',
1379
+ },
1380
+ link: function ($scope, element, attrs, ctrl) {
1381
+ attrs.display = attrs.display || 'name';
1382
+ attrs.primary = attrs.primary || 'id';
1383
+ attrs.space = attrs.space || ' ';
1384
+ attrs.ngValue = attrs.ngValue || '';
1385
+ $scope.nodes = $scope.nodes || [];
1386
+
1387
+ $scope.v_nodes = [];
1388
+
1389
+ $scope.$watch('nodes', (nodes) => {
1390
+ $scope.v_nodes = [];
1391
+ if (nodes) {
1392
+ nodes.forEach((node, i) => {
1393
+ if (node.nodes) {
1394
+ node.nodes.forEach((node2, i) => {
1395
+ node2.$parent_id = node2.parent_id || node.id;
1396
+ node2.v_display = node.v_display || ' ';
1397
+ node2.v_display += ' - ' + node2[attrs.display];
1398
+ });
1399
+ }
1400
+ });
1401
+ }
1402
+ });
1403
+
1404
+ $scope.updateParentModal = function (parent, node) {
1405
+ if (parent) {
1406
+ parent.ngModel = node;
1407
+ if (parent.$parent) {
1408
+ $scope.updateParentModal(parent.$parent, node);
1409
+ }
1410
+ }
1411
+ };
1412
+
1413
+ $scope.unSelectParent = function (parent) {
1414
+ if (parent && parent.nodes) {
1415
+ parent.nodes.forEach((node) => {
1416
+ node.$selected = !1;
1417
+ });
1418
+ if (parent.$parent) {
1419
+ $scope.unSelectParent(parent.$parent);
1420
+ }
1421
+ }
1422
+ };
1423
+
1424
+ $scope.unSelectNodes = function (nodes) {
1425
+ if (nodes) {
1426
+ nodes.forEach((node) => {
1427
+ node.$selected = !1;
1428
+ if (node.nodes) {
1429
+ $scope.unSelectNodes(node.nodes);
1430
+ }
1431
+ });
1432
+ }
1433
+ };
1434
+
1435
+ $scope.updateModal = function (node) {
1436
+ $scope.ngModel = node;
1437
+ $scope.updateParentModal($scope.$parent, node);
1438
+ };
1439
+
1440
+ $scope.selected = function (node) {
1441
+ $scope.unSelectParent($scope.$parent);
1442
+ $scope.unSelectNodes($scope.nodes);
1443
+
1444
+ if (node.nodes) {
1445
+ node.nodes.forEach((itm) => {
1446
+ itm.$selected = !1;
1447
+ });
1448
+ }
1449
+
1450
+ node.$selected = !0;
1451
+ };
1452
+ },
1453
+ template: `/*##client-side/directive/i-treenode.html*/`,
1454
+ };
1455
+ },
1456
+ ]);