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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.13.2",
3
+ "version": "1.13.3",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -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
- <button type="button" ng-click="clear()" ng-if="imageSource && !loading && !hideClear" class="btn btn-primary nice-upload-clear-button">
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
- <input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required" ng-disabled="isDisabled || loading" />
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
- hideClear: '=',
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 (value) {
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(null);
163
- if ($scope.callbackFile) $scope.callbackFile(null);
164
- if ($scope.callbackUrl) $scope.callbackUrl(null);
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 (value, highlightedText) {
11
- if (!value || !highlightedText) return "";
12
- const regex = new RegExp(highlightedText, 'gmi');
13
- const newValue = String(value).replace(regex, "<span class='nice-highlight'>$&</span>");
14
- return newValue;
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
 
@@ -10,7 +10,7 @@ angular.module('niceElements')
10
10
  .service('NiceService', function ($rootScope) {
11
11
  const service = {
12
12
  name: "Nice elements",
13
- version: "1.13.2",
13
+ version: "1.13.3",
14
14
  getHeader: function () {
15
15
  return {};
16
16
  },