Skip to content

Commit

Permalink
[dojo] added support for dojo/dijit aliases (e.g. scopeMap)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricioreyna committed Jan 14, 2012
1 parent d8cf7eb commit 273aa25
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
22 changes: 20 additions & 2 deletions dojofirebugextension/content/dojo/core/dojoaccess.js
Expand Up @@ -25,14 +25,28 @@ define([

var DojoAccess = {};

var _getAlias = function(name) {
var alias = name;
var aliases = DojoPrefs.getAliases();

if(aliases) {
alias = aliases[name] || name;
}
return alias;
};

//FIXME: This way of access objects is unsecure. Decouple communication with page and implement a secure mechanism.
var _dojo = DojoAccess._dojo = function(context) {
//UNSECURE
if(!context.window) {
return null;
}
var alias=_getAlias('dojo');
if(FBTrace.DBG_DOJO_ALIASES) {
FBTrace.sysout("DOJO ALIAS for dojo: "+alias);
}

return Wrapper.unwrapObject(context.window).dojo || null;
return Wrapper.unwrapObject(context.window)[alias] || null;
};

//FIXME: This way of access objects is unsecure. Decouple communication with page and implement a secure mechanism.
Expand All @@ -41,8 +55,12 @@ define([
if(!context.window) {
return null;
}
var alias=_getAlias('dijit');
if(FBTrace.DBG_DOJO_ALIASES) {
FBTrace.sysout("DOJO ALIAS for dijit: "+alias);
}

return Wrapper.unwrapObject(context.window).dijit || null;
return Wrapper.unwrapObject(context.window)[alias] || null;
};


Expand Down
28 changes: 27 additions & 1 deletion dojofirebugextension/content/dojo/core/prefs.js
Expand Up @@ -25,7 +25,7 @@ define([
var documentation_API_DOC_URL_BASE = "dojofirebugextension.documentation.API_DOC_URL_BASE";
var documentation_DOC_SORTED_VERSIONS = "dojofirebugextension.documentation.DOC_SORTED_VERSIONS";


var isExtensionEnabled = DojoPrefs.isExtensionEnabled = function() {
return Firebug.Options.getPref("extensions.firebug.dojofirebugextension", "enableSites");
};
Expand Down Expand Up @@ -104,6 +104,32 @@ define([
var getApiDocURL = DojoPrefs.getApiDocURL = function() {
return Firebug.Options.getPref(Firebug.Options.getPrefDomain(), documentation_API_DOC_URL_BASE);
};

//DOJO ALIASES (ie. scopeMap)
var aliasCacheStr, aliasCache;
DojoPrefs.getAliases = function() {
var value = Firebug.Options.getPref("extensions.firebug.dojofirebugextension", "aliases");
if(!value) {
return;
}
if(aliasCacheStr == value) {
if(FBTrace.DBG_DOJO_ALIASES) {
FBTrace.sysout("DOJO ALIASES - returning cached value: ", [value, aliasCacheStr, aliasCache]);
}
return aliasCache;
}
aliasCacheStr = value;
try {
aliasCache = JSON.parse(value);
return aliasCache;
} catch(err) {
if(FBTrace.DBG_DOJO_ALIASES) {
FBTrace.sysout("DOJO ALIASES ERROR: value="+value, err);
}
return;
}
};


// ***************************************************************

Expand Down
6 changes: 5 additions & 1 deletion dojofirebugextension/defaults/preferences/prefs.js
Expand Up @@ -18,9 +18,13 @@ pref("extensions.firebug.DBG_DOJO_CONN_COUNTER", false);
pref("extensions.firebug.DBG_DOJO_DBG_DOC", false);
pref("extensions.firebug.DBG_DOJO_CONTEXTMENU", false);
pref("extensions.firebug.DBG_DOJO_DBG_VERSIONS", false);
pref("extensions.firebug.DBG_DOJO_ALIASES", false);

//Dojo documentation related preferences
pref("extensions.firebug.dojofirebugextension.documentation.REFERENCE_GUIDE_URL", "http://dojotoolkit.org/reference-guide/");
pref("extensions.firebug.dojofirebugextension.documentation.API_DOC_URL_BASE", "http://dojotoolkit.org/api/");
//DOC_SORTED_VERSIONS contains the available documentation version numbers in the http://dojotoolkit.org/api/ page
pref("extensions.firebug.dojofirebugextension.documentation.DOC_SORTED_VERSIONS", "1.3,1.4,1.5,1.6,1.7");
pref("extensions.firebug.dojofirebugextension.documentation.DOC_SORTED_VERSIONS", "1.3,1.4,1.5,1.6,1.7");

//aliases (eg. \"{'dojo':'myDojo', 'dijit': 'myDijit', 'dojox': 'myDojox'}\" )
pref("extensions.firebug.dojofirebugextension.aliases", "");

0 comments on commit 273aa25

Please sign in to comment.