📄 igf_ui.js
字号:
else{var dv=ig.ui.getDocument().defaultView;if(!ig.isNull(dv)){var cs=dv.getComputedStyle(this.elm,"");if(!ig.isNull(cs)){result=cs.getPropertyValue(p);}}
else{if(this.elm.style.getPropertyValue){result=this.elm.style.getPropertyValue(p);}}}}}
return result;};IgDomNode.prototype.getStyleAsFloat=function(propName){return ig.toFloat(this.getStyle(propName));};IgDomNode.prototype.getStyleInline=function(p){var r=null;if(ig.NaES(p)){var pc=ig.camelize(p);r=this.elm.style[pc];}
return r;};IgDomNode.prototype.getDragMode=function(){var r=null;var p=ig.findAncestor(this.elm.parentNode,ig.PROP_TYPE,null,null);if(!ig.isNull(p)){r=p.getAttribute(ig.ui.PROP_DRAG_MODE);}
if(ig.isNull(r)){r=this.getAttribute(ig.ui.PROP_DRAG_MODE);}
if(ig.isNull(r)){r=ig.ui.DRAG_MODE_DRAG;}
return r;};IgDomNode.prototype.getResizeMode=function(left,bottom,right,top){return 0;};IgDomNode.prototype.doResizeBegin=function(){};IgDomNode.prototype.doResizeMove=function(evt){};IgDomNode.prototype.doResizeEnd=function(evt){};IgDomNode.prototype.deleteDragShadow=function(){var ds=this.getDragShadow();if(!ig.isNull(ds)){ds.removeNode();ds=null;this.elm.oddds=null;}};IgDomNode.prototype.getCompatMode=function(){var r=ig.ui.COMPAT_CSS1;if((ig.isIE)||(ig.isOpera)){var cm=ig.ui.getDocument()["compatMode"];if((cm=="BackCompat")||(cm=="QuirksMode")){r=ig.ui.COMPAT_BACK;}}
return r;};IgDomNode.prototype.getBoxingModel=function(){var r=ig.ui.BOX_CONTENT;if((ig.isIE)||(ig.isOpera)){if(this.getCompatMode()==ig.ui.COMPAT_BACK){r=ig.ui.BOX_BORDER;}}
else{r=this.getStyle("-moz-box-sizing");if(!ig.NaES(r)){r=this.getStyle("box-sizing");}
if(ig.NaES(r)){r=ig.ui.toBoxingModelIndex(r);}}
return r;};IgDomNode.prototype.getDragShadow=function(){var r=this.elm.oddds;if(!ig.isNull(r)){r=new IgPopup(r);}
return r;};IgDomNode.prototype.getMaxHeight=function(){var result=0;var tmpDisplay=this.getStyleInline("display");this.setStyle("display","block");var tmpVisibility=this.getStyleInline("visibility");this.setStyle("visibility","");var tmpHeight=this.getStyleInline("height");this.setStyle("height","");result=this.getHeight();this.setStyle("display",tmpDisplay);this.setStyle("visibility",tmpVisibility);this.setStyle("height",tmpHeight);return result;};IgDomNode.prototype.getOriginalCssProperty=function(propName){return this.getAttribute(propName);};IgDomNode.prototype.getOuterHtml=function(){var r=this.elm.outerHTML;if(!ig.NaES(r)){r="<"+this.elm.nodeName+" class='"+this.elm.className+"'>";r=r+this.elm.innerHTML+"</"+this.elm.nodeName+">";}
return r;};IgDomNode.prototype.getFirstChild=function(){var r=null;var childNodes=this.elm.childNodes;for(var i=0;i<childNodes.length;i++){if(childNodes[i].tagName){r=childNodes[i];break;}}
return ig.getUIElementById(r);};IgDomNode.prototype.getFirstTextElement=function(){var r=null;var childNodes=this.elm.childNodes;for(var i=0;i<childNodes.length;i++){var c=childNodes[i];if(!c.tagName){return c;}else{var t=ig.getUIElementById(c).getFirstTextElement();if(t!=null)
return t;}}
return null;};IgDomNode.prototype.getFirstLeaf=function(){var node=this.elm;while(node.firstChild!=null&&node.firstChild.tagName){node=node.firstChild}
return node;};IgDomNode.prototype.getForm=function(){return ig.findAncestor(this.elm,null,null,"FORM");};IgDomNode.prototype.getHeight=function(){return this.elm.offsetHeight;};IgDomNode.prototype.getId=function(){return this.elm.id;};IgDomNode.prototype.getMargin=function(w){var s=0;if(ig.NaES(w)){if(w=="width"){s=this.getMargin("left")+this.getMargin("right");}
else if(w=="height"){s=this.getMargin("top")+this.getMargin("bottom");}
else{w="margin-"+w;s=this.getStyleAsFloat(w);}}
return s;};IgDomNode.prototype.getLastChild=function(){var r=null;var childNodes=this.elm.childNodes;for(var i=childNodes.length-1;i>=0;i--){if(childNodes[i].tagName){r=childNodes[i];break;}}
return ig.getUIElementById(r);};IgDomNode.prototype.getPosition=function(){return{x:this.getStyleAsFloat("left"),y:this.getStyleAsFloat("top")};};IgDomNode.prototype.getOpacity=function(){var result=this.getStyleAsFloat("opacity");if(result==0){result=1.0;}
return result;};IgDomNode.prototype.getPadding=function(w){var s=0;if(ig.NaES(w)){if(w=="width"){s=this.getPadding("left")+this.getPadding("right");}
else if(w=="height"){s=this.getPadding("top")+this.getPadding("bottom");}
else{w="padding-"+w;s=this.getStyleAsFloat(w);}}
return s;};IgDomNode.prototype.getPagePosition=function(){var rect=new IgRect(0,0,0,0);var elm=this.elm;if(!ig.isNull(elm)){var curElm=elm;while(!ig.isNull(curElm)){rect.x=rect.x+curElm.offsetLeft;rect.y=rect.y+curElm.offsetTop;curElm=curElm.offsetParent;}
var sp=this.getScroll(true);rect.x=rect.x-sp.x;rect.y=rect.y-sp.y;}
return rect;};IgDomNode.prototype.getProperty=function(propName){var result=null;if(ig.NaES(propName)){var tmp="this.get"+ig.ucase(propName)+"()";result=eval(tmp);}
return result;};IgDomNode.prototype.getScroll=function(bu){var p={x:0,y:0};var curElm=this.elm;while(curElm&&curElm.nodeName!="BODY"&&curElm.nodeName!="HTML"){if(curElm.style["position"]=="fixed"){break;}
p.x+=curElm.scrollLeft;p.y+=curElm.scrollTop;curElm=curElm.parentNode;if(!(bu===true)){curElm=null;}}
return p;};IgDomNode.prototype.getSize=function(){var r={width:this.elm.offsetWidth,height:this.elm.offsetHeight};return r;};IgDomNode.prototype.getType=function(){return ig.getType(this);};IgDomNode.prototype.getWidth=function(){return this.elm.offsetWidth;};IgDomNode.prototype.hide=function(rs){if(this.getStyleInline("visibility")!="hidden"){this.setStyle("visibility","hidden");}
if(rs===true){if(this.getStyleInline("display")!="none"){this.setStyle("display","none");}}};IgDomNode.prototype.hideDropCaret=function(){};IgDomNode.prototype.isAncestor=function(n){var res=false;if(!ig.isNull(n)){var tmp=n.elm;while(!ig.isNull(tmp)){if(tmp==this.elm){res=true;break;}
tmp=tmp.parentNode;}}
return res;};IgDomNode.prototype.isDraggable=function(){return(this.getAttribute(ig.ui.PROP_DRAGGABLE)=="true");};IgDomNode.prototype.isDraggableViaHandle=function(){return(this.getAttribute(ig.ui.PROP_DRAGGABLE_VIA_HANDLE)=="true");};IgDomNode.prototype.isDragHandle=function(){return(this.getAttribute(ig.ui.PROP_DRAG_HANDLE)=="true");};IgDomNode.prototype.isDragSourceAccepted=function(dragSources){return false;};IgDomNode.prototype.isEnabled=function(){return(this.getAttribute(ig.PROP_DISABLED)!="true");};IgDomNode.prototype.isResizable=function(){return(this.getAttribute(ig.ui.PROP_RESIZABLE,false,"")=="true");};IgDomNode.prototype.isVisible=function(){return!(this.getStyleInline("visibility")=="hidden"||this.getStyleInline("display")=="none");};IgDomNode.prototype.makeMovable=function(){var p=this.getStyle("position");if(p=="static"){this.setStyle("position","absolute");}};IgDomNode.prototype.moveBy=function(xo,yo){if(ig.isNumber(xo)){xo=xo!=0?xo+this.getStyleAsFloat("left"):null;}
if(ig.isNumber(yo)){yo=yo!=0?yo+this.getStyleAsFloat("top"):null;}
this.setPosition(xo,yo);};IgDomNode.prototype.moveTo=function(x,y){if(ig.isNumber(x)||ig.isNumber(y)){this.makeMovable();this.setStyle("display","");var cx=this.getStyleAsFloat("left");var cy=this.getStyleAsFloat("top");this.setPosition(cx,cy);var curPos=this.getPagePosition();if(ig.isNumber(x)){x=x-curPos.x;}
if(ig.isNumber(y)){y=y-curPos.y;}
this.moveBy(x,y);}};IgDomNode.prototype.onClick=function(){this.click();};IgDomNode.prototype.onDoubleClick=function(){};IgDomNode.prototype.onDragStart=function(dea){var pos=this.getPagePosition();if(ig.ui.dragMode===ig.ui.DRAG_MODE_MOVE){this.moveTo(pos.x,pos.y);}
else{var ds=this.createDragShadow();ds.show(ig.ui.x+10,pos.y);}};IgDomNode.prototype.onDrag=function(){var dx=ig.ui.x-ig.ui.lastX;var dy=ig.ui.y-ig.ui.lastY;if(ig.ui.dragMode===ig.ui.DRAG_MODE_MOVE){var p=this.getPosition();this.moveBy(dx,dy);}
else{var ds=this.getDragShadow();if(!ig.isNull(ds)){var p=ds.getPosition();ds.moveBy(dx,dy);}}};IgDomNode.prototype.onDragEnd=function(dea){this.deleteDragShadow();};IgDomNode.prototype.onDragEnter=function(dea){this.showDropCaret(dea);};IgDomNode.prototype.onDragOver=function(dea){};IgDomNode.prototype.onDragLeave=function(dea){this.hideDropCaret();};IgDomNode.prototype.onDrop=function(dea,dragSources){if(!ig.isNull(dragSources)){for(var i=0;i<dragSources.size();i++){var n=dragSources.get(i);this.elm.appendChild(n);}}};IgDomNode.prototype.onKeyDown=function(e){var c=this.getParentComponent();if(!ig.isNull(c)){c.onKeyDown(e);}};IgDomNode.prototype.onKeyPress=function(e){var c=this.getParentComponent();if(!ig.isNull(c)){c.onKeyPress(e);}};IgDomNode.prototype.onMouseEnter=function(){ig.ui.setHoveredElement(this);};IgDomNode.prototype.onMouseLeave=function(){ig.ui.setHoveredElement(null);};IgDomNode.prototype.onScroll=function(){};IgDomNode.prototype.removeNode=function(){if(this.elm.parentNode){this.elm.parentNode.removeChild(this.elm);}
else{ig.ui.getDocumentBody().removeChild(this.elm);}
this.elm=null;};IgDomNode.prototype.setAttribute=function(n,v){return ig.setAttribute(this.elm,n,v);};IgDomNode.prototype.setCursor=function(v){this.setStyle("cursor",v);};IgDomNode.prototype.setPosition=function(x,y){this.makeMovable();if(ig.isNumber(x)){this.setStyle("left",x+"px");}
if(ig.isNumber(y)){this.setStyle("top",y+"px");}};IgDomNode.prototype.setProperty=function(propName,propValue){var result=null;if(ig.NaES(propName)&&!ig.isNull(propValue)){var tmp="this.set"+ig.ucase(propName)+"("+propValue+")";result=eval(tmp);}
return result;};IgDomNode.prototype.setType=function(type){this.setAttribute(this.elm,ig.PROP_TYPE,type);};IgDomNode.prototype.setOpacity=function(o){var t=Math.max(0,Math.min(o,1));this.setStyle("filter","alpha(opacity:"+Math.round(t*100)+")");this.setStyle("opacity",t);};IgDomNode.prototype.setSize=function(w,h,dnabm){var r=new IgRect(0,0,w,h);if(dnabm!=true){this.convertBoxCoordinates(r);}
if(ig.isIE){if(this.getCompatMode()==ig.ui.COMPAT_BACK){if(this.elm.nodeName=="TD"||this.elm.nodeName=="COL"){r.width=r.width-this.getMargin("left")-this.getMargin("right");r.width=r.width-this.getBorder("left")-this.getBorder("right");r.width=r.width-this.getPadding("left")-this.getPadding("right");}else if(this.elm.nodeName=="IMG"){r.width=r.width-this.getBorder("left")-this.getBorder("right");r.height=r.height-this.getBorder("top")-this.getBorder("bottom");}}else{if(this.elm.nodeName=="COL"){r.width=r.width-this.getMargin("left")-this.getMargin("right");r.width=r.width-this.getBorder("left")-this.getBorder("right");r.width=r.width-this.getPadding("left")-this.getPadding("right");}else if(this.elm.nodeName=="TR"||this.elm.nodeName=="TD"||this.elm.nodeName=="TH"||this.elm.nodeName=="TABLE"){r.height=r.height-this.getBorder("bottom")-this.getBorder("top");r.height=r.height-this.getPadding("top")-this.getPadding("bottom");}}}else if(ig.isMozilla){if(this.elm.nodeName=="TD"){r.height=r.height+this.getBorder("top")+this.getBorder("bottom");r.height=r.height+this.getPadding("top")+this.getPadding("bottom");}else if(this.elm.nodeName=="COL"){r.width=r.width-this.getMargin("left")-this.getMargin("right");r.width=r.width-this.getBorder("left")-this.getBorder("right");r.width=r.width-this.getPadding("left")-this.getPadding("right");}else if(this.elm.nodeName=="TR"){r.height=r.height+this.getBorder("top")+this.getBorder("bottom");r.height=r.height+this.getPadding("top")+this.getPadding("bottom");}}else if(ig.isOpera)
{if(this.elm.nodeName=="DIV")
{r.width=r.width+6;}}
if(ig.isNumber(w)){if(r.width>=0){this.elm.style["width"]=r.width+"px";}}
if(ig.isNumber(h)){if(r.height>=0){this.elm.style["height"]=r.height+"px";}}};IgDomNode.prototype.setStyle=function(sn,sv){if(ig.NaES(sn)&&!ig.isNull(sv)){sn=ig.camelize(sn);this.elm.style[sn]=sv+"";}};IgDomNode.prototype.show=function(x,y,x2,y2){if(ig.isNumber(x)||ig.isNumber(y)){var w=this.getWidth();var sl=ig.getScrollLeft();var cw=ig.getClientWidth();var h=this.getHeight();var ch=ig.getClientHeight();var st=ig.getScrollTop();this.moveTo(x,y);}
if(this.getStyleInline("visibility")!="visible"){this.setStyle("visibility","visible");}
if(ig.NaES(this.getStyleInline("display"))){this.setStyle("display","");}};IgDomNode.prototype.showDropCaret=function(){};IgDomNode.prototype.convertBoxCoordinates=function(rect,sbm,tbm){if(ig.isNull(sbm)){sbm=ig.ui.BOX_BORDER;}
if(ig.isNull(tbm)){tbm=this.getBoxingModel();}
if(!ig.isNull(rect)&&sbm!=tbm&&sbm>=ig.ui.BOX_MARGIN&&sbm<=ig.ui.BOX_CONTENT&&tbm>=ig.ui.BOX_MARGIN&&tbm<=ig.ui.BOX_CONTENT){if(tbm>sbm){var fp=[this.getMargin,this.getBorder,this.getPadding];for(var i=sbm;i<tbm;i++){rect.x=rect.x+fp[i].call(this,"left");rect.y=rect.y+fp[i].call(this,"top");rect.width=rect.width-fp[i].call(this,"width");rect.height=rect.height-fp[i].call(this,"height");}}
else{var fp=[this.getMargin,this.getBorder,this.getPadding];for(var i=sbm-1;i>=tbm;i--){rect.x=rect.x-fp[i].call(this,"left");rect.y=rect.y-fp[i].call(this,"top");rect.width=rect.width+fp[i].call(this,"width");rect.height=rect.height+fp[i].call(this,"height");}}}};IgDomNode.prototype.get_element=function(){return this.elm;}
function IgUIElement(e){this.IgDomNode(e);};IgUIElement.prototype.applyClass=function(){var css=this.getClass();if(ig.isString(css)){if(this.elm.className!=css){this.elm.className=css;}}};IgUIElement.prototype.updateCursor=function(){if(!this.isEnabled()){return;}
if(!this.isHovered()){return;}
if(ig.ui.state==ig.ui.STATE_IDLE){if(this.equals(ig.ui.resizeTarget)){document.body.style.cursor=ig.ui.getResizeCursor(ig.ui.resizeMode);return;}
if(this.equals(ig.ui.dragTarget)){if(this.getDragMode()==ig.ui.DRAG_MODE_MOVE){document.body.style.cursor="move";}
else{document.body.style.cursor="pointer";}
return;}}
if(ig.ui.state==ig.ui.STATE_RESIZE){}
if(ig.ui.state==ig.ui.STATE_DRAG){}};IgUIElement.prototype.collapse=function(){var cc=this.getChildContainer();if(!ig.isNull(cc)){cc.hide(true);var pc=this.getParentComponent();if(!ig.isNull(pc)){var sn=pc.getSelectedElement();if(this.isAncestor(sn)){this.select();}}}};IgUIElement.prototype.disable=function(){this.setUIAttribute(ig.PROP_DISABLED,true);};IgUIElement.prototype.enable=function(){this.setUIAttribute(ig.PROP_DISABLED,false);};IgUIElement.prototype.expand=function(){var cc=this.getChildContainer();if(!ig.isNull(cc)){cc.show();}};IgUIElement.prototype.fireEvent=function(eventName,eventArgs,jsCallback,srid){if(ig.isNull(srid)){ig.smartSubmit(this.getId(),eventName,eventArgs,this.getId(),jsCallback);}
else{ig.smartSubmit(this.getId(),eventName,eventArgs,srid,jsCallback);}};IgUIElement.prototype.focus=function(){if(this.isEnabled()){ig.ui.setHoveredElement(this);var link=ig.findDescendant(this.elm,null,null,"a");if(!ig.isNull(link)){link.focus();}}};IgUIElement.prototype.getAttribute=function(attrn,p,s){var tmp=ig.getAttribute(this.elm,attrn);if(p===true&&!ig.NaES(tmp)){var pc=this.getParentComponent();if(!ig.isNull(pc)){if(!ig.isNull(s)){tmp=ig.getAttribute(pc.elm,attrn+s);}
else{tmp=ig.getAttribute(pc.elm,attrn+this.getType());}}}
return tmp;};IgUIElement.prototype.getChildContainer=function(){return ig.getUIElementById(this.getId()+"_cc");};IgUIElement.prototype.getClass=function(){var css=null;if(!this.isEnabled()){css=this.getDisabledClass();}
else{if(this.isSelected()){css=this.getSelectedClass();}
else{if(this.isHovered()){css=this.getHoverClass();}}
if(!css){css=this.getDefaultClass();}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -