isite 2022.8.4 → 2022.8.5

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.
@@ -370,7 +370,7 @@ app.directive('iList', [
370
370
  $scope.hide();
371
371
  };
372
372
  },
373
- template: `/*##client-side/sub/i-list2.content.html*/`,
373
+ template: `/*##client-side/directive/i-list.html*/`,
374
374
  };
375
375
  },
376
376
  ]);
@@ -583,487 +583,6 @@ app.directive('iDate', function () {
583
583
  };
584
584
  });
585
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;
618
- $scope.model.minute = ngModel.minute;
619
- } else {
620
- $scope.model = $scope.model || {};
621
- $scope.model.hour = 0;
622
- $scope.model.minute = 0;
623
- }
624
- });
625
-
626
- $scope.updateTime = function () {
627
- if ($scope.model) {
628
- $scope.ngModel = $scope.ngModel || {};
629
- $scope.ngModel.hour = $scope.model.hour;
630
- $scope.ngModel.minute = $scope.model.minute;
631
- $scope.ngModel.date = new Date(null, null, null, $scope.model.hour, $scope.model.minute, null);
632
- } else {
633
- delete $scope.ngModel;
634
- }
635
- };
636
- },
637
- restrict: 'E',
638
- require: 'ngModel',
639
- scope: {
640
- v: '@',
641
- disabled: '@',
642
- label: '@',
643
- ngModel: '=',
644
- },
645
- template: `
646
- <div class="row i-time">
647
- <div class=" control ">
648
- <label class="text-center"> {{label}} </label>
649
- <div class="row">
650
- <div class="col6 right">
651
- <div class="row">
652
- <div class="col2"></div>
653
- <div class="col8">
654
- <select ng-disabled="disabled" ng-model="model.minute" ng-change="updateTime()" class="small appearance-none no-border-left no-border-radius" >
655
- <option ng-repeat="m in minutes" ng-value="m"> {{m}}</option>
656
- </select>
657
- </div>
658
- <div class="col2"></div>
659
- </div>
660
-
661
- </div>
662
- <div class="col6">
663
- <div class="row">
664
- <div class="col2 space right">
665
- <span> : </span>
666
- </div>
667
- <div class="col8">
668
- <select ng-disabled="disabled" ng-model="model.hour" ng-change="updateTime()" class="large blue appearance-none no-border-left no-border-radius" >
669
- <option ng-repeat="h in hours" ng-value="h"> {{h}} </option>
670
- </select>
671
- </div>
672
-
673
- </div>
674
-
675
- </div>
676
- </div>
677
- </div>
678
- `,
679
- };
680
- });
681
-
682
- app.directive('iDatetime2', function () {
683
- return {
684
- link: function ($scope, element, attrs) {
685
- if (typeof attrs.disabled !== 'undefined') {
686
- attrs.disabled = 'disabled';
687
- } else {
688
- attrs.disabled = '';
689
- }
690
-
691
- $scope.hour1 = [];
692
- for (let i = 1; i < 25; i++) {
693
- $scope.hour1.push(i);
694
- }
695
-
696
- $scope.minute_list = [];
697
- for (let i = 1; i < 60; i++) {
698
- $scope.minute_list.push({
699
- name: i,
700
- });
701
- }
702
-
703
- $scope.days1 = [];
704
- for (let i = 1; i < 32; i++) {
705
- $scope.days1.push(i);
706
- }
707
- $scope.years1 = [];
708
- for (let i = 1900; i < 2100; i++) {
709
- $scope.years1.push(i);
710
- }
711
- $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
712
-
713
- $scope.model = null;
714
-
715
- $(element)
716
- .find('select')
717
- .focus(() => {
718
- $('.popup').hide();
719
- });
720
-
721
- $scope.$watch('ngModel', function (ngModel) {
722
- if (ngModel) {
723
- ngModel = new Date(ngModel);
724
- $scope.model = $scope.model || {};
725
- $scope.model.hour = ngModel.getHours();
726
- $scope.model.minute = ngModel.getMinutes();
727
- $scope.model.day = ngModel.getDate();
728
- $scope.model.month = ngModel.getMonth();
729
- $scope.model.year = ngModel.getFullYear();
730
- } else {
731
- $scope.model = $scope.model || {};
732
- $scope.model.hour = 0;
733
- $scope.model.minute = 0;
734
- $scope.model.day = 0;
735
- $scope.model.month = -1;
736
- $scope.model.year = 0;
737
- }
738
- });
739
-
740
- $scope.updateDate = function () {
741
- if ($scope.model && $scope.model.year && $scope.model.day) {
742
- $scope.ngModel = new Date($scope.model.year, $scope.model.month, $scope.model.day, $scope.model.hour, $scope.model.minute);
743
- } else {
744
- delete $scope.ngModel;
745
- }
746
- };
747
- },
748
- restrict: 'E',
749
- require: 'ngModel',
750
- scope: {
751
- v: '@',
752
- disabled: '@',
753
- label: '@',
754
- ngModel: '=',
755
- },
756
- template: `
757
- <div class="row i-datetime2">
758
-
759
- <div class=" control">
760
- <label> {{label}} </label>
761
- <div class="row">
762
-
763
- <div class="col2 day">
764
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.day" ng-change="updateDate()" class="appearance-none no-border-left no-border-radius" >
765
- <option ng-repeat="d1 in days1" ng-value="d1"> {{d1}} </option>
766
- </select>
767
- </div>
768
- <div class="col5 month">
769
- <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" >
770
- <option ng-repeat="m1 in monthes1" ng-value="$index"> {{m1}} </option>
771
- </select>
772
- </div>
773
- <div class="col3 year">
774
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.year" ng-change="updateDate()" class="appearance-none no-border-right no-border-radius" >
775
- <option ng-repeat="y1 in years1" ng-value="y1"> {{y1}} </option>
776
- </select>
777
- </div>
778
-
779
- <div class="col1 hour">
780
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.hour" ng-change="updateDate()" class="appearance-none no-border-radius" >
781
- <option ng-repeat="h1 in hour1" ng-value="h1"> {{h1}} </option>
782
- </select>
783
- </div>
784
- <div class="col1 minute">
785
- <select v="{{v}}" ng-disabled="disabled" ng-model="model.minute" ng-change="updateDate()" class="green appearance-none no-border-right no-border-radius" >
786
- <option ng-repeat="m1 in minute_list" ng-value="m1.name" class="green"> {{m1.name}} </option>
787
- </select>
788
- </div>
789
-
790
- </div>
791
- </div>
792
-
793
-
794
- </div>
795
- `,
796
- };
797
- });
798
-
799
- app.directive('iMonth2', function () {
800
- return {
801
- link: function ($scope, element, attrs) {
802
- if (typeof attrs.disabled !== 'undefined') {
803
- attrs.disabled = 'disabled';
804
- } else {
805
- attrs.disabled = '';
806
- }
807
-
808
- $scope.years = [];
809
- for (let i = 1900; i < 2100; i++) {
810
- $scope.years.push(i);
811
- }
812
- $scope.monthes = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
813
-
814
- $scope.model = null;
815
-
816
- $(element)
817
- .find('select')
818
- .focus(() => {
819
- $('.popup').hide();
820
- });
821
-
822
- $scope.$watch('ngModel', function (ngModel) {
823
- if (ngModel) {
824
- ngModel = new Date(ngModel);
825
- $scope.model = $scope.model || {};
826
- $scope.model.day = 1;
827
- $scope.model.month = ngModel.getMonth();
828
- $scope.model.year = ngModel.getFullYear();
829
- } else {
830
- $scope.model = $scope.model || {};
831
- $scope.model.day = 0;
832
- $scope.model.month = -1;
833
- $scope.model.year = 0;
834
- }
835
- });
836
-
837
- $scope.updateDate = function () {
838
- if ($scope.model && $scope.model.year) {
839
- $scope.ngModel = new Date($scope.model.year, $scope.model.month, 1);
840
- } else {
841
- delete $scope.ngModel;
842
- }
843
- };
844
- },
845
- restrict: 'E',
846
- require: 'ngModel',
847
- scope: {
848
- v: '@',
849
- label: '@',
850
- disabled: '@',
851
- ngModel: '=',
852
- },
853
- template: `
854
- <div class="row i-date2">
855
-
856
- <div class=" control">
857
- <label> {{label}} </label>
858
- <div class="row">
859
-
860
- <div class="col7 month">
861
- <select ng-disabled="disabled" v="{{v}}" ng-model="model.month" ng-change="updateDate()" class="appearance-none no-border-left no-border-radius" >
862
- <option ng-repeat="m1 in monthes" ng-value="$index"> {{m1}} </option>
863
- </select>
864
- </div>
865
-
866
- <div class="col5 year">
867
- <select ng-disabled="disabled" v="{{v}}" ng-model="model.year" ng-change="updateDate()" class="appearance-none no-border-right no-border-radius" >
868
- <option ng-repeat="y1 in years" ng-value="y1"> {{y1}} </option>
869
- </select>
870
- </div>
871
-
872
- </div>
873
- </div>
874
-
875
-
876
- </div>
877
- `,
878
- };
879
- });
880
-
881
- app.directive('iFulldate', [
882
- '$http',
883
- function ($http) {
884
- return {
885
- link: function ($scope, element, attrs, ngModel) {
886
- let _busy = !1;
887
-
888
- if (typeof attrs.disabled !== 'undefined') {
889
- attrs.disabled = 'disabled';
890
- } else {
891
- attrs.disabled = '';
892
- }
893
-
894
- $(element)
895
- .find('select')
896
- .focus(() => {
897
- $('.popup').hide();
898
- });
899
-
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
- }
908
-
909
- $scope.monthes1 = ['يناير', 'فبراير', 'مارس', 'ابريل', 'مايو', 'يونيو', 'يوليو', 'اغسطس', 'سبتمبر', 'اكتوبر', 'نوفمبر', 'ديسمبر'];
910
-
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 = ['محرم', 'صفر', 'ربيع اول', 'ربيع ثان', 'جمادى اول', 'جمادى ثان', 'رجب', 'شعبان', 'رمضان', 'شوال', 'ذى القعدة', 'ذى الحجة'];
920
-
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);
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();
942
- }
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;
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
- });
973
- }
974
- };
975
-
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;
981
- }
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
- });
1003
- }
1004
- };
1005
- },
1006
- restrict: 'E',
1007
- require: 'ngModel',
1008
- scope: {
1009
- v: '@',
1010
- label1: '@',
1011
- label2: '@',
1012
- disabled: '@',
1013
- ngModel: '=',
1014
- ngChange: '&',
1015
- },
1016
- template: `
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>
1038
- </div>
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
- `,
1063
- };
1064
- },
1065
- ]);
1066
-
1067
586
  app.directive('iChecklist2', [
1068
587
  '$interval',
1069
588
  function ($interval) {
@@ -1212,13 +731,17 @@ app.directive('iFile', [
1212
731
  required: 'ngModel',
1213
732
  scope: {
1214
733
  label: '@',
734
+ accept: '@',
1215
735
  folder: '@',
1216
736
  ngModel: '=',
1217
737
  ngClick: '&',
1218
738
  onSelected: '&',
739
+ ngChange: '&',
1219
740
  },
1220
741
  link: function ($scope, element, attrs, ctrl) {
1221
742
  $scope.label = $scope.label || 'Select File to Upload';
743
+ $scope.folder = $scope.folder || 'default';
744
+ $scope.accept = $scope.accept ? $scope.accept : '';
1222
745
  let input = $(element).find('input')[0];
1223
746
  let button = $(element).find('button')[0];
1224
747
  if (attrs.view === '') {
@@ -1226,7 +749,7 @@ app.directive('iFile', [
1226
749
  }
1227
750
  let progress = $(element).find('.progress')[0];
1228
751
  $(progress).hide();
1229
- $scope.folder = $scope.folder || 'default';
752
+
1230
753
  $scope.id = Math.random().toString().replace('.', '_');
1231
754
  if (attrs.view !== '') {
1232
755
  button.addEventListener('click', function () {
@@ -1252,7 +775,9 @@ app.directive('iFile', [
1252
775
 
1253
776
  if (file) {
1254
777
  $scope.ngModel = file;
1255
- console.log(file);
778
+ if ($scope.ngChange) {
779
+ $scope.ngChange();
780
+ }
1256
781
  }
1257
782
  }
1258
783
  );
@@ -1267,7 +792,7 @@ app.directive('iFile', [
1267
792
  }
1268
793
  });
1269
794
  },
1270
- template: `/*##client-side/sub/i-file.content.html*/`,
795
+ template: `/*##client-side/directive/i-file.html*/`,
1271
796
  };
1272
797
  },
1273
798
  ]);
@@ -1281,12 +806,14 @@ app.directive('iImage', [
1281
806
  required: 'ngModel',
1282
807
  scope: {
1283
808
  folder: '@',
809
+ accept: '@',
1284
810
  ngModel: '=',
1285
811
  ngClick: '&',
812
+ ngChange: '&',
1286
813
  },
1287
814
  link: function ($scope, element, attrs, ctrl) {
1288
815
  $scope.folder = $scope.folder || 'default';
1289
-
816
+ $scope.accept = $scope.accept ? $scope.accept : 'image/*';
1290
817
  let input = $(element).find('input')[0];
1291
818
  let img = $(element).find('img')[0];
1292
819
  let progress = $(element).find('.progress')[0];
@@ -1316,6 +843,9 @@ app.directive('iImage', [
1316
843
 
1317
844
  if (image) {
1318
845
  $scope.ngModel = image;
846
+ if ($scope.ngChange) {
847
+ $scope.ngChange();
848
+ }
1319
849
  }
1320
850
  }
1321
851
  );
@@ -1327,223 +857,7 @@ app.directive('iImage', [
1327
857
  }
1328
858
  });
1329
859
  },
1330
- template: `
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>
1338
- `,
1339
- };
1340
- },
1341
- ]);
1342
-
1343
- app.directive('iUpload', [
1344
- '$interval',
1345
- 'isite',
1346
- function ($interval, isite) {
1347
- return {
1348
- restrict: 'E',
1349
- required: 'ngModel',
1350
- scope: {
1351
- label: '@',
1352
- api: '@',
1353
- type: '@',
1354
- ngModel: '=',
1355
- ngClick: '&',
1356
- onUploaded: '&',
1357
- },
1358
- link: function (scope, element, attrs, ctrl) {
1359
- scope.type = scope.type || 'bg-green';
1360
-
1361
- let input = $(element).find('input')[0];
1362
- let a = $(element).find('a')[0];
1363
- let progress = $(element).find('progress')[0];
1364
- $(progress).hide();
1365
-
1366
- if (attrs.view !== '') {
1367
- a.addEventListener('click', function () {
1368
- input.click();
1369
- });
1370
- }
1371
-
1372
- input.addEventListener('change', function () {
1373
- isite.upload(
1374
- this.files,
1375
- {
1376
- api: scope.api,
1377
- },
1378
- (err, file, e) => {
1379
- if (e) {
1380
- $(progress).show();
1381
- progress.value = e.loaded;
1382
- progress.max = e.total;
1383
- }
1384
-
1385
- if (file) {
1386
- scope.ngModel = file;
1387
- scope.onUploaded();
1388
- }
1389
- }
1390
- );
1391
- });
1392
-
1393
- scope.$watch('ngModel', (ngModel) => {
1394
- if (ngModel) {
1395
- a.setAttribute('url', ngModel);
1396
- }
1397
- });
1398
- },
1399
- template: `
1400
- <form class="form text-center pointer">
1401
- <input class="hidden" type="file" name="file" />
1402
- <a class="btn {{type}}" ngClick="ngClick()" url="{{ngModel}}"> {{label}} </a>
1403
- <progress class="row"></progress>
1404
- </form>
1405
- `,
1406
- };
1407
- },
1408
- ]);
1409
-
1410
- app.directive('iFiles', [
1411
- '$interval',
1412
- 'isite',
1413
- function ($interval, isite) {
1414
- return {
1415
- restrict: 'E',
1416
- required: 'ngModel',
1417
- scope: {
1418
- category: '@',
1419
- label: '@',
1420
- ngModel: '=',
1421
- },
1422
- link: function (scope, element, attrs, ctrl) {
1423
- if (attrs.view === '') {
1424
- scope.viewOnly = !0;
1425
- }
1426
-
1427
- let progress = $(element).find('progress')[0];
1428
-
1429
- scope.category = scope.category || 'default';
1430
- scope.id = Math.random().toString().replace('.', '_');
1431
- scope.deleteFile = function (file) {
1432
- isite.deleteFile(file, () => {
1433
- for (let i = 0; i < scope.ngModel.length; i++) {
1434
- let f = scope.ngModel[i];
1435
- if (f.url === file.url) {
1436
- scope.ngModel.splice(i, 1);
1437
- return;
1438
- }
1439
- }
1440
- });
1441
- };
1442
-
1443
- let setEvent = !1;
1444
- $interval(() => {
1445
- if (setEvent) {
1446
- return;
1447
- }
1448
-
1449
- if (attrs.view !== '') {
1450
- let btn = document.querySelector('#btn_' + scope.id);
1451
- if (btn) {
1452
- setEvent = !0;
1453
- btn.addEventListener('click', function () {
1454
- document.querySelector('#input_' + scope.id).click();
1455
- });
1456
- }
1457
-
1458
- let input = document.querySelector('#input_' + scope.id);
1459
- if (input) {
1460
- input.addEventListener('change', function () {
1461
- isite.uploadFile(
1462
- this.files,
1463
- {
1464
- category: scope.category,
1465
- },
1466
- (err, file, e) => {
1467
- if (e) {
1468
- $(progress).show();
1469
- progress.value = e.loaded;
1470
- progress.max = e.total;
1471
- }
1472
-
1473
- if (file) {
1474
- if (typeof scope.ngModel === 'undefined') {
1475
- scope.ngModel = [];
1476
- }
1477
- scope.ngModel.push(file);
1478
- }
1479
- }
1480
- );
1481
- });
1482
- }
1483
- } else {
1484
- setEvent = !0;
1485
- }
1486
- }, 500);
1487
- },
1488
- template: `
1489
- <div class="files">
1490
- <label> {{label}} </label>
1491
- <form ng-if="viewOnly !== !0" id="img_{{id}}" class="form text-center pointer">
1492
- <input id="input_{{id}}" class="hidden" type="file" name="file" />
1493
- <a id="btn_{{id}}" class="btn bg-green"> <i class="fa fa-upload white"></i> </a>
1494
- </form>
1495
- <progress class="row"></progress>
1496
- <div class="padding">
1497
-
1498
- <div class="row padding" ng-repeat="f in ngModel">
1499
- <h2>
1500
- <a class="btn default bg-blue" href="{{f.url}}"> <i class="fa fa-2x fa-download white"></i> </a>
1501
- <a ng-if="viewOnly !== !0" class="btn default bg-red" ng-click="deleteFile(f)"> <i class="fa fa-trash white"></i> </a>
1502
- <span> {{f.name}} </span>
1503
- </h2>
1504
- </div>
1505
- </div>
1506
- </div>
1507
-
1508
- `,
1509
- };
1510
- },
1511
- ]);
1512
-
1513
- app.directive('iDrag', [
1514
- '$document',
1515
- function ($document) {
1516
- return function (scope, element, attr) {
1517
- var startX = 0,
1518
- startY = 0,
1519
- x = 0,
1520
- y = 0;
1521
-
1522
- element.css({
1523
- position: 'relative',
1524
- });
1525
-
1526
- element.on('mousedown', function (event) {
1527
- event.preventDefault();
1528
- startX = event.screenX - x;
1529
- startY = event.screenY - y;
1530
- $document.on('mousemove', mousemove);
1531
- $document.on('mouseup', mouseup);
1532
- });
1533
-
1534
- function mousemove(event) {
1535
- y = event.screenY - startY;
1536
- x = event.screenX - startX;
1537
- element.css({
1538
- top: y + 'px',
1539
- left: x + 'px',
1540
- });
1541
- }
1542
-
1543
- function mouseup() {
1544
- $document.off('mousemove', mousemove);
1545
- $document.off('mouseup', mouseup);
1546
- }
860
+ template: `/*##client-side/directive/i-image.html*/`,
1547
861
  };
1548
862
  },
1549
863
  ]);