Changeset 921


Ignore:
Timestamp:
11/18/07 19:42:42 (6 years ago)
Author:
ray
Message:

#1105 [Enhancement][XinhaCore?] Convert all textareas in a document

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r920 r921  
    219219  if ( !textarea ) 
    220220  { 
    221     throw("Tried to create Xinha without textarea specified."); 
     221    throw new Error ("Tried to create Xinha without textarea specified."); 
    222222  } 
    223223 
     
    64336433 
    64346434  var editors = {}; 
     6435  var textarea; 
    64356436  for ( var x = 0; x < editor_names.length; x++ ) 
    64366437  { 
    6437     if ( typeof editor_names[x] != 'object' ) 
    6438     { 
    6439       var textarea = Xinha.getElementById('textarea', editor_names[x] ); 
    6440       if ( !textarea ) 
    6441           { 
    6442                 editor_names[x] = null; 
    6443                 continue; 
    6444           }  
     6438    if ( typeof editor_names[x] == 'string' ) // the regular case, an id of a textarea 
     6439    { 
     6440      textarea = Xinha.getElementById('textarea', editor_names[x] ); 
     6441      if (!textarea) // the id may be specified for a textarea that is maybe on another page; we simply skip it and go on 
     6442      { 
     6443        editor_names[x] = null; 
     6444        continue; 
     6445      } 
     6446    } 
     6447         // make it possible to pass a reference instead of an id, for example from  document.getElementsByTagName('textarea') 
     6448    else if ( typeof editor_names[x] == 'object' && editor_names[x].tagName && editor_names[x].tagName.toLowerCase() == 'textarea' ) 
     6449    { 
     6450      textarea =  editor_names[x]; 
     6451      if ( !textarea.id ) // we'd like to have the textarea have an id 
     6452      { 
     6453        textarea.id = 'xinha_id_' + x; 
     6454      }  
    64456455    } 
    64466456    var editor = new Xinha(textarea, Xinha.cloneObject(default_config)); 
    64476457    editor.registerPlugins(plugin_names); 
    6448     editors[editor_names[x]] = editor; 
     6458    editors[textarea.id] = editor; 
    64496459  } 
    64506460  return editors; 
Note: See TracChangeset for help on using the changeset viewer.