Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit c9cf276

Browse files
committed
Merge branch 'master' of https://github.com/joshschumacher/angularFire into joshschumacher-master
2 parents c1bd781 + 2b2eb78 commit c9cf276

File tree

10 files changed

+157
-32
lines changed

10 files changed

+157
-32
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.jshintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"bitwise" : true,
3+
"boss" : true,
4+
"browser" : true,
5+
"curly" : true,
6+
"devel" : true,
7+
"eqnull" : true,
8+
"globals" : {
9+
"angular" : false,
10+
"Firebase" : false,
11+
"FirebaseSimpleLogin" : false
12+
},
13+
"globalstrict" : true,
14+
"indent" : 2,
15+
"latedef" : true,
16+
"maxlen" : 115,
17+
"noempty" : true,
18+
"nonstandard" : true,
19+
"undef" : true,
20+
"unused" : true,
21+
"trailing" : true
22+
}

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
language: node_js
22
node_js:
3-
- 0.8
3+
- 0.10
44
branches:
55
only:
66
- master
7-
before_install:
7+
install:
88
- git clone git://github.com/n1k0/casperjs.git ~/casperjs
99
- export PATH=$PATH:~/casperjs/bin
10-
- npm install -g uglify-js
10+
- npm install -g grunt-cli
11+
- npm install
1112
before_script:
1213
- phantomjs --version
1314
- casperjs --version
1415
script:
15-
- make test
16+
- grunt

Gruntfile.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* global module */
2+
3+
module.exports = function(grunt) {
4+
'use strict';
5+
6+
grunt.initConfig({
7+
exec: {
8+
casperjs : {
9+
command : 'casperjs test tests/'
10+
}
11+
},
12+
13+
uglify : {
14+
app : {
15+
files : {
16+
'angularfire.min.js' : ['angularFire.js']
17+
}
18+
}
19+
},
20+
21+
jshint : {
22+
options : {
23+
'bitwise' : true,
24+
'boss' : true,
25+
'browser' : true,
26+
'curly' : true,
27+
'devel' : true,
28+
'eqnull' : true,
29+
'globals' : {
30+
'angular' : false,
31+
'Firebase' : false,
32+
'FirebaseSimpleLogin' : false
33+
},
34+
'globalstrict' : true,
35+
'indent' : 2,
36+
'latedef' : true,
37+
'maxlen' : 115,
38+
'noempty' : true,
39+
'nonstandard' : true,
40+
'undef' : true,
41+
'unused' : true,
42+
'trailing' : true
43+
},
44+
all : ['angularFire.js']
45+
},
46+
47+
watch : {
48+
scripts : {
49+
files : 'angularFire.js',
50+
tasks : ['default', 'notify:watch'],
51+
options : {
52+
interrupt : true
53+
}
54+
}
55+
},
56+
57+
notify: {
58+
watch: {
59+
options: {
60+
title: 'Grunt Watch',
61+
message: 'Build Finished'
62+
}
63+
}
64+
}
65+
66+
});
67+
68+
grunt.loadNpmTasks('grunt-contrib-uglify');
69+
grunt.loadNpmTasks('grunt-contrib-jshint');
70+
grunt.loadNpmTasks('grunt-exec');
71+
grunt.loadNpmTasks('grunt-contrib-watch');
72+
grunt.loadNpmTasks('grunt-notify');
73+
74+
grunt.registerTask('build', ['jshint', 'uglify']);
75+
grunt.registerTask('test', ['exec:casperjs']);
76+
77+
grunt.registerTask('default', ['build', 'test']);
78+
};

Makefile

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,28 @@ Development
1414
[![Build Status](https://travis-ci.org/firebase/angularFire.png)](https://travis-ci.org/firebase/angularFire)
1515

1616
If you'd like to hack on AngularFire itself, you'll need
17-
[UglifyJS](https://github.com/mishoo/UglifyJS2) and
17+
[node.js](http://nodejs.org/download/) and
1818
[CasperJS](https://github.com/n1k0/casperjs):
1919

2020
```bash
21-
npm install uglify-js -g
2221
brew install casperjs
22+
npm install
2323
```
2424

25-
A Makefile is included for your convenience:
25+
Use grunt to build and test the code:
2626

2727
```bash
28+
# Default task - validates with jshint, minifies source and then runs unit tests
29+
grunt
30+
31+
# Watch for changes and run unit test after each change
32+
grunt watch
33+
2834
# Run tests
29-
make test
35+
grunt test
36+
3037
# Minify source
31-
make minify
38+
grunt build
3239
```
3340

3441
License

angularFire.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
"use strict";
1313

14+
var AngularFire;
15+
1416
// Define the `firebase` module under which all AngularFire services will live.
1517
angular.module("firebase", []).value("Firebase", Firebase);
1618

@@ -33,7 +35,7 @@ angular.module("firebase").factory("angularFire", ["$q", "$parse", "$timeout",
3335
]);
3436

3537
// The `AngularFire` object that implements implicit synchronization.
36-
function AngularFire($q, $parse, $timeout, ref) {
38+
AngularFire = function($q, $parse, $timeout, ref) {
3739
this._q = $q;
3840
this._parse = $parse;
3941
this._timeout = $timeout;
@@ -45,7 +47,8 @@ function AngularFire($q, $parse, $timeout, ref) {
4547
"of a URL, eg: new Firebase(url)");
4648
}
4749
this._fRef = ref;
48-
}
50+
};
51+
4952
AngularFire.prototype = {
5053
// This function is called by the factory to create a new 2-way binding
5154
// between a particular model in a `$scope` and a particular Firebase
@@ -102,7 +105,7 @@ AngularFire.prototype = {
102105

103106
// Update the local model to reflect remote changes.
104107
self._timeout(function() {
105-
self._resolve($scope, name, resolve, remote)
108+
self._resolve($scope, name, resolve, remote);
106109
});
107110
});
108111
return promise;
@@ -202,12 +205,12 @@ angular.module("firebase").factory("angularFireCollection", ["$timeout",
202205
}
203206

204207
// An internal representation of a model present in the collection.
205-
function angularFireItem(ref, index) {
208+
var AngularFireItem = function(ref, index) {
206209
this.$ref = ref.ref();
207210
this.$id = ref.name();
208211
this.$index = index;
209212
angular.extend(this, {$priority: ref.getPriority()}, ref.val());
210-
}
213+
};
211214

212215
// Implementation of firebase priority ordering:
213216
// https://www.firebase.com/docs/javascript/firebase/setpriority.html
@@ -290,7 +293,7 @@ angular.module("firebase").factory("angularFireCollection", ["$timeout",
290293
collectionRef.on("child_added", function(data, prevId) {
291294
$timeout(function() {
292295
var index = getIndex(prevId);
293-
addChild(index, new angularFireItem(data, index));
296+
addChild(index, new AngularFireItem(data, index));
294297
updateIndexes(index);
295298
});
296299
});
@@ -308,7 +311,7 @@ angular.module("firebase").factory("angularFireCollection", ["$timeout",
308311
$timeout(function() {
309312
var index = indexes[data.name()];
310313
var newIndex = getIndex(prevId);
311-
var item = new angularFireItem(data, index);
314+
var item = new AngularFireItem(data, index);
312315

313316
updateChild(index, item);
314317
if (newIndex !== index) {
@@ -386,15 +389,15 @@ angular.module("firebase").factory("angularFireCollection", ["$timeout",
386389

387390
collection.order = firebaseOrder;
388391
return collection;
389-
}
392+
};
390393
}
391394
]);
392395

393396
// Defines the `angularFireAuth` service that provides authentication support
394397
// for AngularFire.
395398
angular.module("firebase").factory("angularFireAuth", [
396-
"$rootScope", "$parse", "$timeout", "$location", "$route", "$q",
397-
function($rootScope, $parse, $timeout, $location, $route, $q) {
399+
"$rootScope", "$parse", "$timeout", "$location", "$route", "$q",
400+
function($rootScope, $parse, $timeout, $location, $route, $q) {
398401

399402
// Helper function to extract claims from a JWT. Does *not* verify the
400403
// validity of the token.
@@ -509,7 +512,7 @@ angular.module("firebase").factory("angularFireAuth", [
509512
if (err) {
510513
$rootScope.$broadcast("angularFireAuth:error", err);
511514
} else if (user) {
512-
self._loggedIn(user)
515+
self._loggedIn(user);
513516
} else {
514517
self._loggedOut();
515518
}
@@ -549,7 +552,7 @@ angular.module("firebase").factory("angularFireAuth", [
549552
}
550553
});
551554
} catch(e) {
552-
$rootScope.$broadcast("angularFireAuth:error", e)
555+
$rootScope.$broadcast("angularFireAuth:error", e);
553556
}
554557
}
555558
return promise;
@@ -638,6 +641,6 @@ angular.module("firebase").factory("angularFireAuth", [
638641
}));
639642
return def.promise;
640643
}
641-
}
644+
};
642645
}
643646
]);

0 commit comments

Comments
 (0)