update build

This commit is contained in:
Vladimir Agafonkin 2013-01-31 17:59:13 +02:00
parent 619698f6fb
commit b2c0de16ac
2 changed files with 86 additions and 38 deletions

116
dist/leaflet-src.js vendored
View File

@ -109,7 +109,7 @@ L.Util = {
var params = [];
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
params.push(i + '=' + obj[i]);
params.push(encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]));
}
}
return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
@ -307,10 +307,12 @@ L.Mixin = {};
L.Mixin.Events = {
addEventListener: function (types, fn, context) { // (String, Function[, Object]) or (Object[, Object])
var events = this[key] = this[key] || {},
type, i, len;
type, i, len, evt,
contextId, objKey, objLenKey, eventsObj;
// Types can be a map of types/handlers
// types can be a map of types/handlers
if (typeof types === 'object') {
for (type in types) {
if (types.hasOwnProperty(type)) {
@ -321,26 +323,50 @@ L.Mixin.Events = {
return this;
}
// types can be a string of space-separated words
types = L.Util.splitWords(types);
for (i = 0, len = types.length; i < len; i++) {
events[types[i]] = events[types[i]] || [];
events[types[i]].push({
evt = {
action: fn,
context: context || this
});
};
contextId = context && context._leaflet_id;
if (contextId) {
// store listeners of a particular context in a separate hash (if it has an id)
// gives a major performance boost when removing thousands of map layers
objKey = types[i] + '_idx',
objLenKey = objKey + '_len',
eventsObj = events[objKey] = events[objKey] || {};
if (eventsObj[contextId]) {
eventsObj[contextId].push(evt);
} else {
eventsObj[contextId] = [evt];
events[objLenKey] = (events[objLenKey] || 0) + 1;
}
} else {
events[types[i]] = events[types[i]] || [];
events[types[i]].push(evt);
}
}
return this;
},
hasEventListeners: function (type) { // (String) -> Boolean
return (key in this) && (type in this[key]) && (this[key][type].length > 0);
return (key in this) &&
(((type in this[key]) && this[key][type].length > 0) ||
(this[key][type + '_idx_len'] > 0));
},
removeEventListener: function (types, fn, context) { // (String[, Function, Object]) or (Object[, Object])
var events = this[key],
type, i, len, listeners, j;
type, i, len, listeners, j,
contextId, objKey, objLenKey;
if (typeof types === 'object') {
for (type in types) {
@ -348,25 +374,35 @@ L.Mixin.Events = {
this.removeEventListener(type, types[type], fn);
}
}
return this;
}
types = L.Util.splitWords(types);
for (i = 0, len = types.length; i < len; i++) {
if (this.hasEventListeners(types[i])) {
listeners = events[types[i]];
// if the context has an id, use it to find the listeners
contextId = context && context._leaflet_id;
objKey = types[i] + '_idx';
if (contextId && events[objKey]) {
listeners = events[objKey][contextId] || [];
} else {
listeners = events[types[i]] || [];
}
for (j = listeners.length - 1; j >= 0; j--) {
if (
(!fn || listeners[j].action === fn) &&
(!context || (listeners[j].context === context))
) {
if ((!fn || listeners[j].action === fn) && (!context || (listeners[j].context === context))) {
listeners.splice(j, 1);
}
}
if (contextId && listeners.length === 0) {
objLenKey = objKey + '_len';
delete events[objKey][contextId];
events[objLenKey] = (events[objLenKey] || 1) - 1;
}
}
}
@ -378,15 +414,36 @@ L.Mixin.Events = {
return this;
}
var event = L.extend({
var event = L.Util.extend({
type: type,
target: this
}, data);
var listeners = this[key][type].slice();
var listeners, i, len, eventsObj, contextId;
for (var i = 0, len = listeners.length; i < len; i++) {
listeners[i].action.call(listeners[i].context || this, event);
if (this[key][type]) {
listeners = this[key][type].slice();
for (i = 0, len = listeners.length; i < len; i++) {
listeners[i].action.call(listeners[i].context || this, event);
}
}
// fire event for the context-indexed listeners as well
eventsObj = this[key][type + '_idx'];
if (eventsObj) {
for (contextId in eventsObj) {
if (eventsObj.hasOwnProperty(contextId)) {
listeners = eventsObj[contextId];
if (listeners) {
for (i = 0, len = listeners.length; i < len; i++) {
listeners[i].action.call(listeners[i].context || this, event);
}
}
}
}
}
return this;
@ -7296,23 +7353,14 @@ L.Control.Zoom = L.Control.extend({
onAdd: function (map) {
var zoomName = 'leaflet-control-zoom',
barName = 'leaflet-bar',
partName = barName + '-part',
container = L.DomUtil.create('div', zoomName + ' ' + barName);
container = L.DomUtil.create('div', zoomName + ' leaflet-bar');
this._map = map;
this._zoomInButton = this._createButton('+', 'Zoom in',
zoomName + '-in ' +
partName + ' ' +
partName + '-top',
container, this._zoomIn, this);
this._zoomOutButton = this._createButton('-', 'Zoom out',
zoomName + '-out ' +
partName + ' ' +
partName + '-bottom',
container, this._zoomOut, this);
this._zoomInButton = this._createButton(
'+', 'Zoom in', zoomName + '-in', container, this._zoomIn, this);
this._zoomOutButton = this._createButton(
'-', 'Zoom out', zoomName + '-out', container, this._zoomOut, this);
map.on('zoomend', this._updateDisabled, this);
@ -7351,7 +7399,7 @@ L.Control.Zoom = L.Control.extend({
_updateDisabled: function () {
var map = this._map,
className = 'leaflet-control-zoom-disabled';
className = 'leaflet-disabled';
L.DomUtil.removeClass(this._zoomInButton, className);
L.DomUtil.removeClass(this._zoomOutButton, className);

8
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long