📄 application.js
字号:
{this.addState(oComp,"checked");changed=true;}
if("disabled"in hash&&!oComp.getEnabled())
{this.addState(oComp,"disabled");changed=true;}
if(changed)
this.applyAppearance(oComp);};_p.getAppearanceStates=function(sName)
{var t=this.getDefaultTheme();return t.getAppearanceStates(sName);};_p.getThemeStates=function(oComp)
{return oComp._themeStates;};_p.getCurrentState=function(oComp)
{return this._stateHash[oComp.toHashCode()];};_p.getHasInteractiveTheme=function(oComp)
{return Object.isEmpty(oComp._themeStates);};_p.getAppearanceTag=function(oComp)
{var app=oComp.getAppearance();var state=this._stateHash[oComp.toHashCode()];if(app)
return this._getAppearanceTag(app,state);return"";};_p._getAppearanceTag=function(sName,oStates)
{var s=" "+sName;for(var pseudo in oStates)
s+=" "+sName+"-"+pseudo;return s;};_p.applyAppearance=function(oComp)
{oComp.setHtmlProperty("className",oComp._cssClassName+this.getAppearanceTag(oComp));};_p.addState=function(oComp,sPseudo)
{var hc=oComp.toHashCode();if(!(hc in this._stateHash))
this._stateHash[hc]={};this._stateHash[hc][sPseudo]=true;};_p.removeState=function(oComp,sPseudo)
{var hc=oComp.toHashCode();if(hc in this._stateHash)
delete this._stateHash[hc][sPseudo];};_p.setStateValue=function(oComp,sPseudo,bAdd)
{if(bAdd)
this.addState(oComp,sPseudo);else this.removeState(oComp,sPseudo);};_p.addTheme=function(oTheme)
{var n=oTheme.getName();if(!(n in this._themes))
{this._themes[n]=oTheme;oTheme._create();if(oTheme.getName()==this._defaultThemeName)
{this._defaultThemeName="";this.setDefaultTheme(oTheme);}}
else if(this._themes[n]!=oTheme)
{throw new Error("Cannot add another theme with the same name: "+n);}};_p.removeTheme=function(oTheme)
{if(oTheme.getDefault())
oTheme.setDefault(false);delete this._themes[oTheme.getName()];}
_p.getThemes=function()
{var res=[];for(var n in this._themes)
res.push(this._themes[n]);return res;};_p.getDefaultTheme=function()
{if(this._defaultTheme)
return this._defaultTheme;return this._defaultTheme=this._themes[this._defaultThemeName];};_p.setDefaultTheme=function(oTheme)
{if(oTheme!=this._defaultTheme)
{this._setDefaultThemeByName(oTheme.getName());this.dispatchEvent(new BiEvent("themechanged"));}};_p._setDefaultThemeByName=function(sName)
{if(this._defaultThemeName!=sName)
{this._defaultThemeName=sName;if(sName in this._themes)
{var t=this._themes[sName];this._defaultTheme=t;for(var n in this._themes)
this._themes[n].setDefault(t==this._themes[n]);if(window.BiComponent&&BiComponent.invalidateAll)
BiComponent.invalidateAll();if(window.BiMenu&&BiMenu.invalidateAll)
BiMenu.invalidateAll();}}};_p.addCssRule=function(sSelector,sStyle)
{if(!sSelector||!sStyle)
{return;}
if(!this._sharedStyleSheet)
{this._sharedStyleSheet=BiThemeManager._createStyleElement();this._sharedStyleSheet.id="bi-theme-shared-style-sheet";}
var ss;if(BiBrowserCheck.ie)
{ss=document.styleSheets["bi-theme-shared-style-sheet"];ss.addRule(sSelector,sStyle);}
else {ss=this._sharedStyleSheet.sheet;ss.insertRule(sSelector+"{"+sStyle+"}",ss.cssRules.length);}};_p.removeCssRule=function(sSelector){if(sSelector==null||!this._sharedStyleSheet){return;}
var ss,rules,l,i;if(BiBrowserCheck.ie){ss=document.styleSheets["bi-theme-shared-style-sheet"];rules=ss.rules;l=rules.length;for(i=rules.length-1;i>=0;i--){if(rules[i].selectorText==sSelector){ss.removeRule(i);}}}else{ss=this._sharedStyleSheet.sheet;rules=ss.cssRules;l=rules.length;for(i=rules.length-1;i>=0;i--){if(rules[i].selectorText==sSelector){ss.deleteRule(i);}}}};BiThemeManager._createStyleElement=function(sCssText,sClassName)
{var el;if(BiBrowserCheck.ie)
{var ss=document.createStyleSheet();if(sCssText)
ss.cssText=sCssText;el=ss.owningElement;}
else {el=document.createElement("STYLE");el.type="text/css";el.appendChild(document.createTextNode(sCssText));var h=document.getElementsByTagName("HEAD")[0];h.appendChild(el);}
if(sClassName)
el.className=sClassName;return el;};BiThemeManager._createLinkElement=function(sName,oUri,sClassName)
{var uri=String(oUri);var el=document.createElement("link");el.type="text/css";el.rel="stylesheet";el.href=uri;var h=document.getElementsByTagName("HEAD")[0];h.appendChild(el);el.className=sClassName||"bi-theme-link";el.title=sName;el.disabled=false;return el;};_p._handleMouseDown=function(e)
{var c=e.getCurrentTarget();this._activeSet.add(c);this.addState(c,"active");this.applyAppearance(c);};_p._handleMouseUp=function(e)
{var changed=new BiSet;var active=this._activeSet.toArray();var c,i;for(i=0;i<active.length;i++)
{c=active[i];changed.add(c);this.removeState(c,"active");}
this._activeSet.clear();var changed2=changed.toArray();for(i=0;i<changed2.length;i++)
{if(!changed2[i]._disposed)
{this.applyAppearance(changed2[i]);}}
changed.dispose();};_p._handleMouseOver=function(e)
{var c=e.getCurrentTarget();this._hoverSet.add(c);this.addState(c,"hover");if(this._activeSet.contains(c))
{this.addState(c,"active");}
this.applyAppearance(c);};_p._handleMouseOut=function(e)
{var c=e.getCurrentTarget();this._hoverSet.remove(c);this.removeState(c,"active");this.removeState(c,"hover");this.applyAppearance(c);};_p._handleFocusIn=function(e)
{var c=e.getCurrentTarget();this.addState(c,"focus");this.applyAppearance(c);};_p._handleFocusOut=function(e)
{var c=e.getCurrentTarget();this.removeState(c,"focus");this.applyAppearance(c);};_p._handleChange=function(e)
{var c=e.getCurrentTarget();if(c.getChecked&&c.getChecked())
this.addState(c,"checked");else this.removeState(c,"checked");this.applyAppearance(c);};_p._handleEnabledChanged=function(e)
{var c=e.getCurrentTarget();if(c.getEnabled())
this.removeState(c,"disabled");else this.addState(c,"disabled");this.applyAppearance(c);};_p.dispose=function()
{if(this.getDisposed())
return;BiObject.prototype.dispose.call(this);this._sharedStyleSheet=null;};function BiTheme(sName)
{if(_biInPrototype)return;BiObject.call(this);this._appearances={};this._appearanceProperties={};if(sName)
this._name=sName;}
_p=_biExtend(BiTheme,BiObject,"BiTheme");_p._name="";_p._default=false;BiTheme.prototype.getName=function(){return this._name;};BiTheme.prototype.getDefault=function(){return this._default;};_p.setDefault=function(b)
{if(b!=this._default)
{this._default=b;if(this._created)
{if(BiBrowserCheck.ie)
{this._menuStyleEl.disabled=!b;if(b&&window.Menu&&window.Menu.prototype)
{Menu.prototype.cssText=this.getMenuCss();}}
this._linkEl.disabled=!b;}
if(b)
application.getThemeManager().setDefaultTheme(this);}
this._default=b;if(this._created)
this._linkEl.disabled=!b;};_p.addAppearance=function(sAppearanceName,oStates)
{var hash={};for(var i=0;i<oStates.length;i++)
hash[oStates[i]]=true;this._appearances[sAppearanceName]=hash;};_p.removeAppearance=function(sAppearanceName)
{delete this._appearances[sAppearanceName];};_p.getAppearanceStates=function(sName)
{return this._appearances[sName]||{};};_p.getAppearanceProperty=function(sName,sPropertyName)
{if(sName in this._appearanceProperties)
return this._appearanceProperties[sName][sPropertyName];return null;};_p.setAppearanceProperty=function(sName,sPropertyName,oValue)
{if(!(sName in this._appearanceProperties))
this._appearanceProperties[sName]={};this._appearanceProperties[sName][sPropertyName]=oValue;};_p._create=function()
{if(this._created)
return;this._linkEl=application.getAdf()._findLinkElement(this.getName());this._linkEl.disabled=!this.getDefault();if(BiBrowserCheck.ie)
{this._menuStyleEl=BiThemeManager._createStyleElement(this.getMenuCss());this._menuStyleEl.disabled=!this.getDefault();}
this._created=true;};_p.dispose=function()
{if(this.getDisposed())
return;BiObject.prototype.dispose.call(this);if(this._linkEl)
{this._linkEl.disabled=true;this._linkEl.onload=null;}
this._linkEl=null;if(this._menuStyleEl)
this._menuStyleEl.disabled=true;this._menuStyleEl=null;};BiTheme.prototype.getMenuCss=function(){return this._menuCss;};BiTheme.prototype.setMenuCss=function(v){this._menuCss=v;};function BiAdf()
{if(_biInPrototype)return;BiXmlLoader.call(this);this._async=true;this._caption="";this._scripts=[];this._linkEls={};this._xmlResourceParser=new BiXmlResourceParser;}
_p=_biExtend(BiAdf,BiXmlLoader,"BiAdf");_p._disposed=false;BiAdf.prototype.getCaption=function(){return this._caption;};BiAdf.prototype.setCaption=function(v){this._caption=v;};BiAdf.prototype.getXmlResourceParser=function(){return this._xmlResourceParser;};_p.setAutoNameMapping=function(b)
{if(this._autoNameMapping!=b)
{this._autoNameMapping=b;if(this._xmlResourceParser)
this._xmlResourceParser.setAutoNameMapping(b);var rl=application.getResourceLoader();if(rl)
rl.setAutoNameMapping(b);application.setAutoNameMapping(b);}};_p.getAutoNameMapping=function()
{return application.getAutoNameMapping();};_p._interpret=function()
{var doc=this.getDocument();var node=doc.selectSingleNode("/application/window/@caption | /Application/Window/@caption");if(node)
{this._caption=String(node.text);document.title=this._caption;}
var appEl=doc.documentElement;this._xmlResourceParser.processAttributes(application,appEl);application._themeManager=new BiThemeManager;this._insertThemeCss();this._createSplashScreen();};_p._addResources=function()
{var doc=this.getDocument();var rl=application.getResourceLoader();rl.setAutoNameMapping(this._autoNameMapping);var n=doc.selectSingleNode("/application/resources | /Application/Resources");if(n)
{var nl=n.childNodes;var l=nl.length;var uri;var systemRootPath=application.getPath();for(var i=0;i<l;i++)
{if(nl[i].nodeType!=1)
continue;uri=nl[i].getAttribute("uri")||nl[i].getAttribute("src");switch(nl[i].tagName)
{case"package":case"Package":if(uri)
rl.addResource("script",new BiUri(systemRootPath,uri));else if(nl[i].getAttribute("name"))
{var uris=application.getPackage(nl[i].getAttribute("name"));for(var j=0;j<uris.length;j++)
rl.addResource("script",new BiUri(systemRootPath,uris[j]));}
break;case"script":case"Script":if(uri)
rl.addResource("script",uri);else if(nl[i].text!="")
{rl.addResource("inlinescript",nl[i].text);}
break;default:rl.addResource(nl[i].tagName,nl[i],nl[i].getAttribute("id"));}}}};_p._createSplashScreen=function()
{application._loadStatus.setVisible(true);};_p.parseXmlResources=function()
{this._xmlResourceParser.setAutoNameMapping(this._autoNameMapping);var doc=this.getDocument();var windowEl=doc.selectSingleNode("/application/window | /Application/Window");if(!windowEl)
return;this._xmlResourceParser.setRootNode(windowEl);var win=application.getWindow();var adfAttrs=["left","right","top","bottom","width","height","centered","resizable","fullScreen"];var temp={};for(var i=0;i<adfAttrs.length;i++)
{if(windowEl.getAttributeNode(adfAttrs[i])!=null)
{temp[adfAttrs[i]]=windowEl.getAttribute(adfAttrs[i]);windowEl.removeAttribute(adfAttrs[i]);}}
this._xmlResourceParser.processAttributes(win,windowEl);this._xmlResourceParser.processChildNodes(win,windowEl);for(var attr in temp)
{windowEl.setAttribute(attr,temp[attr]);temp[attr]=null;}};_p._insertThemeCss=function()
{this._loadTheme("Default",true,new BiUri(application.getPath(),"themes/Default/theme.css"),new BiUri(application.getPath(),"themes/Default/theme.js"));var doc=this.getDocument();var themes=doc.selectNodes("/application/theme | /Application/Theme");for(var i=0;i<themes.length;i++)
{this._loadTheme(themes[i].getAttribute("name"),themes[i].getAttribute("default")=="true",themes[i].getAttribute("cssUri"),themes[i].getAttribute("jsUri"));}};_p._loadTheme=function(sName,bDefault,sCssUri,sJsUri)
{var rl=application.getResourceLoader();if(!sCssUri)
sCssUri=new BiUri(application.getPath(),"themes/"+sName+"/theme.css");else sCssUri=new BiUri(application.getAdfPath(),sCssUri);if(!sJsUri)
sJsUri=new BiUri(application.getPath(),"themes/"+sName+"/theme.js");else sJsUri=new BiUri(application.getAdfPath(),sJsUri);var linkEl=BiThemeManager._createLinkElement(sName,sCssUri);linkEl.disabled=!bDefault;this._linkEls[sName]=linkEl;rl.addResource("script",sJsUri);if(bDefault)
application.getThemeManager()._setDefaultThemeByName(sName);};_p._findLinkElement=function(sName)
{return this._linkEls[sName];};_p.dispose=function()
{if(this._disposed)
return;BiXmlLoader.prototype.dispose.call(this);for(var n in this._linkEls)
{delete this._linkEls[n];}};BiAdf.prototype._createSplashScreen=function()
{var doc=this.getDocument();var el=doc.selectSingleNode
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -