From 68398cba956d1b692ab19f83f277ca9df130b64c Mon Sep 17 00:00:00 2001 From: Vit Brunner Date: Mon, 4 Feb 2019 22:55:11 +0100 Subject: [PATCH] Message when wrong number of poems displayed --- source/includes/comparison.html.jade | 2 ++ source/scripts/controllers/comparison.js.coffee | 17 +++++++++++++---- source/styles/style.css.styl | 8 ++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/source/includes/comparison.html.jade b/source/includes/comparison.html.jade index 7dbf8b3..5971937 100644 --- a/source/includes/comparison.html.jade +++ b/source/includes/comparison.html.jade @@ -9,6 +9,8 @@ .pick(ng-show="pick") .pick-in + div#too-few(ng-hide="! tooFew") There is no escape. + div#too-many(ng-hide="! tooMany") You can only compare five translations at the moment. Choose wisely. table tr th(ng-repeat="attribute in metaKeys" ng-bind-html="attribute") diff --git a/source/scripts/controllers/comparison.js.coffee b/source/scripts/controllers/comparison.js.coffee index b62b95a..53dee62 100644 --- a/source/scripts/controllers/comparison.js.coffee +++ b/source/scripts/controllers/comparison.js.coffee @@ -1,6 +1,6 @@ angular.module("sideBySide").controller "ComparisonController", -['$document', '$rootScope', '$scope', 'filter', 'load', 'poems', 'route', 'transformer' -($document, $rootScope, $scope, filter, load, poems, route, transformer) -> +['$document', '$rootScope', '$scope', '$timeout', 'filter', 'load', 'poems', 'route', 'transformer' +($document, $rootScope, $scope, $timeout, filter, load, poems, route, transformer) -> min = 1 max = 5 @@ -40,9 +40,18 @@ angular.module("sideBySide").controller "ComparisonController", $scope.switchActive = (poem) -> length = poems.getActive().length active = poem.meta.Active - if (length > min or not active) and (length < max or active) + + if (length <= min and active) + $scope.tooFew = true + $timeout((-> $scope.tooFew = false), 1000) + else if (length >= max and not active) + $scope.tooMany = true + $timeout((-> $scope.tooMany = false), 2500) + else poem.meta.Active = ! active - # TODO else notification + + $scope.tooFew = false + $scope.tooMany = false load( route.getBaseDir() diff --git a/source/styles/style.css.styl b/source/styles/style.css.styl index cc277c9..9f696d8 100644 --- a/source/styles/style.css.styl +++ b/source/styles/style.css.styl @@ -106,6 +106,14 @@ a a color: $neutral + #too-few, #too-many + color: #F66 + text-align: center + transition: .3s linear all + height: 36px + #too-few.ng-hide, #too-many.ng-hide + height: 0px + table margin: auto min-width: 50%