diff --git a/src/webapp/components/uiOptions/js/FatPanelUIOptions.js b/src/webapp/components/uiOptions/js/FatPanelUIOptions.js index ebbc9d4492..d2e812cbda 100644 --- a/src/webapp/components/uiOptions/js/FatPanelUIOptions.js +++ b/src/webapp/components/uiOptions/js/FatPanelUIOptions.js @@ -30,8 +30,6 @@ var fluid_1_5 = fluid_1_5 || {}; /***************************************** * Fat Panel UI Options Top Level Driver * *****************************************/ - - fluid.registerNamespace("fluid.uiOptions.fatPanel"); fluid.defaults("fluid.uiOptions.fatPanel", { gradeNames: ["fluid.uiOptions.inline", "autoInit"], @@ -42,7 +40,7 @@ var fluid_1_5 = fluid_1_5 || {}; listeners: { onReady: { listener: "fluid.uiOptions.fatPanel.bindEvents", - args: ["{fatPanel}.uiOptionsLoader.uiOptions", "{uiEnhancer}", "{iframeRenderer}.iframeEnhancer", "{fatPanel}"] + args: ["{fatPanel}.uiOptionsLoader.uiOptions", "{iframeRenderer}.iframeEnhancer", "{fatPanel}"] } }, selectors: { @@ -120,6 +118,7 @@ var fluid_1_5 = fluid_1_5 || {}; createOnEvent: "templatesAndIframeReady", container: "{iframeRenderer}.renderUIOContainer", options: { + gradeNames: ["fluid.uiOptions.uiEnhancerRelay"], // ensure that model and applier are available to users at top level model: "{fatPanel}.model", applier: "{fatPanel}.applier", @@ -197,24 +196,24 @@ var fluid_1_5 = fluid_1_5 || {}; that.iframe.appendTo(that.container); }; - fluid.uiOptions.fatPanel.updateView = function (uiOptions, uiEnhancer) { + fluid.uiOptions.fatPanel.updateView = function (uiOptions) { uiOptions.events.onSignificantDOMChange.fire(); }; - fluid.uiOptions.fatPanel.bindEvents = function (uiOptions, uiEnhancer, iframeEnhancer, fatPanel) { + fluid.uiOptions.fatPanel.bindEvents = function (uiOptions, iframeEnhancer, fatPanel) { // TODO: This binding should be done declaratively - needs ginger world in order to bind onto slidingPanel // which is a child of this component - and also uiOptionsLoader which is another child fatPanel.slidingPanel.events.afterPanelShow.addListener(function () { iframeEnhancer.events.onIframeVisible.fire(iframeEnhancer); - fluid.uiOptions.fatPanel.updateView(uiOptions, iframeEnhancer); + fluid.uiOptions.fatPanel.updateView(uiOptions); }); uiOptions.events.modelChanged.addListener(function (model) { - uiEnhancer.updateModel(model.selections); + iframeEnhancer.updateModel(model.selections); uiOptions.save(); }); uiOptions.events.onReset.addListener(function (uiOptions) { - fluid.uiOptions.fatPanel.updateView(uiOptions, iframeEnhancer); + fluid.uiOptions.fatPanel.updateView(uiOptions); }); uiOptions.events.onSignificantDOMChange.addListener(function () { var dokkument = uiOptions.container[0].ownerDocument; diff --git a/src/webapp/components/uiOptions/js/ModelRelay.js b/src/webapp/components/uiOptions/js/ModelRelay.js index 5f8ac4687b..b11447755c 100644 --- a/src/webapp/components/uiOptions/js/ModelRelay.js +++ b/src/webapp/components/uiOptions/js/ModelRelay.js @@ -32,24 +32,38 @@ var fluid_1_5 = fluid_1_5 || {}; mergePolicy: { sourceApplier: "nomerge" }, + listeners: { + onCreate: "{that}.addListeners", + onDestroy: "{that}.removeListeners" + }, + invokers: { + addListeners: { + funcName: "fluid.uiOptions.modelRelay.addListeners", + args: ["{that}.options.rules", "{that}.applier", "{that}.options.sourceApplier", "{that}.id"] + }, + removeListeners: { + funcName: "fluid.uiOptions.modelRelay.removeListeners", + args: ["{that}.options.rules", "{that}.options.sourceApplier", "{that}.id"] + } + }, sourceApplier: null, // must be supplied by implementors - rules: {}, // must be supplied by implementors, in format: "externalModelKey": "internalModelKey" - postInitFunction: "fluid.uiOptions.modelRelay.postInit" + rules: {} // must be supplied by implementors, in format: "externalModelKey": "internalModelKey" }); - - fluid.uiOptions.modelRelay.postInit = function (that) { - fluid.transform(that.options.rules, function (internalKey, sourceKey) { - that.applier.modelChanged.addListener(internalKey, function (newModel, oldModel) { - if (!that.applier.hasChangeSource(sourceKey)) { - fluid.fireSourcedChange(that.options.sourceApplier, sourceKey, fluid.get(newModel, internalKey), internalKey); - } - }); - - that.options.sourceApplier.modelChanged.addListener(sourceKey, function (newModel, oldModel) { - if (!that.options.sourceApplier.hasChangeSource(internalKey)) { - fluid.fireSourcedChange(that.applier, internalKey, fluid.get(newModel, sourceKey), sourceKey); - } + + fluid.uiOptions.modelRelay.removeListeners = function (rules, applier, namespace) { + fluid.each(rules, function () { + applier.removeListener(namespace); + }); + }; + + fluid.uiOptions.modelRelay.addListeners = function (rules, applier, sourceApplier, namespace) { + fluid.each(rules, function (internalKey, sourceKey) { + fluid.addSourceGuardedListener(applier, internalKey, sourceKey, function (newModel) { + fluid.fireSourcedChange(sourceApplier, sourceKey, fluid.get(newModel, internalKey), internalKey) }); + fluid.addSourceGuardedListener(sourceApplier, sourceKey, internalKey, function (newModel) { + fluid.fireSourcedChange(applier, internalKey, fluid.get(newModel, sourceKey), sourceKey); + }, undefined, namespace); }); }; diff --git a/src/webapp/components/uiOptions/js/SettingsPanels.js b/src/webapp/components/uiOptions/js/SettingsPanels.js index f52d517441..6414f5322b 100644 --- a/src/webapp/components/uiOptions/js/SettingsPanels.js +++ b/src/webapp/components/uiOptions/js/SettingsPanels.js @@ -323,7 +323,7 @@ var fluid_1_5 = fluid_1_5 || {}; "selections.textSize": "value" }, model: { - value: "{uiOptions}.defaultModel.textSize" + value: "{fluid.uiOptions.defaultModel}.defaultModel.textSize" }, resources: { template: "{templateLoader}.resources.textSizer" @@ -340,7 +340,7 @@ var fluid_1_5 = fluid_1_5 || {}; "selections.lineSpacing": "value" }, model: { - value: "{uiOptions}.defaultModel.lineSpacing" + value: "{fluid.uiOptions.defaultModel}.defaultModel.lineSpacing" }, resources: { template: "{templateLoader}.resources.lineSpacer" @@ -358,7 +358,7 @@ var fluid_1_5 = fluid_1_5 || {}; "selections.textFont": "value" }, model: { - value: "{uiOptions}.defaultModel.textFont" + value: "{fluid.uiOptions.defaultModel}.defaultModel.textFont" }, resources: { template: "{templateLoader}.resources.textFont" @@ -376,7 +376,7 @@ var fluid_1_5 = fluid_1_5 || {}; "selections.theme": "value" }, model: { - value: "{uiOptions}.defaultModel.theme" + value: "{fluid.uiOptions.defaultModel}.defaultModel.theme" }, resources: { template: "{templateLoader}.resources.contrast" @@ -394,8 +394,8 @@ var fluid_1_5 = fluid_1_5 || {}; "selections.layout": "layout" }, model: { - toc: "{uiOptions}.defaultModel.toc", - layout: "{uiOptions}.defaultModel.layout" + toc: "{fluid.uiOptions.defaultModel}.defaultModel.toc", + layout: "{fluid.uiOptions.defaultModel}.defaultModel.layout" }, resources: { template: "{templateLoader}.resources.layoutControls" @@ -413,8 +413,8 @@ var fluid_1_5 = fluid_1_5 || {}; "selections.inputsLarger": "inputsLarger" }, model: { - links: "{uiOptions}.defaultModel.links", - inputsLarger: "{uiOptions}.defaultModel.inputsLarger" + links: "{fluid.uiOptions.defaultModel}.defaultModel.links", + inputsLarger: "{fluid.uiOptions.defaultModel}.defaultModel.inputsLarger" }, resources: { template: "{templateLoader}.resources.linksControls" diff --git a/src/webapp/components/uiOptions/js/Store.js b/src/webapp/components/uiOptions/js/Store.js index ac8941a33b..ccd53453d5 100644 --- a/src/webapp/components/uiOptions/js/Store.js +++ b/src/webapp/components/uiOptions/js/Store.js @@ -139,4 +139,21 @@ var fluid_1_5 = fluid_1_5 || {}; applier.requestChange("", settings); }; + fluid.defaults("fluid.globalSettingsStore", { + gradeNames: ["autoInit", "fluid.littleComponent"], + components: { + settingsStore: { + type: "fluid.uiOptions.store" + } + } + }); + + fluid.globalSettingsStore.finalInit = function (that) { + fluid.staticEnvironment.settingsStore = that.settingsStore; + }; + + fluid.demands("fluid.uiOptions.store", ["fluid.globalSettingsStore"], { + funcName: "fluid.cookieStore" + }); + })(jQuery, fluid_1_5); \ No newline at end of file diff --git a/src/webapp/components/uiOptions/js/UIEnhancer.js b/src/webapp/components/uiOptions/js/UIEnhancer.js index f72537c46b..59adacf75c 100755 --- a/src/webapp/components/uiOptions/js/UIEnhancer.js +++ b/src/webapp/components/uiOptions/js/UIEnhancer.js @@ -114,7 +114,7 @@ var fluid_1_5 = fluid_1_5 || {}; "textSize": "value" }, model: { - value: "{uiOptions}.defaultModel.textSize" + value: "{fluid.uiOptions.defaultModel}.defaultModel.textSize" } } }, @@ -128,7 +128,7 @@ var fluid_1_5 = fluid_1_5 || {}; "textFont": "value" }, model: { - value: "{uiOptions}.defaultModel.textFont" + value: "{fluid.uiOptions.defaultModel}.defaultModel.textFont" } } }, @@ -142,7 +142,7 @@ var fluid_1_5 = fluid_1_5 || {}; "lineSpacing": "value" }, model: { - value: "{uiOptions}.defaultModel.lineSpacing" + value: "{fluid.uiOptions.defaultModel}.defaultModel.lineSpacing" } } }, @@ -156,7 +156,7 @@ var fluid_1_5 = fluid_1_5 || {}; "theme": "value" }, model: { - value: "{uiOptions}.defaultModel.theme" + value: "{fluid.uiOptions.defaultModel}.defaultModel.theme" } } }, @@ -170,7 +170,7 @@ var fluid_1_5 = fluid_1_5 || {}; "links": "value" }, model: { - links: "{uiOptions}.defaultModel.links" + links: "{fluid.uiOptions.defaultModel}.defaultModel.links" } } }, @@ -184,7 +184,7 @@ var fluid_1_5 = fluid_1_5 || {}; "inputsLarger": "value" }, model: { - inputsLarger: "{uiOptions}.defaultModel.inputsLarger" + inputsLarger: "{fluid.uiOptions.defaultModel}.defaultModel.inputsLarger" } } }, @@ -203,7 +203,7 @@ var fluid_1_5 = fluid_1_5 || {}; onLateRefreshRelay: "{uiEnhancer}.events.onAsyncEnactorReady" }, model: { - toc: "{uiOptions}.defaultModel.toc" + toc: "{fluid.uiOptions.defaultModel}.defaultModel.toc" } } }, @@ -216,7 +216,7 @@ var fluid_1_5 = fluid_1_5 || {}; "theme": "value" }, model: { - value: "{uiOptions}.defaultModel.theme" + value: "{fluid.uiOptions.defaultModel}.defaultModel.theme" } } } @@ -260,12 +260,13 @@ var fluid_1_5 = fluid_1_5 || {}; that.options.originalUserOptions = fluid.copy(uiEnhancerOptions); that.uiEnhancerOptions = uiEnhancerOptions; fluid.initDependents(that); + that.uiEnhancer.updateModel(that.getSettings()); fluid.staticEnvironment.uiEnhancer = that.uiEnhancer; return that; }; fluid.defaults("fluid.pageEnhancer", { - gradeNames: ["fluid.originalEnhancerOptions"], + gradeNames: ["fluid.originalEnhancerOptions", "fluid.uiOptions.defaultModel", "fluid.uiOptions.settingsGetter"], components: { uiEnhancer: { type: "fluid.uiEnhancer", diff --git a/src/webapp/components/uiOptions/js/UIOptions.js b/src/webapp/components/uiOptions/js/UIOptions.js index 7a2b9314ab..1dba511737 100644 --- a/src/webapp/components/uiOptions/js/UIOptions.js +++ b/src/webapp/components/uiOptions/js/UIOptions.js @@ -258,13 +258,10 @@ var fluid_1_5 = fluid_1_5 || {}; * @param {Object} options */ fluid.defaults("fluid.uiOptions", { - gradeNames: ["fluid.viewComponent", "autoInit"], + gradeNames: ["fluid.viewComponent", "fluid.uiOptions.settingsGetter", "fluid.uiOptions.settingsSetter", "autoInit"], components: { eventBinder: { type: "fluid.uiOptions.eventBinder" - }, - settingsStore: { - type: "fluid.uiOptions.store" } }, invokers: { @@ -304,6 +301,33 @@ var fluid_1_5 = fluid_1_5 || {}; autoSave: false }); + fluid.defaults("fluid.uiOptions.settingsGetter", { + gradeNames: ["fluid.littleComponent", "autoInit"], + members: { + getSettings: "{settingsStore}.get" + } + }); + + fluid.defaults("fluid.uiOptions.settingsSetter", { + gradeNames: ["fluid.littleComponent", "autoInit"], + invokers: { + setSettings: { + funcName: "fluid.uiOptions.settingsSetter.setSettings", + args: ["{fluid.uiOptions.defaultModel}", "{arguments}.0", "{settingsStore}.set"] + } + } + }); + + fluid.uiOptions.settingsSetter.setSettings = function (defaultModel, model, set) { + var userSettings = fluid.copy(model); + if (defaultModel) { + fluid.remove_if(userSettings, function (settingVal, settingKey) { + return settingVal === defaultModel[settingKey] + }); + } + set(userSettings); + }; + fluid.defaults("fluid.uiOptions.defaultModel", { gradeNames: ["fluid.littleComponent", "autoInit"], members: { @@ -322,6 +346,40 @@ var fluid_1_5 = fluid_1_5 || {}; } } }); + + fluid.defaults("fluid.uiOptions.uiEnhancerRelay", { + gradeNames: ["autoInit", "fluid.eventedComponent"], + listeners: { + onCreate: "{that}.addListener", + onDestroy: "{that}.removeListener" + }, + invokers: { + addListener: { + funcName: "fluid.uiOptions.uiEnhancerRelay.addListener", + args: ["{fluid.uiOptions}.events.modelChanged", "{that}.updateEnhancerModel"] + }, + removeListener: { + funcName: "fluid.uiOptions.uiEnhancerRelay.removeListener", + args: ["{fluid.uiOptions}.events.modelChanged", "{that}.updateEnhancerModel"] + }, + updateEnhancerModel: { + funcName: "fluid.uiOptions.uiEnhancerRelay.updateEnhancerModel", + args: ["{uiEnhancer}", "{arguments}.0"] + } + } + }); + + fluid.uiOptions.uiEnhancerRelay.addListener = function (modelChanged, listener) { + modelChanged.addListener(listener); + }; + + fluid.uiOptions.uiEnhancerRelay.removeListener = function (modelChanged, listener) { + modelChanged.removeListener(listener); + }; + + fluid.uiOptions.uiEnhancerRelay.updateEnhancerModel = function (uiEnhancer, newModel) { + uiEnhancer.updateModel(newModel.selections); + }; // called once markup is applied to the document containing tab component roots fluid.uiOptions.finishInit = function (that) { @@ -349,7 +407,7 @@ var fluid_1_5 = fluid_1_5 || {}; fluid.uiOptions.preInit = function (that) { that.fetch = function () { - var initialModel = that.settingsStore.get(); + var initialModel = that.getSettings(); initialModel = $.extend(true, {}, that.defaultModel, initialModel); that.updateModel(initialModel, "settingsStore"); that.events.onUIOptionsRefresh.fire(); @@ -362,7 +420,7 @@ var fluid_1_5 = fluid_1_5 || {}; that.events.onSave.fire(that.model.selections); var savedSelections = fluid.copy(that.model.selections); - that.settingsStore.set(savedSelections); + that.setSettings(savedSelections); }; that.saveAndApply = function () { @@ -393,12 +451,6 @@ var fluid_1_5 = fluid_1_5 || {}; that.events.onAutoSave.fire(); } }); - - fluid.addSourceGuardedListener(that.applier, "selections", "settingsStore", - function (newModel, oldModel, changeRequest) { - that.uiEnhancer.updateModel(fluid.get(that.model, changeRequest[0].path)) - } - ); }; fluid.uiOptions.finalInit = function (that) { @@ -442,7 +494,10 @@ var fluid_1_5 = fluid_1_5 || {}; enhancer: { type: "fluid.uiEnhancer", container: "{preview}.enhancerContainer", - createOnEvent: "onReady" + createOnEvent: "onReady", + options: { + gradeNames: ["fluid.uiOptions.uiEnhancerRelay"] + } }, eventBinder: { type: "fluid.uiOptions.preview.eventBinder", @@ -507,8 +562,4 @@ var fluid_1_5 = fluid_1_5 || {}; } }); - fluid.demands("fluid.uiOptions.store", ["fluid.uiOptions"], { - funcName: "fluid.cookieStore" - }); - })(jQuery, fluid_1_5); diff --git a/src/webapp/framework/core/js/DataBinding.js b/src/webapp/framework/core/js/DataBinding.js index 93841fe281..9bfe7d8514 100644 --- a/src/webapp/framework/core/js/DataBinding.js +++ b/src/webapp/framework/core/js/DataBinding.js @@ -420,16 +420,17 @@ var fluid_1_5 = fluid_1_5 || {}; * @param path The path specification to listen to * @param source The source value to exclude (direct equality used) * @param func The listener to be notified of a change - * @param [eventName] - optional - the event name to be listened to - defaults to "modelChanged" + * @param [eventName] - optional - the event name to be listened to - defaults to "modelChanged" + * @param [namespace] - optional - the event namespace */ - fluid.addSourceGuardedListener = function(applier, path, source, func, eventName) { + fluid.addSourceGuardedListener = function(applier, path, source, func, eventName, namespace) { eventName = eventName || "modelChanged"; applier[eventName].addListener(path, function() { if (!applier.hasChangeSource(source)) { func.apply(null, arguments); } - }); + }, namespace); }; /** Convenience method to fire a change event to a specified applier, including diff --git a/src/webapp/tests/component-tests/uiOptions/html/ModelRelay-test.html b/src/webapp/tests/component-tests/uiOptions/html/ModelRelay-test.html index 2b6212a63e..4546eb8b93 100644 --- a/src/webapp/tests/component-tests/uiOptions/html/ModelRelay-test.html +++ b/src/webapp/tests/component-tests/uiOptions/html/ModelRelay-test.html @@ -2,7 +2,7 @@ - Builder Tests + Model Relay Tests diff --git a/src/webapp/tests/component-tests/uiOptions/js/FatPanelUIOptionsTests.js b/src/webapp/tests/component-tests/uiOptions/js/FatPanelUIOptionsTests.js index 62de969b30..830844d4da 100644 --- a/src/webapp/tests/component-tests/uiOptions/js/FatPanelUIOptionsTests.js +++ b/src/webapp/tests/component-tests/uiOptions/js/FatPanelUIOptionsTests.js @@ -31,6 +31,9 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.defaults("fluid.tests.fatPanelIntegration", { gradeNames: ["fluid.test.testEnvironment", "autoInit"], + listeners: { + onDestroy: "fluid.tests.clearStore" + }, components: { fatPanel: { type: "fluid.uiOptions.fatPanel", @@ -53,7 +56,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }, uiOptions: { options: { - gradeNames: ["fluid.uiOptions.defaultSettingsPanels", "fluid.uiOptions.defaultModel"] + gradeNames: ["fluid.uiOptions.defaultSettingsPanels", "fluid.uiOptions.defaultModel", "fluid.uiOptions.uiEnhancerRelay"] } } } @@ -64,6 +67,11 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt } }); + // Cleanup listener that restores a global settings store model to default. + fluid.tests.clearStore = function () { + fluid.staticEnvironment.settingsStore.set(); + }; + fluid.tests.testComponent = function (uiOptionsLoader, uiOptions) { jqUnit.assertEquals("IFrame is invisible and keyboard inaccessible", false, uiOptions.iframeRenderer.iframe.is(":visible")); @@ -93,7 +101,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.tests.afterShowFunc3 = function (fatPanel) { return function () { - var defaultSiteSettings = fatPanel.pageEnhancer.settingsStore.options.defaultSiteSettings; + var defaultSiteSettings = fatPanel.uiOptionsLoader.uiOptions.defaultModel; var pageModel = fatPanel.pageEnhancer.model; var panelModel = fatPanel.iframeRenderer.iframeEnhancer.model; @@ -110,7 +118,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt modules: [{ name: "Fat panel integration tests", tests: [{ - expect: 19, + expect: 18, name: "Fat panel integration tests", sequence: [{ listener: "fluid.tests.testComponent", @@ -165,6 +173,15 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt src: "./FatPanelUIOptionsFrame.html" } } + }, + uiOptions: { + options: { + members: { + defaultModel: { + theme: "yb" + } + } + } } }) }, @@ -202,6 +219,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt $(document).ready(function () { + fluid.globalSettingsStore(); fluid.pageEnhancer(fluid.tests.uiOptions.enhancerOptions); fluid.test.runTests([ diff --git a/src/webapp/tests/component-tests/uiOptions/js/IntegrationTestsCommon.js b/src/webapp/tests/component-tests/uiOptions/js/IntegrationTestsCommon.js index 88f68ee714..2a395a6235 100644 --- a/src/webapp/tests/component-tests/uiOptions/js/IntegrationTestsCommon.js +++ b/src/webapp/tests/component-tests/uiOptions/js/IntegrationTestsCommon.js @@ -21,7 +21,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.staticEnvironment.uiOptionsTest = fluid.typeTag("fluid.tests.uiOptions"); // Use temp store rather than the cookie store for setting save - fluid.demands("fluid.uiOptions.store", ["fluid.uiOptions", "fluid.tests.uiOptions"], { + fluid.demands("fluid.uiOptions.store", ["fluid.globalSettingsStore", "fluid.tests.uiOptions"], { funcName: "fluid.tempStore" }); @@ -56,7 +56,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt "contrast", "layoutControls", "linksControls", - "settingsStore", "eventBinder" ], "fluid.uiOptions.fullNoPreview": [ @@ -66,7 +65,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt "contrast", "layoutControls", "linksControls", - "settingsStore", "eventBinder" ], "fluid.uiOptions.fullPreview": [ @@ -77,7 +75,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt "layoutControls", "linksControls", "preview", - "settingsStore", "eventBinder" ] }; @@ -102,6 +99,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.tests.uiOptions.integrationTest = function (componentName, resetShouldSave) { jqUnit.asyncTest(componentName + " Integration tests", function () { + fluid.globalSettingsStore(); fluid.pageEnhancer({ gradeNames: ["fluid.uiEnhancer.defaultActions"], tocTemplate: "../../../../components/tableOfContents/html/TableOfContents.html" @@ -116,7 +114,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt } function testComponent(uiOptionsLoader, uiOptions) { - var defaultModel = uiOptions.settingsStore.options.defaultModel; + var defaultModel = uiOptions.defaultModel; fluid.tests.uiOptions.assertPresent(uiOptions, fluid.tests.uiOptions.expectedComponents[componentName]); fluid.tests.uiOptions.applierRequestChanges(uiOptions, fluid.tests.uiOptions.bwSkin); @@ -243,7 +241,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }, uiOptions: { options: { - gradeNames: ["fluid.uiOptions.defaultSettingsPanels", "fluid.uiOptions.defaultModel"] + gradeNames: ["fluid.uiOptions.defaultSettingsPanels", "fluid.uiOptions.defaultModel", "fluid.uiOptions.uiEnhancerRelay"] } } }; @@ -252,6 +250,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt extraListener = extraListener || function () { jqUnit.start(); }; jqUnit.asyncTest(componentName + " Munging Integration tests", function () { + fluid.globalSettingsStore(); fluid.pageEnhancer(fluid.tests.uiOptions.enhancerOptions); var options = fluid.merge(null, fluid.tests.uiOptions.mungingIntegrationOptions, { uiOptionsLoader: { diff --git a/src/webapp/tests/component-tests/uiOptions/js/PageEnhancerTests.js b/src/webapp/tests/component-tests/uiOptions/js/PageEnhancerTests.js index 835ad89675..7614c17e5a 100644 --- a/src/webapp/tests/component-tests/uiOptions/js/PageEnhancerTests.js +++ b/src/webapp/tests/component-tests/uiOptions/js/PageEnhancerTests.js @@ -24,8 +24,8 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt createPageEnhancer: null }, components: { - uiOptions: { - type: "fluid.uiOptions.defaultModel" + settingsStore: { + type: "fluid.globalSettingsStore" }, pageEnhancer: { type: "fluid.pageEnhancer", diff --git a/src/webapp/tests/component-tests/uiOptions/js/UIOptionsTests.js b/src/webapp/tests/component-tests/uiOptions/js/UIOptionsTests.js index e48cf32bcb..58a535ee53 100644 --- a/src/webapp/tests/component-tests/uiOptions/js/UIOptionsTests.js +++ b/src/webapp/tests/component-tests/uiOptions/js/UIOptionsTests.js @@ -67,7 +67,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.demands("fluid.uiOptions", ["fluid.uiOptionsTests", "fluid.uiOptions.tests"], { funcName: "fluid.uiOptions.defaultSettingsPanels", options: { - gradeNames: ["fluid.uiOptions.defaultModel"], + gradeNames: ["fluid.uiOptions.defaultModel", "fluid.uiOptions.uiEnhancerRelay"], components: { uiEnhancer: { type: "fluid.uiEnhancer", @@ -85,8 +85,8 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt } } }); - - fluid.demands("fluid.uiOptions.store", ["fluid.uiOptions", "fluid.uiOptions.tests"], { + + fluid.demands("fluid.uiOptions.store", ["fluid.globalSettingsStore", "fluid.uiOptions.tests"], { funcName: "fluid.tempStore" }); @@ -115,6 +115,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt var testUIOptions = function (testFn, uio) { uio = uio || fluid.uiOptionsTests; uio.testFn = testFn; + fluid.globalSettingsStore(); uio("#ui-options"); }; @@ -376,7 +377,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt var container = $("body"); jqUnit.assertTrue("Save has been called", saveCalled); - var uiEnhancerSettings = uiOptions.settingsStore.get(); + var uiEnhancerSettings = uiOptions.getSettings(); jqUnit.assertDeepEq("bw setting was saved", bwSkin.theme, uiEnhancerSettings.theme); jqUnit.assertTrue("Body has the high contrast colour scheme", container.hasClass("fl-theme-bw")); jqUnit.assertEquals("Text size has been saved", bwSkin.textSize, uiOptions.model.selections.textSize); @@ -408,7 +409,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt jqUnit.assertEquals("bw setting was set in the model", bwSkin.theme, uiOptions.model.selections.theme); - var uiEnhancerSettings = uiOptions.settingsStore.get(); + var uiEnhancerSettings = uiOptions.getSettings(); jqUnit.assertUndefined("bw setting was not saved", uiEnhancerSettings.theme); uiOptions.events.onUIOptionsRefresh.fire(); @@ -488,15 +489,15 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt applierRequestChanges(uiOptions, saveModel); checkModelSelections("After apply saveModel", saveModel, uiOptions.model.selections); saveButton.click(); - checkModelSelections("After clicking save", saveModel, uiOptions.settingsStore.get()); + checkModelSelections("After clicking save", saveModel, uiOptions.getSettings()); applierRequestChanges(uiOptions, cancelModel); cancelButton.click(); checkModelSelections("After applying cancelModel and clicking cancel", saveModel, - uiOptions.settingsStore.get()); + uiOptions.getSettings()); resetButton.click(); checkModelSelections("After clicking reset", uiOptions.defaultModel, uiOptions.model.selections); cancelButton.click(); - checkModelSelections("After clicking cancel", saveModel, uiOptions.settingsStore.get()); + checkModelSelections("After clicking cancel", saveModel, uiOptions.getSettings()); // apply the reset settings to make the test result page more readable resetButton.click(); @@ -564,7 +565,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt "contrast": false, "layoutControls": false, "linksControls": false, - "options.components.settingsStore": true, "uiEnhancer.options.components.tableOfContentsEnactor": true }; @@ -624,7 +624,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt "contrast": true, "layoutControls": true, "linksControls": true, - "options.components.settingsStore": true, "uiEnhancer.options.components.tableOfContentsEnactor": true }; @@ -657,7 +656,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt uiOptions.updateModel(bwSkin); jqUnit.assertTrue("Model has changed, auto-save changes", saveCalled); - var uiEnhancerSettings = uiOptions.settingsStore.get(); + var uiEnhancerSettings = uiOptions.getSettings(); jqUnit.assertDeepEq("bw setting was saved", bwSkin.theme, uiEnhancerSettings.theme); fluid.enhance.forget("fluid.uiOptions.uiOptionsTestsAutoSave");