Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Div
stylemax-width: 50%
classfloatRight
Panel
borderColor#ccc
bgColor#fff
borderStylesolid
titleOn This PageborderStylesolid
Table of Contents
Div
stylemax-width: 50%
classfloatRight
Panel
borderColor#ccc
bgColor#fff
borderStylesolid
titleSee Also
borderStylesolid
Include Page
_useful links for prefs framework
_useful links for prefs framework

 

 

In cases where you are adding a full-page editor to your site, you likely want the user's settings to be applied to every other page on your site as well. On these pages, you don't want to instantiate the preferences editor, but you do need to instantiate the page enhancer and the settings store; without these, the preferences will have no effect.

 

 

 

 

 

The Builder takes as its input the primary and auxiliary schemas and constructs all the components necessary to render the preferences editor, store preferences, and respond to changes in preferences.

The Builder is invoked using the fluid.prefs.builder() function, and accepts a JavaScript object as its argument. The JavaScript object contains the configuration information, using various keys:

Key

Description

gradeNames

the name of a grade defining an auxiliary schema

schema

the primary schema

auxiliarySchema

the auxiliary schema

The Builder will only include any panels defined by the auxiliary schema. The 'starter set' of panels provided by the Preferences Framework can be added by using the fluid.prefs.auxSchema.starter grade. The content of whatever auxiliary schema grade you provide can be overriden by specifics in the auxiliarySchema option.Adding the settings store and enhancer requires a two-step process:

  1. Use the Builder to build the tools, then
  2. Instantiate the tools built by the builder.

Build the Settings Store and Enhancer

Build the settings store and enhancer with a call to the Preferences Framework Builder (this call also builds a preferences editor, but you aren't required to instantiate it). The Builder can be used with either the auxiliarySchema property or with an auxiliary schema grade.

NOTE: Your auxiliary schema MUST specify a namespace. You'll need this namespace to access the components created by the builder.

Section
Column
Code Block
titleExample: Using the builder with the

...

Section
Column
width50%

Directly

var prefsBuilder = fluid.prefs.builder(
Code Block
javascriptjavascript
auxiliarySchema property
linenumberstrue
vary myAuxiliarySchema = {
    gradeNamesnamespace: ["fluidmy.prefs.auxSchema.starter"]
});
Column

Through a custom grade

Code Block
javascriptjavascript
fluid.defaults("fluid.videoPlayer.myBuilder", {

   gradeNames: ["fluid.prefs.builder", "fluid.prefs.auxSchema.starter"]
});
var prefsBuilder = fluid.videoPlayer.myBuilder();

Example: Using the builder to add Video Player panels to the 'starter set'

Section
Column
width50%

Directly

Code Block
javascriptjavascript
var
prefsBuilder = fluid.prefs.builder({
    gradeNamesprimarySchema: ["fluid.prefs.auxSchema.starter"]myPrimarySchema,
    auxiliarySchemaauxiliaryScham: fluid.videoPlayer.auxSchemamyAuxiliarySchema
});

Through a custom grade

Column
Code Block
javascriptjavascript
Code Block
titleExample: Using the builder with an auxiliary schema grade
linenumberstrue
fluid.defaults("fluidmy.videoPlayer.myBuilderauxSchemaGrade", {
    gradeNames: ["fluid.prefs.builder", "fluid.prefs.auxSchema.starter", "autoInit"],
    schemaauxiliarySchema: fluid.videoPlayer.primarySchema,{
        auxiliarySchemanamespace: fluid.videoPlayer.auxSchema
});
var prefsBuilder = fluid.videoPlayer.myBuilder();

Example: Using the builder for a set of custom preferences and panels

Section
Column
width50%

Directly

Code Block
javascriptjavascript
var prefsBuilder = fluid.prefs.builder({"my.prefs",
        ....
    auxiliarySchema: fluid.myApplication.auxSchema}
});
Column

Through a custom grade

Code Block
javascriptjavascript
fluid.defaults("fluid.myApplication.myBuilder", fluid.prefs.builder({
    gradeNames: ["fluid.prefs.builder", "autoInitmy.auxSchemaGrade"],

   schema: fluid.myApplication.primarySchema,
    auxiliarySchema: fluid.myApplication.auxSchemamyPrimarySchema
});
var prefsBuilder

Instantiate the Enhancer

Once you've run the builder, you can access the enhancer through the namespace you specified in your auxiliary schema

Code Block
titleInstantiating the default separated-panel editor
linenumberstrue
var enhancer = 
fluid
my.
videoPlayer
prefs.
myBuilder
uie(
);
"body");

The uie method will automatically instantiate both the settings store and the page enhancer, so you only need to make the one call. The settings store will automatically connect to the saved settings, and the enhancer will automatically use your enactors to adjust the page according to the settings.

 

 

Back to Tutorial - Creating a Preferences Editor Using the Preferences Framework

...