Merge remote branch 'upstream/master' into 3320
This commit is contained in:
@@ -55,7 +55,20 @@ def build(config_file = None, output_file = None, options = None):
|
||||
elif use_compressor == "minimize":
|
||||
minimized = minimize.minimize(merged)
|
||||
elif use_compressor == "closure_ws":
|
||||
minimized = closure_ws.minimize(merged)
|
||||
if len(merged) > 1000000: # The maximum file size for this web service is 1000 KB.
|
||||
print "\nPre-compressing using jsmin"
|
||||
merged = jsmin.jsmin(merged)
|
||||
print "\nIs being compressed using Closure Compiler Service."
|
||||
try:
|
||||
minimized = closure_ws.minimize(merged)
|
||||
except Exception, E:
|
||||
print "\nAbnormal termination."
|
||||
sys.exit("ERROR: Closure Compilation using Web service failed!\n%s" % E)
|
||||
if len(minimized) <= 2:
|
||||
print "\nAbnormal termination due to compilation errors."
|
||||
sys.exit("ERROR: Closure Compilation using Web service failed!")
|
||||
else:
|
||||
print '\nClosure Compilation using Web service has completed successfully.'
|
||||
elif use_compressor == "closure":
|
||||
minimized = closure.minimize(merged)
|
||||
else: # fallback
|
||||
|
||||
@@ -122,7 +122,7 @@ OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.center = new OpenLayers.LonLat(parseFloat(args.lon),
|
||||
parseFloat(args.lat));
|
||||
if (args.zoom) {
|
||||
this.zoom = parseInt(args.zoom);
|
||||
this.zoom = parseFloat(args.zoom);
|
||||
}
|
||||
|
||||
// when we add a new baselayer to see when we can set the center
|
||||
|
||||
@@ -26,10 +26,14 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* send a list of strings corresponding to the geometry class names.
|
||||
*/
|
||||
geometryTypes: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: onStart
|
||||
* {Function} Define this function if you want to know when a drag starts.
|
||||
* {Function} *Deprecated*. Register for "beforefeaturemodified" instead.
|
||||
* The "beforefeaturemodified" event is triggered on the layer before
|
||||
* any modification begins.
|
||||
*
|
||||
* Define this function if you want to know when a drag starts.
|
||||
* The function should expect to receive two arguments: the feature
|
||||
* that is about to be dragged and the pixel location of the mouse.
|
||||
*
|
||||
@@ -42,7 +46,11 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: onDrag
|
||||
* {Function} Define this function if you want to know about each move of a
|
||||
* {Function} *Deprecated*. Register for "featuremodified" instead.
|
||||
* The "featuremodified" event is triggered on the layer with each
|
||||
* feature modification.
|
||||
*
|
||||
* Define this function if you want to know about each move of a
|
||||
* feature. The function should expect to receive two arguments: the
|
||||
* feature that is being dragged and the pixel location of the mouse.
|
||||
*
|
||||
@@ -54,7 +62,11 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: onComplete
|
||||
* {Function} Define this function if you want to know when a feature is
|
||||
* {Function} *Deprecated*. Register for "afterfeaturemodified" instead.
|
||||
* The "afterfeaturemodified" event is triggered on the layer after
|
||||
* a feature has been modified.
|
||||
*
|
||||
* Define this function if you want to know when a feature is
|
||||
* done dragging. The function should expect to receive two arguments:
|
||||
* the feature that is being dragged and the pixel location of the
|
||||
* mouse.
|
||||
@@ -273,6 +285,9 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
downFeature: function(pixel) {
|
||||
this.lastPixel = pixel;
|
||||
this.onStart(this.feature, pixel);
|
||||
return this.layer.events.triggerEvent(
|
||||
"beforefeaturemodified", {feature: this.feature}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -290,6 +305,8 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.layer.drawFeature(this.feature);
|
||||
this.lastPixel = pixel;
|
||||
this.onDrag(this.feature, pixel);
|
||||
this.layer.events.triggerEvent("featuremodified",
|
||||
{feature: this.feature});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -315,6 +332,9 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
doneDragging: function(pixel) {
|
||||
this.onComplete(this.feature, pixel);
|
||||
this.layer.events.triggerEvent("afterfeaturemodified", {
|
||||
feature: this.feature
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -122,6 +122,26 @@ OpenLayers.Request = {
|
||||
{proxy: OpenLayers.ProxyHost}
|
||||
);
|
||||
config = OpenLayers.Util.applyDefaults(config, defaultConfig);
|
||||
|
||||
// Always set the "X-Requested-With" header to signal that this request
|
||||
// was issued through the XHR-object. Since header keys are case
|
||||
// insensitive and we want to allow overriding of the "X-Requested-With"
|
||||
// header through the user we cannot use applyDefaults, but have to
|
||||
// check manually whether we were called with a "X-Requested-With"
|
||||
// header.
|
||||
var customRequestedWithHeader = false,
|
||||
headerKey;
|
||||
for(headerKey in config.headers) {
|
||||
if (config.headers.hasOwnProperty( headerKey )) {
|
||||
if (headerKey.toLowerCase() === 'x-requested-with') {
|
||||
customRequestedWithHeader = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (customRequestedWithHeader === false) {
|
||||
// we did not have a custom "X-Requested-With" header
|
||||
config.headers['X-Requested-With'] = 'XMLHttpRequest';
|
||||
}
|
||||
|
||||
// create request, open, and set headers
|
||||
var request = new OpenLayers.Request.XMLHttpRequest();
|
||||
|
||||
@@ -191,7 +191,7 @@ OpenLayers.Style = OpenLayers.Class({
|
||||
style.display = "none";
|
||||
}
|
||||
|
||||
if (style.label && typeof style.label !== "string") {
|
||||
if (style.label != null && typeof style.label !== "string") {
|
||||
style.label = String(style.label);
|
||||
}
|
||||
|
||||
|
||||
@@ -168,9 +168,13 @@
|
||||
}
|
||||
|
||||
function test_Control_DragFeature_move(t) {
|
||||
t.plan(3);
|
||||
t.plan(5);
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
layer.events.on({
|
||||
'beforefeaturemodified': function(evt) { t.ok(true, "beforefeaturemodified is triggered on the layer"); },
|
||||
'featuremodified': function(evt) { t.ok(true, "featuremodified is triggered on the layer"); }
|
||||
});
|
||||
map.addLayer(layer);
|
||||
var control = new OpenLayers.Control.DragFeature(layer);
|
||||
map.addControl(control);
|
||||
@@ -257,10 +261,13 @@
|
||||
}
|
||||
|
||||
function test_Control_DragFeature_done(t) {
|
||||
t.plan(2);
|
||||
t.plan(3);
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
map.addLayer(layer);
|
||||
layer.events.on({
|
||||
'afterfeaturemodified': function(evt) { t.ok(true, "afterfeaturemodified is triggered on the layer"); }
|
||||
});
|
||||
var control = new OpenLayers.Control.DragFeature(layer);
|
||||
map.addControl(control);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
function test_issue(t) {
|
||||
setup();
|
||||
|
||||
t.plan(22);
|
||||
t.plan(25);
|
||||
var request, config;
|
||||
var proto = OpenLayers.Request.XMLHttpRequest.prototype;
|
||||
var issue = OpenLayers.Function.bind(OpenLayers.Request.issue,
|
||||
@@ -96,19 +96,35 @@
|
||||
// reset open method
|
||||
proto.open = _open;
|
||||
|
||||
// test that headers are correctly set - 4 tests
|
||||
// test that headers are correctly set - 6 tests
|
||||
var _setRequestHeader = proto.setRequestHeader;
|
||||
config = {
|
||||
headers: {
|
||||
foo: "bar",
|
||||
chicken: "soup"
|
||||
chicken: "soup",
|
||||
// This checks whether the autoadded 'X-Requested-With'-header
|
||||
// can be overridden, even though the given key here is spelled
|
||||
// in lowercase.
|
||||
'x-requested-with': 'humpty'
|
||||
}
|
||||
};
|
||||
// we also track how often setRequestHeader is being called, it should
|
||||
// be called once for every header, even with the above defined
|
||||
// custom 'x-requested-with' header which we usually autoadd.
|
||||
// If the numbers match, we make sure to not send duplicate headers like
|
||||
// x-requested-with: humpty AND
|
||||
// X-Requested-With: XMLHttpRequest
|
||||
var actualSetHeaderCnt = 0;
|
||||
var expectedSetHeaderCnt = 3; // and not four!
|
||||
proto.setRequestHeader = function(key, value) {
|
||||
actualSetHeaderCnt++;
|
||||
t.ok(key in config.headers, "setRequestHeader called with key: " + key);
|
||||
t.eq(value, config.headers[key], "setRequestHeader called with correct value: " + value);
|
||||
}
|
||||
};
|
||||
request = issue(config);
|
||||
|
||||
t.eq(actualSetHeaderCnt, expectedSetHeaderCnt, 'A custom "x-requested-with" header overrides the default "X-Requested-With" header.');
|
||||
|
||||
proto.setRequestHeader = _setRequestHeader;
|
||||
|
||||
// test that callback is called (no scope) - 1 test
|
||||
@@ -444,6 +460,35 @@
|
||||
var req = OpenLayers.Request.GET();
|
||||
req.abort();
|
||||
}
|
||||
|
||||
function test_XRequestedWithHeaderAutoadded(t) {
|
||||
t.plan( 2 );
|
||||
|
||||
var headerSet = false;
|
||||
var headerGot = '';
|
||||
var headerExpected = 'XMLHttpRequest';
|
||||
|
||||
// save to be able to restore later
|
||||
var _setRequestHeader = OpenLayers.Request.XMLHttpRequest.prototype.setRequestHeader;
|
||||
|
||||
OpenLayers.Request.XMLHttpRequest.prototype.setRequestHeader = function(field, value) {
|
||||
if (field === 'X-Requested-With') {
|
||||
headerSet = true;
|
||||
headerGot = value;
|
||||
}
|
||||
};
|
||||
|
||||
var req = OpenLayers.Request.issue({
|
||||
url: location.href,
|
||||
async: false
|
||||
});
|
||||
|
||||
t.ok( headerSet, 'We call the method "setRequestHeader" to set a "X-Requested-With"-header' );
|
||||
t.eq( headerGot, headerExpected, 'The "X-Requested-With"-header is set to "' + headerExpected + '" as expected.' );
|
||||
|
||||
// restore old setRequestHeader
|
||||
OpenLayers.Request.XMLHttpRequest.prototype.setRequestHeader = _setRequestHeader;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -176,9 +176,9 @@
|
||||
|
||||
// c) test that label in returned symbolizer is a string even if property value is a number
|
||||
var symbolizer = style.createSymbolizer(
|
||||
new OpenLayers.Feature.Vector(null, {foo: "bar", labelValue: 10})
|
||||
new OpenLayers.Feature.Vector(null, {foo: "bar", labelValue: 0})
|
||||
);
|
||||
t.eq(symbolizer.label, "10", "c) feature property cast to string when used as symbolizer label");
|
||||
t.eq(symbolizer.label, "0", "c) feature property cast to string when used as symbolizer label");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user