Merge pull request #114 from CartoDB/nodefix

Replaces direct call to document with abstraction
This commit is contained in:
Raul Ochoa 2015-02-17 15:01:23 +01:00
commit 847f3fc2f4

View File

@ -134,12 +134,7 @@ var filters = require('./torque_filters');
var w = ctx.width = canvas.width = ctx.height = canvas.height = Math.ceil(canvasSize);
ctx.translate(w/2, w/2);
function qualifyURL(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
};
var img_name = qualifyURL(st["marker-file"] || st["point-file"]);
var img_name = this._qualifyURL(st["marker-file"] || st["point-file"]);
if (img_name && this._icons.itemsToLoad <= 0) {
var img = this._icons[img_name];
img.w = st['marker-width'] || img.width;
@ -197,6 +192,16 @@ var filters = require('./torque_filters');
? new this.options.imageClass()
: new Image();
},
_qualifyURL: function(url) {
if (typeof this.options.qualifyURL !== "undefined"){
return this.options.qualifyURL(url);
}
else{
var a = document.createElement('a');
a.href = url;
return a.href;
}
},
//
// renders a tile in the canvas for key defined in
@ -314,12 +319,7 @@ var filters = require('./torque_filters');
if (img_names.length > 0 && !this._forcePoints){
for (var i = 0; i<img_names.length; i++){
var new_img = this._createImage();
function qualifyURL(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
}
this._icons[qualifyURL(img_names[i])] = null;
this._icons[this._qualifyURL(img_names[i])] = null;
if (typeof self._icons.itemsToLoad === 'undefined'){
this._icons.itemsToLoad = img_names.length;
}