Author: johnh
Date: Thu Feb 3 00:12:31 2011
New Revision: 1066703
URL: http://svn.apache.org/viewvc?rev=1066703&view=rev
Log:
Support inline/forced config via object set on window["___config"], if present.
Modified:
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
shindig/trunk/features/src/test/javascript/features/core/config-test.js
Modified:
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.config.base/config.js?rev=1066703&r1=1066702&r2=1066703&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
Thu Feb 3 00:12:31 2011
@@ -225,6 +225,8 @@ gadgets.config = function() {
configuration = config;
}
augmentConfig(configuration);
+ var inlineOverride = window["___config"] || {};
+ foldConfig(configuration, inlineOverride);
for (var name in components) {
if (components.hasOwnProperty(name)) {
var componentList = components[name], conf = configuration[name];
Modified:
shindig/trunk/features/src/test/javascript/features/core/config-test.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/core/config-test.js?rev=1066703&r1=1066702&r2=1066703&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/core/config-test.js
(original)
+++ shindig/trunk/features/src/test/javascript/features/core/config-test.js Thu
Feb 3 00:12:31 2011
@@ -37,6 +37,7 @@ ConfigTest.prototype.setUp = function()
ConfigTest.prototype.tearDown = function() {
gadgets.config.update({}, true); // "reset" gadgets lib
window["___jsl"] = undefined;
+ window["___config"] = undefined;
};
ConfigTest.prototype.testBasic = function() {
@@ -161,6 +162,21 @@ ConfigTest.prototype.testUpdateMerge = f
this.assertEquals(123, testListen.three.foo);
};
+ConfigTest.prototype.testMergeFromInlineConfig = function() {
+ var testListen;
+ gadgets.config.register("one", null, function(config) {
+ testListen = config;
+ });
+ window["___config"] = { one: { oneKey1: { oneSubkey1: "override" } } };
+ gadgets.config.init({
+ one: { oneKey1: { oneSubkey1: "oneVal1" }, oneKey2: "data" },
+ two: "twoVal1"
+ });
+ this.assertEquals("override", testListen.one.oneKey1.oneSubkey1);
+ this.assertEquals("data", testListen.one.oneKey2);
+ this.assertEquals("twoVal1", testListen.two);
+};
+
ConfigTest.prototype.testValidator = function() {
var validatorValue;
gadgets.config.register("testValidator", {data: function(value) {