[prev in list] [next in list] [prev in thread] [next in thread]
List: kupu-checkins
Subject: [kupu-checkins] r6247 - in kupu/branch/kupu-1.1: common default
From: guido () codespeak ! net
Date: 2004-08-31 16:28:42
Message-ID: 20040831162842.A6DA05ABC6 () thoth ! codespeak ! net
[Download RAW message or body]
Author: guido
Date: Tue Aug 31 18:28:42 2004
New Revision: 6247
Modified:
kupu/branch/kupu-1.1/common/kupubasetools.js
kupu/branch/kupu-1.1/common/kupucontentfilters.js
kupu/branch/kupu-1.1/default/toolbar.kupu
kupu/branch/kupu-1.1/default/toolboxes.kupu
Log:
Ported some bugfixes (mostly Silva specific) from the trunk for the 1.1.1b1
release.
Modified: kupu/branch/kupu-1.1/common/kupubasetools.js
==============================================================================
--- kupu/branch/kupu-1.1/common/kupubasetools.js (original)
+++ kupu/branch/kupu-1.1/common/kupubasetools.js Tue Aug 31 18:28:42 2004
@@ -512,8 +512,9 @@
};
// the order of the arguments is a bit odd here because of backward \
compatibility
- this.createLink = function(url, type, name, target) {
+ this.createLink = function(url, type, name, target, title) {
var currnode = this.editor.getSelectedNode();
+ var doc = this.editor.getInnerDocument();
var linkel = this.editor.getNearestParentOfType(currnode, 'A');
if (!linkel) {
this.editor.execCommand("CreateLink", url);
@@ -524,19 +525,27 @@
linkel = currnode.nextSibling;
};
if (!linkel) {
- this.editor.logMessage('No text selected');
- return;
+ // Insert link with no text selected, insert the title
+ // or URI instead.
+ linkel = doc.createElement("a");
+ linkel.setAttribute('href', url);
+ currnode.appendChild(linkel);
};
} else {
linkel.setAttribute('href', url);
}
-
+ if (linkel.innerHTML == "") {
+ linkel.appendChild(doc.createTextNode(title?title:url));
+ }
if (type && type == 'anchor') {
linkel.removeAttribute('href');
linkel.setAttribute('name', name);
} else {
- if (target) {
+ if (target && target != '') {
linkel.setAttribute('target', target);
+ }
+ else {
+ linkel.removeAttribute('target');
};
};
@@ -655,8 +664,11 @@
imageWindow.focus();
};
- this.createImage = function(url) {
+ this.createImage = function(url, floatstyle) {
var img = this.editor.getInnerDocument().createElement('img');
+ if (floatstyle) {
+ img.style.cssFloat = floatstyle;
+ };
img.setAttribute('src', url);
img = this.editor.insertNodeAtSelection(img, 1);
this.editor.logMessage('Image inserted');
@@ -670,11 +682,12 @@
ImageTool.prototype = new KupuTool;
-function ImageToolBox(inputfieldid, insertbuttonid, toolboxid, plainclass, \
activeclass) { +function ImageToolBox(inputfieldid, insertbuttonid, floatselectid, \
toolboxid, plainclass, activeclass) { /* toolbox for adding images */
this.inputfield = document.getElementById(inputfieldid);
this.insertbutton = document.getElementById(insertbuttonid);
+ this.floatselect = document.getElementById(floatselectid);
this.toolboxel = document.getElementById(toolboxid);
this.plainclass = plainclass;
this.activeclass = activeclass;
@@ -692,6 +705,9 @@
// check first before setting a class for backward compatibility
if (this.toolboxel) {
this.toolboxel.className = this.activeclass;
+ this.inputfield.value = imageel.getAttribute('src');
+ var floatstyle = imageel.style.cssFloat ? imageel.style.cssFloat : \
'left'; + selectSelectItem(this.floatselect, floatstyle);
};
} else {
if (this.toolboxel) {
@@ -703,7 +719,8 @@
this.addImage = function() {
/* add an image */
var url = this.inputfield.value;
- this.tool.createImage(url);
+ var floatstyle = \
this.floatselect.options[this.floatselect.selectedIndex].value; + \
this.tool.createImage(url, floatstyle); };
};
@@ -1097,14 +1114,150 @@
return currcolindex;
};
+
+ this._getColumnAlign = function(selNode) {
+ /* return the alignment setting of the current column */
+ var align;
+ var td = this.editor.getNearestParentOfType(selNode, 'td');
+ if (!td) {
+ td = this.editor.getNearestParentOfType(selNode, 'th');
+ };
+ if (td) {
+ align = td.getAttribute('align');
+ if (this.editor.config.use_css) {
+ align = td.style.textAlign;
+ };
+ };
+ return align;
+ };
+
+ this.fixTable = function(event) {
+ /* fix the table so it can be processed by Kupu */
+ // since this can be quite a nasty creature we can't just use the
+ // helper methods
+
+ // first we create a new tbody element
+ var currnode = this.editor.getSelectedNode();
+ var table = this.editor.getNearestParentOfType(currnode, 'TABLE');
+ if (!table) {
+ this.editor.logMessage('Not inside a table!');
+ return;
+ };
+ this._fixTableHelper(table);
+ };
+
+ this._fixTableHelper = function(table) {
+ /* the code to actually fix tables */
+ var doc = this.editor.getInnerDocument();
+ var tbody = doc.createElement('tbody');
+
+ var allowed_classes = new Array('plain', 'grid', 'list', 'listing', 'data');
+ if (!allowed_classes.contains(table.getAttribute('class'))) {
+ table.setAttribute('class', 'plain');
+ };
+
+ table.setAttribute('cellpadding', '0');
+ table.setAttribute('cellspacing', '0');
+
+ // now get all the rows of the table, the rows can either be
+ // direct descendants of the table or inside a 'tbody', 'thead'
+ // or 'tfoot' element
+ var rows = new Array();
+ var parents = new Array('thead', 'tbody', 'tfoot');
+ for (var i=0; i < table.childNodes.length; i++) {
+ var node = table.childNodes[i];
+ if (node.nodeName.toLowerCase() == 'tr') {
+ rows.push(node);
+ } else if (parents.contains(node.nodeName.toLowerCase())) {
+ for (var j=0; j < node.childNodes.length; j++) {
+ var inode = node.childNodes[j];
+ if (inode.nodeName.toLowerCase() == 'tr') {
+ rows.push(inode);
+ };
+ };
+ };
+ };
+
+ // now find out how many cells our rows should have
+ var numcols = 0;
+ for (var i=0; i < rows.length; i++) {
+ var row = rows[i];
+ var currnumcols = 0;
+ for (var j=0; j < row.childNodes.length; j++) {
+ var node = row.childNodes[j];
+ if (node.nodeName.toLowerCase() == 'td' ||
+ node.nodeName.toLowerCase() == 'th') {
+ var colspan = 1;
+ if (node.getAttribute('colSpan')) {
+ colspan = parseInt(node.getAttribute('colSpan'));
+ };
+ currnumcols += colspan;
+ };
+ };
+ if (currnumcols > numcols) {
+ numcols = currnumcols;
+ };
+ };
+
+ // now walk through all rows to clean them up
+ for (var i=0; i < rows.length; i++) {
+ var row = rows[i];
+ var newrow = doc.createElement('tr');
+ var currcolnum = 0;
+ while (row.childNodes.length > 0) {
+ var node = row.childNodes[0];
+ if (node.nodeName.toLowerCase() != 'td' && \
node.nodeName.toLowerCase() != 'th') { + row.removeChild(node);
+ continue;
+ };
+ node.removeAttribute('colSpan');
+ node.removeAttribute('rowSpan');
+ newrow.appendChild(node);
+ };
+ if (newrow.childNodes.length) {
+ tbody.appendChild(newrow);
+ };
+ };
+
+ // now make sure all rows have the correct length
+ for (var i=0; i < tbody.childNodes.length; i++) {
+ var row = tbody.childNodes[i];
+ var cellname = row.childNodes[0].nodeName;
+ while (row.childNodes.length < numcols) {
+ var cell = doc.createElement(cellname);
+ var nbsp = doc.createTextNode('\u00a0');
+ cell.appendChild(nbsp);
+ row.appendChild(cell);
+ };
+ };
+
+ // now remove all the old stuff from the table and add the new tbody
+ var tlength = table.childNodes.length;
+ for (var i=0; i < tlength; i++) {
+ table.removeChild(table.childNodes[0]);
+ };
+ table.appendChild(tbody);
+
+ this.editor.getDocument().getWindow().focus();
+
+ this.editor.logMessage('Table cleaned up');
+ };
+
+ this.fixAllTables = function() {
+ /* fix all the tables in the document at once */
+ var tables = this.editor.getInnerDocument().getElementsByTagName('table');
+ for (var i=0; i < tables.length; i++) {
+ this._fixTableHelper(tables[i]);
+ };
+ };
};
TableTool.prototype = new KupuTool;
function TableToolBox(addtabledivid, edittabledivid, newrowsinputid,
newcolsinputid, makeheaderinputid, classselectid, alignselectid, \
addtablebuttonid,
- addrowbuttonid, delrowbuttonid, addcolbuttonid, delcolbuttonid,
- toolboxid, plainclass, activeclass) {
+ addrowbuttonid, delrowbuttonid, addcolbuttonid, delcolbuttonid, \
fixbuttonid, + fixallbuttonid, toolboxid, plainclass, activeclass) \
{ /* The table tool */
// XXX There are some awfully long methods in here!!
@@ -1124,6 +1277,8 @@
this.delrowbutton = document.getElementById(delrowbuttonid);
this.addcolbutton = document.getElementById(addcolbuttonid);
this.delcolbutton = document.getElementById(delcolbuttonid);
+ this.fixbutton = document.getElementById(fixbuttonid);
+ this.fixallbutton = document.getElementById(fixallbuttonid);
this.toolboxel = document.getElementById(toolboxid);
this.plainclass = plainclass;
this.activeclass = activeclass;
@@ -1133,6 +1288,21 @@
/* attach the event handlers */
this.tool = tool;
this.editor = editor;
+ // build the select list of table classes if configured
+ if (this.editor.config.table_classes) {
+ var classes = this.editor.config.table_classes['class'];
+ while (this.classselect.hasChildNodes()) {
+ this.classselect.removeChild(this.classselect.firstChild);
+ };
+ for (var i=0; i < classes.length; i++) {
+ var classname = classes[i];
+ var option = document.createElement('option');
+ var content = document.createTextNode(classname);
+ option.appendChild(content);
+ option.setAttribute('value', classname);
+ this.classselect.appendChild(option);
+ };
+ };
addEventHandler(this.addtablebutton, "click", this.addTable, this);
addEventHandler(this.addrowbutton, "click", this.tool.addTableRow, \
this.tool);
addEventHandler(this.delrowbutton, "click", this.tool.delTableRow, \
this.tool); @@ -1140,6 +1310,8 @@
addEventHandler(this.delcolbutton, "click", this.tool.delTableColumn, \
this.tool);
addEventHandler(this.alignselect, "change", this.setColumnAlign, this);
addEventHandler(this.classselect, "change", this.setTableClass, this);
+ addEventHandler(this.fixbutton, "click", this.tool.fixTable, this.tool);
+ addEventHandler(this.fixallbutton, "click", this.tool.fixAllTables, \
this.tool); this.addtablediv.style.display = "block";
this.edittablediv.style.display = "none";
this.editor.logMessage('Table tool initialized');
@@ -1151,17 +1323,9 @@
if (table) {
this.addtablediv.style.display = "none";
this.edittablediv.style.display = "block";
- var td = this.editor.getNearestParentOfType(selNode, 'td');
- if (!td) {
- td = this.editor.getNearestParentOfType(selNode, 'th');
- };
- if (td) {
- var align = td.getAttribute('align');
- if (this.editor.config.use_css) {
- align = td.style.textAlign;
- };
- selectSelectItem(this.alignselect, align);
- };
+
+ var align = this.tool._getColumnAlign(selNode);
+ selectSelectItem(this.alignselect, align);
selectSelectItem(this.classselect, table.className);
if (this.toolboxel) {
this.toolboxel.className = this.activeclass;
Modified: kupu/branch/kupu-1.1/common/kupucontentfilters.js
==============================================================================
--- kupu/branch/kupu-1.1/common/kupucontentfilters.js (original)
+++ kupu/branch/kupu-1.1/common/kupucontentfilters.js Tue Aug 31 18:28:42 2004
@@ -84,6 +84,7 @@
'script': 1,
'span': 1,
'strong': 1,
+ 'style': 1,
'sub': 1,
'sup': 1,
'table': 1,
Modified: kupu/branch/kupu-1.1/default/toolbar.kupu
==============================================================================
--- kupu/branch/kupu-1.1/default/toolbar.kupu (original)
+++ kupu/branch/kupu-1.1/default/toolbar.kupu Tue Aug 31 18:28:42 2004
@@ -41,7 +41,7 @@
</kupu:part>
<kupu:part name="logo">
- <span class="kupu-tb-buttongroup" style="float: right">
+ <span class="kupu-tb-buttongroup" style="float: right" id="kupu=logo">
<button type="button" class="kupu-logo" title="Kupu 1.1" accesskey="k"
onclick="window.open('http://kupu.oscom.org');"> </button>
</span>
@@ -77,7 +77,7 @@
</kupu:part>
<kupu:part name="buttongroup-basicmarkup">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-basicmarkup">
<button type="button" class="kupu-bold" id="kupu-bold-button" title="bold: \
alt-b" i18n:attributes="title" accesskey="b"> </button>
<button type="button" class="kupu-italic" id="kupu-italic-button" \
title="italic: alt-i" @@ -88,7 +88,7 @@
</kupu:part>
<kupu:part name="buttongroup-subsuper">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-subsuper">
<button type="button" class="kupu-subscript" id="kupu-subscript-button" \
title="subscript: alt--" i18n:attributes="title" accesskey="-"> </button>
<button type="button" class="kupu-superscript" id="kupu-superscript-button" \
title="superscript: alt-+" @@ -97,7 +97,7 @@
</kupu:part>
<kupu:part name="buttongroup-justify">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-justify">
<button type="button" class="kupu-justifyleft" id="kupu-justifyleft-button"
title="left justify: alt-l" i18n:attributes="title"
accesskey="l"> </button>
@@ -111,7 +111,7 @@
</kupu:part>
<kupu:part name="buttongroup-list">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-list">
<!-- list button events are set on the list tool -->
<button type="button" class="kupu-insertorderedlist"
title="numbered list: alt-#" id="kupu-list-ol-addbutton"
@@ -123,7 +123,7 @@
</kupu:part>
<kupu:part name="buttongroup-definitionlist">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-definitionlist">
<!-- list button events are set on the list tool -->
<button type="button" class="kupu-insertdefinitionlist"
title="definition list: alt-=" id="kupu-list-dl-addbutton"
@@ -132,7 +132,7 @@
</kupu:part>
<kupu:part name="buttongroup-indent">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-indent">
<button type="button" class="kupu-outdent"
id="kupu-outdent-button" title="outdent: alt-<"
i18n:attributes="title" accesskey="<"> </button>
@@ -143,7 +143,7 @@
</kupu:part>
<kupu:part name="buttongroup-undo">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-undo">
<button type="button" class="kupu-undo"
id="kupu-undo-button" title="undo: alt-z"
i18n:attributes="title" accesskey="z"> </button>
@@ -154,7 +154,7 @@
</kupu:part>
<kupu:part name="buttongroup-remove">
- <span class="kupu-tb-buttongroup">
+ <span class="kupu-tb-buttongroup" id="kupu-bg-remove">
<button type="button" class="kupu-removeimage invisible"
id="kupu-removeimage-button" title="Remove image"
i18n:attributes="title"> </button>
Modified: kupu/branch/kupu-1.1/default/toolboxes.kupu
==============================================================================
--- kupu/branch/kupu-1.1/default/toolboxes.kupu (original)
+++ kupu/branch/kupu-1.1/default/toolboxes.kupu Tue Aug 31 18:28:42 2004
@@ -16,22 +16,10 @@
<div class="kupu-toolbox" id="kupu-toolbox-properties">
<h1>Properties</h1>
- <table id="kupu-properties">
- <tbody>
- <tr>
- <td class="kupu-toolbox-label">Title</td>
- <td><input id="kupu-properties-title" /></td>
- </tr>
- <tr>
- <td colspan="2" class="kupu-toolbox-label">Description</td>
- </tr>
- <tr>
- <td colspan="2">
- <textarea id="kupu-properties-description"> </textarea>
- </td>
- </tr>
- </tbody>
- </table>
+ <div class="kupu-toolbox-label">Title</div>
+ <input id="kupu-properties-title" />
+ <div class="kupu-toolbox-label">Description</div>
+ <textarea style="width: 90%" id="kupu-properties-description"> </textarea>
</div>
</kupu:part>
@@ -49,7 +37,7 @@
<input id="kupu-link-input"
class="kupu-toolbox-st"
- type="text" size="14"
+ type="text" style="width: 98%"
/>
<div style="text-align: center">
<button type="button" id="kupu-link-button"
@@ -73,7 +61,19 @@
<input id="kupu-image-input"
value="kupuimages/kupu_icon.gif"
class="kupu-toolbox-st"
- type="text" size="14" />
+ type="text" style="width: 98%" />
+ <div class="kupu-toolbox-label">
+ <span i18n:translate="">
+ Image float
+ </span>:
+ </div>
+
+ <select id="kupu-image-float-select"
+ class="kupu-toolbox-st">
+ <option value="none">No float</option>
+ <option value="left">Left</option>
+ <option value="right">Right</option>
+ </select>
<div style="text-align: center">
<button type="button" id="kupu-image-addbutton"
class="kupu-toolbox-action">Insert Image</button>
@@ -85,81 +85,57 @@
<div class="kupu-toolbox" id="kupu-toolbox-tables">
<h1 i18n:translate="table-inspector">Tables</h1>
- <table width="100%">
- <tbody>
- <tr>
- <td class="kupu-toolbox-label">Table Class</td>
- <td>
- <select id="kupu-table-classchooser">
- <option value="plain">Plain</option>
- <option value="listing">Listing</option>
- <option value="grid">Grid</option>
- <option value="data">Data</option>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <div id="kupu-toolbox-addtable">
- <table width="100%">
- <tr>
- <td class="kupu-toolbox-label">Rows</td>
- <td><input id="kupu-table-newrows" /></td>
- </tr>
- <tr>
- <td class="kupu-toolbox-label">Columns</td>
- <td><input id="kupu-table-newcols" /></td>
- </tr>
- <tr>
- <td class="kupu-toolbox-label">Headings</td>
- <td class="kupu-toolbox-label">
- <input name="kupu-table-makeheader"
- id="kupu-table-makeheader"
- type="checkbox"
- />
- <label for="kupu-table-makeheader">Create</label>
- </td>
- </tr>
- <tr>
- <td colspan="2" style="text-align: center">
- <button type="button"
- id="kupu-table-addtable-button">Add Table</button>
- </td>
- </tr>
- </table>
- </div>
- <div id="kupu-toolbox-edittable">
- <table width="100%">
- <tr>
- <td>Col Align</td>
- <td>
- <select id="kupu-table-alignchooser">
- <option value="left">Left</option>
- <option value="center">Center</option>
- <option value="right">Right</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Column</td>
- <td>
- <button type="button" \
id="kupu-table-addcolumn-button">Add</button>
- <button type="button" \
id="kupu-table-delcolumn-button">Remove</button>
- </td>
- </tr>
- <tr>
- <td>Row</td>
- <td>
- <button type="button" \
id="kupu-table-addrow-button">Add</button>
- <button type="button" \
id="kupu-table-delrow-button">Remove</button>
- </td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
+ <div class="kupu-toolbox-label">Table Class
+ <select id="kupu-table-classchooser"> </select>
+ </div>
+
+ <div id="kupu-toolbox-addtable">
+ <div class="kupu-toolbox-label">Rows</div>
+ <input type="text" id="kupu-table-newrows" style="width: 98%" />
+
+ <div class="kupu-toolbox-label">Columns</div>
+ <input type="text" id="kupu-table-newcols" style="width: 98%" />
+
+ <div class="kupu-toolbox-label">
+ Headings
+ <input name="kupu-table-makeheader"
+ id="kupu-table-makeheader"
+ type="checkbox"
+ />
+ <label for="kupu-table-makeheader">Create</label>
+ </div>
+
+ <div style="text-align: center">
+ <button type="button" id="kupu-table-fixall-button">Fix Table</button>
+ <button type="button" id="kupu-table-addtable-button">Add Table</button>
+ </div>
+
+ </div>
+
+ <div id="kupu-toolbox-edittable">
+
+ <div class="kupu-toolbox-label">Col Align
+ <select id="kupu-table-alignchooser">
+ <option value="left">Left</option>
+ <option value="center">Center</option>
+ <option value="right">Right</option>
+ </select>
+ </div>
+
+ <br />
+ <button type="button" id="kupu-table-addcolumn-button">Add Column</button>
+ <button type="button" id="kupu-table-delcolumn-button">Remove \
Column</button> +
+ <br />
+ <button type="button" id="kupu-table-addrow-button">Add Row</button>
+ <button type="button" id="kupu-table-delrow-button">Remove Row</button>
+
+ <div style="text-align: center">
+ <button type="button" id="kupu-table-fix-button">Fix</button>
+ </div>
+
+ </div>
+
</div>
</kupu:part>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic