Skip to content

Commit

Permalink
Move changes to src and build
Browse files Browse the repository at this point in the history
  • Loading branch information
furstenheim committed Feb 15, 2017
1 parent 3608463 commit b8f4d44
Show file tree
Hide file tree
Showing 78 changed files with 2,074 additions and 2,066 deletions.
963 changes: 481 additions & 482 deletions dist/angular-leaflet-directive.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/angular-leaflet-directive.min.js

Large diffs are not rendered by default.

965 changes: 484 additions & 481 deletions dist/angular-leaflet-directive.no-header.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"devDependencies": {
"grunt": "^0.4.5",
"grunt-bower-task": "^0.4.0",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-connect": "^0.11.2",
Expand Down Expand Up @@ -52,7 +53,8 @@
"test": "grunt travis --verbose",
"karmaChrome": "grunt test-unit-chrome",
"karmaChromeOnce": "grunt karma:unit-chrome-once",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"build": "grunt --force"
},
"main": "dist/angular-leaflet-directive",
"dependencies": {
Expand Down
22 changes: 11 additions & 11 deletions src/directives/bounds.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
angular.module('leaflet-directive').directive('bounds', function($log, $timeout, $http, leafletHelpers, nominatimService, leafletBoundsHelpers) {
angular.module('leaflet-directive').directive('bounds', function ($log, $timeout, $http, leafletHelpers, nominatimService, leafletBoundsHelpers) {

return {
restrict: 'A',
scope: false,
replace: false,
require: ['leaflet'],

link: function(scope, element, attrs, controller) {
link: function (scope, element, attrs, controller) {
var isDefined = leafletHelpers.isDefined;
var createLeafletBounds = leafletBoundsHelpers.createLeafletBounds;
var leafletScope = controller[0].getLeafletScope();
var mapController = controller[0];
var errorHeader = leafletHelpers.errorHeader + ' [Bounds] ';

var emptyBounds = function(bounds) {
var emptyBounds = function (bounds) {
return (bounds._southWest.lat === 0 && bounds._southWest.lng === 0 &&
bounds._northEast.lat === 0 && bounds._northEast.lng === 0);
};

mapController.getMap().then(function(map) {
leafletScope.$on('boundsChanged', function(event) {
mapController.getMap().then(function (map) {
leafletScope.$on('boundsChanged', function (event) {
var scope = event.currentScope;
var bounds = map.getBounds();

Expand All @@ -43,28 +43,28 @@ angular.module('leaflet-directive').directive('bounds', function($log, $timeout,
scope.bounds = newScopeBounds;
}

$timeout(function() {
$timeout(function () {
scope.settingBoundsFromLeaflet = false;
});
});

var lastNominatimQuery;
leafletScope.$watch('bounds', function(bounds) {
leafletScope.$watch('bounds', function (bounds) {
if (scope.settingBoundsFromLeaflet)
return;
if (isDefined(bounds.address) && bounds.address !== lastNominatimQuery) {
scope.settingBoundsFromScope = true;
nominatimService.query(bounds.address, attrs.id).then(function(data) {
nominatimService.query(bounds.address, attrs.id).then(function (data) {
var b = data.boundingbox;
var newBounds = [[b[0], b[2]], [b[1], b[3]]];
map.fitBounds(newBounds);
}, function(errMsg) {
}, function (errMsg) {

$log.error(errorHeader + ' ' + errMsg + '.');
});

lastNominatimQuery = bounds.address;
$timeout(function() {
$timeout(function () {
scope.settingBoundsFromScope = false;
});

Expand All @@ -75,7 +75,7 @@ angular.module('leaflet-directive').directive('bounds', function($log, $timeout,
if (leafletBounds && !map.getBounds().equals(leafletBounds)) {
scope.settingBoundsFromScope = true;
map.fitBounds(leafletBounds, bounds.options);
$timeout(function() {
$timeout(function () {
scope.settingBoundsFromScope = false;
});
}
Expand Down
38 changes: 19 additions & 19 deletions src/directives/center.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var centerDirectiveTypes = ['center', 'lfCenter'];
var centerDirectives = {};

centerDirectiveTypes.forEach(function(directiveName) {
centerDirectiveTypes.forEach(function (directiveName) {
centerDirectives[directiveName] = ['$log', '$q', '$location', '$timeout', 'leafletMapDefaults', 'leafletHelpers',
'leafletBoundsHelpers', 'leafletMapEvents',
function($log, $q, $location, $timeout, leafletMapDefaults, leafletHelpers,
function ($log, $q, $location, $timeout, leafletMapDefaults, leafletHelpers,
leafletBoundsHelpers, leafletMapEvents) {

var isDefined = leafletHelpers.isDefined;
Expand All @@ -16,7 +16,7 @@ centerDirectiveTypes.forEach(function(directiveName) {
var isUndefinedOrEmpty = leafletHelpers.isUndefinedOrEmpty;
var errorHeader = leafletHelpers.errorHeader;

var shouldInitializeMapWithBounds = function(bounds, center) {
var shouldInitializeMapWithBounds = function (bounds, center) {
return isDefined(bounds) && isValidBounds(bounds) && isUndefinedOrEmpty(center);
};

Expand All @@ -26,18 +26,18 @@ centerDirectiveTypes.forEach(function(directiveName) {
scope: false,
replace: false,
require: 'leaflet',
controller: function() {
controller: function () {
_leafletCenter = $q.defer();
this.getCenter = function() {
this.getCenter = function () {
return _leafletCenter.promise;
};
},

link: function(scope, element, attrs, controller) {
link: function (scope, element, attrs, controller) {
var leafletScope = controller.getLeafletScope();
var centerModel = leafletScope[directiveName];

controller.getMap().then(function(map) {
controller.getMap().then(function (map) {
var defaults = leafletMapDefaults.getDefaults(attrs.id);

if (attrs[directiveName].search('-') !== -1) {
Expand All @@ -47,7 +47,7 @@ centerDirectiveTypes.forEach(function(directiveName) {
} else if (shouldInitializeMapWithBounds(leafletScope.bounds, centerModel)) {
map.fitBounds(leafletBoundsHelpers.createLeafletBounds(leafletScope.bounds), leafletScope.bounds.options);
centerModel = map.getCenter();
safeApply(leafletScope, function(scope) {
safeApply(leafletScope, function (scope) {
angular.extend(scope[directiveName], {
lat: map.getCenter().lat,
lng: map.getCenter().lng,
Expand All @@ -56,7 +56,7 @@ centerDirectiveTypes.forEach(function(directiveName) {
});
});

safeApply(leafletScope, function(scope) {
safeApply(leafletScope, function (scope) {
var mapBounds = map.getBounds();
scope.bounds = {
northEast: {
Expand All @@ -80,7 +80,7 @@ centerDirectiveTypes.forEach(function(directiveName) {
var urlCenterHash;
var mapReady;
if (attrs.urlHashCenter === 'yes') {
var extractCenterFromUrl = function() {
var extractCenterFromUrl = function () {
var search = $location.search();
var centerParam;
if (isDefined(search.c)) {
Expand All @@ -99,7 +99,7 @@ centerDirectiveTypes.forEach(function(directiveName) {

urlCenterHash = extractCenterFromUrl();

leafletScope.$on('$locationChangeSuccess', function(event) {
leafletScope.$on('$locationChangeSuccess', function (event) {
var scope = event.currentScope;

//$log.debug("updated location...");
Expand All @@ -115,7 +115,7 @@ centerDirectiveTypes.forEach(function(directiveName) {
});
}

leafletScope.$watch(directiveName, function(center) {
leafletScope.$watch(directiveName, function (center) {
if (leafletScope.settingCenterFromLeaflet)
return;

Expand Down Expand Up @@ -166,18 +166,18 @@ centerDirectiveTypes.forEach(function(directiveName) {
leafletScope.settingCenterFromScope = true;
map.setView([center.lat, center.lng], center.zoom);
leafletMapEvents.notifyCenterChangedToBounds(leafletScope, map);
$timeout(function() {
$timeout(function () {
leafletScope.settingCenterFromScope = false;

//$log.debug("allow center scope updates");
});
}, true);

map.whenReady(function() {
map.whenReady(function () {
mapReady = true;
});

map.on('moveend', function(/* event */) {
map.on('moveend', function (/* event */) {
// Resolve the center after the first map position
_leafletCenter.resolve();
leafletMapEvents.notifyCenterUrlHashChanged(leafletScope, map, attrs, $location.search());
Expand All @@ -189,7 +189,7 @@ centerDirectiveTypes.forEach(function(directiveName) {
}

leafletScope.settingCenterFromLeaflet = true;
safeApply(leafletScope, function(scope) {
safeApply(leafletScope, function (scope) {
if (!leafletScope.settingCenterFromScope) {
//$log.debug("updating center model...", map.getCenter(), map.getZoom());
angular.extend(scope[directiveName], {
Expand All @@ -201,14 +201,14 @@ centerDirectiveTypes.forEach(function(directiveName) {
}

leafletMapEvents.notifyCenterChangedToBounds(leafletScope, map);
$timeout(function() {
$timeout(function () {
leafletScope.settingCenterFromLeaflet = false;
});
});
});

if (centerModel.autoDiscover === true) {
map.on('locationerror', function() {
map.on('locationerror', function () {
$log.warn(errorHeader + ' The Geolocation API is unauthorized on this page.');
if (isValidCenter(centerModel)) {
map.setView([centerModel.lat, centerModel.lng], centerModel.zoom);
Expand All @@ -226,6 +226,6 @@ centerDirectiveTypes.forEach(function(directiveName) {
];
});

centerDirectiveTypes.forEach(function(dirType) {
centerDirectiveTypes.forEach(function (dirType) {
angular.module('leaflet-directive').directive(dirType, centerDirectives[dirType]);
});
8 changes: 4 additions & 4 deletions src/directives/controls.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
angular.module('leaflet-directive').directive('controls', function($log, leafletHelpers, leafletControlHelpers) {
angular.module('leaflet-directive').directive('controls', function ($log, leafletHelpers, leafletControlHelpers) {

return {
restrict: 'A',
scope: false,
replace: false,
require: '?^leaflet',

link: function(scope, element, attrs, controller) {
link: function (scope, element, attrs, controller) {
if (!controller) {
return;
}
Expand All @@ -19,9 +19,9 @@ angular.module('leaflet-directive').directive('controls', function($log, leaflet
var leafletControls = {};
var errorHeader = leafletHelpers.errorHeader + ' [Controls] ';

controller.getMap().then(function(map) {
controller.getMap().then(function (map) {

leafletScope.$watchCollection('controls', function(newControls) {
leafletScope.$watchCollection('controls', function (newControls) {

// Delete controls from the array
for (var name in leafletControls) {
Expand Down
8 changes: 4 additions & 4 deletions src/directives/decorations.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
angular.module('leaflet-directive').directive('decorations', function($log, leafletHelpers) {
angular.module('leaflet-directive').directive('decorations', function ($log, leafletHelpers) {

return {
restrict: 'A',
scope: false,
replace: false,
require: 'leaflet',

link: function(scope, element, attrs, controller) {
link: function (scope, element, attrs, controller) {
var leafletScope = controller.getLeafletScope();
var PolylineDecoratorPlugin = leafletHelpers.PolylineDecoratorPlugin;
var isDefined = leafletHelpers.isDefined;
Expand Down Expand Up @@ -34,8 +34,8 @@ angular.module('leaflet-directive').directive('decorations', function($log, leaf
}
}

controller.getMap().then(function(map) {
leafletScope.$watch('decorations', function(newDecorations) {
controller.getMap().then(function (map) {
leafletScope.$watch('decorations', function (newDecorations) {
for (var name in leafletDecorations) {
if (!isDefined(newDecorations[name]) || !angular.equals(newDecorations[name], leafletDecorations)) {
map.removeLayer(leafletDecorations[name]);
Expand Down
8 changes: 4 additions & 4 deletions src/directives/eventBroadcast.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
angular.module('leaflet-directive').directive('eventBroadcast', function($log, $rootScope, leafletHelpers, leafletMapEvents, leafletIterators) {
angular.module('leaflet-directive').directive('eventBroadcast', function ($log, $rootScope, leafletHelpers, leafletMapEvents, leafletIterators) {

return {
restrict: 'A',
scope: false,
replace: false,
require: 'leaflet',

link: function(scope, element, attrs, controller) {
link: function (scope, element, attrs, controller) {
var isObject = leafletHelpers.isObject;
var isDefined = leafletHelpers.isDefined;
var leafletScope = controller.getLeafletScope();
var eventBroadcast = leafletScope.eventBroadcast;
var availableMapEvents = leafletMapEvents.getAvailableMapEvents();
var addEvents = leafletMapEvents.addEvents;

controller.getMap().then(function(map) {
controller.getMap().then(function (map) {

var mapEvents = [];
var logic = 'broadcast';
Expand All @@ -40,7 +40,7 @@ angular.module('leaflet-directive').directive('eventBroadcast', function($log, $
$log.warn('[AngularJS - Leaflet] event-broadcast.map.enable must be an object check your model.');
} else {
// Enable events
leafletIterators.each(eventBroadcast.map.enable, function(eventName) {
leafletIterators.each(eventBroadcast.map.enable, function (eventName) {
// Do we have already the event enabled?
if (mapEvents.indexOf(eventName) === -1 && availableMapEvents.indexOf(eventName) !== -1) {
mapEvents.push(eventName);
Expand Down
Loading

0 comments on commit b8f4d44

Please sign in to comment.