Debian Codegraph @

dojox/geo/openlayers/Patch.js

raw symbols SCIP
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
26 // the type to patch.
27 // method: String
28 // the method name.
29 // execBefore: Function
30 // the function to execute before the legacy implementation.
31 // execAfter: Function
32 // the function to execute after the legacy implementation.
33 // tags:
34 // private
35 var old = type.prototype[method];
36 type.prototype[method] = function(){
37 var callee = method;
38 if(execBefore){
39 execBefore.call(this, callee, arguments);
40 }
41 var ret = old.apply(this, arguments);
42 if(execAfter){
43 ret = execAfter.call(this, callee, ret, arguments) || ret;
44 }
45 return ret;
46 };
47 },
48
49 patchGFX: function(){
50
51 var vmlFixRawNodePath = function(){
52 if(!this.rawNode.path){
53 this.rawNode.path = {};
54 }
55 };
56
57 var vmlFixFillColors = function(){
58 if(this.rawNode.fill && !this.rawNode.fill.colors){
59 this.rawNode.fill.colors = {};
60 }
61 };
62
63 if(sniff.isIE <= 8 && gfx.renderer === "vml"){
64 this.patchMethod(gfx.Line, "setShape", vmlFixRawNodePath, null);
65 this.patchMethod(gfx.Polyline, "setShape", vmlFixRawNodePath, null);
66 this.patchMethod(gfx.Path, "setShape", vmlFixRawNodePath, null);
67
68 this.patchMethod(shape.Shape, "setFill", vmlFixFillColors, null);
69 }
70 }
71 };
72 return dgo.Patch;
73 });