Commit 81897ce5 authored by dmitriz's avatar dmitriz

angularjs-perf: Wrap into anonymous functions

parent a960f9a4
/*global angular */ /*global angular */
/*jshint unused:false */ /*jshint unused:false */
'use strict'; (function () {
'use strict';
/** /**
* The main TodoMVC app module that pulls all dependency modules declared in same named files * The main TodoMVC app module that pulls all dependency modules declared in same named files
* *
* @type {angular.Module} * @type {angular.Module}
*/ */
angular.module('todomvc', ['todoCtrl', 'todoEscape', 'todoStorage']); angular.module('todomvc', ['todoCtrl', 'todoEscape', 'todoStorage']);
})();
/*global angular */ /*global angular */
'use strict'; (function () {
'use strict';
angular.module('todoCtrl', []) angular.module('todoCtrl', [])
/** /**
* The main controller for the app. The controller: * The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service * - retrieves and persists the model via the todoStorage service
* - exposes the model to the template and provides event handlers * - exposes the model to the template and provides event handlers
*/ */
.controller('TodoCtrl', function TodoCtrl($scope, $location, $filter, todoStorage) { .controller('TodoCtrl', function TodoCtrl($scope, $location, $filter, todoStorage) {
var todos = $scope.todos = todoStorage.get(); var todos = $scope.todos = todoStorage.get();
$scope.newTodo = ''; $scope.newTodo = '';
...@@ -92,4 +93,5 @@ angular.module('todoCtrl', []) ...@@ -92,4 +93,5 @@ angular.module('todoCtrl', [])
$scope.remainingCount = completed ? 0 : todos.length; $scope.remainingCount = completed ? 0 : todos.length;
todoStorage.put(todos); todoStorage.put(todos);
}; };
}); });
})();
/*global angular */ /*global angular */
'use strict'; (function () {
'use strict';
angular.module('todoEscape', []) angular.module('todoEscape', [])
/** /**
* Directive that executes an expression when the element it is applied to gets * Directive that executes an expression when the element it is applied to gets
* an `escape` keydown event. * an `escape` keydown event.
*/ */
.directive('todoEscape', function () { .directive('todoEscape', function () {
var ESCAPE_KEY = 27; var ESCAPE_KEY = 27;
return function (scope, elem, attrs) { return function (scope, elem, attrs) {
elem.bind('keydown', function (event) { elem.bind('keydown', function (event) {
...@@ -20,4 +21,5 @@ angular.module('todoEscape', []) ...@@ -20,4 +21,5 @@ angular.module('todoEscape', [])
elem.unbind('keydown'); elem.unbind('keydown');
}); });
}; };
}); });
})();
/*global angular */ /*global angular */
'use strict'; (function () {
'use strict';
angular.module('todoFocus', []) angular.module('todoFocus', [])
/** /**
* Directive that places focus on the element it is applied to when the expression it binds to evaluates to true * Directive that places focus on the element it is applied to when the expression it binds to evaluates to true
*/ */
.directive('todoFocus', function ($timeout) { .directive('todoFocus', function ($timeout) {
return function (scope, elem, attrs) { return function (scope, elem, attrs) {
scope.$watch(attrs.todoFocus, function (newVal) { scope.$watch(attrs.todoFocus, function (newVal) {
if (newVal) { if (newVal) {
...@@ -16,4 +17,5 @@ angular.module('todoFocus', []) ...@@ -16,4 +17,5 @@ angular.module('todoFocus', [])
} }
}); });
}; };
}); });
})();
/*global angular */ /*global angular */
'use strict'; (function () {
'use strict';
angular.module('todoStorage', []) angular.module('todoStorage', [])
/** /**
* Services that persists and retrieves TODOs from localStorage * Services that persists and retrieves TODOs from localStorage
*/ */
.factory('todoStorage', function () { .factory('todoStorage', function () {
var STORAGE_ID = 'todos-angularjs-perf'; var STORAGE_ID = 'todos-angularjs-perf';
return { return {
...@@ -18,4 +19,5 @@ angular.module('todoStorage', []) ...@@ -18,4 +19,5 @@ angular.module('todoStorage', [])
localStorage.setItem(STORAGE_ID, JSON.stringify(todos)); localStorage.setItem(STORAGE_ID, JSON.stringify(todos));
} }
}; };
}); });
})();
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