From 60e1f366a00c3a19be34ca3b659af00927e62cdb Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 2 Feb 2012 21:28:43 +0000 Subject: [PATCH] experimentation with table editing --- contentEditable/main.js | 67 ++++++++++++++++++++++- contentEditable/views/es.TableCellView.js | 45 +++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/contentEditable/main.js b/contentEditable/main.js index 1f7f5815c8..66a8e8ec7e 100644 --- a/contentEditable/main.js +++ b/contentEditable/main.js @@ -60,7 +60,72 @@ $(document).ready( function() { 'content': { 'text': 'row 1 & cell 2' } } ] - } + }, + { + 'type': 'tableCell', + 'attributes': { 'html/style': 'border: solid 1px;' }, + 'children': [ + { + 'type': 'paragraph', + 'content': { 'text': 'row 1 & cell 3' } + } + ] + }, + { + 'type': 'tableCell', + 'attributes': { 'html/style': 'border: solid 1px;' }, + 'children': [ + { + 'type': 'paragraph', + 'content': { 'text': 'row 1 & cell 4' } + } + ] + } + ] + }, + { + 'type': 'tableRow', + 'children': [ + { + 'type': 'tableCell', + 'attributes': { 'html/style': 'border: solid 1px;' }, + 'children': [ + { + 'type': 'paragraph', + 'content': { 'text': 'row 2 & cell 1' } + } + ] + }, + { + 'type': 'tableCell', + 'attributes': { 'html/style': 'border: solid 1px;' }, + 'children': [ + { + 'type': 'paragraph', + 'content': { 'text': 'row 2 & cell 2' } + } + ] + }, + { + 'type': 'tableCell', + 'attributes': { 'html/style': 'border: solid 1px;' }, + 'children': [ + { + 'type': 'paragraph', + 'content': { 'text': 'row 2 & cell 3' } + } + ] + }, + { + 'type': 'tableCell', + 'attributes': { 'html/style': 'border: solid 1px;' }, + 'children': [ + { + 'type': 'paragraph', + 'content': { 'text': 'row 2 & cell 4' } + } + ] + } ] } ] diff --git a/contentEditable/views/es.TableCellView.js b/contentEditable/views/es.TableCellView.js index 893749675d..c28766b887 100644 --- a/contentEditable/views/es.TableCellView.js +++ b/contentEditable/views/es.TableCellView.js @@ -10,10 +10,23 @@ es.TableCellView = function( model ) { // Inheritance es.DocumentViewBranchNode.call( this, model, $( '' ) ); + var _this = this; + // DOM Changes this.$ .attr( 'style', model.getElementAttribute( 'html/style' ) ) .addClass( 'es-tableCellView' ); + + /* Table interaction experiment */ + /* + this.$.mousedown( function( e ) { + _this.mousedown( e ); + } ); + this.$.mouseup( function( e ) { + _this.mouseup( e ); + } ); + */ + }; /* Registration */ @@ -26,3 +39,35 @@ es.DocumentView.splitRules.tableCell = { /* Inheritance */ es.extendClass( es.TableCellView, es.DocumentViewBranchNode ); + + +/* Table interaction experiment */ +/* +es.TableCellView.prototype.mousedown = function( e ) { + + if ( this.$.hasClass('selected') ) { + $(document.body).css('-webkit-user-select', 'auto'); + this.giveCursor = true; + } else { + e.preventDefault(); + window.getSelection().removeAllRanges(); + this.giveCursor = false; + $(document.body).css('-webkit-user-select', 'none'); + if ( e.metaKey ) { + + } else if ( e.shiftKey ) { + + } else { + this.getParent().getParent().$.find('.es-tableCellView.selected').removeClass('selected'); + } + } + this.$.addClass('selected'); +} + +es.TableCellView.prototype.mouseup = function( e ) { + if ( this.giveCursor ) { + this.getParent().getParent().$.find('.es-tableCellView.selected').removeClass('selected'); + } else { + } +} +*/ \ No newline at end of file