/
uiOptionsDemo.js
117 lines (102 loc) · 4 KB
/
uiOptionsDemo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
Copyright 2011 OCAD University
Copyright 2011 Lucendo Development Ltd.
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
// Declare dependencies
/*global demo:true, fluid, jQuery, window*/
// JSLint options
/*jslint white: true, funcinvoke: true, undef: true, newcap: true, nomen: true, regexp: true, bitwise: true, browser: true, forin: true, maxerr: 100, indent: 4 */
var demo = demo || {};
(function ($, fluid) {
/**
* The UI Options interface is defined by several HTML templates. The component
* needs to know where those templates are. This variable will be used by all
* versions of the component.
*/
var pathToTemplates = "../../../components/uiOptions/html/";
/**
* The UI Enhancer's Table of Contents uses a template. This path variable is used by all
* three versions of the component, as well as by the UI Enhancer present in the Preview
* itself.
*/
var pathToTocTemplate = "../../../components/tableOfContents/html/TableOfContents.html";
/**
* Initialize UI Enhancer for the page. This function is used by the two full-page
* UI Options pages as well as by the demo page itself.
*/
demo.initPageEnhancer = function (customThemeName) {
fluid.pageEnhancer({
gradeNames: ["fluid.uiEnhancer.defaultActions"],
tocTemplate: pathToTocTemplate,
classnameMap: {
theme: {
"default": customThemeName
}
}
});
};
/**
* The basic options for configuring the full-page versions of UI Options are the same,
* regardless of whether or not the Preview is used. These settings used by both
* full-page version, with and without Preview.
*/
var basicFullPageOpts = {
// Tell UIOptions where to find all the templates, relative to this file
prefix: pathToTemplates,
// Tell UIOptions where to redirect to if the user cancels the operation
uiOptions: {
options: {
gradeNames: ["fluid.uiOptions.defaultSettingsPanels"],
listeners: {
onCancel: function () {
window.location = "uiOptions.html";
}
}
}
}
};
/**
* Initialize UI Options on the "Full Page, No Preview" version.
*/
demo.initFullNoPreview = function (container, options) {
fluid.uiOptions.fullNoPreview(container, $.extend(true, {}, basicFullPageOpts, options));
};
/**
* Initialize UI Options on the "Full Page, With Preview" version.
*/
demo.initFullWithPreview = function (container, options) {
fluid.uiOptions.fullPreview(container, $.extend(true, {}, basicFullPageOpts, options));
};
/**
* Initialize UI Options on the "Fat Panel" version. This version of UI Options uses the
* page itself as a live preview.
*/
demo.initFatPanel = function (container) {
fluid.uiOptions.fatPanel(container, {
// Tell UIOptions where to find all the templates, relative to this file
prefix: pathToTemplates,
uiOptions: {
options: {
gradeNames: ["fluid.uiOptions.defaultSettingsPanels"]
}
}
});
};
/**
* Set up the buttons to link to the full-page versions of UI Options.
*/
demo.setUpButtons = function () {
// Configure the buttons
$(".disp-opts-with-preview").click(function () {
window.location = "uiOptionsFullWithPreview.html";
});
$(".disp-opts-without-preview").click(function () {
window.location = "uiOptionsFullWithoutPreview.html";
});
};
})(jQuery, fluid);