Skip to content

Commit

Permalink
FLUID-5754: A bit of clean-up; remove localization; add a README
Browse files Browse the repository at this point in the history
  • Loading branch information
acheetham committed Aug 27, 2015
1 parent f3097b1 commit a261441
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 55 deletions.
9 changes: 9 additions & 0 deletions examples/framework/preferences/minimalEditor/README.md
@@ -0,0 +1,9 @@

## Minimal Preferences Editor ##

This folder provides an example of a minimal but fully functional preferences editor. It has:
- only one preference
- no enactor
- no localization (Note that this is not best practice!)

This code is the basis for the Preferences Framework tutorial.
6 changes: 3 additions & 3 deletions examples/framework/preferences/minimalEditor/css/style.css
@@ -1,7 +1,7 @@
.me-panel {
padding: 1em;
border: 1px solid black;
width: 50%;
padding: 1em;
border: 1px solid black;
width: 50%;
}

.me-save {
Expand Down
@@ -1,7 +1,8 @@
<!-- This file is the template for the auto-pilot preference panel -->
<section class="me-panel">
<h2 class="mec-autoPilot-header">header here</h2>
<h2>Auto-Pilot</h2>

<label for="minEditor-autoPilot" class="mec-autoPilot-label">label here</label>
<input type="checkbox" id="minEditor-autoPilot" class="mec-autoPilot"/>
<label for="minEditor-autoPilot">Enable the auto-pilot when the car starts</label>
<input type="checkbox" id="minEditor-autoPilot" class="mec-autoPilot"/>
</section>

@@ -1,9 +1,8 @@
<!-- This file is the template for the entire Preference Editor -->
<h1>A simple preferences editor</h1>
<h1>Flying Car Setup</h1>
<p>This preferences editor ...</p>

<!-- placeholder for the auto-pilot preference panel -->
<div class="mec-autoPilot"></div>

<button class="flc-prefsEditor-save me-save">Save</button>

<!-- what about localizing the 'save' text? -->
<button class="flc-prefsEditor-save me-save">save</button>
12 changes: 5 additions & 7 deletions examples/framework/preferences/minimalEditor/index.html
Expand Up @@ -35,14 +35,12 @@

<body>

<!-- placeholder for the preferences editor -->
<div id="myMinEditor"></div>

<script type="text/javascript">
$(document).ready(function () {
myEditor = minEditor.init("#myMinEditor");
});
minEditor.init("#myMinEditor");
</script>

<!-- placeholder for the preferences editor -->
<div id="myMinEditor"></div>

</body>
</body>
</html>
54 changes: 20 additions & 34 deletions examples/framework/preferences/minimalEditor/js/minEditor.js
Expand Up @@ -21,13 +21,20 @@ var minEditor = minEditor || {};
* This schema defines the preference(s) edited by this preferences editor:
* their names, types, default values, etc.
*/
minEditor.primarySchema = {
// the string "minEditor.autoPilot" is the 'name' of the preference
"minEditor.autoPilot": {
type: "boolean",
"default": false
fluid.defaults("minEditor.primarySchema", {

// the base grade for the schema;
// using this grade tells the framework that this is a primary schema
gradeNames: ["fluid.prefs.schemas"],

schema: {
// the actual specification of the preference
"minEditor.autoPilot": {
"type": "boolean",
"default": false
}
}
};
});

/**
* Panel for the auto-pilot preference
Expand All @@ -44,22 +51,16 @@ var minEditor = minEditor || {};
}
},

// selectors identify elements in the DOM that need to be accessed by the code
// selectors identify elements in the DOM that need to be accessed by the code;
// in this case, the Renderer will render data into these particular elements
selectors: {
header: ".mec-autoPilot-header",
label: ".mec-autoPilot-label",
autoPilot: ".mec-autoPilot"
},

// the ProtoTree is basically instructions to the Renderer
// the keys in the prototree match the selectors above
protoTree: {
// "messagekey" refers to the keys for strings in the JSON messages file
header: {messagekey: "autoPilotHeader"},
label: {messagekey: "autoPilotLabel"},

// this string 'autoPilot' refers to the last part of the model path in the preferenceMap
// this value is an IoC reference to the last part of the model path in the preferenceMap
autoPilot: "${autoPilot}"
}
});
Expand All @@ -69,27 +70,22 @@ var minEditor = minEditor || {};
*/
fluid.defaults("minEditor.auxSchema", {

// the basic grade for the schema
// the base grade for the schema
gradeNames: ["fluid.prefs.auxSchema"],

auxiliarySchema: {

// the loaderGrade identifies the "base" form of preference editor desired
loaderGrades: ["fluid.prefs.fullNoPreview"],

// these are the root paths used to reference templates
// and message files in this schema
// 'terms' are strings that can be re-used elsewhere in this schema;
terms: {
templatePrefix: "html",
messagePrefix: "messages"
templatePrefix: "html"
},

// the main template for the preference editor itself
template: "%templatePrefix/minEditor.html",

// the message bundle for the preference editor itself
message: "%messagePrefix/prefsEditor.json",

autoPilot: {
// this 'type' must match the name of the pref in the primary schema
type: "minEditor.autoPilot",
Expand All @@ -101,10 +97,7 @@ var minEditor = minEditor || {};
container: ".mec-autoPilot",

// the template for this panel
template: "%templatePrefix/autoPilot.html",

// the message bundle for this panel
message: "%messagePrefix/autoPilot.json"
template: "%templatePrefix/autoPilot.html"
}
}
}
Expand All @@ -116,16 +109,9 @@ var minEditor = minEditor || {};
minEditor.init = function (container) {
return fluid.prefs.create(container, {
build: {
gradeNames: ["minEditor.auxSchema"],
primarySchema: minEditor.primarySchema
gradeNames: ["minEditor.auxSchema"]
}
});
};

})();






This file was deleted.

0 comments on commit a261441

Please sign in to comment.