Changeset 1080 for trunk


Ignore:
Timestamp:
10/12/08 15:44:54 (11 years ago)
Author:
ray
Message:
  • #1303 add getElementsByClassName()
  • #1302 add Array.prototype.forEach for Browser that doesn't support it
  • new version of about box implemented as module using new dialogs
  • new version of dojo js compressor
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1079 r1080  
    10061006   "insert_table":  _editor_url + "modules/InsertTable/insert_table.html", 
    10071007   "select_color": _editor_url + "popups/select_color.html", 
    1008    "about": _editor_url + "popups/about.html", 
    10091008   "help": _editor_url + "popups/editor_help.html" 
    10101009  }; 
     
    10731072    print: [ "Print document", ["ed_buttons_main.gif",8,1], false, function(e) { if(Xinha.is_gecko) {e._iframe.contentWindow.print(); } else { e.focusEditor(); print(); } } ], 
    10741073    saveas: [ "Save as", "ed_saveas.gif", false, function(e) { e.execCommand("saveas",false,"noname.htm"); } ], 
    1075     about: [ "About this editor", ["ed_buttons_main.gif",8,2], true, function(e) { e.execCommand("about"); } ], 
     1074    about: [ "About this editor", ["ed_buttons_main.gif",8,2], true, function(e) { e.getPluginInstance("AboutBox").show(); } ], 
    10761075    showhelp: [ "Help using editor", ["ed_buttons_main.gif",9,2], true, function(e) { e.execCommand("showhelp"); } ], 
    10771076 
     
    21502149          else if ( typeof Xinha.getPluginConstructor('InsertTable') != 'undefined' && !this.plugins['InsertTable']) editor.registerPlugin('InsertTable'); 
    21512150        break; 
     2151        case "about": 
     2152          url = _editor_url + 'modules/AboutBox/AboutBox.js'; 
     2153          if ( !Xinha.loadPlugins([{plugin:"AboutBox",url:url}], function() { editor.generate(); } ) ) 
     2154          { 
     2155            return false; 
     2156          } 
     2157          else if ( typeof Xinha.getPluginConstructor('AboutBox') != 'undefined' && !this.plugins['AboutBox']) editor.registerPlugin('AboutBox'); 
     2158        break; 
    21522159      } 
    21532160    } 
     
    34613468{ 
    34623469  if ( !Xinha.isSupportedBrowser ) return; 
    3463   Xinha.setLoadingMessage (Xinha._lc("Loading plugins")); 
     3470  //Xinha.setLoadingMessage (Xinha._lc("Loading plugins")); 
    34643471  var m; 
    34653472  for (var i=0;i<plugins.length;i++) 
     
    47224729    break; 
    47234730 
    4724     case "about": 
    4725       this._popupDialog(editor.config.URIs.about, null, this); 
    4726     break; 
    4727  
    47284731    case "showhelp": 
    47294732      this._popupDialog(editor.config.URIs.help, null, this); 
     
    64216424  }; 
    64226425} 
     6426/** Executes a provided function once per array element 
     6427 * @source http://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Array/ForEach 
     6428 * @param {Function} fn Function to execute for each element 
     6429 * @param {Object} thisObject Object to use as this when executing callback.  
     6430 */ 
     6431if (!Array.prototype.forEach) 
     6432{ 
     6433  Array.prototype.forEach = function(fn /*, thisObject*/) 
     6434  { 
     6435    var len = this.length; 
     6436    if (typeof fn != "function") 
     6437      throw new TypeError(); 
     6438 
     6439    var thisObject = arguments[1]; 
     6440    for (var i = 0; i < len; i++) 
     6441    { 
     6442      if (i in this) 
     6443        fn.call(thisObject, this[i], i, this); 
     6444    } 
     6445  }; 
     6446} 
     6447Xinha.getElementsByClassName = function(el,className) 
     6448{ 
     6449  if (el.getElementsByClassName) 
     6450  { 
     6451    return Array.prototype.slice.call(el.getElementsByClassName(className)); 
     6452  } 
     6453  else 
     6454  { 
     6455    var els = el.getElementsByTagName('*'); 
     6456    var result = []; 
     6457    var classNames; 
     6458    for (var i=0;i<els.length;i++) 
     6459    { 
     6460      classNames = els[i].className.split(' '); 
     6461      if (classNames.contains(className)) result.push(els[i]); 
     6462    } 
     6463    return result; 
     6464  } 
     6465} 
     6466 
    64236467/** Returns true if all elements of <em>a2</em> are also contained in <em>a1</em> (at least I think this is what it does) 
    64246468* @param {Array} a1 
     
    73717415  Xinha.addDom0Event(window,'unload',Xinha.collectGarbageForIE); 
    73727416} 
    7373 /** Print some message to Firebug, Webkit, or Opera console 
     7417/** Print some message to Firebug, Webkit, Opera, or IE8 console 
    73747418 *  
    73757419 * @param {String} text 
  • trunk/modules/Dialogs/XinhaDialog.js

    r1075 r1080  
    159159  rootElem.appendChild(main); 
    160160  main.innerHTML = html; 
    161  
     161   
    162162  //make the first h1 to drag&drop the rootElem 
    163163  var captionBar = main.removeChild( main.getElementsByTagName("h1")[0]); 
     
    259259      bottom = "0px"; 
    260260      right= "0px"; 
     261      MozUserSelect = 'none'; 
    261262    } 
    262263    Xinha._addEvent(this.resizer, 'mousedown', function(ev) { dialog.resizeStart(ev); }); 
     
    513514  } 
    514515}; 
    515  
     516/** Equivalent to document.getElementById. You can't use document.getElementById because id's are dynamic to avoid id clashes between plugins 
     517 * @type {Element} 
     518 * @param {String} id 
     519 */ 
    516520Xinha.Dialog.prototype.getElementById = function(id) 
    517521{ 
    518522  return this.document.getElementById(this.id[id] ? this.id[id] : id); 
    519523}; 
    520  
     524/** Equivalent to document.getElementByName. You can't use document.getElementByName because names are dynamic to avoid name clashes between plugins 
     525 * @type {Array} 
     526 * @param {String} name 
     527 */ 
    521528Xinha.Dialog.prototype.getElementsByName = function(name) 
    522529{ 
    523   return this.document.getElementsByName(this.id[name] ? this.id[name] : name); 
     530  var els = this.document.getElementsByName(this.id[name] ? this.id[name] : name);  
     531  return els.length ? Array.prototype.slice.call(els) : []; //Collection to Array 
     532}; 
     533/** Return all elements in the dialog that have the given class 
     534 * @type {Array}  
     535 * @param {String} className 
     536 */ 
     537Xinha.Dialog.prototype.getElementsByClassName = function(className) 
     538{ 
     539  return Xinha.getElementsByClassName(this.rootElem,className); 
    524540}; 
    525541 
Note: See TracChangeset for help on using the changeset viewer.