locomotive-aloha-rails 0.20.1.2 → 0.20.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/aloha/rails/version.rb +2 -2
- data/vendor/assets/javascripts/aloha/css/aloha.css +3 -0
- data/vendor/assets/javascripts/aloha/css/ext-aloha.css +3 -0
- data/vendor/assets/javascripts/aloha/lib/aloha-bootstrap.js +4565 -3934
- data/vendor/assets/javascripts/aloha/lib/aloha.js +1357 -702
- data/vendor/assets/javascripts/aloha/lib/aloha/command.js +16 -13
- data/vendor/assets/javascripts/aloha/lib/aloha/core.js +23 -3
- data/vendor/assets/javascripts/aloha/lib/aloha/ecma5shims.js +23 -7
- data/vendor/assets/javascripts/aloha/lib/aloha/editable.js +57 -14
- data/vendor/assets/javascripts/aloha/lib/aloha/engine.js +9 -5
- data/vendor/assets/javascripts/aloha/lib/aloha/floatingmenu.js +288 -96
- data/vendor/assets/javascripts/aloha/lib/aloha/jquery.js +11 -1
- data/vendor/assets/javascripts/aloha/lib/aloha/markup.js +318 -40
- data/vendor/assets/javascripts/aloha/lib/aloha/repositorymanager.js +11 -10
- data/vendor/assets/javascripts/aloha/lib/aloha/selection.js +20 -1
- data/vendor/assets/javascripts/aloha/lib/aloha/sidebar.js +11 -1
- data/vendor/assets/javascripts/aloha/lib/jquery-plugin.js +10 -7
- data/vendor/assets/javascripts/aloha/lib/util/dom.js +18 -6
- data/vendor/assets/javascripts/aloha/lib/util/range.js +6 -6
- data/vendor/assets/javascripts/aloha/lib/vendor/ext-3.2.1/ext-all-debug.js +26 -2
- data/vendor/assets/javascripts/aloha/lib/vendor/jquery.store.js +39 -15
- data/vendor/assets/javascripts/aloha/plugins/common/abbr/lib/abbr-plugin.js +1 -0
- data/vendor/assets/javascripts/aloha/plugins/common/align/lib/align-plugin.js +344 -334
- data/vendor/assets/javascripts/aloha/plugins/common/block/css/block.css +65 -12
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/block-plugin.js +12 -15
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/block.js +796 -180
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/blockcontenthandler.js +54 -13
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/blockmanager.js +315 -78
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/editor.js +111 -8
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/editormanager.js +2 -0
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/jquery-ui-1.8.16.custom.min.js +198 -0
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/sidebarattributeeditor.js +7 -20
- data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/lib/characterpicker-plugin.js +15 -3
- data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/sanitizecontenthandler.js +3 -2
- data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/wordcontenthandler.js +111 -5
- data/vendor/assets/javascripts/aloha/plugins/common/dom-to-xhtml/lib/dom-to-xhtml-plugin.js +29 -0
- data/vendor/assets/javascripts/aloha/plugins/common/dom-to-xhtml/lib/dom-to-xhtml.js +306 -0
- data/vendor/assets/javascripts/aloha/plugins/common/format/lib/format-plugin.js +59 -5
- data/vendor/assets/javascripts/aloha/plugins/common/format/nls/i18n.js +1 -1
- data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/lib/horizontalruler-plugin.js +18 -3
- data/vendor/assets/javascripts/aloha/plugins/common/image/img/crop-buttons.gif +0 -0
- data/vendor/assets/javascripts/aloha/plugins/common/image/lib/image-plugin.js +1629 -1601
- data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/jcrop/jquery.jcrop.css +11 -0
- data/vendor/assets/javascripts/aloha/plugins/common/link/extra/linklist.js +8 -6
- data/vendor/assets/javascripts/aloha/plugins/common/link/lib/link-plugin.js +26 -10
- data/vendor/assets/javascripts/aloha/plugins/common/list/nls/de/i18n.js +5 -1
- data/vendor/assets/javascripts/aloha/plugins/common/paste/lib/paste-plugin.js +3 -4
- data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-cell.js +13 -12
- data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-plugin.js +108 -61
- data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-selection.js +61 -1
- data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table.js +1 -0
- data/vendor/assets/javascripts/aloha/plugins/common/table/nls/de/i18n.js +28 -1
- data/vendor/assets/javascripts/aloha/plugins/common/table/nls/i18n.js +36 -10
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/css/browser.jqgrid.css +292 -292
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/lib/browser.js +28 -5
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/lib/locale.js +2 -2
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/vendor/grid.locale.de.js +6 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/vendor/grid.locale.en.js +5 -0
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/vendor/jquery.jqGrid.js +5 -0
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/vendor/jquery.jstree.js +6 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/vendor/jquery.ui.js +6 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/browser/vendor/ui-layout.js +6 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/cite/lib/cite-plugin.js +18 -4
- data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/lib/formatlesspaste-plugin.js +1 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/lib/linkbrowser-plugin.js +14 -2
- data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/demo/js/aloha-config.js +2 -2
- data/vendor/assets/javascripts/aloha/plugins/extra/toc/lib/toc-plugin.js +382 -0
- data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/de/i18n.js +3 -0
- data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/i18n.js +4 -0
- metadata +15 -11
- data/vendor/assets/javascripts/aloha/plugins/extra/toc/i18n/de.json +0 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/toc/i18n/en.json +0 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/toc/src/toc.js +0 -350
@@ -352,8 +352,18 @@ function(Aloha, jQuery, FloatingMenu, Class, Range) {
|
|
352
352
|
// the start of the selection was not yet found, so look for it now
|
353
353
|
// check whether the start of the selection is found here
|
354
354
|
|
355
|
+
// Try to read the nodeType property and return if we do not have permission
|
356
|
+
// ie.: frame document to an external URL
|
357
|
+
var nodeType;
|
358
|
+
try {
|
359
|
+
nodeType = this.nodeType;
|
360
|
+
}
|
361
|
+
catch (e) {
|
362
|
+
return;
|
363
|
+
}
|
364
|
+
|
355
365
|
// check is dependent on the node type
|
356
|
-
switch(
|
366
|
+
switch(nodeType) {
|
357
367
|
case 3: // text node
|
358
368
|
if (this === rangeObject.startContainer) {
|
359
369
|
// the selection starts here
|
@@ -603,8 +613,17 @@ function(Aloha, jQuery, FloatingMenu, Class, Range) {
|
|
603
613
|
standardAttributesComparator: function(domobj, markupObject) {
|
604
614
|
var i, attr, classString, classes, classes2, classLength, attrLength, domAttrLength;
|
605
615
|
|
616
|
+
// Cloning the domobj works around an IE7 bug that crashes
|
617
|
+
// the browser. The exact place where IE7 crashes is when
|
618
|
+
// the domobj.attribute[i] is read below.
|
619
|
+
// The bug can be reproduced with an editable that contains
|
620
|
+
// some text and and image, by clicking inside and outside the
|
621
|
+
// editable a few times.
|
622
|
+
domobj = domobj.cloneNode(false);
|
623
|
+
|
606
624
|
if (domobj.attributes && domobj.attributes.length && domobj.attributes.length > 0) {
|
607
625
|
for (i = 0, domAttrLength = domobj.attributes.length; i < domAttrLength; i++) {
|
626
|
+
// Dereferencing attributes[i] here would crash IE7 if domobj were not cloned above
|
608
627
|
attr = domobj.attributes[i];
|
609
628
|
if (attr.nodeName.toLowerCase() == 'class' && attr.nodeValue.length > 0) {
|
610
629
|
classString = attr.nodeValue;
|
@@ -185,6 +185,7 @@ define( [
|
|
185
185
|
sidebar.init( opts );
|
186
186
|
}
|
187
187
|
} );
|
188
|
+
|
188
189
|
};
|
189
190
|
|
190
191
|
// ------------------------------------------------------------------------
|
@@ -447,7 +448,16 @@ define( [
|
|
447
448
|
if (this.opened) {
|
448
449
|
this.rotateHandleArrow(isRight ? 0 : 180, 0);
|
449
450
|
}
|
450
|
-
|
451
|
+
|
452
|
+
// configure the position of the sidebar handle
|
453
|
+
jQuery( function () {
|
454
|
+
if ( typeof Aloha.settings.sidebar != 'undefined' &&
|
455
|
+
Aloha.settings.sidebar.handle &&
|
456
|
+
Aloha.settings.sidebar.handle.top ) {
|
457
|
+
jQuery(bar.find(nsSel('handle'))).get(0).style.top = Aloha.settings.sidebar.handle.top;
|
458
|
+
}
|
459
|
+
} );
|
460
|
+
|
451
461
|
bar.find(nsSel('handle'))
|
452
462
|
.click(function () {
|
453
463
|
if (bounceTimer) {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/*global define: true */
|
1
2
|
/*!
|
2
3
|
* This file is part of Aloha Editor Project http://aloha-editor.org
|
3
4
|
* Copyright © 2010-2011 Gentics Software GmbH, aloha@gentics.com
|
@@ -26,18 +27,20 @@
|
|
26
27
|
load: function (name, require, load, config) {
|
27
28
|
var url = require.toUrl(name + '.js');
|
28
29
|
|
29
|
-
require(['aloha/jquery'], function(value) {
|
30
|
+
require(['aloha/jquery'], function (value) {
|
30
31
|
var $ = value;
|
31
32
|
$.ajax({
|
32
33
|
type: 'GET',
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
url: url,
|
35
|
+
cache: true,
|
36
|
+
dataType: 'text',
|
37
|
+
success: function (plugin) {
|
37
38
|
// plugin = '(function(jQuery) { var $ = jQuery;\n' + plugin + '}(window.alohaQuery));';
|
38
|
-
plugin = 'define([\'aloha/jquery\'], function(jQuery) { var $ = jQuery;\n' + plugin + '});'
|
39
|
+
plugin = 'define([\'aloha/jquery\'], function(jQuery) { var $ = jQuery;\n' + plugin + '});';
|
39
40
|
load.fromText(name, plugin);
|
40
|
-
|
41
|
+
require([name], function (value) {
|
42
|
+
load(value);
|
43
|
+
});
|
41
44
|
}
|
42
45
|
});
|
43
46
|
});
|
@@ -103,22 +103,22 @@ var Dom = Class.extend({
|
|
103
103
|
*/
|
104
104
|
tags: {
|
105
105
|
'flow' : [ 'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio',
|
106
|
-
'b', 'bdo', 'blockquote', 'br', 'button', 'canvas', 'cite', 'code',
|
106
|
+
'b', 'bdi','bdo', 'blockquote', 'br', 'button', 'canvas', 'cite', 'code',
|
107
107
|
'command', 'datalist', 'del', 'details', 'dfn', 'div', 'dl', 'em',
|
108
108
|
'embed', 'fieldset', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
|
109
109
|
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'iframe', 'img',
|
110
110
|
'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math',
|
111
111
|
'menu', 'meter', 'nav', 'noscript', 'object', 'ol', 'output', 'p',
|
112
|
-
'pre', 'progress', 'q', 'ruby', 'samp', 'script', 'section',
|
112
|
+
'pre', 'progress', 'q', 'ruby', 's', 'samp', 'script', 'section',
|
113
113
|
'select', 'small', 'span', 'strong', 'style', 'sub', 'sup', 'svg',
|
114
|
-
'table', 'textarea', 'time', 'ul', 'var', 'video', 'wbr', '#text' ],
|
115
|
-
'phrasing' : [ 'a', 'abbr', 'area', 'audio', 'b', 'bdo', 'br', 'button',
|
114
|
+
'table', 'textarea', 'time', 'u', 'ul', 'var', 'video', 'wbr', '#text' ],
|
115
|
+
'phrasing' : [ 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button',
|
116
116
|
'canvas', 'cite', 'code', 'command', 'datalist', 'del', 'dfn',
|
117
117
|
'em', 'embed', 'i', 'iframe', 'img', 'input', 'ins', 'kbd',
|
118
118
|
'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
|
119
119
|
'object', 'output', 'progress', 'q', 'ruby', 'samp', 'script',
|
120
120
|
'select', 'small', 'span', 'strong', 'sub', 'sup', 'svg',
|
121
|
-
'textarea', 'time', 'var', 'video', 'wbr', '#text' ]
|
121
|
+
'textarea', 'time', 'u', 'var', 'video', 'wbr', '#text' ]
|
122
122
|
},
|
123
123
|
|
124
124
|
/**
|
@@ -231,6 +231,7 @@ var Dom = Class.extend({
|
|
231
231
|
'title' : '#text',
|
232
232
|
'tr' : ['th', 'td'],
|
233
233
|
'track' : 'empty',
|
234
|
+
'u' : 'phrasing',
|
234
235
|
'ul' : 'li',
|
235
236
|
'var' : 'phrasing',
|
236
237
|
'video' : 'source', // transparent
|
@@ -668,8 +669,19 @@ var Dom = Class.extend({
|
|
668
669
|
|
669
670
|
// iterate through all sub nodes
|
670
671
|
startObject.contents().each(function(index) {
|
672
|
+
|
673
|
+
// Try to read the nodeType property and return if we do not have permission
|
674
|
+
// ie.: frame document to an external URL
|
675
|
+
var nodeType;
|
676
|
+
try {
|
677
|
+
nodeType = this.nodeType;
|
678
|
+
}
|
679
|
+
catch (e) {
|
680
|
+
return;
|
681
|
+
}
|
682
|
+
|
671
683
|
// decide further actions by node type
|
672
|
-
switch(
|
684
|
+
switch(nodeType) {
|
673
685
|
// found a non-text node
|
674
686
|
case 1:
|
675
687
|
if (prevNode && prevNode.nodeName == this.nodeName) {
|
@@ -139,7 +139,6 @@ GENTICS.Utils.RangeObject = Class.extend({
|
|
139
139
|
// sometimes it's cached (or was set)
|
140
140
|
return this.commonAncestorContainer;
|
141
141
|
}
|
142
|
-
|
143
142
|
// if it's not cached, calculate and then cache it
|
144
143
|
this.updateCommonAncestorContainer();
|
145
144
|
|
@@ -225,13 +224,13 @@ GENTICS.Utils.RangeObject = Class.extend({
|
|
225
224
|
* @hide
|
226
225
|
*/
|
227
226
|
updateCommonAncestorContainer: function(commonAncestorContainer) {
|
228
|
-
// this will be needed either right now for finding the CAC or later for the crossing index
|
229
|
-
var parentsStartContainer = this.getStartContainerParents(),
|
230
|
-
parentsEndContainer = this.getEndContainerParents(),
|
231
|
-
i;
|
232
|
-
|
233
227
|
// if no parameter was passed, calculate it
|
234
228
|
if (!commonAncestorContainer) {
|
229
|
+
// this will be needed either right now for finding the CAC or later for the crossing index
|
230
|
+
var parentsStartContainer = this.getStartContainerParents(),
|
231
|
+
parentsEndContainer = this.getEndContainerParents(),
|
232
|
+
i;
|
233
|
+
|
235
234
|
// find the crossing between startContainer and endContainer parents (=commonAncestorContainer)
|
236
235
|
if (!(parentsStartContainer.length > 0 && parentsEndContainer.length > 0)) {
|
237
236
|
console.warn('could not find commonAncestorContainer');
|
@@ -412,6 +411,7 @@ GENTICS.Utils.RangeObject = Class.extend({
|
|
412
411
|
*/
|
413
412
|
update: function(event) {
|
414
413
|
console.debug('now updating rangeObject');
|
414
|
+
|
415
415
|
this.initializeFromUserSelection(event);
|
416
416
|
this.updateCommonAncestorContainer();
|
417
417
|
},
|
@@ -188,14 +188,38 @@ Ext.DomHelper = function(){
|
|
188
188
|
setStart = 'setStart' + (endRe.test(where) ? 'After' : 'Before');
|
189
189
|
if (hash[where]) {
|
190
190
|
range[setStart](el);
|
191
|
-
|
191
|
+
|
192
|
+
// Workaround for IE9, because it does not have this method anymore
|
193
|
+
// When we have moved to jQuery we won't need this anymore
|
194
|
+
if (typeof range.createContextualFragment === 'function') {
|
195
|
+
frag = range.createContextualFragment(html);
|
196
|
+
}
|
197
|
+
else {
|
198
|
+
frag = document.createDocumentFragment(),
|
199
|
+
div = document.createElement("div");
|
200
|
+
frag.appendChild(div);
|
201
|
+
div.outerHTML = html;
|
202
|
+
}
|
203
|
+
|
192
204
|
el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
|
193
205
|
return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];
|
194
206
|
} else {
|
195
207
|
rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';
|
196
208
|
if (el.firstChild) {
|
197
209
|
range[setStart](el[rangeEl]);
|
198
|
-
|
210
|
+
|
211
|
+
// Workaround for IE9, because it does not have this method anymore
|
212
|
+
// When we have moved to jQuery we won't need this anymore
|
213
|
+
if (typeof range.createContextualFragment === 'function') {
|
214
|
+
frag = range.createContextualFragment(html);
|
215
|
+
}
|
216
|
+
else {
|
217
|
+
frag = document.createDocumentFragment(),
|
218
|
+
div = document.createElement("div");
|
219
|
+
frag.appendChild(div);
|
220
|
+
div.outerHTML = html;
|
221
|
+
}
|
222
|
+
|
199
223
|
if(where == afterbegin){
|
200
224
|
el.insertBefore(frag, el.firstChild);
|
201
225
|
}else{
|
@@ -34,9 +34,9 @@
|
|
34
34
|
define(
|
35
35
|
[
|
36
36
|
'aloha/jquery',
|
37
|
-
'
|
37
|
+
'util/json2'
|
38
38
|
],
|
39
|
-
function($,
|
39
|
+
function($, __unused_json, undefined) {
|
40
40
|
|
41
41
|
/**********************************************************************************
|
42
42
|
* $.store base and convinience accessor
|
@@ -46,19 +46,6 @@ $.store = function( driver, serializers )
|
|
46
46
|
{
|
47
47
|
var JSON = window.JSON
|
48
48
|
that = this;
|
49
|
-
|
50
|
-
// IE fix
|
51
|
-
if (typeof JSON === 'undefined' || !JSON) {
|
52
|
-
/*
|
53
|
-
* The GENTICS global namespace object. If GENTICS is already defined, the
|
54
|
-
* existing GENTICS object will not be overwritten so that defined
|
55
|
-
* namespaces are preserved.
|
56
|
-
*/
|
57
|
-
var JSON = function () {
|
58
|
-
this.stringigy = function () {};
|
59
|
-
this.parse = function () {};
|
60
|
-
};
|
61
|
-
}
|
62
49
|
|
63
50
|
if( typeof driver == 'string' )
|
64
51
|
{
|
@@ -443,4 +430,41 @@ $.store.serializers = {
|
|
443
430
|
}
|
444
431
|
};
|
445
432
|
|
433
|
+
|
434
|
+
// We don't want to use window storage for ie7 with aloha because this causes massive issues when dealing with frames.
|
435
|
+
// Window.name will change the framename and this will cause links with target attribute to stop working properly.
|
436
|
+
// We remove the windowName driver and add the void driver which won't store any information.
|
437
|
+
if ( $.browser.msie && $.browser.version == "7.0" ) {
|
438
|
+
delete($.store.drivers.windowName);
|
439
|
+
var voidDriver = {
|
440
|
+
ident: "$.store.drivers.voidDriver",
|
441
|
+
scope: 'void',
|
442
|
+
cache: {},
|
443
|
+
encodes: true,
|
444
|
+
available: function()
|
445
|
+
{
|
446
|
+
return true;
|
447
|
+
},
|
448
|
+
init: function()
|
449
|
+
{
|
450
|
+
},
|
451
|
+
save: function()
|
452
|
+
{
|
453
|
+
},
|
454
|
+
get: function( key )
|
455
|
+
{
|
456
|
+
},
|
457
|
+
set: function( key, value )
|
458
|
+
{
|
459
|
+
},
|
460
|
+
del: function( key )
|
461
|
+
{
|
462
|
+
},
|
463
|
+
flush: function()
|
464
|
+
{
|
465
|
+
}
|
466
|
+
};
|
467
|
+
$.store.drivers.voidDriver=voidDriver;
|
468
|
+
}
|
469
|
+
|
446
470
|
});
|
@@ -143,6 +143,7 @@ define( [
|
|
143
143
|
Aloha.bind( 'aloha-selection-changed', function ( event, rangeObject ) {
|
144
144
|
if ( Aloha.activeEditable ) {
|
145
145
|
// show/hide the button according to the configuration
|
146
|
+
// @todo this part should be done at aloha-editable-activated event
|
146
147
|
var config = me.getEditableConfig( Aloha.activeEditable.obj );
|
147
148
|
|
148
149
|
if ( jQuery.inArray( 'abbr', config ) != -1 ) {
|
@@ -8,338 +8,348 @@
|
|
8
8
|
define(
|
9
9
|
['aloha', 'aloha/plugin', 'aloha/floatingmenu', 'i18n!align/nls/i18n', 'i18n!aloha/nls/i18n', 'aloha/jquery', 'css!align/css/align.css'],
|
10
10
|
function(Aloha, Plugin, FloatingMenu, i18n, i18nCore, jQuery) {
|
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
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
11
|
+
|
12
|
+
|
13
|
+
var
|
14
|
+
GENTICS = window.GENTICS;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* register the plugin with unique name
|
18
|
+
*/
|
19
|
+
return Plugin.create('align', {
|
20
|
+
_constructor: function(){
|
21
|
+
this._super('align');
|
22
|
+
},
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Configure the available languages
|
26
|
+
*/
|
27
|
+
languages: ['en', 'fr'],
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Configuration (available align options)
|
31
|
+
*/
|
32
|
+
config: {
|
33
|
+
alignment: ['right','left','center','justify']
|
34
|
+
},
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Alignment wanted by the user
|
38
|
+
*/
|
39
|
+
alignment: '',
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Alignment of the selection before modification
|
43
|
+
*/
|
44
|
+
lastAlignment: '',
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Initialize the plugin and set initialize flag on true
|
48
|
+
*/
|
49
|
+
init: function () {
|
50
|
+
this.createButtons();
|
51
|
+
|
52
|
+
var that = this;
|
53
|
+
|
54
|
+
// apply specific configuration if an editable has been activated
|
55
|
+
Aloha.bind('aloha-editable-activated', function (e, params) {
|
56
|
+
that.applyButtonConfig(params.editable.obj);
|
57
|
+
});
|
58
|
+
|
59
|
+
// add the event handler for selection change
|
60
|
+
Aloha.bind('aloha-selection-changed', function(event, rangeObject) {
|
61
|
+
if (Aloha.activeEditable) {
|
62
|
+
that.buttonPressed(rangeObject);
|
63
|
+
}
|
64
|
+
});
|
65
|
+
},
|
66
|
+
|
67
|
+
buttonPressed: function (rangeObject) {
|
68
|
+
|
69
|
+
var that = this;
|
70
|
+
|
71
|
+
rangeObject.findMarkup(function() {
|
72
|
+
that.alignment = jQuery(this).css('text-align');
|
73
|
+
}, Aloha.activeEditable.obj);
|
74
|
+
|
75
|
+
if(this.alignment != this.lastAlignment)
|
76
|
+
{
|
77
|
+
switch(this.lastAlignment)
|
78
|
+
{
|
79
|
+
case 'right':
|
80
|
+
this.alignRightButton.setPressed(false);
|
81
|
+
break;
|
82
|
+
|
83
|
+
case 'left':
|
84
|
+
this.alignLeftButton.setPressed(false);
|
85
|
+
break;
|
86
|
+
|
87
|
+
case 'center':
|
88
|
+
this.alignCenterButton.setPressed(false);
|
89
|
+
break;
|
90
|
+
|
91
|
+
case 'justify':
|
92
|
+
this.alignJustifyButton.setPressed(false);
|
93
|
+
break;
|
94
|
+
}
|
95
|
+
|
96
|
+
switch(this.alignment)
|
97
|
+
{
|
98
|
+
case 'right':
|
99
|
+
this.alignRightButton.setPressed(true);
|
100
|
+
break;
|
101
|
+
|
102
|
+
case 'center':
|
103
|
+
this.alignCenterButton.setPressed(true);
|
104
|
+
break;
|
105
|
+
|
106
|
+
case 'justify':
|
107
|
+
this.alignJustifyButton.setPressed(true);
|
108
|
+
break;
|
109
|
+
|
110
|
+
default:
|
111
|
+
this.alignLeftButton.setPressed(true);
|
112
|
+
this.alignment = 'left';
|
113
|
+
break;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
this.lastAlignment = this.alignment;
|
118
|
+
},
|
119
|
+
|
120
|
+
/**
|
121
|
+
* applys a configuration specific for an editable
|
122
|
+
* buttons not available in this configuration are hidden
|
123
|
+
* @param {Object} id of the activated editable
|
124
|
+
* @return void
|
125
|
+
*/
|
126
|
+
applyButtonConfig: function (obj) {
|
127
|
+
|
128
|
+
if (typeof this.settings.alignment === 'undefined') {
|
129
|
+
var config = this.config.alignment;
|
130
|
+
} else {
|
131
|
+
var config = this.settings.alignment;
|
132
|
+
}
|
133
|
+
|
134
|
+
if ( jQuery.inArray('right', config) != -1) {
|
135
|
+
this.alignRightButton.show();
|
136
|
+
} else {
|
137
|
+
this.alignRightButton.hide();
|
138
|
+
}
|
139
|
+
|
140
|
+
if ( jQuery.inArray('left', config) != -1) {
|
141
|
+
this.alignLeftButton.show();
|
142
|
+
} else {
|
143
|
+
this.alignLeftButton.hide();
|
144
|
+
}
|
145
|
+
|
146
|
+
if ( jQuery.inArray('center', config) != -1) {
|
147
|
+
this.alignCenterButton.show();
|
148
|
+
} else {
|
149
|
+
this.alignCenterButton.hide();
|
150
|
+
}
|
151
|
+
|
152
|
+
if ( jQuery.inArray('justify', config) != -1) {
|
153
|
+
this.alignJustifyButton.show();
|
154
|
+
} else {
|
155
|
+
this.alignJustifyButton.hide();
|
156
|
+
}
|
157
|
+
},
|
158
|
+
|
159
|
+
createButtons: function () {
|
160
|
+
var that = this;
|
161
|
+
|
162
|
+
// create a new button
|
163
|
+
this.alignLeftButton = new Aloha.ui.Button({
|
164
|
+
'name' : 'alignLeft',
|
165
|
+
'iconClass' : 'aloha-button-align aloha-button-align-left',
|
166
|
+
'size' : 'small',
|
167
|
+
'onclick' : function () { that.align('left'); },
|
168
|
+
'tooltip' : i18n.t('button.alignleft.tooltip'),
|
169
|
+
'toggle' : true
|
170
|
+
});
|
171
|
+
|
172
|
+
// add it to the floating menu
|
173
|
+
FloatingMenu.addButton(
|
174
|
+
'Aloha.continuoustext',
|
175
|
+
this.alignLeftButton,
|
176
|
+
i18nCore.t('floatingmenu.tab.format'),
|
177
|
+
1
|
178
|
+
);
|
179
|
+
|
180
|
+
// create a new button
|
181
|
+
this.alignCenterButton = new Aloha.ui.Button({
|
182
|
+
'name' : 'alignCenter',
|
183
|
+
'iconClass' : 'aloha-button-align aloha-button-align-center',
|
184
|
+
'size' : 'small',
|
185
|
+
'onclick' : function () { that.align('center'); },
|
186
|
+
'tooltip' : i18n.t('button.aligncenter.tooltip'),
|
187
|
+
'toggle' : true
|
188
|
+
});
|
189
|
+
|
190
|
+
// add it to the floating menu
|
191
|
+
FloatingMenu.addButton(
|
192
|
+
'Aloha.continuoustext',
|
193
|
+
this.alignCenterButton,
|
194
|
+
i18nCore.t('floatingmenu.tab.format'),
|
195
|
+
1
|
196
|
+
);
|
197
|
+
|
198
|
+
// create a new button
|
199
|
+
this.alignRightButton = new Aloha.ui.Button({
|
200
|
+
'name' : 'alignRight',
|
201
|
+
'iconClass' : 'aloha-button-align aloha-button-align-right',
|
202
|
+
'size' : 'small',
|
203
|
+
'onclick' : function () { that.align('right'); },
|
204
|
+
'tooltip' : i18n.t('button.alignright.tooltip'),
|
205
|
+
'toggle' : true
|
206
|
+
});
|
207
|
+
|
208
|
+
// add it to the floating menu
|
209
|
+
FloatingMenu.addButton(
|
210
|
+
'Aloha.continuoustext',
|
211
|
+
this.alignRightButton,
|
212
|
+
i18nCore.t('floatingmenu.tab.format'),
|
213
|
+
1
|
214
|
+
);
|
215
|
+
|
216
|
+
// create a new button
|
217
|
+
this.alignJustifyButton = new Aloha.ui.Button({
|
218
|
+
'name' : 'alignJustify',
|
219
|
+
'iconClass' : 'aloha-button-align aloha-button-align-justify',
|
220
|
+
'size' : 'small',
|
221
|
+
'onclick' : function () { that.align('justify'); },
|
222
|
+
'tooltip' : i18n.t('button.alignjustify.tooltip'),
|
223
|
+
'toggle' : true
|
224
|
+
});
|
225
|
+
|
226
|
+
// add it to the floating menu
|
227
|
+
FloatingMenu.addButton(
|
228
|
+
'Aloha.continuoustext',
|
229
|
+
this.alignJustifyButton,
|
230
|
+
i18nCore.t('floatingmenu.tab.format'),
|
231
|
+
1
|
232
|
+
);
|
233
|
+
|
234
|
+
},
|
235
|
+
|
236
|
+
/**
|
237
|
+
* Check whether inside a align tag
|
238
|
+
* @param {GENTICS.Utils.RangeObject} range range where to insert the object (at start or end)
|
239
|
+
* @return markup
|
240
|
+
* @hide
|
241
|
+
*/
|
242
|
+
findAlignMarkup: function ( range ) {
|
243
|
+
|
244
|
+
var that = this;
|
245
|
+
|
246
|
+
if ( typeof range === 'undefined' ) {
|
247
|
+
var range = Aloha.Selection.getRangeObject();
|
248
|
+
}
|
249
|
+
if ( Aloha.activeEditable ) {
|
250
|
+
return range.findMarkup(function() {
|
251
|
+
return jQuery(this).css('text-align') == that.alignment;
|
252
|
+
}, Aloha.activeEditable.obj);
|
253
|
+
} else {
|
254
|
+
return null;
|
255
|
+
}
|
256
|
+
},
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Align the selection or remove it
|
260
|
+
*/
|
261
|
+
align: function ( tempAlignment ) {
|
262
|
+
|
263
|
+
var range = Aloha.Selection.getRangeObject();
|
264
|
+
|
265
|
+
this.lastAlignment = this.alignment;
|
266
|
+
this.alignment = tempAlignment;
|
267
|
+
|
268
|
+
if (Aloha.activeEditable) {
|
269
|
+
if ( this.findAlignMarkup( range ) ) {
|
270
|
+
this.removeAlign();
|
271
|
+
} else {
|
272
|
+
this.insertAlign();
|
273
|
+
}
|
274
|
+
}
|
275
|
+
},
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Align the selection
|
279
|
+
*/
|
280
|
+
insertAlign: function () {
|
281
|
+
|
282
|
+
var that = this;
|
283
|
+
|
284
|
+
// do not align the range
|
285
|
+
if ( this.findAlignMarkup( range ) ) {
|
286
|
+
return;
|
287
|
+
}
|
288
|
+
// current selection or cursor position
|
289
|
+
var range = Aloha.Selection.getRangeObject();
|
290
|
+
|
291
|
+
// Iterates the whole selectionTree and align
|
292
|
+
jQuery.each(Aloha.Selection.getRangeObject().getSelectionTree(), function () {
|
293
|
+
if(this.selection !== 'none' && this.domobj.nodeType !== 3) {
|
294
|
+
jQuery(this.domobj).css('text-align', that.alignment);
|
295
|
+
}
|
296
|
+
});
|
297
|
+
|
298
|
+
// FIXME: https://github.com/alohaeditor/Aloha-Editor/pull/362
|
299
|
+
if (!GENTICS.Utils.Dom.isEditingHost(range.getCommonAncestorContainer()))
|
300
|
+
jQuery(range.getCommonAncestorContainer()).css('text-align', this.alignment);
|
301
|
+
else
|
302
|
+
jQuery.each(Aloha.Selection.getRangeObject().getSelectionTree(), function () {
|
303
|
+
if(this.selection !== 'none' && this.domobj.nodeType !== 3) {
|
304
|
+
jQuery(this.domobj).css('text-align', that.alignment);
|
305
|
+
}
|
306
|
+
});
|
307
|
+
|
308
|
+
if(this.alignment != this.lastAlignment)
|
309
|
+
{
|
310
|
+
switch(this.lastAlignment)
|
311
|
+
{
|
312
|
+
case 'right':
|
313
|
+
this.alignRightButton.setPressed(false);
|
314
|
+
break;
|
315
|
+
|
316
|
+
case 'left':
|
317
|
+
this.alignLeftButton.setPressed(false);
|
318
|
+
break;
|
319
|
+
|
320
|
+
case 'center':
|
321
|
+
this.alignCenterButton.setPressed(false);
|
322
|
+
break;
|
323
|
+
|
324
|
+
case 'justify':
|
325
|
+
this.alignJustifyButton.setPressed(false);
|
326
|
+
break;
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
// select the (possibly modified) range
|
331
|
+
range.select();
|
332
|
+
},
|
333
|
+
|
334
|
+
/**
|
335
|
+
* Remove the alignment
|
336
|
+
*/
|
337
|
+
removeAlign: function () {
|
338
|
+
|
339
|
+
var range = Aloha.Selection.getRangeObject();
|
340
|
+
|
341
|
+
if ( this.findAlignMarkup( range ) ) {
|
342
|
+
|
343
|
+
// Remove the alignment
|
344
|
+
range.findMarkup(function() {
|
345
|
+
jQuery(this).css('text-align', '');
|
346
|
+
}, Aloha.activeEditable.obj);
|
347
|
+
|
348
|
+
// select the (possibly modified) range
|
349
|
+
range.select();
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
353
|
+
});
|
354
|
+
|
345
355
|
});
|