From 67fbba1a84fb863377b637ed0dc905ef5924bd08 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sat, 15 Dec 2018 13:05:58 +0100 Subject: [PATCH 1/5] implemented search in icon-picker Signed-off-by: fnuesse --- controller/translationcontroller.php | 1 + js/app/directives/iconpicker.js | 41 +++++++++++++++++++++++ sass/credentials.scss | 3 ++ templates/views/partials/icon-picker.html | 1 + 4 files changed, 46 insertions(+) diff --git a/controller/translationcontroller.php b/controller/translationcontroller.php index 00311a01..a3232a9a 100644 --- a/controller/translationcontroller.php +++ b/controller/translationcontroller.php @@ -140,6 +140,7 @@ class TranslationController extends ApiController { 'password.r' => $this->trans->t('Repeat password'), 'add.tag' => $this->trans->t('Add tag'), 'pick.icon' => $this->trans->t('Pick an icon'), + 'pick.icon.search' => $this->trans->t('Search icons'), 'use.icon' => $this->trans->t('Use this icon'), 'selected.icon' => $this->trans->t('Selected icon'), diff --git a/js/app/directives/iconpicker.js b/js/app/directives/iconpicker.js index dd6d85e1..2fabf176 100644 --- a/js/app/directives/iconpicker.js +++ b/js/app/directives/iconpicker.js @@ -52,6 +52,47 @@ $('.iconList').scrollTop(offset.top); }; + 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; + }; + scope.useIcon = function() { $http.get(scope.selectedIcon.url).then(function(result) { var base64Data = window.btoa(result.data); diff --git a/sass/credentials.scss b/sass/credentials.scss index 254585bc..c8b11f1e 100644 --- a/sass/credentials.scss +++ b/sass/credentials.scss @@ -589,4 +589,7 @@ float: right; width: calc(40% - 10px); } + .iconSearch { + width: 100%; + } } \ No newline at end of file diff --git a/templates/views/partials/icon-picker.html b/templates/views/partials/icon-picker.html index 892244be..f3d41b69 100644 --- a/templates/views/partials/icon-picker.html +++ b/templates/views/partials/icon-picker.html @@ -12,6 +12,7 @@
+ -
- {{ 'selected.icon' | translate}}:
+
+ {{ 'selected.icon' | translate}}:
- -
- -
+ + +
+ +
\ No newline at end of file From 568caf4d1195437ed811a26a7d5117e230accd70 Mon Sep 17 00:00:00 2001 From: newhinton Date: Sat, 15 Dec 2018 14:32:49 +0100 Subject: [PATCH 3/5] Added missing variable to iconpicker.js --- js/app/directives/iconpicker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/app/directives/iconpicker.js b/js/app/directives/iconpicker.js index bf2e8c03..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; }); @@ -143,4 +144,4 @@ } }; }]); -}()); \ No newline at end of file +}()); From ea1c107236d90ad5e65c046be16f1a69d22e467e Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 16 Dec 2018 12:12:37 +0100 Subject: [PATCH 4/5] added label to custom icon-upload Signed-off-by: fnuesse --- controller/translationcontroller.php | 1 + templates/views/partials/icon-picker.html | 2 ++ 2 files changed, 3 insertions(+) diff --git a/controller/translationcontroller.php b/controller/translationcontroller.php index a3232a9a..46f95c44 100644 --- a/controller/translationcontroller.php +++ b/controller/translationcontroller.php @@ -141,6 +141,7 @@ class TranslationController extends ApiController { 'add.tag' => $this->trans->t('Add tag'), 'pick.icon' => $this->trans->t('Pick an icon'), 'pick.icon.search' => $this->trans->t('Search icons'), + 'pick.icon.custom.label' => $this->trans->t('Upload a custom icon:'), 'use.icon' => $this->trans->t('Use this icon'), 'selected.icon' => $this->trans->t('Selected icon'), diff --git a/templates/views/partials/icon-picker.html b/templates/views/partials/icon-picker.html index bf1e3480..8c06aa10 100644 --- a/templates/views/partials/icon-picker.html +++ b/templates/views/partials/icon-picker.html @@ -1,6 +1,7 @@
+