Compare commits

...

9 Commits

Author SHA1 Message Date
crschmidt
0f90170d98 Tagging the 2.11-rc3 release.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.11-rc3@12276 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-24 23:36:09 +00:00
crschmidt
e89633fd52 Updating version numbers for 2.11-rc3.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12275 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-24 23:36:06 +00:00
crschmidt
c867627c78 Pulling in patches for OL 2.11 RC3:
* ArcGISCache resolutions get compromised by some JS frameworks. (Closes #3474)
 * OpenLayers.Layer.HTTPRequest initialize simplification (Closes #3470)
 * missing requires (Closes #3467)
 * deleting a vertex does not update feature.modified (Closes #3463)
 * fixing test failure in some browsers (Closes #3461)
 * a grid layer may be moved while its grid hasn't been initialized yet (Closes #3458) -- this one is the actual release blocker
 * Change the callback function of Protocol.Script (JSONP) (Closes #3417)
 * "build.py -c closure" does not work on Windows systems. (Closes #3158)


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12274 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-24 23:32:34 +00:00
ahocevar
061eeacf92 reverting r12185 from #3431
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12232 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-10 08:41:37 +00:00
crschmidt
78c2e7767b Updating version numbers for 2.11-rc2.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12223 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-08 14:14:11 +00:00
crschmidt
911393123e Branching for the 2.11 release
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12222 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-08 14:13:46 +00:00
crschmidt
fcd2a62fa3 Branching for the 2.11 release
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@12220 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-08-08 14:05:07 +00:00
crschmidt
9a3db8c5b7 Updating version numbers for 2.11-rc1.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@11996 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-05-23 14:33:54 +00:00
crschmidt
e846551c2c Branching for the 2.11 release
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.11@11995 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2011-05-23 14:25:10 +00:00
23 changed files with 306 additions and 77 deletions

View File

@@ -383,4 +383,4 @@
/**
* Constant: VERSION_NUMBER
*/
OpenLayers.VERSION_NUMBER="$Revision$";
OpenLayers.VERSION_NUMBER="Release 2.11-rc3";

View File

@@ -633,6 +633,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
this.layer.drawFeature(this.feature, this.standalone ?
undefined :
this.selectControl.renderIntent);
this.modified = true;
this.resetVertices();
this.setFeatureState();
this.onModification(this.feature);

View File

@@ -5,6 +5,7 @@
/**
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Format/OWSCommon/v1_1_0.js
*/
/**

View File

@@ -349,11 +349,6 @@ OpenLayers.Layer = OpenLayers.Class({
this.div.style.width = "100%";
this.div.style.height = "100%";
this.div.dir = "ltr";
if (this.opacity != null) {
OpenLayers.Util.modifyDOMElement(
this.div, null, null, null, null, null, null, this.opacity
);
}
this.events = new OpenLayers.Events(this, this.div,
this.EVENT_TYPES);
@@ -1274,8 +1269,11 @@ OpenLayers.Layer = OpenLayers.Class({
setOpacity: function(opacity) {
if (opacity != this.opacity) {
this.opacity = opacity;
OpenLayers.Util.modifyDOMElement(this.div, null, null, null,
null, null, null, opacity);
for(var i=0, len=this.div.childNodes.length; i<len; ++i) {
var element = this.div.childNodes[i].firstChild;
OpenLayers.Util.modifyDOMElement(element, null, null, null,
null, null, null, opacity);
}
if (this.map != null) {
this.map.events.triggerEvent("changelayer", {
layer: this,

View File

@@ -172,21 +172,23 @@ OpenLayers.Layer.ArcGISCache = OpenLayers.Class(OpenLayers.Layer.XYZ, {
this.lods = [];
for(var key in info.tileInfo.lods) {
var lod = info.tileInfo.lods[key];
if (this.useScales) {
this.scales.push(lod.scale);
} else {
this.resolutions.push(lod.resolution);
if (info.tileInfo.lods.hasOwnProperty(key)) {
var lod = info.tileInfo.lods[key];
if (this.useScales) {
this.scales.push(lod.scale);
} else {
this.resolutions.push(lod.resolution);
}
var start = this.getContainingTileCoords(upperLeft, lod.resolution);
lod.startTileCol = start.x;
lod.startTileRow = start.y;
var end = this.getContainingTileCoords(bottomRight, lod.resolution);
lod.endTileCol = end.x;
lod.endTileRow = end.y;
this.lods.push(lod);
}
var start = this.getContainingTileCoords(upperLeft, lod.resolution);
lod.startTileCol = start.x;
lod.startTileRow = start.y;
var end = this.getContainingTileCoords(bottomRight, lod.resolution);
lod.endTileCol = end.x;
lod.endTileRow = end.y;
this.lods.push(lod);
}
this.maxExtent = this.calculateMaxExtentWithLOD(this.lods[0]);

View File

@@ -58,9 +58,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
* options - {Object} Hashtable of extra options to tag onto the layer
*/
initialize: function(name, url, params, options) {
var newArguments = arguments;
newArguments = [name, options];
OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);
this.url = url;
this.params = OpenLayers.Util.extend( {}, params);
},

View File

@@ -60,6 +60,22 @@ OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
},
/**
* APIMethod: setOpacity
* Sets the opacity for all the markers.
*
* Parameter:
* opacity - {Float}
*/
setOpacity: function(opacity) {
if (opacity != this.opacity) {
this.opacity = opacity;
for (var i=0, len=this.markers.length; i<len; i++) {
this.markers[i].setOpacity(this.opacity);
}
}
},
/**
* Method: moveTo
*

View File

@@ -590,5 +590,21 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
return extent;
},
/**
* APIMethod: setOpacity
* Call the setOpacity method of the appropriate parent class to set the
* opacity.
*
* Parameter:
* opacity - {Float}
*/
setOpacity: function (opacity) {
if (this.vectorMode) {
OpenLayers.Layer.Vector.prototype.setOpacity.apply(this, [opacity]);
} else {
OpenLayers.Layer.Markers.prototype.setOpacity.apply(this, [opacity]);
}
},
CLASS_NAME: "OpenLayers.Layer.WFS"
});

View File

@@ -1722,7 +1722,8 @@ OpenLayers.Map = OpenLayers.Class({
var layer, i, len;
for (i=0, len=this.layers.length; i<len; ++i) {
layer = this.layers[i];
if (layer.visibility) {
if (layer.visibility &&
(layer === this.baseLayer || layer.inRange)) {
layer.moveByPx(dx, dy);
layer.events.triggerEvent("move");
}

View File

@@ -207,7 +207,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
*/
createRequest: function(url, params, callback) {
var id = OpenLayers.Protocol.Script.register(callback);
var name = "OpenLayers.Protocol.Script.getCallback(" + id + ")";
var name = "OpenLayers.Protocol.Script.registry[" + id + "]";
params = OpenLayers.Util.extend({}, params);
params[this.callbackKey] = this.callbackPrefix + name;
url = OpenLayers.Util.urlAppend(
@@ -328,7 +328,7 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
(function() {
var o = OpenLayers.Protocol.Script;
var counter = 0;
var registry = {};
o.registry = [];
/**
* Function: OpenLayers.Protocol.Script.register
@@ -344,7 +344,10 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
*/
o.register = function(callback) {
var id = ++counter;
registry[id] = callback;
o.registry[id] = function() {
o.unregister(id);
callback.apply(this, arguments);
};
return id;
};
@@ -356,22 +359,6 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
* id: {Number} The identifer returned by the register function.
*/
o.unregister = function(id) {
delete registry[id];
};
/**
* Function: OpenLayers.Protocol.Script.getCallback
* Retreive and unregister a callback. A call to this function is the "P"
* in JSONP. For example, a script may be added with a src attribute
* http://example.com/features.json?callback=OpenLayers.Protocol.Script.getCallback(1)
*
* Parameters:
* id: {Number} The identifer returned by the register function.
*/
o.getCallback = function(id) {
var callback = registry[id];
o.unregister(id);
return callback;
delete o.registry[id];
};
})();

View File

@@ -7,7 +7,7 @@ var OpenLayers = {
/**
* Constant: VERSION_NUMBER
*/
VERSION_NUMBER: "$Revision$",
VERSION_NUMBER: "Release 2.11-rc3",
/**
* Constant: singleFile

View File

@@ -20,7 +20,15 @@
// check invalid date
date = new Date("foo");
str = OpenLayers.Date.toISOString(date);
try {
str = OpenLayers.Date.toISOString(date);
} catch (err) {
// some implementations throw RangeError
// see https://bugzilla.mozilla.org/show_bug.cgi?id=649575
if (err instanceof RangeError) {
str = "Invalid Date";
}
}
t.eq(str, "Invalid Date", "invalid date");
}

View File

@@ -74,7 +74,7 @@
}
function test_handleKeypress(t) {
t.plan(14);
t.plan(16);
/**
* There are two things that we want to test here
@@ -101,6 +101,8 @@
// mock up vertex deletion
control.dragControl.feature = point;
control.feature = poly;
// we cannot use selectFeature since the control is not part of a map
control._originalGeometry = poly.geometry.clone();
control.vertices = [point];
point.geometry.parent = {
removeComponent: function(geometry) {
@@ -110,6 +112,7 @@
};
layer.events.on({
"featuremodified": function(event) {
t.ok(event.feature.modified !== null, "modified property of feature should have been set");
t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered");
},
"vertexremoved": function(evt) {

View File

@@ -786,15 +786,14 @@
}
function test_setOpacity(t) {
t.plan(8);
t.plan(5);
var map, layer, log;
map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer("", {opacity: 0.56});
layer = new OpenLayers.Layer("");
map.addLayer(layer);
t.eq(layer.div.style.opacity, "0.56", "initial opacity correctly applied as layer.div style");
log = [];
map.events.register('changelayer', t, function(event) {
log.push({layer: event.layer, property: event.property});
@@ -802,7 +801,6 @@
layer.setOpacity(0.42);
t.eq(layer.opacity, 0.42,
"setOpacity() set layer.opacity to correct value");
t.eq(layer.div.style.opacity, "0.42", "opacity correctly applied as layer.div style");
t.eq(log.length, 1,
"setOpacity() triggers changelayer once");
t.ok(log[0].layer == layer,
@@ -815,12 +813,6 @@
layer.setOpacity(0.42);
t.eq(log.length, 0,
"setOpacity() does not trigger changelayer if the opacity value is the same");
// 0 as initial opacity
layer.destroy();
layer = new OpenLayers.Layer("", {opacity: 0});
map.addLayer(layer);
t.eq(layer.div.style.opacity, "0", "initial opacity correctly applied as layer.div style");
}

View File

@@ -195,6 +195,31 @@
}
function test_Layer_AGS93_setOpacity (t) {
var params = {layers: "show:0,2"};
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tParams = { layers: 'show:0,2',
format: 'png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.ArcGIS93Rest(name, url, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
var pixel = new OpenLayers.Pixel(5,6);
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
tile.draw();
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly");
map.destroy();
}
function test_Layer_AGS93_noGutters (t) {
t.plan(2);
var map = new OpenLayers.Map('map');

View File

@@ -219,6 +219,32 @@
t.ok((tile.x >= 0 && tile.y >= 0), 'layer should not generate negative tile ranges for level of detail');
}
/*
* Test that messing up the Array.prototype does not mess up the lods of the layer.
* This messes up zooming when resolutions are very small/scales are very large/zoomed way in.
*/
function test_Layer_ARCGISCACHE_lods (t) {
t.plan( 2 );
var layerInfo = capabilitiesObject;
lods = layerInfo.tileInfo.lods.length;
// mess up the Array prototype
Array.prototype.foo = function() { };
t.ok( lods == layerInfo.tileInfo.lods.length, 'proper number of "Levels of Detail" before initialization' );
// initialize the layer using the JSON object from an arcgis server
// see: ArcGISCache.json
var layer = new OpenLayers.Layer.ArcGISCache(name, url, {
layerInfo: layerInfo
});
t.ok( lods == layer.lods.length, 'proper number of "Levels of Detail" after initialization.' );
// restore the Array prototype
delete Array.prototype.foo;
}
</script>
</head>
<body>

View File

@@ -196,6 +196,31 @@
}
function test_Layer_MapServer_setOpacity (t) {
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://labs.metacarta.com/cgi-bin/mapserv";
tParams = { layers: 'basic',
format: 'image/png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.MapServer(name, tUrl, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
var pixel = new OpenLayers.Pixel(5,6);
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
tile.draw();
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly");
map.destroy();
}
function test_Layer_MapServer_Reproject (t) {
var validkey = (window.location.protocol == "file:") ||
(window.location.host == "localhost") ||
@@ -386,6 +411,27 @@
}
function test_Layer_MapServer_Untiled_setOpacity (t) {
t.plan( 4 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://labs.metacarta.com/cgi-bin/mapserv";
tParams = { layers: 'basic',
format: 'image/png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.MapServer.Untiled(name, tUrl, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
map.destroy();
}
// DEPRECATED -- REMOVE IN 3.0
function test_Layer_Untiled_MapServer(t) {
t.plan(1);

View File

@@ -121,6 +121,33 @@
}
function test_setOpacity(t) {
t.plan(1);
layer = new OpenLayers.Layer.Markers('Test Layer');
var opacity = 0.1234;
for (var i = 0; i < 12; i++) {
layer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0), new OpenLayers.Icon()));
}
layer.setOpacity(opacity);
for (var i = 0; i < 4; i++) {
layer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0), new OpenLayers.Icon()));
}
var itWorks = false;
for (var i = 0; i < layer.markers.length; i++) {
itWorks = parseFloat(layer.markers[i].icon.imageDiv.style.opacity) == opacity;
if (!itWorks) {
break;
}
}
t.ok(itWorks, "setOpacity change markers opacity");
}
</script>
</head>
<body>

View File

@@ -25,6 +25,22 @@
}
function test_Layer_WFS_setOpacity(t) {
t.plan(3);
var layer = new OpenLayers.Layer.WFS(name, "url", {});
layer.setOpacity(.5);
t.eq(layer.opacity, 0.5, "vector setOpacity didn't fail");
var layer = new OpenLayers.Layer.WFS(name, "url", {}, {'featureClass': OpenLayers.Feature.WFS});
var marker = new OpenLayers.Marker(new OpenLayers.LonLat(0,0));
marker.setOpacity = function() {
t.ok(true, "Marker setOpacity was called");
}
layer.addMarker(marker);
layer.setOpacity(.6);
t.eq(layer.opacity, 0.6, "setOpacity didn't fail on markers");
}
function test_Layer_WFS_destroy(t) {
t.plan(13);

View File

@@ -281,6 +281,31 @@
}
function test_Layer_WMS_setOpacity (t) {
t.plan( 5 );
var map = new OpenLayers.Map('map');
map.projection = "xx";
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
tParams = { layers: 'basic',
format: 'image/png'};
tOptions = { 'opacity': '0.5' };
var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, tOptions);
map.addLayer(tLayer);
map.zoomToMaxExtent();
t.eq(tLayer.opacity, "0.5", "Opacity is set correctly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.5, "Opacity on tile is correct");
tLayer.setOpacity("0.6");
t.eq(tLayer.opacity, "0.6", "setOpacity works properly");
t.eq(parseFloat(tLayer.div.firstChild.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly");
var pixel = new OpenLayers.Pixel(5,6);
var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
tile.draw();
t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly");
map.destroy();
}
function test_Layer_WMS_Reproject (t) {
var validkey = (window.location.protocol == "file:") ||
(window.location.host == "localhost") ||

View File

@@ -1790,36 +1790,76 @@
}
function test_moveByPx(t) {
t.plan(8);
t.plan(16);
var moved;
var Layer = OpenLayers.Class(OpenLayers.Layer, {
moveByPx: function(dx, dy) {
moved[this.name] = true;
}
});
var map = new OpenLayers.Map({
div: 'map',
maxExtent: new OpenLayers.Bounds(-50, -50, 50, 50),
restrictedExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
layers: [
new OpenLayers.Layer('name', {isBaseLayer: true})
new Layer('base',
{isBaseLayer: true}),
new Layer('outofrange',
{isBaseLayer: false, minResolution:2})
]
});
moved = {};
map.zoomToExtent(new OpenLayers.Bounds(-1, -1, 1, 1));
// check initial state
t.eq(map.layerContainerDiv.style.left, '0px', 'layer container left correct');
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
t.eq(map.layerContainerDiv.style.left, '0px',
'[initial state] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '0px',
'[initial state] layer container top correct');
t.eq(moved['base'], undefined,
'[initial state] base layer not moved');
t.eq(moved['outofrange'], undefined,
'[initial state] out-of-range layer not moved');
// move to a valid position
moved = {};
map.moveByPx(-455, 455);
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
t.eq(map.layerContainerDiv.style.left, '455px',
'[valid position] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px',
'[valid position] layer container top correct');
t.eq(moved['base'], true,
'[valid position] base layer moved');
t.eq(moved['outofrange'], undefined,
'[valid position] out-of-range layer not moved');
// move outside the max extent
moved = {};
map.moveByPx(-4500, 4500);
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
t.eq(map.layerContainerDiv.style.left, '455px',
'[outside max extent] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px',
'[outside max extent] layer container top correct');
t.eq(moved['base'], undefined,
'[outside max extent] base layer not moved');
t.eq(moved['outofrange'], undefined,
'[outside max extent] out-of-range layer not moved');
// move outside the restricted extent
moved = {};
map.moveByPx(-500, 500);
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
t.eq(map.layerContainerDiv.style.left, '455px',
'[outside restricted extent] layer container left correct');
t.eq(map.layerContainerDiv.style.top, '-455px',
'[outside restricted extent] layer container top correct');
t.eq(moved['base'], undefined,
'[outside restricted extent] base layer not moved');
t.eq(moved['outofrange'], undefined,
'[outside restricted extent] out-of-range layer not moved');
map.destroy();
}

View File

@@ -150,7 +150,7 @@
t.eq(script.type, 'text/javascript',
'created script has a correct type');
t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.getCallback(bar)',
t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.registry%5Bbar%5D',
'created script has a correct url');
t.eq(script.id, 'OpenLayers_Protocol_Script_bar',
'created script has a correct id');

View File

@@ -2,20 +2,21 @@ import sys
import os
import tempfile
path = os.path.abspath(os.path.join(os.path.dirname(__file__), "closure-compiler.jar"))
path = "../tools/closure-compiler.jar"
if not os.path.exists(path):
raise Exception("No closure-compiler.jar at %s; read README.txt!" % path)
def minimize(code):
ntf = tempfile.NamedTemporaryFile()
ntf = tempfile.NamedTemporaryFile(delete=False)
ntf.write(code)
ntf.flush()
ntf2 = tempfile.NamedTemporaryFile()
os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
ntf2.seek(0)
data = ntf2.read()
ntf2 = tempfile.NamedTemporaryFile(delete=False)
ntf.close()
ntf2.close()
os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
data = open(ntf2.name).read()
os.unlink(ntf.name)
os.unlink(ntf2.name)
return data