locomotive-aloha-rails 0.23.2.1 → 0.23.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/README.md +3 -3
  2. data/lib/aloha/rails/engine.rb +1 -1
  3. data/lib/aloha/rails/version.rb +2 -2
  4. data/lib/tasks/aloha-assets.rake +1 -1
  5. data/vendor/assets/javascripts/aloha/css/aloha-sidebar.css +41 -17
  6. data/vendor/assets/javascripts/aloha/css/aloha.css +2 -2
  7. data/vendor/assets/javascripts/aloha/lib/aloha/contenthandlermanager.js +19 -18
  8. data/vendor/assets/javascripts/aloha/lib/aloha/engine.js +168 -9
  9. data/vendor/assets/javascripts/aloha/lib/aloha/ephemera.js +8 -1
  10. data/vendor/assets/javascripts/aloha/lib/aloha/markup.js +3 -2
  11. data/vendor/assets/javascripts/aloha/lib/aloha/pluginmanager.js +8 -0
  12. data/vendor/assets/javascripts/aloha/lib/aloha/sidebar.js +1 -1
  13. data/vendor/assets/javascripts/aloha/lib/aloha/state-override.js +59 -37
  14. data/vendor/assets/javascripts/aloha/lib/util/arrays.js +53 -6
  15. data/vendor/assets/javascripts/aloha/lib/util/boundary-markers.js +86 -0
  16. data/vendor/assets/javascripts/aloha/lib/util/dom2.js +178 -19
  17. data/vendor/assets/javascripts/aloha/lib/util/html.js +77 -10
  18. data/vendor/assets/javascripts/aloha/lib/util/maps.js +23 -1
  19. data/vendor/assets/javascripts/aloha/lib/util/range-context.js +429 -181
  20. data/vendor/assets/javascripts/aloha/lib/util/strings.js +9 -1
  21. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/de/i18n.js +4 -1
  22. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/blockmanager.js +2 -5
  23. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/css/characterpicker.css +6 -3
  24. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/lib/characterpicker-plugin.js +29 -32
  25. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/blockelementcontenthandler.js +41 -70
  26. data/vendor/assets/javascripts/aloha/plugins/common/dom-to-xhtml/lib/dom-to-xhtml.js +1 -1
  27. data/vendor/assets/javascripts/aloha/plugins/common/format/lib/format-plugin.js +22 -10
  28. data/vendor/assets/javascripts/aloha/plugins/common/link/css/link.css +2 -8
  29. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-cell.js +7 -0
  30. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-plugin.js +149 -131
  31. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table.js +77 -47
  32. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/port-helper-attribute-field.js +4 -8
  33. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/de/i18n.js +1 -0
  34. data/vendor/assets/javascripts/aloha/plugins/extra/cite/css/cite.css +0 -10
  35. data/vendor/assets/javascripts/aloha/plugins/extra/cite/lib/cite-plugin.js +4 -4
  36. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/lib/headerids-plugin.js +84 -32
  37. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/de/i18n.js +2 -1
  38. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/i18n.js +2 -1
  39. metadata +15 -14
@@ -105,10 +105,18 @@ define(['jquery'], function ($) {
105
105
  return result;
106
106
  }
107
107
 
108
+ /**
109
+ * Returns true for the empty string, null and undefined.
110
+ */
111
+ function empty(str) {
112
+ return "" === str || null == str;
113
+ }
114
+
108
115
  return {
109
116
  words: words,
110
117
  dashesToCamelCase: dashesToCamelCase,
111
118
  camelCaseToDashes: camelCaseToDashes,
112
- splitIncl: splitIncl
119
+ splitIncl: splitIncl,
120
+ empty: empty
113
121
  };
114
122
  });
@@ -2,5 +2,8 @@ define({
2
2
  "button.alignright.tooltip": "Rechtsbünding",
3
3
  "button.alignleft.tooltip": "Linksbündig",
4
4
  "button.aligncenter.tooltip": "Zentriert",
5
- "button.alignjustify.tooltip": "Blocksatz"
5
+ "button.alignjustify.tooltip": "Blocksatz",
6
+ "button.aligntop.tooltip": "Oben aurichten",
7
+ "button.alignmiddle.tooltip": "Zentriert ausrichten",
8
+ "button.alignbottom.tooltip": "Unten ausrichten"
6
9
  });
@@ -238,11 +238,8 @@ define([
238
238
  // - IE7/8 Workaround
239
239
  // - deletion of blocks inside block collection
240
240
  jQuery(window.document).keydown(function (e) {
241
-
242
- // Pressing DEL or BACKSPACE in a sidebar attribute editor form input
243
- // causes the destruction of the block;
244
- // if the keypress comes from a form element do nothing
245
- if (typeof e.srcElement !== 'undefined' && typeof e.srcElement.form !== 'undefined') {
241
+ // Ignore events originating from the UI
242
+ if ($(e.target).closest('.aloha-ui').length > 0) {
246
243
  return true;
247
244
  }
248
245
 
@@ -22,13 +22,16 @@
22
22
  .aloha-character-picker-overlay td{
23
23
  width: 1.2em;
24
24
  height: 1.2em;
25
- line-height: 1.2em;
26
- font-size: 1em;
27
25
  padding: 0.1em;
28
- cursor: pointer;
29
26
  border: 1px solid #afafaf;
30
27
  background-color: #fff;
28
+
29
+ color: #000000;
30
+ line-height: 1.2em;
31
+ font-size: 1em;
31
32
  text-align: center;
33
+
34
+ cursor: pointer;
32
35
  }
33
36
 
34
37
  .aloha-character-picker-overlay td.focused {
@@ -67,7 +67,7 @@ define([
67
67
  var configs = {};
68
68
 
69
69
  /**
70
- * Checks whether the character picker overlay.
70
+ * Checks whether the character picker overlay is visible.
71
71
  *
72
72
  * @param {Overlay} overlay
73
73
  * @return {boolean} True if the overlay is visible.
@@ -88,12 +88,12 @@ define([
88
88
  });
89
89
 
90
90
  $('body').click(function ($event) {
91
- // Because we click events on the overlay ui should not cause it to
91
+ // Because click events on the overlay ui should not cause it to
92
92
  // hide itself.
93
93
  if (!overlay._overlayActive
94
94
  || ($event.target === overlay.$element[0])
95
- || $(event.target).is('.aloha-icon-characterpicker')
96
- || $(event.target).find('.aloha-icon-characterpicker').length) {
95
+ || $($event.target).is('.aloha-icon-characterpicker')
96
+ || $($event.target).find('.aloha-icon-characterpicker').length) {
97
97
  return;
98
98
  }
99
99
  overlay.hide();
@@ -119,12 +119,11 @@ define([
119
119
  *
120
120
  * @param {HTMLElement} source The element of which the style element is
121
121
  * taken.
122
- * @param {HTMLElement} target Where the style will be applied.
122
+ * @param {jQuery.<HTMLElement>} target Where the style will be applied.
123
123
  * @param {string} styleProp The css property which shall be copied.
124
- * @return {jQuery.<HTMLElement>}
125
124
  */
126
- function copyStyle(source, target, styleProp) {
127
- // Move to strings.js
125
+ function copyStyle(source, $target, styleProp) {
126
+ // TODO: Move to strings.js
128
127
  var camelize = function (str) {
129
128
  return str.replace(/\-(\w)/g, function (str, letter) {
130
129
  return letter.toUpperCase();
@@ -144,7 +143,9 @@ define([
144
143
  style = source.style[camelize(styleProp)];
145
144
  }
146
145
 
147
- return style ? target.css(styleProp, style) : null;
146
+ if (style) {
147
+ $target.css(styleProp, style);
148
+ }
148
149
  }
149
150
 
150
151
  /**
@@ -252,24 +253,22 @@ define([
252
253
  }
253
254
 
254
255
  /**
255
- * @param {Overlay} overlay
256
+ * Calculates the offset at which to position the overlay element.
257
+ *
256
258
  * @param {jQuery.<HTMLElement>} $element A DOM element around which to
257
259
  * calculate the offset.
258
260
  */
259
- function calculateOffset(overlay, $element) {
261
+ function calculateOffset($element) {
260
262
  var offset = $element.offset();
261
263
  if ('fixed' === Floating.POSITION_STYLE) {
262
264
  offset.top -= $WINDOW.scrollTop();
263
265
  offset.left -= $WINDOW.scrollLeft();
264
266
  }
265
- return {
266
- top: overlay.offset.top + (offset.top - overlay.offset.top),
267
- left: overlay.offset.left + (offset.left - overlay.offset.left)
268
- };
267
+ return offset;
269
268
  }
270
269
 
271
270
  /**
272
- * Insert the selected character, at the editor's selection.
271
+ * Inserts the selected character, at the editor's selection.
273
272
  *
274
273
  * @param {String} character
275
274
  */
@@ -318,13 +317,9 @@ define([
318
317
  }
319
318
 
320
319
  Overlay.prototype = {
321
- offset: {
322
- top: 0,
323
- left: 0
324
- },
325
320
 
326
321
  /**
327
- * Show the character overlay at the insert button's position.
322
+ * Shows the character overlay at the insert button's position.
328
323
  *
329
324
  * @param {jQuery.<HTMLElement>} $insert Insert button.
330
325
  */
@@ -333,7 +328,7 @@ define([
333
328
 
334
329
  // Because the overlay needs to be reposition relative its button.
335
330
  overlay.$element
336
- .css(calculateOffset(overlay, $insert))
331
+ .css(calculateOffset($insert))
337
332
  .css('position', Floating.POSITION_STYLE)
338
333
  .show()
339
334
  .find('.focused')
@@ -347,6 +342,9 @@ define([
347
342
  overlay._overlayActive = true;
348
343
  },
349
344
 
345
+ /**
346
+ * Hides the character overlay.
347
+ */
350
348
  hide: function () {
351
349
  this.$element.hide();
352
350
  this._overlayActive = false;
@@ -354,7 +352,7 @@ define([
354
352
  };
355
353
 
356
354
  /**
357
- * Generate an character picker overlay for the given editable.
355
+ * Generates an character picker overlay for the given editable.
358
356
  *
359
357
  * Because each editable may have its own configuration and therefore may
360
358
  * have its own overlay.
@@ -366,7 +364,7 @@ define([
366
364
  * character picker.
367
365
  */
368
366
  function generateOverlay(characterpicker, editable) {
369
- var config = characterpicker.getEditableConfig(editable);
367
+ var config = characterpicker.getEditableConfig(editable.obj);
370
368
  if (!config) {
371
369
  return null;
372
370
  }
@@ -411,11 +409,11 @@ define([
411
409
  rangeAtOpen = Aloha.Selection.rangeObject;
412
410
 
413
411
  var from = rangeAtOpen.startContainer.parentNode;
414
- var to = characterpicker.overlay.$element;
412
+ var $to = characterpicker.overlay.$element;
415
413
 
416
- copyStyle(from, to, 'font-family');
417
- copyStyle(from, to, 'font-weight');
418
- copyStyle(from, to, 'font-style');
414
+ copyStyle(from, $to, 'font-family');
415
+ copyStyle(from, $to, 'font-weight');
416
+ copyStyle(from, $to, 'font-style');
419
417
 
420
418
  characterpicker.overlay.show(this.element);
421
419
  }
@@ -423,8 +421,8 @@ define([
423
421
  });
424
422
 
425
423
  /**
426
- * Pre-generate overlays to so that they will be ready when the
427
- * editor click on an editable.
424
+ * Pre-generates overlays so that they will be ready when the editor
425
+ * click on an editable.
428
426
  *
429
427
  * @param {number} editableIndex
430
428
  */
@@ -455,9 +453,8 @@ define([
455
453
 
456
454
  PubSub.sub('aloha.floating.changed', function (message) {
457
455
  if (characterpicker.overlay) {
458
- characterpicker.overlay.offset = message.position.offset;
459
456
  characterpicker.overlay.$element.css(
460
- calculateOffset(characterpicker.overlay, button.element)
457
+ calculateOffset(button.element)
461
458
  );
462
459
  }
463
460
  });
@@ -3,76 +3,58 @@
3
3
  * Author & Copyright (c) 2010-2013 Gentics Software GmbH
4
4
  * aloha-sales@gentics.com
5
5
  * Licensed unter the terms of http://www.aloha-editor.com/license.html
6
+ *
7
+ * @overview
8
+ * Prepares block-level elements in contents of editables that are initialized
9
+ * for editing ('initEditing'), or when exporting contents of editable for
10
+ * saving ('getContents').
6
11
  */
7
12
  define([
8
13
  'jquery',
9
14
  'aloha/core',
10
15
  'aloha/contenthandlermanager',
11
16
  'contenthandler/contenthandler-utils',
17
+ 'util/functions',
12
18
  'util/html'
13
19
  ], function (
14
20
  $,
15
21
  Aloha,
16
22
  ContentHandlerManager,
17
23
  Utils,
24
+ Functions,
18
25
  Html
19
26
  ) {
20
27
  'use strict';
21
28
 
22
- var blocksSelector = Html.BLOCK_TAGNAMES.join();
23
- var emptyBlocksSelector = Html.BLOCK_TAGNAMES.join(':empty,') + ':empty';
29
+ var blocksSelector = Html.BLOCKLEVEL_ELEMENTS.join();
30
+ var emptyBlocksSelector = Html.BLOCKLEVEL_ELEMENTS.join(':empty,')
31
+ + ':empty';
24
32
  var NOT_ALOHA_BLOCK_FILTER = ':not(.aloha-block)';
25
33
 
26
- /**
27
- * Determines if the given HTML element needs a trailing <br> tag in order
28
- * for it to be visible.
29
- *
30
- * @param {HTMLElement} block
31
- * @return {boolean}
32
- */
33
- function needsEndBr(block) {
34
- return (
35
- Html.isBlock(block)
36
- &&
37
- (!block.lastChild ||
38
- 'br' !== block.lastChild.nodeName.toLowerCase())
39
- );
40
- }
41
-
42
- /**
43
- * Finds a <br> tag that is at the end of the given container.
44
- * Invisible what spaces are ignored.
45
- *
46
- * @param {HTMLElement} container
47
- * @return {HTMLElement|null} A <br> tag at the end of the container; null
48
- * if none is found.
49
- */
50
- function findEndBr(container) {
51
- var node = container.lastChild;
52
- while (node && Html.isIgnorableWhitespace(node)) {
53
- node = node.previousSibling;
54
- }
55
- return ('br' === node.nodeName.toLowerCase()) ? node : null;
56
- }
34
+ var isNotIgnorableWhitespace =
35
+ Functions.complement(Html.isIgnorableWhitespace);
57
36
 
58
37
  /**
59
38
  * Removes the <br> tag that is at the end of the given container.
60
- * Invisible what spaces are ignored.
39
+ * Invisible white spaces are ignored.
61
40
  *
62
- * @param {number} i Unused
63
- * @param {HTMLElement} element
41
+ * @param {number} i Index of element in its collection. (Unused)
42
+ * @param {HTMLElement} element The container in which to remove the <br>.
64
43
  */
65
- function removeEndBr(i, element) {
66
- var br = findEndBr(element);
67
- if (br) {
68
- $(br).remove();
44
+ function removeTrailingBr(i, element) {
45
+ var node = Html.findNodeRight(
46
+ element.lastChild,
47
+ isNotIgnorableWhitespace
48
+ );
49
+ if (node && 'br' === node.nodeName.toLowerCase()) {
50
+ $(node).remove();
69
51
  }
70
52
  }
71
53
 
72
54
  /**
73
55
  * Prepares this content for editing
74
56
  *
75
- * @param {number} i Unused
57
+ * @param {number} i Index of element in its collection. (Unused)
76
58
  * @param {HTMLElement} element
77
59
  */
78
60
  function prepareForEditing(i, element) {
@@ -81,10 +63,10 @@ define([
81
63
  $element.filter(emptyBlocksSelector).remove();
82
64
 
83
65
  if ($.browser.msie) {
84
- // If editing in IE: remove end-br's. Content edited by Aloha
85
- // Editor is no longer exported with <br>'s that are annotated with
86
- // "aloha-end-br" classes, this clean-up is still done, however,
87
- // for content that was edited using legacy Aloha Editor.
66
+ // Because even though content edited by Aloha Editor is no longer
67
+ // exported with propping <br>'s that are annotated with
68
+ // "aloha-end-br" classes, this clean-up still needs to be done for
69
+ // content that was edited using legacy Aloha Editor.
88
70
  $element.filter('br.aloha-end-br').remove();
89
71
 
90
72
  // Because IE's Trident engine goes against W3C's HTML specification
@@ -95,20 +77,14 @@ define([
95
77
  // content editable block-level elements are not rendered invisibly
96
78
  // in IE, we can remove the propping <br> in otherwise empty
97
79
  // block-level elements.
98
- $element.filter(blocksSelector).each(removeEndBr);
99
- } else {
100
- $element.filter('li').each(function () {
101
- // Does not compute; Html.isBlock(li) === false
102
- if (needsEndBr(this)) {
103
- $(this).append('<br/>');
104
- }
105
- });
80
+ $element.filter(blocksSelector).each(removeTrailingBr);
106
81
  }
82
+
107
83
  $element.children(NOT_ALOHA_BLOCK_FILTER).each(prepareForEditing);
108
84
  }
109
85
 
110
86
  /**
111
- * Prepares the content for editing in IE7.
87
+ * Prepares the content for editing in IE versions older than version 8.
112
88
  *
113
89
  * Ensure that all empty blocklevel elements must contain a zero-width
114
90
  * whitespace.
@@ -116,18 +92,18 @@ define([
116
92
  * @param {number} i Unused
117
93
  * @param {HTMLElement} element
118
94
  */
119
- function prepareEditingIE7(i, element) {
95
+ function prepareEditingInOldIE(i, element) {
120
96
  var $element = $(element);
121
97
  $element.filter(emptyBlocksSelector).append('\u200b');
122
- $element.children(NOT_ALOHA_BLOCK_FILTER).each(prepareEditingIE7);
98
+ $element.children(NOT_ALOHA_BLOCK_FILTER).each(prepareEditingInOldIE);
123
99
  }
124
100
 
125
101
  /**
126
102
  * For a given DOM element, will make sure that it, and every one of its
127
103
  * child nodes, which is a block-level element ends with a <br> node.
128
104
  *
129
- * This ensures that a block is rendered visibly (with atleast one
130
- * character height).
105
+ * This ensures that a block is rendered visibly (with atleast one character
106
+ * height).
131
107
  *
132
108
  * @param {number} i Unused
133
109
  * @param {HTMLElement} element
@@ -139,34 +115,29 @@ define([
139
115
  }
140
116
 
141
117
  return ContentHandlerManager.createHandler({
142
- handleContent: function (content, options) {
118
+ handleContent: function handleBlockLevelContent(content, options) {
119
+ if (!options) {
120
+ return content;
121
+ }
143
122
  var $content = Utils.wrapContent(content);
144
-
145
- if (!options || !$content) {
146
- return $content && $content.html();
123
+ if (!$content) {
124
+ return content;
147
125
  }
148
-
149
126
  switch (options.command) {
150
127
  case 'initEditable':
151
128
  $content.children(NOT_ALOHA_BLOCK_FILTER)
152
129
  .each(prepareForEditing);
153
130
 
154
- // TODO: Do we support ie versions below 7?
155
131
  if ($.browser.msie && $.browser.version <= 7) {
156
132
  $content.children(NOT_ALOHA_BLOCK_FILTER)
157
- .each(prepareEditingIE7);
133
+ .each(prepareEditingInOldIE);
158
134
  }
159
135
  break;
160
136
  case 'getContents':
161
137
  $content.children(NOT_ALOHA_BLOCK_FILTER)
162
138
  .each(propBlockElements);
163
-
164
- // Because trailing end <br>s in <li>s are not necessary for
165
- // rendering.
166
- $content.find('li>br:last').remove();
167
139
  break;
168
140
  }
169
-
170
141
  return $content.html();
171
142
  }
172
143
  });
@@ -118,7 +118,7 @@ function(
118
118
  * The given string with & and < characters replaced with the corresponding HTML entity references.
119
119
  */
120
120
  function encodePcdata(str) {
121
- return str.replace(/&/g, '&amp;').replace(/</g, '&lt;');
121
+ return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
122
122
  }
123
123
 
124
124
  /**
@@ -199,6 +199,19 @@ define('format/format-plugin', [
199
199
  Aloha.Selection.changeMarkupOnSelection(jQuery('<' + button + '>'));
200
200
  }
201
201
 
202
+ function updateUiAfterMutation(formatPlugin, rangeObject) {
203
+ // select the modified range
204
+ rangeObject.select();
205
+ // update Button toggle state. We take 'Aloha.Selection.getRangeObject()'
206
+ // because rangeObject is not up-to-date
207
+ onSelectionChanged(formatPlugin, Aloha.Selection.getRangeObject());
208
+ }
209
+
210
+ function format(formatPlugin, rangeObject, markup) {
211
+ GENTICS.Utils.Dom.addMarkup(rangeObject, markup);
212
+ updateUiAfterMutation(formatPlugin, rangeObject);
213
+ }
214
+
202
215
  function addMarkup(button) {
203
216
  var formatPlugin = this;
204
217
  var markup = jQuery('<'+button+'>');
@@ -223,27 +236,26 @@ define('format/format-plugin', [
223
236
  // the range is not collapsed, so we remove the markup from the range
224
237
  GENTICS.Utils.Dom.removeMarkup(rangeObject, jQuery(foundMarkup), Aloha.activeEditable.obj);
225
238
  }
239
+ updateUiAfterMutation(formatPlugin, rangeObject);
226
240
  } else {
227
241
  // when the range is collapsed, extend it to a word
228
242
  if (rangeObject.isCollapsed()) {
229
243
  GENTICS.Utils.Dom.extendToWord(rangeObject);
230
244
  if (rangeObject.isCollapsed()) {
231
245
  if (StateOverride.enabled()) {
232
- StateOverride.setWithRangeObject(commandsByElement[button], true, rangeObject);
246
+ StateOverride.setWithRangeObject(
247
+ commandsByElement[button],
248
+ rangeObject,
249
+ function (command, rangeObject) {
250
+ format(formatPlugin, rangeObject, markup);
251
+ }
252
+ );
233
253
  return;
234
254
  }
235
255
  }
236
256
  }
237
-
238
- // add the markup
239
- GENTICS.Utils.Dom.addMarkup(rangeObject, markup);
257
+ format(formatPlugin, rangeObject, markup);
240
258
  }
241
- // select the modified range
242
- rangeObject.select();
243
-
244
- // update Button toggle state. We take 'Aloha.Selection.getRangeObject()'
245
- // because rangeObject is not up-to-date
246
- onSelectionChanged(formatPlugin, Aloha.Selection.getRangeObject());
247
259
  }
248
260
 
249
261
  function onSelectionChanged(formatPlugin, rangeObject) {