Created
May 13, 2011 16:05
-
-
Save bryanforbes/970808 to your computer and use it in GitHub Desktop.
gfx situation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // dojox/gfx.js | |
| define(['dojo/_base/kernel'], function(dojo){ | |
| var gfx = dojo.getObject("gfx", true, dojox); | |
| // this is actualy added in dojox/gfx/_base.js | |
| dojo.mixin(gfx, { | |
| switchTo: function(renderer){ | |
| var ns = gfx[renderer]; | |
| if(ns){ | |
| dojo.mixin(gfx, ns); | |
| } | |
| } | |
| }); | |
| // this is actually set by checking a few different | |
| // renderer types | |
| gfx.renderer = 'svg'; | |
| if(gfx[gfx.renderer]){ | |
| // already loaded | |
| gfx.switchTo(gfx.renderer); | |
| }else{ | |
| // load | |
| gfx.loadAndSwitch = gfx.renderer; | |
| require(['./' + gfx.renderer], function(renderer){ | |
| if(dojo.config.isDebug){ | |
| console.debug("loaded gfx renderer:",renderer); | |
| } | |
| }); | |
| } | |
| return gfx; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>GFX situation</title> | |
| <script> | |
| var dojoConfig = { | |
| async: true | |
| }; | |
| </script> | |
| <script src="dojo/dojo.js"></script> | |
| <script> | |
| require(['dojox/gfx'], function(gfx){ | |
| console.log("Is the createSurface function defined? " + !!gfx.createSurface); | |
| }); | |
| </script> | |
| </head> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // dojox/gfx/svg.js | |
| define(['dojox/gfx'], function(gfx){ | |
| var svg = dojo.getObject("gfx.svg", true, dojox); | |
| svg.createSurface = function(){}; | |
| // see if we are required to initilize | |
| if(gfx.loadAndSwitch === "svg"){ | |
| gfx.switchTo("svg"); | |
| delete gfx.loadAndSwitch; | |
| } | |
| return svg; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment