tinymce-rails 4.4.1 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/source/tinymce/tinymce.js +406 -197
  3. data/lib/tinymce/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/tinymce/plugins/codesample/plugin.js +1 -1
  5. data/vendor/assets/javascripts/tinymce/plugins/contextmenu/plugin.js +1 -1
  6. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.js +1 -1
  7. data/vendor/assets/javascripts/tinymce/plugins/importcss/plugin.js +1 -1
  8. data/vendor/assets/javascripts/tinymce/plugins/lists/plugin.js +1 -1
  9. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.js +1 -1
  10. data/vendor/assets/javascripts/tinymce/plugins/spellchecker/plugin.js +1 -1
  11. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.js +2 -2
  12. data/vendor/assets/javascripts/tinymce/plugins/template/plugin.js +1 -1
  13. data/vendor/assets/javascripts/tinymce/themes/inlite/theme.js +1 -1
  14. data/vendor/assets/javascripts/tinymce/tinymce.js +14 -13
  15. metadata +2 -55
  16. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/atomic.js +0 -5
  17. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-atomic.js +0 -1491
  18. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-browser.js +0 -1491
  19. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-demo.js +0 -1491
  20. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-prod.js +0 -1491
  21. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/browser.js +0 -10
  22. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/demo.js +0 -8
  23. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/prod.js +0 -5
  24. data/vendor/assets/javascripts/tinymce/themes/inlite/config/dent/depend.js +0 -21
  25. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/compile/bootstrap.js +0 -1526
  26. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/compile/theme.js +0 -1594
  27. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/inline/theme.js +0 -1679
  28. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/inline/theme.raw.js +0 -1679
  29. data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/css/demo.css +0 -25
  30. data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/html/demo.html +0 -69
  31. data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/js/tinymce/inlite/Demo.js +0 -28
  32. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/Theme.js +0 -150
  33. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Arr.js +0 -22
  34. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Bookmark.js +0 -130
  35. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Unlink.js +0 -84
  36. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Uuid.js +0 -34
  37. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Actions.js +0 -106
  38. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Convert.js +0 -37
  39. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/ElementMatcher.js +0 -47
  40. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Layout.js +0 -95
  41. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Matcher.js +0 -39
  42. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js +0 -61
  43. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/PredicateId.js +0 -32
  44. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/SelectionMatcher.js +0 -55
  45. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/SkinLoader.js +0 -45
  46. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/UrlType.js +0 -27
  47. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/file/Conversions.js +0 -31
  48. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/file/Picker.js +0 -40
  49. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js +0 -80
  50. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Forms.js +0 -102
  51. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Panel.js +0 -218
  52. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Toolbar.js +0 -126
  53. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/alien/ArrTest.js +0 -9
  54. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/alien/UuidTest.js +0 -10
  55. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/ConvertTest.js +0 -12
  56. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/MatcherTest.js +0 -51
  57. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/UrlTypeTest.js +0 -33
  58. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/ThemeTest.js +0 -202
  59. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/alien/BookmarkTest.js +0 -65
  60. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/alien/UnlinkTest.js +0 -38
  61. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/ActionsTest.js +0 -177
  62. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/ElementMatcher.js +0 -69
  63. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/LayoutTest.js +0 -118
  64. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/MeasureTest.js +0 -62
  65. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/PredicateIdTest.js +0 -26
  66. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/SelectionMatcherTest.js +0 -76
  67. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/file/ConversionsTest.js +0 -41
  68. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/file/SelectionMatcher.js +0 -55
@@ -1,65 +0,0 @@
1
- asynctest('browser/alien/BookmarkTest', [
2
- 'ephox/tinymce',
3
- 'ephox.agar.api.Pipeline',
4
- 'ephox.agar.api.Chain',
5
- 'ephox.agar.api.Cursors',
6
- 'ephox.agar.api.Assertions',
7
- 'ephox.mcagar.api.TinyDom',
8
- 'tinymce/inlite/alien/Bookmark'
9
- ], function (tinymce, Pipeline, Chain, Cursors, Assertions, TinyDom, Bookmark) {
10
- var success = arguments[arguments.length - 2];
11
- var failure = arguments[arguments.length - 1];
12
-
13
- var toNativeRange = function (range) {
14
- var domRange = document.createRange();
15
- domRange.setStart(range.start().dom(), range.soffset());
16
- domRange.setEnd(range.finish().dom(), range.foffset());
17
- return domRange;
18
- };
19
-
20
- var rangeToBookmark = function (dom) {
21
- return function (range) {
22
- return Bookmark.create(dom, range);
23
- };
24
- };
25
-
26
- var bookmarkToRange = function (dom) {
27
- return function (bookmark) {
28
- return Bookmark.resolve(dom, bookmark);
29
- };
30
- };
31
-
32
- var cAssertRangeEq = function (expected) {
33
- return Chain.op(function (actual) {
34
- Assertions.assertEq('Not equal startContainer', expected.start().dom(), actual.startContainer);
35
- Assertions.assertEq('Not equal startOffset', expected.soffset(), actual.startOffset);
36
- Assertions.assertEq('Not equal endContainer', expected.finish().dom(), actual.endContainer);
37
- Assertions.assertEq('Not equal endOffset', expected.foffset(), actual.endOffset);
38
- });
39
- };
40
-
41
- var sTestBookmark = function (html, path) {
42
- var dom = tinymce.DOM;
43
- var elm = TinyDom.fromDom(dom.create('div', {}, html));
44
-
45
- return Chain.asStep(elm, [
46
- Cursors.cFollowPath(Cursors.pathFrom(path)),
47
- Chain.mapper(toNativeRange),
48
- Chain.mapper(rangeToBookmark(dom)),
49
- Chain.mapper(bookmarkToRange(dom)),
50
- cAssertRangeEq(Cursors.calculate(elm, Cursors.pathFrom(path)))
51
- ]);
52
- };
53
-
54
- Pipeline.async({}, [
55
- sTestBookmark('abc', {element: [0], offset: 0}),
56
- sTestBookmark('abc', {element: [0], offset: 1}),
57
- sTestBookmark('abc', {start: {element: [0], offset: 0}, finish: {element: [0], offset: 1}}),
58
- sTestBookmark('<b>a</b>', {element: [0, 0], offset: 0}),
59
- sTestBookmark('<b>a</b>', {element: [0, 0], offset: 0}),
60
- sTestBookmark('<b>a</b>', {start: {element: [0, 0], offset: 0}, finish: {element: [0, 0], offset: 1}}),
61
- sTestBookmark('<b>a</b><b>b</b>', {start: {element: [0, 0], offset: 0}, finish: {element: [1, 0], offset: 1}})
62
- ], function () {
63
- success();
64
- }, failure);
65
- });
@@ -1,38 +0,0 @@
1
- asynctest('browser/alien/UnlinkTest', [
2
- 'ephox.mcagar.api.TinyLoader',
3
- 'ephox.mcagar.api.TinyApis',
4
- 'tinymce/inlite/alien/Unlink',
5
- 'ephox.agar.api.Pipeline',
6
- 'ephox.agar.api.Step',
7
- 'ephox.agar.api.GeneralSteps'
8
- ], function (TinyLoader, TinyApis, Unlink, Pipeline, Step, GeneralSteps) {
9
- var success = arguments[arguments.length - 2];
10
- var failure = arguments[arguments.length - 1];
11
-
12
- var sUnlinkSelection = function (editor) {
13
- return Step.sync(function () {
14
- Unlink.unlinkSelection(editor);
15
- });
16
- };
17
-
18
- TinyLoader.setup(function (editor, onSuccess, onFailure) {
19
- var tinyApis = TinyApis(editor);
20
-
21
- var sAssertUnlink = function (inputHtml, startPath, startOffset, finishPath, finishOffset, expectedHtml) {
22
- return GeneralSteps.sequence([
23
- tinyApis.sSetContent(inputHtml),
24
- tinyApis.sSetSelection(startPath, startOffset, finishPath, finishOffset),
25
- sUnlinkSelection(editor),
26
- tinyApis.sAssertContent(expectedHtml, 'Should match expected anchor less html')
27
- ]);
28
- };
29
-
30
- Pipeline.async({}, [
31
- sAssertUnlink('<p><a href="#">a</a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '<p>a</p>'),
32
- sAssertUnlink('<p><a href="#">a</a>b</p>', [0, 0, 0], 0, [0, 1], 1, '<p>ab</p>'),
33
- sAssertUnlink('<p><a href="#">a</a><p><a href="#">b</a>', [0, 0, 0], 0, [0, 0, 0], 1, '<p>a</p>\n<p><a href="#">b</a></p>'),
34
- sAssertUnlink('<p><a href="#">a</a><p><a href="#">b</a>', [0, 0, 0], 0, [1, 0, 0], 1, '<p>a</p>\n<p>b</p>')
35
- ], onSuccess, onFailure);
36
- }, {
37
- }, success, failure);
38
- });
@@ -1,177 +0,0 @@
1
- asynctest('browser/core/ActionsTest', [
2
- 'ephox.mcagar.api.TinyLoader',
3
- 'ephox.mcagar.api.TinyApis',
4
- 'tinymce/inlite/core/Actions',
5
- 'ephox.agar.api.Pipeline',
6
- 'ephox.agar.api.Step',
7
- 'ephox.agar.api.GeneralSteps'
8
- ], function (TinyLoader, TinyApis, Actions, Pipeline, Step, GeneralSteps) {
9
- var success = arguments[arguments.length - 2];
10
- var failure = arguments[arguments.length - 1];
11
-
12
- var wrap = function (f, args) {
13
- return function () {
14
- var currentArgs = Array.prototype.slice.call(arguments);
15
- return Step.sync(function () {
16
- f.apply(null, [].concat(args).concat(currentArgs));
17
- });
18
- };
19
- };
20
-
21
- var sInsertTableTests = function (editor, tinyApis) {
22
- var sInsertTableTest = function (cols, rows, expectedHtml, message) {
23
- var sInsertTable = wrap(Actions.insertTable, editor);
24
-
25
- return GeneralSteps.sequence([
26
- tinyApis.sSetContent(''),
27
- sInsertTable(cols, rows),
28
- tinyApis.sAssertContent(expectedHtml, message)
29
- ]);
30
- };
31
-
32
- return GeneralSteps.sequence([
33
- sInsertTableTest(2, 3, [
34
- '<table style="width: 100%;">',
35
- '<tbody>',
36
- '<tr>',
37
- '<td>&nbsp;</td>',
38
- '<td>&nbsp;</td>',
39
- '</tr>',
40
- '<tr>',
41
- '<td>&nbsp;</td>',
42
- '<td>&nbsp;</td>',
43
- '</tr>',
44
- '<tr>',
45
- '<td>&nbsp;</td>',
46
- '<td>&nbsp;</td>',
47
- '</tr>',
48
- '</tbody>',
49
- '</table>'
50
- ].join('\n'),
51
- 'Should be a 2x3 table'
52
- ),
53
-
54
- sInsertTableTest(3, 2, [
55
- '<table style="width: 100%;">',
56
- '<tbody>',
57
- '<tr>',
58
- '<td>&nbsp;</td>',
59
- '<td>&nbsp;</td>',
60
- '<td>&nbsp;</td>',
61
- '</tr>',
62
- '<tr>',
63
- '<td>&nbsp;</td>',
64
- '<td>&nbsp;</td>',
65
- '<td>&nbsp;</td>',
66
- '</tr>',
67
- '</tbody>',
68
- '</table>'
69
- ].join('\n'),
70
- 'Should be a 3x2 table'
71
- )
72
- ]);
73
- };
74
-
75
- var sFormatBlockTests = function (editor, tinyApis) {
76
- var sFormatBlockTest = function (name) {
77
- var sFormatBlock = wrap(Actions.formatBlock, editor);
78
-
79
- return GeneralSteps.sequence([
80
- tinyApis.sSetContent('<p>a</p>'),
81
- tinyApis.sSetCursor([0], 0),
82
- sFormatBlock(name),
83
- tinyApis.sAssertContent('<' + name + '>a</' + name + '>', 'Should be a ' + name + ' block')
84
- ]);
85
- };
86
-
87
- return GeneralSteps.sequence([
88
- sFormatBlockTest('h1'),
89
- sFormatBlockTest('h2'),
90
- sFormatBlockTest('pre')
91
- ]);
92
- };
93
-
94
- var sCreateLinkTests = function (editor, tinyApis) {
95
- var sCreateLinkTest = function (inputHtml, url, sPath, sOffset, fPath, fOffset, expectedHtml) {
96
- var sCreateLink = wrap(Actions.createLink, editor);
97
-
98
- return GeneralSteps.sequence([
99
- tinyApis.sSetContent(inputHtml),
100
- tinyApis.sSetSelection(sPath, sOffset, fPath, fOffset),
101
- sCreateLink(url),
102
- tinyApis.sAssertContent(expectedHtml, 'Should have a link')
103
- ]);
104
- };
105
-
106
- return GeneralSteps.sequence([
107
- sCreateLinkTest('<p>a</p>', '#1', [0, 0], 0, [0, 0], 1, '<p><a href="#1">a</a></p>'),
108
- sCreateLinkTest('<p><a href="#1">a</a></p>', '#2', [0, 0], 0, [0, 0], 1, '<p><a href="#2">a</a></p>'),
109
- sCreateLinkTest('<p><a href="#1"><em>a</em></a></p>', '#2', [0, 0, 0], 0, [0, 0, 0], 1, '<p><a href="#2"><em>a</em></a></p>')
110
- ]);
111
- };
112
-
113
- var sUnlinkTests = function (editor, tinyApis) {
114
- var sUnlinkTest = function (inputHtml, sPath, sOffset, fPath, fOffset, expectedHtml) {
115
- var sUnlink = wrap(Actions.unlink, editor);
116
-
117
- return GeneralSteps.sequence([
118
- tinyApis.sSetContent(inputHtml),
119
- tinyApis.sSetSelection(sPath, sOffset, fPath, fOffset),
120
- sUnlink(),
121
- tinyApis.sAssertContent(expectedHtml, 'Should not have a link')
122
- ]);
123
- };
124
-
125
- return GeneralSteps.sequence([
126
- sUnlinkTest('<p>a</p>', [0, 0], 0, [0, 0], 1, '<p>a</p>'),
127
- sUnlinkTest('<p><a href="#">a</a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '<p>a</p>'),
128
- sUnlinkTest('<p><a href="#"><em>a</em></a></p>', [0, 0, 0], 0, [0, 0, 0], 1, '<p><em>a</em></p>'),
129
- sUnlinkTest('<p><a href="#">a</a>b</p>', [0, 0, 0], 0, [0, 1], 1, '<p>ab</p>')
130
- ]);
131
- };
132
-
133
- var base64ToBlob = function (base64, type) {
134
- var buff = atob(base64);
135
- var bytes = new Uint8Array(buff.length);
136
-
137
- for (var i = 0; i < bytes.length; i++) {
138
- bytes[i] = buff.charCodeAt(i);
139
- }
140
-
141
- return new Blob([bytes], {type: type});
142
- };
143
-
144
- var sInsertBlobTests = function (editor, tinyApis) {
145
- var sInsertBlobTest = function (inputHtml, path, offset, blob, base64, expectedHtml) {
146
- var sInsertBlob = wrap(Actions.insertBlob, editor);
147
-
148
- return GeneralSteps.sequence([
149
- tinyApis.sSetContent(inputHtml),
150
- tinyApis.sSetCursor(path, offset),
151
- sInsertBlob(blob, base64),
152
- tinyApis.sAssertContent(expectedHtml, 'Should have a image')
153
- ]);
154
- };
155
-
156
- var base64 = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
157
- var blob = base64ToBlob(base64, 'image/gif');
158
-
159
- return GeneralSteps.sequence([
160
- sInsertBlobTest('<p>a</p>', [0, 0], 0, base64, blob, '<p><img src="data:image/gif;base64,' + base64 + '" />a</p>')
161
- ]);
162
- };
163
-
164
- TinyLoader.setup(function (editor, onSuccess, onFailure) {
165
- var tinyApis = TinyApis(editor);
166
-
167
- Pipeline.async({}, [
168
- sInsertTableTests(editor, tinyApis),
169
- sFormatBlockTests(editor, tinyApis),
170
- sInsertBlobTests(editor, tinyApis),
171
- sCreateLinkTests(editor, tinyApis),
172
- sUnlinkTests(editor, tinyApis)
173
- ], onSuccess, onFailure);
174
- }, {
175
- inline: true
176
- }, success, failure);
177
- });
@@ -1,69 +0,0 @@
1
- asynctest('browser/core/ElementMatcherTest', [
2
- 'ephox.mcagar.api.TinyLoader',
3
- 'ephox.mcagar.api.TinyApis',
4
- 'ephox.agar.api.Step',
5
- 'ephox.agar.api.Assertions',
6
- 'tinymce/inlite/core/ElementMatcher',
7
- 'tinymce/inlite/core/PredicateId',
8
- 'ephox.agar.api.Pipeline'
9
- ], function (TinyLoader, TinyApis, Step, Assertions, ElementMatcher, PredicateId, Pipeline) {
10
- var success = arguments[arguments.length - 2];
11
- var failure = arguments[arguments.length - 1];
12
-
13
- var eq = function (target) {
14
- return function (elm) {
15
- return elm === target;
16
- };
17
- };
18
-
19
- var constantFalse = function (/*elm*/) {
20
- return false;
21
- };
22
-
23
- var sElementTest = function (tinyApis, editor, inputHtml, selector) {
24
- return Step.sync(function () {
25
- var target, result;
26
-
27
- editor.setContent(inputHtml);
28
- target = editor.dom.select(selector)[0];
29
-
30
- result = ElementMatcher.element(target, [
31
- PredicateId.create('a', constantFalse),
32
- PredicateId.create('b', eq(target))
33
- ])(editor);
34
-
35
- Assertions.assertEq(result.id, 'b', 'Should be matching B');
36
- Assertions.assertEq(result.rect.w > 0, true, 'Should be have width');
37
- });
38
- };
39
-
40
- var sParentTest = function (tinyApis, editor, inputHtml, selector) {
41
- return Step.sync(function () {
42
- var target, parents, result;
43
-
44
- editor.setContent(inputHtml);
45
- target = editor.dom.select(selector)[0];
46
- parents = editor.dom.getParents(target);
47
-
48
- result = ElementMatcher.parent(parents, [
49
- PredicateId.create('a', constantFalse),
50
- PredicateId.create('b', eq(parents[1])),
51
- PredicateId.create('c', eq(parents[0]))
52
- ])(editor);
53
-
54
- Assertions.assertEq(result.id, 'c', 'Should be matching C the closest one');
55
- Assertions.assertEq(result.rect.w > 0, true, 'Should be have width');
56
- });
57
- };
58
-
59
- TinyLoader.setup(function (editor, onSuccess, onFailure) {
60
- var tinyApis = TinyApis(editor);
61
-
62
- Pipeline.async({}, [
63
- sElementTest(tinyApis, editor, '<p>a</p>', 'p'),
64
- sParentTest(tinyApis, editor, '<div><p><em>a</em></p></div>', 'em')
65
- ], onSuccess, onFailure);
66
- }, {
67
- inline: true
68
- }, success, failure);
69
- });
@@ -1,118 +0,0 @@
1
- test('browser/core/LayoutTest', [
2
- 'ephox/tinymce',
3
- 'tinymce/inlite/core/Layout'
4
- ], function (tinymce, Layout) {
5
- // TODO: Move this to atomic test when we can require parts of tinymce core using bolt
6
-
7
- var rect = function (x, y, w, h) {
8
- return {x: x, y: y, w: w, h: h};
9
- };
10
-
11
- var clientRect = function (x, y, w, h) {
12
- return {left: x, top: y, width: w, height: h, bottom: y + h, right: x + w};
13
- };
14
-
15
- var assertLayout = function (expected, rects) {
16
- var result;
17
-
18
- result = Layout.calc(
19
- rects.targetRect,
20
- rects.contentAreaRect,
21
- rects.panelRect
22
- );
23
-
24
- assert.eq(expected, result);
25
- };
26
-
27
- var testCalcPanelAtBottomLeft = function () {
28
- assertLayout({
29
- rect: rect(0, 10, 20, 10),
30
- position: 'bl-tl'
31
- }, {
32
- contentAreaRect: rect(0, 0, 100, 100),
33
- targetRect: rect(0, 0, 10, 10),
34
- panelRect: rect(0, 0, 20, 10)
35
- });
36
- };
37
-
38
- var testCalcPanelAtBottomRight = function () {
39
- assertLayout({
40
- rect: rect(80, 10, 20, 10),
41
- position: 'br-tr'
42
- }, {
43
- contentAreaRect: rect(0, 0, 100, 100),
44
- targetRect: rect(90, 0, 10, 10),
45
- panelRect: rect(0, 0, 20, 10)
46
- });
47
- };
48
-
49
- var testCalcPanelAtTopLeft = function () {
50
- assertLayout({
51
- rect: rect(0, 10, 20, 10),
52
- position: 'tl-bl'
53
- }, {
54
- contentAreaRect: rect(0, 0, 100, 100),
55
- targetRect: rect(0, 20, 10, 10),
56
- panelRect: rect(0, 0, 20, 10)
57
- });
58
- };
59
-
60
- var testCalcPanelAtTopRight = function () {
61
- assertLayout({
62
- rect: rect(80, 10, 20, 10),
63
- position: 'tr-br'
64
- }, {
65
- contentAreaRect: rect(0, 0, 100, 100),
66
- targetRect: rect(90, 20, 10, 10),
67
- panelRect: rect(0, 0, 20, 10)
68
- });
69
- };
70
-
71
- var testCalcPanelAtTopCenter = function () {
72
- assertLayout({
73
- rect: rect(35, 10, 20, 10),
74
- position: 'tc-bc'
75
- }, {
76
- contentAreaRect: rect(0, 0, 100, 100),
77
- targetRect: rect(40, 20, 10, 10),
78
- panelRect: rect(0, 0, 20, 10)
79
- });
80
- };
81
-
82
- var testCalcPanelAtBottomCenter = function () {
83
- assertLayout({
84
- rect: rect(35, 10, 20, 10),
85
- position: 'bc-tc'
86
- }, {
87
- contentAreaRect: rect(0, 0, 100, 100),
88
- targetRect: rect(40, 0, 10, 10),
89
- panelRect: rect(0, 0, 20, 10)
90
- });
91
- };
92
-
93
- var testUserConstrain = function () {
94
- var targetRect, contentAreaRect, panelRect, userConstrainedPanelRect, handler;
95
-
96
- contentAreaRect = rect(0, 0, 100, 100);
97
- targetRect = rect(40, 0, 10, 10);
98
- panelRect = rect(0, 0, 20, 10);
99
-
100
- handler = function (rects) {
101
- assert.eq(rects.elementRect, clientRect(40, 0, 10, 10));
102
- assert.eq(rects.contentAreaRect, clientRect(0, 0, 100, 100));
103
- assert.eq(rects.panelRect, clientRect(0, 0, 20, 10));
104
- return clientRect(1, 2, 3, 4);
105
- };
106
-
107
- userConstrainedPanelRect = Layout.userConstrain(handler, targetRect, contentAreaRect, panelRect);
108
- assert.eq(userConstrainedPanelRect, rect(1, 2, 3, 4));
109
- };
110
-
111
- testCalcPanelAtBottomLeft();
112
- testCalcPanelAtBottomRight();
113
- testCalcPanelAtTopLeft();
114
- testCalcPanelAtTopRight();
115
- testCalcPanelAtTopCenter();
116
- testCalcPanelAtBottomCenter();
117
- testUserConstrain();
118
- });