📄 decorator.js
字号:
/**
* 装饰器基类
* @public
* @param <HTMLElement> ele HTML元素.如 <d:code language='JScript'>....</d:code>
*/
function Decorator(ele){
}
Decorator.prototype.parent = null;
Decorator.prototype.children = null;
Decorator.prototype.getContainer = function(){
return document.getElementById(this.id);
}
Decorator.prototype.before = function(){
//$JSI.addComponent(this.id,this);
}
Decorator.prototype.decorate = function(){
}
Decorator.prototype.dispose = function(){
}
//判断是否需要装饰该网页
var declared = null;
var ua = navigator.userAgent;
var dns = "http://www.xidea.org/taglib/decorator";
function detectFromAttribute(){
var ns = document.documentElement.getAttribute("xmlns:d");
if(ns){
if(ns == dns){
return true;
}else{
$log.info("发现Decorator保留前缀d被占用",ns);
return false;
}
}else{
return false;
}
}
function detectFromOuterHTML(){
var str = document.documentElement.outerHTML;
//str = str.substring(5,str.indexOf('>'));
//\s*(('[^']')|("[^"]")|([^'"\r\n]*))
//var p = /xmlns(\:)?\s*=?/g;//需要兼容ie5正则表达式
return str.indexOf(dns)>0;
}
if(ua.indexOf(" MSIE ")>0){//for ie and opera
var ns = document.namespaces;
if(ns){//for ie 5.5+
declared = false;
for(var i = ns.length-1;i>=0;i--){
if(ns.item(i).name.toLowerCase() == 'd'){
if(ns.item(i).urn == dns){
declared = true;
}else{
$log.info("发现Decorator保留前缀d被占用",ns.item(i).urn);
}
break;
}
}
}else{//for ie5 or opera
declared = detectFromOuterHTML();
}
if(declared && ua.indexOf(" Opera ")<0){
document.write("<style>d\\:*{behavior:url("+$package.scriptBase+"decorator.htc)}</style>");
}
}else if(ua.indexOf("Gecko/") > 0){//all? not sure!!!
declared = detectFromAttribute();
}else if(detectFromAttribute()){
declared = true;
}else if(document.documentElement.outerHTML){
declared = detectFromOuterHTML();
}else{
declared = null;
}
//$JSI.setAttribute("decoratorDeclared",declared);
/**
* 是否申明了装饰用的名称空间
* xmlns:d = "http://www.xidea.org/taglib/decorator"
* @public
* @readonly
*/
Decorator.declared = declared;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -