nice-elements 1.13.1 → 1.13.2
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 +5 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +69 -57
- package/dist/nice.min.js +1 -1
- package/dist/style.css +15 -0
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +1 -1
- package/package.json +1 -1
- package/src/components/nice-upload/nice-upload.html +3 -0
- package/src/components/nice-upload/nice-upload.js +68 -59
- package/src/components/nice-upload/nice-upload.scss +15 -0
- package/src/services/nice-service.js +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
# Nice elements v1.13.
|
|
3
|
+
# Nice elements v1.13.2
|
|
4
4
|
|
|
5
5
|
Nice elements is an AngularJS v1.5.8 module that contains nice form elements like inputs, choice fields, search, toggle, dropdown, etc.
|
|
6
6
|
|
package/bower.json
CHANGED
package/dist/nice.js
CHANGED
|
@@ -5846,6 +5846,7 @@ angular.module('niceElements')
|
|
|
5846
5846
|
callbackUrl: '=',
|
|
5847
5847
|
isDisabled: '=',
|
|
5848
5848
|
isInline: '=',
|
|
5849
|
+
hideClear: '=',
|
|
5849
5850
|
help: '@',
|
|
5850
5851
|
maxFileSize: '@',
|
|
5851
5852
|
required: '=',
|
|
@@ -5896,73 +5897,71 @@ angular.module('niceElements')
|
|
|
5896
5897
|
}
|
|
5897
5898
|
|
|
5898
5899
|
$timeout(function () {
|
|
5899
|
-
scope.loading = true;
|
|
5900
|
-
scope.error = null;
|
|
5901
5900
|
const inputObj = changeEvent.target;
|
|
5902
5901
|
const reader = new FileReader();
|
|
5902
|
+
if (!inputObj.files || !inputObj.files[0]) return;
|
|
5903
|
+
scope.loading = true;
|
|
5904
|
+
scope.error = null;
|
|
5903
5905
|
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
const fileSize = inputObj.files[0].size; // in bytes
|
|
5906
|
+
try {
|
|
5907
|
+
const fileSize = inputObj.files[0].size; // in bytes
|
|
5907
5908
|
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5909
|
+
reader.onload = function (event) {
|
|
5910
|
+
$timeout(function () {
|
|
5911
|
+
// file size must be smaller than XMB.
|
|
5912
|
+
if (fileSize > (scope.maxFileSize * 1000000)) {
|
|
5913
|
+
scope.error = gettextCatalog.getString("File must be smaller than {{size}}MB", { size: scope.maxFileSize }, "Nice");
|
|
5914
|
+
scope.loading = false;
|
|
5915
|
+
scope.imageSource = null;
|
|
5916
|
+
return;
|
|
5917
|
+
}
|
|
5917
5918
|
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5919
|
+
if (scope.callbackFunction != undefined) {
|
|
5920
|
+
scope.loading = false;
|
|
5921
|
+
scope.imageSource = null;
|
|
5922
|
+
scope.callbackFunction(event.target.result);
|
|
5923
|
+
scope.text = inputObj.files[0].name;
|
|
5924
|
+
scope.form.$setDirty();
|
|
5925
|
+
}
|
|
5926
|
+
|
|
5927
|
+
if (scope.callbackFile != undefined) {
|
|
5928
|
+
scope.loading = false;
|
|
5929
|
+
scope.text = inputObj.files[0].name;
|
|
5930
|
+
scope.callbackFile(inputObj.files[0]);
|
|
5931
|
+
scope.form.$setDirty();
|
|
5932
|
+
}
|
|
5925
5933
|
|
|
5926
|
-
|
|
5934
|
+
if (scope.uploadFunction != undefined) {
|
|
5935
|
+
scope.uploadFunction(inputObj.files[0]).then(function (response) {
|
|
5927
5936
|
scope.loading = false;
|
|
5928
|
-
scope.
|
|
5929
|
-
scope.
|
|
5937
|
+
scope.imageSource = event.target.result;
|
|
5938
|
+
if (response.data && response.data.url) scope.model = response.data.url;
|
|
5939
|
+
if (response.file) scope.model = response.data.url;
|
|
5930
5940
|
scope.form.$setDirty();
|
|
5941
|
+
}, function (error) {
|
|
5942
|
+
// Handle upload function error
|
|
5943
|
+
scope.error = error;
|
|
5944
|
+
scope.loading = false;
|
|
5945
|
+
scope.imageSource = null;
|
|
5946
|
+
});
|
|
5947
|
+
} else {
|
|
5948
|
+
// console.error("No upload function set!");
|
|
5949
|
+
if (event.target.result.substring(0, 10) == "data:image") {
|
|
5950
|
+
scope.imageSource = event.target.result;
|
|
5931
5951
|
}
|
|
5952
|
+
}
|
|
5953
|
+
});
|
|
5954
|
+
};
|
|
5932
5955
|
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
if (response.file) scope.model = response.data.url;
|
|
5939
|
-
scope.form.$setDirty();
|
|
5940
|
-
}, function (error) {
|
|
5941
|
-
// Handle upload function error
|
|
5942
|
-
scope.error = error;
|
|
5943
|
-
scope.loading = false;
|
|
5944
|
-
scope.imageSource = null;
|
|
5945
|
-
});
|
|
5946
|
-
} else {
|
|
5947
|
-
// console.error("No upload function set!");
|
|
5948
|
-
if (event.target.result.substring(0, 10) == "data:image") {
|
|
5949
|
-
scope.imageSource = event.target.result;
|
|
5950
|
-
}
|
|
5951
|
-
}
|
|
5952
|
-
});
|
|
5953
|
-
};
|
|
5954
|
-
|
|
5955
|
-
} catch (err) {
|
|
5956
|
-
// Handle try catch
|
|
5957
|
-
scope.error = gettextCatalog.getString("Something went wrong", null, "Nice");
|
|
5958
|
-
scope.loading = false;
|
|
5959
|
-
scope.imageSource = null;
|
|
5960
|
-
}
|
|
5961
|
-
|
|
5962
|
-
// when the file is read it triggers the onload event above.
|
|
5963
|
-
reader.readAsDataURL(inputObj.files[0]);
|
|
5964
|
-
|
|
5956
|
+
} catch (err) {
|
|
5957
|
+
// Handle try catch
|
|
5958
|
+
scope.error = gettextCatalog.getString("Something went wrong", null, "Nice");
|
|
5959
|
+
scope.loading = false;
|
|
5960
|
+
scope.imageSource = null;
|
|
5965
5961
|
}
|
|
5962
|
+
|
|
5963
|
+
// when the file is read it triggers the onload event above.
|
|
5964
|
+
reader.readAsDataURL(inputObj.files[0]);
|
|
5966
5965
|
});
|
|
5967
5966
|
|
|
5968
5967
|
});
|
|
@@ -5972,6 +5971,16 @@ angular.module('niceElements')
|
|
|
5972
5971
|
$scope.$watch("model", function (value) {
|
|
5973
5972
|
$scope.imageSource = angular.copy($scope.model);
|
|
5974
5973
|
});
|
|
5974
|
+
|
|
5975
|
+
$scope.clear = function () {
|
|
5976
|
+
$scope.model = null;
|
|
5977
|
+
$scope.imageSource = null;
|
|
5978
|
+
$scope.form.$setDirty();
|
|
5979
|
+
$scope.text = gettextCatalog.getString('Click to upload file', null, 'Nice');
|
|
5980
|
+
if ($scope.callbackFunction) $scope.callbackFunction(null);
|
|
5981
|
+
if ($scope.callbackFile) $scope.callbackFile(null);
|
|
5982
|
+
if ($scope.callbackUrl) $scope.callbackUrl(null);
|
|
5983
|
+
};
|
|
5975
5984
|
}
|
|
5976
5985
|
|
|
5977
5986
|
};
|
|
@@ -6525,7 +6534,7 @@ angular.module('niceElements')
|
|
|
6525
6534
|
.service('NiceService', function ($rootScope) {
|
|
6526
6535
|
const service = {
|
|
6527
6536
|
name: "Nice elements",
|
|
6528
|
-
version: "1.13.
|
|
6537
|
+
version: "1.13.2",
|
|
6529
6538
|
getHeader: function () {
|
|
6530
6539
|
return {};
|
|
6531
6540
|
},
|
|
@@ -9215,6 +9224,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
|
|
|
9215
9224
|
" <img data-ng-src=\"{{ imageSource }}\">\n" +
|
|
9216
9225
|
" </div>\n" +
|
|
9217
9226
|
" </div>\n" +
|
|
9227
|
+
" <button type=\"button\" ng-click=\"clear()\" ng-if=\"imageSource && !loading && !hideClear\" class=\"btn btn-primary nice-upload-clear-button\">\n" +
|
|
9228
|
+
" <nice-icon icon=\"icon-x\"></nice-icon>\n" +
|
|
9229
|
+
" </button>\n" +
|
|
9218
9230
|
" <input class=\"input-file\" type=\"file\" accept=\"{{ accept }}\" ng-model=\"file\" ng-required=\"required\" ng-disabled=\"isDisabled || loading\">\n" +
|
|
9219
9231
|
" <nice-loader fulldiv=\"true\" ng-if=\"loading\"></nice-loader>\n" +
|
|
9220
9232
|
" </div>\n" +
|