// $Id: table.js,v 1.1.2.2 2008/11/21 22:54:27 jeffcd Exp $ function yui_editor_table() { for (var e in YAHOO.Drupal.editors) { var myEditor = YAHOO.Drupal.editors[e].editor; var config = YAHOO.Drupal.editors[e].config; var id = YAHOO.Drupal.editors[e].id; if (config.table == 1) { myEditor.on('toolbarLoaded', function () { var tableConfig = { type: 'push', label: 'Create Table', value: 'table' }; myEditor.toolbar.addButtonToGroup(tableConfig, 'plugins'); myEditor.win = null; myEditor.createTableHTML = '' + '' + '' + '' + '' + '' + '' + '
Rows:Columns:
Width:Height:

Border Size:

Cell Spacing:
Cell Padding:
'; myEditor.toolbar.on('tableClick', function(ev) { if (this.win !== null) { this.win.setBody(myEditor.createTableHTML); this.win.show(); } else { this.win = new YAHOO.widget.Panel('test', { modal: true, fixedcenter: true, draggable: false, width: '350px' }); this.win.setHeader('Create Table'); this.win.setBody(myEditor.createTableHTML); this.win.render(document.body); this.win.hideEvent.subscribe(function() { //Just to make sure we didn't loose it this._setDesignMode('on'); this._focusWindow(); }, myEditor, true); } var tableCreateButton = new YAHOO.widget.Button('tableCreate' + id); tableCreateButton.on('click', function() { var rows = document.getElementById('tableRows' + id).value.match('[0-9]+') ? document.getElementById('tableRows' + id).value : 3; var columns = document.getElementById('tableColumns' + id).value.match('[0-9]+') ? document.getElementById('tableColumns' + id).value : 3; var borderSize = document.getElementById('tableBorderSize' + id).value.match('[0-9]+') ? document.getElementById('tableBorderSize' + id).value : 1; var cellspacing = document.getElementById('tableCellspacing' + id).value.match('[0-9]+') ? document.getElementById('tableCellspacing' + id).value : 0; var cellpadding = document.getElementById('tableCellpadding' + id).value.match('[0-9]+') ? document.getElementById('tableCellpadding' + id).value : 0; var width = document.getElementById('tableWidth' + id).value.match('[0-9]+') ? document.getElementById('tableWidth' + id).value : 0; var height = document.getElementById('tableHeight' + id).value.match('[0-9]+') ? document.getElementById('tableHeight' + id).value : 0; var tableHTML = ''; // Build table for (var i = 0;i < rows;i++) { tableHTML += '\n'; for (var j = 0;j < columns;j++) { tableHTML += '\n'; } tableHTML += '\n'; } tableHTML += '
 
'; myEditor.execCommand('inserthtml', tableHTML); createTablePanel.hide(); }); return false; }, myEditor, true); }); } } } YAHOO.Drupal.yui_editor_load.subscribe(yui_editor_table);