summaryrefslogtreecommitdiff
path: root/addons/website/static/lib/summernote/src/js/editing/Table.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2014-12-10 15:59:48 +0100
committerChristophe Matthieu <chm@odoo.com>2015-01-05 10:17:10 +0100
commit1596e45e8174cd736d4f7c78f85ec76a8e34888d (patch)
tree4ff318ee78bccc6c0bb6253670e85977f8f5a643 /addons/website/static/lib/summernote/src/js/editing/Table.js
parentf9a7ed6b9406d657fda33ec55c4e237576b77a42 (diff)
[IMP] website: add summernote lib
Diffstat (limited to 'addons/website/static/lib/summernote/src/js/editing/Table.js')
-rw-r--r--addons/website/static/lib/summernote/src/js/editing/Table.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/addons/website/static/lib/summernote/src/js/editing/Table.js b/addons/website/static/lib/summernote/src/js/editing/Table.js
new file mode 100644
index 00000000000..291f85128e5
--- /dev/null
+++ b/addons/website/static/lib/summernote/src/js/editing/Table.js
@@ -0,0 +1,50 @@
+define([
+ 'summernote/core/dom', 'summernote/core/range', 'summernote/core/list'
+], function (dom, range, list) {
+ /**
+ * Table
+ * @class
+ */
+ var Table = function () {
+ /**
+ * handle tab key
+ *
+ * @param {WrappedRange} rng
+ * @param {Boolean} isShift
+ */
+ this.tab = function (rng, isShift) {
+ var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);
+ var table = dom.ancestor(cell, dom.isTable);
+ var cells = dom.listDescendant(table, dom.isCell);
+
+ var nextCell = list[isShift ? 'prev' : 'next'](cells, cell);
+ if (nextCell) {
+ range.create(nextCell, 0).select();
+ }
+ };
+
+ /**
+ * create empty table element
+ *
+ * @param {Number} rowCount
+ * @param {Number} colCount
+ * @return {Node}
+ */
+ this.createTable = function (colCount, rowCount) {
+ var tds = [], tdHTML;
+ for (var idxCol = 0; idxCol < colCount; idxCol++) {
+ tds.push('<td>' + dom.blank + '</td>');
+ }
+ tdHTML = tds.join('');
+
+ var trs = [], trHTML;
+ for (var idxRow = 0; idxRow < rowCount; idxRow++) {
+ trs.push('<tr>' + tdHTML + '</tr>');
+ }
+ trHTML = trs.join('');
+ return $('<table class="table table-bordered">' + trHTML + '</table>')[0];
+ };
+ };
+ return Table;
+});
+