Changeset 1358 for trunk/plugins


Ignore:
Timestamp:
02/04/18 05:22:00 (20 months ago)
Author:
gogo
Message:

#1163 Add th support to TableOperations? - in that it won't break th's and will allow you to style existing ones, you just can't insert new ones presently.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/TableOperations/TableOperations.js

    r1282 r1358  
    7171 
    7272  cfg.dblclickList['td'] = [function() { self.dialogTableProperties() }]; 
     73  cfg.dblclickList['th'] = [function() { self.dialogTableProperties() }]; 
    7374} 
    7475 
     
    109110}; 
    110111 
     112TableOperations.prototype.getClosestMatch = function(regExpTagName) { 
     113  var editor = this.editor; 
     114  var ancestors = editor.getAllAncestors(); 
     115  var ret = null; 
     116   
     117  for (var i = 0; i < ancestors.length; ++i) { 
     118    var el = ancestors[i]; 
     119    if (el.tagName.toLowerCase().match(regExpTagName)) { 
     120      ret = el; 
     121      break; 
     122    } 
     123  } 
     124  return ret; 
     125}; 
    111126// this function gets called when some button from the TableOperations toolbar 
    112127// was pressed. 
     
    117132  // helper function that clears the content in a table row 
    118133  function clearRow(tr) { 
    119     var tds = tr.getElementsByTagName("td"); 
     134    var tds = tr.getElementsByTagName("td").append(tr.getElementsByTagName("th")); 
    120135    for (var i = tds.length; --i >= 0;) { 
    121136      var td = tds[i]; 
     
    266281    break; 
    267282  case "TO-row-split": 
    268     var td = this.getClosest("td"); 
     283    var td = this.getClosestMatch(/^(td|th)$/i); 
    269284    if (!td) { 
    270285      break; 
     
    277292  case "TO-col-insert-before": 
    278293  case "TO-col-insert-after": 
    279     var td = this.getClosest("td"); 
     294    var td = this.getClosestMatch(/^(td|th)$/i); 
    280295    if (!td) { 
    281296      break; 
     
    301316    break; 
    302317  case "TO-col-split": 
    303     var td = this.getClosest("td"); 
     318    var td = this.getClosestMatch(/^(td|th)$/i); 
    304319    if (!td) { 
    305320      break; 
     
    308323    break; 
    309324  case "TO-col-delete": 
    310     var td = this.getClosest("td"); 
     325    var td = this.getClosestMatch(/^(td|th)$/i); 
    311326    if (!td) { 
    312327      break; 
     
    332347 
    333348  case "TO-cell-split": 
    334     var td = this.getClosest("td"); 
     349    var td = this.getClosestMatch(/^(td|th)$/i); 
    335350    if (!td) { 
    336351      break; 
     
    340355  case "TO-cell-insert-before": 
    341356  case "TO-cell-insert-after": 
    342     var td = this.getClosest("td"); 
     357    var td = this.getClosestMatch(/^(td|th)$/i); 
    343358    if (!td) { 
    344359      break; 
     
    352367    break; 
    353368  case "TO-cell-delete": 
    354     var td = this.getClosest("td"); 
     369    var td = this.getClosestMatch(/^(td|th)$/i); 
    355370    if (!td) { 
    356371      break; 
     
    401416    } else { 
    402417      // Internet Explorer "browser" or not more than one cell selected in Moz 
    403       var td = this.getClosest("td"); 
     418      var td = this.getClosestMatch(/^(td|th)$/i); 
    404419      if (!td) { 
    405420        alert(Xinha._lc("Please click into some cell", "TableOperations")); 
     
    449464 
    450465  // COLS 
    451   ["col-insert-before", "td", "Insert column before"], 
    452   ["col-insert-after",  "td", "Insert column after"], 
    453   ["col-delete",        "td", "Delete column"], 
    454   ["col-split",         "td[colSpan!=1]", "Split column"], 
     466  ["col-insert-before", ["td","th"], "Insert column before"], 
     467  ["col-insert-after",  ["td","th"], "Insert column after"], 
     468  ["col-delete",        ["td","th"], "Delete column"], 
     469  ["col-split",         ["td[colSpan!=1]","th[colSpan!=1]"], "Split column"], 
    455470  null, 
    456471 
    457472  // CELLS 
    458   ["cell-prop",          "td", "Cell properties"], 
    459   ["cell-insert-before", "td", "Insert cell before"], 
    460   ["cell-insert-after",  "td", "Insert cell after"], 
    461   ["cell-delete",        "td", "Delete cell"], 
     473  ["cell-prop",          ["td","th"], "Cell properties"], 
     474  ["cell-insert-before", ["td","th"], "Insert cell before"], 
     475  ["cell-insert-after",  ["td","th"], "Insert cell after"], 
     476  ["cell-delete",        ["td","th"], "Delete cell"], 
    462477  ["cell-merge",         "tr", "Merge cells"], 
    463   ["cell-split",         "td[colSpan!=1,rowSpan!=1]", "Split cell"] 
     478  ["cell-split",         ["td[colSpan!=1,rowSpan!=1]","th[colSpan!=1,rowSpan!=1]"], "Split cell"] 
    464479]; 
    465480 
     
    605620TableOperations.prototype.dialogRowCellProperties = function(cell) { 
    606621  // retrieve existing values 
    607   var element = this.getClosest(cell ? "td" : "tr"); 
     622  var element = cell ? this.getClosestMatch(/^(td|th)$/i) : this.getClosest("tr"); 
    608623  var table = this.getClosest("table"); 
    609624 
Note: See TracChangeset for help on using the changeset viewer.