Skip to content

Commit

Permalink
using namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryB432 committed Aug 9, 2015
1 parent 32383b4 commit d43aa6b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion source/jade/templates/states/main.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ div
div.a1
h2 Current
div(data-homer-loca-directive="",data-address="current")
div.distance {{distance | distanceFilter:'miles' | number:3}}
div.distance {{distance | distanceFilter:'miles' | number:3}} miles
button#setCurrent(ng-click="setCurrent()") Set Current
div.a2
img#map(ng-src="{{mapUrl}}")
Expand Down
12 changes: 7 additions & 5 deletions source/js/controllers/about.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
interface AboutScope extends ng.IScope{
awesomeThings: string[]
}
namespace HomerWeb {
interface AboutScope extends ng.IScope {
awesomeThings: string[]
}

App.controller('AboutCtrl', function ($scope: AboutScope, $routeParams: ng.route.IRouteParamsService) {
App.controller('AboutCtrl', function($scope: AboutScope, $routeParams: ng.route.IRouteParamsService) {
$scope.awesomeThings = [
'Lorem',
'Ipsum',
'Dolar',
'Sit Amet'
];
});
});
}
4 changes: 2 additions & 2 deletions source/js/controllers/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HomerWeb {
namespace HomerWeb {
interface Scope extends ng.IScope {
home: ILoca;
current: ILoca;
Expand Down Expand Up @@ -41,4 +41,4 @@ module HomerWeb {
}

App.controller('HomerHomeCtrl', ['$scope', 'homerService', HomerHomeCtrl]);
}
}
4 changes: 2 additions & 2 deletions source/js/directives/address-detail.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HomerWeb {
namespace HomerWeb {
interface Scope extends ng.IScope, ILoca {
name: string;
}
Expand Down Expand Up @@ -27,4 +27,4 @@ module HomerWeb {
};
return directiveDefinitionObject;
});
}
}
16 changes: 9 additions & 7 deletions source/js/filters/distance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module HomerWeb {

This comment has been minimized.

Copy link
@GaryB432

GaryB432 Aug 10, 2015

Author Owner
console.log(App);

App.filter('distanceFilter', function () {
return function (meters: number, a: string) {
return (meters * 0.000621371192237);
};
});
function translateMeters(meters: number, unit: string) {
switch (unit) {
case 'miles':
return meters * 0.000621371192237
default:
throw new Error(`${unit} is an unknown unit`);
}
}
App.filter('distanceFilter', () => translateMeters);
}
4 changes: 2 additions & 2 deletions source/js/services/google.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module GoogleGeocoding {
namespace GoogleGeocoding {
export class GeoCoder {
static computeDistanceBetween(from: Coordinates, to: Coordinates, radius?: number) {
return google.maps.geometry.spherical.computeDistanceBetween(
Expand All @@ -24,7 +24,7 @@ module GoogleGeocoding {
}
}

module GoogleMapping {
namespace GoogleMapping {
export class DynamicMap {
map: google.maps.Map;
constructor(mapDiv: Element, opts?: google.maps.MapOptions) {
Expand Down
2 changes: 1 addition & 1 deletion source/js/services/homer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HomerWeb {
namespace HomerWeb {
interface VenessGeo {
// www.movable-type.co.uk/scripts/latlong.html
parseDMS(dms: string): number;
Expand Down

0 comments on commit d43aa6b

Please sign in to comment.