From 6f9e00339fa42feffeff84edcaa656d451140058 Mon Sep 17 00:00:00 2001 From: Athou Date: Wed, 1 May 2013 15:14:43 +0200 Subject: [PATCH] smarter subscription dialog --- src/main/webapp/js/controllers.js | 15 ++++++++++++--- src/main/webapp/templates/_subscribe.html | 8 +++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index d7d40525..c319a1f9 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -41,20 +41,29 @@ function($scope, FeedService, CategoryService) { $scope.isOpen = false; }; + // 'ok', 'loading' or 'failed' + $scope.state = 'ok'; $scope.urlChanged = function() { - var msg = 'Loading...'; - if ($scope.sub.url && (!$scope.sub.title || $scope.sub.title == msg)) { - $scope.sub.title = msg; + if ($scope.sub.url) { + $scope.state = 'loading'; + $scope.sub.title = 'Loading...'; FeedService.fetch({ url : $scope.sub.url }, function(data) { + $scope.state = 'ok'; $scope.sub.title = data.title; $scope.sub.url = data.url; + }, function(data) { + $scope.state = 'failed'; + $scope.sub.title = 'Loading failed. Invalid feed?'; }); } }; $scope.save = function() { + if ($scope.state != 'ok') { + return; + } if (!$scope.sub.categoryId) { return; } diff --git a/src/main/webapp/templates/_subscribe.html b/src/main/webapp/templates/_subscribe.html index c8989b82..dee645c6 100644 --- a/src/main/webapp/templates/_subscribe.html +++ b/src/main/webapp/templates/_subscribe.html @@ -19,14 +19,16 @@
- + Required
- + Required
@@ -42,7 +44,7 @@