Fix L variable definition, closes #122

This commit is contained in:
Mourner 2011-06-14 15:14:47 +03:00
parent 9f9d13044f
commit 667fdd9797
3 changed files with 30 additions and 25 deletions

View File

@ -29,6 +29,7 @@ Leaflet Changelog
* Improved `Popup` to accept HTML elements in addition to strings as its content.
* Added `Makefile` for building `leaflet.js` on non-Windows machines (by [@tmcw](https://github.com/tmcw)).
* Improved `debug/leaflet-include.js` script to allow using it outside of `debug` folder (by [@antonj](https://github.com/antonj)).
* Improved `L` definition to be compatible with CommonJS. [#122](https://github.com/CloudMade/Leaflet/issues/122)
### Bug fixes
@ -61,4 +62,4 @@ Leaflet Changelog
## 0.1 (2011-05-13)
* Initial Leaflet release.
* Initial Leaflet release.

2
dist/leaflet.js vendored
View File

@ -3,7 +3,7 @@
Leaflet is a BSD-licensed JavaScript library for map display and interaction.
See http://cloudmade.github.com/Leaflet/ for more information.
*/
var L={VERSION:"0.2",ROOT_URL:function(){for(var a=document.getElementsByTagName("script"),b=/^(.*\/)leaflet-?([\w-]*)\.js.*$/,c=0,d=a.length;c<d;c++){var e=a[c].src;if(e=e&&e.match(b)){if(e[2]=="include")break;return e[1]}}return"../../dist/"}(),noConflict:function(){L=this._originalL;return this},_originalL:L};L.Util={extend:function(a){for(var b=Array.prototype.slice.call(arguments,1),c=0,d=b.length,e;c<d;c++){e=b[c]||{};for(var f in e)e.hasOwnProperty(f)&&(a[f]=e[f])}return a},bind:function(a,b){return function(){return a.apply(b,arguments)}},stamp:function(){var a=0;return function(b){b._leaflet_id=b._leaflet_id||++a;return b._leaflet_id}}(),limitExecByInterval:function(a,b,c){function d(){e=!1;f&&(g.callee.apply(c,g),f=!1)}var e,f,g;return function(){g=arguments;e?f=!0:(e=!0,setTimeout(d,b),a.apply(c,
(function(a){var b={VERSION:"0.2",ROOT_URL:function(){for(var a=document.getElementsByTagName("script"),b=/^(.*\/)leaflet-?([\w-]*)\.js.*$/,e=0,f=a.length;e<f;e++){var g=a[e].src;if(g=g&&g.match(b)){if(g[2]=="include")break;return g[1]}}return"../../dist/"}(),noConflict:function(){a.L=this._originalL;return this},_originalL:a.L};window.L=b})(this);L.Util={extend:function(a){for(var b=Array.prototype.slice.call(arguments,1),c=0,d=b.length,e;c<d;c++){e=b[c]||{};for(var f in e)e.hasOwnProperty(f)&&(a[f]=e[f])}return a},bind:function(a,b){return function(){return a.apply(b,arguments)}},stamp:function(){var a=0;return function(b){b._leaflet_id=b._leaflet_id||++a;return b._leaflet_id}}(),limitExecByInterval:function(a,b,c){function d(){e=!1;f&&(g.callee.apply(c,g),f=!1)}var e,f,g;return function(){g=arguments;e?f=!0:(e=!0,setTimeout(d,b),a.apply(c,
g))}},deferExecByInterval:function(a,b,c){function d(){f=!1;a.apply(c,e)}var e,f;return function(){e=arguments;f||(f=!0,setTimeout(d,b))}},falseFn:function(){return!1},formatNum:function(a,b){var c=Math.pow(10,b||5);return Math.round(a*c)/c},setOptions:function(a,b){a.options=L.Util.extend({},a.options,b)},getParamString:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c+"="+a[c]);return"?"+b.join("&")}};L.Class=function(){};
L.Class.extend=function(a){var b=function(){!L.Class._prototyping&&this.initialize&&this.initialize.apply(this,arguments)};L.Class._prototyping=!0;var c=new this;L.Class._prototyping=!1;c.constructor=b;b.prototype=c;c.superclass=this.prototype;a.statics&&(L.Util.extend(b,a.statics),delete a.statics);a.includes&&(L.Util.extend.apply(null,[c].concat(a.includes)),delete a.includes);if(a.options&&c.options)a.options=L.Util.extend({},c.options,a.options);L.Util.extend(c,a);b.extend=arguments.callee;b.include=
function(a){L.Util.extend(this.prototype,a)};for(var d in this)this.hasOwnProperty(d)&&d!="prototype"&&(b[d]=this[d]);return b};L.Mixin={};

View File

@ -4,28 +4,32 @@
* See http://cloudmade.github.com/Leaflet/ for more information.
*/
var L = {
VERSION: '0.2',
ROOT_URL: (function() {
var scripts = document.getElementsByTagName('script'),
leafletRe = /^(.*\/)leaflet-?([\w-]*)\.js.*$/;
for (var i = 0, len = scripts.length; i < len; i++) {
var src = scripts[i].src,
res = src && src.match(leafletRe);
if (res) {
if (res[2] == 'include') break;
return res[1];
(function(root) {
var L = {
VERSION: '0.2',
ROOT_URL: (function() {
var scripts = document.getElementsByTagName('script'),
leafletRe = /^(.*\/)leaflet-?([\w-]*)\.js.*$/;
for (var i = 0, len = scripts.length; i < len; i++) {
var src = scripts[i].src,
res = src && src.match(leafletRe);
if (res) {
if (res[2] == 'include') break;
return res[1];
}
}
}
return '../../dist/';
})(),
return '../../dist/';
})(),
noConflict: function() {
root.L = this._originalL;
return this;
},
_originalL: root.L
};
noConflict: function() {
L = this._originalL;
return this;
},
_originalL: L
};
window.L = L;
}(this));