-
Notifications
You must be signed in to change notification settings - Fork 0
/
_GuidePopupMixin.js
89 lines (79 loc) · 2.68 KB
/
_GuidePopupMixin.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
/*jshint quotmark:false */
define([
"dojo/_base/declare",
"dojo/_base/array",
"dojo/_base/lang",
"dojo/_base/window",
"dojo/dom-attr",
"dojo/dom-class",
"dojo/dom-construct",
"dojo/dom-style",
"dojo/dom",
"dojo/on",
"dojo/query",
"dijit/popup",
"dijit/TooltipDialog",
"dojo/i18n!./nls/GuideManager"
], function (declare, array, lang, win, domAttr, domClass, domConstruct, domStyle, dom, on, query, popup, TooltipDialog, i18n) {
return declare(null, {
// Default actions available.
// NB 'action' must be unique.
actions: [
{ label: i18n.prev, action: 'prev' },
{ label: i18n.next, action: 'next' },
{ label: i18n.ok, action: 'ok' },
{ label: i18n.cancel, action: 'cancel' }
],
postCreate: function () {
this.inherited(arguments);
// We maintain two elements in our ContainerNode:
// - stepContainerNode - a div in which we place the current step
// - buttonBar - a div containing the current controls
this.stepContainerNode = domConstruct.create('div', {
'class': 'dojoxGuideStepContainer'
}, this.containerNode, 'last');
// The buttonBar borrows the actionBar styles from dijit because
// they're a nice sensible default, though annoying to override.
this.buttonBar = domConstruct.create('div', {
'class': 'dojoxGuideButtonBar dijitDialogPaneActionBar'
}, this.containerNode, 'last');
// We have a set of standard actions we can support
this.actionNode = [];
array.forEach(this.actions, lang.hitch(this, function (action) {
var actNode = this.createActionButton(action);
domConstruct.place(actNode, this.buttonBar, 'last');
// handle click on the action, e.g. 'prev' calls this.prev()
this.own(on(actNode, 'click', lang.hitch(this, function () {
// Tell the parent that an action was clicked.
this.parent.act(action.action);
})));
// remember node for later just in case
this.actionNode[action.action] = actNode;
}));
},
// Default creator - can be overridden
createActionButton: function (action) {
return domConstruct.create('span', {
'class': 'dojoxGuideAction',
innerHTML: action.label
});
},
// Makes actions visible or invisible
// e.g. this.set('actions', [ 'prev', 'next'])
displayActions: function (requiredActions, lastOne) {
array.forEach(this.actions, lang.hitch(this, function (action) {
var display = (array.indexOf(requiredActions, action.action) !== -1);
if (lastOne && action.notIfLast) {
display = false;
}
if (lastOne && action.alwaysIfLast) {
display = true;
}
domStyle.set(this.actionNode[action.action], 'display',
display ? 'inline-block':'none');
}));
},
prev: function () {
}
});
});