isite 2022.8.1 → 2022.8.4

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.
@@ -15,6 +15,7 @@ app.directive('iControl', function () {
15
15
  },
16
16
  link: function ($scope, element, attrs, ctrl) {
17
17
  attrs.type = attrs.type || 'text';
18
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
18
19
 
19
20
  if (typeof attrs.disabled !== 'undefined') {
20
21
  attrs.disabled = 'disabled';
@@ -30,8 +31,8 @@ app.directive('iControl', function () {
30
31
  },
31
32
  template: `
32
33
  <div class="mb-3 {{class2}}">
33
- <label for="id2" class="form-label">{{label}}</label>
34
- <input id="id2" ng-disabled="disabled" autofocus v="{{v}}" type="{{type}}" ng-model="ngModel" ng-change="ngChange()" ngKeydown="ngKeydown()" class="form-control" placeholder="{{placeholder}}" aria-label="{{label}}" />
34
+ <label for="{{id2}}" class="form-label">{{label}}</label>
35
+ <input id="{{id2}}" ng-disabled="disabled" autofocus v="{{v}}" type="{{type}}" ng-model="ngModel" ng-change="ngChange()" ngKeydown="ngKeydown()" class="form-control" placeholder="{{placeholder}}" aria-label="{{label}}" />
35
36
  <div class="invalid-feedback">
36
37
 
37
38
  </div>
@@ -40,7 +41,43 @@ app.directive('iControl', function () {
40
41
  };
41
42
  });
42
43
 
43
- app.directive('iCheckbox', function () {
44
+ app.directive('iTextarea', function () {
45
+ return {
46
+ restrict: 'E',
47
+ require: 'ngModel',
48
+ scope: {
49
+ v: '@',
50
+ label: '@',
51
+ id2: '@',
52
+ disabled: '@',
53
+ rows: '@',
54
+ ngModel: '=',
55
+ ngChange: '&',
56
+ },
57
+ link: function ($scope, element, attrs, ctrl) {
58
+ if (typeof attrs.disabled !== 'undefined') {
59
+ attrs.disabled = 'disabled';
60
+ } else {
61
+ attrs.disabled = '';
62
+ }
63
+ $scope.rows = $scope.rows || 4;
64
+ $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
65
+ $(element)
66
+ .find('textarea')
67
+ .focus(() => {
68
+ $('.popup').hide();
69
+ });
70
+ },
71
+ template: `
72
+ <div class="mb-3">
73
+ <label for="{{id2}}" class="form-label">{{label}}</label>
74
+ <textarea ng-disabled="disabled" class="form-control" id="{{id2}}" ng-model="ngModel" ng-change="ngChange()" v="{{v}}" rows="{{rows}}"></textarea>
75
+ </div>
76
+ `,
77
+ };
78
+ });
79
+
80
+ app.directive('iCheckbox', function ($timeout) {
44
81
  return {
45
82
  restrict: 'E',
46
83
  require: 'ngModel',
@@ -57,10 +94,17 @@ app.directive('iCheckbox', function () {
57
94
  $scope.disabled = '';
58
95
  }
59
96
  $scope.id2 = $scope.id2 || 'input_' + Math.random().toString().replace('0.', '');
97
+ $scope.changed = function () {
98
+ $timeout(() => {
99
+ if ($scope.ngChange) {
100
+ $scope.ngChange();
101
+ }
102
+ }, 100);
103
+ };
60
104
  },
61
105
  template: `
62
106
  <div class="form-check">
63
- <input ng-change="ngChange()" ng-disabled="disabled" class="form-check-input" type="checkbox" ng-model="ngModel" id="{{id2}}">
107
+ <input ng-change="changed()" ng-disabled="disabled" class="form-check-input" type="checkbox" ng-model="ngModel" id="{{id2}}">
64
108
  <label class="form-check-label" for="{{id2}}">
65
109
  {{label}}
66
110
  </label>
@@ -108,234 +152,469 @@ app.directive('iButton', function () {
108
152
  scope: {
109
153
  label: '@',
110
154
  type: '@',
111
- ngClick: '&',
155
+ loading: '@',
156
+ click: '&',
112
157
  fa: '@',
113
158
  },
114
159
  link: function ($scope, element, attrs, ctrl) {
115
- attrs.type = attrs.type || '';
116
- if (attrs.type.like('*exit*') || attrs.type.like('*close*')) {
117
- attrs.fa = 'times';
118
- } else if (attrs.type.like('*view*') || attrs.type.like('*details*')) {
119
- attrs.fa = 'file';
120
- } else if (attrs.type.like('*add*') || attrs.type.like('*new*')) {
121
- attrs.fa = 'plus-circle';
122
- } else if (attrs.type.like('*update*') || attrs.type.like('*edit*')) {
123
- attrs.fa = 'edit';
124
- } else if (attrs.type.like('*save*')) {
125
- attrs.fa = 'save';
126
- } else if (attrs.type.like('*delete*') || attrs.type.like('*remove*')) {
127
- attrs.fa = 'trash';
128
- } else if (attrs.type.like('*print*')) {
129
- attrs.fa = 'print';
130
- } else if (attrs.type.like('*search*')) {
131
- attrs.fa = 'search';
132
- } else if (attrs.type.like('*export*') || attrs.type.like('*excel*')) {
133
- attrs.fa = 'table';
134
- } else {
160
+ $scope.type = $scope.type || '';
161
+ $scope.class = $scope.class = 'btn-dark';
162
+ $scope.fa = $scope.fa || $scope.label ? '' : 'fas fa-play';
163
+
164
+ if ($scope.type.like('*add*') || $scope.type.like('*new*')) {
165
+ $scope.fa = 'fas fa-plus';
135
166
  $scope.class = 'btn-primary';
167
+ } else if ($scope.type.like('*update*') || $scope.type.like('*edit*')) {
168
+ $scope.fa = 'fas fa-edit';
169
+ $scope.class = 'btn-warning';
170
+ } else if ($scope.type.like('*save*')) {
171
+ $scope.fa = 'fas fa-save';
172
+ $scope.class = 'btn-success';
173
+ } else if ($scope.type.like('*view*') || $scope.type.like('*details*')) {
174
+ $scope.fa = 'fas fa-eye';
175
+ $scope.class = 'btn-info';
176
+ } else if ($scope.type.like('*delete*') || $scope.type.like('*remove*')) {
177
+ $scope.fa = 'fas fa-trash';
178
+ $scope.class = 'btn-danger';
179
+ } else if ($scope.type.like('*exit*') || $scope.type.like('*close*')) {
180
+ $scope.fa = 'fas fa-times-circle';
181
+ $scope.class = 'btn-danger';
182
+ } else if ($scope.type.like('*print*')) {
183
+ $scope.fa = 'fas fa-print';
184
+ $scope.class = 'btn-secondary';
185
+ } else if ($scope.type.like('*search*')) {
186
+ $scope.fa = 'search';
187
+ } else if ($scope.type.like('*export*') || $scope.type.like('*excel*')) {
188
+ $scope.fa = 'fas fa-file-export';
189
+ $scope.class = 'btn-secondary';
136
190
  }
191
+ $scope.$watch('loading', (loading) => {
192
+ if (loading === 'true') {
193
+ $scope.busy = true;
194
+ } else {
195
+ $scope.busy = false;
196
+ }
197
+ });
137
198
  },
138
199
  template: `
139
- <a type="button" class="btn {{class}}" ng-click="ngClick()">{{label}}</a>
200
+ <button class="btn {{class}}" type="button" ng-click="click()" ng-disabled="busy">
201
+ <span ng-show="busy" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
202
+ {{label}}
203
+ <i class="{{fa}}"></i>
204
+ </button>
140
205
  `,
141
206
  };
142
207
  });
208
+ app.directive('iList', [
209
+ '$interval',
210
+ '$timeout',
211
+ 'isite',
212
+ function ($interval, $timeout, isite) {
213
+ return {
214
+ restrict: 'E',
215
+ require: 'ngModel',
216
+ scope: {
217
+ v: '@',
218
+ label: '@',
219
+ display: '@',
220
+ display2: '@',
221
+ disabled: '@',
222
+ css: '@',
223
+ space: '@',
224
+ primary: '@',
225
+ ngValue: '@',
226
+ ngModel: '=',
227
+ ngSearch: '=',
228
+ ngChange: '&',
229
+ ngAdd: '&',
230
+ items: '=',
231
+ },
232
+ link: function ($scope, element, attrs, ctrl) {
233
+ $scope.primary = $scope.primary || 'id';
234
+ $scope.display = $scope.display || 'name';
235
+ $scope.display2 = $scope.display2 || '';
236
+ $scope.space = $scope.space || ' - ';
237
+ attrs.ngValue = attrs.ngValue || '';
143
238
 
144
- app.directive('iDate', function () {
145
- return {
146
- link: function (scope, element, attrs) {
147
- if (typeof attrs.disabled !== 'undefined') {
148
- attrs.disabled = 'disabled';
149
- } else {
150
- attrs.disabled = '';
151
- }
152
-
153
- $(element)
154
- .find('select')
155
- .focus(() => {
156
- $('.popup').hide();
157
- });
158
-
159
- scope.days1 = [];
160
- for (let i = 1; i < 32; i++) {
161
- scope.days1.push(i);
162
- }
163
- scope.years1 = [];
164
- for (let i = 1900; i < 2100; i++) {
165
- scope.years1.push(i);
166
- }
167
- scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
168
- },
169
- restrict: 'E',
170
- require: 'ngModel',
171
- scope: {
172
- v: '@',
173
- label: '@',
174
- disabled: '@',
175
- ngModel: '=',
176
- },
177
- template: `
178
- <div class="row i-date">
179
-
180
- <div class=" control">
181
- <label> {{label}} </label>
182
- <div class="row">
183
- <div class="col3 day">
184
- <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.day" class="appearance-none no-border-left no-border-radius" >
185
- <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
186
- </select>
187
- </div>
188
- <div class="col5 month">
189
- <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.month" class="appearance-none no-border-left no-border-right no-border-radius" >
190
- <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
191
- </select>
192
- </div>
193
- <div class="col4 year">
194
- <select ng-disabled="disabled" v="{{v}}" ng-model="ngModel.year" class="appearance-none no-border-right no-border-radius" >
195
- <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
196
- </select>
197
- </div>
198
- </div>
199
- </div>
200
-
201
-
202
- </div>
203
- `,
204
- };
205
- });
206
-
207
- app.directive('iDate2', function () {
208
- return {
209
- link: function ($scope, element, attrs) {
210
- if (typeof attrs.disabled !== 'undefined') {
211
- attrs.disabled = 'disabled';
212
- } else {
213
- attrs.disabled = '';
214
- }
215
-
216
- $scope.y_search = attrs.year || '202';
217
- $scope.m_search = attrs.month || '';
218
- $scope.d_search = attrs.day || '';
219
-
220
- $scope.days1 = [];
221
- for (let i = 1; i < 32; i++) {
222
- $scope.days1.push({
223
- id: i,
224
- name: i,
225
- });
226
- }
227
- $scope.years1 = [];
228
- for (let i = 1900; i < 2100; i++) {
229
- $scope.years1.push({
230
- id: i,
231
- name: i,
232
- });
233
- }
234
-
235
- $scope.monthes1 = [
236
- { id: 0, name: 'يناير / Jan' },
237
- { id: 1, name: 'فبراير / Feb' },
238
- { id: 2, name: 'مارس / Mar' },
239
- { id: 3, name: 'ابريل / Aper' },
240
- { id: 4, name: 'مايو / May' },
241
- { id: 5, name: 'يونيو / June' },
242
- { id: 6, name: 'يوليو / Jule' },
243
- { id: 7, name: 'اغسطس / Aug' },
244
- { id: 8, name: 'سبتمبر / Sep' },
245
- { id: 9, name: 'اكتوبر / Oct' },
246
- { id: 10, name: 'نوفمبر / Nov' },
247
- { id: 11, name: 'ديسمبر / Des' },
248
- ];
249
-
250
- $scope.model = null;
239
+ $scope.searchElement = $(element).find('.dropdown .search');
240
+ $scope.popupElement = $(element).find('.dropdown .dropdown-content');
251
241
 
252
- $scope.$watch('ngModel', function (ngModel) {
253
- if (ngModel) {
254
- ngModel = new Date(ngModel);
255
- $scope.model = $scope.model || {};
256
- $scope.model.day = ngModel.getDate();
257
- $scope.model.day_name = $scope.model.day;
258
- $scope.model.month = ngModel.getMonth();
259
- $scope.model.month_name = $scope.monthes1.find((m) => m.id == $scope.model.month).name;
260
- $scope.model.year = ngModel.getFullYear();
261
- $scope.model.year_name = $scope.model.year;
242
+ if (typeof attrs.disabled !== 'undefined') {
243
+ attrs.disabled = 'disabled';
262
244
  } else {
263
- $scope.model = $scope.model || {};
264
- $scope.model.day = 0;
265
- $scope.model.day_name = '';
266
- $scope.model.month = -1;
267
- $scope.model.month_name = '';
268
- $scope.model.year = 0;
269
- $scope.model.year_name = '';
245
+ attrs.disabled = '';
270
246
  }
271
- });
272
247
 
273
- $scope.setDay = function () {
274
- $scope.ngModel = new Date();
275
- };
276
- $scope.updateDate = function (date) {
277
- if (date.year) {
278
- $scope.model.year = date.year.id;
279
- $scope.model.year_name = date.year.name;
280
- } else if (date.month) {
281
- $scope.model.month = date.month.id;
282
- $scope.model.month_name = date.month.name;
283
- } else if (date.day) {
284
- $scope.model.day = date.day.id;
285
- $scope.model.day_name = date.day.name;
248
+ if (typeof attrs.ngAdd == 'undefined') {
249
+ $scope.fa_add = 'fa-search';
250
+ } else {
251
+ $scope.fa_add = 'fa-plus';
286
252
  }
287
253
 
288
- if ($scope.model && $scope.model.year && $scope.model.day && $scope.model.month > -1) {
289
- $scope.ngModel = new Date($scope.model.year, $scope.model.month, $scope.model.day, 0, 0, 0);
254
+ if (typeof attrs.ngSearch == 'undefined') {
255
+ $scope.showSearch = !1;
290
256
  } else {
291
- delete $scope.ngModel;
257
+ $scope.showSearch = !0;
292
258
  }
293
- };
294
- },
295
- restrict: 'E',
296
- require: 'ngModel',
297
- scope: {
298
- v: '@',
299
- disabled: '@',
300
- label: '@',
301
- ngModel: '=',
302
- },
303
- template: `/*##client-side/sub/i-date2.content.html*/`,
304
- };
305
- });
306
259
 
307
- app.directive('iTime', function () {
308
- return {
309
- link: function ($scope, element, attrs) {
310
- if (typeof attrs.disabled !== 'undefined') {
311
- attrs.disabled = 'disabled';
312
- } else {
313
- attrs.disabled = '';
314
- }
260
+ let input = $(element).find('input');
261
+ $(element).hover(
262
+ () => {
263
+ $scope.popupElement.css('display', 'block');
264
+ },
265
+ () => {
266
+ $scope.popupElement.css('display', 'none');
267
+ }
268
+ );
269
+ $scope.focus = function () {
270
+ $('.i-list .dropdown-content').css('display', 'none');
271
+ $scope.popupElement.css('display', 'block');
272
+ $scope.searchElement.focus();
273
+ };
274
+ $scope.hide = function () {
275
+ $scope.popupElement.css('display', 'none');
276
+ };
315
277
 
316
- $scope.model = {};
278
+ $scope.getValue = function (item) {
279
+ let v = isite.getValue(item, $scope.display);
280
+ return v || '';
281
+ };
317
282
 
318
- $scope.hours = [];
319
- for (let i = 1; i < 25; i++) {
320
- $scope.hours.push(i);
321
- }
283
+ $scope.getValue2 = function (item) {
284
+ if ($scope.display2) {
285
+ return isite.getValue(item, $scope.display2) || '';
286
+ }
287
+ return '';
288
+ };
322
289
 
323
- $scope.minutes = [];
324
- for (let i = 0; i < 60; i++) {
325
- $scope.minutes.push(i);
326
- }
290
+ $scope.getNgModelValue = function (ngModel) {
291
+ if (ngModel && $scope.display && $scope.ngValue) {
292
+ return isite.getValue(ngModel, $scope.display.replace($scope.ngValue + '.', '')) || '';
293
+ } else if (ngModel && $scope.display) {
294
+ return isite.getValue(ngModel, $scope.display) || '';
295
+ }
296
+ return '';
297
+ };
327
298
 
328
- $(element)
329
- .find('select')
330
- .focus(() => {
331
- $('.popup').hide();
332
- });
299
+ $scope.getNgModelValue2 = function (ngModel) {
300
+ if (ngModel && $scope.display2 && $scope.ngValue) {
301
+ return isite.getValue(ngModel, $scope.display2.replace($scope.ngValue + '.', '')) || '';
302
+ } else if (ngModel && $scope.display2) {
303
+ return isite.getValue(ngModel, $scope.display2) || '';
304
+ }
305
+ return '';
306
+ };
333
307
 
334
- $scope.$watch('ngModel', function (ngModel) {
335
- if (ngModel) {
336
- ngModel.date = new Date(ngModel.date);
337
- $scope.model = $scope.model || {};
338
- $scope.model.hour = ngModel.hour;
308
+ $scope.getNgValue = function (item) {
309
+ if (item && $scope.ngValue) {
310
+ return isite.getValue(item, $scope.ngValue);
311
+ }
312
+ return item;
313
+ };
314
+
315
+ $scope.$watch('items', (items) => {
316
+ input.val('');
317
+
318
+ if (items) {
319
+ items.forEach((item) => {
320
+ if ($scope.display2) {
321
+ item.$display = $scope.getValue(item) + $scope.space + $scope.getValue2(item);
322
+ } else {
323
+ item.$display = $scope.getValue(item);
324
+ }
325
+ });
326
+ }
327
+
328
+ if (items && $scope.ngModel) {
329
+ items.forEach((item) => {
330
+ if (isite.getValue(item, $scope.primary) == isite.getValue($scope.ngModel, $scope.primary)) {
331
+ $scope.ngModel = item;
332
+ if ($scope.display2) {
333
+ item.$display = $scope.getValue(item) + $scope.space + $scope.getValue2(item);
334
+ } else {
335
+ item.$display = $scope.getValue(item);
336
+ }
337
+
338
+ input.val(item.$display);
339
+ }
340
+ });
341
+ }
342
+ });
343
+
344
+ $scope.$watch('ngModel', (ngModel) => {
345
+ input.val('');
346
+
347
+ $scope.ngModel = ngModel;
348
+
349
+ if (ngModel) {
350
+ if ($scope.display2) {
351
+ input.val(' ' + $scope.getNgModelValue(ngModel) + $scope.space + $scope.getNgModelValue2(ngModel));
352
+ } else {
353
+ input.val(' ' + $scope.getNgModelValue(ngModel));
354
+ }
355
+ }
356
+ });
357
+
358
+ $scope.updateModel = function (item) {
359
+ $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
360
+ if ($scope.display2) {
361
+ input.val($scope.getNgModelValue($scope.ngModel) + $scope.space + $scope.getNgModelValue2($scope.ngModel));
362
+ } else {
363
+ input.val($scope.getNgModelValue($scope.ngModel));
364
+ }
365
+ $timeout(() => {
366
+ if ($scope.ngChange) {
367
+ $scope.ngChange();
368
+ }
369
+ }, 100);
370
+ $scope.hide();
371
+ };
372
+ },
373
+ template: `/*##client-side/sub/i-list2.content.html*/`,
374
+ };
375
+ },
376
+ ]);
377
+ app.directive('iChecklist', [
378
+ '$interval',
379
+ '$timeout',
380
+ function ($interval, $timeout) {
381
+ return {
382
+ restrict: 'E',
383
+ required: 'ngModel',
384
+ scope: {
385
+ label: '@',
386
+ primary: '@',
387
+ display: '@',
388
+ class2: '@',
389
+ ngModel: '=',
390
+ items: '=',
391
+ like: '&',
392
+ ngChange: '&',
393
+ },
394
+ link: function ($scope, element, attrs, ctrl) {
395
+ $scope.primary = $scope.primary || 'id';
396
+ $scope.display = $scope.display || 'name';
397
+ $scope.class2 = $scope.class2 || 'col';
398
+ $scope.selectedItems = [];
399
+
400
+ $scope.$watch('ngModel', (ngModel) => {
401
+ $scope.reload();
402
+ });
403
+
404
+ $scope.reload = function () {
405
+ $scope.selectedItems = [];
406
+
407
+ if ($scope.ngModel) {
408
+ $scope.ngModel.forEach((mitem) => {
409
+ $scope.selectedItems.push(mitem);
410
+ });
411
+
412
+ if ($scope.items) {
413
+ $scope.items.forEach((mitem) => {
414
+ let exist = !1;
415
+ $scope.selectedItems.forEach((sitem) => {
416
+ if (mitem[$scope.primary] === sitem[$scope.primary]) {
417
+ exist = !0;
418
+ }
419
+ });
420
+ if (exist) {
421
+ mitem.$selected = !0;
422
+ } else {
423
+ mitem.$selected = !1;
424
+ }
425
+ });
426
+ }
427
+ }
428
+ if (!$scope.ngModel) {
429
+ $scope.selectedItems = [];
430
+ if ($scope.items) {
431
+ $scope.items.forEach((mitem) => {
432
+ mitem.$selected = !1;
433
+ });
434
+ }
435
+ }
436
+ };
437
+
438
+ $scope.change = function (item) {
439
+ if (item.$selected) {
440
+ let exsits = !1;
441
+ $scope.selectedItems.forEach((sitem) => {
442
+ if (sitem[$scope.primary] === item[$scope.primary]) {
443
+ exsits = !0;
444
+ }
445
+ });
446
+ if (!exsits) {
447
+ let nitem = { ...item };
448
+ delete nitem.$selected;
449
+ delete nitem.$$hashKey;
450
+ $scope.selectedItems.push(nitem);
451
+ }
452
+ } else {
453
+ $scope.selectedItems.forEach((sitem, index) => {
454
+ if (sitem[$scope.primary] === item[$scope.primary]) {
455
+ $scope.selectedItems.splice(index, 1);
456
+ }
457
+ });
458
+ }
459
+
460
+ $scope.ngModel = $scope.selectedItems;
461
+ $timeout(() => {
462
+ if ($scope.ngChange) {
463
+ $scope.ngChange();
464
+ }
465
+ }, 100);
466
+ };
467
+ },
468
+ template: `
469
+ <div class="check-list">
470
+ <label class="title margin"> {{label}} </label>
471
+ <div class="row">
472
+ <i-checkbox class="{{class2}}" label="{{item[display]}}" ng-repeat="item in items" ng-model="item.$selected" ng-change="change(item);"></i-checkbox>
473
+ </div>
474
+ </div>
475
+ `,
476
+ };
477
+ },
478
+ ]);
479
+
480
+ app.directive('iDate', function () {
481
+ return {
482
+ restrict: 'E',
483
+ required: 'ngModel',
484
+ scope: {
485
+ label: '@',
486
+ year: '@',
487
+ ngModel: '=',
488
+ ngChange: '&',
489
+ },
490
+ link: function ($scope, element, attrs) {
491
+ if (typeof attrs.disabled !== 'undefined') {
492
+ attrs.disabled = 'disabled';
493
+ } else {
494
+ attrs.disabled = '';
495
+ }
496
+ $scope.year = $scope.year ? parseInt($scope.year) : 1960;
497
+
498
+ $scope.model = {};
499
+
500
+ $scope.days = [];
501
+ for (let i = 1; i < 32; i++) {
502
+ $scope.days.push({
503
+ id: i,
504
+ name: i,
505
+ });
506
+ }
507
+ $scope.years = [];
508
+ for (let i = $scope.year; i < 2100; i++) {
509
+ $scope.years.push({
510
+ id: i,
511
+ name: i,
512
+ });
513
+ }
514
+ $scope.lang = site.session ? site.session.lang : 'en';
515
+ if ($scope.lang === 'ar') {
516
+ $scope.monthes = [
517
+ { id: 0, name: 'يناير' },
518
+ { id: 1, name: 'فبراير' },
519
+ { id: 2, name: 'مارس' },
520
+ { id: 3, name: 'ابريل' },
521
+ { id: 4, name: 'مايو' },
522
+ { id: 5, name: 'يونيو' },
523
+ { id: 6, name: 'يوليو' },
524
+ { id: 7, name: 'اغسطس' },
525
+ { id: 8, name: 'سبتمبر' },
526
+ { id: 9, name: 'اكتوبر' },
527
+ { id: 10, name: 'نوفمبر' },
528
+ { id: 11, name: 'ديسمبر' },
529
+ ];
530
+ } else {
531
+ $scope.monthes = [
532
+ { id: 0, name: 'Jan' },
533
+ { id: 1, name: 'Feb' },
534
+ { id: 2, name: 'Mar' },
535
+ { id: 3, name: 'Aper' },
536
+ { id: 4, name: 'May' },
537
+ { id: 5, name: 'June' },
538
+ { id: 6, name: 'Jule' },
539
+ { id: 7, name: 'Aug' },
540
+ { id: 8, name: 'Sep' },
541
+ { id: 9, name: 'Oct' },
542
+ { id: 10, name: 'Nov' },
543
+ { id: 11, name: 'Des' },
544
+ ];
545
+ }
546
+
547
+ $scope.$watch('ngModel', function (ngModel) {
548
+ if (ngModel) {
549
+ ngModel = new Date(ngModel);
550
+ $scope.model = $scope.model || {};
551
+ $scope.model.selectedDay = $scope.days.find((d) => d.id == ngModel.getDate());
552
+ $scope.model.selectedMonth = $scope.monthes.find((m) => m.id == ngModel.getMonth());
553
+ $scope.model.selectedYear = $scope.years.find((y) => y.id == ngModel.getFullYear());
554
+ } else {
555
+ $scope.model = $scope.model || {};
556
+ $scope.model.selectedDay = null;
557
+ $scope.model.selectedMonth = null;
558
+ $scope.model.selectedYear = null;
559
+ }
560
+ });
561
+
562
+ $scope.setDay = function () {
563
+ $scope.ngModel = new Date();
564
+ };
565
+ $scope.updateDate = function (date) {
566
+ if ($scope.model.selectedDay && $scope.model.selectedMonth && $scope.model.selectedYear) {
567
+ $scope.ngModel = new Date($scope.model.selectedYear.id, $scope.model.selectedMonth.id, $scope.model.selectedDay.id, 0, 0, 0);
568
+ if ($scope.ngChange) {
569
+ $scope.ngChange();
570
+ }
571
+ }
572
+ };
573
+ },
574
+ restrict: 'E',
575
+ require: 'ngModel',
576
+ scope: {
577
+ v: '@',
578
+ disabled: '@',
579
+ label: '@',
580
+ ngModel: '=',
581
+ },
582
+ template: `/*##client-side/directive/i-date.html*/`,
583
+ };
584
+ });
585
+
586
+ app.directive('iTime', function () {
587
+ return {
588
+ link: function ($scope, element, attrs) {
589
+ if (typeof attrs.disabled !== 'undefined') {
590
+ attrs.disabled = 'disabled';
591
+ } else {
592
+ attrs.disabled = '';
593
+ }
594
+
595
+ $scope.model = {};
596
+
597
+ $scope.hours = [];
598
+ for (let i = 1; i < 25; i++) {
599
+ $scope.hours.push(i);
600
+ }
601
+
602
+ $scope.minutes = [];
603
+ for (let i = 0; i < 60; i++) {
604
+ $scope.minutes.push(i);
605
+ }
606
+
607
+ $(element)
608
+ .find('select')
609
+ .focus(() => {
610
+ $('.popup').hide();
611
+ });
612
+
613
+ $scope.$watch('ngModel', function (ngModel) {
614
+ if (ngModel) {
615
+ ngModel.date = new Date(ngModel.date);
616
+ $scope.model = $scope.model || {};
617
+ $scope.model.hour = ngModel.hour;
339
618
  $scope.model.minute = ngModel.minute;
340
619
  } else {
341
620
  $scope.model = $scope.model || {};
@@ -609,456 +888,178 @@ app.directive('iFulldate', [
609
888
  if (typeof attrs.disabled !== 'undefined') {
610
889
  attrs.disabled = 'disabled';
611
890
  } else {
612
- attrs.disabled = '';
613
- }
614
-
615
- $(element)
616
- .find('select')
617
- .focus(() => {
618
- $('.popup').hide();
619
- });
620
-
621
- $scope.days1 = [];
622
- for (let i = 1; i < 32; i++) {
623
- $scope.days1.push(i);
624
- }
625
- $scope.years1 = [];
626
- for (let i = 1950; i < 2030; i++) {
627
- $scope.years1.push(i);
628
- }
629
-
630
- $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
631
-
632
- $scope.days2 = [];
633
- for (let i = 1; i < 31; i++) {
634
- $scope.days2.push(i);
635
- }
636
- $scope.years2 = [];
637
- for (let i = 1370; i < 1450; i++) {
638
- $scope.years2.push(i);
639
- }
640
- $scope.monthes2 = ['محرم', 'صفر', 'ربيع اول', 'ربيع ثان', 'جمادى اول', 'جمادى ثان', 'رجب', 'شعبان', 'رمضان', 'شوال', 'ذى القعدة', 'ذى الحجة'];
641
-
642
- $scope.model = {};
643
-
644
- $scope.$watch('ngModel', function (ngModel) {
645
- if (ngModel) {
646
- $scope.model = ngModel;
647
- } else {
648
- $scope.model = {};
649
- }
650
- });
651
-
652
- $scope.$watch('ngModel.date', function (date) {
653
- if (date) {
654
- if (typeof date == 'string') {
655
- date = new Date(date);
656
- }
657
- $scope.model = $scope.model || {};
658
- $scope.model.date = date;
659
- $scope.model.day = date.getDate();
660
- $scope.model.month = date.getMonth();
661
- $scope.model.year = date.getFullYear();
662
- $scope.get_hijri_date();
663
- }
664
- });
665
-
666
- $scope.get_hijri_date = function () {
667
- if ($scope.model && $scope.model.year && $scope.model.day) {
668
- ngModel.$setViewValue($scope.model);
669
- if (_busy) {
670
- return;
671
- }
672
- _busy = !0;
673
- $scope.model.date = new Date($scope.model.year, $scope.model.month, $scope.model.day);
674
- $http({
675
- method: 'POST',
676
- url: '/api/get_hijri_date',
677
- data: {
678
- date: $scope.model.year + '/' + ($scope.model.month + 1) + '/' + $scope.model.day,
679
- },
680
- })
681
- .then((response) => {
682
- if (response.data.done) {
683
- $scope.model.hijri = response.data.hijri;
684
- $scope.model.day2 = parseInt($scope.model.hijri.split('/')[2]);
685
- $scope.model.month2 = parseInt($scope.model.hijri.split('/')[1]) - 1;
686
- $scope.model.year2 = parseInt($scope.model.hijri.split('/')[0]);
687
- ngModel.$setViewValue($scope.model);
688
- _busy = !1;
689
- }
690
- })
691
- .catch(() => {
692
- _busy = !1;
693
- });
694
- }
695
- };
696
-
697
- $scope.get_normal_date = function () {
698
- if ($scope.model && $scope.model.year2 && $scope.model.day2) {
699
- ngModel.$setViewValue($scope.model);
700
- if (_busy) {
701
- return;
702
- }
703
- _busy = !0;
704
- $http({
705
- method: 'POST',
706
- url: '/api/get_normal_date',
707
- data: {
708
- hijri: $scope.model.year2 + '/' + ($scope.model.month2 + 1) + '/' + $scope.model.day2,
709
- },
710
- })
711
- .then((response) => {
712
- if (response.data.done) {
713
- $scope.model.date = new Date(response.data.date);
714
- $scope.model.day = parseInt(response.data.date.split('/')[2]);
715
- $scope.model.month = parseInt(response.data.date.split('/')[1]) - 1;
716
- $scope.model.year = parseInt(response.data.date.split('/')[0]);
717
- ngModel.$setViewValue($scope.model);
718
- _busy = !1;
719
- }
720
- })
721
- .catch(() => {
722
- _busy = !1;
723
- });
724
- }
725
- };
726
- },
727
- restrict: 'E',
728
- require: 'ngModel',
729
- scope: {
730
- v: '@',
731
- label1: '@',
732
- label2: '@',
733
- disabled: '@',
734
- ngModel: '=',
735
- ngChange: '&',
736
- },
737
- template: `
738
- <div class="row i-date">
739
-
740
- <div class="col6 control">
741
- <label> {{label1}} </label>
742
- <div class="row">
743
- <div class="col3 day">
744
- <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day" class="appearance-none no-border-left no-border-radius">
745
- <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
746
- </select>
747
- </div>
748
- <div class="col5 month">
749
- <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">
750
- <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
751
- </select>
752
- </div>
753
- <div class="col4 year">
754
- <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year" class="appearance-none no-border-right no-border-radius">
755
- <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
756
- </select>
757
- </div>
758
- </div>
759
- </div>
760
-
761
- <div class="col6 control">
762
- <label> {{label2}} </label>
763
- <div class="row">
764
- <div class="col3 day">
765
- <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day2" class="appearance-none no-border-left no-border-radius">
766
- <option ng-repeat="d2 in days2" ng-value="d2"> {{d2}} </option>
767
- </select>
768
- </div>
769
- <div class="col5 month">
770
- <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">
771
- <option ng-repeat="m2 in monthes2" ng-value="$index"> {{m2}} </option>
772
- </select>
773
- </div>
774
- <div class="col4 year">
775
- <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year2" class="appearance-none no-border-right no-border-radius">
776
- <option ng-repeat="y2 in years2" ng-value="y2"> {{y2}} </option>
777
- </select>
778
- </div>
779
- </div>
780
- </div>
781
-
782
- </div>
783
- `,
784
- };
785
- },
786
- ]);
787
-
788
- app.directive('iTextarea', function () {
789
- return {
790
- restrict: 'E',
791
- require: 'ngModel',
792
- scope: {
793
- v: '@',
794
- label: '@',
795
- disabled: '@',
796
- rows: '@',
797
- ngModel: '=',
798
- ngChange: '&',
799
- },
800
- link: function (scope, element, attrs, ctrl) {
801
- if (typeof attrs.disabled !== 'undefined') {
802
- attrs.disabled = 'disabled';
803
- } else {
804
- attrs.disabled = '';
805
- }
806
- scope.rows = scope.rows || 4;
807
-
808
- $(element)
809
- .find('textarea')
810
- .focus(() => {
811
- $('.popup').hide();
812
- });
813
- },
814
- template: `
815
- <div class="control">
816
- <label> {{label}} </label>
817
- <textarea ng-disabled="disabled" rows="{{rows}}" v="{{v}}" ng-model="ngModel" ng-change="ngChange()"></textarea>
818
- </div>
819
- `,
820
- };
821
- });
822
-
823
- app.directive('iList', [
824
- '$interval',
825
- '$timeout',
826
- 'isite',
827
- function ($interval, $timeout, isite) {
828
- return {
829
- restrict: 'E',
830
- require: 'ngModel',
831
- scope: {
832
- v: '@',
833
- label: '@',
834
- display: '@',
835
- display2: '@',
836
- disabled: '@',
837
- css: '@',
838
- space: '@',
839
- primary: '@',
840
- ngValue: '@',
841
- ngModel: '=',
842
- ngSearch: '=',
843
- ngChange: '&',
844
- ngAdd: '&',
845
- items: '=',
846
- },
847
- link: function ($scope, element, attrs, ctrl) {
848
- $scope.display = attrs.display = attrs.display || 'name';
849
- $scope.primary = attrs.primary = attrs.primary || 'id';
850
- attrs.space = attrs.space || ' ';
851
- attrs.ngValue = attrs.ngValue || '';
852
-
853
- $scope.searchElement = $(element).find('.dropdown .search');
854
- $scope.popupElement = $(element).find('.dropdown .dropdown-content');
855
-
856
- if (typeof attrs.disabled !== 'undefined') {
857
- attrs.disabled = 'disabled';
858
- } else {
859
- attrs.disabled = '';
860
- }
861
-
862
- if (typeof attrs.ngAdd == 'undefined') {
863
- $scope.fa_add = 'fa-search';
864
- } else {
865
- $scope.fa_add = 'fa-plus';
866
- }
867
-
868
- if (typeof attrs.ngSearch == 'undefined') {
869
- $scope.showSearch = !1;
870
- } else {
871
- $scope.showSearch = !0;
872
- }
873
-
874
- let input = $(element).find('input');
875
- $(element).hover(
876
- () => {
877
- $scope.popupElement.css('display', 'block');
878
- },
879
- () => {
880
- $scope.popupElement.css('display', 'none');
881
- }
882
- );
883
- $scope.focus = function () {
884
- $('.i-list .dropdown-content').css('display', 'none');
885
- $scope.popupElement.css('display', 'block');
886
- $scope.searchElement.focus();
887
- };
888
- $scope.hide = function () {
889
- $scope.popupElement.css('display', 'none');
890
- };
891
-
892
- $scope.getValue = function (item) {
893
- let v = isite.getValue(item, $scope.display);
894
- return v || '';
895
- };
896
-
897
- $scope.getValue2 = function (item) {
898
- if ($scope.display2) {
899
- return isite.getValue(item, $scope.display2) || '';
900
- }
901
- return '';
902
- };
903
-
904
- $scope.getNgModelValue = function (ngModel) {
905
- if (ngModel && $scope.display && $scope.ngValue) {
906
- return isite.getValue(ngModel, $scope.display.replace($scope.ngValue + '.', '')) || '';
907
- } else if (ngModel && $scope.display) {
908
- return isite.getValue(ngModel, $scope.display) || '';
909
- }
910
- return '';
911
- };
912
-
913
- $scope.getNgModelValue2 = function (ngModel) {
914
- if (ngModel && $scope.display2 && $scope.ngValue) {
915
- return isite.getValue(ngModel, $scope.display2.replace($scope.ngValue + '.', '')) || '';
916
- } else if (ngModel && $scope.display2) {
917
- return isite.getValue(ngModel, $scope.display2) || '';
918
- }
919
- return '';
920
- };
921
-
922
- $scope.getNgValue = function (item) {
923
- if (item && $scope.ngValue) {
924
- return isite.getValue(item, $scope.ngValue);
925
- }
926
- return item;
927
- };
928
-
929
- $scope.$watch('items', (items) => {
930
- input.val('');
931
-
932
- if (items) {
933
- items.forEach((item) => {
934
- item.$display = $scope.getValue(item) + attrs.space + $scope.getValue2(item);
935
- });
936
- }
937
-
938
- if (items && $scope.ngModel) {
939
- items.forEach((item) => {
940
- if (isite.getValue(item, $scope.primary) == isite.getValue($scope.ngModel, $scope.primary)) {
941
- $scope.ngModel = item;
942
- item.$display = $scope.getValue(item) + attrs.space + $scope.getValue2(item);
943
- input.val(item.$display);
944
- }
945
- });
946
- }
947
- });
948
-
949
- $scope.$watch('ngModel', (ngModel) => {
950
- input.val('');
951
-
952
- $scope.ngModel = ngModel;
953
-
954
- if (ngModel) {
955
- input.val(' ' + $scope.getNgModelValue(ngModel) + attrs.space + $scope.getNgModelValue2(ngModel));
956
- }
957
- });
958
-
959
- $scope.updateModel = function (item) {
960
- $scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
961
- input.val($scope.getNgModelValue($scope.ngModel) + attrs.space + $scope.getNgModelValue2($scope.ngModel));
962
- $timeout(() => {
963
- $scope.ngChange();
964
- });
965
- $scope.hide();
966
- };
967
- },
968
- template: `/*##client-side/sub/i-list2.content.html*/`,
969
- };
970
- },
971
- ]);
972
-
973
- app.directive('iChecklist', [
974
- '$interval',
975
- function ($interval) {
976
- return {
977
- restrict: 'E',
978
- required: 'ngModel',
979
- scope: {
980
- label: '@',
981
- primary: '@',
982
- display: '@',
983
- ngModel: '=',
984
- items: '=',
985
- like: '&',
986
- },
987
- link: function ($scope, element, attrs, ctrl) {
988
- attrs.primary = attrs.primary || 'id';
891
+ attrs.disabled = '';
892
+ }
989
893
 
990
- $scope.selectedItems = [];
894
+ $(element)
895
+ .find('select')
896
+ .focus(() => {
897
+ $('.popup').hide();
898
+ });
991
899
 
992
- $scope.$watch('ngModel', (ngModel) => {
993
- $scope.reload();
994
- });
900
+ $scope.days1 = [];
901
+ for (let i = 1; i < 32; i++) {
902
+ $scope.days1.push(i);
903
+ }
904
+ $scope.years1 = [];
905
+ for (let i = 1950; i < 2030; i++) {
906
+ $scope.years1.push(i);
907
+ }
995
908
 
996
- $scope.reload = function () {
997
- $scope.selectedItems = [];
909
+ $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
998
910
 
999
- if ($scope.ngModel) {
1000
- $scope.ngModel.forEach((mitem) => {
1001
- $scope.selectedItems.push(mitem);
1002
- });
911
+ $scope.days2 = [];
912
+ for (let i = 1; i < 31; i++) {
913
+ $scope.days2.push(i);
914
+ }
915
+ $scope.years2 = [];
916
+ for (let i = 1370; i < 1450; i++) {
917
+ $scope.years2.push(i);
918
+ }
919
+ $scope.monthes2 = ['محرم', 'صفر', 'ربيع اول', 'ربيع ثان', 'جمادى اول', 'جمادى ثان', 'رجب', 'شعبان', 'رمضان', 'شوال', 'ذى القعدة', 'ذى الحجة'];
1003
920
 
1004
- if ($scope.items) {
1005
- $scope.items.forEach((mitem) => {
1006
- let exist = !1;
1007
- $scope.selectedItems.forEach((sitem) => {
1008
- if (mitem[$scope.primary] === sitem[$scope.primary]) {
1009
- exist = !0;
1010
- }
1011
- });
1012
- if (exist) {
1013
- mitem.$selected = !0;
1014
- } else {
1015
- mitem.$selected = !1;
1016
- }
1017
- });
921
+ $scope.model = {};
922
+
923
+ $scope.$watch('ngModel', function (ngModel) {
924
+ if (ngModel) {
925
+ $scope.model = ngModel;
926
+ } else {
927
+ $scope.model = {};
928
+ }
929
+ });
930
+
931
+ $scope.$watch('ngModel.date', function (date) {
932
+ if (date) {
933
+ if (typeof date == 'string') {
934
+ date = new Date(date);
1018
935
  }
936
+ $scope.model = $scope.model || {};
937
+ $scope.model.date = date;
938
+ $scope.model.day = date.getDate();
939
+ $scope.model.month = date.getMonth();
940
+ $scope.model.year = date.getFullYear();
941
+ $scope.get_hijri_date();
1019
942
  }
1020
- if (!$scope.ngModel) {
1021
- $scope.selectedItems = [];
1022
- if ($scope.items) {
1023
- $scope.items.forEach((mitem) => {
1024
- mitem.$selected = !1;
1025
- });
943
+ });
944
+
945
+ $scope.get_hijri_date = function () {
946
+ if ($scope.model && $scope.model.year && $scope.model.day) {
947
+ ngModel.$setViewValue($scope.model);
948
+ if (_busy) {
949
+ return;
1026
950
  }
951
+ _busy = !0;
952
+ $scope.model.date = new Date($scope.model.year, $scope.model.month, $scope.model.day);
953
+ $http({
954
+ method: 'POST',
955
+ url: '/api/get_hijri_date',
956
+ data: {
957
+ date: $scope.model.year + '/' + ($scope.model.month + 1) + '/' + $scope.model.day,
958
+ },
959
+ })
960
+ .then((response) => {
961
+ if (response.data.done) {
962
+ $scope.model.hijri = response.data.hijri;
963
+ $scope.model.day2 = parseInt($scope.model.hijri.split('/')[2]);
964
+ $scope.model.month2 = parseInt($scope.model.hijri.split('/')[1]) - 1;
965
+ $scope.model.year2 = parseInt($scope.model.hijri.split('/')[0]);
966
+ ngModel.$setViewValue($scope.model);
967
+ _busy = !1;
968
+ }
969
+ })
970
+ .catch(() => {
971
+ _busy = !1;
972
+ });
1027
973
  }
1028
974
  };
1029
975
 
1030
- $scope.change = function (item) {
1031
- item.$selected = !item.$selected;
1032
-
1033
- if (item.$selected) {
1034
- let exsits = !1;
1035
- $scope.selectedItems.forEach((sitem) => {
1036
- if (sitem[$scope.primary] === item[$scope.primary]) {
1037
- exsits = !0;
1038
- }
1039
- });
1040
- if (!exsits) {
1041
- $scope.selectedItems.push(item);
976
+ $scope.get_normal_date = function () {
977
+ if ($scope.model && $scope.model.year2 && $scope.model.day2) {
978
+ ngModel.$setViewValue($scope.model);
979
+ if (_busy) {
980
+ return;
1042
981
  }
1043
- } else {
1044
- $scope.selectedItems.forEach((sitem, index) => {
1045
- if (sitem[$scope.primary] === item[$scope.primary]) {
1046
- $scope.selectedItems.splice(index, 1);
1047
- }
1048
- });
982
+ _busy = !0;
983
+ $http({
984
+ method: 'POST',
985
+ url: '/api/get_normal_date',
986
+ data: {
987
+ hijri: $scope.model.year2 + '/' + ($scope.model.month2 + 1) + '/' + $scope.model.day2,
988
+ },
989
+ })
990
+ .then((response) => {
991
+ if (response.data.done) {
992
+ $scope.model.date = new Date(response.data.date);
993
+ $scope.model.day = parseInt(response.data.date.split('/')[2]);
994
+ $scope.model.month = parseInt(response.data.date.split('/')[1]) - 1;
995
+ $scope.model.year = parseInt(response.data.date.split('/')[0]);
996
+ ngModel.$setViewValue($scope.model);
997
+ _busy = !1;
998
+ }
999
+ })
1000
+ .catch(() => {
1001
+ _busy = !1;
1002
+ });
1049
1003
  }
1050
-
1051
- $scope.ngModel = $scope.selectedItems;
1052
1004
  };
1053
1005
  },
1006
+ restrict: 'E',
1007
+ require: 'ngModel',
1008
+ scope: {
1009
+ v: '@',
1010
+ label1: '@',
1011
+ label2: '@',
1012
+ disabled: '@',
1013
+ ngModel: '=',
1014
+ ngChange: '&',
1015
+ },
1054
1016
  template: `
1055
- <div class="row padding check-list">
1056
- <label class="title"> {{label}} </label>
1057
- <div ng-repeat="item in items" ng-click="change(item);ngChange($event , item);" class="selector" ng-class="{'selected' : item.$selected , 'un-selected' : !item.$selected }" >
1058
- <i ng-show="!item.$selected" class="fa fa-square"></i> <i ng-show="item.$selected" class="fa fa-check"></i> {{item[display]}}
1059
- </div>
1017
+ <div class="row i-date">
1018
+
1019
+ <div class="col6 control">
1020
+ <label> {{label1}} </label>
1021
+ <div class="row">
1022
+ <div class="col3 day">
1023
+ <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day" class="appearance-none no-border-left no-border-radius">
1024
+ <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
1025
+ </select>
1026
+ </div>
1027
+ <div class="col5 month">
1028
+ <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">
1029
+ <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
1030
+ </select>
1031
+ </div>
1032
+ <div class="col4 year">
1033
+ <select ng-change="get_hijri_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year" class="appearance-none no-border-right no-border-radius">
1034
+ <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
1035
+ </select>
1036
+ </div>
1037
+ </div>
1060
1038
  </div>
1061
- `,
1039
+
1040
+ <div class="col6 control">
1041
+ <label> {{label2}} </label>
1042
+ <div class="row">
1043
+ <div class="col3 day">
1044
+ <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.day2" class="appearance-none no-border-left no-border-radius">
1045
+ <option ng-repeat="d2 in days2" ng-value="d2"> {{d2}} </option>
1046
+ </select>
1047
+ </div>
1048
+ <div class="col5 month">
1049
+ <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">
1050
+ <option ng-repeat="m2 in monthes2" ng-value="$index"> {{m2}} </option>
1051
+ </select>
1052
+ </div>
1053
+ <div class="col4 year">
1054
+ <select ng-change="get_normal_date()" ng-disabled="disabled" v="{{v}}" ng-model="model.year2" class="appearance-none no-border-right no-border-radius">
1055
+ <option ng-repeat="y2 in years2" ng-value="y2"> {{y2}} </option>
1056
+ </select>
1057
+ </div>
1058
+ </div>
1059
+ </div>
1060
+
1061
+ </div>
1062
+ `,
1062
1063
  };
1063
1064
  },
1064
1065
  ]);
@@ -1211,41 +1212,62 @@ app.directive('iFile', [
1211
1212
  required: 'ngModel',
1212
1213
  scope: {
1213
1214
  label: '@',
1214
- type: '@',
1215
+ folder: '@',
1215
1216
  ngModel: '=',
1216
1217
  ngClick: '&',
1217
1218
  onSelected: '&',
1218
1219
  },
1219
- link: function (scope, element, attrs, ctrl) {
1220
- scope.type = scope.type || 'bg-green';
1221
-
1220
+ link: function ($scope, element, attrs, ctrl) {
1221
+ $scope.label = $scope.label || 'Select File to Upload';
1222
1222
  let input = $(element).find('input')[0];
1223
- let a = $(element).find('a')[0];
1224
-
1223
+ let button = $(element).find('button')[0];
1224
+ if (attrs.view === '') {
1225
+ $scope.viewOnly = !0;
1226
+ }
1227
+ let progress = $(element).find('.progress')[0];
1228
+ $(progress).hide();
1229
+ $scope.folder = $scope.folder || 'default';
1230
+ $scope.id = Math.random().toString().replace('.', '_');
1225
1231
  if (attrs.view !== '') {
1226
- a.addEventListener('click', function () {
1232
+ button.addEventListener('click', function () {
1227
1233
  input.click();
1228
1234
  });
1229
1235
  }
1230
1236
 
1231
1237
  input.addEventListener('change', function () {
1232
- scope.ngModel = this.files[0].path;
1233
- scope.onSelected(this.files[0].path);
1234
- scope.$applyAsync();
1238
+ isite.uploadFile(
1239
+ this.files,
1240
+ {
1241
+ folder: $scope.folder,
1242
+ },
1243
+ (err, file, e) => {
1244
+ if (e) {
1245
+ $(progress).show();
1246
+ $scope.value = (e.loaded / e.total) * 100;
1247
+ $scope.max = e.total;
1248
+ if ($scope.value === 100) {
1249
+ $(progress).hide();
1250
+ }
1251
+ }
1252
+
1253
+ if (file) {
1254
+ $scope.ngModel = file;
1255
+ console.log(file);
1256
+ }
1257
+ }
1258
+ );
1259
+ $scope.ngModel = this.files[0].path;
1260
+ $scope.onSelected(this.files[0].path);
1261
+ $scope.$applyAsync();
1235
1262
  });
1236
1263
 
1237
- scope.$watch('ngModel', (ngModel) => {
1264
+ $scope.$watch('ngModel', (ngModel) => {
1238
1265
  if (ngModel) {
1239
1266
  a.setAttribute('url', ngModel);
1240
1267
  }
1241
1268
  });
1242
1269
  },
1243
- template: `
1244
- <form class="form text-center pointer">
1245
- <input class="hidden" type="file" name="file" />
1246
- <a class="btn {{type}}" ngClick="ngClick()" url="{{ngModel}}"> {{label}} </a>
1247
- </form>
1248
- `,
1270
+ template: `/*##client-side/sub/i-file.content.html*/`,
1249
1271
  };
1250
1272
  },
1251
1273
  ]);
@@ -1258,16 +1280,16 @@ app.directive('iImage', [
1258
1280
  restrict: 'E',
1259
1281
  required: 'ngModel',
1260
1282
  scope: {
1261
- category: '@',
1283
+ folder: '@',
1262
1284
  ngModel: '=',
1263
1285
  ngClick: '&',
1264
1286
  },
1265
- link: function (scope, element, attrs, ctrl) {
1266
- scope.category = scope.category || 'default';
1287
+ link: function ($scope, element, attrs, ctrl) {
1288
+ $scope.folder = $scope.folder || 'default';
1267
1289
 
1268
1290
  let input = $(element).find('input')[0];
1269
1291
  let img = $(element).find('img')[0];
1270
- let progress = $(element).find('progress')[0];
1292
+ let progress = $(element).find('.progress')[0];
1271
1293
  $(progress).hide();
1272
1294
 
1273
1295
  if (attrs.view !== '') {
@@ -1280,34 +1302,39 @@ app.directive('iImage', [
1280
1302
  isite.uploadImage(
1281
1303
  this.files,
1282
1304
  {
1283
- category: scope.category,
1305
+ folder: $scope.folder,
1284
1306
  },
1285
- (err, image_url, e) => {
1307
+ (err, image, e) => {
1286
1308
  if (e) {
1287
1309
  $(progress).show();
1288
- progress.value = e.loaded;
1289
- progress.max = e.total;
1310
+ $scope.value = (e.loaded / e.total) * 100;
1311
+ $scope.max = e.total;
1312
+ if ($scope.value === 100) {
1313
+ $(progress).hide();
1314
+ }
1290
1315
  }
1291
1316
 
1292
- if (image_url) {
1293
- scope.ngModel = image_url;
1317
+ if (image) {
1318
+ $scope.ngModel = image;
1294
1319
  }
1295
1320
  }
1296
1321
  );
1297
1322
  });
1298
1323
 
1299
- scope.$watch('ngModel', (ngModel) => {
1324
+ $scope.$watch('ngModel', (ngModel) => {
1300
1325
  if (ngModel) {
1301
- img.setAttribute('src', ngModel);
1326
+ img.setAttribute('src', ngModel.url);
1302
1327
  }
1303
1328
  });
1304
1329
  },
1305
1330
  template: `
1306
- <form class="form text-center pointer">
1307
- <input class="hidden" type="file" name="file" />
1308
- <img class="bg-white" ng-src="{{ngModel}}" ngClick="ngClick()" onerror="this.src='/images/no.jpg'" />
1309
- <progress class="row"></progress>
1310
- </form>
1331
+ <div class=" text-center pointer">
1332
+ <input class="hidden" type="file" name="fileToUpload" accept="image/*"/>
1333
+ <img class="rounded" ng-src="{{ngModel.url}}" ngClick="ngClick()" onerror="this.src='/images/no.jpg'" />
1334
+ <div class="progress row">
1335
+ <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="0" aria-valuemax="100" style="width: {{value}}%"></div>
1336
+ </div>
1337
+ </div>
1311
1338
  `,
1312
1339
  };
1313
1340
  },