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.
- data/README.md +3 -3
- data/lib/aloha/rails/engine.rb +1 -1
- data/lib/aloha/rails/version.rb +2 -2
- data/lib/tasks/aloha-assets.rake +1 -1
- data/vendor/assets/javascripts/aloha/css/aloha-sidebar.css +41 -17
- data/vendor/assets/javascripts/aloha/css/aloha.css +2 -2
- data/vendor/assets/javascripts/aloha/lib/aloha/contenthandlermanager.js +19 -18
- data/vendor/assets/javascripts/aloha/lib/aloha/engine.js +168 -9
- data/vendor/assets/javascripts/aloha/lib/aloha/ephemera.js +8 -1
- data/vendor/assets/javascripts/aloha/lib/aloha/markup.js +3 -2
- data/vendor/assets/javascripts/aloha/lib/aloha/pluginmanager.js +8 -0
- data/vendor/assets/javascripts/aloha/lib/aloha/sidebar.js +1 -1
- data/vendor/assets/javascripts/aloha/lib/aloha/state-override.js +59 -37
- data/vendor/assets/javascripts/aloha/lib/util/arrays.js +53 -6
- data/vendor/assets/javascripts/aloha/lib/util/boundary-markers.js +86 -0
- data/vendor/assets/javascripts/aloha/lib/util/dom2.js +178 -19
- data/vendor/assets/javascripts/aloha/lib/util/html.js +77 -10
- data/vendor/assets/javascripts/aloha/lib/util/maps.js +23 -1
- data/vendor/assets/javascripts/aloha/lib/util/range-context.js +429 -181
- data/vendor/assets/javascripts/aloha/lib/util/strings.js +9 -1
- data/vendor/assets/javascripts/aloha/plugins/common/align/nls/de/i18n.js +4 -1
- data/vendor/assets/javascripts/aloha/plugins/common/block/lib/blockmanager.js +2 -5
- data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/css/characterpicker.css +6 -3
- data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/lib/characterpicker-plugin.js +29 -32
- data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/blockelementcontenthandler.js +41 -70
- data/vendor/assets/javascripts/aloha/plugins/common/dom-to-xhtml/lib/dom-to-xhtml.js +1 -1
- data/vendor/assets/javascripts/aloha/plugins/common/format/lib/format-plugin.js +22 -10
- data/vendor/assets/javascripts/aloha/plugins/common/link/css/link.css +2 -8
- data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-cell.js +7 -0
- data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-plugin.js +149 -131
- data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table.js +77 -47
- data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/port-helper-attribute-field.js +4 -8
- data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/de/i18n.js +1 -0
- data/vendor/assets/javascripts/aloha/plugins/extra/cite/css/cite.css +0 -10
- data/vendor/assets/javascripts/aloha/plugins/extra/cite/lib/cite-plugin.js +4 -4
- data/vendor/assets/javascripts/aloha/plugins/extra/headerids/lib/headerids-plugin.js +84 -32
- data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/de/i18n.js +2 -1
- data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/i18n.js +2 -1
- metadata +15 -14
@@ -42,14 +42,8 @@
|
|
42
42
|
padding-bottom: 5px;
|
43
43
|
}
|
44
44
|
|
45
|
-
.aloha-link-title-container fieldset
|
46
|
-
width:
|
47
|
-
min-width:180px;
|
48
|
-
}
|
49
|
-
|
50
|
-
.aloha-link-target-container fieldset input[type=text]{
|
51
|
-
width:auto !important;
|
52
|
-
min-width:180px;
|
45
|
+
.aloha-link-target-container fieldset input[type=text], .aloha-link-title-container fieldset input[type=text] {
|
46
|
+
width: 90%;
|
53
47
|
}
|
54
48
|
|
55
49
|
.x-form-field.x-form-text.aloha-link-href-field {
|
@@ -62,6 +62,13 @@ function (jQuery, Utils) {
|
|
62
62
|
|
63
63
|
// attach events to the editable div-object
|
64
64
|
$wrapper.bind('focus', function ($event) {
|
65
|
+
// activate the button for splitting cells if the clicked cell has an active row- or colspan
|
66
|
+
if (Utils.colspan(cell.obj) > 1 || Utils.rowspan(cell.obj) > 1) {
|
67
|
+
cell.tableObj.tablePlugin._splitcellsButton.enable(true);
|
68
|
+
} else {
|
69
|
+
cell.tableObj.tablePlugin._splitcellsButton.enable(false);
|
70
|
+
}
|
71
|
+
|
65
72
|
// ugly workaround for ext-js-adapter problem in
|
66
73
|
// ext-jquery-adapter-debug.js:1020
|
67
74
|
if ($event.currentTarget) {
|
@@ -229,6 +229,96 @@ define([
|
|
229
229
|
return null;
|
230
230
|
}
|
231
231
|
|
232
|
+
/**
|
233
|
+
* Sets the currently selected elements as headers of the table, or removes header-status
|
234
|
+
* if the whole selection is already used as a header
|
235
|
+
*
|
236
|
+
* @param {Aloha.Table} table the table-object for which the headers are to be set
|
237
|
+
* @param {string} scope for which the header should be used (i.e. 'row' or 'column')
|
238
|
+
*/
|
239
|
+
function toggleHeaderStatus(table, scope) {
|
240
|
+
var i,
|
241
|
+
j,
|
242
|
+
allHeaders = table.selection.isHeader(),
|
243
|
+
domCell, // representation of the cell in the dom
|
244
|
+
tableCell, // table-cell object
|
245
|
+
bufferCell; // temporary buffer
|
246
|
+
|
247
|
+
for (i = 0; i < table.selection.selectedCells.length; i++) {
|
248
|
+
domCell = table.selection.selectedCells[i];
|
249
|
+
|
250
|
+
// tries to match the current cell with a cell-object in the table
|
251
|
+
for (j = 0; j < table.cells.length; j++) {
|
252
|
+
if (domCell === table.cells[j].obj[0]) {
|
253
|
+
cell = table.cells[j];
|
254
|
+
break;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
// the transformed dom objects are first stored in a buffer, and only applied to
|
259
|
+
// the table-cell-object if a match was found
|
260
|
+
if (allHeaders) {
|
261
|
+
bufferCell = Aloha.Markup.transformDomObject(domCell, 'td').removeAttr('scope').get(0);
|
262
|
+
} else {
|
263
|
+
bufferCell = Aloha.Markup.transformDomObject(domCell, 'th').attr('scope', scope).get(0);
|
264
|
+
}
|
265
|
+
|
266
|
+
if (cell != null) {
|
267
|
+
// assign the changed dom-element to the table-cell
|
268
|
+
cell.obj[0] = bufferCell;
|
269
|
+
|
270
|
+
// reactivate the table cell in order to bind events to the changed dom object
|
271
|
+
// TODO: re-attaching event-handlers should be factored out into a utility function
|
272
|
+
// so we don't have to do the whole activation/deactivation process for the cells
|
273
|
+
cell.deactivate();
|
274
|
+
cell.activate();
|
275
|
+
}
|
276
|
+
|
277
|
+
// uncommented code-segment, presumably added to force IE to target the wrapper
|
278
|
+
// on mouse-down by applying a timeout after event propagation
|
279
|
+
jQuery(table.selection.selectedCells[i]).bind('mousedown', function (jqEvent) {
|
280
|
+
var wrapper = jQuery(this).children('div').eq(0);
|
281
|
+
window.setTimeout(function () {
|
282
|
+
wrapper.trigger( 'focus' );
|
283
|
+
}, 1);
|
284
|
+
});
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
/**
|
289
|
+
* If the specified style is not already active in all selected cells, it is applied;
|
290
|
+
* otherwise, it is removed from the cells
|
291
|
+
*
|
292
|
+
* @param {Array} config defined styles as defined in the configuration
|
293
|
+
* @param {String} cssClass
|
294
|
+
* @param {Array} sc the selection of target table cells
|
295
|
+
*/
|
296
|
+
function applyStyle(config, cssClass, sc) {
|
297
|
+
var appliedToAll = true;
|
298
|
+
|
299
|
+
for (var i = 0; i < sc.length; i++) {
|
300
|
+
if (jQuery(sc[i]).attr('class').indexOf(cssClass) < 0 ) {
|
301
|
+
appliedToAll = false;
|
302
|
+
break;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
if (!appliedToAll) {
|
307
|
+
for (var i = 0; i < sc.length; i++) {
|
308
|
+
jQuery(sc[i]).addClass(cssClass);
|
309
|
+
for (var f = 0; f < config.length; f++) {
|
310
|
+
if (config[f].cssClass != cssClass) {
|
311
|
+
jQuery(sc[i]).removeClass(config[f].cssClass);
|
312
|
+
}
|
313
|
+
}
|
314
|
+
}
|
315
|
+
} else {
|
316
|
+
for (var i = 0; i < sc.length; i++) {
|
317
|
+
jQuery(sc[i]).removeClass(cssClass);
|
318
|
+
}
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
232
322
|
/**
|
233
323
|
* Init method of the Table-plugin transforms all tables in the document
|
234
324
|
*
|
@@ -551,8 +641,20 @@ define([
|
|
551
641
|
icon: "aloha-icon aloha-icon-splitcells",
|
552
642
|
scope: this.name + '.cell',
|
553
643
|
click: function() {
|
644
|
+
var activeCell;
|
554
645
|
if (TablePlugin.activeTable) {
|
555
|
-
TablePlugin.activeTable.selection.
|
646
|
+
if (TablePlugin.activeTable.selection.selectedCells.length > 0) {
|
647
|
+
TablePlugin.activeTable.selection.splitCells();
|
648
|
+
} else {
|
649
|
+
// if there is currently no selection, the active cell is split instead
|
650
|
+
activeCell = TablePlugin.selectedOrActiveCells();
|
651
|
+
if (activeCell.length > 0) {
|
652
|
+
Utils.splitCell(activeCell, function () {
|
653
|
+
return TablePlugin.activeTable.newActiveCell().obj;
|
654
|
+
});
|
655
|
+
Aloha.trigger('aloha-table-selection-changed');
|
656
|
+
}
|
657
|
+
}
|
556
658
|
}
|
557
659
|
}
|
558
660
|
});
|
@@ -613,7 +715,7 @@ define([
|
|
613
715
|
click: function() {
|
614
716
|
if (that.activeTable) {
|
615
717
|
var tableObj = that.activeTable.obj;
|
616
|
-
tableObj.find('td').each(function() {
|
718
|
+
tableObj.find('td, th').each(function() {
|
617
719
|
jQuery(this).find('div').css('width', '');
|
618
720
|
jQuery(this).css('width', '');
|
619
721
|
});
|
@@ -678,44 +780,12 @@ define([
|
|
678
780
|
scope: this.name + '.row',
|
679
781
|
click: function() {
|
680
782
|
if (that.activeTable) {
|
681
|
-
|
682
|
-
cell,
|
683
|
-
isHeader = that.activeTable.selection.isHeader(),
|
684
|
-
allHeaders = true; // flag for header check
|
685
|
-
|
686
|
-
// loop through selected cells, determine if any are not already headers
|
687
|
-
for (var j = 0; j < that.activeTable.selection.selectedCells.length; j++) {
|
688
|
-
cell = that.activeTable.selection.selectedCells[j];
|
689
|
-
if ( !isHeader ) {
|
690
|
-
allHeaders = false;
|
691
|
-
break;
|
692
|
-
}
|
693
|
-
}
|
694
|
-
|
695
|
-
// updated selected cells
|
696
|
-
for (var j = 0; j < that.activeTable.selection.selectedCells.length; j++) {
|
697
|
-
cell = that.activeTable.selection.selectedCells[j];
|
698
|
-
if ( allHeaders ) {
|
699
|
-
cell = Aloha.Markup.transformDomObject( cell, 'td' ).removeAttr( 'scope' ).get(0);
|
700
|
-
} else {
|
701
|
-
cell = Aloha.Markup.transformDomObject( cell, 'th' ).attr( 'scope', 'col' ).get(0);
|
702
|
-
}
|
783
|
+
that.activeTable.refresh();
|
703
784
|
|
704
|
-
|
705
|
-
var wrapper = jQuery(this).children('div').eq(0);
|
706
|
-
// lovely IE ;-)
|
707
|
-
window.setTimeout(function () {
|
708
|
-
wrapper.trigger( 'focus' );
|
709
|
-
}, 1);
|
710
|
-
// unselect cells
|
711
|
-
});
|
785
|
+
toggleHeaderStatus(that.activeTable, 'column');
|
712
786
|
|
713
|
-
}
|
714
|
-
|
715
|
-
// select the row
|
716
|
-
that.activeTable.refresh();
|
717
787
|
that.activeTable.selection.unselectCells();
|
718
|
-
that.activeTable.selection.selectRows(
|
788
|
+
that.activeTable.selection.selectRows(that.activeTable.selection.selectedRowIdxs);
|
719
789
|
}
|
720
790
|
}
|
721
791
|
});
|
@@ -730,22 +800,8 @@ define([
|
|
730
800
|
iconClass: 'aloha-icon aloha-row-layout ' + itemConf.iconClass,
|
731
801
|
click: function () {
|
732
802
|
if (that.activeTable) {
|
733
|
-
|
734
|
-
// if a selection was made, transform the selected cells
|
735
|
-
for (var i = 0; i < sc.length; i++) {
|
736
|
-
if ( jQuery(sc[i]).attr('class').indexOf(itemConf.cssClass) > -1 ) {
|
737
|
-
jQuery(sc[i]).removeClass(itemConf.cssClass);
|
738
|
-
} else {
|
739
|
-
jQuery(sc[i]).addClass(itemConf.cssClass);
|
740
|
-
// remove all row formattings
|
741
|
-
for (var f = 0; f < that.rowConfig.length; f++) {
|
742
|
-
if (that.rowConfig[f].cssClass != itemConf.cssClass) {
|
743
|
-
jQuery(sc[i]).removeClass(that.rowConfig[f].cssClass);
|
744
|
-
}
|
745
|
-
}
|
803
|
+
applyStyle(that.rowConfig, itemConf.cssClass, that.activeTable.selection.selectedCells);
|
746
804
|
|
747
|
-
}
|
748
|
-
}
|
749
805
|
// selection could have changed.
|
750
806
|
that.activeTable.selectRows();
|
751
807
|
}
|
@@ -772,7 +828,7 @@ define([
|
|
772
828
|
// selection could have changed.
|
773
829
|
that.activeTable.selectRows();
|
774
830
|
}
|
775
|
-
|
831
|
+
}
|
776
832
|
});
|
777
833
|
}
|
778
834
|
|
@@ -830,51 +886,18 @@ define([
|
|
830
886
|
}
|
831
887
|
});
|
832
888
|
|
833
|
-
|
889
|
+
this._columnheaderButton = Ui.adopt("columnheader", ToggleButton, {
|
834
890
|
tooltip: i18n.t("button.columnheader.tooltip"),
|
835
891
|
icon: "aloha-icon aloha-icon-columnheader",
|
836
892
|
scope: this.name + '.column',
|
837
893
|
click: function() {
|
838
894
|
if (that.activeTable) {
|
839
|
-
|
840
|
-
selectedColumnIdxs = that.activeTable.selection.selectedColumnIdxs,
|
841
|
-
cell,
|
842
|
-
isHeader = that.activeTable.selection.isHeader(),
|
843
|
-
allHeaders = true; // flag for header check
|
844
|
-
|
845
|
-
// loop through selected cells, determine if any are not already headers
|
846
|
-
for (var j = 0; j < that.activeTable.selection.selectedCells.length; j++) {
|
847
|
-
cell = that.activeTable.selection.selectedCells[j];
|
848
|
-
if ( !isHeader ) {
|
849
|
-
allHeaders = false;
|
850
|
-
break;
|
851
|
-
}
|
852
|
-
}
|
853
|
-
|
854
|
-
// updated selected cells
|
855
|
-
for (var j = 0; j < that.activeTable.selection.selectedCells.length; j++) {
|
856
|
-
cell = that.activeTable.selection.selectedCells[j];
|
857
|
-
if ( allHeaders ) {
|
858
|
-
cell = Aloha.Markup.transformDomObject( cell, 'td' ).removeAttr( 'scope' ).get(0);
|
859
|
-
} else {
|
860
|
-
cell = Aloha.Markup.transformDomObject( cell, 'th' ).attr( 'scope', 'row' ).get(0);
|
861
|
-
}
|
862
|
-
|
863
|
-
jQuery( that.activeTable.selection.selectedCells[j] ).bind( 'mousedown', function ( jqEvent ) {
|
864
|
-
var wrapper = jQuery(this).children('div').eq(0);
|
865
|
-
// lovely IE ;-)
|
866
|
-
window.setTimeout(function () {
|
867
|
-
wrapper.trigger( 'focus' );
|
868
|
-
}, 1);
|
869
|
-
// unselect cells
|
870
|
-
});
|
895
|
+
that.activeTable.refresh();
|
871
896
|
|
872
|
-
|
897
|
+
toggleHeaderStatus(that.activeTable, 'row');
|
873
898
|
|
874
|
-
// select the column
|
875
|
-
that.activeTable.refresh();
|
876
899
|
that.activeTable.selection.unselectCells();
|
877
|
-
that.activeTable.selection.selectColumns(
|
900
|
+
that.activeTable.selection.selectColumns(that.activeTable.selection.selectedColumnIdxs);
|
878
901
|
}
|
879
902
|
}
|
880
903
|
});
|
@@ -889,21 +912,8 @@ define([
|
|
889
912
|
iconClass : 'aloha-icon aloha-column-layout ' + itemConf.iconClass,
|
890
913
|
click : function (x,y,z) {
|
891
914
|
if (that.activeTable) {
|
892
|
-
|
893
|
-
|
894
|
-
for (var i = 0; i < sc.length; i++) {
|
895
|
-
if ( jQuery(sc[i]).attr('class').indexOf(itemConf.cssClass) > -1 ) {
|
896
|
-
jQuery(sc[i]).removeClass(itemConf.cssClass);
|
897
|
-
} else {
|
898
|
-
jQuery(sc[i]).addClass(itemConf.cssClass);
|
899
|
-
// remove all column formattings
|
900
|
-
for (var f = 0; f < that.columnConfig.length; f++) {
|
901
|
-
if (that.columnConfig[f].cssClass != itemConf.cssClass) {
|
902
|
-
jQuery(sc[i]).removeClass(that.columnConfig[f].cssClass);
|
903
|
-
}
|
904
|
-
}
|
905
|
-
}
|
906
|
-
}
|
915
|
+
applyStyle(that.columnConfig, itemConf.cssClass, that.activeTable.selection.selectedCells);
|
916
|
+
|
907
917
|
// selection could have changed.
|
908
918
|
that.activeTable.selectColumns();
|
909
919
|
}
|
@@ -960,22 +970,7 @@ define([
|
|
960
970
|
iconClass : 'aloha-icon aloha-column-layout ' + itemConf.iconClass,
|
961
971
|
click : function (x,y,z) {
|
962
972
|
if (that.activeTable) {
|
963
|
-
|
964
|
-
|
965
|
-
// if a selection was made, transform the selected cells
|
966
|
-
for (var i = 0; i < sc.length; i++) {
|
967
|
-
if ( jQuery(sc[i]).attr('class').indexOf(itemConf.cssClass) > -1 ) {
|
968
|
-
jQuery(sc[i]).removeClass(itemConf.cssClass);
|
969
|
-
} else {
|
970
|
-
jQuery(sc[i]).addClass(itemConf.cssClass);
|
971
|
-
// remove all column formattings
|
972
|
-
for (var f = 0; f < that.cellConfig.length; f++) {
|
973
|
-
if (that.cellConfig[f].cssClass != itemConf.cssClass) {
|
974
|
-
jQuery(sc[i]).removeClass(that.cellConfig[f].cssClass);
|
975
|
-
}
|
976
|
-
}
|
977
|
-
}
|
978
|
-
}
|
973
|
+
applyStyle(that.cellConfig, itemConf.cssClass, that.selectedOrActiveCells());
|
979
974
|
|
980
975
|
that.setActiveCellStyle();
|
981
976
|
}
|
@@ -1066,10 +1061,18 @@ define([
|
|
1066
1061
|
click: function(){
|
1067
1062
|
// set table css class
|
1068
1063
|
if (that.activeTable) {
|
1069
|
-
|
1070
|
-
|
1064
|
+
if (!that.activeTable.obj.hasClass(itemConf.cssClass)) {
|
1065
|
+
for (var f = 0; f < tableConfig.length; f++) {
|
1066
|
+
that.activeTable.obj.removeClass(tableConfig[f].cssClass);
|
1067
|
+
}
|
1068
|
+
that.activeTable.obj.addClass(itemConf.cssClass);
|
1069
|
+
that.tableMSButton.setActiveItem(itemConf.cssClass);
|
1070
|
+
} else {
|
1071
|
+
for (var f = 0; f < tableConfig.length; f++) {
|
1072
|
+
that.activeTable.obj.removeClass(tableConfig[f].cssClass);
|
1073
|
+
}
|
1074
|
+
that.tableMSButton.setActiveItem();
|
1071
1075
|
}
|
1072
|
-
that.activeTable.obj.addClass(itemConf.cssClass);
|
1073
1076
|
}
|
1074
1077
|
}
|
1075
1078
|
});
|
@@ -1088,6 +1091,7 @@ define([
|
|
1088
1091
|
for (var f = 0; f < tableConfig.length; f++) {
|
1089
1092
|
that.activeTable.obj.removeClass(that.tableConfig[f].cssClass);
|
1090
1093
|
}
|
1094
|
+
that.tableMSButton.setActiveItem();
|
1091
1095
|
}
|
1092
1096
|
}
|
1093
1097
|
});
|
@@ -1437,23 +1441,37 @@ define([
|
|
1437
1441
|
}
|
1438
1442
|
};
|
1439
1443
|
|
1444
|
+
/**
|
1445
|
+
* Set the cell-style to match the active item, if all selected cells have the same style
|
1446
|
+
* TODO: Algorithm very similar to setActiveStyle in table.js, should be refactored
|
1447
|
+
*/
|
1440
1448
|
TablePlugin.setActiveCellStyle = function() {
|
1441
1449
|
var that = this;
|
1450
|
+
var allSelected = false;
|
1451
|
+
var className;
|
1442
1452
|
|
1443
1453
|
// reset any selected cell styles
|
1444
1454
|
this.cellMSButton.setActiveItem();
|
1445
1455
|
|
1446
1456
|
var selectedCells = that.selectedOrActiveCells();
|
1447
1457
|
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
}
|
1458
|
+
for (var i = 0; i < that.cellConfig.length; i++) {
|
1459
|
+
if (jQuery(selectedCells[0]).hasClass(that.cellConfig[i].cssClass) ) {
|
1460
|
+
className = that.cellConfig[i].name;
|
1461
|
+
allSelected = true;
|
1462
|
+
break;
|
1454
1463
|
}
|
1455
|
-
}
|
1464
|
+
}
|
1456
1465
|
|
1466
|
+
// if all selected cells have the same class, set it as active
|
1467
|
+
jQuery(selectedCells).each(function(index) {
|
1468
|
+
if (!jQuery(this).hasClass(className)) {
|
1469
|
+
allSelected = false;
|
1470
|
+
}
|
1471
|
+
});
|
1472
|
+
if (allSelected) {
|
1473
|
+
this.cellMSButton.setActiveItem(className);
|
1474
|
+
}
|
1457
1475
|
};
|
1458
1476
|
|
1459
1477
|
TablePlugin.selectedOrActiveCells = function() {
|
@@ -195,6 +195,7 @@ define([
|
|
195
195
|
var table = tableObj.obj,
|
196
196
|
|
197
197
|
i,
|
198
|
+
j,
|
198
199
|
row,
|
199
200
|
rows = tableObj.getRows(),
|
200
201
|
rowsNum = rows.length,
|
@@ -204,7 +205,7 @@ define([
|
|
204
205
|
|
205
206
|
colsCount,
|
206
207
|
maxColsCount = 0,
|
207
|
-
cachedColsCounts = [],
|
208
|
+
cachedColsCounts = [rowsNum],
|
208
209
|
colsCountDiff,
|
209
210
|
colSpan;
|
210
211
|
|
@@ -236,10 +237,23 @@ define([
|
|
236
237
|
colsCount += ( colSpan - 1 );
|
237
238
|
}
|
238
239
|
|
239
|
-
|
240
|
+
// if a rowspan is set in the last element of the row, the row(s) below
|
241
|
+
// are supposed to have one less column for every colspan the element has
|
242
|
+
rowSpan = parseInt(cols.last().attr('rowspan'), 10);
|
243
|
+
if (rowSpan > 1) {
|
244
|
+
for (j = 1; j < rowSpan-1; j++) {
|
245
|
+
if (colSpan > 1) {
|
246
|
+
cachedColsCounts[i+j] += colSpan;
|
247
|
+
} else {
|
248
|
+
cachedColsCounts[i+j] += 1;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
cachedColsCounts[i] += colsCount;
|
240
254
|
|
241
|
-
if (
|
242
|
-
maxColsCount =
|
255
|
+
if (cachedColsCounts[i] > maxColsCount) {
|
256
|
+
maxColsCount = cachedColsCounts[i];
|
243
257
|
}
|
244
258
|
}
|
245
259
|
|
@@ -254,6 +268,49 @@ define([
|
|
254
268
|
}
|
255
269
|
};
|
256
270
|
|
271
|
+
/**
|
272
|
+
* If all of the selected cells have been set to the same predefined style,
|
273
|
+
* then its style-button is toggled on. Otherwise, all style-buttons are toggled off.
|
274
|
+
*
|
275
|
+
* @param selectedCells the cells to be checked
|
276
|
+
* @param config the list of styles as defined in the aloha-configuration
|
277
|
+
* @param items the multisplit-toggle-items
|
278
|
+
* @param button a multisplit-button
|
279
|
+
*
|
280
|
+
* @return void
|
281
|
+
*/
|
282
|
+
function setActiveStyle(selectedCells, config, items, button) {
|
283
|
+
var className;
|
284
|
+
var allSelected = false;
|
285
|
+
|
286
|
+
// activate all formatting buttons
|
287
|
+
for (var i = 0; i < items.length; i++) {
|
288
|
+
button.showItem(items[i].name);
|
289
|
+
}
|
290
|
+
|
291
|
+
// clear active style block
|
292
|
+
button.setActiveItem();
|
293
|
+
|
294
|
+
// select class of first element as reference
|
295
|
+
for (var i = 0; i < config.length; i++) {
|
296
|
+
if (jQuery(selectedCells[0]).hasClass(config[i].cssClass)) {
|
297
|
+
allSelected = true;
|
298
|
+
className = config[i].name;
|
299
|
+
break;
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
// if all selected cells have the same class, set it as active
|
304
|
+
jQuery(selectedCells).each(function(index) {
|
305
|
+
if (!jQuery(this).hasClass(className)) {
|
306
|
+
allSelected = false;
|
307
|
+
}
|
308
|
+
});
|
309
|
+
if (allSelected) {
|
310
|
+
button.setActiveItem(className);
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
257
314
|
/**
|
258
315
|
* Transforms the existing dom-table into an editable aloha-table. In fact it
|
259
316
|
* replaces the td-elements with equivalent TableCell-elements
|
@@ -1416,40 +1473,26 @@ define([
|
|
1416
1473
|
Table.prototype.selectColumns = function ( columns ) {
|
1417
1474
|
var columnsToSelect;
|
1418
1475
|
|
1419
|
-
if (
|
1476
|
+
if (columns) {
|
1420
1477
|
columnsToSelect = columns;
|
1421
1478
|
} else {
|
1422
1479
|
columnsToSelect = this.columnsToSelect;
|
1423
1480
|
}
|
1424
1481
|
|
1425
|
-
// ====== BEGIN UI specific code - should be handled on event aloha-table-selection-changed by UI =======
|
1426
|
-
// activate all column formatting button
|
1427
|
-
for ( var i = 0; i < this.tablePlugin.columnMSItems.length; i++ ) {
|
1428
|
-
this.tablePlugin.columnMSButton.showItem(this.tablePlugin.columnMSItems[i].name);
|
1429
|
-
}
|
1430
|
-
|
1431
1482
|
Scopes.setScope(this.tablePlugin.name + '.column');
|
1432
|
-
|
1483
|
+
this.selection.selectColumns(columnsToSelect);
|
1433
1484
|
this.tablePlugin._columnheaderButton.setState(this.selection.isHeader());
|
1434
1485
|
|
1435
|
-
|
1486
|
+
// ====== BEGIN UI specific code - should be handled on event aloha-table-selection-changed by UI =======
|
1436
1487
|
|
1437
|
-
|
1438
|
-
|
1439
|
-
for (var k = 0; k < this.tablePlugin.columnConfig.length; k++) {
|
1440
|
-
if ( jQuery(rows[0].cells[0]).hasClass(this.tablePlugin.columnConfig[k].cssClass) ) {
|
1441
|
-
this.tablePlugin.columnMSButton.setActiveItem(this.tablePlugin.columnConfig[k].name);
|
1442
|
-
k = this.tablePlugin.columnConfig.length;
|
1443
|
-
}
|
1444
|
-
}
|
1488
|
+
setActiveStyle(this.selection.selectedCells, this.tablePlugin.columnConfig,
|
1489
|
+
this.tablePlugin.columnMSItems, this.tablePlugin.columnMSButton);
|
1445
1490
|
|
1446
1491
|
// ====== END UI specific code - should be handled by UI =======
|
1447
1492
|
|
1448
1493
|
// blur all editables within the table
|
1449
1494
|
this.obj.find('div.aloha-ui-table-cell-editable').blur();
|
1450
1495
|
|
1451
|
-
this.selection.selectColumns( columnsToSelect );
|
1452
|
-
|
1453
1496
|
this.selection.notifyCellsSelected();
|
1454
1497
|
this._removeCursorSelection();
|
1455
1498
|
};
|
@@ -1461,33 +1504,16 @@ define([
|
|
1461
1504
|
*/
|
1462
1505
|
Table.prototype.selectRows = function () {
|
1463
1506
|
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
}
|
1507
|
+
Scopes.setScope(this.tablePlugin.name + '.row');
|
1508
|
+
this.selection.selectRows(this.rowsToSelect);
|
1509
|
+
this.tablePlugin._rowheaderButton.setState(this.selection.isHeader());
|
1468
1510
|
|
1469
|
-
|
1470
|
-
var rowId = this.rowsToSelect[i];
|
1471
|
-
var rowCells = jQuery(this.getRows()[rowId].cells).toArray();
|
1472
|
-
if (i == 0) {
|
1473
|
-
// set the first class found as active item in the multisplit button
|
1474
|
-
for (var j = 0; j < rowCells.length; j++) {
|
1475
|
-
this.tablePlugin.rowMSButton.setActiveItem();
|
1476
|
-
for ( var k = 0; k < this.tablePlugin.rowConfig.length; k++) {
|
1477
|
-
if (jQuery(rowCells[j]).hasClass(this.tablePlugin.rowConfig[k].cssClass) ) {
|
1478
|
-
this.tablePlugin.rowMSButton.setActiveItem(this.tablePlugin.rowConfig[k].name);
|
1479
|
-
k = this.tablePlugin.rowConfig.length;
|
1480
|
-
}
|
1481
|
-
}
|
1482
|
-
}
|
1483
|
-
}
|
1484
|
-
}
|
1511
|
+
// ====== BEGIN UI specific code - should be handled on event aloha-table-selection-changed by UI =======
|
1485
1512
|
|
1486
|
-
|
1487
|
-
|
1513
|
+
setActiveStyle(this.selection.selectedCells, this.tablePlugin.rowConfig,
|
1514
|
+
this.tablePlugin.rowMSItems, this.tablePlugin.rowMSButton);
|
1488
1515
|
|
1489
|
-
|
1490
|
-
this.tablePlugin._rowheaderButton.setState(this.selection.isHeader());
|
1516
|
+
// ====== END UI specific code - should be handled by UI =======
|
1491
1517
|
|
1492
1518
|
// blur all editables within the table
|
1493
1519
|
this.obj.find('div.aloha-ui-table-cell-editable').blur();
|
@@ -1532,6 +1558,10 @@ define([
|
|
1532
1558
|
// remove the "selection class" from all td and th in the table
|
1533
1559
|
this.obj.find('td, th').removeClass(this.get('classCellSelected'));
|
1534
1560
|
this.obj.find('td, th').removeClass('aloha-table-cell_active');
|
1561
|
+
|
1562
|
+
// remove cursor-styles
|
1563
|
+
this.obj.find('td, th').css('cursor', '');
|
1564
|
+
|
1535
1565
|
this.obj.unbind();
|
1536
1566
|
this.obj.children('tbody').unbind();
|
1537
1567
|
|