📄 layout.js
字号:
}; // object}dojo.html.getPadBorder = function(/* HTMLElement */node){ // summary // Returns the width and height of the passed node's padding and border var pad = dojo.html.getPadding(node); var border = dojo.html.getBorder(node); return { width: pad.width + border.width, height: pad.height + border.height }; // object}dojo.html.getBoxSizing = function(/* HTMLElement */node){ // summary // Returns which box model the passed element is working with var h = dojo.render.html; var bs = dojo.html.boxSizing; if(((h.ie)||(h.opera)) && node.nodeName!="IMG"){ var cm = document["compatMode"]; if((cm == "BackCompat")||(cm == "QuirksMode")){ return bs.BORDER_BOX; // string }else{ return bs.CONTENT_BOX; // string } }else{ if(arguments.length == 0){ node = document.documentElement; } var sizing = dojo.html.getStyle(node, "-moz-box-sizing"); if(!sizing){ sizing = dojo.html.getStyle(node, "box-sizing"); } return (sizing ? sizing : bs.CONTENT_BOX); // string }}dojo.html.isBorderBox = function(/* HTMLElement */node){ // summary // returns whether the passed element is using border box sizing or not. return (dojo.html.getBoxSizing(node) == dojo.html.boxSizing.BORDER_BOX); // boolean}dojo.html.getBorderBox = function(/* HTMLElement */node){ // summary // Returns the dimensions of the passed element based on border-box sizing. node = dojo.byId(node); return { width: node.offsetWidth, height: node.offsetHeight }; // object}dojo.html.getPaddingBox = function(/* HTMLElement */node){ // summary // Returns the dimensions of the padding box (see http://www.w3.org/TR/CSS21/box.html) var box = dojo.html.getBorderBox(node); var border = dojo.html.getBorder(node); return { width: box.width - border.width, height:box.height - border.height }; // object}dojo.html.getContentBox = function(/* HTMLElement */node){ // summary // Returns the dimensions of the content box (see http://www.w3.org/TR/CSS21/box.html) node = dojo.byId(node); var padborder = dojo.html.getPadBorder(node); return { width: node.offsetWidth - padborder.width, height: node.offsetHeight - padborder.height }; // object}dojo.html.setContentBox = function(/* HTMLElement */node, /* object */args){ // summary // Sets the dimensions of the passed node according to content sizing. node = dojo.byId(node); var width = 0; var height = 0; var isbb = dojo.html.isBorderBox(node); var padborder = (isbb ? dojo.html.getPadBorder(node) : { width: 0, height: 0}); var ret = {}; if(typeof args.width != "undefined"){ width = args.width + padborder.width; ret.width = dojo.html.setPositivePixelValue(node, "width", width); } if(typeof args.height != "undefined"){ height = args.height + padborder.height; ret.height = dojo.html.setPositivePixelValue(node, "height", height); } return ret; // object}dojo.html.getMarginBox = function(/* HTMLElement */node){ // summary // returns the dimensions of the passed node including any margins. var borderbox = dojo.html.getBorderBox(node); var margin = dojo.html.getMargin(node); return { width: borderbox.width + margin.width, height: borderbox.height + margin.height }; // object}dojo.html.setMarginBox = function(/* HTMLElement */node, /* object */args){ // summary // Sets the dimensions of the passed node using margin box calcs. node = dojo.byId(node); var width = 0; var height = 0; var isbb = dojo.html.isBorderBox(node); var padborder = (!isbb ? dojo.html.getPadBorder(node) : { width: 0, height: 0 }); var margin = dojo.html.getMargin(node); var ret = {}; if(typeof args.width != "undefined"){ width = args.width - padborder.width; width -= margin.width; ret.width = dojo.html.setPositivePixelValue(node, "width", width); } if(typeof args.height != "undefined"){ height = args.height - padborder.height; height -= margin.height; ret.height = dojo.html.setPositivePixelValue(node, "height", height); } return ret; // object}dojo.html.getElementBox = function(/* HTMLElement */node, /* string */type){ // summary // return dimesions of a node based on the passed box model type. var bs = dojo.html.boxSizing; switch(type){ case bs.MARGIN_BOX: return dojo.html.getMarginBox(node); // object case bs.BORDER_BOX: return dojo.html.getBorderBox(node); // object case bs.PADDING_BOX: return dojo.html.getPaddingBox(node); // object case bs.CONTENT_BOX: default: return dojo.html.getContentBox(node); // object }}// in: coordinate array [x,y,w,h] or dom node// return: coordinate objectdojo.html.toCoordinateObject = dojo.html.toCoordinateArray = function(/* array */coords, /* boolean? */includeScroll, /* string? */boxtype) { // summary // Converts an array of coordinates into an object of named arguments. if(coords instanceof Array || typeof coords == "array"){ dojo.deprecated("dojo.html.toCoordinateArray", "use dojo.html.toCoordinateObject({left: , top: , width: , height: }) instead", "0.5"); // coords is already an array (of format [x,y,w,h]), just return it while ( coords.length < 4 ) { coords.push(0); } while ( coords.length > 4 ) { coords.pop(); } var ret = { left: coords[0], top: coords[1], width: coords[2], height: coords[3] }; }else if(!coords.nodeType && !(coords instanceof String || typeof coords == "string") && ('width' in coords || 'height' in coords || 'left' in coords || 'x' in coords || 'top' in coords || 'y' in coords)){ // coords is a coordinate object or at least part of one var ret = { left: coords.left||coords.x||0, top: coords.top||coords.y||0, width: coords.width||0, height: coords.height||0 }; }else{ // coords is an dom object (or dom object id); return it's coordinates var node = dojo.byId(coords); var pos = dojo.html.abs(node, includeScroll, boxtype); var marginbox = dojo.html.getMarginBox(node); var ret = { left: pos.left, top: pos.top, width: marginbox.width, height: marginbox.height }; } ret.x = ret.left; ret.y = ret.top; return ret; // object}dojo.html.setMarginBoxWidth = dojo.html.setOuterWidth = function(node, width){ return dojo.html._callDeprecated("setMarginBoxWidth", "setMarginBox", arguments, "width");}dojo.html.setMarginBoxHeight = dojo.html.setOuterHeight = function(){ return dojo.html._callDeprecated("setMarginBoxHeight", "setMarginBox", arguments, "height");}dojo.html.getMarginBoxWidth = dojo.html.getOuterWidth = function(){ return dojo.html._callDeprecated("getMarginBoxWidth", "getMarginBox", arguments, null, "width");}dojo.html.getMarginBoxHeight = dojo.html.getOuterHeight = function(){ return dojo.html._callDeprecated("getMarginBoxHeight", "getMarginBox", arguments, null, "height");}dojo.html.getTotalOffset = function(node, type, includeScroll){ return dojo.html._callDeprecated("getTotalOffset", "getAbsolutePosition", arguments, null, type);}dojo.html.getAbsoluteX = function(node, includeScroll){ return dojo.html._callDeprecated("getAbsoluteX", "getAbsolutePosition", arguments, null, "x");}dojo.html.getAbsoluteY = function(node, includeScroll){ return dojo.html._callDeprecated("getAbsoluteY", "getAbsolutePosition", arguments, null, "y");}dojo.html.totalOffsetLeft = function(node, includeScroll){ return dojo.html._callDeprecated("totalOffsetLeft", "getAbsolutePosition", arguments, null, "left");}dojo.html.totalOffsetTop = function(node, includeScroll){ return dojo.html._callDeprecated("totalOffsetTop", "getAbsolutePosition", arguments, null, "top");}dojo.html.getMarginWidth = function(node){ return dojo.html._callDeprecated("getMarginWidth", "getMargin", arguments, null, "width");}dojo.html.getMarginHeight = function(node){ return dojo.html._callDeprecated("getMarginHeight", "getMargin", arguments, null, "height");}dojo.html.getBorderWidth = function(node){ return dojo.html._callDeprecated("getBorderWidth", "getBorder", arguments, null, "width");}dojo.html.getBorderHeight = function(node){ return dojo.html._callDeprecated("getBorderHeight", "getBorder", arguments, null, "height");}dojo.html.getPaddingWidth = function(node){ return dojo.html._callDeprecated("getPaddingWidth", "getPadding", arguments, null, "width");}dojo.html.getPaddingHeight = function(node){ return dojo.html._callDeprecated("getPaddingHeight", "getPadding", arguments, null, "height");}dojo.html.getPadBorderWidth = function(node){ return dojo.html._callDeprecated("getPadBorderWidth", "getPadBorder", arguments, null, "width");}dojo.html.getPadBorderHeight = function(node){ return dojo.html._callDeprecated("getPadBorderHeight", "getPadBorder", arguments, null, "height");}dojo.html.getBorderBoxWidth = dojo.html.getInnerWidth = function(){ return dojo.html._callDeprecated("getBorderBoxWidth", "getBorderBox", arguments, null, "width");}dojo.html.getBorderBoxHeight = dojo.html.getInnerHeight = function(){ return dojo.html._callDeprecated("getBorderBoxHeight", "getBorderBox", arguments, null, "height");}dojo.html.getContentBoxWidth = dojo.html.getContentWidth = function(){ return dojo.html._callDeprecated("getContentBoxWidth", "getContentBox", arguments, null, "width");}dojo.html.getContentBoxHeight = dojo.html.getContentHeight = function(){ return dojo.html._callDeprecated("getContentBoxHeight", "getContentBox", arguments, null, "height");}dojo.html.setContentBoxWidth = dojo.html.setContentWidth = function(node, width){ return dojo.html._callDeprecated("setContentBoxWidth", "setContentBox", arguments, "width");}dojo.html.setContentBoxHeight = dojo.html.setContentHeight = function(node, height){ return dojo.html._callDeprecated("setContentBoxHeight", "setContentBox", arguments, "height");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -