Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/passman.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolFi <wolfi@wolfi.es>2018-12-16 16:07:58 +0300
committerWolFi <wolfi@wolfi.es>2018-12-16 16:07:58 +0300
commite1e0ec7a7658447000238578002e747e4bcd8959 (patch)
tree6c520e35669e88e561609a65c93a11c90b09aa72 /js/app/directives
parent7deb663a110dec2f59a1e80f34a1d9f5c91ced4c (diff)
parentf23c9e36a037de0a4a602a0c6b10e67982d8ad48 (diff)
Merge branch 'feature/noid/iconpickersearch' into feature/merges_v2.2.0
Diffstat (limited to 'js/app/directives')
-rw-r--r--js/app/directives/iconpicker.js71
1 files changed, 69 insertions, 2 deletions
diff --git a/js/app/directives/iconpicker.js b/js/app/directives/iconpicker.js
index dd6d85e1..0c885845 100644
--- a/js/app/directives/iconpicker.js
+++ b/js/app/directives/iconpicker.js
@@ -40,6 +40,7 @@
link: function(scope, element) {
IconService.getIcons().then(function(icons) {
+ scope.iconGroupsAll = icons;
scope.iconGroups = icons;
});
@@ -52,7 +53,73 @@
$('.iconList').scrollTop(offset.top);
};
- scope.useIcon = function() {
+ var search = document.getElementById("iconPicker-Search");
+ search.addEventListener('keypress', function (e) {
+ if(e.keyCode === 13){
+ e.preventDefault();
+ }
+ });
+
+ search.addEventListener('keyup', function (e) {
+ var g={};
+ g.Numix=[];
+ scope.iconGroupsAll.Numix.forEach(function(element) {
+ if(scope.isAllowedIcon(element))
+ g.Numix.push(element);
+ });
+
+ g["essential-collection"]=[];
+ scope.iconGroupsAll["essential-collection"].forEach(function(element) {
+ if(scope.isAllowedIcon(element))
+ g["essential-collection"].push(element);
+ });
+
+ g["font-awesome"]=[];
+ scope.iconGroupsAll["font-awesome"].forEach(function(element) {
+ if(scope.isAllowedIcon(element))
+ g["font-awesome"].push(element);
+ });
+
+ scope.iconGroups=g;
+ scope.$apply();
+ });
+
+ scope.isAllowedIcon = function(IconElement) {
+ var searchval=search.value.toLowerCase();
+ var urlCropped = IconElement.url.substring(IconElement.url.lastIndexOf("/")+1, IconElement.url.length);
+
+ if(urlCropped.includes(searchval) || IconElement.pack.toLowerCase() ===searchval){
+ return true;
+ }
+ return false;
+ };
+
+ $('#iconPicker-CustomIcon').on('change', function(ev) {
+
+ console.log("upload");
+ scope.customIcon = {};
+
+ var f = ev.target.files[0];
+ var fr = new FileReader();
+
+ fr.onload = function(ev2) {
+ scope.customIcon.data=ev2.target.result;
+ scope.$apply();
+ };
+
+ fr.readAsDataURL(f);
+ });
+
+ scope.useIcon = function() {
+
+ if(scope.customIcon){
+ var data = scope.customIcon.data;
+ scope.credential.icon.type = data.substring(data.lastIndexOf(":")+1,data.lastIndexOf(";"));
+ scope.credential.icon.content = data.substring(data.lastIndexOf(",")+1, data.length);
+ $('#iconPicker').dialog('close');
+ return;
+ }
+
$http.get(scope.selectedIcon.url).then(function(result) {
var base64Data = window.btoa(result.data);
var mimeType = 'svg+xml';
@@ -77,4 +144,4 @@
}
};
}]);
-}()); \ No newline at end of file
+}());