Skip to content

Commit

Permalink
FLUID-4171: Injected uiEnhancer component into fluid.uiOptions throug…
Browse files Browse the repository at this point in the history
…h demands block instead of defaults as uiEnhancer is irrelevant to other pieces on fluid.uiOptions defaults tree.
  • Loading branch information
cindyli committed Jun 10, 2011
1 parent a72d180 commit e3f118a
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 105 deletions.
4 changes: 3 additions & 1 deletion src/webapp/components/uiOptions/js/FatPanelUIOptions.js
Expand Up @@ -69,7 +69,9 @@ var fluid_1_4 = fluid_1_4 || {};
type: "fluid.tabs",
container: "{fatPanelUIOptions}.container",
createOnEvent: "onReady"
}
},
uiEnhancer: "{uiEnhancer}",
settingsStore: "{uiEnhancer}.settingsStore"
},
autoSave: true
}
Expand Down
4 changes: 3 additions & 1 deletion src/webapp/components/uiOptions/js/FullNoPreviewUIOptions.js
Expand Up @@ -40,7 +40,9 @@ var fluid_1_4 = fluid_1_4 || {};
components: {
preview: {
type: "fluid.emptySubcomponent"
}
},
uiEnhancer: "{uiEnhancer}",
settingsStore: "{uiEnhancer}.settingsStore"
}
}
});
Expand Down
4 changes: 3 additions & 1 deletion src/webapp/components/uiOptions/js/FullPreviewUIOptions.js
Expand Up @@ -41,7 +41,9 @@ var fluid_1_4 = fluid_1_4 || {};
preview: {
type: "fluid.uiOptions.preview",
createOnEvent: "onReady"
}
},
uiEnhancer: "{uiEnhancer}",
settingsStore: "{uiEnhancer}.settingsStore"
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/webapp/components/uiOptions/js/UIEnhancer.js
Expand Up @@ -103,7 +103,7 @@ var fluid_1_4 = fluid_1_4 || {};
* @param {Object} size
*/
var setMinSize = function (container, times, initFontSize) {
if (times === 1){
if (times === 1) {
container.css("font-size", ""); // empty is same effect as not being set
} else if (times && times > 0) {
newFontSize = initFontSize * times;
Expand Down Expand Up @@ -200,7 +200,7 @@ var fluid_1_4 = fluid_1_4 || {};
selector = selector + ",." + className;
}
});
} else if (typeof settingValues === 'string'){
} else if (typeof settingValues === 'string') {
classesToRemove = classesToRemove + " " + settingValues;
selector = selector + ",." + settingValues;
}
Expand Down Expand Up @@ -347,7 +347,7 @@ var fluid_1_4 = fluid_1_4 || {};
}
});

fluid.demands("settingsStore", ["fluid.uiEnhancer"], {
fluid.demands("fluid.uiOptions.store", ["fluid.uiEnhancer"], {
funcName: "fluid.cookieStore"
});

Expand Down
77 changes: 39 additions & 38 deletions src/webapp/components/uiOptions/js/UIOptions.js
Expand Up @@ -139,7 +139,7 @@ var fluid_1_4 = fluid_1_4 || {};
"aria-valuemin": opts.min,
"aria-valuemax": opts.max
};
thumb.attr(ariaDefaults);
thumb.attr(ariaDefaults);
};

fluid.textfieldSlider.slider.finalInit = function (that) {
Expand Down Expand Up @@ -219,6 +219,24 @@ var fluid_1_4 = fluid_1_4 || {};
* UI Options *
**************/

fluid.demands("fluid.uiOptions.textControls", ["fluid.uiOptions"], {
options: {
classnameMap: "{uiEnhancer}.options.classnameMap"
}
});

fluid.demands("fluid.uiOptions.layoutControls", ["fluid.uiOptions"], {
options: {
classnameMap: "{uiEnhancer}.options.classnameMap"
}
});

fluid.demands("fluid.uiOptions.linksControls", ["fluid.uiOptions"], {
options: {
classnameMap: "{uiEnhancer}.options.classnameMap"
}
});

/**
* A component that works in conjunction with the UI Enhancer component and the Fluid Skinning System (FSS)
* to allow users to set personal user interface preferences. The UI Options component provides a user
Expand All @@ -231,7 +249,6 @@ var fluid_1_4 = fluid_1_4 || {};
fluid.defaults("fluid.uiOptions", {
gradeNames: ["fluid.viewComponent", "autoInit"],
components: {
uiEnhancer: "{uiEnhancer}",
textControls: {
type: "fluid.uiOptions.textControls",
container: "{uiOptions}.dom.textControls",
Expand All @@ -240,8 +257,7 @@ var fluid_1_4 = fluid_1_4 || {};
textSize: "{uiOptions}.options.textSize",
lineSpacing: "{uiOptions}.options.lineSpacing",
model: "{uiOptions}.model",
applier: "{uiOptions}.applier",
classnameMap: "{uiEnhancer}.options.classnameMap",
applier: "{uiOptions}.applier"
}
},
layoutControls: {
Expand All @@ -250,8 +266,7 @@ var fluid_1_4 = fluid_1_4 || {};
createOnEvent: "onUIOptionsTemplateReady",
options: {
model: "{uiOptions}.model",
applier: "{uiOptions}.applier",
classnameMap: "{uiEnhancer}.options.classnameMap"
applier: "{uiOptions}.applier"
}
},
linksControls: {
Expand All @@ -260,17 +275,20 @@ var fluid_1_4 = fluid_1_4 || {};
createOnEvent: "onUIOptionsTemplateReady",
options: {
model: "{uiOptions}.model",
applier: "{uiOptions}.applier",
classnameMap: "{uiEnhancer}.options.classnameMap"
applier: "{uiOptions}.applier"
}
},
preview: {
type: "fluid.uiOptions.preview",
createOnEvent: "onReady"
},
settingsStore: "{uiEnhancer}.settingsStore"
settingsStore: { // supplied by demands
type: "fluid.uiOptions.store"
},
uiEnhancer: { // supplied by demands
type: "fluid.uiEnhancer"
}
},
savedSelections: "{uiEnhancer}.model",
textSize: {
min: 1,
max: 2
Expand Down Expand Up @@ -321,16 +339,17 @@ var fluid_1_4 = fluid_1_4 || {};
};

fluid.uiOptions.finalInit = function (that) {
that.applier.requestChange("selections", fluid.copy(that.uiEnhancer.model));
that.applier.requestChange("selections", fluid.copy(that.settingsStore.fetch()));

/**
* Saves the current model and fires onSave
*/
that.save = function () {
that.events.onSave.fire(that.model.selections);
that.options.savedSelections = fluid.copy(that.model.selections);
that.uiEnhancer.applier.requestChange("", that.options.savedSelections);
that.settingsStore.save(that.model.selections);

var savedSelections = fluid.copy(that.model.selections);
that.uiEnhancer.applier.requestChange("", savedSelections);
that.settingsStore.save(savedSelections);
};

/**
Expand All @@ -347,7 +366,7 @@ var fluid_1_4 = fluid_1_4 || {};
*/
that.cancel = function () {
that.events.onCancel.fire();
that.updateModel(fluid.copy(that.options.savedSelections));
that.updateModel(fluid.copy(that.settingsStore.fetch()));
that.refreshControlsView();
};

Expand Down Expand Up @@ -414,21 +433,6 @@ var fluid_1_4 = fluid_1_4 || {};
});
};

var createRadioButtonNode = function (item) {
return {
type: "fluid.renderer.selection.inputs",
inputID: item + "InputID",
tree: {
optionnames: "${labelMap." + item + ".names}",
optionlist: "${labelMap." + item + ".values}",
selection: "${selections." + item + "}"
},
rowID: item + "RowID",
selectID: item,
labelID: item + "LabelID"
};
};

var createSliderNode = function (that, item) {
return {
decorators: {
Expand Down Expand Up @@ -513,11 +517,10 @@ var fluid_1_4 = fluid_1_4 || {};
}
}
};
} else if (item === "textSize" || item === "lineSpacing") {
// textfield sliders
tree[item] = createSliderNode(that, item);
}
else if (item === "textSize" || item === "lineSpacing") {
// textfield sliders
tree[item] = createSliderNode(that, item);
}
}

return tree;
Expand All @@ -536,7 +539,7 @@ var fluid_1_4 = fluid_1_4 || {};

fluid.defaults("fluid.uiOptions.selectDecorator", {
gradeNames: ["fluid.viewComponent", "autoInit"],
finalInitFunction: "fluid.uiOptions.selectDecorator.finalInit",
finalInitFunction: "fluid.uiOptions.selectDecorator.finalInit"
});

fluid.uiOptions.selectDecorator.finalInit = function (that) {
Expand Down Expand Up @@ -642,8 +645,6 @@ var fluid_1_4 = fluid_1_4 || {};
type: "fluid.uiEnhancer",
createOnEvent: "onReady",
options: {
savedSettings: "{uiOptions}.model.selections",
tableOfContents: "{uiEnhancer}.options.tableOfContents",
settingsStore: {
type: "fluid.uiEnhancer.tempStore"
}
Expand Down

0 comments on commit e3f118a

Please sign in to comment.