1 | define([ |
---|
2 | "dojo/_base/kernel", |
---|
3 | "dojo/_base/lang", // dojo.extend getObject |
---|
4 | "dojo/_base/sniff", // dojo.isIE |
---|
5 | "dojox/gfx", |
---|
6 | "dojox/gfx/shape" |
---|
7 | ], function(dojo, lang, sniff, gfx, shape){ |
---|
8 | |
---|
9 | var dgo = lang.getObject("geo.openlayers", true, dojox); |
---|
10 | |
---|
11 | dgo.Patch = { |
---|
12 | |
---|
13 | patchMethod : function(/*Object*/type, /*String*/method, /*Function*/execBefore, /*Function*/ |
---|
14 | execAfter){ |
---|
15 | // summary: |
---|
16 | // Patches the specified method of the given type so that the 'execBefore' (resp. 'execAfter') function is |
---|
17 | // called before (resp. after) invoking the legacy implementation. |
---|
18 | // description: |
---|
19 | // The execBefore function is invoked with the following parameter: |
---|
20 | // execBefore(method, arguments) where 'method' is the patched method name and 'arguments' the arguments received |
---|
21 | // by the legacy implementation. |
---|
22 | // The execAfter function is invoked with the following parameter: |
---|
23 | // execBefore(method, returnValue, arguments) where 'method' is the patched method name, 'returnValue' the value |
---|
24 | // returned by the legacy implementation and 'arguments' the arguments received by the legacy implementation. |
---|
25 | // type: Object: the type to patch. |
---|
26 | // method: String: the method name. |
---|
27 | // execBefore: Function: the function to execute before the legacy implementation. |
---|
28 | // execAfter: Function: the function to execute after the legacy implementation. |
---|
29 | // tags: |
---|
30 | // private |
---|
31 | var old = type.prototype[method]; |
---|
32 | type.prototype[method] = function(){ |
---|
33 | var callee = method; |
---|
34 | if (execBefore) |
---|
35 | execBefore.call(this, callee, arguments); |
---|
36 | var ret = old.apply(this, arguments); |
---|
37 | if (execAfter) |
---|
38 | ret = execAfter.call(this, callee, ret, arguments) || ret; |
---|
39 | return ret; |
---|
40 | }; |
---|
41 | }, |
---|
42 | |
---|
43 | patchGFX : function(){ |
---|
44 | |
---|
45 | var vmlFixRawNodePath = function(){ |
---|
46 | if (!this.rawNode.path) |
---|
47 | this.rawNode.path = {}; |
---|
48 | }; |
---|
49 | |
---|
50 | var vmlFixFillColors = function() { |
---|
51 | if(this.rawNode.fill && !this.rawNode.fill.colors) |
---|
52 | this.rawNode.fill.colors = {}; |
---|
53 | }; |
---|
54 | |
---|
55 | if (sniff.isIE <= 8) { |
---|
56 | |
---|
57 | dojox.geo.openlayers.Patch.patchMethod(gfx.Line, "setShape", vmlFixRawNodePath, null); |
---|
58 | dojox.geo.openlayers.Patch.patchMethod(gfx.Polyline, "setShape", vmlFixRawNodePath, null); |
---|
59 | dojox.geo.openlayers.Patch.patchMethod(gfx.Path, "setShape", vmlFixRawNodePath, null); |
---|
60 | |
---|
61 | dojox.geo.openlayers.Patch.patchMethod(shape.Shape, "setFill", vmlFixFillColors, null); |
---|
62 | } |
---|
63 | } |
---|
64 | }; |
---|
65 | return dgo.Patch; |
---|
66 | }); |
---|