Skip to content
This repository has been archived by the owner on Aug 6, 2018. It is now read-only.

Commit

Permalink
Autofocus search field on browsing media in entry edit
Browse files Browse the repository at this point in the history
  • Loading branch information
nervetattoo committed Jan 12, 2015
1 parent 0d02150 commit 0f490f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions resources/mediaflow-ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ mediaflow.controller('MediaFlowCtrl', function ($scope, $http, $upload) {
}
});

mediaflow.directive('showFocus', ['$timeout', function($timeout) {
return function(scope, element, attrs) {
scope.$watch(attrs.showFocus, function(showing) {
$timeout(function() {
showing && element[0].focus();
});
}, true);
};
}]);

mediaflow.controller('MediaFlowFieldCtrl', function ($scope, $http, $upload) {
$scope.showMedia = false;
$scope.selected = false;
Expand Down
1 change: 1 addition & 0 deletions templates/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<div class="clearafter">
<div class="texticon search icon">
<input class="text nicetext"
show-focus="showMedia"
type="search"
autocomplete="off"
ng-model="searchText"
Expand Down

0 comments on commit 0f490f4

Please sign in to comment.