This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtestpanel.js
179 lines (153 loc) · 6.12 KB
/
testpanel.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
define(function(require, module, exports) {
main.consumes = ["Plugin", "ui", "test", "settings"];
main.provides = ["TestPanel"];
return main;
function main(options, imports, register) {
var Plugin = imports.Plugin;
var ui = imports.ui;
var test = imports.test;
var settings = imports.settings;
function TestPanel(developer, deps, options) {
// Editor extends ext.Plugin
var plugin = new Plugin(developer, deps);
var emit = plugin.getEmitter();
emit.setMaxListeners(1000);
var caption = options.caption;
var index = options.index || 100;
var height = options.height || "";
var style = options.style || "";
var showTitle = options.showTitle || false;
var amlFrame;
plugin.on("load", function() {
// Draw panel when test panel is drawn
test.once("drawPanels", draw, plugin);
});
function draw(e) {
amlFrame = showTitle ? ui.frame({
buttons: "min",
activetitle: "min",
"class": "absframe " + options.class,
style: "position:relative;" + (style || ""),
textselect: options.textselect,
// height : height,
caption: caption
}) : ui.bar({
"class": options.class,
style: "position:relative;" + (style || ""),
textselect: options.textselect
});
var aml = e.aml;
if (index == 100)
aml.insertBefore(amlFrame, aml.firstChild);
else
aml.appendChild(amlFrame);
if (height)
amlFrame.setHeight(height);
// ui.insertByIndex(e.html, amlFrame.$ext, index, false);
plugin.addElement(amlFrame);
emit.sticky("draw", { aml: amlFrame, html: amlFrame.$int });
amlFrame.on("prop.height", function() {
emit("resize");
});
amlFrame.on("afterstatechange", function () {
if (amlFrame.parentNode) {
amlFrame.parentNode.childNodes.forEach(function(n) {
n.emit("resize");
});
var closed = amlFrame.state != "normal";
settings.set("state/test/panel/" + options.name
+ "/@closed", closed);
}
});
settings.once("read", function() {
var closed = settings.get("state/test/panel/" + options.name
+ "/@closed", closed);
if (closed)
setTimeout(function() {amlFrame.minimize();}, 10);
});
test.on("show", function() { emit("show"); }, plugin);
test.on("hide", function() { emit("hide"); }, plugin);
}
/***** Methods *****/
function show() {
if (amlFrame) {
if (amlFrame.restore) amlFrame.restore();
else amlFrame.show();
emit("show");
}
}
function hide() {
amlFrame.hide();
emit("hide");
}
/***** Register and define API *****/
plugin.freezePublicAPI.baseclass();
/**
* Test panel base class for the {@link collab}.
*
* A test panel is a section of the test pane that allows users to
* collaborate on a workspace
*
* @class TestPanel
* @extends Plugin
*/
/**
* @constructor
* Creates a new TestPanel instance.
* @param {String} developer The name of the developer of the plugin
* @param {String[]} deps A list of dependencies for this
* plugin. In most cases it's a reference to `main.consumes`.
* @param {Object} options The options for the test panel
* @param {String} options.caption The caption of the frame.
*/
plugin.freezePublicAPI({
/**
* The APF UI element that is presenting the pane in the UI.
* This property is here for internal reasons only. *Do not
* depend on this property in your plugin.*
* @property {AMLElement} aml
* @private
* @readonly
*/
get aml() { return amlFrame; },
/**
*
*/
get visible() { return amlFrame.visible; },
/**
* @property {Number} height
*/
get height() { return amlFrame.getHeight(); },
set height(v) {
if (height != v) {
height = v;
amlFrame.setHeight(v);
}
},
_events: [
/**
* Fired when the panel container is drawn.
* @event draw
* @param {Object} e
* @param {HTMLElement} e.html The html container.
* @param {AMLElement} e.aml The aml container.
*/
"draw"
],
/**
* Shows the panel.
*/
show: show,
/**
* Hides the panel.
*/
hide: hide
});
return plugin;
}
/***** Register and define API *****/
register(null, {
TestPanel: TestPanel
});
}
});