From 28d8bab3497c715b777e090a6e8f6acaf7065d13 Mon Sep 17 00:00:00 2001 From: radovan Date: Thu, 13 Aug 2009 11:47:14 +0200 Subject: [PATCH] added add table button --- Assets/MooEditable/Editable.css | 3 + Assets/MooEditable/MooEditable.Table.css | 6 ++ Assets/MooEditable/Tango/table.png | Bin 0 -> 566 bytes Demos/MooEditable/MooEditable.Table.html | 60 +++++++++++++++++ Source/MooEditable/MooEditable.Table.js | 80 +++++++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 Assets/MooEditable/Editable.css create mode 100644 Assets/MooEditable/MooEditable.Table.css create mode 100644 Assets/MooEditable/Tango/table.png create mode 100644 Demos/MooEditable/MooEditable.Table.html create mode 100644 Source/MooEditable/MooEditable.Table.js diff --git a/Assets/MooEditable/Editable.css b/Assets/MooEditable/Editable.css new file mode 100644 index 0000000..f131c09 --- /dev/null +++ b/Assets/MooEditable/Editable.css @@ -0,0 +1,3 @@ +table { border: 1px dashed #BBBBBB; font:inherit; } +table td, table th { border: 1px dashed #BBBBBB; } +table th { font-weight:bold ; } diff --git a/Assets/MooEditable/MooEditable.Table.css b/Assets/MooEditable/MooEditable.Table.css new file mode 100644 index 0000000..d22d649 --- /dev/null +++ b/Assets/MooEditable/MooEditable.Table.css @@ -0,0 +1,6 @@ + +.mooeditable-ui-toolbar .table-item .button-icon { + background: transparent url(Tango/table.png) no-repeat center center; +} + + diff --git a/Assets/MooEditable/Tango/table.png b/Assets/MooEditable/Tango/table.png new file mode 100644 index 0000000000000000000000000000000000000000..abcd93689a08ec9bdbf0984927e8da06c043c7cd GIT binary patch literal 566 zcmV-60?GY}P)>q?GuNnCdgP^*Bj5V_b?dAq2Ppn9^MBB^YUM zad0N-T{Ujg*A6d~mYV4na=hT4Nz+_}SGTgW|Iir!%$ z;@OGkWI6+j0H}~K4RYR%!7y|zM`O@*K>rL{*&}x3lR**HrMXC1->#slU>X|w!U1xQ zqc + + + + MooEditable example with Table button + + + + + + + + + + + + + + +

MooEditable example with Table button

+ +
+ + + + + + +
+ +
+ + + diff --git a/Source/MooEditable/MooEditable.Table.js b/Source/MooEditable/MooEditable.Table.js new file mode 100644 index 0000000..19357c9 --- /dev/null +++ b/Source/MooEditable/MooEditable.Table.js @@ -0,0 +1,80 @@ +/* +Script: MooEditable.Table.js + Add table + +Usage: + Add the following tags in your html + + + + + + + +License: + MIT-style license. + +Author: + Radovan Lozej +*/ + +MooEditable.UI.TableDialog = function(editor){ + var html = '' + + ' x ' + + '' + + '' + + ''; + return new MooEditable.UI.Dialog(html, { + 'class': 'mooeditable-prompt-dialog', + onOpen: function(){ + var input = this.el.getElement('.table-r'); + (function(){ + input.focus(); + input.select(); + }).delay(10); + //console.log(editor.selection.getNode()); + }, + onClick: function(e){ + e.preventDefault(); + if (e.target.tagName.toLowerCase() != 'button') return; + var button = document.id(e.target); + if (button.hasClass('dialog-cancel-button')) this.close(); + else if (button.hasClass('dialog-ok-button')){ + this.close(); + var row = this.el.getElement('.table-r').value.toInt(); + var col = this.el.getElement('.table-c').value.toInt(); + if(!(row>0 && col>0)) return; + var div,table,tbody,ro = []; + div = new Element('tdiv'); + table = new Element('table').set('border','0').set('width','100%').inject(div); + tbody = new Element('tbody').inject(table); + for(var r=0;r