replace tabs with spaces

This commit is contained in:
rolux 2012-08-29 17:42:50 +02:00
parent c4c49fd1d1
commit 8572f93334

View file

@ -88,12 +88,12 @@ Ox.Map = function(options, self) {
.defaults({ .defaults({
// fixme: isClickable? // fixme: isClickable?
clickable: false, clickable: false,
editable: false, editable: false,
find: '', find: '',
findPlaceholder: 'Find', findPlaceholder: 'Find',
keys: [], keys: [],
markerColor: 'auto', markerColor: 'auto',
markerSize: 'auto', markerSize: 'auto',
maxMarkers: 100, maxMarkers: 100,
places: null, places: null,
selected: '', selected: '',
@ -160,86 +160,86 @@ Ox.Map = function(options, self) {
} }
}) })
.addClass('OxMap') .addClass('OxMap')
.bindEvent({ .bindEvent({
gainfocus: function() { gainfocus: function() {
self.options.zoomOnlyWhenFocused && self.map.setOptions({scrollwheel: true}); self.options.zoomOnlyWhenFocused && self.map.setOptions({scrollwheel: true});
}, },
losefocus: function() { losefocus: function() {
self.options.zoomOnlyWhenFocused && self.map.setOptions({scrollwheel: false}); self.options.zoomOnlyWhenFocused && self.map.setOptions({scrollwheel: false});
}, },
key_0: function() { key_0: function() {
panToPlace() panToPlace()
}, },
key_c: toggleControls, key_c: toggleControls,
key_down: function() { key_down: function() {
pan(0, 1); pan(0, 1);
}, },
key_enter: pressEnter, key_enter: pressEnter,
key_escape: pressEscape, key_escape: pressEscape,
key_equal: function() { key_equal: function() {
zoom(1); zoom(1);
}, },
key_l: toggleLabels, key_l: toggleLabels,
key_left: function() { key_left: function() {
pan(-1, 0); pan(-1, 0);
}, },
// FIXME: // FIXME:
'key_meta.left': function() { 'key_meta.left': function() {
self.metaKey = true; self.metaKey = true;
$(document).one({ $(document).one({
keyup: function() { keyup: function() {
self.metaKey = false; self.metaKey = false;
} }
}); });
}, },
'key_meta.right': function() { 'key_meta.right': function() {
self.metaKey = true; self.metaKey = true;
$(document).one({ $(document).one({
keyup: function() { keyup: function() {
self.metaKey = false; self.metaKey = false;
} }
}); });
}, },
key_minus: function() { key_minus: function() {
zoom(-1); zoom(-1);
}, },
key_right: function() { key_right: function() {
pan(1, 0); pan(1, 0);
}, },
key_shift: function() { key_shift: function() {
self.shiftKey = true; self.shiftKey = true;
$(document).one({ $(document).one({
keyup: function() { keyup: function() {
self.shiftKey = false; self.shiftKey = false;
} }
}); });
}, },
key_shift_down: function() { key_shift_down: function() {
pan(0, 2); pan(0, 2);
}, },
key_shift_0: function() { key_shift_0: function() {
zoomToPlace(); zoomToPlace();
}, },
key_shift_equal: function() { key_shift_equal: function() {
zoom(2); zoom(2);
}, },
key_shift_left: function() { key_shift_left: function() {
pan(-2, 0); pan(-2, 0);
}, },
key_shift_minus: function() { key_shift_minus: function() {
zoom(-2); zoom(-2);
}, },
key_shift_right: function() { key_shift_right: function() {
pan(2, 0); pan(2, 0);
}, },
key_shift_up: function() { key_shift_up: function() {
pan(0, -2); pan(0, -2);
}, },
key_up: function() { key_up: function() {
pan(0, -1); pan(0, -1);
}, },
key_z: undo, key_z: undo,
mousedown: function(e) { mousedown: function(e) {
!$(e.target).is('input') && that.gainFocus(); !$(e.target).is('input') && that.gainFocus();
} }
}); });
@ -580,9 +580,9 @@ Ox.Map = function(options, self) {
name: '', name: '',
type: 'feature', type: 'feature',
south: southwest.lat(), south: southwest.lat(),
west: southwest.lng(), west: southwest.lng(),
north: northeast.lat(), north: northeast.lat(),
east: northeast.lng() east: northeast.lng()
}); });
} }
Ox.forEach(self.places, function(p, i) { Ox.forEach(self.places, function(p, i) {
@ -641,8 +641,8 @@ Ox.Map = function(options, self) {
function clickMap(event) { function clickMap(event) {
var place = getSelectedPlace(); var place = getSelectedPlace();
if (self.options.clickable/* && !editing()*/) { if (self.options.clickable/* && !editing()*/) {
getPlaceByLatLng(event.latLng, self.map.getBounds(), function(place) { getPlaceByLatLng(event.latLng, self.map.getBounds(), function(place) {
if (place) { if (place) {
addPlaceToMap(place); addPlaceToMap(place);
//selectPlace(place.id); //selectPlace(place.id);
@ -650,9 +650,9 @@ Ox.Map = function(options, self) {
selectPlace(null); selectPlace(null);
} }
}); });
} else { } else {
pressEscape(); pressEscape();
} }
} }
function clickPlaceButton() { function clickPlaceButton() {
@ -826,16 +826,16 @@ Ox.Map = function(options, self) {
}); });
} }
function getPositionByName(name) { function getPositionByName(name) {
var position = -1; var position = -1;
Ox.forEach(self.options.places, function(place, i) { Ox.forEach(self.options.places, function(place, i) {
if (place.name == name) { if (place.name == name) {
position = i; position = i;
return false; // break return false; // break
} }
}); });
return position; return position;
} }
function getSelectedMarker() { function getSelectedMarker() {
// needed in case self.options.selected // needed in case self.options.selected
@ -931,8 +931,8 @@ Ox.Map = function(options, self) {
} }
updateFormElements(); updateFormElements();
self.loaded = true; self.loaded = true;
that.triggerEvent('load'); that.triggerEvent('load');
}); });
@ -1036,20 +1036,20 @@ Ox.Map = function(options, self) {
formatTerms(); formatTerms();
} }
function pan(x, y) { function pan(x, y) {
self.map.panBy(x * self.$map.width() / 2, y * self.$map.height() / 2); self.map.panBy(x * self.$map.width() / 2, y * self.$map.height() / 2);
}; };
function panToPlace() { function panToPlace() {
var place; var place;
if (!self.loaded) { if (!self.loaded) {
setTimeout(function() { setTimeout(function() {
panToPlace(); panToPlace();
}, 100); }, 100);
} else { } else {
place = getSelectedPlace(); place = getSelectedPlace();
place && self.map.panTo(place.center); place && self.map.panTo(place.center);
} }
} }
function parseGeodata(data) { function parseGeodata(data) {
@ -1059,18 +1059,18 @@ Ox.Map = function(options, self) {
place = { place = {
alternativeNames: [], alternativeNames: [],
components: data.address_components, components: data.address_components,
countryCode: getCountryCode(data.address_components), countryCode: getCountryCode(data.address_components),
east: northEast.lng(), east: northEast.lng(),
editable: self.options.editable, editable: self.options.editable,
fullGeoname: getFullGeoname(data.address_components), fullGeoname: getFullGeoname(data.address_components),
id: '_' + Ox.encodeBase32(Ox.uid()), id: '_' + Ox.encodeBase32(Ox.uid()),
map: that, map: that,
north: northEast.lat(), north: northEast.lat(),
south: southWest.lat(), south: southWest.lat(),
type: getType(data.address_components[0].types), type: getType(data.address_components[0].types),
west: southWest.lng() west: southWest.lng()
}; };
place.geoname = data.formatted_address || place.fullGeoname; place.geoname = data.formatted_address || place.fullGeoname;
place.name = (place.geoname || place.fullGeoname).split(', ')[0]; place.name = (place.geoname || place.fullGeoname).split(', ')[0];
if (Math.abs(place.west) == 180 && Math.abs(place.east) == 180) { if (Math.abs(place.west) == 180 && Math.abs(place.east) == 180) {
place.west = -179.99999999; place.west = -179.99999999;
@ -1098,7 +1098,7 @@ Ox.Map = function(options, self) {
return !country && ( return !country && (
i == 0 || name != components[i - 1].long_name i == 0 || name != components[i - 1].long_name
) ? name : null; ) ? name : null;
}).join(', '); }).join(', ');
} }
function getType(types) { function getType(types) {
// see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes // see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes
@ -1140,7 +1140,7 @@ Ox.Map = function(options, self) {
}); });
return type || 'feature'; return type || 'feature';
} }
return place; return place;
} }
function pressEnter() { function pressEnter() {
@ -1182,11 +1182,11 @@ Ox.Map = function(options, self) {
place.rectangle.update(); place.rectangle.update();
} }
function reset() { function reset() {
self.map.getZoom() == self.zoom self.map.getZoom() == self.zoom
? self.map.panTo(self.center) ? self.map.panTo(self.center)
: self.map.fitBounds(self.bounds); : self.map.fitBounds(self.bounds);
} }
function selectPlace(id, zoom) { function selectPlace(id, zoom) {
// id can be null (deselect) // id can be null (deselect)
@ -1432,9 +1432,9 @@ Ox.Map = function(options, self) {
} }
} }
function zoom(z) { function zoom(z) {
self.map.setZoom(self.map.getZoom() + z); self.map.setZoom(self.map.getZoom() + z);
} }
function zoomChanged() { function zoomChanged() {
var zoom = self.map.getZoom(); var zoom = self.map.getZoom();
@ -1451,17 +1451,17 @@ Ox.Map = function(options, self) {
} }
} }
function zoomToPlace() { function zoomToPlace() {
var place; var place;
if (!self.loaded) { if (!self.loaded) {
setTimeout(function() { setTimeout(function() {
zoomToPlace(); zoomToPlace();
}, 100); }, 100);
} else { } else {
place = getSelectedPlace(); place = getSelectedPlace();
place && self.map.fitBounds(place.bounds); place && self.map.fitBounds(place.bounds);
} }
} }
/*@ /*@
addPlace <f> addPlace addPlace <f> addPlace
@ -1495,7 +1495,7 @@ Ox.Map = function(options, self) {
@*/ @*/
that.editPlace = function() { that.editPlace = function() {
getSelectedPlace().edit(); getSelectedPlace().edit();
return that; return that;
}; };
/*@ /*@
@ -1528,10 +1528,10 @@ Ox.Map = function(options, self) {
panToPlace <f> panToPlace panToPlace <f> panToPlace
() -> <o> pan to place () -> <o> pan to place
@*/ @*/
that.panToPlace = function() { that.panToPlace = function() {
panToPlace(); panToPlace();
return that; return that;
}; };
/*@ /*@
removePlace <f> removePlace removePlace <f> removePlace
@ -1540,7 +1540,7 @@ Ox.Map = function(options, self) {
that.removePlace = function() { that.removePlace = function() {
// fixme: removePlaceFromPlaces() ? // fixme: removePlaceFromPlaces() ?
removePlace(); removePlace();
return that; return that;
}; };
/*@ /*@
@ -1571,7 +1571,7 @@ Ox.Map = function(options, self) {
google.maps.event.trigger(self.map, 'resize'); google.maps.event.trigger(self.map, 'resize');
// self.map.setCenter(center); // self.map.setCenter(center);
} }
return that; return that;
} }
/*@ /*@
@ -1602,7 +1602,7 @@ Ox.Map = function(options, self) {
@*/ @*/
that.zoomToPlace = function() { that.zoomToPlace = function() {
zoomToPlace(); zoomToPlace();
return that; return that;
}; };
/*@ /*@
@ -1611,7 +1611,7 @@ Ox.Map = function(options, self) {
@*/ @*/
that.zoom = function(value) { that.zoom = function(value) {
zoom(value); zoom(value);
return that; return that;
}; };
return that; return that;