Skip to content

Commit

Permalink
Lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Sullivan committed Dec 25, 2014
1 parent a186f08 commit 836aa66
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"node": true,
"browser": true,
"es5": true,
"es5": false,
"esnext": true,
"bitwise": true,
"camelcase": true,
Expand Down
26 changes: 18 additions & 8 deletions dist/angular-mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@
var style = setStyleOptions(attrs);
var marker;

function setStyleOptions(attrs, default_opts) {
var opts = default_opts || {};
function setStyleOptions(attrs, defaultOpts) {
var opts = defaultOpts || {};
if(attrs.size) {
opts['marker-size'] = attrs.size;
}
Expand All @@ -250,7 +250,9 @@
opts = opts || {};

var marker = L.mapbox.marker.style({ properties: style }, latlng);
if(popupContent && popupContent.length > 0) marker.bindPopup(popupContent);
if(popupContent && popupContent.length > 0) {
marker.bindPopup(popupContent);
}

if(controller.$scope.isClusteringMarkers && opts.excludeFromClustering !== true) {
controller.$scope.clusterGroup.addLayer(marker);
Expand All @@ -260,7 +262,9 @@

// this needs to come after being added to map because the L.mapbox.marker.style() factory
// does not let us pass other opts (eg, draggable) in
if(opts.draggable) marker.dragging.enable();
if(opts.draggable) {
marker.dragging.enable();
}

mapboxService.addMarker(marker);
//mapboxService.fitMapToMarkers(map); // TODO: debounce this
Expand All @@ -280,19 +284,23 @@
};

controller.getMap().then(function(map) {
map.on('popupopen', function(e) {
map.on('popupopen', function() {
// ensure that popups are compiled
var popup = angular.element(document.getElementsByClassName('leaflet-popup-content'));
$compile(popup)(scope);
if(!scope.$$phase) scope.$digest();
if(!scope.$$phase) {
scope.$digest();
}
});

setTimeout(function() {
// there's got to be a better way to programmatically access transcluded content
var popupHTML = '';
var transcluded = transclude(scope, function() {});
for(var i = 0; i < transcluded.length; i++) {
if(transcluded[i].outerHTML !== undefined) popupHTML += transcluded[i].outerHTML;
if(transcluded[i].outerHTML !== undefined) {
popupHTML += transcluded[i].outerHTML;
}
}

if(attrs.currentLocation !== undefined) {
Expand All @@ -301,7 +309,9 @@
if(popupHTML) {
var popup = angular.element(popupHTML);
$compile(popup)(scope);
if(!scope.$$phase) scope.$digest();
if(!scope.$$phase) {
scope.$digest();
}

var newPopupHTML = '';
for(i = 0; i < popup.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-mapbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions examples/example-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

var angularMapboxExample = angular.module('angular-mapbox-example', ['angular-mapbox']);

angularMapboxExample.controller('demoController', function($scope, mapboxService) {
angularMapboxExample.controller('demoController', function($scope, $timeout, mapboxService) {
mapboxService.init({ accessToken: 'pk.eyJ1IjoibGljeWV1cyIsImEiOiJuZ1gtOWtjIn0.qaaGvywaJ_kCmwmlTSNyVw' });
$timeout(function() {
var map = mapboxService.getMapInstances()[0];
//mapboxService.fitMapToMarkers(map);
}, 100);

$scope.farmersMarkets = [
{
Expand Down Expand Up @@ -82,7 +86,7 @@

$scope.mapZoomedCallback = function(bounds) {
console.log('You zoomed the map to:');
console.log(bounds);
console.log(bounds.getCenter().toString());
};
});

Expand Down
13 changes: 11 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
<link rel="stylesheet" href="lib/MarkerCluster.Default.css">
</head>
<body ng-app="angular-mapbox-example" ng-controller="demoController">
<mapbox map-id="licyeus.i9pkgkg8"
<input type="text" ng-model="status">
{{ status }}
<mapbox map-id="licyeus.XXXi9pkgkg8"
lat="47.643569"
lng="-122.329453"
on-reposition="mapMovedCallback"
on-zoom="mapZoomedCallback">
on-zoom="mapZoomedCallback"
zoom="12" scale-to-fit>

<marker lat="47.643569" lng="-122.329453" color="blue" icon="zoo">
<h1>status: {{ status }}</h1>
{{ farmersMarkets[0] | json}}
</marker>

<marker ng-repeat="market in farmersMarkets | filter: filterTerm"
lat="{{market.coords.lat}}"
lng="{{market.coords.lng}}"
Expand Down
26 changes: 18 additions & 8 deletions src/directives/marker.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
var style = setStyleOptions(attrs);
var marker;

function setStyleOptions(attrs, default_opts) {
var opts = default_opts || {};
function setStyleOptions(attrs, defaultOpts) {
var opts = defaultOpts || {};
if(attrs.size) {
opts['marker-size'] = attrs.size;
}
Expand All @@ -54,7 +54,9 @@
opts = opts || {};

var marker = L.mapbox.marker.style({ properties: style }, latlng);
if(popupContent && popupContent.length > 0) marker.bindPopup(popupContent);
if(popupContent && popupContent.length > 0) {
marker.bindPopup(popupContent);
}

if(controller.$scope.isClusteringMarkers && opts.excludeFromClustering !== true) {
controller.$scope.clusterGroup.addLayer(marker);
Expand All @@ -64,7 +66,9 @@

// this needs to come after being added to map because the L.mapbox.marker.style() factory
// does not let us pass other opts (eg, draggable) in
if(opts.draggable) marker.dragging.enable();
if(opts.draggable) {
marker.dragging.enable();
}

mapboxService.addMarker(marker);
//mapboxService.fitMapToMarkers(map); // TODO: debounce this
Expand All @@ -84,19 +88,23 @@
};

controller.getMap().then(function(map) {
map.on('popupopen', function(e) {
map.on('popupopen', function() {
// ensure that popups are compiled
var popup = angular.element(document.getElementsByClassName('leaflet-popup-content'));
$compile(popup)(scope);
if(!scope.$$phase) scope.$digest();
if(!scope.$$phase) {
scope.$digest();
}
});

setTimeout(function() {
// there's got to be a better way to programmatically access transcluded content
var popupHTML = '';
var transcluded = transclude(scope, function() {});
for(var i = 0; i < transcluded.length; i++) {
if(transcluded[i].outerHTML !== undefined) popupHTML += transcluded[i].outerHTML;
if(transcluded[i].outerHTML !== undefined) {
popupHTML += transcluded[i].outerHTML;
}
}

if(attrs.currentLocation !== undefined) {
Expand All @@ -105,7 +113,9 @@
if(popupHTML) {
var popup = angular.element(popupHTML);
$compile(popup)(scope);
if(!scope.$$phase) scope.$digest();
if(!scope.$$phase) {
scope.$digest();
}

var newPopupHTML = '';
for(i = 0; i < popup.length; i++) {
Expand Down

0 comments on commit 836aa66

Please sign in to comment.