Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

First test for pull request #451

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [{
"label": "Sass Compile",
"type": "shell",
"command": "node-sass app/app.scss app/app.css",
"group": "build"
}]
}
38 changes: 18 additions & 20 deletions app/app.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
/* app css stylesheet */
body {
background: #e48918d9 !important; }

.menu {
list-style: none;
border-bottom: 0.1em solid black;
margin-bottom: 2em;
padding: 0 0 0.5em;
}
.todoapp h1 {
color: rgba(39, 2, 2, 0.15) !important; }

.menu:before {
content: "[";
}
.item.ng-enter,
.item.ng-leave,
.record.ng-anchor {
transition: 0.5s ease; }

.menu:after {
content: "]";
}
.item.ng-enter {
transform: translateX(50px); }

.menu > li {
display: inline;
}
.item.ng-enter.ng-enter-active,
.item.ng-leave {
transform: translateX(0); }

.menu > li + li:before {
content: "|";
padding-right: 0.3em;
}
.item.ng-leave.ng-leave-active {
transform: translateX(50px); }

.info {
color: #000000; }
36 changes: 24 additions & 12 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
'use strict';

// Declare app level module which depends on views, and core components
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.version'
]).
config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');

$routeProvider.otherwise({redirectTo: '/view1'});
}]);
angular.module('todomvc', ['ngRoute', 'ngResource', 'ngAnimate'])

.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {
controller: 'TodoCtrl',
templateUrl: 'todomvc-index.html',
css: 'app.css',
resolve: {
store: function (todoStorage) {
return todoStorage.then(function (module) {
module.get();
return module;
});
}
}
})
.otherwise({
redirectTo: '/'
});
}])

.controller('TodoCtrl', [function () {

}]);
34 changes: 34 additions & 0 deletions app/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
$translateX : 50px;
$bg_color :#e48918d9;

body {
background: $bg_color !important;
}

.todoapp h1 {
color: rgba(39, 2, 2, 0.15) !important;
}


.item.ng-enter,
.item.ng-leave,
.record.ng-anchor {
transition: 0.5s ease;
}

.item.ng-enter {
transform: translateX($translateX);
}

.item.ng-enter.ng-enter-active,
.item.ng-leave {
transform: translateX(0);
}

.item.ng-leave.ng-leave-active {
transform: translateX($translateX);
}

.info {
color: #000000;
}
125 changes: 125 additions & 0 deletions app/controllers/todoCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*global angular */

/**
* The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service
* - exposes the model to the template and provides event handlers
*/
angular.module('todomvc')
.controller('TodoCtrl', function TodoCtrl($scope, $routeParams, $filter, store) {
'use strict';

var todos = $scope.todos = store.todos;

$scope.newTodo = '';
$scope.editedTodo = null;

$scope.$watch('todos', function () {
$scope.remainingCount = $filter('filter')(todos, { completed: false }).length;
$scope.completedCount = todos.length - $scope.remainingCount;
$scope.allChecked = !$scope.remainingCount;
}, true);

// Monitor the current route for changes and adjust the filter accordingly.
$scope.$on('$routeChangeSuccess', function () {
var status = $scope.status = $routeParams.status || '';
$scope.statusFilter = (status === 'active') ?
{ completed: false } : (status === 'completed') ?
{ completed: true } : {};
});

$scope.addTodo = function () {
var newTodo = {
title: $scope.newTodo.trim(),
completed: false
};

if (!newTodo.title) {
return;
}

$scope.saving = true;
store.insert(newTodo)
.then(function success() {
$scope.newTodo = '';
})
.finally(function () {
$scope.saving = false;
});
};

$scope.editTodo = function (todo) {
$scope.editedTodo = todo;
// Clone the original todo to restore it on demand.
$scope.originalTodo = angular.extend({}, todo);
};

$scope.saveEdits = function (todo, event) {
// Blur events are automatically triggered after the form submit event.
// This does some unfortunate logic handling to prevent saving twice.
if (event === 'blur' && $scope.saveEvent === 'submit') {
$scope.saveEvent = null;
return;
}

$scope.saveEvent = event;

if ($scope.reverted) {
// Todo edits were reverted-- don't save.
$scope.reverted = null;
return;
}

todo.title = todo.title.trim();

if (todo.title === $scope.originalTodo.title) {
$scope.editedTodo = null;
return;
}

store[todo.title ? 'put' : 'delete'](todo)
.then(function success() {}, function error() {
todo.title = $scope.originalTodo.title;
})
.finally(function () {
$scope.editedTodo = null;
});
};

$scope.revertEdits = function (todo) {
todos[todos.indexOf(todo)] = $scope.originalTodo;
$scope.editedTodo = null;
$scope.originalTodo = null;
$scope.reverted = true;
};

$scope.removeTodo = function (todo) {
store.delete(todo);
};

$scope.saveTodo = function (todo) {
store.put(todo);
};

$scope.toggleCompleted = function (todo, completed) {
if (angular.isDefined(completed)) {
todo.completed = completed;
}
store.put(todo, todos.indexOf(todo))
.then(function success() {}, function error() {
todo.completed = !todo.completed;
});
};

$scope.clearCompletedTodos = function () {
store.clearCompleted();
};

$scope.markAll = function (completed) {
todos.forEach(function (todo) {
if (todo.completed !== completed) {
$scope.toggleCompleted(todo, completed);
}
});
};
});
9 changes: 0 additions & 9 deletions app/core/version/interpolate-filter.js

This file was deleted.

15 changes: 0 additions & 15 deletions app/core/version/interpolate-filter.spec.js

This file was deleted.

9 changes: 0 additions & 9 deletions app/core/version/version-directive.js

This file was deleted.

17 changes: 0 additions & 17 deletions app/core/version/version-directive.spec.js

This file was deleted.

8 changes: 0 additions & 8 deletions app/core/version/version.js

This file was deleted.

11 changes: 0 additions & 11 deletions app/core/version/version.spec.js

This file was deleted.

24 changes: 24 additions & 0 deletions app/directives/todoEscape.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*global angular */

/**
* Directive that executes an expression when the element it is applied to gets
* an `escape` keydown event.
*/
angular.module('todomvc')
.directive('todoEscape', function () {
'use strict';

var ESCAPE_KEY = 27;

return function (scope, elem, attrs) {
elem.bind('keydown', function (event) {
if (event.keyCode === ESCAPE_KEY) {
scope.$apply(attrs.todoEscape);
}
});

scope.$on('$destroy', function () {
elem.unbind('keydown');
});
};
});
20 changes: 20 additions & 0 deletions app/directives/todoFocus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*global angular */

/**
* Directive that places focus on the element it is applied to when the
* expression it binds to evaluates to true
*/
angular.module('todomvc')
.directive('todoFocus', function todoFocus($timeout) {
'use strict';

return function (scope, elem, attrs) {
scope.$watch(attrs.todoFocus, function (newVal) {
if (newVal) {
$timeout(function () {
elem[0].focus();
}, 0, false);
}
});
};
});
Loading