📄 htmlelement.jsc
字号:
# language: JSVM2
/** * Copyright (c) 2000 World Wide Web Consortium, * (Massachusetts Institute of Technology, Institut National de * Recherche en Informatique et en Automatique, Keio University). All * Rights Reserved. This program is distributed under the W3C's Software * Intellectual Property License. This program is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. * See W3C License http://www.w3.org/Consortium/Legal/ for more details. */
package org.w3c.dom.html;
import js.lang.BObject;
import js.util.HashMap;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
import org.w3c.dom.events.EventTarget;
class HTMLElement extends Element (tagName)
{
super.call(this, tagName);
EventTarget.call(this);
this.globalize();
this.__entity = null;
this.__builded = false;
}
/** * The element's identifier. See the id attribute definition in HTML 4.0. */HTMLElement.prototype.getId = function ()
{
return "_he_" + this.getUniqueId();
}
/** * The element's advisory title. See the title attribute definition in * HTML 4.0. */
HTMLElement.prototype.getTitle = function ()
{
return this.getEntity().title;
}
HTMLElement.prototype.setTitle = function (sTitle)
{
this.getEntity().title = sTitle;
}/** * The class attribute of the element. This attribute has been renamed * due to conflicts with the "class" keyword exposed by many languages. * See the class attribute definition in HTML 4.0. */
HTMLElement.prototype.getClassName = function ()
{
return this.getEntity().className;
}
HTMLElement.prototype.setClassName = function (sClassName)
{
this.getEntity().className = sClassName;
}
/**
* Override the insertBefore method of superclass
*/HTMLElement.prototype.insertBefore = function (newChild, refChild){
super.prototype.insertBefore.call(this, newChild, refChild); newChild.parent = this; return newChild;}/**
* Override the replaceChild method of superclass
*/HTMLElement.prototype.replaceChild = function (newChild, oldChild){ super.prototype.replaceChild.call(this, newChild, oldChild); oldChild.parent = null; newChild.parent = this; return oldChild;}/**
* Override the removeChild method of superclass
*/HTMLElement.prototype.removeChild = function (oldChild){ super.prototype.removeChild.call(this, oldChild); oldChild.__parentNode = null;
return oldChild;}/**
* Override the appendChild method of superclass
*/HTMLElement.prototype.appendChild = function (newChild){
super.prototype.appendChild.call(this, newChild); newChild.parent = this;
return newChild;
}
/**
*
*/
HTMLElement.prototype.getEntity = function ()
{
return (this.__entity != null) ?
this.__entity : this.createEntity();
}
/**
*
*/
HTMLElement.prototype.build = function (elmt)
{
if (this.__builded != true)
{
if (typeof(elmt) == "string")
{
elmt = document.getElementById(elmt);
}
elmt.appendChild(this.getEntity());
this.__builded = true;
}
}
/**
*
*/
var __htmlTag = "SPAN";
/**
* @private method
*/
HTMLElement.prototype.createEntity = function ()
{
try
{
if (this.__entity == null)
{
this.__entity = document.createElement(__htmlTag);
this.__entity.setAttribute("id", this.getId());
this.__entity.setAttribute("ownerHTMLElement", this);
}
return this.__entity;
}
catch (ex)
{
throw new DOMException(this.getClass().getName()
+ ".createEntity() error.", ex);
}
}
/**
* proxy methods
*/
HTMLElement.prototype.show = function ()
{
this.getEntity().style.display = "";
}
HTMLElement.prototype.hidden = function ()
{
this.getEntity().style.display = "none";
}
HTMLElement.prototype.focus = function ()
{
this.getEntity().focus();
}
HTMLElement.prototype.blur = function ()
{
this.getEntity().blur();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -