From a85e3919176617cc22deea5118a64d44072c9040 Mon Sep 17 00:00:00 2001 From: Athou Date: Fri, 17 May 2013 20:08:10 +0200 Subject: [PATCH] focus feed url input when modal opens --- src/main/webapp/js/directives.js | 16 ++++++++++++++++ src/main/webapp/templates/_subscribe.html | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index 49aa2842..56c2b736 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -1,5 +1,21 @@ var module = angular.module('commafeed.directives', []); +module.directive('focus', [ '$timeout', function($timeout) { + return { + restrict : 'A', + link : function(scope, element, attrs) { + scope.$watch(attrs.focus, function(value) { + if (!value) + return; + $timeout(function() { + $(element).focus(); + }); + }); + } + }; +} ]); + + /** * Open a popup window pointing to the url in the href attribute */ diff --git a/src/main/webapp/templates/_subscribe.html b/src/main/webapp/templates/_subscribe.html index 228f5cf9..910ee6d1 100644 --- a/src/main/webapp/templates/_subscribe.html +++ b/src/main/webapp/templates/_subscribe.html @@ -20,7 +20,7 @@
+ class="input-block-level" required ng-disabled="state=='loading'" focus="isOpen"> ${global.required}