Changeset 1021


Ignore:
Timestamp:
08/15/08 21:27:55 (11 years ago)
Author:
nicholasbs
Message:

CHANGED ticket #1176 Finish converting TableOperations? plugin to work with new dialog system

Location:
branches/new-dialogs/plugins/TableOperations
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new-dialogs/plugins/TableOperations/table-operations.js

    r1008 r1021  
    400400                                break; 
    401401                        } 
    402                         editor._popupDialog("plugin://TableOperations/merge_cells.html", function(param) { 
    403                                 if (!param) {   // user pressed Cancel 
    404                                         return false; 
    405                                 } 
    406                                 no_cols = parseInt(param['f_cols'],10) + 1; 
    407                                 no_rows = parseInt(param['f_rows'],10) + 1; 
    408                                 var tr = td.parentNode; 
    409                                 var cell_index = td.cellIndex; 
    410                                 var row_index = tr.rowIndex; 
    411                                 var table = tr.parentNode; 
    412                                 cellMerge(table, cell_index, row_index, no_cols, no_rows); 
    413                         }, null);        
     402                        var tr = td.parentNode; 
     403                        var cell_index = td.cellIndex; 
     404                        var row_index = tr.rowIndex; 
     405                        // pass cellMerge and the indices so apply() can call cellMerge and know  
     406                        // what cell was selected when the dialog was opened 
     407                        this.dialogMerge(cellMerge, cell_index, row_index); 
    414408                } 
    415409                break; 
     
    463457        ["cell-split",         "td[colSpan!=1,rowSpan!=1]", "Split cell"] 
    464458        ]; 
     459 
     460TableOperations.prototype.dialogMerge = function(merge_func, cell_index, row_index) { 
     461  var table = this.getClosest("table"); 
     462  var self = this; 
     463  var editor = this.editor; 
     464 
     465  if (!this.dialogMergeCellsHtml) { 
     466    Xinha._getback(Xinha.getPluginDir("TableOperations") + '/popups/dialogMergeCells.html', function(getback) { self.dialogMergeCellsHtml = getback; self.dialogMerge(merge_func, cell_index, row_index); }); 
     467    return; 
     468  } 
     469 
     470  if (!this.dialogMergeCells) { 
     471    this.dialogMergeCells = new Xinha.Dialog(editor, this.dialogMergeCellsHtml, 'TableOperations', {width:400}); 
     472    this.dialogMergeCells.getElementById('cancel').onclick = function() { self.dialogMergeCells.hide(); }; 
     473  } 
     474 
     475  var dialog = this.dialogMergeCells; 
     476  function apply() { 
     477    dialog.hide(); 
     478    no_cols = parseInt(dialog.getElementById('f_cols').value,10) + 1; 
     479    no_rows = parseInt(dialog.getElementById('f_rows').value,10) + 1; 
     480    merge_func(table, cell_index, row_index, no_cols, no_rows);     
     481    return 
     482  } 
     483 
     484  this.dialogMergeCells.getElementById('ok').onclick = apply; 
     485  this.dialogMergeCells.show(); 
     486  this.dialogMergeCells.getElementById('f_cols').focus(); 
     487} 
    465488 
    466489TableOperations.prototype.dialogTableProperties = function() { 
Note: See TracChangeset for help on using the changeset viewer.