removed initialize anti-pattern from dzitilesource constructor.

This commit is contained in:
thatcher 2011-12-13 18:34:12 -05:00
parent a7050af619
commit c7706ba66c
2 changed files with 14 additions and 22 deletions

View File

@ -2592,16 +2592,8 @@ $.DziTileSource = function(width, height, tileSize, tileOverlap, tilesUrl, fileF
this.fileFormat = fileFormat; this.fileFormat = fileFormat;
this.displayRects = displayRects; this.displayRects = displayRects;
this.initialize();
}; if ( this.displayRects ) {
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
initialize: function() {
if (!this.displayRects) {
return;
}
for (var i = this.displayRects.length - 1; i >= 0; i--) { for (var i = this.displayRects.length - 1; i >= 0; i--) {
var rect = this.displayRects[i]; var rect = this.displayRects[i];
for (var level = rect.minLevel; level <= rect.maxLevel; level++) { for (var level = rect.minLevel; level <= rect.maxLevel; level++) {
@ -2611,7 +2603,11 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
this._levelRects[level].push(rect); this._levelRects[level].push(rect);
} }
} }
}, }
};
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
getTileUrl: function(level, x, y) { getTileUrl: function(level, x, y) {
return [this.tilesUrl, level, '/', x, '_', y, '.', this.fileFormat].join(''); return [this.tilesUrl, level, '/', x, '_', y, '.', this.fileFormat].join('');

View File

@ -10,16 +10,8 @@ $.DziTileSource = function(width, height, tileSize, tileOverlap, tilesUrl, fileF
this.fileFormat = fileFormat; this.fileFormat = fileFormat;
this.displayRects = displayRects; this.displayRects = displayRects;
this.initialize();
}; if ( this.displayRects ) {
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
initialize: function() {
if (!this.displayRects) {
return;
}
for (var i = this.displayRects.length - 1; i >= 0; i--) { for (var i = this.displayRects.length - 1; i >= 0; i--) {
var rect = this.displayRects[i]; var rect = this.displayRects[i];
for (var level = rect.minLevel; level <= rect.maxLevel; level++) { for (var level = rect.minLevel; level <= rect.maxLevel; level++) {
@ -29,7 +21,11 @@ $.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
this._levelRects[level].push(rect); this._levelRects[level].push(rect);
} }
} }
}, }
};
$.extend( $.DziTileSource.prototype, $.TileSource.prototype, {
getTileUrl: function(level, x, y) { getTileUrl: function(level, x, y) {
return [this.tilesUrl, level, '/', x, '_', y, '.', this.fileFormat].join(''); return [this.tilesUrl, level, '/', x, '_', y, '.', this.fileFormat].join('');