Window.js
2.27 KB
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
(function() {
module("tinymce.ui.Window", {
setup: function() {
document.getElementById('view').innerHTML = '';
},
teardown: function() {
tinymce.dom.Event.clean(document.getElementById('view'));
tinymce.DOM.remove(document.getElementById('mce-modal-block'));
}
});
function createWindow(settings) {
return tinymce.ui.Factory.create(tinymce.extend({
type: 'window'
}, settings)).renderTo(document.getElementById('view')).reflow();
}
test("window x, y, w, h", function() {
var win = createWindow({x: 100, y: 120, width: 200, height: 210});
Utils.nearlyEqualRects(Utils.size(win), [200, 210]);
});
test("no title, no buttonbar, autoResize", function() {
var win = createWindow({
x: 100,
y: 120,
items: [
{type: 'spacer', classes: 'red'}
]
});
Utils.nearlyEqualRects(Utils.size(win), [22, 22]);
Utils.nearlyEqualRects(Utils.size(win.find("spacer")[0]), [20, 20]);
});
test("title, no buttonbar, autoResize, title is widest", function() {
var win = createWindow({
x: 100,
y: 120,
title: "XXXXXXXXXXXXXXXXXXXXXX",
items: [
{type: 'spacer', classes: 'red', flex: 1}
]
});
Utils.nearlyEqualRects(Utils.size(win), [326, 61], 60);
Utils.nearlyEqualRects(Utils.size(win.find("spacer")[0]), [324, 20], 60);
});
test("buttonbar, autoResize, buttonbar is widest", function() {
var win = createWindow({
x: 100,
y: 120,
items: [
{type: 'spacer', classes: 'red', flex: 1}
],
buttons: [
{type: 'spacer', classes: 'green', minWidth: 400}
]
});
Utils.nearlyEqualRects(Utils.size(win), [422, 63]);
Utils.nearlyEqualRects(Utils.size(win.find("spacer")[0]), [420, 20]);
Utils.nearlyEqualRects(Utils.size(win.statusbar.find("spacer")[0]), [400, 20]);
});
test("buttonbar, title, autoResize, content is widest", function() {
var win = createWindow({
x: 100,
y: 120,
title: "X",
items: [
{type: 'spacer', classes: 'red', minWidth: 400}
],
buttons: [
{type: 'spacer', classes: 'green'}
]
});
Utils.nearlyEqualRects(Utils.size(win), [402, 102]);
Utils.nearlyEqualRects(Utils.size(win.getEl("head")), [400, 39]);
Utils.nearlyEqualRects(Utils.size(win.find("spacer")[0]), [400, 20]);
Utils.nearlyEqualRects(Utils.size(win.statusbar.find("spacer")[0]), [20, 20]);
});
})();