Commit 619fa800 authored by dgramlich's avatar dgramlich

angularjs: swapped out todo-blur for ng-blur

parent 43032485
......@@ -26,7 +26,7 @@
<button class="destroy" ng-click="removeTodo(todo)"></button>
</div>
<form ng-submit="doneEditing(todo)">
<input class="edit" ng-trim="false" ng-model="todo.title" todo-blur="doneEditing(todo)" todo-focus="todo == editedTodo">
<input class="edit" ng-trim="false" ng-model="todo.title" ng-blur="doneEditing(todo)" todo-focus="todo == editedTodo">
</form>
</li>
</ul>
......@@ -65,6 +65,5 @@
<script src="js/controllers/todoCtrl.js"></script>
<script src="js/services/todoStorage.js"></script>
<script src="js/directives/todoFocus.js"></script>
<script src="js/directives/todoBlur.js"></script>
</body>
</html>
/*global todomvc */
'use strict';
/**
* Directive that executes an expression when the element it is applied to loses focus
*/
todomvc.directive('todoBlur', function () {
return function (scope, elem, attrs) {
elem.bind('blur', function () {
scope.$apply(attrs.todoBlur);
});
};
});
......@@ -26,7 +26,7 @@
<button class="destroy" ng-click="removeTodo(todo)"></button>
</div>
<form ng-submit="doneEditing(todo)">
<input class="edit" ng-trim="false" ng-model="todo.title" todo-escape="revertEditing(todo)" todo-blur="doneEditing(todo)" todo-focus="todo == editedTodo">
<input class="edit" ng-trim="false" ng-model="todo.title" todo-escape="revertEditing(todo)" ng-blur="doneEditing(todo)" todo-focus="todo == editedTodo">
</form>
</li>
</ul>
......@@ -65,7 +65,6 @@
<script src="js/controllers/todoCtrl.js"></script>
<script src="js/services/todoStorage.js"></script>
<script src="js/directives/todoFocus.js"></script>
<script src="js/directives/todoBlur.js"></script>
<script src="js/directives/todoEscape.js"></script>
</body>
</html>
/*global todomvc */
'use strict';
/**
* Directive that executes an expression when the element it is applied to loses focus
*/
todomvc.directive('todoBlur', function () {
return function (scope, elem, attrs) {
elem.bind('blur', function () {
scope.$apply(attrs.todoBlur);
});
};
});
......@@ -4,32 +4,6 @@
beforeEach(module('todomvc'));
describe('todoBlur directive', function () {
var scope, compile;
beforeEach(inject(function ($rootScope, $compile) {
scope = $rootScope.$new();
compile = $compile;
}));
it('should $apply on blur', function () {
var el,
mock = {
called: false,
call: function () { this.called = true; }
};
scope.mock = mock;
el = angular.element('<input todo-blur="mock.call()">');
compile(el)(scope);
el.triggerHandler('blur');
scope.$digest();
expect(mock.called).toBeTruthy();
});
});
describe('todoFocus directive', function () {
var scope, compile, browser;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment