focus feed url input when modal opens

This commit is contained in:
Athou
2013-05-17 20:08:10 +02:00
parent e1d7bc63bc
commit a85e391917
2 changed files with 17 additions and 1 deletions

View File

@@ -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
*/

View File

@@ -20,7 +20,7 @@
<label class="control-label">${subscribe.feed_url}</label>
<div class="controls">
<input type="text" name="url" ng-model="sub.url" ng-blur="urlChanged()" placeholder="http://example.com/feed"
class="input-block-level" required ng-disabled="state=='loading'"></input>
class="input-block-level" required ng-disabled="state=='loading'" focus="isOpen"></input>
<span class="help-block" ng-show="!subscribeForm.url.$valid">${global.required}</span>
</div>
</div>