Skip to content
This repository was archived by the owner on Jul 31, 2019. It is now read-only.

Commit f26320e

Browse files
committed
initial commit with grunt, bower, karma
1 parent f112450 commit f26320e

18 files changed

+20524
-2
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
TODO

Gruntfile.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
module.exports = function(grunt) {
4+
grunt.initConfig({
5+
pkg: grunt.file.readJSON('package.json'),
6+
jshint: {
7+
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
8+
options: {
9+
// options here to override JSHint defaults
10+
globalstrict: true,
11+
globals: {
12+
jQuery: true,
13+
console: true,
14+
module: true,
15+
document: true,
16+
expect: true,
17+
it: true,
18+
spyOn: true,
19+
beforeEach: true,
20+
angular: true,
21+
inject: true,
22+
describe: true
23+
}
24+
}
25+
},
26+
uglify: {
27+
options: {
28+
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
29+
},
30+
dist: {
31+
files: {
32+
'dist/<%= pkg.name %>.min.js': 'src/geolocation.js'
33+
}
34+
}
35+
},
36+
karma: {
37+
unit: {
38+
configFile: 'karma.conf.js'
39+
}
40+
}
41+
});
42+
43+
grunt.loadNpmTasks('grunt-contrib-jshint');
44+
grunt.loadNpmTasks('grunt-contrib-uglify');
45+
grunt.loadNpmTasks('grunt-karma');
46+
grunt.registerTask('default', ['jshint', 'karma','uglify']);
47+
};

README.md

+60-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,62 @@
1-
angularjs-geolocation
2-
=====================
1+
AngularJS-Geolocation
2+
=========
33

44
An angular.js wrapper around window.navigator.geolocation
5+
6+
Bower
7+
--
8+
This module is available as bower package, install it with this command:
9+
10+
```bash
11+
bower install angularjs-geolocation
12+
```
13+
or
14+
15+
```bash
16+
bower install git://github.com/arunisrael/angularjs-geolocation.git
17+
```
18+
19+
Usage
20+
--
21+
- Add the geolocation module as dependency
22+
- Inject the geolocation service (yes, it has the same name)
23+
- Invoke the getLocation method on the geolocation service to retrieve a promise
24+
- The promise will be resolved with the position returned by window.navigator.getCurrentPosition if the user allows the browser to access their location
25+
- The promise will be rejected if the user rejects location access or the browser does not support it
26+
27+
Example
28+
--
29+
```
30+
angular.module('myApp',['geolocation'])
31+
.controller('mainCtrl', function ($scope,geolocation) {
32+
$scope.coords = geolocation.getLocation().then(function(data){
33+
return {lat:data.coords.latitude, long:data.coords.longitude};
34+
});
35+
});
36+
```
37+
38+
Demo
39+
--
40+
See this [plunker](http://embed.plnkr.co/TM71LBh6ttYotOo6t7oX/preview) that displays your latitude/longitude
41+
42+
Error Handling
43+
--
44+
The geolocation module defines a geolocation-msgs constant holding error msgs that are broadcast if the user rejects location access:
45+
```
46+
$rootScope.$broadcast('error',CONSTANTS['errors.location.notFound']);
47+
```
48+
49+
or if the browser does not support geolocation:
50+
```
51+
$rootScope.$broadcast('error',geolocation_msgs['errors.location.unsupportedBrowser']);
52+
```
53+
54+
Testing
55+
--
56+
```
57+
grunt test
58+
```
59+
60+
License
61+
--
62+
MIT

bower.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "angularjs-geolocation",
3+
"version": "0.1.0",
4+
"homepage": "https://github.com/arunisrael/angularjs-geolocation",
5+
"authors": [
6+
"Arun Israel <[email protected]>"
7+
],
8+
"description": "An angular.js wrapper around window.navigator.geolocation",
9+
"main": "geolocation.js",
10+
"keywords": [
11+
"geolocation",
12+
"angular.js"
13+
],
14+
"license": "MIT",
15+
"ignore": [
16+
"**/.*",
17+
"node_modules",
18+
"bower_components",
19+
"test",
20+
"tests"
21+
],
22+
"dependencies": {
23+
"angular": "~1.x"
24+
},
25+
"devDependencies": {
26+
"angular-mocks": "~1.x"
27+
}
28+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "angular-mocks",
3+
"version": "1.2.0-rc.2",
4+
"main": "./angular-mocks.js",
5+
"dependencies": {
6+
"angular": "1.2.0-rc.2"
7+
},
8+
"homepage": "https://github.com/angular/bower-angular-mocks",
9+
"_release": "1.2.0-rc.2",
10+
"_resolution": {
11+
"type": "version",
12+
"tag": "v1.2.0-rc.2",
13+
"commit": "9bdf39463a7e59c35f4f6163853c8da4fbf81ea3"
14+
},
15+
"_source": "git://github.com/angular/bower-angular-mocks.git",
16+
"_target": "~1.x",
17+
"_originalSource": "angular-mocks"
18+
}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bower-angular-mocks
2+
===================
3+
4+
angular-mocks.js bower repo

0 commit comments

Comments
 (0)