update other libs

This commit is contained in:
Norbert Renner 2014-05-14 16:01:20 +02:00
parent e4ae9b5533
commit aa1e051cfd
31 changed files with 679 additions and 719 deletions

View file

@ -1,11 +1,11 @@
{ {
"name": "leaflet-gpx", "name": "leaflet-gpx",
"homepage": "https://github.com/mpetazzoni/leaflet-gpx", "homepage": "https://github.com/mpetazzoni/leaflet-gpx",
"_release": "f0622fa76e", "_release": "ad9d5adf0a",
"_resolution": { "_resolution": {
"type": "branch", "type": "branch",
"branch": "master", "branch": "master",
"commit": "f0622fa76ec80639b530a2348a7b291ed05a4418" "commit": "ad9d5adf0ae5450bc5bc60e1e86307beb7667772"
}, },
"_source": "git://github.com/mpetazzoni/leaflet-gpx.git", "_source": "git://github.com/mpetazzoni/leaflet-gpx.git",
"_target": "*", "_target": "*",

View file

@ -60,6 +60,7 @@ so in the 'loaded' event handler, calling one of the following methods on the
* `get_moving_time()`: returns the moving time, in milliseconds * `get_moving_time()`: returns the moving time, in milliseconds
* `get_total_time()`: returns the total track time, in milliseconds * `get_total_time()`: returns the total track time, in milliseconds
* `get_moving_pace()`: returns the average moving pace in milliseconds per km * `get_moving_pace()`: returns the average moving pace in milliseconds per km
* `get_moving_speed()`: returns the average moving speed in km per hour
* `get_elevation_gain()`: returns the cumulative elevation gain, in meters * `get_elevation_gain()`: returns the cumulative elevation gain, in meters
* `get_elevation_loss()`: returns the cumulative elevation loss, in meters * `get_elevation_loss()`: returns the cumulative elevation loss, in meters
* `get_average_hr()`: returns the average heart rate (if available) * `get_average_hr()`: returns the average heart rate (if available)
@ -69,7 +70,9 @@ at your disposal:
* `get_distance_imp()`: returns the total track distance in miles * `get_distance_imp()`: returns the total track distance in miles
* `get_moving_pace_imp()`: returns the average moving pace in milliseconds per * `get_moving_pace_imp()`: returns the average moving pace in milliseconds per
mile hour
* `get_moving_speed()`: returns the average moving pace in miles per
hour
The reason why these methods return milliseconds is that you have at your The reason why these methods return milliseconds is that you have at your
disposal a nice helper method to format a duration in milliseconds into a cool disposal a nice helper method to format a duration in milliseconds into a cool
@ -89,6 +92,15 @@ the distance is either in kilometers or in miles and the elevation in meters of
feet, depending on whether you use the `_imp` variant or not. Heart rate, feet, depending on whether you use the `_imp` variant or not. Heart rate,
obviously, doesn't change. obviously, doesn't change.
You can reload remote gpx file every 5 seconds with:
```javascript
var gpxLayer = new L.GPX(gpxFile);
setInterval(function() {
gpxLayer.reload();
},5000);
```
About marker icons About marker icons
------------------ ------------------
@ -124,3 +136,12 @@ new L.GPX(url, {
map.fitBounds(e.target.getBounds()); map.fitBounds(e.target.getBounds());
}).addTo(map); }).addTo(map);
``` ```
Caveats
-------
* Distance calculation is relatively accurate, but elevation change
calculation is not topographically adjusted, so the total elevation
gain/loss/change might appear inaccurate in some situations.
* Currently doesn't seem to work in IE8/9. See #9 and #11 for
discussion.

View file

@ -107,12 +107,17 @@ L.GPX = L.FeatureGroup.extend({
return s; return s;
}, },
// Public methods
to_miles: function(v) { return v / 1.60934; }, to_miles: function(v) { return v / 1.60934; },
to_ft: function(v) { return v * 3.28084; }, to_ft: function(v) { return v * 3.28084; },
m_to_km: function(v) { return v / 1000; }, m_to_km: function(v) { return v / 1000; },
m_to_mi: function(v) { return v / 1609.34; }, m_to_mi: function(v) { return v / 1609.34; },
get_name: function() { return this._info.name; }, get_name: function() { return this._info.name; },
get_desc: function() { return this._info.desc; },
get_author: function() { return this._info.author; },
get_copyright: function() { return this._info.copyright; },
get_desc: function() { return this._info.desc; },
get_distance: function() { return this._info.length; }, get_distance: function() { return this._info.length; },
get_distance_imp: function() { return this.to_miles(this.m_to_km(this.get_distance())); }, get_distance_imp: function() { return this.to_miles(this.m_to_km(this.get_distance())); },
@ -124,6 +129,9 @@ L.GPX = L.FeatureGroup.extend({
get_moving_pace: function() { return this.get_moving_time() / this.m_to_km(this.get_distance()); }, get_moving_pace: function() { return this.get_moving_time() / this.m_to_km(this.get_distance()); },
get_moving_pace_imp: function() { return this.get_moving_time() / this.get_distance_imp(); }, get_moving_pace_imp: function() { return this.get_moving_time() / this.get_distance_imp(); },
get_moving_speed: function() { return this.m_to_km(this.get_distance()) / (this.get_moving_time() / (3600 * 1000)) ; },
get_moving_speed_imp:function() { return this.to_miles(this.m_to_km(this.get_distance())) / (this.get_moving_time() / (3600 * 1000)) ; },
get_elevation_gain: function() { return this._info.elevation.gain; }, get_elevation_gain: function() { return this._info.elevation.gain; },
get_elevation_loss: function() { return this._info.elevation.loss; }, get_elevation_loss: function() { return this._info.elevation.loss; },
get_elevation_data: function() { get_elevation_data: function() {
@ -157,8 +165,12 @@ L.GPX = L.FeatureGroup.extend({
}); });
}, },
// Private methods reload: function() {
this.clearLayers();
this._parse(this._gpx, this.options, this.options.async);
},
// Private methods
_merge_objs: function(a, b) { _merge_objs: function(a, b) {
var _ = {}; var _ = {};
for (var attr in a) { _[attr] = a[attr]; } for (var attr in a) { _[attr] = a[attr]; }
@ -214,6 +226,18 @@ L.GPX = L.FeatureGroup.extend({
if (name.length > 0) { if (name.length > 0) {
this._info.name = name[0].textContent; this._info.name = name[0].textContent;
} }
var desc = xml.getElementsByTagName('desc');
if (desc.length > 0) {
this._info.desc = desc[0].textContent;
}
var author = xml.getElementsByTagName('author');
if (author.length > 0) {
this._info.author = author[0].textContent;
}
var copyright = xml.getElementsByTagName('copyright');
if (copyright.length > 0) {
this._info.copyright = copyright[0].textContent;
}
for (j = 0; j < tags.length; j++) { for (j = 0; j < tags.length; j++) {
el = xml.getElementsByTagName(tags[j][0]); el = xml.getElementsByTagName(tags[j][0]);
@ -333,5 +357,5 @@ L.GPX = L.FeatureGroup.extend({
_deg2rad: function(deg) { _deg2rad: function(deg) {
return deg * Math.PI / 180; return deg * Math.PI / 180;
}, }
}); });

View file

@ -1,12 +1,12 @@
{ {
"name": "shramov-plugins-permalink", "name": "leaflet-plugins",
"homepage": "https://github.com/shramov/leaflet-plugins", "homepage": "https://github.com/shramov/leaflet-plugins",
"version": "1.0.1", "version": "1.1.2",
"_release": "1.0.1", "_release": "1.1.2",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.1", "tag": "v1.1.2",
"commit": "a03de1df77d53c58dd7194bf7e1ddbc100231ac2" "commit": "de2380a9efa24b3b43fb780219363f171f9f3140"
}, },
"_source": "git://github.com/shramov/leaflet-plugins.git", "_source": "git://github.com/shramov/leaflet-plugins.git",
"_target": "*", "_target": "*",

View file

@ -0,0 +1,11 @@
{
"browser": true,
"eqeqeq": true,
"undef": true,
"quotmark": "single",
"trailing": true,
"laxbreak": true,
"globals": {
"L": true
}
}

View file

@ -1,4 +1,4 @@
Copyright (c) 2011-2012, Pavel Shramov Copyright (c) 2011-2014, Pavel Shramov, Bruno Bergot
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are Redistribution and use in source and binary forms, with or without modification, are

View file

@ -22,7 +22,7 @@ Also there are some useful control plugins (`control/`):
* Permalink - OpenLayers compatible permanent link with support for storing * Permalink - OpenLayers compatible permanent link with support for storing
location data in hash part (#lat=...); location data in hash part (#lat=...);
* Scale - scale ruler which looks like one on paper maps. * Distance - simple tool to measure distances on maps
== How to get? == How to get?

View file

@ -1,3 +1,4 @@
/* global console: true */
L.Control.Distance = L.Control.extend({ L.Control.Distance = L.Control.extend({
options: { options: {
position: 'topleft', position: 'topleft',
@ -95,15 +96,15 @@ L.Control.Distance = L.Control.extend({
}, },
_update: function(e) { _update: function(e) {
console.info("Update"); console.info('Update');
this._text.textContent = this._d2txt(this._distance_calc()); this._text.textContent = this._d2txt(this._distance_calc());
}, },
_d2txt: function(d) { _d2txt: function(d) {
if (d < 2000) if (d < 2000)
return d.toFixed(0) + " m"; return d.toFixed(0) + ' m';
else else
return (d/1000).toFixed(1) + " km"; return (d/1000).toFixed(1) + ' km';
}, },
_distance_calc: function(e) { _distance_calc: function(e) {

View file

@ -3,7 +3,7 @@
*/ */
L.Control.Layers.include({ L.Control.Layers.include({
_loadScripts: function(scripts, cb, args) { _loadScripts: function(scripts, cb, args) {
if (!scripts || scripts.length == 0) if (!scripts || scripts.length === 0)
return cb(args); return cb(args);
var _this = this, s = scripts.pop(), c; var _this = this, s = scripts.pop(), c;
c = L.Control.Layers._script_cache[s]; c = L.Control.Layers._script_cache[s];
@ -17,13 +17,13 @@ L.Control.Layers.include({
var i = 0; var i = 0;
for (i = 0; i < c.wait.length; i++) for (i = 0; i < c.wait.length; i++)
c.wait[i](); c.wait[i]();
} };
c.e = script; c.e = script;
document.getElementsByTagName('head')[0].appendChild(script); document.getElementsByTagName('head')[0].appendChild(script);
} }
function _cb() { _this._loadScripts(scripts, cb, args); } function _cb() { _this._loadScripts(scripts, cb, args); }
c.wait.push(_cb); c.wait.push(_cb);
if (c.e.readyState == "completed") if (c.e.readyState === 'completed')
_cb(); _cb();
L.Control.Layers._script_cache[s] = c; L.Control.Layers._script_cache[s] = c;
}, },
@ -43,7 +43,7 @@ L.Control.Layers.include({
loadLayer: function(name, deflt) { loadLayer: function(name, deflt) {
var _this = this, l = this._layer_defs[name]; var _this = this, l = this._layer_defs[name];
l['default'] = deflt; l['default'] = deflt;
this._loadScripts(l.js.reverse(), function(l) {_this._loadLayer(l)}, l); this._loadScripts(l.js.reverse(), function(l) {_this._loadLayer(l);}, l);
}, },
_loadLayer: function(l) { _loadLayer: function(l) {

View file

@ -44,20 +44,20 @@ L.Control.Layers.include({
if (!this._layers.hasOwnProperty(i)) if (!this._layers.hasOwnProperty(i))
continue; continue;
obj = this._layers[i]; obj = this._layers[i];
if (!obj.overlay && obj.name == name) if (!obj.overlay && obj.name === name)
layer = obj.layer; layer = obj.layer;
} }
if (!layer || this._map.hasLayer(layer)) if (!layer || this._map.hasLayer(layer))
return; return;
for (var i in this._layers) { for (var j in this._layers) {
if (!this._layers.hasOwnProperty(i)) if (!this._layers.hasOwnProperty(j))
continue; continue;
obj = this._layers[i]; obj = this._layers[j];
if (!obj.overlay && this._map.hasLayer(obj.layer)) if (!obj.overlay && this._map.hasLayer(obj.layer))
this._map.removeLayer(obj.layer) this._map.removeLayer(obj.layer);
} }
this._map.addLayer(layer) this._map.addLayer(layer);
this._update(); this._update();
}, },

View file

@ -16,7 +16,7 @@ L.Control.Permalink.include({
//console.info("onAdd::line", e); //console.info("onAdd::line", e);
if (!this.options.line) return; if (!this.options.line) return;
this.options.line.on('edit', this._update_line, this); this.options.line.on('edit', this._update_line, this);
this._update_line() this._update_line();
}, },
_update_line: function() { _update_line: function() {
@ -27,7 +27,7 @@ L.Control.Permalink.include({
if (!coords.length) if (!coords.length)
return this._update({line: null}); return this._update({line: null});
for (var i in coords) for (var i in coords)
text.push(coords[i].lat.toFixed(4) + "," + coords[i].lng.toFixed(4)) text.push(coords[i].lat.toFixed(4) + ',' + coords[i].lng.toFixed(4));
this._update({line: text.join(';')}); this._update({line: text.join(';')});
}, },
@ -38,7 +38,7 @@ L.Control.Permalink.include({
var coords = [], text = p.line.split(';'); var coords = [], text = p.line.split(';');
for (var i in text) { for (var i in text) {
var ll = text[i].split(','); var ll = text[i].split(',');
if (ll.length != 2) continue; if (ll.length !== 2) continue;
coords.push(new L.LatLng(ll[0], ll[1])); coords.push(new L.LatLng(ll[0], ll[1]));
} }
if (!coords.length) return; if (!coords.length) return;

View file

@ -18,13 +18,13 @@ L.Control.Permalink.include({
var p = e.params; var p = e.params;
//if (!this.options.useMarker) return; //if (!this.options.useMarker) return;
if (this._marker) return; if (this._marker) return;
if (p.marker != 1) return; if (p.marker !== 1) return;
if (p.mlat !== undefined && p.mlon !== undefined) if (p.mlat !== undefined && p.mlon !== undefined)
return this._update({mlat: null, mlon: null, return this._update({mlat: null, mlon: null,
lat: p.mlat, lon: p.mlon, marker: 1}); lat: p.mlat, lon: p.mlon, marker: 1});
this._marker = new L.Marker(new L.LatLng(p.lat, p.lon), this._marker = new L.Marker(new L.LatLng(p.lat, p.lon),
this.options.markerOptions); this.options.markerOptions);
this._marker.bindPopup("<a href='" + this._update_href() + "'>" + this.options.text + "</a>"); this._marker.bindPopup('<a href="' + this._update_href() + '">' + this.options.text + '</a>');
this._map.addLayer(this._marker); this._map.addLayer(this._marker);
this._update({marker: null}); this._update({marker: null});
} }

View file

@ -2,19 +2,19 @@ L.Control.Permalink = L.Control.extend({
includes: L.Mixin.Events, includes: L.Mixin.Events,
options: { options: {
position: "bottomleft", position: 'bottomleft',
useAnchor: true, useAnchor: true,
useLocation: false, useLocation: false,
text: "Permalink" text: 'Permalink'
}, },
initialize: function(options) { initialize: function(options) {
L.Util.setOptions(this, options); L.Util.setOptions(this, options);
this._params = {}; this._params = {};
this._set_urlvars(); this._set_urlvars();
this.on("update", this._set_center, this); this.on('update', this._set_center, this);
for (var i in this) { for (var i in this) {
if (typeof(i) === "string" && i.indexOf('initialize_') == 0) if (typeof(i) === 'string' && i.indexOf('initialize_') === 0)
this[i](); this[i]();
} }
}, },
@ -24,10 +24,10 @@ L.Control.Permalink = L.Control.extend({
L.DomEvent.disableClickPropagation(this._container); L.DomEvent.disableClickPropagation(this._container);
this._map = map; this._map = map;
this._href = L.DomUtil.create('a', null, this._container); this._href = L.DomUtil.create('a', null, this._container);
this._href.innerHTML = this.options.text this._href.innerHTML = this.options.text;
map.on('moveend', this._update_center, this); map.on('moveend', this._update_center, this);
this.fire("update", {params: this._params}) this.fire('update', {params: this._params});
this._update_center(); this._update_center();
if (this.options.useAnchor && 'onhashchange' in window) { if (this.options.useAnchor && 'onhashchange' in window) {
@ -35,7 +35,7 @@ L.Control.Permalink = L.Control.extend({
window.onhashchange = function() { window.onhashchange = function() {
_this._set_urlvars(); _this._set_urlvars();
if (fn) return fn(); if (fn) return fn();
} };
} }
this.fire('add', {map: map}); this.fire('add', {map: map});
@ -66,26 +66,26 @@ L.Control.Permalink = L.Control.extend({
var ne = bounds.getNorthEast(), sw = bounds.getSouthWest(); var ne = bounds.getNorthEast(), sw = bounds.getSouthWest();
var round = function (x, p) { var round = function (x, p) {
if (p == 0) return x; if (p === 0) return x;
shift = 1; var shift = 1;
while (p < 1 && p > -1) { while (p < 1 && p > -1) {
x *= 10; x *= 10;
p *= 10; p *= 10;
shift *= 10; shift *= 10;
} }
return Math.floor(x)/shift; return Math.floor(x)/shift;
} };
point.lat = round(point.lat, (ne.lat - sw.lat) / size.y); point.lat = round(point.lat, (ne.lat - sw.lat) / size.y);
point.lng = round(point.lng, (ne.lng - sw.lng) / size.x); point.lng = round(point.lng, (ne.lng - sw.lng) / size.x);
return point; return point;
}, },
_update: function(obj, source) { _update: function(obj, source) {
//console.info("Update", obj, this._params); //console.info('Update', obj, this._params);
for(var i in obj) { for(var i in obj) {
if (!obj.hasOwnProperty(i)) continue; if (!obj.hasOwnProperty(i)) continue;
if (obj[i] != null && obj[i] != undefined) if (obj[i] !== null && obj[i] !== undefined)
this._params[i] = obj[i] this._params[i] = obj[i];
else else
delete this._params[i]; delete this._params[i];
} }
@ -105,7 +105,7 @@ L.Control.Permalink = L.Control.extend({
function eq(x, y) { function eq(x, y) {
for(var i in x) for(var i in x)
if (x.hasOwnProperty(i) && x[i] != y[i]) if (x.hasOwnProperty(i) && x[i] !== y[i])
return false; return false;
return true; return true;
} }
@ -114,16 +114,16 @@ L.Control.Permalink = L.Control.extend({
return; return;
this._params = p; this._params = p;
this._update_href(); this._update_href();
this.fire("update", {params: this._params}) this.fire('update', {params: this._params});
}, },
_set_center: function(e) _set_center: function(e)
{ {
//console.info("Update center", e); //console.info('Update center', e);
var params = e.params; var params = e.params;
if (params.zoom == undefined || if (params.zoom === undefined ||
params.lat == undefined || params.lat === undefined ||
params.lon == undefined) return; params.lon === undefined) return;
this._map.setView(new L.LatLng(params.lat, params.lon), params.zoom); this._map.setView(new L.LatLng(params.lat, params.lon), params.zoom);
} }
}); });
@ -131,13 +131,13 @@ L.Control.Permalink = L.Control.extend({
L.UrlUtil = { L.UrlUtil = {
queryParse: function(s) { queryParse: function(s) {
var p = {}; var p = {};
var sep = "&"; var sep = '&';
if (s.search("&amp;") != -1) if (s.search('&amp;') !== -1)
sep = "&amp;"; sep = '&amp;';
var params = s.split(sep); var params = s.split(sep);
for(var i = 0; i < params.length; i++) { for(var i = 0; i < params.length; i++) {
var tmp = params[i].split('='); var tmp = params[i].split('=');
if (tmp.length != 2) continue; if (tmp.length !== 2) continue;
p[tmp[0]] = decodeURI(tmp[1]); p[tmp[0]] = decodeURI(tmp[1]);
} }
return p; return p;
@ -150,7 +150,7 @@ L.UrlUtil = {
return href.slice(idx+1); return href.slice(idx+1);
}, },
hash: function() { return window.location.hash.slice(1) }, hash: function() { return window.location.hash.slice(1); },
updateParamString: function (q, obj) { updateParamString: function (q, obj) {
var p = L.UrlUtil.queryParse(q); var p = L.UrlUtil.queryParse(q);

View file

@ -1,118 +0,0 @@
L.Control.Scale = L.Control.extend({
options: {
position: "bottomleft",
useCanvas: null,
width: 100
},
initialize: function(options) {
L.Util.setOptions(this, options);
},
onAdd: function(map) {
this._map = map;
this._container = L.DomUtil.create('div', 'leaflet-control-attribution leaflet-control-scale');
this._label = L.DomUtil.create('div', null, this._container);
this._label.style.textAlign = 'right';
if (!this.options.useCanvas && this.options.useCanvas != false)
this.options.useCanvas = "HTMLCanvasElement" in window;
if (this.options.useCanvas) {
this._canvas = L.DomUtil.create('canvas', 'leaflet-canvas-marker', this._container);
} else {
this._canvas = L.DomUtil.create('div', null, this._container);
this._canvas.style.border = "1px solid black";
this._canvas.innerHTML = "&nbsp;";
//this._canvas.style.padding = "none";
//this._canvas.style.margin = "none";
//this._canvas.style.width = 100;
//this._canvas.style.height = 5;
}
map.on('zoomend', this._update, this);
this._update();
return this._container;
},
onRemove: function(map) {
map._container.removeChild(this._label);
map._container.removeChild(this._canvas);
map.off('zoomend', this._reset);
},
getPosition: function() {
return this.options.position;
},
getContainer: function() {
return this._container;
},
_update: function() {
if (!this._map) return;
var size = this.options.width;
var b = this._map.getBounds(), pb = this._map.getPixelBounds();
var width = this._deg_length(b.getNorthEast(), b.getNorthWest());
width = size * width / (pb.max.x - pb.min.x);
var iw = this._round(width);
if (iw >= 1)
this._label.innerHTML = iw + " km";
else
this._label.innerHTML = Math.round(1000 * iw) + " m";
size = size * iw / width;
if (this.options.useCanvas) {
this._canvas.width = size+1;
this._canvas.height = 10+1;
var ctx = this._canvas.getContext("2d");
this._draw(ctx, size, 5);
} else {
this._canvas.style.width = size;
this._canvas.style.height = 5;
}
},
_draw: function(ctx, width, height) {
ctx.beginPath();
ctx.fillStyle = ctx.strokeStyle = '#000';
ctx.lineWidth = 0.5;
ctx.strokeRect(0, height, width/2, height);
ctx.fillRect(0, height, width/2, height);
ctx.strokeRect(width/2, height, width/2, height);
ctx.moveTo(0, 0);
ctx.lineTo(0, height);
ctx.moveTo(width/2, 0);
ctx.lineTo(width/2, height);
ctx.moveTo(width, 0);
ctx.lineTo(width, height);
ctx.stroke();
},
_deg_length : function(p1, p2) {
var deglen = 111.12 * L.LatLng.RAD_TO_DEG;
var p1lat = p1.lat * L.LatLng.DEG_TO_RAD,
p1lng = p1.lng * L.LatLng.DEG_TO_RAD,
p2lat = p2.lat * L.LatLng.DEG_TO_RAD,
p2lng = p2.lng * L.LatLng.DEG_TO_RAD;
return deglen * Math.acos(Math.sin(p1lat) * Math.sin(p2lat) +
Math.cos(p1lat) * Math.cos(p2lat) * Math.cos(p2lng - p1lng));
},
_round : function (x) {
var div = 1;
while (div < x) div *= 10;
while (div > x) div /= 10;
var s = div;
while (s < x) s += div;
if (s > 5 * div) s = 10 * div;
return s;
}
});

View file

@ -12,7 +12,7 @@ L.Icon.Canvas = L.Icon.extend({
var e = document.createElement('canvas'); var e = document.createElement('canvas');
this._setIconStyles(e, 'icon'); this._setIconStyles(e, 'icon');
var s = this.options.iconSize; var s = this.options.iconSize;
e.width = s.x e.width = s.x;
e.height = s.y; e.height = s.y;
this.draw(e.getContext('2d'), s.x, s.y); this.draw(e.getContext('2d'), s.x, s.y);
return e; return e;

View file

@ -15,42 +15,42 @@ L.DeferredLayer = L.LayerGroup.extend({
onAdd: function(map) { onAdd: function(map) {
L.LayerGroup.prototype.onAdd.apply(this, [map]); L.LayerGroup.prototype.onAdd.apply(this, [map]);
if (this._loaded) return; if (this._loaded) return;
//console.info("Script cache", this._script_cache); //console.info('Script cache', this._script_cache);
var loaded = function() { var loaded = function() {
//console.info("Loaded", this, this.options); //console.info('Loaded', this, this.options);
this._loaded = true; this._loaded = true;
var l = this.options.init(); var l = this.options.init();
if (l) if (l)
this.addLayer(l); this.addLayer(l);
} };
this._loadScripts(this.options.js.reverse(), L.Util.bind(loaded, this)); this._loadScripts(this.options.js.reverse(), L.Util.bind(loaded, this));
}, },
_loadScripts: function(scripts, cb, args) { _loadScripts: function(scripts, cb, args) {
if (!scripts || scripts.length == 0) if (!scripts || scripts.length === 0)
return cb(args); return cb(args);
var _this = this, s = scripts.pop(), c; var _this = this, s = scripts.pop(), c;
c = this._script_cache[s]; c = this._script_cache[s];
if (c === undefined) { if (c === undefined) {
c = {url: s, wait: []}; c = {url: s, wait: []};
//console.info("Load ", s); //console.info('Load ', s);
var script = document.createElement('script'); var script = document.createElement('script');
script.src = s; script.src = s;
script.type = 'text/javascript'; script.type = 'text/javascript';
script.onload = function () { script.onload = function () {
//console.info("Element(cb)", c.e.readyState); //console.info('Element(cb)', c.e.readyState);
c.e.readyState = "completed"; c.e.readyState = 'completed';
var i = 0; var i = 0;
for (i = 0; i < c.wait.length; i++) for (i = 0; i < c.wait.length; i++)
c.wait[i](); c.wait[i]();
} };
c.e = script; c.e = script;
document.getElementsByTagName('head')[0].appendChild(script); document.getElementsByTagName('head')[0].appendChild(script);
} }
function _cb() { _this._loadScripts(scripts, cb, args); } function _cb() { _this._loadScripts(scripts, cb, args); }
c.wait.push(_cb); c.wait.push(_cb);
//console.info("Element", c.e.readyState); //console.info('Element', c.e.readyState);
if (c.e.readyState == "completed") if (c.e.readyState === 'completed')
_cb(); _cb();
this._script_cache[s] = c; this._script_cache[s] = c;
} }

View file

@ -18,17 +18,15 @@
setIconAngle: function (iconAngle) { setIconAngle: function (iconAngle) {
this.options.iconAngle = iconAngle; this.options.iconAngle = iconAngle;
if (this._map)
if (this._map) this.update(); this.update();
}, },
_setPos: function (pos) { _setPos: function (pos) {
if (this._icon) { if (this._icon)
this._icon.style[L.DomUtil.TRANSFORM] = ""; this._icon.style[L.DomUtil.TRANSFORM] = '';
} if (this._shadow)
if (this._shadow) { this._shadow.style[L.DomUtil.TRANSFORM] = '';
this._shadow.style[L.DomUtil.TRANSFORM] = "";
}
_old__setPos.apply(this,[pos]); _old__setPos.apply(this,[pos]);
@ -40,14 +38,14 @@
i = this._icon; i = this._icon;
this._updateImg(i, a, s); this._updateImg(i, a, s);
} }
if (this._shadow) { if (this._shadow) {
// Rotate around the icons anchor. if (this.options.icon.options.shadowAnchor)
a = this.options.icon.options.shadowAnchor;
s = this.options.icon.options.shadowSize; s = this.options.icon.options.shadowSize;
i = this._shadow; i = this._shadow;
this._updateImg(i, a, s); this._updateImg(i, a, s);
} }
}
} } }
}); });
}()); }());

View file

@ -8,7 +8,7 @@ L.Icon.Text = L.Icon.extend({
var el = document.createElement('div'); var el = document.createElement('div');
el.appendChild(document.createTextNode(this._text)); el.appendChild(document.createTextNode(this._text));
this._setIconStyles(el, 'icon'); this._setIconStyles(el, 'icon');
el.style.textShadow = "2px 2px 2px #fff"; el.style.textShadow = '2px 2px 2px #fff';
return el; return el;
}, },
@ -25,7 +25,7 @@ L.Marker.Text = L.Marker.extend({
_initIcon: function() { _initIcon: function() {
L.Marker.prototype._initIcon.apply(this); L.Marker.prototype._initIcon.apply(this);
var i = this._icon, s = this._shadow, obj = this.options.icon var i = this._icon, s = this._shadow, obj = this.options.icon;
this._icon = this._shadow = null; this._icon = this._shadow = null;
this.options.icon = this._fakeicon; this.options.icon = this._fakeicon;
@ -41,7 +41,7 @@ L.Marker.Text = L.Marker.extend({
this._icon.appendChild(i); this._icon.appendChild(i);
var w = this._icon.clientWidth, h = this._icon.clientHeight; var w = this._icon.clientWidth, h = this._icon.clientHeight;
this._icon.style.marginLeft = -w / 2 + "px"; this._icon.style.marginLeft = -w / 2 + 'px';
//this._icon.style.backgroundColor = "red"; //this._icon.style.backgroundColor = "red";
var off = new L.Point(w/2, 0); var off = new L.Point(w/2, 0);
if (L.Browser.webkit) off.y = -h; if (L.Browser.webkit) off.y = -h;

View file

@ -1,9 +1,10 @@
/* global alert: true */
L.OpenStreetBugs = L.FeatureGroup.extend({ L.OpenStreetBugs = L.FeatureGroup.extend({
options : { options : {
serverURL : "http://openstreetbugs.schokokeks.org/api/0.1/", serverURL : 'http://openstreetbugs.schokokeks.org/api/0.1/',
readonly : false, readonly : false,
setCookie : true, setCookie : true,
username : "NoName", username : 'NoName',
cookieLifetime : 1000, cookieLifetime : 1000,
cookiePath : null, cookiePath : null,
permalinkZoom : 14, permalinkZoom : 14,
@ -11,8 +12,8 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
opacity : 0.7, opacity : 0.7,
showOpen: true, showOpen: true,
showClosed: true, showClosed: true,
iconOpen: "http://openstreetbugs.schokokeks.org/client/open_bug_marker.png", iconOpen: 'http://openstreetbugs.schokokeks.org/client/open_bug_marker.png',
iconClosed:"http://openstreetbugs.schokokeks.org/client/closed_bug_marker.png", iconClosed:'http://openstreetbugs.schokokeks.org/client/closed_bug_marker.png',
iconActive: undefined, iconActive: undefined,
editArea: 0.01, editArea: 0.01,
popupOptions: {autoPan: false}, popupOptions: {autoPan: false},
@ -21,8 +22,8 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
initialize : function(options) initialize : function(options)
{ {
var tmp = L.Util.extend({}, this.options.popupOptions, (options || {}).popupOptions) var tmp = L.Util.extend({}, this.options.popupOptions, (options || {}).popupOptions);
L.Util.setOptions(this, options) L.Util.setOptions(this, options);
this.options.popupOptions = tmp; this.options.popupOptions = tmp;
putAJAXMarker.layers.push(this); putAJAXMarker.layers.push(this);
@ -30,7 +31,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
this.bugs = {}; this.bugs = {};
this._layers = {}; this._layers = {};
var username = this.get_cookie("osbUsername"); var username = this.get_cookie('osbUsername');
if (username) if (username)
this.options.username = username; this.options.username = username;
@ -41,7 +42,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
{ {
L.FeatureGroup.prototype.onAdd.apply(this, [map]); L.FeatureGroup.prototype.onAdd.apply(this, [map]);
this._map.on("moveend", this.loadBugs, this); this._map.on('moveend', this.loadBugs, this);
this.loadBugs(); this.loadBugs();
if (!this.options.readonly) { if (!this.options.readonly) {
if (this.options.dblClick) { if (this.options.dblClick) {
@ -57,7 +58,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
onRemove : function(map) onRemove : function(map)
{ {
this._map.off("moveend", this.loadBugs, this); this._map.off('moveend', this.loadBugs, this);
this._iterateLayers(map.removeLayer, map); this._iterateLayers(map.removeLayer, map);
delete this._map; delete this._map;
if (!this.options.readonly) { if (!this.options.readonly) {
@ -75,7 +76,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
set_cookie : function(name, value) set_cookie : function(name, value)
{ {
var expires = (new Date((new Date()).getTime() + 604800000)).toGMTString(); // one week from now var expires = (new Date((new Date()).getTime() + 604800000)).toGMTString(); // one week from now
document.cookie = name+"="+escape(value)+";"; document.cookie = name+'='+encodeURIComponent(value)+';';
}, },
get_cookie : function(name) get_cookie : function(name)
@ -83,9 +84,9 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
var cookies = (document.cookie || '').split(/;\s*/); var cookies = (document.cookie || '').split(/;\s*/);
for(var i=0; i<cookies.length; i++) for(var i=0; i<cookies.length; i++)
{ {
var cookie = cookies[i].split("="); var cookie = cookies[i].split('=');
if(cookie[0] == name) if(cookie[0] === name)
return unescape(cookie[1]); return decodeURIComponent(cookie[1]);
} }
return null; return null;
}, },
@ -104,18 +105,18 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
return Math.round(number*factor)/factor; return Math.round(number*factor)/factor;
} }
this.apiRequest("getBugs" this.apiRequest('getBugs'
+ "?t="+round(ne.lat, 5) + '?t='+round(ne.lat, 5)
+ "&r="+round(ne.lng, 5) + '&r='+round(ne.lng, 5)
+ "&b="+round(sw.lat, 5) + '&b='+round(sw.lat, 5)
+ "&l="+round(sw.lng, 5)); + '&l='+round(sw.lng, 5));
}, },
apiRequest : function(url, reload) apiRequest : function(url, reload)
{ {
var script = document.createElement("script"); var script = document.createElement('script');
script.type = "text/javascript"; script.type = 'text/javascript';
script.src = this.options.serverURL + url + "&nocache="+(new Date()).getTime(); script.src = this.options.serverURL + url + '&nocache='+(new Date()).getTime();
var _this = this; var _this = this;
script.onload = function(e) { script.onload = function(e) {
document.body.removeChild(this); document.body.removeChild(this);
@ -129,7 +130,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
var bug = putAJAXMarker.bugs[id]; var bug = putAJAXMarker.bugs[id];
if(this.bugs[id]) if(this.bugs[id])
{ {
if (force || this.bugs[id].osb.closed != bug[2]) if (force || this.bugs[id].osb.closed !== bug[2])
this.removeLayer(this.bugs[id]); this.removeLayer(this.bugs[id]);
else else
return; return;
@ -146,7 +147,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
icon_url = this.options.iconClosed; icon_url = this.options.iconClosed;
class_popup += ' osbClosed'; class_popup += ' osbClosed';
} }
else if (bug[1].length == 1) { else if (bug[1].length === 1) {
icon_url = this.options.iconOpen; icon_url = this.options.iconOpen;
class_popup += ' osbOpen'; class_popup += ' osbOpen';
} }
@ -167,10 +168,10 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
this.setPopupContent(id); this.setPopupContent(id);
feature._popup.options.className += class_popup; feature._popup.options.className += class_popup;
if (this.options.bugid && (parseInt(this.options.bugid) == id)) if (this.options.bugid && (parseInt(this.options.bugid) === id))
feature.openPopup(); feature.openPopup();
//this.events.triggerEvent("markerAdded"); //this.events.triggerEvent('markerAdded');
}, },
osbIcon : L.Icon.extend({ osbIcon : L.Icon.extend({
@ -196,26 +197,26 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
var newContent = L.DomUtil.create('div', 'osb-popup'); var newContent = L.DomUtil.create('div', 'osb-popup');
var h1 = L.DomUtil.create('h1', null, newContent); var h1 = L.DomUtil.create('h1', null, newContent);
if (rawbug[2]) if (rawbug[2])
h1.textContent = L.i18n("Fixed Error"); h1.textContent = L.i18n('Fixed Error');
else if (rawbug[1].length == 1) else if (rawbug[1].length === 1)
h1.textContent = L.i18n("Unresolved Error"); h1.textContent = L.i18n('Unresolved Error');
else else
h1.textContent = L.i18n("Active Error"); h1.textContent = L.i18n('Active Error');
var divinfo = L.DomUtil.create('div', 'osb-info', newContent); var divinfo = L.DomUtil.create('div', 'osb-info', newContent);
var table = L.DomUtil.create('table', 'osb-table', divinfo); var table = L.DomUtil.create('table', 'osb-table', divinfo);
for(var i=0; i<rawbug[1].length; i++) for(var i=0; i<rawbug[1].length; i++)
{ {
var tr = L.DomUtil.create('tr', "osb-tr-info", table); var tr = L.DomUtil.create('tr', 'osb-tr-info', table);
tr.setAttribute("valign","top") tr.setAttribute('valign','top');
var td = L.DomUtil.create('td', "osb-td-nickname", tr); var td_nickname = L.DomUtil.create('td', 'osb-td-nickname', tr);
td.textContent = rawbug[5][i] + ':'; td_nickname.textContent = rawbug[5][i] + ':';
var td = L.DomUtil.create('td', "osb-td-datetime", tr); var td_datetime = L.DomUtil.create('td', 'osb-td-datetime', tr);
td.textContent = rawbug[6][i]; td_datetime.textContent = rawbug[6][i];
var td = L.DomUtil.create('td', "osb-td-comment", L.DomUtil.create('tr', "osb-tr-comment", table)); var td_comment = L.DomUtil.create('td', 'osb-td-comment', L.DomUtil.create('tr', 'osb-tr-comment', table));
td.setAttribute("colspan","2"); td_comment.setAttribute('colspan','2');
td.setAttribute("charoff","2"); td_comment.setAttribute('charoff','2');
td.textContent = rawbug[4][i]; td_comment.textContent = rawbug[4][i];
} }
function create_link(ul, text) { function create_link(ul, text) {
@ -224,7 +225,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
a.href = '#'; a.href = '#';
a.textContent = L.i18n(text); a.textContent = L.i18n(text);
return a; return a;
}; }
var ul = L.DomUtil.create('ul', null, newContent); var ul = L.DomUtil.create('ul', null, newContent);
var _this = this; var _this = this;
@ -239,7 +240,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
h1.textContent = h1.textContent_old; h1.textContent = h1.textContent_old;
newContent.removeChild(form); newContent.removeChild(form);
newContent.appendChild(ul); newContent.appendChild(ul);
} };
form.ok.onclick = function(e) { form.ok.onclick = function(e) {
bug.closePopup(); bug.closePopup();
if (!add_comment) if (!add_comment)
@ -251,26 +252,26 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
newContent.appendChild(form); newContent.appendChild(form);
newContent.removeChild(ul); newContent.removeChild(ul);
return false; return false;
}; }
if (!isclosed && !this.options.readonly) { if (!isclosed && !this.options.readonly) {
var a; var a;
a = create_link(ul, "Add comment"); a = create_link(ul, 'Add comment');
a.onclick = function(e) { return showComment("Add comment", true); } a.onclick = function(e) { return showComment('Add comment', true); };
a = create_link(ul, "Mark as Fixed"); a = create_link(ul, 'Mark as Fixed');
a.onclick = function(e) { return showComment("Close bug", false); } a.onclick = function(e) { return showComment('Close bug', false); };
} }
var a = create_link(ul, "JOSM"); var a_josm = create_link(ul, 'JOSM');
a.onclick = function() { _this.remoteEdit(rawbug[0]); }; a_josm.onclick = function() { _this.remoteEdit(rawbug[0]); };
var a = create_link(ul, "Link"); var a_link = create_link(ul, 'Link');
var vars = {lat:rawbug[0].lat, lon:rawbug[0].lng, zoom:this.options.permalinkZoom, bugid:id} var vars = {lat:rawbug[0].lat, lon:rawbug[0].lng, zoom:this.options.permalinkZoom, bugid:id};
if (this.options.permalinkUrl) if (this.options.permalinkUrl)
a.href = L.Util.template(this.options.permalinkUrl, vars) a_link.href = L.Util.template(this.options.permalinkUrl, vars);
else else
a.href = location.protocol + '//' + location.host + location.pathname + a_link.href = location.protocol + '//' + location.host + location.pathname +
L.Util.getParamString(vars) L.Util.getParamString(vars);
bug._popup_content = newContent; bug._popup_content = newContent;
@ -283,26 +284,26 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
submitComment: function(form) { submitComment: function(form) {
if (!form.osbcomment.value) return; if (!form.osbcomment.value) return;
var nickname = form.osbnickname.value || this.options.username; var nickname = form.osbnickname.value || this.options.username;
this.apiRequest("editPOIexec" this.apiRequest('editPOIexec'
+ "?id="+encodeURIComponent(form.osbid.value) + '?id='+encodeURIComponent(form.osbid.value)
+ "&text="+encodeURIComponent(form.osbcomment.value + " [" + nickname + "]") + '&text='+encodeURIComponent(form.osbcomment.value + ' [' + nickname + ']')
+ "&format=js", true + '&format=js', true
); );
this.set_cookie("osbUsername",nickname); this.set_cookie('osbUsername',nickname);
this.options.username=nickname; this.options.username=nickname;
}, },
closeBug: function(form) { closeBug: function(form) {
var id = form.osbid.value; var id = form.osbid.value;
this.submitComment(form); this.submitComment(form);
this.apiRequest("closePOIexec" this.apiRequest('closePOIexec'
+ "?id="+encodeURIComponent(id) + '?id='+encodeURIComponent(id)
+ "&format=js", true + '&format=js', true
); );
}, },
createCommentForm: function(elt) { createCommentForm: function(elt) {
var form = L.DomUtil.create("form", 'osb-add-comment', elt); var form = L.DomUtil.create('form', 'osb-add-comment', elt);
var content = ''; var content = '';
content += '<input name="osbid" type="hidden"/>'; content += '<input name="osbid" type="hidden"/>';
content += '<input name="osblat" type="hidden"/>'; content += '<input name="osblat" type="hidden"/>';
@ -320,27 +321,27 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
addBug: function(e) { addBug: function(e) {
var newContent = L.DomUtil.create('div', 'osb-popup'); var newContent = L.DomUtil.create('div', 'osb-popup');
newContent.innerHTML += '<h1>'+L.i18n("New bug")+'</h1>'; newContent.innerHTML += '<h1>'+L.i18n('New bug')+'</h1>';
newContent.innerHTML += '<div class="osbCreateInfo">'+L.i18n("Find your bug?")+'<br />'+L.i18n("Contact details and someone will fix it.")+'</div>'; newContent.innerHTML += '<div class="osbCreateInfo">'+L.i18n('Find your bug?')+'<br />'+L.i18n('Contact details and someone will fix it.')+'</div>';
var popup = new L.Popup(); var popup = new L.Popup();
var _this = this; var _this = this;
var form = this.createCommentForm(newContent); var form = this.createCommentForm(newContent);
form.osblat.value = e.latlng.lat; form.osblat.value = e.latlng.lat;
form.osblon.value = e.latlng.lng; form.osblon.value = e.latlng.lng;
form.ok.value = L.i18n("Add comment"); form.ok.value = L.i18n('Add comment');
form.onsubmit = function(e) { form.onsubmit = function(e) {
_this._map.closePopup(popup); _this._map.closePopup(popup);
_this.createBug(form); _this.createBug(form);
return false; return false;
}; };
form.cancel.onclick = function(e) { _this._map.closePopup(popup); } form.cancel.onclick = function(e) { _this._map.closePopup(popup); };
popup.setLatLng(e.latlng); popup.setLatLng(e.latlng);
popup.setContent(newContent); popup.setContent(newContent);
popup.options.maxWidth=410; popup.options.maxWidth=410;
popup.options.minWidth=410; popup.options.minWidth=410;
popup.options.className += ' osb osbCreate' popup.options.className += ' osb osbCreate';
this._map.openPopup(popup); this._map.openPopup(popup);
}, },
@ -348,21 +349,20 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
createBug: function(form) { createBug: function(form) {
if (!form.osbcomment.value) return; if (!form.osbcomment.value) return;
var nickname = form.osbnickname.value || this.options.username; var nickname = form.osbnickname.value || this.options.username;
this.apiRequest("addPOIexec" this.apiRequest('addPOIexec'
+ "?lat="+encodeURIComponent(form.osblat.value) + '?lat='+encodeURIComponent(form.osblat.value)
+ "&lon="+encodeURIComponent(form.osblon.value) + '&lon='+encodeURIComponent(form.osblon.value)
+ "&text="+encodeURIComponent(form.osbcomment.value + " [" + nickname + "]") + '&text='+encodeURIComponent(form.osbcomment.value + ' [' + nickname + ']')
+ "&format=js", true + '&format=js', true
); );
this.set_cookie("osbUsername",nickname); this.set_cookie('osbUsername',nickname);
this.options.username=nickname; this.options.username=nickname;
}, },
remoteEdit: function(x) { remoteEdit: function(x) {
var ydelta = this.options.editArea || 0.01; var ydelta = this.options.editArea || 0.01;
var xdelta = ydelta * 2; var xdelta = ydelta * 2;
var p = [ 'left=' + (x.lng - xdelta), 'bottom=' + (x.lat - ydelta) var p = [ 'left=' + (x.lng - xdelta), 'bottom=' + (x.lat - ydelta), 'right=' + (x.lng + xdelta), 'top=' + (x.lat + ydelta)];
, 'right=' + (x.lng + xdelta), 'top=' + (x.lat + ydelta)];
var url = 'http://localhost:8111/load_and_zoom?' + p.join('&'); var url = 'http://localhost:8111/load_and_zoom?' + p.join('&');
var frame = L.DomUtil.create('iframe', null); var frame = L.DomUtil.create('iframe', null);
frame.style.display = 'none'; frame.style.display = 'none';
@ -371,7 +371,7 @@ L.OpenStreetBugs = L.FeatureGroup.extend({
frame.onload = function(e) { document.body.removeChild(frame); }; frame.onload = function(e) { document.body.removeChild(frame); };
return false; return false;
} }
}) });
L.OpenStreetBugs.setCSS = function() { L.OpenStreetBugs.setCSS = function() {
if(L.OpenStreetBugs.setCSS.done) if(L.OpenStreetBugs.setCSS.done)
@ -387,40 +387,41 @@ L.OpenStreetBugs.setCSS = function() {
if(s.addRule) // M$IE if(s.addRule) // M$IE
rule = s.addRule(selector, rules, idx); rule = s.addRule(selector, rules, idx);
else else
rule = s.insertRule(selector + " { " + rules + " }", idx); rule = s.insertRule(selector + ' { ' + rules + ' }', idx);
s.style = L.Util.extend(s.style || {}, rules); s.style = L.Util.extend(s.style || {}, rules);
idx++; idx++;
}; };
addRule(".osb-popup dl", 'margin:0; padding:0;'); addRule('.osb-popup dl', 'margin:0; padding:0;');
addRule(".osb-popup dt", 'margin:0; padding:0; font-weight:bold; float:left; clear:left;'); addRule('.osb-popup dt', 'margin:0; padding:0; font-weight:bold; float:left; clear:left;');
addRule(".osb-popup dt:after", 'content: ": ";'); addRule('.osb-popup dt:after', 'content: ": ";');
addRule("* html .osb-popup dt", 'margin-right:1ex;'); addRule('* html .osb-popup dt', 'margin-right:1ex;');
addRule(".osb-popup dd", 'margin:0; padding:0;'); addRule('.osb-popup dd', 'margin:0; padding:0;');
addRule(".osb-popup ul.buttons", 'list-style-type:none; padding:0; margin:0;'); addRule('.osb-popup ul.buttons', 'list-style-type:none; padding:0; margin:0;');
addRule(".osb-popup ul.buttons li", 'display:inline; margin:0; padding:0;'); addRule('.osb-popup ul.buttons li', 'display:inline; margin:0; padding:0;');
addRule(".osb-popup h3", 'font-size:1.2em; margin:.2em 0 .7em 0;'); addRule('.osb-popup h3', 'font-size:1.2em; margin:.2em 0 .7em 0;');
}; };
function putAJAXMarker(id, lon, lat, text, closed) function putAJAXMarker(id, lon, lat, text, closed)
{ {
var comments = text.split(/<hr \/>/); var comments = text.split(/<hr \/>/);
var comments_only = [] var comments_only = [];
var nickname = []; var nickname = [];
var datetime = []; var datetime = [];
var info = null; var info = null;
var isplit = 0; var isplit = 0;
for(var i=0; i<comments.length; i++) { var i;
for(i=0; i<comments.length; i++) {
info = null; info = null;
isplit = 0; isplit = 0;
comments[i] = comments[i].replace(/&quot;/g, "\"").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&"); comments[i] = comments[i].replace(/&quot;/g, '"').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
isplit = comments[i].lastIndexOf("["); isplit = comments[i].lastIndexOf('[');
if (isplit > 0) { if (isplit > 0) {
comments_only[i] = comments[i].substr(0,isplit-1); comments_only[i] = comments[i].substr(0,isplit-1);
info = comments[i].substr(isplit+1); info = comments[i].substr(isplit+1);
nickname[i] = info.substr(0,info.lastIndexOf(",")); nickname[i] = info.substr(0,info.lastIndexOf(','));
datetime[i] = info.substr(info.lastIndexOf(",")+2); datetime[i] = info.substr(info.lastIndexOf(',')+2);
datetime[i] = datetime[i].substr(0,datetime[i].lastIndexOf("]")); datetime[i] = datetime[i].substr(0,datetime[i].lastIndexOf(']'));
} }
else { else {
comments_only[i] = comments[i]; comments_only[i] = comments[i];
@ -436,19 +437,17 @@ function putAJAXMarker(id, lon, lat, text, closed)
nickname, nickname,
datetime datetime
]; ];
var force = (old && old[3]) != text; var force = (old && old[3]) !== text;
for(var i=0; i<putAJAXMarker.layers.length; i++) for(i=0; i<putAJAXMarker.layers.length; i++)
putAJAXMarker.layers[i].createMarker(id, force); putAJAXMarker.layers[i].createMarker(id, force);
} }
function osbResponse(error) function osbResponse(error)
{ {
if(error) if(error)
alert("Error: "+error); alert('Error: '+error);
return; return;
for(var i=0; i<putAJAXMarker.layers.length; i++)
putAJAXMarker.layers[i].loadBugs();
} }
putAJAXMarker.layers = [ ]; putAJAXMarker.layers = [ ];
@ -462,36 +461,36 @@ L.Marker.include({
function onclick() { function onclick() {
this.off('mouseout', onout, this); this.off('mouseout', onout, this);
this.off('click', onclick, this); this.off('click', onclick, this);
this.on('click', this.openPopup, this) this.on('click', this.openPopup, this);
} }
function onout() { function onout() {
onclick.call(this); onclick.call(this);
this.closePopup(); this.closePopup();
}; }
this.on("mouseout", onout, this); this.on('mouseout', onout, this);
this.on("click", onclick, this); this.on('click', onclick, this);
} }
}); });
L.i18n = function(s) { return (L.i18n.lang[L.i18n.current] || {})[s] || s; } L.i18n = function(s) { return (L.i18n.lang[L.i18n.current] || {})[s] || s; };
L.i18n.current = 'ru'; L.i18n.current = 'ru';
L.i18n.lang = {}; L.i18n.lang = {};
L.i18n.extend = function(lang, args) { L.i18n.extend = function(lang, args) {
L.i18n.lang[lang] = L.Util.extend(L.i18n.lang[lang] || {}, args) L.i18n.lang[lang] = L.Util.extend(L.i18n.lang[lang] || {}, args);
}; };
L.i18n.extend('ru', { L.i18n.extend('ru', {
"Fixed Error":"Ошибка исправлена", 'Fixed Error':'Ошибка исправлена',
"Unresolved Error":"Неисправленная ошибка", 'Unresolved Error':'Неисправленная ошибка',
"Active Error":"Ошибка уточняется", 'Active Error':'Ошибка уточняется',
"Description":"Описание", 'Description':'Описание',
"Comment":"Описание", 'Comment':'Описание',
"Add comment":"Дополнить", 'Add comment':'Дополнить',
"Mark as Fixed":"Исправлено", 'Mark as Fixed':'Исправлено',
"Link":"Ссылка", 'Link':'Ссылка',
"Cancel":"Отмена", 'Cancel':'Отмена',
"New bug":"Я нашел ошибку", 'New bug':'Я нашел ошибку',
"Find your bug?":"Нашли ошибку?", 'Find your bug?':'Нашли ошибку?',
"Contact details and someone will fix it.":"Напишите подробнее и кто-нибудь её исправит." 'Contact details and someone will fix it.':'Напишите подробнее и кто-нибудь её исправит.'
}); });

View file

@ -1,3 +1,4 @@
/* global console: true */
L.BingLayer = L.TileLayer.extend({ L.BingLayer = L.TileLayer.extend({
options: { options: {
subdomains: [0, 1, 2, 3], subdomains: [0, 1, 2, 3],
@ -20,20 +21,19 @@ L.BingLayer = L.TileLayer.extend({
for (var i = z; i > 0; i--) { for (var i = z; i > 0; i--) {
var digit = 0; var digit = 0;
var mask = 1 << (i - 1); var mask = 1 << (i - 1);
if ((x & mask) != 0) digit += 1; if ((x & mask) !== 0) digit += 1;
if ((y & mask) != 0) digit += 2; if ((y & mask) !== 0) digit += 2;
quad = quad + digit; quad = quad + digit;
} }
return quad; return quad;
}, },
getTileUrl: function(p, z) { getTileUrl: function(p, z) {
var z = this._getZoomForUrl(); var zoom = this._getZoomForUrl();
var subdomains = this.options.subdomains, var subdomains = this.options.subdomains,
s = this.options.subdomains[Math.abs((p.x + p.y) % subdomains.length)]; s = this.options.subdomains[Math.abs((p.x + p.y) % subdomains.length)];
return this._url.replace('{subdomain}', s) return this._url.replace('{subdomain}', s)
.replace('{quadkey}', this.tile2quad(p.x, p.y, z)) .replace('{quadkey}', this.tile2quad(p.x, p.y, zoom))
.replace('http:', document.location.protocol)
.replace('{culture}', this.options.culture); .replace('{culture}', this.options.culture);
}, },
@ -46,17 +46,18 @@ L.BingLayer = L.TileLayer.extend({
var e = document.getElementById(cbid); var e = document.getElementById(cbid);
e.parentNode.removeChild(e); e.parentNode.removeChild(e);
if (meta.errorDetails) { if (meta.errorDetails) {
if (window.console) console.log("Leaflet Bing Plugin Error - Got metadata: " + meta.errorDetails); if (window.console) console.log('Leaflet Bing Plugin Error - Got metadata: ' + meta.errorDetails);
return; return;
} }
_this.initMetadata(); _this.initMetadata();
}; };
var url = document.location.protocol + "//dev.virtualearth.net/REST/v1/Imagery/Metadata/" + this.options.type + "?include=ImageryProviders&jsonp=" + cbid + "&key=" + this._key; var url = document.location.protocol + '//dev.virtualearth.net/REST/v1/Imagery/Metadata/' + this.options.type + '?include=ImageryProviders&jsonp=' + cbid +
var script = document.createElement("script"); '&key=' + this._key + '&UriScheme=' + document.location.protocol.slice(0, -1);
script.type = "text/javascript"; var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url; script.src = url;
script.id = cbid; script.id = cbid;
document.getElementsByTagName("head")[0].appendChild(script); document.getElementsByTagName('head')[0].appendChild(script);
}, },
initMetadata: function() { initMetadata: function() {
@ -84,7 +85,7 @@ L.BingLayer = L.TileLayer.extend({
}, },
_update: function() { _update: function() {
if (this._url == null || !this._map) return; if (this._url === null || !this._map) return;
this._update_attribution(); this._update_attribution();
L.TileLayer.prototype._update.apply(this, []); L.TileLayer.prototype._update.apply(this, []);
}, },

View file

@ -1,7 +1,8 @@
/* /*
* Google layer using Google Maps API * Google layer using Google Maps API
*/ */
//(function (google, L) {
/* global google: true */
L.Google = L.Class.extend({ L.Google = L.Class.extend({
includes: L.Mixin.Events, includes: L.Mixin.Events,
@ -25,7 +26,7 @@ L.Google = L.Class.extend({
initialize: function(type, options) { initialize: function(type, options) {
L.Util.setOptions(this, options); L.Util.setOptions(this, options);
this._ready = google.maps.Map != undefined; this._ready = google.maps.Map !== undefined;
if (!this._ready) L.Google.asyncWait.push(this); if (!this._ready) L.Google.asyncWait.push(this);
this._type = type || 'SATELLITE'; this._type = type || 'SATELLITE';
@ -48,7 +49,7 @@ L.Google = L.Class.extend({
map.on('zoomanim', this._handleZoomAnim, this); map.on('zoomanim', this._handleZoomAnim, this);
//20px instead of 1em to avoid a slight overlap with google's attribution //20px instead of 1em to avoid a slight overlap with google's attribution
map._controlCorners['bottomright'].style.marginBottom = "20px"; map._controlCorners.bottomright.style.marginBottom = '20px';
this._reset(); this._reset();
this._update(); this._update();
@ -64,7 +65,7 @@ L.Google = L.Class.extend({
this._map.off('zoomanim', this._handleZoomAnim, this); this._map.off('zoomanim', this._handleZoomAnim, this);
map._controlCorners['bottomright'].style.marginBottom = "0em"; map._controlCorners.bottomright.style.marginBottom = '0em';
//this._map.off('moveend', this._update, this); //this._map.off('moveend', this._update, this);
}, },
@ -80,8 +81,8 @@ L.Google = L.Class.extend({
}, },
setElementSize: function(e, size) { setElementSize: function(e, size) {
e.style.width = size.x + "px"; e.style.width = size.x + 'px';
e.style.height = size.y + "px"; e.style.height = size.y + 'px';
}, },
_initContainer: function() { _initContainer: function() {
@ -90,16 +91,14 @@ L.Google = L.Class.extend({
if (!this._container) { if (!this._container) {
this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left'); this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left');
this._container.id = "_GMapContainer_" + L.Util.stamp(this); this._container.id = '_GMapContainer_' + L.Util.stamp(this);
this._container.style.zIndex = "auto"; this._container.style.zIndex = 'auto';
} }
if (true) {
tilePane.insertBefore(this._container, first); tilePane.insertBefore(this._container, first);
this.setOpacity(this.options.opacity); this.setOpacity(this.options.opacity);
this.setElementSize(this._container, this._map.getSize()); this.setElementSize(this._container, this._map.getSize());
}
}, },
_initMapObject: function() { _initMapObject: function() {
@ -121,11 +120,11 @@ L.Google = L.Class.extend({
}); });
var _this = this; var _this = this;
this._reposition = google.maps.event.addListenerOnce(map, "center_changed", this._reposition = google.maps.event.addListenerOnce(map, 'center_changed',
function() { _this.onReposition(); }); function() { _this.onReposition(); });
this._google = map; this._google = map;
google.maps.event.addListenerOnce(map, "idle", google.maps.event.addListenerOnce(map, 'idle',
function() { _this._checkZoomLevels(); }); function() { _this._checkZoomLevels(); });
}, },
@ -163,8 +162,8 @@ L.Google = L.Class.extend({
_resize: function() { _resize: function() {
var size = this._map.getSize(); var size = this._map.getSize();
if (this._container.style.width == size.x && if (this._container.style.width === size.x &&
this._container.style.height == size.y) this._container.style.height === size.y)
return; return;
this.setElementSize(this._container, size); this.setElementSize(this._container, size);
this.onReposition(); this.onReposition();
@ -182,7 +181,7 @@ L.Google = L.Class.extend({
onReposition: function() { onReposition: function() {
if (!this._google) return; if (!this._google) return;
google.maps.event.trigger(this._google, "resize"); google.maps.event.trigger(this._google, 'resize');
} }
}); });
@ -199,4 +198,3 @@ L.Google.asyncInitialize = function() {
} }
L.Google.asyncWait = []; L.Google.asyncWait = [];
}; };
//})(window.google, L)

View file

@ -1,7 +1,9 @@
/* /*
* L.TileLayer is used for standard xyz-numbered tile layers. * L.TileLayer is used for standard xyz-numbered tile layers.
*/ */
//(function (ymaps, L) {
/* global ymaps: true */
/* global console: true */
L.Yandex = L.Class.extend({ L.Yandex = L.Class.extend({
includes: L.Mixin.Events, includes: L.Mixin.Events,
@ -18,7 +20,7 @@ L.Yandex = L.Class.extend({
initialize: function(type, options) { initialize: function(type, options) {
L.Util.setOptions(this, options); L.Util.setOptions(this, options);
this._type = "yandex#" + (type || 'map'); this._type = 'yandex#' + (type || 'map');
}, },
onAdd: function(map, insertAtTheBottom) { onAdd: function(map, insertAtTheBottom) {
@ -35,7 +37,7 @@ L.Yandex = L.Class.extend({
this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this); this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this);
map.on('move', this._update, this); map.on('move', this._update, this);
map._controlCorners['bottomright'].style.marginBottom = "3em"; map._controlCorners.bottomright.style.marginBottom = '3em';
this._reset(); this._reset();
this._update(true); this._update(true);
@ -48,7 +50,7 @@ L.Yandex = L.Class.extend({
this._map.off('move', this._update, this); this._map.off('move', this._update, this);
map._controlCorners['bottomright'].style.marginBottom = "0em"; map._controlCorners.bottomright.style.marginBottom = '0em';
}, },
getAttribution: function() { getAttribution: function() {
@ -63,8 +65,8 @@ L.Yandex = L.Class.extend({
}, },
setElementSize: function(e, size) { setElementSize: function(e, size) {
e.style.width = size.x + "px"; e.style.width = size.x + 'px';
e.style.height = size.y + "px"; e.style.height = size.y + 'px';
}, },
_initContainer: function() { _initContainer: function() {
@ -73,8 +75,8 @@ L.Yandex = L.Class.extend({
if (!this._container) { if (!this._container) {
this._container = L.DomUtil.create('div', 'leaflet-yandex-layer leaflet-top leaflet-left'); this._container = L.DomUtil.create('div', 'leaflet-yandex-layer leaflet-top leaflet-left');
this._container.id = "_YMapContainer_" + L.Util.stamp(this); this._container.id = '_YMapContainer_' + L.Util.stamp(this);
this._container.style.zIndex = "auto"; this._container.style.zIndex = 'auto';
} }
if (this.options.overlay) { if (this.options.overlay) {
@ -82,7 +84,7 @@ L.Yandex = L.Class.extend({
first = first.nextSibling; first = first.nextSibling;
// XXX: Bug with layer order // XXX: Bug with layer order
if (L.Browser.opera) if (L.Browser.opera)
this._container.className += " leaflet-objects-pane"; this._container.className += ' leaflet-objects-pane';
} }
tilePane.insertBefore(this._container, first); tilePane.insertBefore(this._container, first);
@ -96,9 +98,9 @@ L.Yandex = L.Class.extend({
// Check that ymaps.Map is ready // Check that ymaps.Map is ready
if (ymaps.Map === undefined) { if (ymaps.Map === undefined) {
if (console) { if (console) {
console.debug("L.Yandex: Waiting on ymaps.load('package.map')"); console.debug('L.Yandex: Waiting on ymaps.load("package.map")');
} }
return ymaps.load(["package.map"], this._initMapObject, this); return ymaps.load(['package.map'], this._initMapObject, this);
} }
// If traffic layer is requested check if control.TrafficControl is ready // If traffic layer is requested check if control.TrafficControl is ready
@ -106,9 +108,9 @@ L.Yandex = L.Class.extend({
if (ymaps.control === undefined || if (ymaps.control === undefined ||
ymaps.control.TrafficControl === undefined) { ymaps.control.TrafficControl === undefined) {
if (console) { if (console) {
console.debug("L.Yandex: loading traffic and controls"); console.debug('L.Yandex: loading traffic and controls');
} }
return ymaps.load(["package.traffic", "package.controls"], return ymaps.load(['package.traffic', 'package.controls'],
this._initMapObject, this); this._initMapObject, this);
} }
@ -117,9 +119,9 @@ L.Yandex = L.Class.extend({
if (this.options.traffic) if (this.options.traffic)
map.controls.add(new ymaps.control.TrafficControl({shown: true})); map.controls.add(new ymaps.control.TrafficControl({shown: true}));
if (this._type == "yandex#null") { if (this._type === 'yandex#null') {
this._type = new ymaps.MapType("null", []); this._type = new ymaps.MapType('null', []);
map.container.getElement().style.background = "transparent"; map.container.getElement().style.background = 'transparent';
} }
map.setType(this._type); map.setType(this._type);
@ -143,19 +145,17 @@ L.Yandex = L.Class.extend({
var _center = [center.lat, center.lng]; var _center = [center.lat, center.lng];
var zoom = this._map.getZoom(); var zoom = this._map.getZoom();
if (force || this._yandex.getZoom() != zoom) if (force || this._yandex.getZoom() !== zoom)
this._yandex.setZoom(zoom); this._yandex.setZoom(zoom);
this._yandex.panTo(_center, {duration: 0, delay: 0}); this._yandex.panTo(_center, {duration: 0, delay: 0});
}, },
_resize: function(force) { _resize: function(force) {
var size = this._map.getSize(), style = this._container.style; var size = this._map.getSize(), style = this._container.style;
if (style.width == size.x + "px" && if (style.width === size.x + 'px' && style.height === size.y + 'px')
style.height == size.y + "px") if (force !== true) return;
if (force != true) return;
this.setElementSize(this._container, size); this.setElementSize(this._container, size);
var b = this._map.getBounds(), sw = b.getSouthWest(), ne = b.getNorthEast(); var b = this._map.getBounds(), sw = b.getSouthWest(), ne = b.getNorthEast();
this._yandex.container.fitToViewport(); this._yandex.container.fitToViewport();
} }
}); });
//})(ymaps, L)

View file

@ -1,4 +1,4 @@
//#include "GPX.js" //#include 'GPX.js'
(function() { (function() {
@ -6,7 +6,7 @@ function d2h(d) {
var hex = '0123456789ABCDEF'; var hex = '0123456789ABCDEF';
var r = ''; var r = '';
d = Math.floor(d); d = Math.floor(d);
while (d != 0) { while (d !== 0) {
r = hex[d % 16] + r; r = hex[d % 16] + r;
d = Math.floor(d / 16); d = Math.floor(d / 16);
} }
@ -18,23 +18,23 @@ function gradient(color) {
// First arc (0, PI) in HSV colorspace // First arc (0, PI) in HSV colorspace
function f2h(d) { return d2h(256 * d); } function f2h(d) { return d2h(256 * d); }
if (color < 0) if (color < 0)
return "#FF0000"; return '#FF0000';
else if (color < 1.0/3) else if (color < 1.0/3)
return "#FF" + f2h(3 * color) + "00"; return '#FF' + f2h(3 * color) + '00';
else if (color < 2.0/3) else if (color < 2.0/3)
return "#" + f2h(2 - 3 * color) + "FF00"; return '#' + f2h(2 - 3 * color) + 'FF00';
else if (color < 1) else if (color < 1)
return "#00FF" + f2h(3 * color - 2); return '#00FF' + f2h(3 * color - 2);
else else
return "#00FFFF"; return '#00FFFF';
}; }
function gpx2time(s) { function gpx2time(s) {
// 2011-09-24T12:07:53Z // 2011-09-24T12:07:53Z
if (s.length != 10 + 1 + 8 + 1) if (s.length !== 10 + 1 + 8 + 1)
return new Date(); return new Date();
return new Date(s); return new Date(s);
}; }
L.GPX.include({ L.GPX.include({
options: { options: {
@ -68,11 +68,11 @@ L.GPX.include({
p = ll[i + chunk - 1]; p = ll[i + chunk - 1];
t = (gpx2time(p.meta.time) - t) / (3600 * 1000); t = (gpx2time(p.meta.time) - t) / (3600 * 1000);
var speed = 0.001 * d / t; var speed = 0.001 * d / t;
//console.info('Dist: ' + d + "; Speed: " + speed); //console.info('Dist: ' + d + '; Speed: ' + speed);
var color = gradient(speed / this.options.maxSpeed); var color = gradient(speed / this.options.maxSpeed);
var l = new L.Polyline(ll.slice(i, i+chunk+1), {color: color, weight: 2, opacity: 1}); var poly = new L.Polyline(ll.slice(i, i+chunk+1), {color: color, weight: 2, opacity: 1});
l.bindPopup('Dist: ' + d.toFixed() + "m; Speed: " + speed.toFixed(2) + " km/h"); poly.bindPopup('Dist: ' + d.toFixed() + 'm; Speed: ' + speed.toFixed(2) + ' km/h');
e.line.push(l); e.line.push(poly);
} }
} }

View file

@ -1,5 +1,3 @@
/*global L: true */
L.GPX = L.FeatureGroup.extend({ L.GPX = L.FeatureGroup.extend({
initialize: function(gpx, options) { initialize: function(gpx, options) {
L.Util.setOptions(this, options); L.Util.setOptions(this, options);
@ -12,8 +10,8 @@ L.GPX = L.FeatureGroup.extend({
}, },
loadXML: function(url, cb, options, async) { loadXML: function(url, cb, options, async) {
if (async == undefined) async = this.options.async; if (async === undefined) async = this.options.async;
if (options == undefined) options = this.options; if (options === undefined) options = this.options;
var req = new window.XMLHttpRequest(); var req = new window.XMLHttpRequest();
req.open('GET', url, async); req.open('GET', url, async);
@ -21,17 +19,17 @@ L.GPX = L.FeatureGroup.extend({
req.overrideMimeType('text/xml'); // unsupported by IE req.overrideMimeType('text/xml'); // unsupported by IE
} catch(e) {} } catch(e) {}
req.onreadystatechange = function() { req.onreadystatechange = function() {
if (req.readyState != 4) return; if (req.readyState !== 4) return;
if(req.status == 200) cb(req.responseXML, options); if(req.status === 200) cb(req.responseXML, options);
}; };
req.send(null); req.send(null);
}, },
_humanLen: function(l) { _humanLen: function(l) {
if (l < 2000) if (l < 2000)
return l.toFixed(0) + " m"; return l.toFixed(0) + ' m';
else else
return (l/1000).toFixed(1) + " km"; return (l/1000).toFixed(1) + ' km';
}, },
_polylineLen: function(line)//line is a L.Polyline() _polylineLen: function(line)//line is a L.Polyline()
@ -49,7 +47,7 @@ L.GPX = L.FeatureGroup.extend({
addGPX: function(url, options, async) { addGPX: function(url, options, async) {
var _this = this; var _this = this;
var cb = function(gpx, options) { _this._addGPX(gpx, options) }; var cb = function(gpx, options) { _this._addGPX(gpx, options); };
this.loadXML(url, cb, options, async); this.loadXML(url, cb, options, async);
}, },
@ -57,7 +55,7 @@ L.GPX = L.FeatureGroup.extend({
var layers = this.parseGPX(gpx, options); var layers = this.parseGPX(gpx, options);
if (!layers) return; if (!layers) return;
this.addLayer(layers); this.addLayer(layers);
this.fire("loaded"); this.fire('loaded');
}, },
parseGPX: function(xml, options) { parseGPX: function(xml, options) {
@ -76,12 +74,12 @@ L.GPX = L.FeatureGroup.extend({
} }
el = xml.getElementsByTagName('wpt'); el = xml.getElementsByTagName('wpt');
if (options.display_wpt != false) { if (options.display_wpt !== false) {
for (i = 0; i < el.length; i++) { for (i = 0; i < el.length; i++) {
var l = this.parse_wpt(el[i], xml, options); var marker = this.parse_wpt(el[i], xml, options);
if (!l) continue; if (!marker) continue;
if (this.parse_name(el[i], l)) named = true; if (this.parse_name(el[i], marker)) named = true;
layers.push(l); layers.push(marker);
} }
} }
@ -94,7 +92,7 @@ L.GPX = L.FeatureGroup.extend({
}, },
parse_name: function(xml, layer) { parse_name: function(xml, layer) {
var i, el, txt="", name, descr="", len=0; var i, el, txt='', name, descr='', len=0;
el = xml.getElementsByTagName('name'); el = xml.getElementsByTagName('name');
if (el.length) if (el.length)
name = el[0].childNodes[0].nodeValue; name = el[0].childNodes[0].nodeValue;
@ -107,8 +105,8 @@ L.GPX = L.FeatureGroup.extend({
if(layer instanceof L.Path) if(layer instanceof L.Path)
len = this._polylineLen(layer); len = this._polylineLen(layer);
if (name) txt += "<h2>" + name + "</h2>" + descr; if (name) txt += '<h2>' + name + '</h2>' + descr;
if (len) txt += "<p>" + this._humanLen(len) + "</p>"; if (len) txt += '<p>' + this._humanLen(len) + '</p>';
if (layer && layer._popup === undefined) layer.bindPopup(txt); if (layer && layer._popup === undefined) layer.bindPopup(txt);
return txt; return txt;
@ -130,7 +128,7 @@ L.GPX = L.FeatureGroup.extend({
coords.push(ll); coords.push(ll);
} }
var l = [new L.Polyline(coords, options)]; var l = [new L.Polyline(coords, options)];
this.fire('addline', {line:l}) this.fire('addline', {line:l});
return l; return l;
}, },

View file

@ -1,5 +1,3 @@
/*global L: true */
L.KML = L.FeatureGroup.extend({ L.KML = L.FeatureGroup.extend({
options: { options: {
async: true async: true
@ -16,8 +14,8 @@ L.KML = L.FeatureGroup.extend({
}, },
loadXML: function(url, cb, options, async) { loadXML: function(url, cb, options, async) {
if (async == undefined) async = this.options.async; if (async === undefined) async = this.options.async;
if (options == undefined) options = this.options; if (options === undefined) options = this.options;
var req = new window.XMLHttpRequest(); var req = new window.XMLHttpRequest();
req.open('GET', url, async); req.open('GET', url, async);
@ -25,30 +23,29 @@ L.KML = L.FeatureGroup.extend({
req.overrideMimeType('text/xml'); // unsupported by IE req.overrideMimeType('text/xml'); // unsupported by IE
} catch(e) {} } catch(e) {}
req.onreadystatechange = function() { req.onreadystatechange = function() {
if (req.readyState != 4) return; if (req.readyState !== 4) return;
if(req.status == 200) cb(req.responseXML, options); if (req.status === 200) cb(req.responseXML, options);
}; };
req.send(null); req.send(null);
}, },
addKML: function(url, options, async) { addKML: function(url, options, async) {
var _this = this; var _this = this;
var cb = function(gpx, options) { _this._addKML(gpx, options) }; var cb = function(gpx, options) { _this._addKML(gpx, options); };
this.loadXML(url, cb, options, async); this.loadXML(url, cb, options, async);
}, },
_addKML: function(xml, options) { _addKML: function(xml, options) {
var layers = L.KML.parseKML(xml); var layers = L.KML.parseKML(xml);
if (!layers || !layers.length) return; if (!layers || !layers.length) return;
for (var i = 0; i < layers.length; i++) for (var i = 0; i < layers.length; i++) {
{
this.fire('addlayer', { this.fire('addlayer', {
layer: layers[i] layer: layers[i]
}); });
this.addLayer(layers[i]); this.addLayer(layers[i]);
} }
this.latLngs = L.KML.getLatLngs(xml); this.latLngs = L.KML.getLatLngs(xml);
this.fire("loaded"); this.fire('loaded');
}, },
latLngs: [] latLngs: []
@ -59,7 +56,7 @@ L.Util.extend(L.KML, {
parseKML: function (xml) { parseKML: function (xml) {
var style = this.parseStyle(xml); var style = this.parseStyle(xml);
this.parseStyleMap(xml, style); this.parseStyleMap(xml, style);
var el = xml.getElementsByTagName("Folder"); var el = xml.getElementsByTagName('Folder');
var layers = [], l; var layers = [], l;
for (var i = 0; i < el.length; i++) { for (var i = 0; i < el.length; i++) {
if (!this._check_folder(el[i])) { continue; } if (!this._check_folder(el[i])) { continue; }
@ -79,7 +76,7 @@ L.Util.extend(L.KML, {
// - returns true if no parent Folders // - returns true if no parent Folders
_check_folder: function (e, folder) { _check_folder: function (e, folder) {
e = e.parentElement; e = e.parentElement;
while (e && e.tagName !== "Folder") while (e && e.tagName !== 'Folder')
{ {
e = e.parentElement; e = e.parentElement;
} }
@ -88,7 +85,7 @@ L.Util.extend(L.KML, {
parseStyle: function (xml) { parseStyle: function (xml) {
var style = {}; var style = {};
var sl = xml.getElementsByTagName("Style"); var sl = xml.getElementsByTagName('Style');
//for (var i = 0; i < sl.length; i++) { //for (var i = 0; i < sl.length; i++) {
var attributes = {color: true, width: true, Icon: true, href: true, var attributes = {color: true, width: true, Icon: true, href: true,
@ -109,7 +106,7 @@ L.Util.extend(L.KML, {
var value = e.childNodes[0].nodeValue; var value = e.childNodes[0].nodeValue;
if (key === 'color') { if (key === 'color') {
options.opacity = parseInt(value.substring(0, 2), 16) / 255.0; options.opacity = parseInt(value.substring(0, 2), 16) / 255.0;
options.color = "#" + value.substring(6, 8) + value.substring(4, 6) + value.substring(2, 4); options.color = '#' + value.substring(6, 8) + value.substring(4, 6) + value.substring(2, 4);
} else if (key === 'width') { } else if (key === 'width') {
options.weight = value; options.weight = value;
} else if (key === 'Icon') { } else if (key === 'Icon') {
@ -126,13 +123,13 @@ L.Util.extend(L.KML, {
for (var i = 0; i < sl.length; i++) { for (var i = 0; i < sl.length; i++) {
var e = sl[i], el; var e = sl[i], el;
var options = {}, poptions = {}, ioptions = {}; var options = {}, poptions = {}, ioptions = {};
el = e.getElementsByTagName("LineStyle"); el = e.getElementsByTagName('LineStyle');
if (el && el[0]) { options = _parse(el[0]); } if (el && el[0]) { options = _parse(el[0]); }
el = e.getElementsByTagName("PolyStyle"); el = e.getElementsByTagName('PolyStyle');
if (el && el[0]) { poptions = _parse(el[0]); } if (el && el[0]) { poptions = _parse(el[0]); }
if (poptions.color) { options.fillColor = poptions.color; } if (poptions.color) { options.fillColor = poptions.color; }
if (poptions.opacity) { options.fillOpacity = poptions.opacity; } if (poptions.opacity) { options.fillOpacity = poptions.opacity; }
el = e.getElementsByTagName("IconStyle"); el = e.getElementsByTagName('IconStyle');
if (el && el[0]) { ioptions = _parse(el[0]); } if (el && el[0]) { ioptions = _parse(el[0]); }
if (ioptions.href) { if (ioptions.href) {
// save anchor info until the image is loaded // save anchor info until the image is loaded
@ -149,18 +146,18 @@ L.Util.extend(L.KML, {
}, },
parseStyleMap: function (xml, existingStyles) { parseStyleMap: function (xml, existingStyles) {
var sl = xml.getElementsByTagName("StyleMap"); var sl = xml.getElementsByTagName('StyleMap');
for (var i = 0; i < sl.length; i++) { for (var i = 0; i < sl.length; i++) {
var e = sl[i], el; var e = sl[i], el;
var smKey, smStyleUrl; var smKey, smStyleUrl;
el = e.getElementsByTagName("key"); el = e.getElementsByTagName('key');
if (el && el[0]) { smKey = el[0].textContent; } if (el && el[0]) { smKey = el[0].textContent; }
el = e.getElementsByTagName("styleUrl"); el = e.getElementsByTagName('styleUrl');
if (el && el[0]) { smStyleUrl = el[0].textContent; } if (el && el[0]) { smStyleUrl = el[0].textContent; }
if (smKey=='normal') if (smKey === 'normal')
{ {
existingStyles['#' + e.getAttribute('id')] = existingStyles[smStyleUrl]; existingStyles['#' + e.getAttribute('id')] = existingStyles[smStyleUrl];
} }
@ -212,7 +209,7 @@ L.Util.extend(L.KML, {
var tag = parse[j]; var tag = parse[j];
el = place.getElementsByTagName(tag); el = place.getElementsByTagName(tag);
for (i = 0; i < el.length; i++) { for (i = 0; i < el.length; i++) {
var l = this["parse" + tag](el[i], xml, options); var l = this['parse' + tag](el[i], xml, options);
if (l) { layers.push(l); } if (l) { layers.push(l); }
} }
} }
@ -226,7 +223,7 @@ L.Util.extend(L.KML, {
layer = new L.FeatureGroup(layers); layer = new L.FeatureGroup(layers);
} }
var name, descr = ""; var name, descr = '';
el = place.getElementsByTagName('name'); el = place.getElementsByTagName('name');
if (el.length && el[0].childNodes.length) { if (el.length && el[0].childNodes.length) {
name = el[0].childNodes[0].nodeValue; name = el[0].childNodes[0].nodeValue;
@ -239,7 +236,7 @@ L.Util.extend(L.KML, {
} }
if (name) { if (name) {
layer.bindPopup("<h2>" + name + "</h2>" + descr); layer.bindPopup('<h2>' + name + '</h2>' + descr);
} }
return layer; return layer;
@ -304,7 +301,7 @@ L.Util.extend(L.KML, {
}, },
_read_coords: function (el) { _read_coords: function (el) {
var text = "", coords = [], i; var text = '', coords = [], i;
for (i = 0; i < el.childNodes.length; i++) { for (i = 0; i < el.childNodes.length; i++) {
text = text + el.childNodes[i].nodeValue; text = text + el.childNodes[i].nodeValue;
} }
@ -326,8 +323,7 @@ L.KMLIcon = L.Icon.extend({
createIcon: function () { createIcon: function () {
var img = this._createIcon('icon'); var img = this._createIcon('icon');
img.onload = function () { img.onload = function () {
var i = new Image(); var i = img;
i.src = this.src;
this.style.width = i.width + 'px'; this.style.width = i.width + 'px';
this.style.height = i.height + 'px'; this.style.height = i.height + 'px';
@ -337,13 +333,13 @@ L.KMLIcon = L.Icon.extend({
if (this.anchorType.y === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') { if (this.anchorType.y === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') {
img.style.marginTop = (-(1 - this.anchor.y) * i.height) + 'px'; img.style.marginTop = (-(1 - this.anchor.y) * i.height) + 'px';
} }
this.style.display = ""; this.style.display = '';
}; };
return img; return img;
}, },
_setIconStyles: function (img, name) { _setIconStyles: function (img, name) {
L.Icon.prototype._setIconStyles.apply(this, [img, name]) L.Icon.prototype._setIconStyles.apply(this, [img, name]);
// save anchor information to the image // save anchor information to the image
img.anchor = this.options.iconAnchorRef; img.anchor = this.options.iconAnchorRef;
img.anchorType = this.options.iconAnchorType; img.anchorType = this.options.iconAnchorType;

View file

@ -1,4 +1,4 @@
/*global L: true */ /* global console: true */
L.OSM = L.FeatureGroup.extend({ L.OSM = L.FeatureGroup.extend({
options: { options: {
@ -17,22 +17,22 @@ L.OSM = L.FeatureGroup.extend({
}, },
loadXML: function(url, cb, options, async) { loadXML: function(url, cb, options, async) {
if (async == undefined) async = this.options.async; if (async === undefined) async = this.options.async;
if (options == undefined) options = this.options; if (options === undefined) options = this.options;
var req = new window.XMLHttpRequest(); var req = new window.XMLHttpRequest();
req.open('GET', url, async); req.open('GET', url, async);
req.overrideMimeType('text/xml'); req.overrideMimeType('text/xml');
req.onreadystatechange = function() { req.onreadystatechange = function() {
if (req.readyState != 4) return; if (req.readyState !== 4) return;
if(req.status == 200) cb(req.responseXML, options); if (req.status === 200) cb(req.responseXML, options);
}; };
req.send(null); req.send(null);
}, },
addXML: function(url, options, async) { addXML: function(url, options, async) {
var _this = this; var _this = this;
var cb = function(xml, options) { _this._addXML(xml, options) }; var cb = function(xml, options) { _this._addXML(xml, options); };
this.loadXML(url, cb, options, async); this.loadXML(url, cb, options, async);
}, },
@ -40,7 +40,7 @@ L.OSM = L.FeatureGroup.extend({
var layers = this.parseOSM(xml, options); var layers = this.parseOSM(xml, options);
if (!layers) return; if (!layers) return;
this.addLayer(layers); this.addLayer(layers);
this.fire("loaded"); this.fire('loaded');
}, },
parseOSM: function(xml, options) { parseOSM: function(xml, options) {
@ -52,34 +52,34 @@ L.OSM = L.FeatureGroup.extend({
el = xml.getElementsByTagName('node'); el = xml.getElementsByTagName('node');
for (i = 0; i < el.length; i++) { for (i = 0; i < el.length; i++) {
var l = this.parse_node(el[i], xml, options); var l = this.parse_node(el[i], xml, options);
if (l == undefined) continue; if (l === undefined) continue;
nodes[l.osmid] = l; nodes[l.osmid] = l;
if (!this.options.forceAll && !l.tags.length) continue; if (!this.options.forceAll && !l.tags.length) continue;
var m = this.named_node(l, options); var m = this.named_node(l, options);
if (!ll) ll = m.getLatLng(); if (!ll) ll = m.getLatLng();
if (this.parse_name(m, l, "Node")) named = true; if (this.parse_name(m, l, 'Node')) named = true;
layers.push(m); layers.push(m);
} }
el = xml.getElementsByTagName('way'); el = xml.getElementsByTagName('way');
for (i = 0; i < el.length; i++) { for (i = 0; i < el.length; i++) {
if (i > 10) break; if (i > 10) break;
var l = this.parse_way(el[i], nodes, options); var way = this.parse_way(el[i], nodes, options);
if (!l) continue; if (!way) continue;
if (!ll) ll = l.getLatLngs()[0]; if (!ll) ll = way.getLatLngs()[0];
if (this.parse_name(l, l, "Way")) named = true; if (this.parse_name(way, way, 'Way')) named = true;
layers.push(l); layers.push(way);
ways[l.osmid] = l; ways[way.osmid] = way;
} }
el = xml.getElementsByTagName('relation'); el = xml.getElementsByTagName('relation');
for (i = 0; i < el.length; i++) { for (i = 0; i < el.length; i++) {
if (i > 10) break; if (i > 10) break;
var l = this.parse_relation(el[i], ways, options); var relation = this.parse_relation(el[i], ways, options);
if (!l) continue; if (!relation) continue;
if (!ll) ll = l.getLatLngs()[0]; if (!ll) ll = relation.getLatLngs()[0];
if (this.parse_name(l, l, "Relation")) named = true; if (this.parse_name(relation, relation, 'Relation')) named = true;
layers.push(l); layers.push(relation);
} }
if (!layers.length) return; if (!layers.length) return;
@ -92,17 +92,17 @@ L.OSM = L.FeatureGroup.extend({
}, },
parse_name: function(layer, obj, obj_name) { parse_name: function(layer, obj, obj_name) {
console.info("parse name"); console.info('parse name');
console.info(this.options); console.info(this.options);
if (!this.options.forceAll) if (!this.options.forceAll)
if (!obj.tags || !obj.tags.length) return; if (!obj.tags || !obj.tags.length) return;
var i, txt = "<table>"; var i, txt = '<table>';
for (i = 0; i < obj.tags.length; i++) { for (i = 0; i < obj.tags.length; i++) {
var t = obj.tags[i]; var t = obj.tags[i];
txt += "<tr><td>" + t.k + "</td><td>=</td><td>" + t.v + "</td></tr>"; txt += '<tr><td>' + t.k + '</td><td>=</td><td>' + t.v + '</td></tr>';
} }
txt += "</table>" txt += '</table>';
txt = "<h2>" + obj_name + " " + obj.osmid + "</h2>" + txt; txt = '<h2>' + obj_name + ' ' + obj.osmid + '</h2>' + txt;
if (layer) layer.bindPopup(txt); if (layer) layer.bindPopup(txt);
return txt; return txt;
}, },
@ -110,15 +110,15 @@ L.OSM = L.FeatureGroup.extend({
parse_tags: function(line) { parse_tags: function(line) {
var tags = [], el = line.getElementsByTagName('tag'); var tags = [], el = line.getElementsByTagName('tag');
for (var i = 0; i < el.length; i++) for (var i = 0; i < el.length; i++)
tags.push({k: el[i].getAttribute('k'), v: el[i].getAttribute('v')}) tags.push({k: el[i].getAttribute('k'), v: el[i].getAttribute('v')});
return tags; return tags;
}, },
parse_node: function(e) { parse_node: function(e) {
var n = { osmid: e.getAttribute('id') var n = { osmid: e.getAttribute('id'),
, lat:e.getAttribute('lat') lat:e.getAttribute('lat'),
, lon:e.getAttribute('lon') lon:e.getAttribute('lon')
} };
n.ll = new L.LatLng(n.lat, n.lon); n.ll = new L.LatLng(n.lat, n.lon);
n.tags = this.parse_tags(e); n.tags = this.parse_tags(e);
return n; return n;
@ -135,7 +135,7 @@ L.OSM = L.FeatureGroup.extend({
} }
var layer = new L.Polyline(coords, options); var layer = new L.Polyline(coords, options);
layer.tags = this.parse_tags(line); layer.tags = this.parse_tags(line);
layer.osmid = line.getAttribute('id') layer.osmid = line.getAttribute('id');
return layer; return layer;
}, },
@ -143,25 +143,26 @@ L.OSM = L.FeatureGroup.extend({
var el = line.getElementsByTagName('member'); var el = line.getElementsByTagName('member');
if (!el.length) return; if (!el.length) return;
var rt, coords = [], tags = this.parse_tags(line); var rt, coords = [], tags = this.parse_tags(line);
for (var i = 0; i < tags.length; i++) var i;
if (tags[i].k == "type") rt = tags[i].v; for (i = 0; i < tags.length; i++)
if (tags[i].k === 'type') rt = tags[i].v;
if (rt != "multipolygon" && rt != "boundary" && rt != "waterway") if (rt !== 'multipolygon' && rt !== 'boundary' && rt !== 'waterway')
return; return;
for (var i = 0; i < el.length; i++) { for (i = 0; i < el.length; i++) {
var mt = el[i].getAttribute("type"), ref = el[i].getAttribute("ref"); var mt = el[i].getAttribute('type'), ref = el[i].getAttribute('ref');
if (mt != "way") continue; if (mt !== 'way') continue;
var w = ways[ref]; var w = ways[ref];
console.info("Way: " + ref + " " + w); console.info('Way: ' + ref + ' ' + w);
if (!w) return; if (!w) return;
coords.push(w); coords.push(w);
} }
console.info("Coords: " + coords.length); console.info('Coords: ' + coords.length);
if (!coords.length) return; if (!coords.length) return;
var layer = new L.MultiPolyline(coords, options); var layer = new L.MultiPolyline(coords, options);
layer.tags = this.parse_tags(line); layer.tags = this.parse_tags(line);
layer.osmid = line.getAttribute('id') layer.osmid = line.getAttribute('id');
return layer; return layer;
}, },

View file

@ -1,12 +1,18 @@
{ {
"author": "Pavel Shramov", "author": "Pavel Shramov",
"name": "leaflet-plugins", "name": "leaflet-plugins",
"version": "1.0.1", "version": "1.1.2",
"description": "Miscellaneous plugins for Leaflet library for services that need to display route information and need satellite imagery from different providers", "description": "Miscellaneous plugins for Leaflet library for services that need to display route information and need satellite imagery from different providers",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git@github.com:shramov/leaflet-plugins.git" "url": "git@github.com:shramov/leaflet-plugins.git"
}, },
"scripts": {
"test": "jshint control/* layer/*"
},
"devDependencies": {
"jshint": "2.5.0"
},
"contributors": [ "contributors": [
"Bruno Bergot <bruno@eliaz.fr>", "Bruno Bergot <bruno@eliaz.fr>",
"Andrey Lushchick <andrew@lushchick.org>" "Andrey Lushchick <andrew@lushchick.org>"

View file

@ -1,20 +1,21 @@
{ {
"name": "normalize-css", "name": "normalize-css",
"version": "2.1.3", "version": "3.0.1",
"main": "normalize.css", "main": "normalize.css",
"author": "Nicolas Gallagher", "author": "Nicolas Gallagher",
"ignore": [ "ignore": [
"CHANGELOG.md", "CHANGELOG.md",
"CONTRIBUTING.md", "CONTRIBUTING.md",
"component.json", "component.json",
"package.json",
"test.html" "test.html"
], ],
"homepage": "https://github.com/necolas/normalize.css", "homepage": "https://github.com/necolas/normalize.css",
"_release": "2.1.3", "_release": "3.0.1",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v2.1.3", "tag": "3.0.1",
"commit": "be14934fad255a01ed345de6ae59ff612adcf3b9" "commit": "e3c71c911b0c0ebc0ee14d2421543ce1476fd761"
}, },
"_source": "git://github.com/necolas/normalize.css.git", "_source": "git://github.com/necolas/normalize.css.git",
"_target": "*", "_target": "*",

View file

@ -1,4 +1,4 @@
# normalize.css v2 # normalize.css v3
Normalize.css is a customisable CSS file that makes browsers render all Normalize.css is a customisable CSS file that makes browsers render all
elements more consistently and in line with modern standards. elements more consistently and in line with modern standards.
@ -7,15 +7,17 @@ The project relies on researching the differences between default browser
styles in order to precisely target only the styles that need or benefit from styles in order to precisely target only the styles that need or benefit from
normalizing. normalizing.
[Check out the demo](http://necolas.github.io/normalize.css/latest/test.html) [View the test file](http://necolas.github.io/normalize.css/latest/test.html)
## Install ## Install
Download from the [project page](http://necolas.github.io/normalize.css/). Download from the [project page](http://necolas.github.io/normalize.css/).
Install with [Bower](http://bower.io/): `bower install --save normalize-css` Install with [Component(1)](https://github.com/component/component/): `component install necolas/normalize.css`
Install with [Component(1)](http://component.io/): `component install necolas/normalize.css` Install with [npm](http://npmjs.org/): `npm install --save normalize.css`
Install with [Bower](http://bower.io/): `bower install --save normalize.css`
## What does it do? ## What does it do?
@ -34,10 +36,11 @@ library code.
## Browser support ## Browser support
* Google Chrome * Google Chrome (latest)
* Mozilla Firefox 4+ * Mozilla Firefox (latest)
* Apple Safari 5+ * Mozilla Firefox 4
* Opera 12+ * Opera (latest)
* Apple Safari 6+
* Internet Explorer 8+ * Internet Explorer 8+
[Normalize.css v1 provides legacy browser [Normalize.css v1 provides legacy browser

View file

@ -1,12 +1,13 @@
{ {
"name": "normalize-css", "name": "normalize-css",
"version": "2.1.3", "version": "3.0.1",
"main": "normalize.css", "main": "normalize.css",
"author": "Nicolas Gallagher", "author": "Nicolas Gallagher",
"ignore": [ "ignore": [
"CHANGELOG.md", "CHANGELOG.md",
"CONTRIBUTING.md", "CONTRIBUTING.md",
"component.json", "component.json",
"package.json",
"test.html" "test.html"
] ]
} }

View file

@ -1,61 +1,4 @@
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */ /*! normalize.css v3.0.1 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
/**
* Correct `inline-block` display not defined in IE 8/9.
*/
audio,
canvas,
video {
display: inline-block;
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9.
* Hide the `template` element in IE, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/** /**
* 1. Set default font family to sans-serif. * 1. Set default font family to sans-serif.
@ -77,8 +20,64 @@ body {
margin: 0; margin: 0;
} }
/* ========================================================================== /* HTML5 display definitions
Links ========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */ ========================================================================== */
/** /**
@ -89,14 +88,6 @@ a {
background: transparent; background: transparent;
} }
/**
* Address `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
}
/** /**
* Improve readability when focused and also mouse hovered in all browsers. * Improve readability when focused and also mouse hovered in all browsers.
*/ */
@ -106,22 +97,11 @@ a:hover {
outline: 0; outline: 0;
} }
/* ========================================================================== /* Text-level semantics
Typography
========================================================================== */ ========================================================================== */
/** /**
* Address variable `h1` font-size and margin within `section` and `article` * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
* contexts in Firefox 4+, Safari 5, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9, Safari 5, and Chrome.
*/ */
abbr[title] { abbr[title] {
@ -129,7 +109,7 @@ abbr[title] {
} }
/** /**
* Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
*/ */
b, b,
@ -138,7 +118,7 @@ strong {
} }
/** /**
* Address styling not present in Safari 5 and Chrome. * Address styling not present in Safari and Chrome.
*/ */
dfn { dfn {
@ -146,13 +126,13 @@ dfn {
} }
/** /**
* Address differences between Firefox and other browsers. * Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/ */
hr { h1 {
-moz-box-sizing: content-box; font-size: 2em;
box-sizing: content-box; margin: 0.67em 0;
height: 0;
} }
/** /**
@ -164,34 +144,6 @@ mark {
color: #000; color: #000;
} }
/**
* Correct font family set oddly in Safari 5 and Chrome.
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
font-size: 1em;
}
/**
* Improve readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre-wrap;
}
/**
* Set consistent quote types.
*/
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
/** /**
* Address inconsistent and variable font size in all browsers. * Address inconsistent and variable font size in all browsers.
*/ */
@ -220,12 +172,11 @@ sub {
bottom: -0.25em; bottom: -0.25em;
} }
/* ========================================================================== /* Embedded content
Embedded content
========================================================================== */ ========================================================================== */
/** /**
* Remove border when inside `a` element in IE 8/9. * Remove border when inside `a` element in IE 8/9/10.
*/ */
img { img {
@ -233,79 +184,92 @@ img {
} }
/** /**
* Correct overflow displayed oddly in IE 9. * Correct overflow not hidden in IE 9/10/11.
*/ */
svg:not(:root) { svg:not(:root) {
overflow: hidden; overflow: hidden;
} }
/* ========================================================================== /* Grouping content
Figures
========================================================================== */ ========================================================================== */
/** /**
* Address margin not present in IE 8/9 and Safari 5. * Address margin not present in IE 8/9 and Safari.
*/ */
figure { figure {
margin: 0; margin: 1em 40px;
} }
/* ========================================================================== /**
Forms * Address differences between Firefox and other browsers.
*/
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
/* Forms
========================================================================== */ ========================================================================== */
/** /**
* Define consistent border, margin, and padding. * Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of `select`, unless a `border` property is set.
*/ */
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/** /**
* 1. Correct `color` not being inherited in IE 8/9. * 1. Correct color not being inherited.
* 2. Remove padding so people aren't caught out if they zero out fieldsets. * Known issue: affects color of disabled elements.
*/ * 2. Correct font properties not being inherited.
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/**
* 1. Correct font family not being inherited in all browsers.
* 2. Correct font size not being inherited in all browsers.
* 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome.
*/ */
button, button,
input, input,
optgroup,
select, select,
textarea { textarea {
font-family: inherit; /* 1 */ color: inherit; /* 1 */
font-size: 100%; /* 2 */ font: inherit; /* 2 */
margin: 0; /* 3 */ margin: 0; /* 3 */
} }
/** /**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in * Address `overflow` set to `hidden` in IE 8/9/10/11.
* the UA stylesheet.
*/ */
button, button {
input { overflow: visible;
line-height: normal;
} }
/** /**
* Address inconsistent `text-transform` inheritance for `button` and `select`. * Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values. * All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+. * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct `select` style inheritance in Firefox 4+ and Opera. * Correct `select` style inheritance in Firefox.
*/ */
button, button,
@ -339,6 +303,28 @@ html input[disabled] {
} }
/** /**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
input {
line-height: normal;
}
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to `content-box` in IE 8/9/10. * 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10. * 2. Remove excess padding in IE 8/9/10.
*/ */
@ -350,8 +336,19 @@ input[type="radio"] {
} }
/** /**
* 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. * Fix the cursor style for Chrome's increment/decrement buttons. For certain
* 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome * `font-size` values of the `input`, it causes the cursor style of the
* decrement button to change from `default` to `text`.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Address `appearance` set to `searchfield` in Safari and Chrome.
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome
* (include `-moz` to future-proof). * (include `-moz` to future-proof).
*/ */
@ -363,8 +360,9 @@ input[type="search"] {
} }
/** /**
* Remove inner padding and search cancel button in Safari 5 and Chrome * Remove inner padding and search cancel button in Safari and Chrome on OS X.
* on OS X. * Safari (but not Chrome) clips the cancel button when the search input has
* padding (and `textfield` appearance).
*/ */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-cancel-button,
@ -373,27 +371,43 @@ input[type="search"]::-webkit-search-decoration {
} }
/** /**
* Remove inner padding and border in Firefox 4+. * Define consistent border, margin, and padding.
*/ */
button::-moz-focus-inner, fieldset {
input::-moz-focus-inner { border: 1px solid #c0c0c0;
border: 0; margin: 0 2px;
padding: 0; padding: 0.35em 0.625em 0.75em;
} }
/** /**
* 1. Remove default vertical scrollbar in IE 8/9. * 1. Correct `color` not being inherited in IE 8/9/10/11.
* 2. Improve readability and alignment in all browsers. * 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/ */
textarea { textarea {
overflow: auto; /* 1 */ overflow: auto;
vertical-align: top; /* 2 */
} }
/* ========================================================================== /**
Tables * Don't inherit the `font-weight` (applied by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold;
}
/* Tables
========================================================================== */ ========================================================================== */
/** /**
@ -404,3 +418,8 @@ table {
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0; border-spacing: 0;
} }
td,
th {
padding: 0;
}