isite 2022.8.5 → 2022.8.6

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 (39) hide show
  1. package/README.md +7 -7
  2. package/apps/client-side/app.js +251 -185
  3. package/apps/client-side/site_files/css/bootstrap5-addon.css +32 -5
  4. package/apps/client-side/site_files/css/bootstrap5.css +1 -1
  5. package/apps/client-side/site_files/css/bootstrap5.css.map +1 -0
  6. package/apps/client-side/site_files/css/effect.css +136 -77
  7. package/apps/client-side/site_files/css/layout.css +37 -44
  8. package/apps/client-side/site_files/css/modal.css +1 -1
  9. package/apps/client-side/site_files/css/normalize.css +146 -0
  10. package/apps/client-side/site_files/css/scrollbar.css +9 -5
  11. package/apps/client-side/site_files/html/directive/i-button.html +5 -0
  12. package/apps/client-side/site_files/html/directive/i-checkbox.html +4 -0
  13. package/apps/client-side/site_files/html/directive/i-checklist.html +6 -0
  14. package/apps/client-side/site_files/html/directive/i-control.html +5 -0
  15. package/apps/client-side/site_files/html/directive/i-date.html +21 -16
  16. package/apps/client-side/site_files/html/directive/i-datetime.html +31 -0
  17. package/apps/client-side/site_files/html/directive/i-file.html +3 -5
  18. package/apps/client-side/site_files/html/directive/i-list.html +2 -2
  19. package/apps/client-side/site_files/html/directive/i-radio.html +4 -0
  20. package/apps/client-side/site_files/html/directive/i-textarea.html +4 -0
  21. package/apps/client-side/site_files/html/directive/i-treenode.html +20 -0
  22. package/apps/client-side/site_files/html/directive/i-treeview.html +13 -0
  23. package/apps/client-side/site_files/html/directive/i-upload.html +5 -0
  24. package/apps/client-side/site_files/html/directive-core/i-date.html +64 -0
  25. package/apps/client-side/site_files/html/directive-core/i-list.html +22 -0
  26. package/apps/client-side/site_files/js/bootstrap-5-directive.js +226 -234
  27. package/apps/client-side/site_files/js/bootstrap.js.map +1 -0
  28. package/apps/client-side/site_files/js/directive.js +1865 -2044
  29. package/apps/client-side/site_files/js/directive.min.js +2 -2
  30. package/apps/client-side/site_files/js/site.js +1 -1
  31. package/apps/security/site_files/html/login_modal.html +18 -26
  32. package/index.js +2 -5
  33. package/lib/parser.js +519 -509
  34. package/lib/routing.js +21 -15
  35. package/lib/sessions.js +182 -247
  36. package/object-options/index.js +6 -4
  37. package/package.json +3 -2
  38. package/pull.bat +3 -0
  39. package/push.bat +2 -5
@@ -1,2044 +1,1865 @@
1
- var app = app || angular.module('myApp', []);
2
- window.$ = window.jQuery;
3
-
4
- app.filter('xdate', function () {
5
- return function (item) {
6
- if (item) {
7
- if (item.day2) {
8
- return `${item.day} - ${item.month + 1} - ${item.year} -- ${item.day2} - ${item.month2 + 1} - ${item.year2}`;
9
- } else {
10
- return `${item.day} - ${item.month + 1} - ${item.year}`;
11
- }
12
- }
13
- };
14
- });
15
- app.filter('xmoney', function () {
16
- return function (value) {
17
- return site.toMoney(value, false);
18
- };
19
- });
20
- app.filter('xmoney2', function () {
21
- return function (value) {
22
- if (value) {
23
- let arr = value.toString().split('.');
24
- if (arr[1] && arr[1].length === 3 && parseInt(arr[1][2]) === 5) {
25
- arr[1] = arr[1][0] + arr[1][1] + 9;
26
- value = arr.join('.');
27
- }
28
- return parseFloat( value).toFixed(2);
29
- }
30
- return value;
31
- };
32
- });
33
- app.service('isite', [
34
- '$http',
35
- function ($http) {
36
- this.getValue = function (obj, property) {
37
- if (!obj || !property) {
38
- return null;
39
- }
40
-
41
- if (property == '_') {
42
- return obj;
43
- }
44
-
45
- let arr = property.split('.');
46
-
47
- if (arr.length === 1) {
48
- return obj[arr[0]];
49
- }
50
-
51
- if (arr.length === 2) {
52
- return obj[arr[0]][arr[1]];
53
- }
54
-
55
- if (arr.length === 3) {
56
- return obj[arr[0]][arr[1]][arr[2]];
57
- }
58
-
59
- return null;
60
- };
61
-
62
- this.uploadImage = function (files, options, callback) {
63
- options = Object.assign(
64
- {
65
- category: 'default',
66
- },
67
- options
68
- );
69
- callback = callback || function () {};
70
-
71
- var fd = new FormData();
72
- fd.append('fileToUpload', files[0]);
73
- $http
74
- .post('/api/upload/image/' + options.category, fd, {
75
- withCredentials: !0,
76
- headers: {
77
- 'Content-Type': undefined,
78
- },
79
- uploadEventHandlers: {
80
- progress: function (e) {
81
- callback(null, null, e);
82
- },
83
- },
84
- transformRequest: angular.identity,
85
- })
86
- .then(
87
- function (res) {
88
- if (res.data && res.data.done) {
89
- callback(null, res.data.image_url);
90
- }
91
- },
92
- function (error) {
93
- callback(error, null, null);
94
- }
95
- );
96
- };
97
-
98
- this.uploadFile = function (files, options, callback) {
99
- options = Object.assign(
100
- {
101
- category: 'default',
102
- },
103
- options
104
- );
105
- callback = callback || function () {};
106
-
107
- var fd = new FormData();
108
- fd.append('fileToUpload', files[0]);
109
- $http
110
- .post('/api/upload/file/' + options.category, fd, {
111
- withCredentials: !0,
112
- headers: {
113
- 'Content-Type': undefined,
114
- },
115
- uploadEventHandlers: {
116
- progress: function (e) {
117
- callback(null, null, e);
118
- },
119
- },
120
- transformRequest: angular.identity,
121
- })
122
- .then(
123
- function (res) {
124
- if (res.data && res.data.done && res.data.file) {
125
- callback(null, {
126
- name: res.data.file.name,
127
- url: res.data.file.url,
128
- });
129
- }
130
- },
131
- function (error) {
132
- callback(error, null, null);
133
- }
134
- );
135
- };
136
-
137
- this.deleteFile = function (file, callback) {
138
- callback = callback || function () {};
139
- callback();
140
- };
141
-
142
- this.upload = function (files, options, callback) {
143
- options = Object.assign(
144
- {
145
- api: '/api/upload/file',
146
- },
147
- options
148
- );
149
- callback = callback || function () {};
150
-
151
- var fd = new FormData();
152
- fd.append('fileToUpload', files[0]);
153
- $http
154
- .post(options.api, fd, {
155
- withCredentials: !0,
156
- headers: {
157
- 'Content-Type': undefined,
158
- },
159
- uploadEventHandlers: {
160
- progress: function (e) {
161
- callback(null, null, e);
162
- },
163
- },
164
- transformRequest: angular.identity,
165
- })
166
- .then(
167
- function (res) {
168
- if (res.data && res.data.done && res.data.file) {
169
- callback(null, {
170
- name: res.data.file.name,
171
- url: res.data.file.url,
172
- });
173
- }
174
- },
175
- function (error) {
176
- callback(error, null, null);
177
- }
178
- );
179
- };
180
- },
181
- ]);
182
-
183
- app.directive('iDate', function () {
184
- return {
185
- link: function (scope, element, attrs) {
186
- if (typeof attrs.disabled !== 'undefined') {
187
- attrs.disabled = 'disabled';
188
- } else {
189
- attrs.disabled = '';
190
- }
191
-
192
- $(element)
193
- .find('select')
194
- .focus(() => {
195
- $('.popup').hide();
196
- });
197
-
198
- scope.days1 = [];
199
- for (let i = 1; i < 32; i++) {
200
- scope.days1.push(i);
201
- }
202
- scope.years1 = [];
203
- for (let i = 1900; i < 2100; i++) {
204
- scope.years1.push(i);
205
- }
206
- scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
207
- },
208
- restrict: 'E',
209
- require: 'ngModel',
210
- scope: {
211
- v: '@',
212
- label: '@',
213
- disabled: '@',
214
- ngModel: '=',
215
- },
216
- template: `
217
- <div class="row i-date">
218
-
219
- <div class=" control">
220
- <label> {{label}} </label>
221
- <div class="row">
222
- <div class="col3 day">
223
- <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.day" class="appearance-none no-border-left no-border-radius" >
224
- <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
225
- </select>
226
- </div>
227
- <div class="col5 month">
228
- <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.month" class="appearance-none no-border-left no-border-right no-border-radius" >
229
- <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
230
- </select>
231
- </div>
232
- <div class="col4 year">
233
- <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.year" class="appearance-none no-border-right no-border-radius" >
234
- <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
235
- </select>
236
- </div>
237
- </div>
238
- </div>
239
-
240
-
241
- </div>
242
- `,
243
- };
244
- });
245
-
246
- app.directive('iDate2', function () {
247
- return {
248
- link: function ($scope, element, attrs) {
249
- if (typeof attrs.disabled !== 'undefined') {
250
- attrs.disabled = 'disabled';
251
- } else {
252
- attrs.disabled = '';
253
- }
254
-
255
- $scope.y_search = attrs.year || '202';
256
- $scope.m_search = attrs.month || '';
257
- $scope.d_search = attrs.day || '';
258
-
259
- $scope.days1 = [];
260
- for (let i = 1; i < 32; i++) {
261
- $scope.days1.push({
262
- id: i,
263
- name: i,
264
- });
265
- }
266
- $scope.years1 = [];
267
- for (let i = 1900; i < 2100; i++) {
268
- $scope.years1.push({
269
- id: i,
270
- name: i,
271
- });
272
- }
273
-
274
- $scope.monthes1 = [
275
- { id: 0, name: 'يناير / Jan' },
276
- { id: 1, name: 'فبراير / Feb' },
277
- { id: 2, name: 'مارس / Mar' },
278
- { id: 3, name: 'ابريل / Aper' },
279
- { id: 4, name: 'مايو / May' },
280
- { id: 5, name: 'يونيو / June' },
281
- { id: 6, name: 'يوليو / Jule' },
282
- { id: 7, name: 'اغسطس / Aug' },
283
- { id: 8, name: 'سبتمبر / Sep' },
284
- { id: 9, name: 'اكتوبر / Oct' },
285
- { id: 10, name: 'نوفمبر / Nov' },
286
- { id: 11, name: 'ديسمبر / Des' },
287
- ];
288
-
289
- $scope.model = null;
290
-
291
- $scope.$watch('ngModel', function (ngModel) {
292
- if (ngModel) {
293
- ngModel = new Date(ngModel);
294
- $scope.model = $scope.model || {};
295
- $scope.model.day = ngModel.getDate();
296
- $scope.model.day_name = $scope.model.day;
297
- $scope.model.month = ngModel.getMonth();
298
- $scope.model.month_name = $scope.monthes1.find((m) => m.id == $scope.model.month).name;
299
- $scope.model.year = ngModel.getFullYear();
300
- $scope.model.year_name = $scope.model.year;
301
- } else {
302
- $scope.model = $scope.model || {};
303
- $scope.model.day = 0;
304
- $scope.model.day_name = '';
305
- $scope.model.month = -1;
306
- $scope.model.month_name = '';
307
- $scope.model.year = 0;
308
- $scope.model.year_name = '';
309
- }
310
- });
311
-
312
- $scope.setDay = function () {
313
- $scope.ngModel = new Date();
314
- };
315
- $scope.updateDate = function (date) {
316
- if (date.year) {
317
- $scope.model.year = date.year.id;
318
- $scope.model.year_name = date.year.name;
319
- } else if (date.month) {
320
- $scope.model.month = date.month.id;
321
- $scope.model.month_name = date.month.name;
322
- } else if (date.day) {
323
- $scope.model.day = date.day.id;
324
- $scope.model.day_name = date.day.name;
325
- }
326
-
327
- if ($scope.model && $scope.model.year && $scope.model.day && $scope.model.month > -1) {
328
- $scope.ngModel = new Date($scope.model.year, $scope.model.month, $scope.model.day, 0, 0, 0);
329
- } else {
330
- delete $scope.ngModel;
331
- }
332
- };
333
- },
334
- restrict: 'E',
335
- require: 'ngModel',
336
- scope: {
337
- v: '@',
338
- disabled: '@',
339
- label: '@',
340
- ngModel: '=',
341
- },
342
- template: `/*##client-side/directive/i-date.html*/`,
343
- };
344
- });
345
-
346
- app.directive('iTime', function () {
347
- return {
348
- link: function ($scope, element, attrs) {
349
- if (typeof attrs.disabled !== 'undefined') {
350
- attrs.disabled = 'disabled';
351
- } else {
352
- attrs.disabled = '';
353
- }
354
-
355
- $scope.model = {};
356
-
357
- $scope.hours = [];
358
- for (let i = 1; i < 25; i++) {
359
- $scope.hours.push(i);
360
- }
361
-
362
- $scope.minutes = [];
363
- for (let i = 0; i < 60; i++) {
364
- $scope.minutes.push(i);
365
- }
366
-
367
- $(element)
368
- .find('select')
369
- .focus(() => {
370
- $('.popup').hide();
371
- });
372
-
373
- $scope.$watch('ngModel', function (ngModel) {
374
- if (ngModel) {
375
- ngModel.date = new Date(ngModel.date);
376
- $scope.model = $scope.model || {};
377
- $scope.model.hour = ngModel.hour;
378
- $scope.model.minute = ngModel.minute;
379
- } else {
380
- $scope.model = $scope.model || {};
381
- $scope.model.hour = 0;
382
- $scope.model.minute = 0;
383
- }
384
- });
385
-
386
- $scope.updateTime = function () {
387
- if ($scope.model) {
388
- $scope.ngModel = $scope.ngModel || {};
389
- $scope.ngModel.hour = $scope.model.hour;
390
- $scope.ngModel.minute = $scope.model.minute;
391
- $scope.ngModel.date = new Date(null, null, null, $scope.model.hour, $scope.model.minute, null);
392
- } else {
393
- delete $scope.ngModel;
394
- }
395
- };
396
- },
397
- restrict: 'E',
398
- require: 'ngModel',
399
- scope: {
400
- v: '@',
401
- disabled: '@',
402
- label: '@',
403
- ngModel: '=',
404
- },
405
- template: `
406
- <div class="row i-time">
407
- <div class=" control ">
408
- <label class="text-center"> {{label}} </label>
409
- <div class="row">
410
- <div class="col6 right">
411
- <div class="row">
412
- <div class="col2"></div>
413
- <div class="col8">
414
- <select ng-disabled="disabled" ng-model="model.minute" ng-change="updateTime()" class="small appearance-none no-border-left no-border-radius" >
415
- <option ng-repeat="m in minutes" ng-value="m"> {{m}}</option>
416
- </select>
417
- </div>
418
- <div class="col2"></div>
419
- </div>
420
-
421
- </div>
422
- <div class="col6">
423
- <div class="row">
424
- <div class="col2 space right">
425
- <span> : </span>
426
- </div>
427
- <div class="col8">
428
- <select ng-disabled="disabled" ng-model="model.hour" ng-change="updateTime()" class="large blue appearance-none no-border-left no-border-radius" >
429
- <option ng-repeat="h in hours" ng-value="h"> {{h}} </option>
430
- </select>
431
- </div>
432
-
433
- </div>
434
-
435
- </div>
436
- </div>
437
- </div>
438
- `,
439
- };
440
- });
441
-
442
- app.directive('iDatetime2', function () {
443
- return {
444
- link: function ($scope, element, attrs) {
445
- if (typeof attrs.disabled !== 'undefined') {
446
- attrs.disabled = 'disabled';
447
- } else {
448
- attrs.disabled = '';
449
- }
450
-
451
- $scope.hour1 = [];
452
- for (let i = 1; i < 25; i++) {
453
- $scope.hour1.push(i);
454
- }
455
-
456
- $scope.minute_list = [];
457
- for (let i = 1; i < 60; i++) {
458
- $scope.minute_list.push({
459
- name: i,
460
- });
461
- }
462
-
463
- $scope.days1 = [];
464
- for (let i = 1; i < 32; i++) {
465
- $scope.days1.push(i);
466
- }
467
- $scope.years1 = [];
468
- for (let i = 1900; i < 2100; i++) {
469
- $scope.years1.push(i);
470
- }
471
- $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
472
-
473
- $scope.model = null;
474
-
475
- $(element)
476
- .find('select')
477
- .focus(() => {
478
- $('.popup').hide();
479
- });
480
-
481
- $scope.$watch('ngModel', function (ngModel) {
482
- if (ngModel) {
483
- ngModel = new Date(ngModel);
484
- $scope.model = $scope.model || {};
485
- $scope.model.hour = ngModel.getHours();
486
- $scope.model.minute = ngModel.getMinutes();
487
- $scope.model.day = ngModel.getDate();
488
- $scope.model.month = ngModel.getMonth();
489
- $scope.model.year = ngModel.getFullYear();
490
- } else {
491
- $scope.model = $scope.model || {};
492
- $scope.model.hour = 0;
493
- $scope.model.minute = 0;
494
- $scope.model.day = 0;
495
- $scope.model.month = -1;
496
- $scope.model.year = 0;
497
- }
498
- });
499
-
500
- $scope.updateDate = function () {
501
- if ($scope.model && $scope.model.year && $scope.model.day) {
502
- $scope.ngModel = new Date($scope.model.year, $scope.model.month, $scope.model.day, $scope.model.hour, $scope.model.minute);
503
- } else {
504
- delete $scope.ngModel;
505
- }
506
- };
507
- },
508
- restrict: 'E',
509
- require: 'ngModel',
510
- scope: {
511
- v: '@',
512
- disabled: '@',
513
- label: '@',
514
- ngModel: '=',
515
- },
516
- template: `
517
- <div class="row i-datetime2">
518
-
519
- <div class=" control">
520
- <label> {{label}} </label>
521
- <div class="row">
522
-
523
- <div class="col2 day">
524
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.day" ng-change="updateDate()" class="appearance-none no-border-left no-border-radius" >
525
- <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
526
- </select>
527
- </div>
528
- <div class="col5 month">
529
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.month" ng-change="updateDate()" class="appearance-none no-border-left no-border-right no-border-radius" >
530
- <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
531
- </select>
532
- </div>
533
- <div class="col3 year">
534
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.year" ng-change="updateDate()" class="appearance-none no-border-right no-border-radius" >
535
- <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
536
- </select>
537
- </div>
538
-
539
- <div class="col1 hour">
540
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.hour" ng-change="updateDate()" class="appearance-none no-border-radius" >
541
- <option ng-repeat="h1 in hour1" ng-value="h1"> {{h1}} </option>
542
- </select>
543
- </div>
544
- <div class="col1 minute">
545
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.minute" ng-change="updateDate()" class="green appearance-none no-border-right no-border-radius" >
546
- <option ng-repeat="m1 in minute_list" ng-value="m1.name" class="green"> {{m1.name}} </option>
547
- </select>
548
- </div>
549
-
550
- </div>
551
- </div>
552
-
553
-
554
- </div>
555
- `,
556
- };
557
- });
558
-
559
- app.directive('iMonth2', function () {
560
- return {
561
- link: function ($scope, element, attrs) {
562
- if (typeof attrs.disabled !== 'undefined') {
563
- attrs.disabled = 'disabled';
564
- } else {
565
- attrs.disabled = '';
566
- }
567
-
568
- $scope.years = [];
569
- for (let i = 1900; i < 2100; i++) {
570
- $scope.years.push(i);
571
- }
572
- $scope.monthes = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
573
-
574
- $scope.model = null;
575
-
576
- $(element)
577
- .find('select')
578
- .focus(() => {
579
- $('.popup').hide();
580
- });
581
-
582
- $scope.$watch('ngModel', function (ngModel) {
583
- if (ngModel) {
584
- ngModel = new Date(ngModel);
585
- $scope.model = $scope.model || {};
586
- $scope.model.day = 1;
587
- $scope.model.month = ngModel.getMonth();
588
- $scope.model.year = ngModel.getFullYear();
589
- } else {
590
- $scope.model = $scope.model || {};
591
- $scope.model.day = 0;
592
- $scope.model.month = -1;
593
- $scope.model.year = 0;
594
- }
595
- });
596
-
597
- $scope.updateDate = function () {
598
- if ($scope.model && $scope.model.year) {
599
- $scope.ngModel = new Date($scope.model.year, $scope.model.month, 1);
600
- } else {
601
- delete $scope.ngModel;
602
- }
603
- };
604
- },
605
- restrict: 'E',
606
- require: 'ngModel',
607
- scope: {
608
- v: '@',
609
- label: '@',
610
- disabled: '@',
611
- ngModel: '=',
612
- },
613
- template: `
614
- <div class="row i-date2">
615
-
616
- <div class=" control">
617
- <label> {{label}} </label>
618
- <div class="row">
619
-
620
- <div class="col7 month">
621
- <select ng-disabled="disabled" v="{{v}}" ng-model="model.month" ng-change="updateDate()" class="appearance-none no-border-left no-border-radius" >
622
- <option ng-repeat="m1 in monthes" ng-value="$index"> {{m1}} </option>
623
- </select>
624
- </div>
625
-
626
- <div class="col5 year">
627
- <select ng-disabled="disabled" v="{{v}}" ng-model="model.year" ng-change="updateDate()" class="appearance-none no-border-right no-border-radius" >
628
- <option ng-repeat="y1 in years" ng-value="y1"> {{y1}} </option>
629
- </select>
630
- </div>
631
-
632
- </div>
633
- </div>
634
-
635
-
636
- </div>
637
- `,
638
- };
639
- });
640
-
641
- app.directive('iFulldate', [
642
- '$http',
643
- function ($http) {
644
- return {
645
- link: function ($scope, element, attrs, ngModel) {
646
- let _busy = !1;
647
-
648
- if (typeof attrs.disabled !== 'undefined') {
649
- attrs.disabled = 'disabled';
650
- } else {
651
- attrs.disabled = '';
652
- }
653
-
654
- $(element)
655
- .find('select')
656
- .focus(() => {
657
- $('.popup').hide();
658
- });
659
-
660
- $scope.days1 = [];
661
- for (let i = 1; i < 32; i++) {
662
- $scope.days1.push(i);
663
- }
664
- $scope.years1 = [];
665
- for (let i = 1950; i < 2030; i++) {
666
- $scope.years1.push(i);
667
- }
668
-
669
- $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
670
-
671
- $scope.days2 = [];
672
- for (let i = 1; i < 31; i++) {
673
- $scope.days2.push(i);
674
- }
675
- $scope.years2 = [];
676
- for (let i = 1370; i < 1450; i++) {
677
- $scope.years2.push(i);
678
- }
679
- $scope.monthes2 = ['محرم', 'صفر', 'ربيع اول', 'ربيع ثان', 'جمادى اول', 'جمادى ثان', 'رجب', 'شعبان', 'رمضان', 'شوال', 'ذى القعدة', 'ذى الحجة'];
680
-
681
- $scope.model = {};
682
-
683
- $scope.$watch('ngModel', function (ngModel) {
684
- if (ngModel) {
685
- $scope.model = ngModel;
686
- } else {
687
- $scope.model = {};
688
- }
689
- });
690
-
691
- $scope.$watch('ngModel.date', function (date) {
692
- if (date) {
693
- if (typeof date == 'string') {
694
- date = new Date(date);
695
- }
696
- $scope.model = $scope.model || {};
697
- $scope.model.date = date;
698
- $scope.model.day = date.getDate();
699
- $scope.model.month = date.getMonth();
700
- $scope.model.year = date.getFullYear();
701
- $scope.get_hijri_date();
702
- }
703
- });
704
-
705
- $scope.get_hijri_date = function () {
706
- if ($scope.model && $scope.model.year && $scope.model.day) {
707
- ngModel.$setViewValue($scope.model);
708
- if (_busy) {
709
- return;
710
- }
711
- _busy = !0;
712
- $scope.model.date = new Date($scope.model.year, $scope.model.month, $scope.model.day);
713
- $http({
714
- method: 'POST',
715
- url: '/api/get_hijri_date',
716
- data: {
717
- date: $scope.model.year + '/' + ($scope.model.month + 1) + '/' + $scope.model.day,
718
- },
719
- })
720
- .then((response) => {
721
- if (response.data.done) {
722
- $scope.model.hijri = response.data.hijri;
723
- $scope.model.day2 = parseInt($scope.model.hijri.split('/')[2]);
724
- $scope.model.month2 = parseInt($scope.model.hijri.split('/')[1]) - 1;
725
- $scope.model.year2 = parseInt($scope.model.hijri.split('/')[0]);
726
- ngModel.$setViewValue($scope.model);
727
- _busy = !1;
728
- }
729
- })
730
- .catch(() => {
731
- _busy = !1;
732
- });
733
- }
734
- };
735
-
736
- $scope.get_normal_date = function () {
737
- if ($scope.model && $scope.model.year2 && $scope.model.day2) {
738
- ngModel.$setViewValue($scope.model);
739
- if (_busy) {
740
- return;
741
- }
742
- _busy = !0;
743
- $http({
744
- method: 'POST',
745
- url: '/api/get_normal_date',
746
- data: {
747
- hijri: $scope.model.year2 + '/' + ($scope.model.month2 + 1) + '/' + $scope.model.day2,
748
- },
749
- })
750
- .then((response) => {
751
- if (response.data.done) {
752
- $scope.model.date = new Date(response.data.date);
753
- $scope.model.day = parseInt(response.data.date.split('/')[2]);
754
- $scope.model.month = parseInt(response.data.date.split('/')[1]) - 1;
755
- $scope.model.year = parseInt(response.data.date.split('/')[0]);
756
- ngModel.$setViewValue($scope.model);
757
- _busy = !1;
758
- }
759
- })
760
- .catch(() => {
761
- _busy = !1;
762
- });
763
- }
764
- };
765
- },
766
- restrict: 'E',
767
- require: 'ngModel',
768
- scope: {
769
- v: '@',
770
- label1: '@',
771
- label2: '@',
772
- disabled: '@',
773
- ngModel: '=',
774
- ngChange: '&',
775
- },
776
- template: `
777
- <div class="row i-date">
778
-
779
- <div class="col6 control">
780
- <label> {{label1}} </label>
781
- <div class="row">
782
- <div class="col3 day">
783
- <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day" class="appearance-none no-border-left no-border-radius">
784
- <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
785
- </select>
786
- </div>
787
- <div class="col5 month">
788
- <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.month" class="appearance-none no-border-left no-border-right no-border-radius">
789
- <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
790
- </select>
791
- </div>
792
- <div class="col4 year">
793
- <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year" class="appearance-none no-border-right no-border-radius">
794
- <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
795
- </select>
796
- </div>
797
- </div>
798
- </div>
799
-
800
- <div class="col6 control">
801
- <label> {{label2}} </label>
802
- <div class="row">
803
- <div class="col3 day">
804
- <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day2" class="appearance-none no-border-left no-border-radius">
805
- <option ng-repeat="d2 in days2" ng-value="d2"> {{d2}} </option>
806
- </select>
807
- </div>
808
- <div class="col5 month">
809
- <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.month2" class="appearance-none no-border-left no-border-right no-border-radius">
810
- <option ng-repeat="m2 in monthes2" ng-value="$index"> {{m2}} </option>
811
- </select>
812
- </div>
813
- <div class="col4 year">
814
- <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year2" class="appearance-none no-border-right no-border-radius">
815
- <option ng-repeat="y2 in years2" ng-value="y2"> {{y2}} </option>
816
- </select>
817
- </div>
818
- </div>
819
- </div>
820
-
821
- </div>
822
- `,
823
- };
824
- },
825
- ]);
826
-
827
- app.directive('iControl', function () {
828
- return {
829
- restrict: 'E',
830
- require: 'ngModel',
831
- scope: {
832
- v: '@',
833
- id2: '@',
834
- label: '@',
835
- type: '@',
836
- disabled: '@',
837
- ngModel: '=',
838
- ngChange: '&',
839
- ngKeydown: '&',
840
- },
841
- link: function (scope, element, attrs, ctrl) {
842
- attrs.type = attrs.type || 'text';
843
-
844
- if (typeof attrs.disabled !== 'undefined') {
845
- attrs.disabled = 'disabled';
846
- } else {
847
- attrs.disabled = '';
848
- }
849
-
850
- $(element)
851
- .find('input')
852
- .focus(() => {
853
- $('.i-list .dropdown-content').css('display', 'none');
854
- });
855
-
856
- scope.$watch(attrs.ngModel, function (v) {});
857
- },
858
- template: `
859
- <div class="control">
860
- <label> {{label}} </label>
861
- <input id="{{id2}}" ng-disabled="disabled" autofocus v="{{v}}" type="{{type}}" ng-model="ngModel" ng-change="ngChange()" ngKeydown="ngKeydown()">
862
- </div>
863
- `,
864
- };
865
- });
866
-
867
- app.directive('iTextarea', function () {
868
- return {
869
- restrict: 'E',
870
- require: 'ngModel',
871
- scope: {
872
- v: '@',
873
- label: '@',
874
- disabled: '@',
875
- rows: '@',
876
- ngModel: '=',
877
- ngChange: '&',
878
- },
879
- link: function (scope, element, attrs, ctrl) {
880
- if (typeof attrs.disabled !== 'undefined') {
881
- attrs.disabled = 'disabled';
882
- } else {
883
- attrs.disabled = '';
884
- }
885
- scope.rows = scope.rows || 4;
886
-
887
- $(element)
888
- .find('textarea')
889
- .focus(() => {
890
- $('.popup').hide();
891
- });
892
- },
893
- template: `
894
- <div class="control">
895
- <label> {{label}} </label>
896
- <textarea ng-disabled="disabled" rows="{{rows}}" v="{{v}}" ng-model="ngModel" ng-change="ngChange()"></textarea>
897
- </div>
898
- `,
899
- };
900
- });
901
-
902
- app.directive('iCheckbox', function () {
903
- return {
904
- restrict: 'E',
905
- require: 'ngModel',
906
- scope: {
907
- label: '@',
908
- ngModel: '=',
909
- ngChange: '&',
910
- },
911
- link: function (scope, element, attrs, ctrl) {
912
- if (typeof attrs.disabled !== 'undefined') {
913
- attrs.disabled = 'disabled';
914
- } else {
915
- attrs.disabled = '';
916
- }
917
-
918
- scope.updateModal = function (ngModel) {
919
- if (attrs.disabled == 'disabled') {
920
- return !1;
921
- } else {
922
- scope.ngModel = !ngModel;
923
- return !0;
924
- }
925
- };
926
- },
927
- template: `
928
- <div class="selector" ng-class="{'selected' : ngModel , 'un-selected' : !ngModel }" ng-click="updateModal(ngModel);ngChange($event , ngModel)">
929
- <i ng-show="!ngModel" class="fa fa-square"></i> <i ng-show="ngModel" class="fa fa-check"></i> {{label}}
930
- </div>
931
- `,
932
- };
933
- });
934
-
935
- app.directive('iCheckbox2', function () {
936
- return {
937
- restrict: 'E',
938
- require: 'ngModel',
939
- scope: {
940
- label: '@',
941
- ngModel: '=',
942
- },
943
- link: function (scope, element, attrs, ctrl) {},
944
- template: `
945
- <div class="control">
946
- <label class="checkbox">
947
- <span class="title"> {{label}} </span>
948
- <input type="checkbox" ng-model="ngModel" >
949
- <span class="checkmark"></span>
950
- </label>
951
- </div>
952
- `,
953
- };
954
- });
955
-
956
- app.directive('iRadio', function () {
957
- return {
958
- restrict: 'E',
959
- require: 'ngModel',
960
- scope: {
961
- label: '@',
962
- ngValue: '@',
963
- group: '@',
964
- ngModel: '=',
965
- },
966
- link: function ($scope, element, attrs, ctrl) {
967
- if (!attrs.group) {
968
- attrs.group = attrs.ngModel;
969
- }
970
-
971
- $scope.changeModal = function (ngValue) {
972
- $scope.ngModel = ngValue;
973
- };
974
-
975
- $scope.$watch('ngModel', (ngModel) => {
976
- if (ngModel) {
977
- if (ngModel == $scope.ngValue) {
978
- }
979
- }
980
- });
981
-
982
- $scope.$watch('ngValue', (ngValue) => {
983
- if (ngValue) {
984
- if (ngValue == $scope.ngModel) {
985
- }
986
- }
987
- });
988
- },
989
- template: `
990
- <div group="{{group}}" class="selector" ng-class="{'selected' : ngModel == ngValue , 'un-selected' : ngModel != ngValue }" ng-click="changeModal(ngValue);ngChange($event , ngModel , ngValue)">
991
- <i ng-show="ngModel != ngValue" class="fa fa-circle"></i> <i ng-show="ngModel == ngValue" class="fa fa-circle"></i> {{label}}
992
- </div>
993
- `,
994
- };
995
- });
996
-
997
- app.directive('iRadio2', function () {
998
- return {
999
- restrict: 'E',
1000
- require: 'ngModel',
1001
- scope: {
1002
- label: '@',
1003
- ngValue: '@',
1004
- group: '@',
1005
- ngModel: '=',
1006
- },
1007
- link: function (scope, element, attrs, ctrl) {
1008
- if (!attrs.group) {
1009
- attrs.group = attrs.ngModel;
1010
- }
1011
-
1012
- let input = $(element).find('input');
1013
-
1014
- scope.$watch('ngModel', (ngModel) => {
1015
- if (ngModel) {
1016
- scope.ngModel = ngModel;
1017
- if (ngModel == scope.ngValue) {
1018
- input.prop('checked', !0);
1019
- }
1020
- }
1021
- });
1022
-
1023
- scope.$watch('ngValue', (ngValue) => {
1024
- if (ngValue) {
1025
- if (ngValue == scope.ngModel) {
1026
- input.prop('checked', !0);
1027
- }
1028
- }
1029
- });
1030
- },
1031
- template: `
1032
- <div class="control">
1033
- <label class="radio">
1034
- <span > {{label}} </span>
1035
- <input name="{{group}}" ng-value="ngValue" type="radio" ng-model="ngModel" >
1036
- <span class="checkmark"></span>
1037
- </label>
1038
- </div>
1039
- `,
1040
- };
1041
- });
1042
-
1043
- app.directive('iButton', function () {
1044
- return {
1045
- restrict: 'E',
1046
- scope: {
1047
- label: '@',
1048
- type: '@',
1049
- click: '@',
1050
- fa: '@',
1051
- },
1052
- link: function (scope, element, attrs, ctrl) {
1053
- if (!attrs.fa && attrs.type) {
1054
- if (attrs.type.like('*exit*') || attrs.type.like('*close*')) {
1055
- attrs.fa = 'times';
1056
- } else if (attrs.type.like('*view*') || attrs.type.like('*details*')) {
1057
- attrs.fa = 'file';
1058
- } else if (attrs.type.like('*add*') || attrs.type.like('*new*')) {
1059
- attrs.fa = 'plus-circle';
1060
- } else if (attrs.type.like('*update*') || attrs.type.like('*edit*')) {
1061
- attrs.fa = 'edit';
1062
- } else if (attrs.type.like('*save*')) {
1063
- attrs.fa = 'save';
1064
- } else if (attrs.type.like('*delete*') || attrs.type.like('*remove*')) {
1065
- attrs.fa = 'trash';
1066
- } else if (attrs.type.like('*print*')) {
1067
- attrs.fa = 'print';
1068
- } else if (attrs.type.like('*search*')) {
1069
- attrs.fa = 'search';
1070
- } else if (attrs.type.like('*export*') || attrs.type.like('*excel*')) {
1071
- attrs.fa = 'table';
1072
- }
1073
- }
1074
- },
1075
- template: `
1076
- <a class="btn {{type}}">
1077
- {{label}}
1078
- <i ng-show="fa" class="fa fa-{{fa}}" aria-hidden="true"></i> </a>
1079
- `,
1080
- };
1081
- });
1082
-
1083
- app.directive('iList', [
1084
- '$interval',
1085
- '$timeout',
1086
- 'isite',
1087
- function ($interval, $timeout, isite) {
1088
- return {
1089
- restrict: 'E',
1090
- require: 'ngModel',
1091
- scope: {
1092
- v: '@',
1093
- label: '@',
1094
- display: '@',
1095
- display2: '@',
1096
- disabled: '@',
1097
- css: '@',
1098
- space: '@',
1099
- primary: '@',
1100
- ngValue: '@',
1101
- ngModel: '=',
1102
- ngSearch: '=',
1103
- ngChange: '&',
1104
- ngAdd: '&',
1105
- items: '=',
1106
- },
1107
- link: function ($scope, element, attrs, ctrl) {
1108
- $scope.display = attrs.display = attrs.display || 'name';
1109
- $scope.primary = attrs.primary = attrs.primary || 'id';
1110
- attrs.space = attrs.space || ' ';
1111
- attrs.ngValue = attrs.ngValue || '';
1112
-
1113
- $scope.searchElement = $(element).find('.dropdown .search');
1114
- $scope.popupElement = $(element).find('.dropdown .dropdown-content');
1115
-
1116
- if (typeof attrs.disabled !== 'undefined') {
1117
- attrs.disabled = 'disabled';
1118
- } else {
1119
- attrs.disabled = '';
1120
- }
1121
-
1122
- if (typeof attrs.ngAdd == 'undefined') {
1123
- $scope.fa_add = 'fa-search';
1124
- } else {
1125
- $scope.fa_add = 'fa-plus';
1126
- }
1127
-
1128
- if (typeof attrs.ngSearch == 'undefined') {
1129
- $scope.showSearch = !1;
1130
- } else {
1131
- $scope.showSearch = !0;
1132
- }
1133
-
1134
- let input = $(element).find('input');
1135
- $(element).hover(
1136
- () => {
1137
- $scope.popupElement.css('display', 'block');
1138
- },
1139
- () => {
1140
- $scope.popupElement.css('display', 'none');
1141
- }
1142
- );
1143
- $scope.focus = function () {
1144
- $('.i-list .dropdown-content').css('display', 'none');
1145
- $scope.popupElement.css('display', 'block');
1146
- $scope.searchElement.focus();
1147
- };
1148
- $scope.hide = function () {
1149
- $scope.popupElement.css('display', 'none');
1150
- };
1151
-
1152
- $scope.getValue = function (item) {
1153
- let v = isite.getValue(item, $scope.display);
1154
- return v || '';
1155
- };
1156
-
1157
- $scope.getValue2 = function (item) {
1158
- if ($scope.display2) {
1159
- return isite.getValue(item, $scope.display2) || '';
1160
- }
1161
- return '';
1162
- };
1163
-
1164
- $scope.getNgModelValue = function (ngModel) {
1165
- if (ngModel && $scope.display && $scope.ngValue) {
1166
- return isite.getValue(ngModel, $scope.display.replace($scope.ngValue + '.', '')) || '';
1167
- } else if (ngModel && $scope.display) {
1168
- return isite.getValue(ngModel, $scope.display) || '';
1169
- }
1170
- return '';
1171
- };
1172
-
1173
- $scope.getNgModelValue2 = function (ngModel) {
1174
- if (ngModel && $scope.display2 && $scope.ngValue) {
1175
- return isite.getValue(ngModel, $scope.display2.replace($scope.ngValue + '.', '')) || '';
1176
- } else if (ngModel && $scope.display2) {
1177
- return isite.getValue(ngModel, $scope.display2) || '';
1178
- }
1179
- return '';
1180
- };
1181
-
1182
- $scope.getNgValue = function (item) {
1183
- if (item && $scope.ngValue) {
1184
- return isite.getValue(item, $scope.ngValue);
1185
- }
1186
- return item;
1187
- };
1188
-
1189
- $scope.$watch('items', (items) => {
1190
- input.val('');
1191
-
1192
- if (items) {
1193
- items.forEach((item) => {
1194
- item.$display = $scope.getValue(item) + attrs.space + $scope.getValue2(item);
1195
- });
1196
- }
1197
-
1198
- if (items && $scope.ngModel) {
1199
- items.forEach((item) => {
1200
- if (isite.getValue(item, $scope.primary) == isite.getValue($scope.ngModel, $scope.primary)) {
1201
- $scope.ngModel = item;
1202
- item.$display = $scope.getValue(item) + attrs.space + $scope.getValue2(item);
1203
- input.val(item.$display);
1204
- }
1205
- });
1206
- }
1207
- });
1208
-
1209
- $scope.$watch('ngModel', (ngModel) => {
1210
- input.val('');
1211
-
1212
- $scope.ngModel = ngModel;
1213
-
1214
- if (ngModel) {
1215
- input.val(' ' + $scope.getNgModelValue(ngModel) + attrs.space + $scope.getNgModelValue2(ngModel));
1216
- }
1217
- });
1218
-
1219
- $scope.updateModel = function (item) {
1220
- $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
1221
- input.val($scope.getNgModelValue($scope.ngModel) + attrs.space + $scope.getNgModelValue2($scope.ngModel));
1222
- $timeout(() => {
1223
- $scope.ngChange();
1224
- });
1225
- $scope.hide();
1226
- };
1227
- },
1228
- template: `/*##client-side/directive/i-list.html*/`,
1229
- };
1230
- },
1231
- ]);
1232
-
1233
- app.directive('iChecklist', [
1234
- '$interval',
1235
- function ($interval) {
1236
- return {
1237
- restrict: 'E',
1238
- required: 'ngModel',
1239
- scope: {
1240
- label: '@',
1241
- primary: '@',
1242
- display: '@',
1243
- ngModel: '=',
1244
- items: '=',
1245
- like: '&',
1246
- },
1247
- link: function ($scope, element, attrs, ctrl) {
1248
- attrs.primary = attrs.primary || 'id';
1249
-
1250
- $scope.selectedItems = [];
1251
-
1252
- $scope.$watch('ngModel', (ngModel) => {
1253
- $scope.reload();
1254
- });
1255
-
1256
- $scope.reload = function () {
1257
- $scope.selectedItems = [];
1258
-
1259
- if ($scope.ngModel) {
1260
- $scope.ngModel.forEach((mitem) => {
1261
- $scope.selectedItems.push(mitem);
1262
- });
1263
-
1264
- if ($scope.items) {
1265
- $scope.items.forEach((mitem) => {
1266
- let exist = !1;
1267
- $scope.selectedItems.forEach((sitem) => {
1268
- if (mitem[$scope.primary] === sitem[$scope.primary]) {
1269
- exist = !0;
1270
- }
1271
- });
1272
- if (exist) {
1273
- mitem.$selected = !0;
1274
- } else {
1275
- mitem.$selected = !1;
1276
- }
1277
- });
1278
- }
1279
- }
1280
- if (!$scope.ngModel) {
1281
- $scope.selectedItems = [];
1282
- if ($scope.items) {
1283
- $scope.items.forEach((mitem) => {
1284
- mitem.$selected = !1;
1285
- });
1286
- }
1287
- }
1288
- };
1289
-
1290
- $scope.change = function (item) {
1291
- item.$selected = !item.$selected;
1292
-
1293
- if (item.$selected) {
1294
- let exsits = !1;
1295
- $scope.selectedItems.forEach((sitem) => {
1296
- if (sitem[$scope.primary] === item[$scope.primary]) {
1297
- exsits = !0;
1298
- }
1299
- });
1300
- if (!exsits) {
1301
- $scope.selectedItems.push(item);
1302
- }
1303
- } else {
1304
- $scope.selectedItems.forEach((sitem, index) => {
1305
- if (sitem[$scope.primary] === item[$scope.primary]) {
1306
- $scope.selectedItems.splice(index, 1);
1307
- }
1308
- });
1309
- }
1310
-
1311
- $scope.ngModel = $scope.selectedItems;
1312
- };
1313
- },
1314
- template: `
1315
- <div class="row padding check-list">
1316
- <label class="title"> {{label}} </label>
1317
- <div ng-repeat="item in items" ng-click="change(item);ngChange($event , item);" class="selector" ng-class="{'selected' : item.$selected , 'un-selected' : !item.$selected }" >
1318
- <i ng-show="!item.$selected" class="fa fa-square"></i> <i ng-show="item.$selected" class="fa fa-check"></i> {{item[display]}}
1319
- </div>
1320
- </div>
1321
- `,
1322
- };
1323
- },
1324
- ]);
1325
-
1326
- app.directive('iChecklist2', [
1327
- '$interval',
1328
- function ($interval) {
1329
- return {
1330
- restrict: 'E',
1331
- required: 'ngModel',
1332
- scope: {
1333
- label: '@',
1334
- primary: '@',
1335
- display: '@',
1336
- ngModel: '=',
1337
- items: '=',
1338
- like: '&',
1339
- },
1340
- link: function ($scope, element, attrs, ctrl) {
1341
- attrs.primary = attrs.primary || 'id';
1342
-
1343
- $scope.selectedItems = [];
1344
-
1345
- $scope.$watch('ngModel', (ngModel) => {
1346
- $scope.reload();
1347
- });
1348
-
1349
- $scope.reload = function () {
1350
- $scope.selectedItems = [];
1351
-
1352
- if ($scope.ngModel) {
1353
- $scope.ngModel.forEach((mitem) => {
1354
- $scope.selectedItems.push(mitem);
1355
- });
1356
-
1357
- if ($scope.items) {
1358
- $scope.items.forEach((mitem) => {
1359
- let exist = !1;
1360
- $scope.selectedItems.forEach((sitem) => {
1361
- if (mitem[$scope.primary] === sitem[$scope.primary]) {
1362
- exist = !0;
1363
- }
1364
- });
1365
- if (exist) {
1366
- mitem.$selected = !0;
1367
- } else {
1368
- mitem.$selected = !1;
1369
- }
1370
- });
1371
- }
1372
- }
1373
- if (!$scope.ngModel) {
1374
- $scope.selectedItems = [];
1375
- if ($scope.items) {
1376
- $scope.items.forEach((mitem) => {
1377
- mitem.$selected = !1;
1378
- });
1379
- }
1380
- }
1381
- };
1382
-
1383
- $scope.change = function (item) {
1384
- if (item.$selected) {
1385
- let exsits = !1;
1386
- $scope.selectedItems.forEach((sitem) => {
1387
- if (sitem[$scope.primary] === item[$scope.primary]) {
1388
- exsits = !0;
1389
- }
1390
- });
1391
- if (!exsits) {
1392
- $scope.selectedItems.push(item);
1393
- }
1394
- } else {
1395
- $scope.selectedItems.forEach((sitem, index) => {
1396
- if (sitem[$scope.primary] === item[$scope.primary]) {
1397
- $scope.selectedItems.splice(index, 1);
1398
- }
1399
- });
1400
- }
1401
-
1402
- $scope.ngModel = $scope.selectedItems;
1403
- };
1404
- },
1405
- template: `
1406
- <div class="row padding check-list">
1407
- <label class="title"> {{label}} </label>
1408
- <div class="control" ng-repeat="item in items">
1409
- <label class="checkbox" >
1410
- <span > {{item[display]}} </span>
1411
- <input type="checkbox" ng-model="item.$selected" ng-change="change(item)" >
1412
- <span class="checkmark"></span>
1413
- </label>
1414
- </div>
1415
- </div>
1416
- `,
1417
- };
1418
- },
1419
- ]);
1420
-
1421
- app.directive('iRadiolist', [
1422
- '$interval',
1423
- function ($interval) {
1424
- return {
1425
- restrict: 'E',
1426
- required: 'ngModel',
1427
- scope: {
1428
- label: '@',
1429
- display: '@',
1430
- ngModel: '=',
1431
- items: '=',
1432
- },
1433
- link: function (scope, element, attrs) {
1434
- scope.model = scope.ngModel;
1435
-
1436
- scope.code = 'radio_' + Math.random();
1437
-
1438
- scope.change = function (item) {
1439
- scope.ngModel = item;
1440
- };
1441
-
1442
- scope.isChecked = function (item) {
1443
- if (item && scope.ngModel && scope.ngModel.id === item.id) {
1444
- return !0;
1445
- }
1446
- return !1;
1447
- };
1448
- },
1449
- template: `
1450
- <div class="row padding radio-list">
1451
- <label class="title"> {{label}} </label>
1452
- <div class="control" ng-repeat="item in items">
1453
- <label class="radio" >
1454
- <span > {{item[display]}} </span>
1455
- <input name="{{code}}" type="radio" ng-model="model" ng-checked="isChecked(item)" ng-click="change(item)" ng-change="change(item)" >
1456
- <span class="checkmark"></span>
1457
- </label>
1458
- </div>
1459
- </div>
1460
- `,
1461
- };
1462
- },
1463
- ]);
1464
-
1465
- app.directive('iFile', [
1466
- '$interval',
1467
- 'isite',
1468
- function ($interval, isite) {
1469
- return {
1470
- restrict: 'E',
1471
- required: 'ngModel',
1472
- scope: {
1473
- label: '@',
1474
- type: '@',
1475
- ngModel: '=',
1476
- ngClick: '&',
1477
- onSelected: '&',
1478
- },
1479
- link: function (scope, element, attrs, ctrl) {
1480
- scope.type = scope.type || 'bg-green';
1481
-
1482
- let input = $(element).find('input')[0];
1483
- let a = $(element).find('a')[0];
1484
-
1485
- if (attrs.view !== '') {
1486
- a.addEventListener('click', function () {
1487
- input.click();
1488
- });
1489
- }
1490
-
1491
- input.addEventListener('change', function () {
1492
- scope.ngModel = this.files[0].path;
1493
- scope.onSelected(this.files[0].path);
1494
- scope.$applyAsync();
1495
- });
1496
-
1497
- scope.$watch('ngModel', (ngModel) => {
1498
- if (ngModel) {
1499
- a.setAttribute('url', ngModel);
1500
- }
1501
- });
1502
- },
1503
- template: `
1504
- <form class="form text-center pointer">
1505
- <input class="hidden" type="file" name="file" />
1506
- <a class="btn {{type}}" ngClick="ngClick()" url="{{ngModel}}"> {{label}} </a>
1507
- </form>
1508
- `,
1509
- };
1510
- },
1511
- ]);
1512
-
1513
- app.directive('iImage', [
1514
- '$interval',
1515
- 'isite',
1516
- function ($interval, isite) {
1517
- return {
1518
- restrict: 'E',
1519
- required: 'ngModel',
1520
- scope: {
1521
- category: '@',
1522
- ngModel: '=',
1523
- ngClick: '&',
1524
- },
1525
- link: function (scope, element, attrs, ctrl) {
1526
- scope.category = scope.category || 'default';
1527
-
1528
- let input = $(element).find('input')[0];
1529
- let img = $(element).find('img')[0];
1530
- let progress = $(element).find('progress')[0];
1531
- $(progress).hide();
1532
-
1533
- if (attrs.view !== '') {
1534
- img.addEventListener('click', function () {
1535
- input.click();
1536
- });
1537
- }
1538
-
1539
- input.addEventListener('change', function () {
1540
- isite.uploadImage(
1541
- this.files,
1542
- {
1543
- category: scope.category,
1544
- },
1545
- (err, image_url, e) => {
1546
- if (e) {
1547
- $(progress).show();
1548
- progress.value = e.loaded;
1549
- progress.max = e.total;
1550
- }
1551
-
1552
- if (image_url) {
1553
- scope.ngModel = image_url;
1554
- }
1555
- }
1556
- );
1557
- });
1558
-
1559
- scope.$watch('ngModel', (ngModel) => {
1560
- if (ngModel) {
1561
- img.setAttribute('src', ngModel);
1562
- }
1563
- });
1564
- },
1565
- template: `
1566
- <form class="form text-center pointer">
1567
- <input class="hidden" type="file" name="file" />
1568
- <img class="bg-white" ng-src="{{ngModel}}" ngClick="ngClick()" onerror="this.src='/images/no.jpg'" />
1569
- <progress class="row"></progress>
1570
- </form>
1571
- `,
1572
- };
1573
- },
1574
- ]);
1575
-
1576
- app.directive('iUpload', [
1577
- '$interval',
1578
- 'isite',
1579
- function ($interval, isite) {
1580
- return {
1581
- restrict: 'E',
1582
- required: 'ngModel',
1583
- scope: {
1584
- label: '@',
1585
- api: '@',
1586
- type: '@',
1587
- ngModel: '=',
1588
- ngClick: '&',
1589
- onUploaded: '&',
1590
- },
1591
- link: function (scope, element, attrs, ctrl) {
1592
- scope.type = scope.type || 'bg-green';
1593
-
1594
- let input = $(element).find('input')[0];
1595
- let a = $(element).find('a')[0];
1596
- let progress = $(element).find('progress')[0];
1597
- $(progress).hide();
1598
-
1599
- if (attrs.view !== '') {
1600
- a.addEventListener('click', function () {
1601
- input.click();
1602
- });
1603
- }
1604
-
1605
- input.addEventListener('change', function () {
1606
- isite.upload(
1607
- this.files,
1608
- {
1609
- api: scope.api,
1610
- },
1611
- (err, file, e) => {
1612
- if (e) {
1613
- $(progress).show();
1614
- progress.value = e.loaded;
1615
- progress.max = e.total;
1616
- }
1617
-
1618
- if (file) {
1619
- scope.ngModel = file;
1620
- scope.onUploaded();
1621
- }
1622
- }
1623
- );
1624
- });
1625
-
1626
- scope.$watch('ngModel', (ngModel) => {
1627
- if (ngModel) {
1628
- a.setAttribute('url', ngModel);
1629
- }
1630
- });
1631
- },
1632
- template: `
1633
- <form class="form text-center pointer">
1634
- <input class="hidden" type="file" name="file" />
1635
- <a class="btn {{type}}" ngClick="ngClick()" url="{{ngModel}}"> {{label}} </a>
1636
- <progress class="row"></progress>
1637
- </form>
1638
- `,
1639
- };
1640
- },
1641
- ]);
1642
-
1643
- app.directive('iFiles', [
1644
- '$interval',
1645
- 'isite',
1646
- function ($interval, isite) {
1647
- return {
1648
- restrict: 'E',
1649
- required: 'ngModel',
1650
- scope: {
1651
- category: '@',
1652
- label: '@',
1653
- ngModel: '=',
1654
- },
1655
- link: function (scope, element, attrs, ctrl) {
1656
- if (attrs.view === '') {
1657
- scope.viewOnly = !0;
1658
- }
1659
-
1660
- let progress = $(element).find('progress')[0];
1661
-
1662
- scope.category = scope.category || 'default';
1663
- scope.id = Math.random().toString().replace('.', '_');
1664
- scope.deleteFile = function (file) {
1665
- isite.deleteFile(file, () => {
1666
- for (let i = 0; i < scope.ngModel.length; i++) {
1667
- let f = scope.ngModel[i];
1668
- if (f.url === file.url) {
1669
- scope.ngModel.splice(i, 1);
1670
- return;
1671
- }
1672
- }
1673
- });
1674
- };
1675
-
1676
- let setEvent = !1;
1677
- $interval(() => {
1678
- if (setEvent) {
1679
- return;
1680
- }
1681
-
1682
- if (attrs.view !== '') {
1683
- let btn = document.querySelector('#btn_' + scope.id);
1684
- if (btn) {
1685
- setEvent = !0;
1686
- btn.addEventListener('click', function () {
1687
- document.querySelector('#input_' + scope.id).click();
1688
- });
1689
- }
1690
-
1691
- let input = document.querySelector('#input_' + scope.id);
1692
- if (input) {
1693
- input.addEventListener('change', function () {
1694
- isite.uploadFile(
1695
- this.files,
1696
- {
1697
- category: scope.category,
1698
- },
1699
- (err, file, e) => {
1700
- if (e) {
1701
- $(progress).show();
1702
- progress.value = e.loaded;
1703
- progress.max = e.total;
1704
- }
1705
-
1706
- if (file) {
1707
- if (typeof scope.ngModel === 'undefined') {
1708
- scope.ngModel = [];
1709
- }
1710
- scope.ngModel.push(file);
1711
- }
1712
- }
1713
- );
1714
- });
1715
- }
1716
- } else {
1717
- setEvent = !0;
1718
- }
1719
- }, 500);
1720
- },
1721
- template: `
1722
- <div class="files">
1723
- <label> {{label}} </label>
1724
- <form ng-if="viewOnly !== !0" id="img_{{id}}" class="form text-center pointer">
1725
- <input id="input_{{id}}" class="hidden" type="file" name="file" />
1726
- <a id="btn_{{id}}" class="btn bg-green"> <i class="fa fa-upload white"></i> </a>
1727
- </form>
1728
- <progress class="row"></progress>
1729
- <div class="padding">
1730
-
1731
- <div class="row padding" ng-repeat="f in ngModel">
1732
- <h2>
1733
- <a class="btn default bg-blue" href="{{f.url}}"> <i class="fa fa-2x fa-download white"></i> </a>
1734
- <a ng-if="viewOnly !== !0" class="btn default bg-red" ng-click="deleteFile(f)"> <i class="fa fa-trash white"></i> </a>
1735
- <span> {{f.name}} </span>
1736
- </h2>
1737
- </div>
1738
- </div>
1739
- </div>
1740
-
1741
- `,
1742
- };
1743
- },
1744
- ]);
1745
-
1746
- app.directive('iDrag', [
1747
- '$document',
1748
- function ($document) {
1749
- return function (scope, element, attr) {
1750
- var startX = 0,
1751
- startY = 0,
1752
- x = 0,
1753
- y = 0;
1754
-
1755
- element.css({
1756
- position: 'relative',
1757
- });
1758
-
1759
- element.on('mousedown', function (event) {
1760
- event.preventDefault();
1761
- startX = event.screenX - x;
1762
- startY = event.screenY - y;
1763
- $document.on('mousemove', mousemove);
1764
- $document.on('mouseup', mouseup);
1765
- });
1766
-
1767
- function mousemove(event) {
1768
- y = event.screenY - startY;
1769
- x = event.screenX - startX;
1770
- element.css({
1771
- top: y + 'px',
1772
- left: x + 'px',
1773
- });
1774
- }
1775
-
1776
- function mouseup() {
1777
- $document.off('mousemove', mousemove);
1778
- $document.off('mouseup', mouseup);
1779
- }
1780
- };
1781
- },
1782
- ]);
1783
-
1784
- app.directive('iTreeview', [
1785
- '$interval',
1786
- '$timeout',
1787
- 'isite',
1788
- function ($interval, $timeout, isite) {
1789
- return {
1790
- restrict: 'E',
1791
- require: 'ngModel',
1792
- scope: {
1793
- v: '@',
1794
- label: '@',
1795
- display: '@',
1796
- display2: '@',
1797
- disabled: '@',
1798
- space: '@',
1799
- primary: '@',
1800
- ngValue: '@',
1801
- ngModel: '=',
1802
- ngSearch: '=',
1803
- ngChange: '&',
1804
- ngClick: '&',
1805
- ngAdd: '&',
1806
- ngNode: '&',
1807
- ngEdit: '&',
1808
- ngDelete: '&',
1809
- nodes: '=',
1810
- },
1811
- link: function ($scope, element, attrs, ctrl) {
1812
- attrs.display = attrs.display || 'name';
1813
- attrs.primary = attrs.primary || 'id';
1814
- attrs.space = attrs.space || ' ';
1815
- attrs.ngValue = attrs.ngValue || '';
1816
-
1817
- $scope.source = {};
1818
-
1819
- $scope.setNodes = function (v_node) {
1820
- v_node.nodes.forEach((v_node2) => {
1821
- v_node2.nodes = v_node2.nodes || [];
1822
- $scope.nodes.forEach((node) => {
1823
- if (node.$parent_id == v_node2.id) {
1824
- node.v_display = node.v_display || '';
1825
- node.v_display += node[attrs.display];
1826
-
1827
- let exist = !1;
1828
- v_node2.nodes.forEach((n) => {
1829
- if (n.id == node.id) {
1830
- exist = !0;
1831
- }
1832
- });
1833
- if (!exist) {
1834
- v_node2.nodes.push(node);
1835
- }
1836
- }
1837
- });
1838
- $scope.setNodes(v_node2);
1839
- });
1840
- };
1841
-
1842
- $scope.v_nodes = [];
1843
-
1844
- $scope.$watch('ngModel', (ngModel) => {
1845
- if (ngModel) {
1846
- $scope.ngModel = ngModel;
1847
- $scope.ngModel.v_display = $scope.ngModel.v_display || ngModel[attrs.display];
1848
- }
1849
- });
1850
-
1851
- $scope.$watch('nodes', (nodes) => {
1852
- $scope.v_nodes = [];
1853
- if (nodes) {
1854
- nodes.forEach((node) => {
1855
- node.$parent_id = node.parent_id || 0;
1856
- node.v_display = node.v_display || '';
1857
- node.v_display += node[attrs.display];
1858
- if (node.$parent_id == 0) {
1859
- let exist = !1;
1860
- $scope.v_nodes.forEach((n) => {
1861
- if (n.id == node.id) {
1862
- exist = !0;
1863
- }
1864
- });
1865
- if (!exist) {
1866
- $scope.v_nodes.push(node);
1867
- }
1868
- }
1869
- });
1870
-
1871
- $scope.v_nodes.forEach((v_node) => {
1872
- v_node.nodes = v_node.nodes || [];
1873
-
1874
- nodes.forEach((node) => {
1875
- node.$parent_id = node.parent_id || 0;
1876
- if (node.$parent_id == v_node.id) {
1877
- node.v_display = node.v_display || '';
1878
- node.v_display += node[attrs.display];
1879
-
1880
- let exist = !1;
1881
- v_node.nodes.forEach((n) => {
1882
- if (n.id == node.id) {
1883
- exist = !0;
1884
- }
1885
- });
1886
- if (!exist) {
1887
- v_node.nodes.push(node);
1888
- }
1889
- }
1890
- });
1891
-
1892
- $scope.setNodes(v_node);
1893
- });
1894
- }
1895
- });
1896
- },
1897
- template: `
1898
- <div class="treeview">
1899
- <ul >
1900
- <li ng-dblclick="$event.preventDefault();$event.stopPropagation();source.$actions = !0" ng-mouseleave="source.$actions = !1">
1901
-
1902
- <i ng-hide="openTree" class="fa fa-folder"></i> <i ng-show="openTree" class="fa fa-folder"></i>
1903
-
1904
-
1905
- <span ng-click="openTree = !openTree" class="title"> {{label}} <small class="display"> [ {{ngModel.v_display}} ] </small> </span>
1906
- <div class="actions" ng-show="source.$actions === !0">
1907
- <i-button type="add default" ng-click="ngClick($event , ngModel);ngNode($event , ngModel)"></i-button>
1908
- </div>
1909
- <i-treenode display="{{display}}" ng-click="ngClick($event)" ng-add="ngAdd()" ng-edit="ngEdit()" ng-delete="ngDelete()" ng-show="openTree" ng-model="ngModel" nodes="v_nodes" ></i-treenode>
1910
- </li>
1911
- </ul>
1912
- </div>
1913
- `,
1914
- };
1915
- },
1916
- ]);
1917
-
1918
- app.directive('iTreenode', [
1919
- '$interval',
1920
- '$timeout',
1921
- 'isite',
1922
- function ($interval, $timeout, isite) {
1923
- return {
1924
- restrict: 'E',
1925
- require: 'ngModel',
1926
- scope: {
1927
- v: '@',
1928
- label: '@',
1929
- display: '@',
1930
- display2: '@',
1931
- disabled: '@',
1932
- space: '@',
1933
- primary: '@',
1934
- ngValue: '@',
1935
- ngChange: '&',
1936
- ngClick: '&',
1937
- ngAdd: '&',
1938
- ngEdit: '&',
1939
- ngDelete: '&',
1940
- ngModel: '=',
1941
- ngSearch: '=',
1942
- nodes: '=',
1943
- nodes: '=',
1944
- },
1945
- link: function ($scope, element, attrs, ctrl) {
1946
- attrs.display = attrs.display || 'name';
1947
- attrs.primary = attrs.primary || 'id';
1948
- attrs.space = attrs.space || ' ';
1949
- attrs.ngValue = attrs.ngValue || '';
1950
- $scope.nodes = $scope.nodes || [];
1951
-
1952
- $scope.v_nodes = [];
1953
-
1954
- $scope.$watch('nodes', (nodes) => {
1955
- $scope.v_nodes = [];
1956
- if (nodes) {
1957
- nodes.forEach((node, i) => {
1958
- if (node.nodes) {
1959
- node.nodes.forEach((node2, i) => {
1960
- node2.$parent_id = node2.parent_id || node.id;
1961
- node2.v_display = node.v_display || ' ';
1962
- node2.v_display += ' - ' + node2[attrs.display];
1963
- });
1964
- }
1965
- });
1966
- }
1967
- });
1968
-
1969
- $scope.updateParentModal = function (parent, node) {
1970
- if (parent) {
1971
- parent.ngModel = node;
1972
- if (parent.$parent) {
1973
- $scope.updateParentModal(parent.$parent, node);
1974
- }
1975
- }
1976
- };
1977
-
1978
- $scope.unSelectParent = function (parent) {
1979
- if (parent && parent.nodes) {
1980
- parent.nodes.forEach((node) => {
1981
- node.$selected = !1;
1982
- });
1983
- if (parent.$parent) {
1984
- $scope.unSelectParent(parent.$parent);
1985
- }
1986
- }
1987
- };
1988
-
1989
- $scope.unSelectNodes = function (nodes) {
1990
- if (nodes) {
1991
- nodes.forEach((node) => {
1992
- node.$selected = !1;
1993
- if (node.nodes) {
1994
- $scope.unSelectNodes(node.nodes);
1995
- }
1996
- });
1997
- }
1998
- };
1999
-
2000
- $scope.updateModal = function (node) {
2001
- $scope.ngModel = node;
2002
- $scope.updateParentModal($scope.$parent, node);
2003
- };
2004
-
2005
- $scope.selected = function (node) {
2006
- $scope.unSelectParent($scope.$parent);
2007
- $scope.unSelectNodes($scope.nodes);
2008
-
2009
- if (node.nodes) {
2010
- node.nodes.forEach((itm) => {
2011
- itm.$selected = !1;
2012
- });
2013
- }
2014
-
2015
- node.$selected = !0;
2016
- };
2017
- },
2018
- template: `
2019
- <div class="treenode">
2020
- <ul >
2021
- <li ng-repeat="node in nodes" >
2022
- <div class="row" ng-dblclick="$event.preventDefault();$event.stopPropagation();node.$actions = !0;source.$actions = !1" ng-mouseleave="node.$actions = !1">
2023
- <span ng-show="node.nodes.length > 0" ng-click="node.$expand = !node.$expand;">
2024
- <i ng-hide="node.$expand" class="fa fa-caret-left"></i> <i ng-show="node.$expand" class="fa fa-caret-down"></i>
2025
- </span>
2026
- <span ng-hide="node.nodes.length > 0" >
2027
- <i class="fa fa-file"></i>
2028
- </span>
2029
-
2030
- <span class="text" ng-class="{'selected' : node.$selected == !0}" ng-click="ngClick($event , node);node.$expand = !node.$expand;selected(node);updateModal(node)" > {{node[display]}} </span>
2031
- <div class="actions" ng-show="node.$actions === !0">
2032
- <i-button type="add default" ng-click="ngAdd(node)"></i-button>
2033
- <i-button type="edit default" ng-click="ngEdit(node)"></i-button>
2034
- <i-button type="delete default" ng-click="ngDelete(node)"></i-button>
2035
- </div>
2036
- </div>
2037
- <i-treenode display="{{display}}" ng-click="ngClick($event)" ng-add="ngAdd()" ng-edit="ngEdit()" ng-delete="ngDelete()" ng-show="node.$expand" ng-model="ngModel" nodes="node.nodes" nodes="node.nodes"></i-treenode>
2038
- </li>
2039
- </ul>
2040
- </div>
2041
- `,
2042
- };
2043
- },
2044
- ]);
1
+ var app = app || angular.module('myApp', []);
2
+ window.$ = window.jQuery;
3
+
4
+ app.directive('iDate', function () {
5
+ return {
6
+ link: function (scope, element, attrs) {
7
+ if (typeof attrs.disabled !== 'undefined') {
8
+ attrs.disabled = 'disabled';
9
+ } else {
10
+ attrs.disabled = '';
11
+ }
12
+
13
+ $(element)
14
+ .find('select')
15
+ .focus(() => {
16
+ $('.popup').hide();
17
+ });
18
+
19
+ scope.days1 = [];
20
+ for (let i = 1; i < 32; i++) {
21
+ scope.days1.push(i);
22
+ }
23
+ scope.years1 = [];
24
+ for (let i = 1900; i < 2100; i++) {
25
+ scope.years1.push(i);
26
+ }
27
+ scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
28
+ },
29
+ restrict: 'E',
30
+ require: 'ngModel',
31
+ scope: {
32
+ v: '@',
33
+ label: '@',
34
+ disabled: '@',
35
+ ngModel: '=',
36
+ },
37
+ template: `
38
+ <div class="row i-date">
39
+
40
+ <div class=" control">
41
+ <label> {{label}} </label>
42
+ <div class="row">
43
+ <div class="col3 day">
44
+ <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.day" class="appearance-none no-border-left no-border-radius" >
45
+ <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
46
+ </select>
47
+ </div>
48
+ <div class="col5 month">
49
+ <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.month" class="appearance-none no-border-left no-border-right no-border-radius" >
50
+ <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
51
+ </select>
52
+ </div>
53
+ <div class="col4 year">
54
+ <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.year" class="appearance-none no-border-right no-border-radius" >
55
+ <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
56
+ </select>
57
+ </div>
58
+ </div>
59
+ </div>
60
+
61
+
62
+ </div>
63
+ `,
64
+ };
65
+ });
66
+
67
+ app.directive('iDate2', function () {
68
+ return {
69
+ link: function ($scope, element, attrs) {
70
+ if (typeof attrs.disabled !== 'undefined') {
71
+ attrs.disabled = 'disabled';
72
+ } else {
73
+ attrs.disabled = '';
74
+ }
75
+
76
+ $scope.y_search = attrs.year || '202';
77
+ $scope.m_search = attrs.month || '';
78
+ $scope.d_search = attrs.day || '';
79
+
80
+ $scope.days1 = [];
81
+ for (let i = 1; i < 32; i++) {
82
+ $scope.days1.push({
83
+ id: i,
84
+ name: i,
85
+ });
86
+ }
87
+ $scope.years1 = [];
88
+ for (let i = 1900; i < 2100; i++) {
89
+ $scope.years1.push({
90
+ id: i,
91
+ name: i,
92
+ });
93
+ }
94
+
95
+ $scope.monthes1 = [
96
+ { id: 0, name: 'يناير / Jan' },
97
+ { id: 1, name: 'فبراير / Feb' },
98
+ { id: 2, name: 'مارس / Mar' },
99
+ { id: 3, name: 'ابريل / Aper' },
100
+ { id: 4, name: 'مايو / May' },
101
+ { id: 5, name: 'يونيو / June' },
102
+ { id: 6, name: 'يوليو / Jule' },
103
+ { id: 7, name: 'اغسطس / Aug' },
104
+ { id: 8, name: 'سبتمبر / Sep' },
105
+ { id: 9, name: 'اكتوبر / Oct' },
106
+ { id: 10, name: 'نوفمبر / Nov' },
107
+ { id: 11, name: 'ديسمبر / Des' },
108
+ ];
109
+
110
+ $scope.model = null;
111
+
112
+ $scope.$watch('ngModel', function (ngModel) {
113
+ if (ngModel) {
114
+ ngModel = new Date(ngModel);
115
+ $scope.model = $scope.model || {};
116
+ $scope.model.day = ngModel.getDate();
117
+ $scope.model.day_name = $scope.model.day;
118
+ $scope.model.month = ngModel.getMonth();
119
+ $scope.model.month_name = $scope.monthes1.find((m) => m.id == $scope.model.month).name;
120
+ $scope.model.year = ngModel.getFullYear();
121
+ $scope.model.year_name = $scope.model.year;
122
+ } else {
123
+ $scope.model = $scope.model || {};
124
+ $scope.model.day = 0;
125
+ $scope.model.day_name = '';
126
+ $scope.model.month = -1;
127
+ $scope.model.month_name = '';
128
+ $scope.model.year = 0;
129
+ $scope.model.year_name = '';
130
+ }
131
+ });
132
+
133
+ $scope.setDay = function () {
134
+ $scope.ngModel = new Date();
135
+ };
136
+ $scope.updateDate = function (date) {
137
+ if (date.year) {
138
+ $scope.model.year = date.year.id;
139
+ $scope.model.year_name = date.year.name;
140
+ } else if (date.month) {
141
+ $scope.model.month = date.month.id;
142
+ $scope.model.month_name = date.month.name;
143
+ } else if (date.day) {
144
+ $scope.model.day = date.day.id;
145
+ $scope.model.day_name = date.day.name;
146
+ }
147
+
148
+ if ($scope.model && $scope.model.year && $scope.model.day && $scope.model.month > -1) {
149
+ $scope.ngModel = new Date($scope.model.year, $scope.model.month, $scope.model.day, 0, 0, 0);
150
+ } else {
151
+ delete $scope.ngModel;
152
+ }
153
+ };
154
+ },
155
+ restrict: 'E',
156
+ require: 'ngModel',
157
+ scope: {
158
+ v: '@',
159
+ disabled: '@',
160
+ label: '@',
161
+ ngModel: '=',
162
+ },
163
+ template: `/*##client-side/directive-core/i-date.html*/`,
164
+ };
165
+ });
166
+
167
+ app.directive('iTime', function () {
168
+ return {
169
+ link: function ($scope, element, attrs) {
170
+ if (typeof attrs.disabled !== 'undefined') {
171
+ attrs.disabled = 'disabled';
172
+ } else {
173
+ attrs.disabled = '';
174
+ }
175
+
176
+ $scope.model = {};
177
+
178
+ $scope.hours = [];
179
+ for (let i = 1; i < 25; i++) {
180
+ $scope.hours.push(i);
181
+ }
182
+
183
+ $scope.minutes = [];
184
+ for (let i = 0; i < 60; i++) {
185
+ $scope.minutes.push(i);
186
+ }
187
+
188
+ $(element)
189
+ .find('select')
190
+ .focus(() => {
191
+ $('.popup').hide();
192
+ });
193
+
194
+ $scope.$watch('ngModel', function (ngModel) {
195
+ if (ngModel) {
196
+ ngModel.date = new Date(ngModel.date);
197
+ $scope.model = $scope.model || {};
198
+ $scope.model.hour = ngModel.hour;
199
+ $scope.model.minute = ngModel.minute;
200
+ } else {
201
+ $scope.model = $scope.model || {};
202
+ $scope.model.hour = 0;
203
+ $scope.model.minute = 0;
204
+ }
205
+ });
206
+
207
+ $scope.updateTime = function () {
208
+ if ($scope.model) {
209
+ $scope.ngModel = $scope.ngModel || {};
210
+ $scope.ngModel.hour = $scope.model.hour;
211
+ $scope.ngModel.minute = $scope.model.minute;
212
+ $scope.ngModel.date = new Date(null, null, null, $scope.model.hour, $scope.model.minute, null);
213
+ } else {
214
+ delete $scope.ngModel;
215
+ }
216
+ };
217
+ },
218
+ restrict: 'E',
219
+ require: 'ngModel',
220
+ scope: {
221
+ v: '@',
222
+ disabled: '@',
223
+ label: '@',
224
+ ngModel: '=',
225
+ },
226
+ template: `
227
+ <div class="row i-time">
228
+ <div class=" control ">
229
+ <label class="text-center"> {{label}} </label>
230
+ <div class="row">
231
+ <div class="col6 right">
232
+ <div class="row">
233
+ <div class="col2"></div>
234
+ <div class="col8">
235
+ <select ng-disabled="disabled" ng-model="model.minute" ng-change="updateTime()" class="small appearance-none no-border-left no-border-radius" >
236
+ <option ng-repeat="m in minutes" ng-value="m"> {{m}}</option>
237
+ </select>
238
+ </div>
239
+ <div class="col2"></div>
240
+ </div>
241
+
242
+ </div>
243
+ <div class="col6">
244
+ <div class="row">
245
+ <div class="col2 space right">
246
+ <span> : </span>
247
+ </div>
248
+ <div class="col8">
249
+ <select ng-disabled="disabled" ng-model="model.hour" ng-change="updateTime()" class="large blue appearance-none no-border-left no-border-radius" >
250
+ <option ng-repeat="h in hours" ng-value="h"> {{h}} </option>
251
+ </select>
252
+ </div>
253
+
254
+ </div>
255
+
256
+ </div>
257
+ </div>
258
+ </div>
259
+ `,
260
+ };
261
+ });
262
+
263
+ app.directive('iDatetime2', function () {
264
+ return {
265
+ link: function ($scope, element, attrs) {
266
+ if (typeof attrs.disabled !== 'undefined') {
267
+ attrs.disabled = 'disabled';
268
+ } else {
269
+ attrs.disabled = '';
270
+ }
271
+
272
+ $scope.hour1 = [];
273
+ for (let i = 1; i < 25; i++) {
274
+ $scope.hour1.push(i);
275
+ }
276
+
277
+ $scope.minute_list = [];
278
+ for (let i = 1; i < 60; i++) {
279
+ $scope.minute_list.push({
280
+ name: i,
281
+ });
282
+ }
283
+
284
+ $scope.days1 = [];
285
+ for (let i = 1; i < 32; i++) {
286
+ $scope.days1.push(i);
287
+ }
288
+ $scope.years1 = [];
289
+ for (let i = 1900; i < 2100; i++) {
290
+ $scope.years1.push(i);
291
+ }
292
+ $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
293
+
294
+ $scope.model = null;
295
+
296
+ $(element)
297
+ .find('select')
298
+ .focus(() => {
299
+ $('.popup').hide();
300
+ });
301
+
302
+ $scope.$watch('ngModel', function (ngModel) {
303
+ if (ngModel) {
304
+ ngModel = new Date(ngModel);
305
+ $scope.model = $scope.model || {};
306
+ $scope.model.hour = ngModel.getHours();
307
+ $scope.model.minute = ngModel.getMinutes();
308
+ $scope.model.day = ngModel.getDate();
309
+ $scope.model.month = ngModel.getMonth();
310
+ $scope.model.year = ngModel.getFullYear();
311
+ } else {
312
+ $scope.model = $scope.model || {};
313
+ $scope.model.hour = 0;
314
+ $scope.model.minute = 0;
315
+ $scope.model.day = 0;
316
+ $scope.model.month = -1;
317
+ $scope.model.year = 0;
318
+ }
319
+ });
320
+
321
+ $scope.updateDate = function () {
322
+ if ($scope.model && $scope.model.year && $scope.model.day) {
323
+ $scope.ngModel = new Date($scope.model.year, $scope.model.month, $scope.model.day, $scope.model.hour, $scope.model.minute);
324
+ } else {
325
+ delete $scope.ngModel;
326
+ }
327
+ };
328
+ },
329
+ restrict: 'E',
330
+ require: 'ngModel',
331
+ scope: {
332
+ v: '@',
333
+ disabled: '@',
334
+ label: '@',
335
+ ngModel: '=',
336
+ },
337
+ template: `
338
+ <div class="row i-datetime2">
339
+
340
+ <div class=" control">
341
+ <label> {{label}} </label>
342
+ <div class="row">
343
+
344
+ <div class="col2 day">
345
+ <select v="{{v}}" ng-disabled="disabled" ng-model="model.day" ng-change="updateDate()" class="appearance-none no-border-left no-border-radius" >
346
+ <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
347
+ </select>
348
+ </div>
349
+ <div class="col5 month">
350
+ <select v="{{v}}" ng-disabled="disabled" ng-model="model.month" ng-change="updateDate()" class="appearance-none no-border-left no-border-right no-border-radius" >
351
+ <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
352
+ </select>
353
+ </div>
354
+ <div class="col3 year">
355
+ <select v="{{v}}" ng-disabled="disabled" ng-model="model.year" ng-change="updateDate()" class="appearance-none no-border-right no-border-radius" >
356
+ <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
357
+ </select>
358
+ </div>
359
+
360
+ <div class="col1 hour">
361
+ <select v="{{v}}" ng-disabled="disabled" ng-model="model.hour" ng-change="updateDate()" class="appearance-none no-border-radius" >
362
+ <option ng-repeat="h1 in hour1" ng-value="h1"> {{h1}} </option>
363
+ </select>
364
+ </div>
365
+ <div class="col1 minute">
366
+ <select v="{{v}}" ng-disabled="disabled" ng-model="model.minute" ng-change="updateDate()" class="green appearance-none no-border-right no-border-radius" >
367
+ <option ng-repeat="m1 in minute_list" ng-value="m1.name" class="green"> {{m1.name}} </option>
368
+ </select>
369
+ </div>
370
+
371
+ </div>
372
+ </div>
373
+
374
+
375
+ </div>
376
+ `,
377
+ };
378
+ });
379
+
380
+ app.directive('iMonth2', function () {
381
+ return {
382
+ link: function ($scope, element, attrs) {
383
+ if (typeof attrs.disabled !== 'undefined') {
384
+ attrs.disabled = 'disabled';
385
+ } else {
386
+ attrs.disabled = '';
387
+ }
388
+
389
+ $scope.years = [];
390
+ for (let i = 1900; i < 2100; i++) {
391
+ $scope.years.push(i);
392
+ }
393
+ $scope.monthes = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
394
+
395
+ $scope.model = null;
396
+
397
+ $(element)
398
+ .find('select')
399
+ .focus(() => {
400
+ $('.popup').hide();
401
+ });
402
+
403
+ $scope.$watch('ngModel', function (ngModel) {
404
+ if (ngModel) {
405
+ ngModel = new Date(ngModel);
406
+ $scope.model = $scope.model || {};
407
+ $scope.model.day = 1;
408
+ $scope.model.month = ngModel.getMonth();
409
+ $scope.model.year = ngModel.getFullYear();
410
+ } else {
411
+ $scope.model = $scope.model || {};
412
+ $scope.model.day = 0;
413
+ $scope.model.month = -1;
414
+ $scope.model.year = 0;
415
+ }
416
+ });
417
+
418
+ $scope.updateDate = function () {
419
+ if ($scope.model && $scope.model.year) {
420
+ $scope.ngModel = new Date($scope.model.year, $scope.model.month, 1);
421
+ } else {
422
+ delete $scope.ngModel;
423
+ }
424
+ };
425
+ },
426
+ restrict: 'E',
427
+ require: 'ngModel',
428
+ scope: {
429
+ v: '@',
430
+ label: '@',
431
+ disabled: '@',
432
+ ngModel: '=',
433
+ },
434
+ template: `
435
+ <div class="row i-date2">
436
+
437
+ <div class=" control">
438
+ <label> {{label}} </label>
439
+ <div class="row">
440
+
441
+ <div class="col7 month">
442
+ <select ng-disabled="disabled" v="{{v}}" ng-model="model.month" ng-change="updateDate()" class="appearance-none no-border-left no-border-radius" >
443
+ <option ng-repeat="m1 in monthes" ng-value="$index"> {{m1}} </option>
444
+ </select>
445
+ </div>
446
+
447
+ <div class="col5 year">
448
+ <select ng-disabled="disabled" v="{{v}}" ng-model="model.year" ng-change="updateDate()" class="appearance-none no-border-right no-border-radius" >
449
+ <option ng-repeat="y1 in years" ng-value="y1"> {{y1}} </option>
450
+ </select>
451
+ </div>
452
+
453
+ </div>
454
+ </div>
455
+
456
+
457
+ </div>
458
+ `,
459
+ };
460
+ });
461
+
462
+ app.directive('iFulldate', [
463
+ '$http',
464
+ function ($http) {
465
+ return {
466
+ link: function ($scope, element, attrs, ngModel) {
467
+ let _busy = !1;
468
+
469
+ if (typeof attrs.disabled !== 'undefined') {
470
+ attrs.disabled = 'disabled';
471
+ } else {
472
+ attrs.disabled = '';
473
+ }
474
+
475
+ $(element)
476
+ .find('select')
477
+ .focus(() => {
478
+ $('.popup').hide();
479
+ });
480
+
481
+ $scope.days1 = [];
482
+ for (let i = 1; i < 32; i++) {
483
+ $scope.days1.push(i);
484
+ }
485
+ $scope.years1 = [];
486
+ for (let i = 1950; i < 2030; i++) {
487
+ $scope.years1.push(i);
488
+ }
489
+
490
+ $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
491
+
492
+ $scope.days2 = [];
493
+ for (let i = 1; i < 31; i++) {
494
+ $scope.days2.push(i);
495
+ }
496
+ $scope.years2 = [];
497
+ for (let i = 1370; i < 1450; i++) {
498
+ $scope.years2.push(i);
499
+ }
500
+ $scope.monthes2 = ['محرم', 'صفر', 'ربيع اول', 'ربيع ثان', 'جمادى اول', 'جمادى ثان', 'رجب', 'شعبان', 'رمضان', 'شوال', 'ذى القعدة', 'ذى الحجة'];
501
+
502
+ $scope.model = {};
503
+
504
+ $scope.$watch('ngModel', function (ngModel) {
505
+ if (ngModel) {
506
+ $scope.model = ngModel;
507
+ } else {
508
+ $scope.model = {};
509
+ }
510
+ });
511
+
512
+ $scope.$watch('ngModel.date', function (date) {
513
+ if (date) {
514
+ if (typeof date == 'string') {
515
+ date = new Date(date);
516
+ }
517
+ $scope.model = $scope.model || {};
518
+ $scope.model.date = date;
519
+ $scope.model.day = date.getDate();
520
+ $scope.model.month = date.getMonth();
521
+ $scope.model.year = date.getFullYear();
522
+ $scope.get_hijri_date();
523
+ }
524
+ });
525
+
526
+ $scope.get_hijri_date = function () {
527
+ if ($scope.model && $scope.model.year && $scope.model.day) {
528
+ ngModel.$setViewValue($scope.model);
529
+ if (_busy) {
530
+ return;
531
+ }
532
+ _busy = !0;
533
+ $scope.model.date = new Date($scope.model.year, $scope.model.month, $scope.model.day);
534
+ $http({
535
+ method: 'POST',
536
+ url: '/api/get_hijri_date',
537
+ data: {
538
+ date: $scope.model.year + '/' + ($scope.model.month + 1) + '/' + $scope.model.day,
539
+ },
540
+ })
541
+ .then((response) => {
542
+ if (response.data.done) {
543
+ $scope.model.hijri = response.data.hijri;
544
+ $scope.model.day2 = parseInt($scope.model.hijri.split('/')[2]);
545
+ $scope.model.month2 = parseInt($scope.model.hijri.split('/')[1]) - 1;
546
+ $scope.model.year2 = parseInt($scope.model.hijri.split('/')[0]);
547
+ ngModel.$setViewValue($scope.model);
548
+ _busy = !1;
549
+ }
550
+ })
551
+ .catch(() => {
552
+ _busy = !1;
553
+ });
554
+ }
555
+ };
556
+
557
+ $scope.get_normal_date = function () {
558
+ if ($scope.model && $scope.model.year2 && $scope.model.day2) {
559
+ ngModel.$setViewValue($scope.model);
560
+ if (_busy) {
561
+ return;
562
+ }
563
+ _busy = !0;
564
+ $http({
565
+ method: 'POST',
566
+ url: '/api/get_normal_date',
567
+ data: {
568
+ hijri: $scope.model.year2 + '/' + ($scope.model.month2 + 1) + '/' + $scope.model.day2,
569
+ },
570
+ })
571
+ .then((response) => {
572
+ if (response.data.done) {
573
+ $scope.model.date = new Date(response.data.date);
574
+ $scope.model.day = parseInt(response.data.date.split('/')[2]);
575
+ $scope.model.month = parseInt(response.data.date.split('/')[1]) - 1;
576
+ $scope.model.year = parseInt(response.data.date.split('/')[0]);
577
+ ngModel.$setViewValue($scope.model);
578
+ _busy = !1;
579
+ }
580
+ })
581
+ .catch(() => {
582
+ _busy = !1;
583
+ });
584
+ }
585
+ };
586
+ },
587
+ restrict: 'E',
588
+ require: 'ngModel',
589
+ scope: {
590
+ v: '@',
591
+ label1: '@',
592
+ label2: '@',
593
+ disabled: '@',
594
+ ngModel: '=',
595
+ ngChange: '&',
596
+ },
597
+ template: `
598
+ <div class="row i-date">
599
+
600
+ <div class="col6 control">
601
+ <label> {{label1}} </label>
602
+ <div class="row">
603
+ <div class="col3 day">
604
+ <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day" class="appearance-none no-border-left no-border-radius">
605
+ <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
606
+ </select>
607
+ </div>
608
+ <div class="col5 month">
609
+ <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.month" class="appearance-none no-border-left no-border-right no-border-radius">
610
+ <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
611
+ </select>
612
+ </div>
613
+ <div class="col4 year">
614
+ <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year" class="appearance-none no-border-right no-border-radius">
615
+ <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
616
+ </select>
617
+ </div>
618
+ </div>
619
+ </div>
620
+
621
+ <div class="col6 control">
622
+ <label> {{label2}} </label>
623
+ <div class="row">
624
+ <div class="col3 day">
625
+ <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day2" class="appearance-none no-border-left no-border-radius">
626
+ <option ng-repeat="d2 in days2" ng-value="d2"> {{d2}} </option>
627
+ </select>
628
+ </div>
629
+ <div class="col5 month">
630
+ <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.month2" class="appearance-none no-border-left no-border-right no-border-radius">
631
+ <option ng-repeat="m2 in monthes2" ng-value="$index"> {{m2}} </option>
632
+ </select>
633
+ </div>
634
+ <div class="col4 year">
635
+ <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year2" class="appearance-none no-border-right no-border-radius">
636
+ <option ng-repeat="y2 in years2" ng-value="y2"> {{y2}} </option>
637
+ </select>
638
+ </div>
639
+ </div>
640
+ </div>
641
+
642
+ </div>
643
+ `,
644
+ };
645
+ },
646
+ ]);
647
+
648
+ app.directive('iControl', function () {
649
+ return {
650
+ restrict: 'E',
651
+ require: 'ngModel',
652
+ scope: {
653
+ v: '@',
654
+ id2: '@',
655
+ label: '@',
656
+ type: '@',
657
+ disabled: '@',
658
+ ngModel: '=',
659
+ ngChange: '&',
660
+ ngKeydown: '&',
661
+ },
662
+ link: function (scope, element, attrs, ctrl) {
663
+ attrs.type = attrs.type || 'text';
664
+
665
+ if (typeof attrs.disabled !== 'undefined') {
666
+ attrs.disabled = 'disabled';
667
+ } else {
668
+ attrs.disabled = '';
669
+ }
670
+
671
+ $(element)
672
+ .find('input')
673
+ .focus(() => {
674
+ $('.i-list .dropdown-content').css('display', 'none');
675
+ });
676
+
677
+ scope.$watch(attrs.ngModel, function (v) {});
678
+ },
679
+ template: `
680
+ <div class="control">
681
+ <label> {{label}} </label>
682
+ <input id="{{id2}}" ng-disabled="disabled" autofocus v="{{v}}" type="{{type}}" ng-model="ngModel" ng-change="ngChange()" ngKeydown="ngKeydown()">
683
+ </div>
684
+ `,
685
+ };
686
+ });
687
+
688
+ app.directive('iTextarea', function () {
689
+ return {
690
+ restrict: 'E',
691
+ require: 'ngModel',
692
+ scope: {
693
+ v: '@',
694
+ label: '@',
695
+ disabled: '@',
696
+ rows: '@',
697
+ ngModel: '=',
698
+ ngChange: '&',
699
+ },
700
+ link: function (scope, element, attrs, ctrl) {
701
+ if (typeof attrs.disabled !== 'undefined') {
702
+ attrs.disabled = 'disabled';
703
+ } else {
704
+ attrs.disabled = '';
705
+ }
706
+ scope.rows = scope.rows || 4;
707
+
708
+ $(element)
709
+ .find('textarea')
710
+ .focus(() => {
711
+ $('.popup').hide();
712
+ });
713
+ },
714
+ template: `
715
+ <div class="control">
716
+ <label> {{label}} </label>
717
+ <textarea ng-disabled="disabled" rows="{{rows}}" v="{{v}}" ng-model="ngModel" ng-change="ngChange()"></textarea>
718
+ </div>
719
+ `,
720
+ };
721
+ });
722
+
723
+ app.directive('iCheckbox', function () {
724
+ return {
725
+ restrict: 'E',
726
+ require: 'ngModel',
727
+ scope: {
728
+ label: '@',
729
+ ngModel: '=',
730
+ ngChange: '&',
731
+ },
732
+ link: function (scope, element, attrs, ctrl) {
733
+ if (typeof attrs.disabled !== 'undefined') {
734
+ attrs.disabled = 'disabled';
735
+ } else {
736
+ attrs.disabled = '';
737
+ }
738
+
739
+ scope.updateModal = function (ngModel) {
740
+ if (attrs.disabled == 'disabled') {
741
+ return !1;
742
+ } else {
743
+ scope.ngModel = !ngModel;
744
+ return !0;
745
+ }
746
+ };
747
+ },
748
+ template: `
749
+ <div class="selector" ng-class="{'selected' : ngModel , 'un-selected' : !ngModel }" ng-click="updateModal(ngModel);ngChange($event , ngModel)">
750
+ <i ng-show="!ngModel" class="fa fa-square"></i> <i ng-show="ngModel" class="fa fa-check"></i> {{label}}
751
+ </div>
752
+ `,
753
+ };
754
+ });
755
+
756
+ app.directive('iCheckbox2', function () {
757
+ return {
758
+ restrict: 'E',
759
+ require: 'ngModel',
760
+ scope: {
761
+ label: '@',
762
+ ngModel: '=',
763
+ },
764
+ link: function (scope, element, attrs, ctrl) {},
765
+ template: `
766
+ <div class="control">
767
+ <label class="checkbox">
768
+ <span class="title"> {{label}} </span>
769
+ <input type="checkbox" ng-model="ngModel" >
770
+ <span class="checkmark"></span>
771
+ </label>
772
+ </div>
773
+ `,
774
+ };
775
+ });
776
+
777
+ app.directive('iRadio', function () {
778
+ return {
779
+ restrict: 'E',
780
+ require: 'ngModel',
781
+ scope: {
782
+ label: '@',
783
+ ngValue: '@',
784
+ group: '@',
785
+ ngModel: '=',
786
+ },
787
+ link: function ($scope, element, attrs, ctrl) {
788
+ if (!attrs.group) {
789
+ attrs.group = attrs.ngModel;
790
+ }
791
+
792
+ $scope.changeModal = function (ngValue) {
793
+ $scope.ngModel = ngValue;
794
+ };
795
+
796
+ $scope.$watch('ngModel', (ngModel) => {
797
+ if (ngModel) {
798
+ if (ngModel == $scope.ngValue) {
799
+ }
800
+ }
801
+ });
802
+
803
+ $scope.$watch('ngValue', (ngValue) => {
804
+ if (ngValue) {
805
+ if (ngValue == $scope.ngModel) {
806
+ }
807
+ }
808
+ });
809
+ },
810
+ template: `
811
+ <div group="{{group}}" class="selector" ng-class="{'selected' : ngModel == ngValue , 'un-selected' : ngModel != ngValue }" ng-click="changeModal(ngValue);ngChange($event , ngModel , ngValue)">
812
+ <i ng-show="ngModel != ngValue" class="fa fa-circle"></i> <i ng-show="ngModel == ngValue" class="fa fa-circle"></i> {{label}}
813
+ </div>
814
+ `,
815
+ };
816
+ });
817
+
818
+ app.directive('iRadio2', function () {
819
+ return {
820
+ restrict: 'E',
821
+ require: 'ngModel',
822
+ scope: {
823
+ label: '@',
824
+ ngValue: '@',
825
+ group: '@',
826
+ ngModel: '=',
827
+ },
828
+ link: function (scope, element, attrs, ctrl) {
829
+ if (!attrs.group) {
830
+ attrs.group = attrs.ngModel;
831
+ }
832
+
833
+ let input = $(element).find('input');
834
+
835
+ scope.$watch('ngModel', (ngModel) => {
836
+ if (ngModel) {
837
+ scope.ngModel = ngModel;
838
+ if (ngModel == scope.ngValue) {
839
+ input.prop('checked', !0);
840
+ }
841
+ }
842
+ });
843
+
844
+ scope.$watch('ngValue', (ngValue) => {
845
+ if (ngValue) {
846
+ if (ngValue == scope.ngModel) {
847
+ input.prop('checked', !0);
848
+ }
849
+ }
850
+ });
851
+ },
852
+ template: `
853
+ <div class="control">
854
+ <label class="radio">
855
+ <span > {{label}} </span>
856
+ <input name="{{group}}" ng-value="ngValue" type="radio" ng-model="ngModel" >
857
+ <span class="checkmark"></span>
858
+ </label>
859
+ </div>
860
+ `,
861
+ };
862
+ });
863
+
864
+ app.directive('iButton', function () {
865
+ return {
866
+ restrict: 'E',
867
+ scope: {
868
+ label: '@',
869
+ type: '@',
870
+ click: '@',
871
+ fa: '@',
872
+ },
873
+ link: function (scope, element, attrs, ctrl) {
874
+ if (!attrs.fa && attrs.type) {
875
+ if (attrs.type.like('*exit*') || attrs.type.like('*close*')) {
876
+ attrs.fa = 'times';
877
+ } else if (attrs.type.like('*view*') || attrs.type.like('*details*')) {
878
+ attrs.fa = 'file';
879
+ } else if (attrs.type.like('*add*') || attrs.type.like('*new*')) {
880
+ attrs.fa = 'plus-circle';
881
+ } else if (attrs.type.like('*update*') || attrs.type.like('*edit*')) {
882
+ attrs.fa = 'edit';
883
+ } else if (attrs.type.like('*save*')) {
884
+ attrs.fa = 'save';
885
+ } else if (attrs.type.like('*delete*') || attrs.type.like('*remove*')) {
886
+ attrs.fa = 'trash';
887
+ } else if (attrs.type.like('*print*')) {
888
+ attrs.fa = 'print';
889
+ } else if (attrs.type.like('*search*')) {
890
+ attrs.fa = 'search';
891
+ } else if (attrs.type.like('*export*') || attrs.type.like('*excel*')) {
892
+ attrs.fa = 'table';
893
+ }
894
+ }
895
+ },
896
+ template: `
897
+ <a class="btn {{type}}">
898
+ {{label}}
899
+ <i ng-show="fa" class="fa fa-{{fa}}" aria-hidden="true"></i> </a>
900
+ `,
901
+ };
902
+ });
903
+
904
+ app.directive('iList', [
905
+ '$interval',
906
+ '$timeout',
907
+ 'isite',
908
+ function ($interval, $timeout, isite) {
909
+ return {
910
+ restrict: 'E',
911
+ require: 'ngModel',
912
+ scope: {
913
+ v: '@',
914
+ label: '@',
915
+ display: '@',
916
+ display2: '@',
917
+ disabled: '@',
918
+ css: '@',
919
+ space: '@',
920
+ primary: '@',
921
+ ngValue: '@',
922
+ ngModel: '=',
923
+ ngSearch: '=',
924
+ ngChange: '&',
925
+ ngAdd: '&',
926
+ items: '=',
927
+ },
928
+ link: function ($scope, element, attrs, ctrl) {
929
+ $scope.display = attrs.display = attrs.display || 'name';
930
+ $scope.primary = attrs.primary = attrs.primary || 'id';
931
+ attrs.space = attrs.space || ' ';
932
+ attrs.ngValue = attrs.ngValue || '';
933
+
934
+ $scope.searchElement = $(element).find('.dropdown .search');
935
+ $scope.popupElement = $(element).find('.dropdown .dropdown-content');
936
+
937
+ if (typeof attrs.disabled !== 'undefined') {
938
+ attrs.disabled = 'disabled';
939
+ } else {
940
+ attrs.disabled = '';
941
+ }
942
+
943
+ if (typeof attrs.ngAdd == 'undefined') {
944
+ $scope.fa_add = 'fa-search';
945
+ } else {
946
+ $scope.fa_add = 'fa-plus';
947
+ }
948
+
949
+ if (typeof attrs.ngSearch == 'undefined') {
950
+ $scope.showSearch = !1;
951
+ } else {
952
+ $scope.showSearch = !0;
953
+ }
954
+
955
+ let input = $(element).find('input');
956
+ $(element).hover(
957
+ () => {
958
+ $scope.popupElement.css('display', 'block');
959
+ },
960
+ () => {
961
+ $scope.popupElement.css('display', 'none');
962
+ }
963
+ );
964
+ $scope.focus = function () {
965
+ $('.i-list .dropdown-content').css('display', 'none');
966
+ $scope.popupElement.css('display', 'block');
967
+ $scope.searchElement.focus();
968
+ };
969
+ $scope.hide = function () {
970
+ $scope.popupElement.css('display', 'none');
971
+ };
972
+
973
+ $scope.getValue = function (item) {
974
+ let v = isite.getValue(item, $scope.display);
975
+ return v || '';
976
+ };
977
+
978
+ $scope.getValue2 = function (item) {
979
+ if ($scope.display2) {
980
+ return isite.getValue(item, $scope.display2) || '';
981
+ }
982
+ return '';
983
+ };
984
+
985
+ $scope.getNgModelValue = function (ngModel) {
986
+ if (ngModel && $scope.display && $scope.ngValue) {
987
+ return isite.getValue(ngModel, $scope.display.replace($scope.ngValue + '.', '')) || '';
988
+ } else if (ngModel && $scope.display) {
989
+ return isite.getValue(ngModel, $scope.display) || '';
990
+ }
991
+ return '';
992
+ };
993
+
994
+ $scope.getNgModelValue2 = function (ngModel) {
995
+ if (ngModel && $scope.display2 && $scope.ngValue) {
996
+ return isite.getValue(ngModel, $scope.display2.replace($scope.ngValue + '.', '')) || '';
997
+ } else if (ngModel && $scope.display2) {
998
+ return isite.getValue(ngModel, $scope.display2) || '';
999
+ }
1000
+ return '';
1001
+ };
1002
+
1003
+ $scope.getNgValue = function (item) {
1004
+ if (item && $scope.ngValue) {
1005
+ return isite.getValue(item, $scope.ngValue);
1006
+ }
1007
+ return item;
1008
+ };
1009
+
1010
+ $scope.$watch('items', (items) => {
1011
+ input.val('');
1012
+
1013
+ if (items) {
1014
+ items.forEach((item) => {
1015
+ item.$display = $scope.getValue(item) + attrs.space + $scope.getValue2(item);
1016
+ });
1017
+ }
1018
+
1019
+ if (items && $scope.ngModel) {
1020
+ items.forEach((item) => {
1021
+ if (isite.getValue(item, $scope.primary) == isite.getValue($scope.ngModel, $scope.primary)) {
1022
+ $scope.ngModel = item;
1023
+ item.$display = $scope.getValue(item) + attrs.space + $scope.getValue2(item);
1024
+ input.val(item.$display);
1025
+ }
1026
+ });
1027
+ }
1028
+ });
1029
+
1030
+ $scope.$watch('ngModel', (ngModel) => {
1031
+ input.val('');
1032
+
1033
+ $scope.ngModel = ngModel;
1034
+
1035
+ if (ngModel) {
1036
+ input.val(' ' + $scope.getNgModelValue(ngModel) + attrs.space + $scope.getNgModelValue2(ngModel));
1037
+ }
1038
+ });
1039
+
1040
+ $scope.updateModel = function (item) {
1041
+ $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
1042
+ input.val($scope.getNgModelValue($scope.ngModel) + attrs.space + $scope.getNgModelValue2($scope.ngModel));
1043
+ $timeout(() => {
1044
+ $scope.ngChange();
1045
+ });
1046
+ $scope.hide();
1047
+ };
1048
+ },
1049
+ template: `/*##client-side/directive-core/i-list.html*/`,
1050
+ };
1051
+ },
1052
+ ]);
1053
+
1054
+ app.directive('iChecklist', [
1055
+ '$interval',
1056
+ function ($interval) {
1057
+ return {
1058
+ restrict: 'E',
1059
+ required: 'ngModel',
1060
+ scope: {
1061
+ label: '@',
1062
+ primary: '@',
1063
+ display: '@',
1064
+ ngModel: '=',
1065
+ items: '=',
1066
+ like: '&',
1067
+ },
1068
+ link: function ($scope, element, attrs, ctrl) {
1069
+ attrs.primary = attrs.primary || 'id';
1070
+
1071
+ $scope.selectedItems = [];
1072
+
1073
+ $scope.$watch('ngModel', (ngModel) => {
1074
+ $scope.reload();
1075
+ });
1076
+
1077
+ $scope.reload = function () {
1078
+ $scope.selectedItems = [];
1079
+
1080
+ if ($scope.ngModel) {
1081
+ $scope.ngModel.forEach((mitem) => {
1082
+ $scope.selectedItems.push(mitem);
1083
+ });
1084
+
1085
+ if ($scope.items) {
1086
+ $scope.items.forEach((mitem) => {
1087
+ let exist = !1;
1088
+ $scope.selectedItems.forEach((sitem) => {
1089
+ if (mitem[$scope.primary] === sitem[$scope.primary]) {
1090
+ exist = !0;
1091
+ }
1092
+ });
1093
+ if (exist) {
1094
+ mitem.$selected = !0;
1095
+ } else {
1096
+ mitem.$selected = !1;
1097
+ }
1098
+ });
1099
+ }
1100
+ }
1101
+ if (!$scope.ngModel) {
1102
+ $scope.selectedItems = [];
1103
+ if ($scope.items) {
1104
+ $scope.items.forEach((mitem) => {
1105
+ mitem.$selected = !1;
1106
+ });
1107
+ }
1108
+ }
1109
+ };
1110
+
1111
+ $scope.change = function (item) {
1112
+ item.$selected = !item.$selected;
1113
+
1114
+ if (item.$selected) {
1115
+ let exsits = !1;
1116
+ $scope.selectedItems.forEach((sitem) => {
1117
+ if (sitem[$scope.primary] === item[$scope.primary]) {
1118
+ exsits = !0;
1119
+ }
1120
+ });
1121
+ if (!exsits) {
1122
+ $scope.selectedItems.push(item);
1123
+ }
1124
+ } else {
1125
+ $scope.selectedItems.forEach((sitem, index) => {
1126
+ if (sitem[$scope.primary] === item[$scope.primary]) {
1127
+ $scope.selectedItems.splice(index, 1);
1128
+ }
1129
+ });
1130
+ }
1131
+
1132
+ $scope.ngModel = $scope.selectedItems;
1133
+ };
1134
+ },
1135
+ template: `
1136
+ <div class="row padding check-list">
1137
+ <label class="title"> {{label}} </label>
1138
+ <div ng-repeat="item in items" ng-click="change(item);ngChange($event , item);" class="selector" ng-class="{'selected' : item.$selected , 'un-selected' : !item.$selected }" >
1139
+ <i ng-show="!item.$selected" class="fa fa-square"></i> <i ng-show="item.$selected" class="fa fa-check"></i> {{item[display]}}
1140
+ </div>
1141
+ </div>
1142
+ `,
1143
+ };
1144
+ },
1145
+ ]);
1146
+
1147
+ app.directive('iChecklist2', [
1148
+ '$interval',
1149
+ function ($interval) {
1150
+ return {
1151
+ restrict: 'E',
1152
+ required: 'ngModel',
1153
+ scope: {
1154
+ label: '@',
1155
+ primary: '@',
1156
+ display: '@',
1157
+ ngModel: '=',
1158
+ items: '=',
1159
+ like: '&',
1160
+ },
1161
+ link: function ($scope, element, attrs, ctrl) {
1162
+ attrs.primary = attrs.primary || 'id';
1163
+
1164
+ $scope.selectedItems = [];
1165
+
1166
+ $scope.$watch('ngModel', (ngModel) => {
1167
+ $scope.reload();
1168
+ });
1169
+
1170
+ $scope.reload = function () {
1171
+ $scope.selectedItems = [];
1172
+
1173
+ if ($scope.ngModel) {
1174
+ $scope.ngModel.forEach((mitem) => {
1175
+ $scope.selectedItems.push(mitem);
1176
+ });
1177
+
1178
+ if ($scope.items) {
1179
+ $scope.items.forEach((mitem) => {
1180
+ let exist = !1;
1181
+ $scope.selectedItems.forEach((sitem) => {
1182
+ if (mitem[$scope.primary] === sitem[$scope.primary]) {
1183
+ exist = !0;
1184
+ }
1185
+ });
1186
+ if (exist) {
1187
+ mitem.$selected = !0;
1188
+ } else {
1189
+ mitem.$selected = !1;
1190
+ }
1191
+ });
1192
+ }
1193
+ }
1194
+ if (!$scope.ngModel) {
1195
+ $scope.selectedItems = [];
1196
+ if ($scope.items) {
1197
+ $scope.items.forEach((mitem) => {
1198
+ mitem.$selected = !1;
1199
+ });
1200
+ }
1201
+ }
1202
+ };
1203
+
1204
+ $scope.change = function (item) {
1205
+ if (item.$selected) {
1206
+ let exsits = !1;
1207
+ $scope.selectedItems.forEach((sitem) => {
1208
+ if (sitem[$scope.primary] === item[$scope.primary]) {
1209
+ exsits = !0;
1210
+ }
1211
+ });
1212
+ if (!exsits) {
1213
+ $scope.selectedItems.push(item);
1214
+ }
1215
+ } else {
1216
+ $scope.selectedItems.forEach((sitem, index) => {
1217
+ if (sitem[$scope.primary] === item[$scope.primary]) {
1218
+ $scope.selectedItems.splice(index, 1);
1219
+ }
1220
+ });
1221
+ }
1222
+
1223
+ $scope.ngModel = $scope.selectedItems;
1224
+ };
1225
+ },
1226
+ template: `
1227
+ <div class="row padding check-list">
1228
+ <label class="title"> {{label}} </label>
1229
+ <div class="control" ng-repeat="item in items">
1230
+ <label class="checkbox" >
1231
+ <span > {{item[display]}} </span>
1232
+ <input type="checkbox" ng-model="item.$selected" ng-change="change(item)" >
1233
+ <span class="checkmark"></span>
1234
+ </label>
1235
+ </div>
1236
+ </div>
1237
+ `,
1238
+ };
1239
+ },
1240
+ ]);
1241
+
1242
+ app.directive('iRadiolist', [
1243
+ '$interval',
1244
+ function ($interval) {
1245
+ return {
1246
+ restrict: 'E',
1247
+ required: 'ngModel',
1248
+ scope: {
1249
+ label: '@',
1250
+ display: '@',
1251
+ ngModel: '=',
1252
+ items: '=',
1253
+ },
1254
+ link: function (scope, element, attrs) {
1255
+ scope.model = scope.ngModel;
1256
+
1257
+ scope.code = 'radio_' + Math.random();
1258
+
1259
+ scope.change = function (item) {
1260
+ scope.ngModel = item;
1261
+ };
1262
+
1263
+ scope.isChecked = function (item) {
1264
+ if (item && scope.ngModel && scope.ngModel.id === item.id) {
1265
+ return !0;
1266
+ }
1267
+ return !1;
1268
+ };
1269
+ },
1270
+ template: `
1271
+ <div class="row padding radio-list">
1272
+ <label class="title"> {{label}} </label>
1273
+ <div class="control" ng-repeat="item in items">
1274
+ <label class="radio" >
1275
+ <span > {{item[display]}} </span>
1276
+ <input name="{{code}}" type="radio" ng-model="model" ng-checked="isChecked(item)" ng-click="change(item)" ng-change="change(item)" >
1277
+ <span class="checkmark"></span>
1278
+ </label>
1279
+ </div>
1280
+ </div>
1281
+ `,
1282
+ };
1283
+ },
1284
+ ]);
1285
+
1286
+ app.directive('iFile', [
1287
+ '$interval',
1288
+ 'isite',
1289
+ function ($interval, isite) {
1290
+ return {
1291
+ restrict: 'E',
1292
+ required: 'ngModel',
1293
+ scope: {
1294
+ label: '@',
1295
+ type: '@',
1296
+ ngModel: '=',
1297
+ ngClick: '&',
1298
+ onSelected: '&',
1299
+ },
1300
+ link: function (scope, element, attrs, ctrl) {
1301
+ scope.type = scope.type || 'bg-green';
1302
+
1303
+ let input = $(element).find('input')[0];
1304
+ let a = $(element).find('a')[0];
1305
+
1306
+ if (attrs.view !== '') {
1307
+ a.addEventListener('click', function () {
1308
+ input.click();
1309
+ });
1310
+ }
1311
+
1312
+ input.addEventListener('change', function () {
1313
+ scope.ngModel = this.files[0].path;
1314
+ scope.onSelected(this.files[0].path);
1315
+ scope.$applyAsync();
1316
+ });
1317
+
1318
+ scope.$watch('ngModel', (ngModel) => {
1319
+ if (ngModel) {
1320
+ a.setAttribute('url', ngModel);
1321
+ }
1322
+ });
1323
+ },
1324
+ template: `
1325
+ <form class="form text-center pointer">
1326
+ <input class="hidden" type="file" name="file" />
1327
+ <a class="btn {{type}}" ngClick="ngClick()" url="{{ngModel}}"> {{label}} </a>
1328
+ </form>
1329
+ `,
1330
+ };
1331
+ },
1332
+ ]);
1333
+
1334
+ app.directive('iImage', [
1335
+ '$interval',
1336
+ 'isite',
1337
+ function ($interval, isite) {
1338
+ return {
1339
+ restrict: 'E',
1340
+ required: 'ngModel',
1341
+ scope: {
1342
+ category: '@',
1343
+ ngModel: '=',
1344
+ ngClick: '&',
1345
+ },
1346
+ link: function (scope, element, attrs, ctrl) {
1347
+ scope.category = scope.category || 'default';
1348
+
1349
+ let input = $(element).find('input')[0];
1350
+ let img = $(element).find('img')[0];
1351
+ let progress = $(element).find('progress')[0];
1352
+ $(progress).hide();
1353
+
1354
+ if (attrs.view !== '') {
1355
+ img.addEventListener('click', function () {
1356
+ input.click();
1357
+ });
1358
+ }
1359
+
1360
+ input.addEventListener('change', function () {
1361
+ isite.uploadImage(
1362
+ this.files,
1363
+ {
1364
+ category: scope.category,
1365
+ },
1366
+ (err, image, e) => {
1367
+ if (e) {
1368
+ $(progress).show();
1369
+ progress.value = e.loaded;
1370
+ progress.max = e.total;
1371
+ }
1372
+
1373
+ if (image) {
1374
+ scope.ngModel = image.url;
1375
+ }
1376
+ }
1377
+ );
1378
+ });
1379
+
1380
+ scope.$watch('ngModel', (ngModel) => {
1381
+ if (ngModel) {
1382
+ img.setAttribute('src', ngModel);
1383
+ }
1384
+ });
1385
+ },
1386
+ template: `
1387
+ <form class="form text-center pointer">
1388
+ <input class="hidden" type="file" name="file" />
1389
+ <img class="bg-white" ng-src="{{ngModel}}" ngClick="ngClick()" onerror="this.src='/images/no.jpg'" />
1390
+ <progress class="row"></progress>
1391
+ </form>
1392
+ `,
1393
+ };
1394
+ },
1395
+ ]);
1396
+
1397
+ app.directive('iUpload', [
1398
+ '$interval',
1399
+ 'isite',
1400
+ function ($interval, isite) {
1401
+ return {
1402
+ restrict: 'E',
1403
+ required: 'ngModel',
1404
+ scope: {
1405
+ label: '@',
1406
+ api: '@',
1407
+ type: '@',
1408
+ ngModel: '=',
1409
+ ngClick: '&',
1410
+ onUploaded: '&',
1411
+ },
1412
+ link: function (scope, element, attrs, ctrl) {
1413
+ scope.type = scope.type || 'bg-green';
1414
+
1415
+ let input = $(element).find('input')[0];
1416
+ let a = $(element).find('a')[0];
1417
+ let progress = $(element).find('progress')[0];
1418
+ $(progress).hide();
1419
+
1420
+ if (attrs.view !== '') {
1421
+ a.addEventListener('click', function () {
1422
+ input.click();
1423
+ });
1424
+ }
1425
+
1426
+ input.addEventListener('change', function () {
1427
+ isite.upload(
1428
+ this.files,
1429
+ {
1430
+ api: scope.api,
1431
+ },
1432
+ (err, file, e) => {
1433
+ if (e) {
1434
+ $(progress).show();
1435
+ progress.value = e.loaded;
1436
+ progress.max = e.total;
1437
+ }
1438
+
1439
+ if (file) {
1440
+ scope.ngModel = file.url;
1441
+ scope.onUploaded();
1442
+ }
1443
+ }
1444
+ );
1445
+ });
1446
+
1447
+ scope.$watch('ngModel', (ngModel) => {
1448
+ if (ngModel) {
1449
+ a.setAttribute('url', ngModel);
1450
+ }
1451
+ });
1452
+ },
1453
+ template: `
1454
+ <form class="form text-center pointer">
1455
+ <input class="hidden" type="file" name="file" />
1456
+ <a class="btn {{type}}" ngClick="ngClick()" url="{{ngModel}}"> {{label}} </a>
1457
+ <progress class="row"></progress>
1458
+ </form>
1459
+ `,
1460
+ };
1461
+ },
1462
+ ]);
1463
+
1464
+ app.directive('iFiles', [
1465
+ '$interval',
1466
+ 'isite',
1467
+ function ($interval, isite) {
1468
+ return {
1469
+ restrict: 'E',
1470
+ required: 'ngModel',
1471
+ scope: {
1472
+ category: '@',
1473
+ label: '@',
1474
+ ngModel: '=',
1475
+ },
1476
+ link: function (scope, element, attrs, ctrl) {
1477
+ if (attrs.view === '') {
1478
+ scope.viewOnly = !0;
1479
+ }
1480
+
1481
+ let progress = $(element).find('progress')[0];
1482
+
1483
+ scope.category = scope.category || 'default';
1484
+ scope.id = Math.random().toString().replace('.', '_');
1485
+ scope.deleteFile = function (file) {
1486
+ isite.deleteFile(file, () => {
1487
+ for (let i = 0; i < scope.ngModel.length; i++) {
1488
+ let f = scope.ngModel[i];
1489
+ if (f.url === file.url) {
1490
+ scope.ngModel.splice(i, 1);
1491
+ return;
1492
+ }
1493
+ }
1494
+ });
1495
+ };
1496
+
1497
+ let setEvent = !1;
1498
+ $interval(() => {
1499
+ if (setEvent) {
1500
+ return;
1501
+ }
1502
+
1503
+ if (attrs.view !== '') {
1504
+ let btn = document.querySelector('#btn_' + scope.id);
1505
+ if (btn) {
1506
+ setEvent = !0;
1507
+ btn.addEventListener('click', function () {
1508
+ document.querySelector('#input_' + scope.id).click();
1509
+ });
1510
+ }
1511
+
1512
+ let input = document.querySelector('#input_' + scope.id);
1513
+ if (input) {
1514
+ input.addEventListener('change', function () {
1515
+ isite.uploadFile(
1516
+ this.files,
1517
+ {
1518
+ category: scope.category,
1519
+ },
1520
+ (err, file, e) => {
1521
+ if (e) {
1522
+ $(progress).show();
1523
+ progress.value = e.loaded;
1524
+ progress.max = e.total;
1525
+ }
1526
+
1527
+ if (file) {
1528
+ if (typeof scope.ngModel === 'undefined') {
1529
+ scope.ngModel = [];
1530
+ }
1531
+ scope.ngModel.push(file.url);
1532
+ }
1533
+ }
1534
+ );
1535
+ });
1536
+ }
1537
+ } else {
1538
+ setEvent = !0;
1539
+ }
1540
+ }, 500);
1541
+ },
1542
+ template: `
1543
+ <div class="files">
1544
+ <label> {{label}} </label>
1545
+ <form ng-if="viewOnly !== !0" id="img_{{id}}" class="form text-center pointer">
1546
+ <input id="input_{{id}}" class="hidden" type="file" name="file" />
1547
+ <a id="btn_{{id}}" class="btn bg-green"> <i class="fa fa-upload white"></i> </a>
1548
+ </form>
1549
+ <progress class="row"></progress>
1550
+ <div class="padding">
1551
+
1552
+ <div class="row padding" ng-repeat="f in ngModel">
1553
+ <h2>
1554
+ <a class="btn default bg-blue" href="{{f.url}}"> <i class="fa fa-2x fa-download white"></i> </a>
1555
+ <a ng-if="viewOnly !== !0" class="btn default bg-red" ng-click="deleteFile(f)"> <i class="fa fa-trash white"></i> </a>
1556
+ <span> {{f.name}} </span>
1557
+ </h2>
1558
+ </div>
1559
+ </div>
1560
+ </div>
1561
+
1562
+ `,
1563
+ };
1564
+ },
1565
+ ]);
1566
+
1567
+ app.directive('iDrag', [
1568
+ '$document',
1569
+ function ($document) {
1570
+ return function (scope, element, attr) {
1571
+ var startX = 0,
1572
+ startY = 0,
1573
+ x = 0,
1574
+ y = 0;
1575
+
1576
+ element.css({
1577
+ position: 'relative',
1578
+ });
1579
+
1580
+ element.on('mousedown', function (event) {
1581
+ event.preventDefault();
1582
+ startX = event.screenX - x;
1583
+ startY = event.screenY - y;
1584
+ $document.on('mousemove', mousemove);
1585
+ $document.on('mouseup', mouseup);
1586
+ });
1587
+
1588
+ function mousemove(event) {
1589
+ y = event.screenY - startY;
1590
+ x = event.screenX - startX;
1591
+ element.css({
1592
+ top: y + 'px',
1593
+ left: x + 'px',
1594
+ });
1595
+ }
1596
+
1597
+ function mouseup() {
1598
+ $document.off('mousemove', mousemove);
1599
+ $document.off('mouseup', mouseup);
1600
+ }
1601
+ };
1602
+ },
1603
+ ]);
1604
+
1605
+ app.directive('iTreeview', [
1606
+ '$interval',
1607
+ '$timeout',
1608
+ 'isite',
1609
+ function ($interval, $timeout, isite) {
1610
+ return {
1611
+ restrict: 'E',
1612
+ require: 'ngModel',
1613
+ scope: {
1614
+ v: '@',
1615
+ label: '@',
1616
+ display: '@',
1617
+ display2: '@',
1618
+ disabled: '@',
1619
+ space: '@',
1620
+ primary: '@',
1621
+ ngValue: '@',
1622
+ ngModel: '=',
1623
+ ngSearch: '=',
1624
+ ngChange: '&',
1625
+ ngClick: '&',
1626
+ ngAdd: '&',
1627
+ ngNode: '&',
1628
+ ngEdit: '&',
1629
+ ngDelete: '&',
1630
+ nodes: '=',
1631
+ },
1632
+ link: function ($scope, element, attrs, ctrl) {
1633
+ attrs.display = attrs.display || 'name';
1634
+ attrs.primary = attrs.primary || 'id';
1635
+ attrs.space = attrs.space || ' ';
1636
+ attrs.ngValue = attrs.ngValue || '';
1637
+
1638
+ $scope.source = {};
1639
+
1640
+ $scope.setNodes = function (v_node) {
1641
+ v_node.nodes.forEach((v_node2) => {
1642
+ v_node2.nodes = v_node2.nodes || [];
1643
+ $scope.nodes.forEach((node) => {
1644
+ if (node.$parent_id == v_node2.id) {
1645
+ node.v_display = node.v_display || '';
1646
+ node.v_display += node[attrs.display];
1647
+
1648
+ let exist = !1;
1649
+ v_node2.nodes.forEach((n) => {
1650
+ if (n.id == node.id) {
1651
+ exist = !0;
1652
+ }
1653
+ });
1654
+ if (!exist) {
1655
+ v_node2.nodes.push(node);
1656
+ }
1657
+ }
1658
+ });
1659
+ $scope.setNodes(v_node2);
1660
+ });
1661
+ };
1662
+
1663
+ $scope.v_nodes = [];
1664
+
1665
+ $scope.$watch('ngModel', (ngModel) => {
1666
+ if (ngModel) {
1667
+ $scope.ngModel = ngModel;
1668
+ $scope.ngModel.v_display = $scope.ngModel.v_display || ngModel[attrs.display];
1669
+ }
1670
+ });
1671
+
1672
+ $scope.$watch('nodes', (nodes) => {
1673
+ $scope.v_nodes = [];
1674
+ if (nodes) {
1675
+ nodes.forEach((node) => {
1676
+ node.$parent_id = node.parent_id || 0;
1677
+ node.v_display = node.v_display || '';
1678
+ node.v_display += node[attrs.display];
1679
+ if (node.$parent_id == 0) {
1680
+ let exist = !1;
1681
+ $scope.v_nodes.forEach((n) => {
1682
+ if (n.id == node.id) {
1683
+ exist = !0;
1684
+ }
1685
+ });
1686
+ if (!exist) {
1687
+ $scope.v_nodes.push(node);
1688
+ }
1689
+ }
1690
+ });
1691
+
1692
+ $scope.v_nodes.forEach((v_node) => {
1693
+ v_node.nodes = v_node.nodes || [];
1694
+
1695
+ nodes.forEach((node) => {
1696
+ node.$parent_id = node.parent_id || 0;
1697
+ if (node.$parent_id == v_node.id) {
1698
+ node.v_display = node.v_display || '';
1699
+ node.v_display += node[attrs.display];
1700
+
1701
+ let exist = !1;
1702
+ v_node.nodes.forEach((n) => {
1703
+ if (n.id == node.id) {
1704
+ exist = !0;
1705
+ }
1706
+ });
1707
+ if (!exist) {
1708
+ v_node.nodes.push(node);
1709
+ }
1710
+ }
1711
+ });
1712
+
1713
+ $scope.setNodes(v_node);
1714
+ });
1715
+ }
1716
+ });
1717
+ },
1718
+ template: `
1719
+ <div class="treeview">
1720
+ <ul >
1721
+ <li ng-dblclick="$event.preventDefault();$event.stopPropagation();source.$actions = !0" ng-mouseleave="source.$actions = !1">
1722
+
1723
+ <i ng-hide="openTree" class="fa fa-folder"></i> <i ng-show="openTree" class="fa fa-folder"></i>
1724
+
1725
+
1726
+ <span ng-click="openTree = !openTree" class="title"> {{label}} <small class="display"> [ {{ngModel.v_display}} ] </small> </span>
1727
+ <div class="actions" ng-show="source.$actions === !0">
1728
+ <i-button type="add default" ng-click="ngClick($event , ngModel);ngNode($event , ngModel)"></i-button>
1729
+ </div>
1730
+ <i-treenode display="{{display}}" ng-click="ngClick($event)" ng-add="ngAdd()" ng-edit="ngEdit()" ng-delete="ngDelete()" ng-show="openTree" ng-model="ngModel" nodes="v_nodes" ></i-treenode>
1731
+ </li>
1732
+ </ul>
1733
+ </div>
1734
+ `,
1735
+ };
1736
+ },
1737
+ ]);
1738
+
1739
+ app.directive('iTreenode', [
1740
+ '$interval',
1741
+ '$timeout',
1742
+ 'isite',
1743
+ function ($interval, $timeout, isite) {
1744
+ return {
1745
+ restrict: 'E',
1746
+ require: 'ngModel',
1747
+ scope: {
1748
+ v: '@',
1749
+ label: '@',
1750
+ display: '@',
1751
+ display2: '@',
1752
+ disabled: '@',
1753
+ space: '@',
1754
+ primary: '@',
1755
+ ngValue: '@',
1756
+ ngChange: '&',
1757
+ ngClick: '&',
1758
+ ngAdd: '&',
1759
+ ngEdit: '&',
1760
+ ngDelete: '&',
1761
+ ngModel: '=',
1762
+ ngSearch: '=',
1763
+ nodes: '=',
1764
+ nodes: '=',
1765
+ },
1766
+ link: function ($scope, element, attrs, ctrl) {
1767
+ attrs.display = attrs.display || 'name';
1768
+ attrs.primary = attrs.primary || 'id';
1769
+ attrs.space = attrs.space || ' ';
1770
+ attrs.ngValue = attrs.ngValue || '';
1771
+ $scope.nodes = $scope.nodes || [];
1772
+
1773
+ $scope.v_nodes = [];
1774
+
1775
+ $scope.$watch('nodes', (nodes) => {
1776
+ $scope.v_nodes = [];
1777
+ if (nodes) {
1778
+ nodes.forEach((node, i) => {
1779
+ if (node.nodes) {
1780
+ node.nodes.forEach((node2, i) => {
1781
+ node2.$parent_id = node2.parent_id || node.id;
1782
+ node2.v_display = node.v_display || ' ';
1783
+ node2.v_display += ' - ' + node2[attrs.display];
1784
+ });
1785
+ }
1786
+ });
1787
+ }
1788
+ });
1789
+
1790
+ $scope.updateParentModal = function (parent, node) {
1791
+ if (parent) {
1792
+ parent.ngModel = node;
1793
+ if (parent.$parent) {
1794
+ $scope.updateParentModal(parent.$parent, node);
1795
+ }
1796
+ }
1797
+ };
1798
+
1799
+ $scope.unSelectParent = function (parent) {
1800
+ if (parent && parent.nodes) {
1801
+ parent.nodes.forEach((node) => {
1802
+ node.$selected = !1;
1803
+ });
1804
+ if (parent.$parent) {
1805
+ $scope.unSelectParent(parent.$parent);
1806
+ }
1807
+ }
1808
+ };
1809
+
1810
+ $scope.unSelectNodes = function (nodes) {
1811
+ if (nodes) {
1812
+ nodes.forEach((node) => {
1813
+ node.$selected = !1;
1814
+ if (node.nodes) {
1815
+ $scope.unSelectNodes(node.nodes);
1816
+ }
1817
+ });
1818
+ }
1819
+ };
1820
+
1821
+ $scope.updateModal = function (node) {
1822
+ $scope.ngModel = node;
1823
+ $scope.updateParentModal($scope.$parent, node);
1824
+ };
1825
+
1826
+ $scope.selected = function (node) {
1827
+ $scope.unSelectParent($scope.$parent);
1828
+ $scope.unSelectNodes($scope.nodes);
1829
+
1830
+ if (node.nodes) {
1831
+ node.nodes.forEach((itm) => {
1832
+ itm.$selected = !1;
1833
+ });
1834
+ }
1835
+
1836
+ node.$selected = !0;
1837
+ };
1838
+ },
1839
+ template: `
1840
+ <div class="treenode">
1841
+ <ul >
1842
+ <li ng-repeat="node in nodes" >
1843
+ <div class="row" ng-dblclick="$event.preventDefault();$event.stopPropagation();node.$actions = !0;source.$actions = !1" ng-mouseleave="node.$actions = !1">
1844
+ <span ng-show="node.nodes.length > 0" ng-click="node.$expand = !node.$expand;">
1845
+ <i ng-hide="node.$expand" class="fa fa-caret-left"></i> <i ng-show="node.$expand" class="fa fa-caret-down"></i>
1846
+ </span>
1847
+ <span ng-hide="node.nodes.length > 0" >
1848
+ <i class="fa fa-file"></i>
1849
+ </span>
1850
+
1851
+ <span class="text" ng-class="{'selected' : node.$selected == !0}" ng-click="ngClick($event , node);node.$expand = !node.$expand;selected(node);updateModal(node)" > {{node[display]}} </span>
1852
+ <div class="actions" ng-show="node.$actions === !0">
1853
+ <i-button type="add default" ng-click="ngAdd(node)"></i-button>
1854
+ <i-button type="edit default" ng-click="ngEdit(node)"></i-button>
1855
+ <i-button type="delete default" ng-click="ngDelete(node)"></i-button>
1856
+ </div>
1857
+ </div>
1858
+ <i-treenode display="{{display}}" ng-click="ngClick($event)" ng-add="ngAdd()" ng-edit="ngEdit()" ng-delete="ngDelete()" ng-show="node.$expand" ng-model="ngModel" nodes="node.nodes" nodes="node.nodes"></i-treenode>
1859
+ </li>
1860
+ </ul>
1861
+ </div>
1862
+ `,
1863
+ };
1864
+ },
1865
+ ]);