⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 element.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 5 页
字号:
    borderBottom:"borderBottomStyle",    borderLeftWidth:"borderLeftStyle",     borderRightWidth:"borderRightStyle",     borderBottomWidth:"borderBottomStyle",     borderTopWidth:"borderTopStyle"},getComputedStyleAttribute : function (element, property) {    if (element == null || property == null) return null;        // Use currentStyle for IE (easy!)    if (isc.Browser.isIE || isc.Browser.isOpera) {        // special opera logic for undefined borders returning 3        if (isc.Browser.isOpera && this._$operaBorderStyles[property] != null &&            element.currentStyle[this._$operaBorderStyles[property]] == this._$none) return 0;        return element.currentStyle[property];    }    //>Safari    if (isc.Browser.isSafari) {                var propertyValue = null;        if (element.style) propertyValue = element.style[property];        if ((propertyValue == null || isc.isAn.emptyString(propertyValue)) &&            element.className)        {            var styleDecl = isc.Element.getStyleEdges(element.className);            if (styleDecl) propertyValue = styleDecl[property];        }        if (isc.isAn.emptyString(propertyValue)) return null;        return propertyValue;                } //<Safari        // DOM and not broken (eg Moz).  Convert camelCaps to the CSS property name (only works for    // a specific list of props)    var mask = this._styleFullMask;            var docView = this._docView = this._docView || document.defaultView;    var cssProperty = (mask[property] || property),        // get the style object for the element        style = docView.getComputedStyle(element, null);                   return style.getPropertyValue(cssProperty);},// look up a style declaration via document.stylesheetsgetStyleDeclaration : function (className, checkMultiples) {    if (!className) return null;        if (!isc.allowDuplicateStyles) checkMultiples = false;            if (isc.Browser.isSafari && isc.Browser.safariVersion >= 312) {        className = className.toLowerCase();    }        var selector = "." + className,        commaSpace = ", ";    // Check the array of style rules from any styleSheets     // - This will include <STYLE> tags in the doc    // - Start with the most recently loaded    var styleObj, styleObjs = checkMultiples ? [] : null;    for (var i = document.styleSheets.length - 1; i >= 0; i--) {        var rules = this._getCSSRules(document.styleSheets[i]);                            if (rules == null) continue; // stylesheet inaccessible        // iterate backward through style declarations, since last wins        for (var j = rules.length - 1; j >= 0; j--) {                                                        var selectorText = rules[j].selectorText;            // @import css tags result in entires with no 'selectorText' property.                        if (selectorText == null) continue;            if (isc.Browser.isMoz) {                var selectorTextArray = selectorText.split(commaSpace);                                for (var k = 0; k < selectorTextArray.length; k++) {                    if (selectorTextArray[k] == selector) {                        styleObj = rules[j].style;                        if (styleObj != null) {                            if (checkMultiples) styleObjs[styleObjs.length] = styleObj;                            else return styleObj;                        }                    }                }            } else {                            if (selectorText == selector) {                    styleObj = rules[j].style;                    if (styleObj != null) {                        if (checkMultiples) styleObjs[styleObjs.length] = styleObj;                        else return styleObj;                    }                }            }           }    }    if (checkMultiples && styleObjs.length > 0) return styleObjs;    return null;},// retrieve the css rules property from a stylesheet definition_getCSSRules : function (styleSheet) {        if (!this._fetchStyle) {        // "cssRules" in Moz, "rules" in IE.        // NOTE: use of "_sheet" instead of "sheet" allows private identifier obfuscation        var functionString = "try{return _sheet.rules||_sheet.cssRules}" +                              "catch(e){isc.Page._remoteStyleSheet = true;}";        this._fetchStyle = new Function("_sheet", functionString);	    }    return this._fetchStyle(styleSheet);},                 //>	@classMethod Element.getStyleText()	([A])// Gets the raw CSS style text associated with a CSS className. For example, if you have// defined the following class:<br><br>// <code>.cellSelected {font-family:Verdana; font-size:10px; background-color:#FFFF99;<br>// border-top:1px solid #FFFF99;<br>// border-bottom:1px solid #FFFF99;<br>// }</code><br><br>// Then calling getStyleText("cellSelected") will return:<br><br>// <code>font-family:Verdana; font-size:10px; background-color:#FFFF99;<br>// border-top:1px solid #FFFF99; border-bottom:1px solid #FFFF99;</code>//		@group	drawing////      @param  className   (string)       The CSS ClassName for which you wish to get the style//      @param  [checkMultiples]    (boolean)   If specified this will ensure we check for //                                          multiple definitions of the same className and pick//                                          up cssText from each definition. False by default.//                                          No effect if isc.allowDuplicateStyles is false.//      @return (string)       The cssText property of this CSS style rule//<_cssTextCache:{},		getStyleText : function (className, checkMultiples) {        if (!isc.allowDuplicateStyles) checkMultiples = false;                // check cache.        var cache = this._cssTextCache,        cssText = cache[className];    if (cssText != null) return cssText;    var style = this.getStyleDeclaration(className, checkMultiples);         // if we didn't find anything, return the empty string (rather than null)    if (style == null) {                if (!isc.Browser.isSafari || isc.Page.isLoaded())             this._cssTextCache[className] = isc.emptyString;        return isc.emptyString;    }    // "style" will be an array if we checked multiple styles            if (checkMultiples) {        for (var i = style.length-1; i >-1; i--) {                    var actualStyle = style[i];            if (actualStyle.cssText == null) continue;            if (cssText == null) cssText = actualStyle.cssText;            else cssText += actualStyle.cssText;        }        if (cssText == null) cssText = isc._emptyString;    } else {        cssText = (style.cssText || isc._emptyString);    }            // ensure it ends with a semicolon so it can be appended to    if (!isc.endsWith(cssText, isc.semi)) cssText += isc.semi;    // cache it and return it        return (cache[className] = cssText);},// wipe out any cached CSS information// helper for Canvas._clearCSSCaches_clearCSSCaches : function () {    //isc.Log.logWarn("styleCache is: " + isc.Comm.serialize(isc.Element._styleCache, true));    // wipe out the central style definition caches    isc.Element._styleCache = {};    isc.Element._cssTextCache = {};    // wipe out central edge size caches    isc.Element._borderSizeCache = isc.Element._marginsCache =         isc.Element._padSizeCache = null;},// Border, Padding and Margin on css classes// --------------------------------------------------------------------------------------------// We provide the static Element class methods to handle getting border and padding // thicknesses on each side ('getTopBorderSize()', 'getBottomBorderSize()', 'getTopPadding()',// etc.) for css classes from their classNames.//>	@classMethod	Element._getTopMargin()// Get the size of the top margin for the style passed in.////  @param  className   (string)    className to test for margin size//  @return             (number)    size of top margin in pixels//<_getTopMargin : function (className) {    return this._calculateMargins(className).top;},//>	@classMethod	Element._getBottomMargin()// Get the size of the bottom margin for the style passed in.////  @param  className   (string)    className to test for margin//  @return             (number)    size of bottom margin in pixels//<_getBottomMargin : function (className) {    return this._calculateMargins(className).bottom;},//>	@classMethod	Element._getLeftMargin()// Get the size of the left margin for the style passed in.////  @param  className   (string)    className to test for margin size//  @return             (number)    size of left margin in pixels//<_getLeftMargin : function (className) {    return this._calculateMargins(className).left;},//>	@classMethod	Element._getRightMargin()// Get the size of the right margin for the style passed in.////  @param  className   (string)    className to test for margin size//  @return             (number)    size of right margin in pixels//<_getRightMargin : function (className) {    return this._calculateMargins(className).right;},//>	@classMethod	Element._calculateMargins()// Calculate the sizes of the margins on each side for the css class passed in.////  @param  className   (string)    className to test for margin sizes//  @return             (object)    Object with 'left', 'right', 'top', 'bottom' defined as the //                                  sizes of the margin on each side//<_calculateMargins : function (className) {    if (this._marginsCache == null) this._marginsCache = {};    else if (this._marginsCache[className] != null) {        return this._marginsCache[className];    }            var margins = {top:0, bottom:0, left:0, right:0},        styleObject = isc.Element.getStyleEdges(className);    if (styleObject == null) return margins;        var topMarginString = styleObject.marginTop,        bottomMarginString = styleObject.marginBottom,        leftMarginString = styleObject.marginLeft,        rightMarginString = styleObject.marginRight,        pxString = isc.px;    if (isc.isA.String(topMarginString) && topMarginString.endsWith(pxString))         margins.top = parseInt(topMarginString);    if (isc.isA.String(bottomMarginString) && bottomMarginString.endsWith(pxString))         margins.bottom = parseInt(bottomMarginString);            if (isc.isA.String(leftMarginString) && leftMarginString.endsWith(pxString))         margins.left = parseInt(leftMarginString);            if (isc.isA.String(rightMarginString) && rightMarginString.endsWith(pxString))         margins.right = parseInt(rightMarginString);            this._marginsCache[className] = margins;            return margins;},//>	@classMethod	Element._getTopBorderSize()// Get the size of the top border for the style passed in.////  @param  className   (string)    className to test for border size//  @return             (number)    size of top border in pixels//<_getTopBorderSize : function (className) {    return this._calculateBorderSize(className).top;},//>	@classMethod	Element._getBottomBorderSize()// Get the size of the bottom border for the style passed in.////  @param  className   (string)    className to test for border size//  @return             (number)    size of bottom border in pixels//<_getBottomBorderSize : function (className) {    return this._calculateBorderSize(className).bottom;},//>	@classMethod	Element._getLeftBorderSize()// Get the size of the left border for the style passed in.////  @param  className   (string)    className to test for border size//  @return             (

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -