Skip to content

Commit 2ba990a

Browse files
committed
first commit
0 parents  commit 2ba990a

412 files changed

Lines changed: 6317 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<form name="myForm">
2+
<div class="control-group" ng-class="{error: myForm.name.$invalid}">
3+
<label>Name</label>
4+
<input type="text" name="name" ng-model="project.name" required>
5+
<span ng-show="myForm.name.$error.required" class="help-inline">
6+
Required</span>
7+
</div>
8+
9+
<div class="control-group" ng-class="{error: myForm.site.$invalid}">
10+
<label>Website</label>
11+
<input type="url" name="site" ng-model="project.site" required>
12+
<span ng-show="myForm.site.$error.required" class="help-inline">
13+
Required</span>
14+
<span ng-show="myForm.site.$error.url" class="help-inline">
15+
Not a URL</span>
16+
</div>
17+
18+
<label>Description</label>
19+
<textarea name="description" ng-model="project.description"></textarea>
20+
21+
<br>
22+
<a href="#/" class="btn">Cancel</a>
23+
<button ng-click="save()" ng-disabled="isClean() || myForm.$invalid"
24+
class="btn btn-primary">Save</button>
25+
<button ng-click="destroy()"
26+
ng-show="project.$id" class="btn btn-danger">Delete</button>
27+
</form>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<input type="text" ng-model="search" class="search-query" placeholder="Search">
2+
<table>
3+
<thead>
4+
<tr>
5+
<th>Project</th>
6+
<th>Description</th>
7+
<th><a href="#/new"><i class="icon-plus-sign"></i></a></th>
8+
</tr>
9+
</thead>
10+
<tbody>
11+
<tr ng-repeat="project in projects | filter:search | orderBy:'name'">
12+
<td><a href="{{project.site}}" target="_blank">{{project.name}}</a></td>
13+
<td>{{project.description}}</td>
14+
<td>
15+
<a href="#/edit/{{project.$id}}"><i class="icon-pencil"></i></a>
16+
</td>
17+
</tr>
18+
</tbody>
19+
</table>

angularjs/controllers/default.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
exports.install = function(framework) {
2+
framework.route('/', view_homepage);
3+
};
4+
5+
function view_homepage() {
6+
var self = this;
7+
self.view('homepage');
8+
}

angularjs/controllers/templates.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
exports.install = function(framework) {
2+
// all templates will be routed to contents/templates/*.html
3+
// EXAMPLE:
4+
// $routeProvider.when('/', { templateUrl: '/templates/products.html', controller: 'ProductsCtrl' });
5+
6+
// Documentation: http://docs.totaljs.com/Framework/#framework.file
7+
framework.file('Mapping: templates/*.html', file_template);
8+
};
9+
10+
function file_template(req, res, isValidation) {
11+
12+
// Documentation: http://docs.totaljs.com/Request.prototype/#request.path
13+
if (isValidation)
14+
return req.path[0] === 'templates' && (req.path[1] || '').indexOf('.html') !== -1;
15+
16+
var self = this;
17+
18+
// Documentation: http://docs.totaljs.com/Framework/#framework.responseFile
19+
self.responseFile(req, res, self.path.contents(req.path[0] + '/' + req.path[1]));
20+
}

angularjs/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var framework = require('total.js');
2+
var http = require('http');
3+
4+
var port = parseInt(process.argv[2] || '8000', 10);
5+
var debug = true;
6+
7+
framework.run(http, debug, port);

angularjs/public/css/default.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.done-true {
2+
text-decoration: line-through;
3+
color: gray;
4+
}

angularjs/public/js/project.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
angular.module('project', ['ngRoute', 'firebase']).
2+
value('fbURL', 'https://angularjs-projects.firebaseio.com/').
3+
factory('Projects', function(angularFireCollection, fbURL) {
4+
return angularFireCollection(fbURL);
5+
}).config(function($routeProvider) {
6+
$routeProvider.
7+
when('/', {controller:ListCtrl, templateUrl:'/templates/list.html'}).
8+
when('/edit/:projectId', {controller:EditCtrl, templateUrl:'/templates/detail.html'}).
9+
when('/new', {controller:CreateCtrl, templateUrl:'/templates/detail.html'}).
10+
otherwise({redirectTo:'/'});
11+
});
12+
13+
function ListCtrl($scope, Projects) {
14+
$scope.projects = Projects;
15+
}
16+
17+
function CreateCtrl($scope, $location, $timeout, Projects) {
18+
$scope.save = function() {
19+
Projects.add($scope.project, function() {
20+
$timeout(function() { $location.path('/'); });
21+
});
22+
};
23+
}
24+
25+
function EditCtrl($scope, $location, $routeParams, angularFire, fbURL) {
26+
angularFire(fbURL + $routeParams.projectId, $scope, 'remote', {}).then(function() {
27+
$scope.project = angular.copy($scope.remote);
28+
$scope.project.$id = $routeParams.projectId;
29+
$scope.isClean = function() {
30+
return angular.equals($scope.remote, $scope.project);
31+
};
32+
$scope.destroy = function() {
33+
$scope.remote = null;
34+
$location.path('/');
35+
};
36+
$scope.save = function() {
37+
$scope.remote = angular.copy($scope.project);
38+
$location.path('/');
39+
};
40+
});
41+
}

angularjs/views/homepage.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@{layout('')}
2+
@{meta('JavaScript projects')}
3+
<!doctype html>
4+
<html ng-app="project">
5+
<head>
6+
@{meta}
7+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.2/angular.min.js"></script>
8+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.2/angular-route.min.js"></script>
9+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.2/angular-resource.min.js"></script>
10+
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
11+
<script src="http://firebase.github.io/angularFire/angularFire.js"></script>
12+
@{js('project.js')}
13+
</head>
14+
<body>
15+
<h2>JavaScript Projects</h2>
16+
<div ng-view></div>
17+
</body>
18+
</html>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
exports.install = function(framework) {
2+
framework.route('/1/', test1);
3+
framework.route('/2/', test2);
4+
framework.route('/3/', test3);
5+
};
6+
7+
function test1() {
8+
this.plain('1');
9+
}
10+
11+
function test2() {
12+
/*
13+
if (this.isTest)
14+
console.log('IS TEST');
15+
*/
16+
this.plain('2');
17+
}
18+
19+
function test3() {
20+
// throw error
21+
this.plain('4');
22+
}

assertion-testing/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var framework = require('total.js');
2+
var http = require('http');
3+
4+
var port = 8004;
5+
var debug = true;
6+
7+
framework.run(http, debug, port);
8+
9+
// Documentation: http://docs.totaljs.com/Framework/#framework.test
10+
framework.test(true, function() {
11+
console.log('SUCCESSS');
12+
});

0 commit comments

Comments
 (0)