nice-elements 1.11.1 → 1.12.0
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.
- package/.vscode/settings.json +18 -18
- package/CHANGELOG.md +520 -510
- package/LICENSE.md +21 -21
- package/README.md +98 -98
- package/bower.json +18 -10
- package/dist/nice.js +8399 -8387
- package/dist/nice.min.js +1 -1
- package/dist/style.css +55 -11
- package/dist/style.css.map +2 -1
- package/dist/style.min.css +8 -8
- package/eslint.config.mjs +32 -32
- package/package.json +45 -45
- package/src/components/nice-alert/nice-alert.html +7 -0
- package/src/components/nice-alert/nice-alert.js +27 -0
- package/src/components/nice-alert/nice-alert.scss +41 -0
- package/src/components/nice-button/nice-button.html +4 -4
- package/src/components/nice-button/nice-button.js +41 -41
- package/src/components/nice-button/nice-button.scss +16 -16
- package/src/components/nice-button-toggle/nice-button-toggle.html +9 -9
- package/src/components/nice-button-toggle/nice-button-toggle.js +23 -23
- package/src/components/nice-button-toggle/nice-button-toggle.scss +2 -2
- package/src/components/nice-calendar/nice-calendar.html +91 -91
- package/src/components/nice-calendar/nice-calendar.js +346 -336
- package/src/components/nice-calendar/nice-calendar.scss +288 -285
- package/src/components/nice-checkbox/nice-checkbox.html +5 -5
- package/src/components/nice-checkbox/nice-checkbox.js +34 -34
- package/src/components/nice-checkbox/nice-checkbox.scss +91 -91
- package/src/components/nice-choice/nice-choice.html +18 -18
- package/src/components/nice-choice/nice-choice.js +212 -212
- package/src/components/nice-choice/nice-choice.scss +110 -110
- package/src/components/nice-click-outside/nice-click-outside.js +105 -105
- package/src/components/nice-comment/nice-comment.html +10 -10
- package/src/components/nice-comment/nice-comment.js +71 -71
- package/src/components/nice-comment/nice-comment.scss +39 -39
- package/src/components/nice-date/nice-date.html +79 -79
- package/src/components/nice-date/nice-date.js +333 -333
- package/src/components/nice-date/nice-date.scss +305 -305
- package/src/components/nice-date-input/nice-date-input.html +41 -41
- package/src/components/nice-date-input/nice-date-input.js +111 -111
- package/src/components/nice-date-input/nice-date-input.scss +45 -45
- package/src/components/nice-date-range/nice-date-range.html +15 -15
- package/src/components/nice-date-range/nice-date-range.js +78 -78
- package/src/components/nice-date-range/nice-date-range.scss +390 -390
- package/src/components/nice-datetime-picker/nice-datetime-picker.html +29 -29
- package/src/components/nice-datetime-picker/nice-datetime-picker.js +89 -89
- package/src/components/nice-datetime-picker/nice-datetime-picker.scss +428 -428
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +55 -55
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.js +248 -248
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.scss +73 -73
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +44 -44
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +175 -175
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +127 -127
- package/src/components/nice-dropdown/nice-dropdown.html +61 -61
- package/src/components/nice-dropdown/nice-dropdown.js +517 -517
- package/src/components/nice-dropdown/nice-dropdown.scss +262 -262
- package/src/components/nice-dropdown-date/nice-dropdown-date.html +28 -28
- package/src/components/nice-dropdown-date/nice-dropdown-date.js +132 -132
- package/src/components/nice-dropdown-date/nice-dropdown-date.scss +87 -87
- package/src/components/nice-dropdown-old/nice-dropdown-old.html +44 -44
- package/src/components/nice-dropdown-old/nice-dropdown-old.js +330 -330
- package/src/components/nice-dropdown-old/nice-dropdown-old.scss +129 -129
- package/src/components/nice-dtp/nice-dtp.html +91 -91
- package/src/components/nice-dtp/nice-dtp.js +835 -835
- package/src/components/nice-help/nice-help.html +6 -6
- package/src/components/nice-help/nice-help.js +58 -58
- package/src/components/nice-help/nice-help.scss +78 -78
- package/src/components/nice-input/nice-input.html +48 -48
- package/src/components/nice-input/nice-input.js +249 -246
- package/src/components/nice-input/nice-input.scss +130 -130
- package/src/components/nice-label/nice-label.html +10 -10
- package/src/components/nice-label/nice-label.js +32 -32
- package/src/components/nice-loader/nice-loader.html +6 -6
- package/src/components/nice-loader/nice-loader.js +28 -28
- package/src/components/nice-loader/nice-loader.scss +47 -47
- package/src/components/nice-no-data/nice-no-data.html +3 -3
- package/src/components/nice-no-data/nice-no-data.js +27 -27
- package/src/components/nice-no-data/nice-no-data.scss +26 -26
- package/src/components/nice-notification/nice-notification.html +3 -3
- package/src/components/nice-notification/nice-notification.js +124 -124
- package/src/components/nice-notification/nice-notification.scss +66 -66
- package/src/components/nice-number/nice-number.html +40 -40
- package/src/components/nice-number/nice-number.js +172 -172
- package/src/components/nice-number/nice-number.scss +18 -18
- package/src/components/nice-on-scroll/nice-on-scroll.js +17 -17
- package/src/components/nice-percent/nice-percent.html +24 -24
- package/src/components/nice-percent/nice-percent.js +95 -95
- package/src/components/nice-pill/nice-pill.html +3 -3
- package/src/components/nice-pill/nice-pill.js +29 -29
- package/src/components/nice-pill/nice-pill.scss +25 -25
- package/src/components/nice-popup/nice-popup.html +6 -6
- package/src/components/nice-popup/nice-popup.js +122 -122
- package/src/components/nice-popup/nice-popup.scss +43 -43
- package/src/components/nice-progress-bar/nice-progress-bar.html +15 -15
- package/src/components/nice-progress-bar/nice-progress-bar.js +55 -55
- package/src/components/nice-progress-bar/nice-progress-bar.scss +47 -47
- package/src/components/nice-quantity/nice-quantity.html +22 -22
- package/src/components/nice-quantity/nice-quantity.js +57 -57
- package/src/components/nice-quantity/nice-quantity.scss +51 -51
- package/src/components/nice-search/nice-search.html +44 -44
- package/src/components/nice-search/nice-search.js +243 -243
- package/src/components/nice-search/nice-search.scss +90 -90
- package/src/components/nice-search2/nice-search2.html +32 -32
- package/src/components/nice-search2/nice-search2.js +267 -267
- package/src/components/nice-search2/nice-search2.scss +80 -80
- package/src/components/nice-slot/nice-slot.html +10 -10
- package/src/components/nice-slot/nice-slot.js +31 -31
- package/src/components/nice-steps/nice-steps.scss +81 -81
- package/src/components/nice-svgs/nice-svgs.html +1275 -1275
- package/src/components/nice-svgs/nice-svgs.js +19 -19
- package/src/components/nice-table/nice-table.html +38 -38
- package/src/components/nice-table/nice-table.js +60 -60
- package/src/components/nice-table/nice-table.scss +112 -112
- package/src/components/nice-time-picker/nice-time-picker.html +43 -43
- package/src/components/nice-time-picker/nice-time-picker.js +85 -85
- package/src/components/nice-time-picker/nice-time-picker.scss +37 -37
- package/src/components/nice-title/nice-title.html +3 -3
- package/src/components/nice-title/nice-title.js +21 -21
- package/src/components/nice-toast/nice-toast.html +2 -2
- package/src/components/nice-toast/nice-toast.js +56 -56
- package/src/components/nice-toast/nice-toast.scss +74 -74
- package/src/components/nice-toggle/nice-toggle.html +12 -12
- package/src/components/nice-toggle/nice-toggle.js +55 -55
- package/src/components/nice-toggle/nice-toggle.scss +131 -131
- package/src/components/nice-tooltip/_nice-tooltip.scss +55 -55
- package/src/components/nice-tooltip/nice-tooltip.js +84 -84
- package/src/components/nice-upload/nice-upload.html +22 -22
- package/src/components/nice-upload/nice-upload.js +159 -159
- package/src/components/nice-upload/nice-upload.scss +85 -85
- package/src/components/nice-view/_nice-view.scss +62 -62
- package/src/components/nice-view/nice-view.html +12 -12
- package/src/components/nice-view/nice-view.js +30 -30
- package/src/components/nice-virtual-scroll/_nice-virtual-scroll.scss +17 -17
- package/src/components/nice-virtual-scroll/nice-virtual-scroll.html +12 -12
- package/src/components/nice-virtual-scroll/nice-virtual-scroll.js +70 -70
- package/src/components/nice-wrapper/_nice-wrapper.scss +87 -87
- package/src/components/nice-wrapper/nice-wrapper.html +12 -12
- package/src/components/nice-wrapper/nice-wrapper.js +44 -44
- package/src/components/nice-yesno/nice-yesno.html +14 -14
- package/src/components/nice-yesno/nice-yesno.js +111 -111
- package/src/components/nice-yesno/nice-yesno.scss +95 -95
- package/src/filters/nice-date.js +17 -17
- package/src/filters/nice-highlight.js +16 -16
- package/src/modals/nice-multilangual-modal/nice-multilangual-modal.html +30 -30
- package/src/modals/nice-multilangual-modal/nice-multilangual-modal.js +67 -67
- package/src/modals/nice-multilangual-modal/nice-multilangual-modal.scss +19 -19
- package/src/nice.js +2 -2
- package/src/services/nice-service.js +22 -22
- package/src/styles/_bootstrap-variables.scss +178 -178
- package/src/styles/_nice-buttons.scss +612 -612
- package/src/styles/_nice-common.scss +471 -471
- package/src/styles/_nice-ngdialog.scss +85 -85
- package/src/styles/_nice-spacing.scss +283 -283
- package/src/styles/_nice.scss +71 -70
- package/src/styles/_variables.scss +191 -191
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<ng-form class="nice-component nice-upload" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }" name="form">
|
|
2
|
-
<div class="row">
|
|
3
|
-
<!------------------------- Title ------------------------->
|
|
4
|
-
<nice-title text="title || niceTitle" help="help" required="required" label-width="labelWidth"></nice-title>
|
|
5
|
-
|
|
6
|
-
<!------------------------- Field ------------------------->
|
|
7
|
-
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
|
|
8
|
-
<div class="nice-upload-area">
|
|
9
|
-
<div class="input-area" ng-class="{ 'dragging': dragging || draggingGlobal }">
|
|
10
|
-
<div class="middle-text" ng-if="!imageSource && !loading">
|
|
11
|
-
<nice-icon icon="icon-upload"></nice-icon>
|
|
12
|
-
<div class="text text-placeholder" ng-if="!dragging">{{ text }}</div>
|
|
13
|
-
<div class="text text-placeholder" ng-if="dragging" translate translate-group="Nice">Drop file here</div>
|
|
14
|
-
<div class="error" ng-if="error">{{ error }}</div>
|
|
15
|
-
</div>
|
|
16
|
-
<img ng-if="imageSource" data-ng-src="{{ imageSource }}" />
|
|
17
|
-
</div>
|
|
18
|
-
<input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required" ng-disabled="isDisabled || loading" />
|
|
19
|
-
<nice-loader fulldiv="true" ng-if="loading"></nice-loader>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
1
|
+
<ng-form class="nice-component nice-upload" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }" name="form">
|
|
2
|
+
<div class="row">
|
|
3
|
+
<!------------------------- Title ------------------------->
|
|
4
|
+
<nice-title text="title || niceTitle" help="help" required="required" label-width="labelWidth"></nice-title>
|
|
5
|
+
|
|
6
|
+
<!------------------------- Field ------------------------->
|
|
7
|
+
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
|
|
8
|
+
<div class="nice-upload-area">
|
|
9
|
+
<div class="input-area" ng-class="{ 'dragging': dragging || draggingGlobal }">
|
|
10
|
+
<div class="middle-text" ng-if="!imageSource && !loading">
|
|
11
|
+
<nice-icon icon="icon-upload"></nice-icon>
|
|
12
|
+
<div class="text text-placeholder" ng-if="!dragging">{{ text }}</div>
|
|
13
|
+
<div class="text text-placeholder" ng-if="dragging" translate translate-group="Nice">Drop file here</div>
|
|
14
|
+
<div class="error" ng-if="error">{{ error }}</div>
|
|
15
|
+
</div>
|
|
16
|
+
<img ng-if="imageSource" data-ng-src="{{ imageSource }}" />
|
|
17
|
+
</div>
|
|
18
|
+
<input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required" ng-disabled="isDisabled || loading" />
|
|
19
|
+
<nice-loader fulldiv="true" ng-if="loading"></nice-loader>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
23
|
</ng-form>
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @ngdoc directive
|
|
5
|
-
* @name niceElements.directive:niceUpload
|
|
6
|
-
* @description
|
|
7
|
-
* # niceUpload
|
|
8
|
-
*/
|
|
9
|
-
angular.module('niceElements')
|
|
10
|
-
.directive('niceUpload', function ($timeout, gettextCatalog) {
|
|
11
|
-
return {
|
|
12
|
-
restrict: 'E',
|
|
13
|
-
replace: true,
|
|
14
|
-
transclude: true,
|
|
15
|
-
templateUrl: 'src/components/nice-upload/nice-upload.html',
|
|
16
|
-
scope: {
|
|
17
|
-
model: '=',
|
|
18
|
-
niceTitle: '@',
|
|
19
|
-
title: '@',
|
|
20
|
-
text: '@',
|
|
21
|
-
fieldWidth: '@',
|
|
22
|
-
labelWidth: '@',
|
|
23
|
-
noMargin: '@',
|
|
24
|
-
accept: '@',
|
|
25
|
-
uploadFunction: '=',
|
|
26
|
-
callbackFunction: '=',
|
|
27
|
-
callbackFile: '=',
|
|
28
|
-
callbackUrl: '=',
|
|
29
|
-
isDisabled: '=',
|
|
30
|
-
isInline: '=',
|
|
31
|
-
help: '@',
|
|
32
|
-
maxFileSize: '@',
|
|
33
|
-
required: '=',
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
link: function (scope, element, attrs) {
|
|
37
|
-
if (!attrs.title) { attrs.title = ''; }
|
|
38
|
-
if (!attrs.text) { attrs.text = gettextCatalog.getString('Click to upload file', null, 'Nice'); }
|
|
39
|
-
if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
|
|
40
|
-
if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
|
|
41
|
-
if (!attrs.maxFileSize) scope.maxFileSize = 1; // 1MB
|
|
42
|
-
attrs.noMargin = angular.isDefined(attrs.noMargin);
|
|
43
|
-
|
|
44
|
-
scope.startDragging = function () { $timeout(function () { scope.dragging = true; }); }
|
|
45
|
-
scope.endDragging = function () { $timeout(function () { scope.dragging = false; }); }
|
|
46
|
-
scope.startDraggingGlobal = function () { $timeout(function () { scope.draggingGlobal = true; }); }
|
|
47
|
-
scope.endDraggingGlobal = function () { $timeout(function () { scope.dragging = false; scope.draggingGlobal = false; }); }
|
|
48
|
-
|
|
49
|
-
scope.dragging = false;
|
|
50
|
-
scope.draggingGlobal = false;
|
|
51
|
-
const inputElement = element[0].querySelector(".input-file");
|
|
52
|
-
// document.addEventListener("dragenter", scope.startDraggingGlobal);
|
|
53
|
-
// document.addEventListener("drop", scope.endDraggingGlobal);
|
|
54
|
-
// document.addEventListener("dragend", scope.endDraggingGlobal);
|
|
55
|
-
// document.addEventListener("mouseleave", scope.endDraggingGlobal);
|
|
56
|
-
// document.addEventListener("dragleave", scope.endDragging);
|
|
57
|
-
inputElement.addEventListener("dragenter", scope.startDragging);
|
|
58
|
-
inputElement.addEventListener("dragleave", scope.endDragging);
|
|
59
|
-
inputElement.addEventListener("dragend", scope.endDraggingGlobal);
|
|
60
|
-
inputElement.addEventListener("drop", scope.endDraggingGlobal);
|
|
61
|
-
|
|
62
|
-
scope.$on('$destroy', function () {
|
|
63
|
-
// document.removeEventListener("dragenter", scope.startDraggingGlobal);
|
|
64
|
-
// document.removeEventListener("drop", scope.endDraggingGlobal);
|
|
65
|
-
// document.removeEventListener("dragend", scope.endDraggingGlobal);
|
|
66
|
-
// document.removeEventListener("mouseleave", scope.endDraggingGlobal);
|
|
67
|
-
// document.removeEventListener("dragleave", scope.endDraggingGlobal);
|
|
68
|
-
inputElement.removeEventListener("dragenter", scope.startDragging);
|
|
69
|
-
inputElement.removeEventListener("dragleave", scope.endDragging);
|
|
70
|
-
inputElement.removeEventListener("dragend", scope.endDraggingGlobal);
|
|
71
|
-
inputElement.removeEventListener("drop", scope.endDraggingGlobal);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
element.bind("change", function (changeEvent) {
|
|
76
|
-
if (scope.callbackUrl != undefined) {
|
|
77
|
-
scope.callbackUrl(URL.createObjectURL(changeEvent.target.files[0]));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
$timeout(function () {
|
|
81
|
-
scope.loading = true;
|
|
82
|
-
scope.error = null;
|
|
83
|
-
const inputObj = changeEvent.target;
|
|
84
|
-
const reader = new FileReader();
|
|
85
|
-
|
|
86
|
-
if (inputObj.files) {
|
|
87
|
-
try {
|
|
88
|
-
const fileSize = inputObj.files[0].size; // in bytes
|
|
89
|
-
|
|
90
|
-
reader.onload = function (event) {
|
|
91
|
-
$timeout(function () {
|
|
92
|
-
// file size must be smaller than XMB.
|
|
93
|
-
if (fileSize > (scope.maxFileSize * 1000000)) {
|
|
94
|
-
scope.error = gettextCatalog.getString("File must be smaller than {{size}}MB", { size: scope.maxFileSize }, "Nice");
|
|
95
|
-
scope.loading = false;
|
|
96
|
-
scope.imageSource = null;
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (scope.callbackFunction != undefined) {
|
|
101
|
-
scope.loading = false;
|
|
102
|
-
scope.imageSource = null;
|
|
103
|
-
scope.callbackFunction(event.target.result);
|
|
104
|
-
scope.text = inputObj.files[0].name;
|
|
105
|
-
scope.form.$setDirty();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (scope.callbackFile != undefined) {
|
|
109
|
-
scope.loading = false;
|
|
110
|
-
scope.text = inputObj.files[0].name;
|
|
111
|
-
scope.callbackFile(inputObj.files[0]);
|
|
112
|
-
scope.form.$setDirty();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (scope.uploadFunction != undefined) {
|
|
116
|
-
scope.uploadFunction(inputObj.files[0]).then(function (response) {
|
|
117
|
-
scope.loading = false;
|
|
118
|
-
scope.imageSource = event.target.result;
|
|
119
|
-
scope.model = response.data.url;
|
|
120
|
-
scope.form.$setDirty();
|
|
121
|
-
}, function (error) {
|
|
122
|
-
// Handle upload function error
|
|
123
|
-
scope.error = error;
|
|
124
|
-
scope.loading = false;
|
|
125
|
-
scope.imageSource = null;
|
|
126
|
-
});
|
|
127
|
-
} else {
|
|
128
|
-
// console.error("No upload function set!");
|
|
129
|
-
if (event.target.result.substring(0, 10) == "data:image") {
|
|
130
|
-
scope.imageSource = event.target.result;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
} catch (err) {
|
|
137
|
-
// Handle try catch
|
|
138
|
-
scope.error = gettextCatalog.getString("Something went wrong", null, "Nice");
|
|
139
|
-
scope.loading = false;
|
|
140
|
-
scope.imageSource = null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// when the file is read it triggers the onload event above.
|
|
144
|
-
reader.readAsDataURL(inputObj.files[0]);
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
controller: function ($scope) {
|
|
153
|
-
$scope.$watch("model", function (value) {
|
|
154
|
-
$scope.imageSource = angular.copy($scope.model);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
};
|
|
159
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @ngdoc directive
|
|
5
|
+
* @name niceElements.directive:niceUpload
|
|
6
|
+
* @description
|
|
7
|
+
* # niceUpload
|
|
8
|
+
*/
|
|
9
|
+
angular.module('niceElements')
|
|
10
|
+
.directive('niceUpload', function ($timeout, gettextCatalog) {
|
|
11
|
+
return {
|
|
12
|
+
restrict: 'E',
|
|
13
|
+
replace: true,
|
|
14
|
+
transclude: true,
|
|
15
|
+
templateUrl: 'src/components/nice-upload/nice-upload.html',
|
|
16
|
+
scope: {
|
|
17
|
+
model: '=',
|
|
18
|
+
niceTitle: '@',
|
|
19
|
+
title: '@',
|
|
20
|
+
text: '@',
|
|
21
|
+
fieldWidth: '@',
|
|
22
|
+
labelWidth: '@',
|
|
23
|
+
noMargin: '@',
|
|
24
|
+
accept: '@',
|
|
25
|
+
uploadFunction: '=',
|
|
26
|
+
callbackFunction: '=',
|
|
27
|
+
callbackFile: '=',
|
|
28
|
+
callbackUrl: '=',
|
|
29
|
+
isDisabled: '=',
|
|
30
|
+
isInline: '=',
|
|
31
|
+
help: '@',
|
|
32
|
+
maxFileSize: '@',
|
|
33
|
+
required: '=',
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
link: function (scope, element, attrs) {
|
|
37
|
+
if (!attrs.title) { attrs.title = ''; }
|
|
38
|
+
if (!attrs.text) { attrs.text = gettextCatalog.getString('Click to upload file', null, 'Nice'); }
|
|
39
|
+
if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
|
|
40
|
+
if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
|
|
41
|
+
if (!attrs.maxFileSize) scope.maxFileSize = 1; // 1MB
|
|
42
|
+
attrs.noMargin = angular.isDefined(attrs.noMargin);
|
|
43
|
+
|
|
44
|
+
scope.startDragging = function () { $timeout(function () { scope.dragging = true; }); }
|
|
45
|
+
scope.endDragging = function () { $timeout(function () { scope.dragging = false; }); }
|
|
46
|
+
scope.startDraggingGlobal = function () { $timeout(function () { scope.draggingGlobal = true; }); }
|
|
47
|
+
scope.endDraggingGlobal = function () { $timeout(function () { scope.dragging = false; scope.draggingGlobal = false; }); }
|
|
48
|
+
|
|
49
|
+
scope.dragging = false;
|
|
50
|
+
scope.draggingGlobal = false;
|
|
51
|
+
const inputElement = element[0].querySelector(".input-file");
|
|
52
|
+
// document.addEventListener("dragenter", scope.startDraggingGlobal);
|
|
53
|
+
// document.addEventListener("drop", scope.endDraggingGlobal);
|
|
54
|
+
// document.addEventListener("dragend", scope.endDraggingGlobal);
|
|
55
|
+
// document.addEventListener("mouseleave", scope.endDraggingGlobal);
|
|
56
|
+
// document.addEventListener("dragleave", scope.endDragging);
|
|
57
|
+
inputElement.addEventListener("dragenter", scope.startDragging);
|
|
58
|
+
inputElement.addEventListener("dragleave", scope.endDragging);
|
|
59
|
+
inputElement.addEventListener("dragend", scope.endDraggingGlobal);
|
|
60
|
+
inputElement.addEventListener("drop", scope.endDraggingGlobal);
|
|
61
|
+
|
|
62
|
+
scope.$on('$destroy', function () {
|
|
63
|
+
// document.removeEventListener("dragenter", scope.startDraggingGlobal);
|
|
64
|
+
// document.removeEventListener("drop", scope.endDraggingGlobal);
|
|
65
|
+
// document.removeEventListener("dragend", scope.endDraggingGlobal);
|
|
66
|
+
// document.removeEventListener("mouseleave", scope.endDraggingGlobal);
|
|
67
|
+
// document.removeEventListener("dragleave", scope.endDraggingGlobal);
|
|
68
|
+
inputElement.removeEventListener("dragenter", scope.startDragging);
|
|
69
|
+
inputElement.removeEventListener("dragleave", scope.endDragging);
|
|
70
|
+
inputElement.removeEventListener("dragend", scope.endDraggingGlobal);
|
|
71
|
+
inputElement.removeEventListener("drop", scope.endDraggingGlobal);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
element.bind("change", function (changeEvent) {
|
|
76
|
+
if (scope.callbackUrl != undefined) {
|
|
77
|
+
scope.callbackUrl(URL.createObjectURL(changeEvent.target.files[0]));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
$timeout(function () {
|
|
81
|
+
scope.loading = true;
|
|
82
|
+
scope.error = null;
|
|
83
|
+
const inputObj = changeEvent.target;
|
|
84
|
+
const reader = new FileReader();
|
|
85
|
+
|
|
86
|
+
if (inputObj.files) {
|
|
87
|
+
try {
|
|
88
|
+
const fileSize = inputObj.files[0].size; // in bytes
|
|
89
|
+
|
|
90
|
+
reader.onload = function (event) {
|
|
91
|
+
$timeout(function () {
|
|
92
|
+
// file size must be smaller than XMB.
|
|
93
|
+
if (fileSize > (scope.maxFileSize * 1000000)) {
|
|
94
|
+
scope.error = gettextCatalog.getString("File must be smaller than {{size}}MB", { size: scope.maxFileSize }, "Nice");
|
|
95
|
+
scope.loading = false;
|
|
96
|
+
scope.imageSource = null;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (scope.callbackFunction != undefined) {
|
|
101
|
+
scope.loading = false;
|
|
102
|
+
scope.imageSource = null;
|
|
103
|
+
scope.callbackFunction(event.target.result);
|
|
104
|
+
scope.text = inputObj.files[0].name;
|
|
105
|
+
scope.form.$setDirty();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (scope.callbackFile != undefined) {
|
|
109
|
+
scope.loading = false;
|
|
110
|
+
scope.text = inputObj.files[0].name;
|
|
111
|
+
scope.callbackFile(inputObj.files[0]);
|
|
112
|
+
scope.form.$setDirty();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (scope.uploadFunction != undefined) {
|
|
116
|
+
scope.uploadFunction(inputObj.files[0]).then(function (response) {
|
|
117
|
+
scope.loading = false;
|
|
118
|
+
scope.imageSource = event.target.result;
|
|
119
|
+
scope.model = response.data.url;
|
|
120
|
+
scope.form.$setDirty();
|
|
121
|
+
}, function (error) {
|
|
122
|
+
// Handle upload function error
|
|
123
|
+
scope.error = error;
|
|
124
|
+
scope.loading = false;
|
|
125
|
+
scope.imageSource = null;
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
// console.error("No upload function set!");
|
|
129
|
+
if (event.target.result.substring(0, 10) == "data:image") {
|
|
130
|
+
scope.imageSource = event.target.result;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
} catch (err) {
|
|
137
|
+
// Handle try catch
|
|
138
|
+
scope.error = gettextCatalog.getString("Something went wrong", null, "Nice");
|
|
139
|
+
scope.loading = false;
|
|
140
|
+
scope.imageSource = null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// when the file is read it triggers the onload event above.
|
|
144
|
+
reader.readAsDataURL(inputObj.files[0]);
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
controller: function ($scope) {
|
|
153
|
+
$scope.$watch("model", function (value) {
|
|
154
|
+
$scope.imageSource = angular.copy($scope.model);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
};
|
|
159
|
+
});
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
.nice-upload {
|
|
2
|
-
display: block;
|
|
3
|
-
// overflow: hidden;
|
|
4
|
-
|
|
5
|
-
.nice-field {
|
|
6
|
-
&:focus-within {
|
|
7
|
-
.input-area {
|
|
8
|
-
@extend .nice-focus;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.nice-upload-area {
|
|
14
|
-
height: 150px;
|
|
15
|
-
position: relative;
|
|
16
|
-
|
|
17
|
-
border-radius: var(--nice-border-radius);
|
|
18
|
-
border: 1px solid var(--nice-border-color);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
input {
|
|
22
|
-
position: absolute;
|
|
23
|
-
top: 0;
|
|
24
|
-
left: 0;
|
|
25
|
-
width: 100%;
|
|
26
|
-
height: 100%;
|
|
27
|
-
opacity: 0;
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
|
|
30
|
-
&:disabled {
|
|
31
|
-
cursor: not-allowed;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.input-area {
|
|
36
|
-
width: 100%;
|
|
37
|
-
height: 100%;
|
|
38
|
-
top: 0;
|
|
39
|
-
left: 0;
|
|
40
|
-
position: absolute;
|
|
41
|
-
padding: 1rem;
|
|
42
|
-
border-radius: $nice-border-radius;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
display: flex;
|
|
45
|
-
justify-content: center;
|
|
46
|
-
align-items: center;
|
|
47
|
-
|
|
48
|
-
&.dragging {
|
|
49
|
-
outline: 2px dashed var(--nice-primary-color);
|
|
50
|
-
outline-offset: -7px;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.middle-text {
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
justify-content: center;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
height: 100%;
|
|
59
|
-
|
|
60
|
-
svg {
|
|
61
|
-
opacity: 0.6;
|
|
62
|
-
margin-bottom: 5px;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.error,
|
|
66
|
-
.text-placeholder {
|
|
67
|
-
font-size: 0.9em;
|
|
68
|
-
opacity: 0.6;
|
|
69
|
-
text-align: center;
|
|
70
|
-
padding-left: 0.5rem;
|
|
71
|
-
padding-right: 0.5rem;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.error {
|
|
75
|
-
color: $nice-danger-color;
|
|
76
|
-
opacity: 1;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
img {
|
|
81
|
-
width: 100%;
|
|
82
|
-
height: 100%;
|
|
83
|
-
object-fit: contain;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
1
|
+
.nice-upload {
|
|
2
|
+
display: block;
|
|
3
|
+
// overflow: hidden;
|
|
4
|
+
|
|
5
|
+
.nice-field {
|
|
6
|
+
&:focus-within {
|
|
7
|
+
.input-area {
|
|
8
|
+
@extend .nice-focus;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.nice-upload-area {
|
|
14
|
+
height: 150px;
|
|
15
|
+
position: relative;
|
|
16
|
+
|
|
17
|
+
border-radius: var(--nice-border-radius);
|
|
18
|
+
border: 1px solid var(--nice-border-color);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
input {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
|
|
30
|
+
&:disabled {
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.input-area {
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: 100%;
|
|
38
|
+
top: 0;
|
|
39
|
+
left: 0;
|
|
40
|
+
position: absolute;
|
|
41
|
+
padding: 1rem;
|
|
42
|
+
border-radius: $nice-border-radius;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
display: flex;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-items: center;
|
|
47
|
+
|
|
48
|
+
&.dragging {
|
|
49
|
+
outline: 2px dashed var(--nice-primary-color);
|
|
50
|
+
outline-offset: -7px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.middle-text {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
height: 100%;
|
|
59
|
+
|
|
60
|
+
svg {
|
|
61
|
+
opacity: 0.6;
|
|
62
|
+
margin-bottom: 5px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.error,
|
|
66
|
+
.text-placeholder {
|
|
67
|
+
font-size: 0.9em;
|
|
68
|
+
opacity: 0.6;
|
|
69
|
+
text-align: center;
|
|
70
|
+
padding-left: 0.5rem;
|
|
71
|
+
padding-right: 0.5rem;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.error {
|
|
75
|
+
color: $nice-danger-color;
|
|
76
|
+
opacity: 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
img {
|
|
81
|
+
width: 100%;
|
|
82
|
+
height: 100%;
|
|
83
|
+
object-fit: contain;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
86
|
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
.nice-view {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
height: 100dvh;
|
|
5
|
-
--nice-view-padding: 2rem;
|
|
6
|
-
|
|
7
|
-
&.nice-view-has-header {
|
|
8
|
-
.nice-view-body {
|
|
9
|
-
padding-top: calc(var(--nice-view-padding) / 2);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&.nice-view-has-footer {
|
|
14
|
-
.nice-view-body {
|
|
15
|
-
padding-bottom: calc(var(--nice-view-padding) / 2);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.nice-view-header {
|
|
20
|
-
flex-shrink: 0;
|
|
21
|
-
padding: var(--nice-view-padding);
|
|
22
|
-
padding-bottom: calc(var(--nice-view-padding) / 2);
|
|
23
|
-
|
|
24
|
-
.nice-view-header-wrapper {
|
|
25
|
-
display: flex;
|
|
26
|
-
align-items: center;
|
|
27
|
-
|
|
28
|
-
.nice-icon {
|
|
29
|
-
height: 50px;
|
|
30
|
-
width: 50px;
|
|
31
|
-
margin-right: 1rem;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.nice-view-header-title {
|
|
36
|
-
font-size: 2em;
|
|
37
|
-
line-height: 1;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.nice-view-header-subtitle {
|
|
41
|
-
text-transform: uppercase;
|
|
42
|
-
color: var(--nice-primary-color);
|
|
43
|
-
margin-bottom: 3px;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.nice-view-body {
|
|
48
|
-
flex-grow: 1;
|
|
49
|
-
overflow: auto;
|
|
50
|
-
padding: var(--nice-view-padding);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.nice-view-footer {
|
|
54
|
-
flex-shrink: 0;
|
|
55
|
-
padding: var(--nice-view-padding);
|
|
56
|
-
padding-top: calc(var(--nice-view-padding) / 2);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@media (max-width: 767px) {
|
|
60
|
-
--nice-view-padding: 1rem;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
.nice-view {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
height: 100dvh;
|
|
5
|
+
--nice-view-padding: 2rem;
|
|
6
|
+
|
|
7
|
+
&.nice-view-has-header {
|
|
8
|
+
.nice-view-body {
|
|
9
|
+
padding-top: calc(var(--nice-view-padding) / 2);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&.nice-view-has-footer {
|
|
14
|
+
.nice-view-body {
|
|
15
|
+
padding-bottom: calc(var(--nice-view-padding) / 2);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.nice-view-header {
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
padding: var(--nice-view-padding);
|
|
22
|
+
padding-bottom: calc(var(--nice-view-padding) / 2);
|
|
23
|
+
|
|
24
|
+
.nice-view-header-wrapper {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
|
|
28
|
+
.nice-icon {
|
|
29
|
+
height: 50px;
|
|
30
|
+
width: 50px;
|
|
31
|
+
margin-right: 1rem;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.nice-view-header-title {
|
|
36
|
+
font-size: 2em;
|
|
37
|
+
line-height: 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.nice-view-header-subtitle {
|
|
41
|
+
text-transform: uppercase;
|
|
42
|
+
color: var(--nice-primary-color);
|
|
43
|
+
margin-bottom: 3px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nice-view-body {
|
|
48
|
+
flex-grow: 1;
|
|
49
|
+
overflow: auto;
|
|
50
|
+
padding: var(--nice-view-padding);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.nice-view-footer {
|
|
54
|
+
flex-shrink: 0;
|
|
55
|
+
padding: var(--nice-view-padding);
|
|
56
|
+
padding-top: calc(var(--nice-view-padding) / 2);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media (max-width: 767px) {
|
|
60
|
+
--nice-view-padding: 1rem;
|
|
61
|
+
}
|
|
62
|
+
}
|