Index: table-operations.js
===================================================================
--- table-operations.js	(revision 1016)
+++ table-operations.js	(working copy)
@@ -399,18 +399,12 @@
 				alert(Xinha._lc("Please click into some cell", "TableOperations"));
 				break;
 			}
-			editor._popupDialog("plugin://TableOperations/merge_cells.html", function(param) {
-				if (!param) {	// user pressed Cancel
-					return false;
-				}
-				no_cols = parseInt(param['f_cols'],10) + 1;
-				no_rows = parseInt(param['f_rows'],10) + 1;
-				var tr = td.parentNode;
-				var cell_index = td.cellIndex;
-				var row_index = tr.rowIndex;
-				var table = tr.parentNode;
-				cellMerge(table, cell_index, row_index, no_cols, no_rows);
-			}, null);	
+		        var tr = td.parentNode;
+		        var cell_index = td.cellIndex;
+		        var row_index = tr.rowIndex;
+		        // pass cellMerge and the indices so apply() can call cellMerge and know 
+       		        // what cell was selected when the dialog was opened
+		        this.dialogMerge(cellMerge, cell_index, row_index);
 		}
 		break;
 
@@ -463,6 +457,35 @@
 	["cell-split",         "td[colSpan!=1,rowSpan!=1]", "Split cell"]
 	];
 
+TableOperations.prototype.dialogMerge = function(merge_func, cell_index, row_index) {
+  var table = this.getClosest("table");
+  var self = this;
+  var editor = this.editor;
+
+  if (!this.dialogMergeCellsHtml) {
+    Xinha._getback(Xinha.getPluginDir("TableOperations") + '/popups/dialogMergeCells.html', function(getback) { self.dialogMergeCellsHtml = getback; self.dialogMerge(merge_func, cell_index, row_index); });
+    return;
+  }
+
+  if (!this.dialogMergeCells) {
+    this.dialogMergeCells = new Xinha.Dialog(editor, this.dialogMergeCellsHtml, 'TableOperations', {width:400});
+    this.dialogMergeCells.getElementById('cancel').onclick = function() { self.dialogMergeCells.hide(); };
+  }
+
+  var dialog = this.dialogMergeCells;
+  function apply() {
+    dialog.hide();
+    no_cols = parseInt(dialog.getElementById('f_cols').value,10) + 1;
+    no_rows = parseInt(dialog.getElementById('f_rows').value,10) + 1;
+    merge_func(table, cell_index, row_index, no_cols, no_rows);    
+    return
+  }
+
+  this.dialogMergeCells.getElementById('ok').onclick = apply;
+  this.dialogMergeCells.show();
+  this.dialogMergeCells.getElementById('f_cols').focus();
+}
+
 TableOperations.prototype.dialogTableProperties = function() {
 
 	var table = this.getClosest("table");
Index: popups/dialogMergeCells.html
===================================================================
--- popups/dialogMergeCells.html	(revision 0)
+++ popups/dialogMergeCells.html	(revision 0)
@@ -0,0 +1,26 @@
+<h1 id="[h1]"><l10n>Merge Cells</l10n></h1>
+<table width="100%">
+  <tr>
+    <td colspan="2">
+      <l10n>Merge current cell with:</l10n>
+    </td>
+  </tr>
+  <tr>
+    <td style="text-align: right;" width="30%"><input type="text" name="[cols]" value="0" id="[f_cols]" size="4" title="Columns" /></td>
+    <td width="70%"><l10n>Cells to the right, and</l10n></td>
+  </tr>
+  <tr>
+    <td style="text-align: right;"><input type="text" name="[rows]" value="0" id="[f_rows]" size="4" title="Rows" /></td>
+    <td><l10n>Cells down</l10n></td>
+  </tr>
+  <tr>
+    <td colspan="2" style="text-align: right;">
+      <hr />
+      <div class="buttons" id="[buttons]">
+	<input type="button" id="[ok]" value="_(OK)" />
+	<input type="button" id="[cancel]" value="_(Cancel)" />
+      </div>
+    </td>
+  </tr>
+</table>
+

Property changes on: popups/dialogMergeCells.html
___________________________________________________________________
Name: svn:mime-type
   + text/html
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native


