Subversion Repositories wimsdev

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.         DynAPI Distribution
  3.         HTMLHyperLink Class
  4.  
  5.         The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
  6.        
  7.         Requires: HTMLComponent
  8. */
  9.  
  10. function HTMLHyperLink(css,text,url,title){
  11.         this.HTMLComponent = HTMLComponent;
  12.         this.HTMLComponent(css);
  13.        
  14.         this.url=url;
  15.         this._text=text;
  16.         this._title=title;
  17. };
  18. var p = dynapi.setPrototype('HTMLHyperLink','HTMLComponent');
  19. p._assignElm = function(elm){
  20.         if(!this.parent) return;
  21.         else if(!this.parent._created) return;
  22.         var doc=this.parent.doc;
  23.         if(elm) elm;
  24.         else if(dynapi.ua.ie) elm=doc.all[this.id];
  25.         else if(dynapi.ua.dom) elm=doc.getElementById(this.id);
  26.         else {
  27.                 for(i=0;i<doc.links.length;i++){
  28.                         elm=doc.links[i];
  29.                         if(elm.name==this.id) break;
  30.                         elm=null;
  31.                 }
  32.         };
  33.         if(!elm) return;
  34.         this.elm = elm;
  35.         this.css = (dynapi.ua.ns4)? elm:elm.style;
  36.         this.doc = this.parent.doc; //??
  37. };
  38. p.getInnerHTML = function(){
  39.         var evt = this._generateInlineEvents(this);
  40.         var url=this.url||'javascript:;';
  41.         return [
  42.                 '<a class="',this._class,'" id="',this.id,'" name="',this.id,'" href="',url,'" ',
  43.                 evt,' title="',this._title,'">',this._text,'</a>'
  44.         ].join('');
  45. };
  46. p.setText = function(t) {
  47.         var elm = this.getElm();
  48.         if(elm){
  49.                 if(dynapi.ua.ns4) elm.text = t; // not supported in ns4?
  50.                 else elm.innerHTML=t;
  51.         }
  52. };
  53. p.getURL = function(){
  54.         var url='',elm = this.getElm();
  55.         if(elm) url=elm.href;
  56.         return url;
  57. };
  58. p.setURL = function(url){
  59.         url=(url!=null)? url:'javascript:;';
  60.         var elm = this.getElm();
  61.         if(elm) elm.href=url;  
  62. };