nice-elements 1.13.2 → 1.13.3
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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +35 -14
- package/dist/nice.min.js +1 -1
- package/package.json +1 -1
- package/src/components/nice-upload/nice-upload.html +16 -2
- package/src/components/nice-upload/nice-upload.js +11 -6
- package/src/filters/nice-highlight.js +15 -6
- package/src/services/nice-service.js +1 -1
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
7
|
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
|
|
8
8
|
<div class="nice-upload-area">
|
|
9
|
+
<!-- Input area texts -->
|
|
9
10
|
<div class="input-area" ng-class="{ 'dragging': dragging || draggingGlobal }">
|
|
10
11
|
<div class="middle-text" ng-if="!imageSource && !loading">
|
|
11
12
|
<nice-icon icon="icon-upload"></nice-icon>
|
|
@@ -17,10 +18,23 @@
|
|
|
17
18
|
<img data-ng-src="{{ imageSource }}" />
|
|
18
19
|
</div>
|
|
19
20
|
</div>
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
<!-- Clear button -->
|
|
23
|
+
<button type="button" ng-click="clear()" ng-if="imageSource && !loading && showClear" class="btn btn-primary nice-upload-clear-button">
|
|
21
24
|
<nice-icon icon="icon-x"></nice-icon>
|
|
22
25
|
</button>
|
|
23
|
-
|
|
26
|
+
|
|
27
|
+
<!-- Input file -->
|
|
28
|
+
<input
|
|
29
|
+
class="input-file"
|
|
30
|
+
type="file"
|
|
31
|
+
accept="{{ accept }}"
|
|
32
|
+
ng-model="file"
|
|
33
|
+
ng-required="required"
|
|
34
|
+
ng-disabled="isDisabled || loading"
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
<!-- Loading -->
|
|
24
38
|
<nice-loader fulldiv="true" ng-if="loading"></nice-loader>
|
|
25
39
|
</div>
|
|
26
40
|
</div>
|
|
@@ -28,7 +28,7 @@ angular.module('niceElements')
|
|
|
28
28
|
callbackUrl: '=',
|
|
29
29
|
isDisabled: '=',
|
|
30
30
|
isInline: '=',
|
|
31
|
-
|
|
31
|
+
showClear: '=',
|
|
32
32
|
help: '@',
|
|
33
33
|
maxFileSize: '@',
|
|
34
34
|
required: '=',
|
|
@@ -46,6 +46,7 @@ angular.module('niceElements')
|
|
|
46
46
|
scope.endDragging = function () { $timeout(function () { scope.dragging = false; }); };
|
|
47
47
|
scope.startDraggingGlobal = function () { $timeout(function () { scope.draggingGlobal = true; }); };
|
|
48
48
|
scope.endDraggingGlobal = function () { $timeout(function () { scope.dragging = false; scope.draggingGlobal = false; }); };
|
|
49
|
+
scope.file = null;
|
|
49
50
|
|
|
50
51
|
scope.dragging = false;
|
|
51
52
|
scope.draggingGlobal = false;
|
|
@@ -149,8 +150,8 @@ angular.module('niceElements')
|
|
|
149
150
|
});
|
|
150
151
|
},
|
|
151
152
|
|
|
152
|
-
controller: function ($scope) {
|
|
153
|
-
$scope.$watch("model", function (
|
|
153
|
+
controller: function ($scope, $element) {
|
|
154
|
+
$scope.$watch("model", function () {
|
|
154
155
|
$scope.imageSource = angular.copy($scope.model);
|
|
155
156
|
});
|
|
156
157
|
|
|
@@ -158,10 +159,14 @@ angular.module('niceElements')
|
|
|
158
159
|
$scope.model = null;
|
|
159
160
|
$scope.imageSource = null;
|
|
160
161
|
$scope.form.$setDirty();
|
|
162
|
+
const inputElement = $element[0].querySelector(".input-file");
|
|
163
|
+
if (inputElement) inputElement.value = null;
|
|
164
|
+
|
|
161
165
|
$scope.text = gettextCatalog.getString('Click to upload file', null, 'Nice');
|
|
162
|
-
if ($scope.callbackFunction) $scope.callbackFunction(
|
|
163
|
-
if ($scope.callbackFile) $scope.callbackFile(
|
|
164
|
-
if ($scope.callbackUrl) $scope.callbackUrl(
|
|
166
|
+
if ($scope.callbackFunction) $scope.callbackFunction();
|
|
167
|
+
if ($scope.callbackFile) $scope.callbackFile();
|
|
168
|
+
if ($scope.callbackUrl) $scope.callbackUrl();
|
|
169
|
+
if ($scope.uploadFunction) $scope.uploadFunction();
|
|
165
170
|
};
|
|
166
171
|
}
|
|
167
172
|
|
|
@@ -6,12 +6,21 @@
|
|
|
6
6
|
* # niceHighlight
|
|
7
7
|
* Filter in the niceElements.
|
|
8
8
|
*/
|
|
9
|
-
angular.module('niceElements').filter('niceHighlight', function () {
|
|
10
|
-
return function (
|
|
11
|
-
if (!
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
angular.module('niceElements').filter('niceHighlight', function ($sanitize, $sce) {
|
|
10
|
+
return function (text, phrase) {
|
|
11
|
+
if (!phrase || !text) return text;
|
|
12
|
+
|
|
13
|
+
// 1. Sanitize the original text to prevent XSS
|
|
14
|
+
let cleanText = $sanitize(text);
|
|
15
|
+
|
|
16
|
+
// 2. Create the case-insensitive global Regex
|
|
17
|
+
const regex = new RegExp('(' + phrase + ')', 'gi');
|
|
18
|
+
|
|
19
|
+
// 3. Replace matches with the h element
|
|
20
|
+
const highlighted = cleanText.replace(regex, '<h>$1</h>');
|
|
21
|
+
|
|
22
|
+
// 4. Trust the result so ng-bind-html renders it
|
|
23
|
+
return $sce.trustAsHtml(highlighted);
|
|
15
24
|
};
|
|
16
25
|
});
|
|
17
26
|
|