Changeset 1075 for trunk


Ignore:
Timestamp:
10/09/08 22:02:30 (10 years ago)
Author:
nicholasbs
Message:

UPDATES #1283 (new-dialogs version of TableOperations? is incomplete)
ids/names are now properly added to the dialog reverse lookup table

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/Dialogs/XinhaDialog.js

    r1058 r1075  
    10381038    function(fullString, id) 
    10391039    { 
    1040       if(typeof dialog.id[id] == 'undefined') 
    1041       { 
    1042         dialog.id[id] = Xinha.uniq('Dialog'); 
    1043         dialog.r_id[dialog.id[id]] = id; 
    1044       } 
    1045       return dialog.id[id]; 
     1040      return dialog.createId(id); 
    10461041    } 
    10471042    ).replace(/<l10n>(.*?)<\/l10n>/ig, 
     
    10581053  return html; 
    10591054} 
     1055 
     1056/** Use this function when adding an element with a new ID/name to a  
     1057 *  dialog after it has already been created. This function ensures 
     1058 *  that the dialog has the id/name stored in its reverse-lookup table 
     1059 *  (which is required for form values to be properly returned by 
     1060 *  Xinha.Dialog.hide). 
     1061 *  
     1062 * @param {id} the id (or name) to add  
     1063 * 
     1064 * Returns the internal ID to which the passed in ID maps 
     1065 * 
     1066 * TODO: createId is a really awful name, but I can't think of anything better... 
     1067 */ 
     1068Xinha.Dialog.prototype.createId = function(id) 
     1069{ 
     1070  var dialog = this; 
     1071  if (typeof dialog.id[id] == 'undefined') 
     1072  { 
     1073    dialog.id[id] = Xinha.uniq('Dialog'); 
     1074    dialog.r_id[dialog.id[id]] = id; 
     1075  } 
     1076  return dialog.id[id]; 
     1077}; 
    10601078 
    10611079/** When several modeless dialogs are shown, one can be brought to front with this function (as happens on mouseclick)  
  • trunk/modules/InlineStyler/InlineStyler.js

    r1065 r1075  
    1 Xinha.InlineStyler = function(element, editor, doc) 
     1Xinha.InlineStyler = function(element, editor, dialog, doc) 
    22{ 
    33  this.element = element; 
    44  this.editor = editor; 
     5  this.dialog = dialog; 
    56  this.doc = doc ? doc : document; 
    67  this.inputs = { 
     
    3233    if (typeof params[i] == 'function')  
    3334      continue; 
    34     var val = params[i].value; 
     35    if (params[i] != null) 
     36      var val = params[i].value || params[i]; 
     37 
    3538    switch (i) 
    3639    { 
     
    4649      break; 
    4750    case "borderCollapse": 
    48       style.borderCollapse =  params[i].checked ? "collapse" : ""; 
     51      style.borderCollapse = params[i] == "on" ? "collapse" : "separate"; 
    4952      break; 
    5053    case "width": 
     
    109112      break; 
    110113    case "borderWidth": 
    111       var borderWidthUnit = this.inputs.aux["heightUnit"].value; 
    112       style[i] = val + (borderWidthUnit) ? borderWidthUnit : 'px'; 
    113       break; 
    114     default: 
     114      style[i] = val + "px"; 
     115      break; 
     116    default:       
    115117      style[i] = val; 
    116118      break; 
     
    155157    tr.appendChild(td); 
    156158    select = doc.createElement("select"); 
     159    select.name = this.dialog.createId("float"); 
    157160    td.appendChild(select); 
    158161    this.inputs.styles['float'] = select; 
     
    185188  tr.appendChild(td); 
    186189  input = doc.createElement("input"); 
     190  input.name = this.dialog.createId("width"); 
    187191  input.type = "text"; 
    188192  input.value = Xinha.InlineStyler.getLength(el.style.width); 
     
    192196  td.appendChild(input); 
    193197  select = doc.createElement("select"); 
     198  select.name = this.dialog.createId("widthUnit"); 
    194199  this.inputs.aux['widthUnit'] = select; 
    195200  option = doc.createElement("option"); 
     
    208213  td.appendChild(doc.createTextNode(Xinha._lc("Text align", "TableOperations") + ":")); 
    209214  select = doc.createElement("select"); 
     215  select.name = this.dialog.createId("textAlign"); 
    210216  select.style.marginLeft = select.style.marginRight = "0.5em"; 
    211217  td.appendChild(select); 
     
    218224  input = doc.createElement("input"); 
    219225  this.inputs.aux['textAlignChar'] = input; 
    220   input.name= 'fuck'; 
     226  input.name= this.dialog.createId("textAlignChar"); 
    221227  input.size = "1"; 
    222228  input.style.fontFamily = "monospace"; 
     
    258264  tr.appendChild(td); 
    259265  input = doc.createElement("input"); 
     266  input.name = this.dialog.createId("height"); 
    260267  input.type = "text"; 
    261268  input.value = Xinha.InlineStyler.getLength(el.style.height); 
     
    265272  td.appendChild(input); 
    266273  select = doc.createElement("select"); 
     274  select.name = this.dialog.createId("heightUnit"); 
    267275  this.inputs.aux['heightUnit'] = select; 
    268276  option = doc.createElement("option"); 
     
    281289  td.appendChild(doc.createTextNode(Xinha._lc("Vertical align", "TableOperations") + ":")); 
    282290  select = doc.createElement("select"); 
     291  select.name = this.dialog.createId("verticalAlign"); 
    283292  this.inputs.styles['verticalAlign'] = select; 
    284293  select.style.marginLeft = "0.5em"; 
     
    330339 
    331340  input = doc.createElement("input"); 
     341  input.name = this.dialog.createId("backgroundColor"); 
    332342  input.value = Xinha._colorToRgb( el.style.backgroundColor ); 
    333343  input.type = "hidden"; 
     
    337347  new Xinha.colorPicker.InputBinding(input) 
    338348   
    339   td.appendChild(doc.createTextNode(Xinha._lc("Image URL", "TableOperations") + ": ")); 
    340   input = doc.createElement("input"); 
     349  td.appendChild(doc.createTextNode(" " + Xinha._lc("Image URL", "TableOperations") + ": ")); 
     350  input = doc.createElement("input"); 
     351  input.name = this.dialog.createId("backgroundImage"); 
    341352  input.type = "text"; 
    342353  this.inputs.styles['backgroundImage'] = input; 
    343   if (el.style.backgroundImage.match(/url\(\s*(.*?)\s*\)/))  
    344   { 
     354  if (el.style.backgroundImage.match(/url\(\s*(.*?)\s*\)/)) 
    345355    input.value = RegExp.$1; 
    346   } 
    347356  // input.style.width = "100%"; 
    348357  td.appendChild(input); 
     
    357366  tr.appendChild(td); 
    358367  input = doc.createElement("input"); 
     368  input.name = this.dialog.createId("color"); 
    359369  input.value = Xinha._colorToRgb( el.style.color ); 
    360370  input.type = "hidden"; 
     
    379389  tr.appendChild(td); 
    380390  input = doc.createElement("input"); 
     391  input.name = this.dialog.createId("borderColor"); 
    381392  input.value = Xinha._colorToRgb( el.style.borderColor ); 
    382393  input.type = "hidden"; 
     
    387398   
    388399  select = doc.createElement("select"); 
     400  select.name = this.dialog.createId("borderStyle"); 
    389401  var borderFields = []; 
    390402  td.appendChild(select); 
     
    424436   
    425437  input = doc.createElement("input"); 
     438  input.name = this.dialog.createId("borderWidth"); 
    426439  borderFields.push(input); 
    427440  input.type = "text"; 
     
    447460    tr.appendChild(td); 
    448461    input = doc.createElement("input"); 
     462    input.name = this.dialog.createId("borderCollapse"); 
    449463    input.type = "checkbox"; 
    450464    this.inputs.styles['borderCollapse'] = input; 
  • trunk/plugins/TableOperations/TableOperations.js

    r1067 r1075  
    503503  var dialog = this.dialogTable; 
    504504   
    505   var Styler = new Xinha.InlineStyler(table, this.editor); 
     505  var Styler = new Xinha.InlineStyler(table, this.editor, dialog); 
    506506   
    507507  function apply() { 
     
    512512      if(typeof params[i] == 'function') continue; 
    513513      var val = params[i]; 
    514       if (typeof val == 'object' && val.tagName) val = val.value; 
     514      //if (val == null) continue; 
     515      if (typeof val == 'object' && val != null && val.tagName) val = val.value; 
    515516      switch (i) { 
    516517      case "caption": 
     
    619620  var dialog = this.dialogRowCell; 
    620621  dialog.getElementById('title').innerHTML = cell ? Xinha._lc("Cell Properties", "TableOperations") : Xinha._lc("Row Properties", "TableOperations"); 
    621   var Styler = new Xinha.InlineStyler(element, self.editor); 
     622  var Styler = new Xinha.InlineStyler(element, self.editor, dialog); 
    622623   
    623624  function apply() { 
    624625    var params = dialog.hide(); 
    625     Styler.applyStyle(); 
     626    Styler.applyStyle(params); 
    626627     
    627628    // various workarounds to refresh the table display (Gecko, 
Note: See TracChangeset for help on using the changeset viewer.