📄 labels-javascript
字号:
|| document.body.scrollLeft || 0; this.deltaY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; }, realOffset: function(element) { var valueT = 0, valueL = 0; do { valueT += element.scrollTop || 0; valueL += element.scrollLeft || 0; element = element.parentNode; } while (element); return [valueL, valueT]; }, cumulativeOffset: function(element) { var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; element = element.offsetParent; } while (element); return [valueL, valueT]; }, // caches x/y coordinate pair to use with overlap within: function(element, x, y) { if (this.includeScrollOffsets) return this.withinIncludingScrolloffsets(element, x, y); this.xcomp = x; this.ycomp = y; this.offset = this.cumulativeOffset(element); return (y >= this.offset[1] && y < this.offset[1] + element.offsetHeight && x >= this.offset[0] && x < this.offset[0] + element.offsetWidth); }, withinIncludingScrolloffsets: function(element, x, y) { var offsetcache = this.realOffset(element); this.xcomp = x + offsetcache[0] - this.deltaX; this.ycomp = y + offsetcache[1] - this.deltaY; this.offset = this.cumulativeOffset(element); return (this.ycomp >= this.offset[1] && this.ycomp < this.offset[1] + element.offsetHeight && this.xcomp >= this.offset[0] && this.xcomp < this.offset[0] + element.offsetWidth); }, // within must be called directly before overlap: function(mode, element) { if (!mode) return 0; if (mode == 'vertical') return ((this.offset[1] + element.offsetHeight) - this.ycomp) / element.offsetHeight; if (mode == 'horizontal') return ((this.offset[0] + element.offsetWidth) - this.xcomp) / element.offsetWidth; }, clone: function(source, target) { source = $(source); target = $(target); target.style.position = 'absolute'; var offsets = this.cumulativeOffset(source); target.style.top = offsets[1] + 'px'; target.style.left = offsets[0] + 'px'; target.style.width = source.offsetWidth + 'px'; target.style.height = source.offsetHeight + 'px'; }}// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)//// See scriptaculous.js for full license.Object.debug = function(obj) { var info = []; if(typeof obj in ["string","number"]) { return obj; } else { for(property in obj) if(typeof obj[property]!="function") info.push(property + ' => ' + (typeof obj[property] == "string" ? '"' + obj[property] + '"' : obj[property])); } return ("'" + obj + "' #" + typeof obj + ": {" + info.join(", ") + "}");}String.prototype.toArray = function() { var results = []; for (var i = 0; i < this.length; i++) results.push(this.charAt(i)); return results;}/*--------------------------------------------------------------------------*/var Builder = { NODEMAP: { AREA: 'map', CAPTION: 'table', COL: 'table', COLGROUP: 'table', LEGEND: 'fieldset', OPTGROUP: 'select', OPTION: 'select', PARAM: 'object', TBODY: 'table', TD: 'table', TFOOT: 'table', TH: 'table', THEAD: 'table', TR: 'table' }, // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken, // due to a Firefox bug node: function(elementName) { elementName = elementName.toUpperCase(); // try innerHTML approach var parentTag = this.NODEMAP[elementName] || 'div'; var parentElement = document.createElement(parentTag); parentElement.innerHTML = "<" + elementName + "></" + elementName + ">"; var element = parentElement.firstChild || null; // see if browser added wrapping tags if(element && (element.tagName != elementName)) element = element.getElementsByTagName(elementName)[0]; // fallback to createElement approach if(!element) element = document.createElement(elementName); // abort if nothing could be created if(!element) return; // attributes (or text) if(arguments[1]) if(this._isStringOrNumber(arguments[1]) || (arguments[1] instanceof Array)) { this._children(element, arguments[1]); } else { var attrs = this._attributes(arguments[1]); if(attrs.length) { parentElement.innerHTML = "<" +elementName + " " + attrs + "></" + elementName + ">"; element = parentElement.firstChild || null; // workaround firefox 1.0.X bug if(!element) { element = document.createElement(elementName); for(attr in arguments[1]) element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; } if(element.tagName != elementName) element = parentElement.getElementsByTagName(elementName)[0]; } } // text, or array of children if(arguments[2]) this._children(element, arguments[2]); return element; }, _text: function(text) { return document.createTextNode(text); }, _attributes: function(attributes) { var attrs = []; for(attribute in attributes) attrs.push((attribute=='className' ? 'class' : attribute) + '="' + attributes[attribute].toString().escapeHTML() + '"'); return attrs.join(" "); }, _children: function(element, children) { if(typeof children=='object') { // array can hold nodes and text children.flatten().each( function(e) { if(typeof e=='object') element.appendChild(e) else if(Builder._isStringOrNumber(e)) element.appendChild(Builder._text(e)); }); } else if(Builder._isStringOrNumber(children)) element.appendChild(Builder._text(children)); }, _isStringOrNumber: function(param) { return(typeof param=='string' || typeof param=='number'); }}/* ------------- element ext -------------- */// adapted from http://dhtmlkitchen.com/learn/js/setstyle/index4.jsp// note: Safari return null on elements with display:none; see http://bugzilla.opendarwin.org/show_bug.cgi?id=4125// instead of "auto" values returns null so it's easier to use with || constructsString.prototype.camelize = function() { var oStringList = this.split('-'); if(oStringList.length == 1) return oStringList[0]; var ret = this.indexOf("-") == 0 ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0]; for(var i = 1, len = oStringList.length; i < len; i++){ var s = oStringList[i]; ret += s.charAt(0).toUpperCase() + s.substring(1) } return ret;}Element.getStyle = function(element, style) { element = $(element); var value = element.style[style.camelize()]; if(!value) if(document.defaultView && document.defaultView.getComputedStyle) { var css = document.defaultView.getComputedStyle(element, null); value = (css!=null) ? css.getPropertyValue(style) : null; } else if(element.currentStyle) { value = element.currentStyle[style.camelize()]; } // If top, left, bottom, or right values have been queried, return "auto" for consistency resaons // if position is "static", as Opera (and others?) returns the pixel values relative to root element // (or positioning context?) if (window.opera && (style == "left" || style == "top" || style == "right" || style == "bottom")) if (Element.getStyle(element, "position") == "static") value = "auto"; if(value=='auto') value = null; return value;}// converts rgb() and #xxx to #xxxxxx format,// returns self (or first argument) if not convertableString.prototype.parseColor = function() { color = "#"; if(this.slice(0,4) == "rgb(") { var cols = this.slice(4,this.length-1).split(','); var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); } else { if(this.slice(0,1) == '#') { if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); if(this.length==7) color = this.toLowerCase(); } } return(color.length==7 ? color : (arguments[0] || this));}Element.makePositioned = function(element) { element = $(element); var pos = Element.getStyle(element, 'position'); if(pos =='static' || !pos) { element._madePositioned = true; element.style.position = "relative"; // Opera returns the offset relative to the positioning context, when an element is position relative // but top and left have not been defined if (window.opera){ element.style.top = 0; element.style.left = 0; } }} Element.undoPositioned = function(element) { element = $(element); if(typeof element._madePositioned != "undefined"){ element._madePositioned = undefined; element.style.position = ""; element.style.top = ""; element.style.left = ""; element.style.bottom = ""; element.style.right = ""; }}Element.makeClipping = function(element) { element = $(element); if (typeof element._overflow != 'undefined') return; element._overflow = element.style.overflow; if((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') element.style.overflow = 'hidden';}Element.undoClipping = function(element) { element = $(element); if (typeof element._overflow == 'undefined') return; element.style.overflow = element._overflow; element._overflow = undefined;}Element.collectTextNodesIgnoreClass = function(element, ignoreclass) { var children = $(element).childNodes; var text = ""; var classtest = new RegExp("^([^ ]+ )*" + ignoreclass+ "( [^ ]+)*$","i"); for (var i = 0; i < children.length; i++) { if(children[i].nodeType==3) { text+=children[i].nodeValue; } else { if((!children[i].className.match(classtest)) && children[i].hasChildNodes()) text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass); } } return text;}Element.setContentZoom = function(element, percent) { element = $(element); element.style.fontSize = (percent/100) + "em"; if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);}Element.getOpacity = function(element){ var opacity; if (opacity = Element.getStyle(element, "opacity")) return parseFloat(opacity); if (opacity = (Element.getStyle(element, "filter") || '').match(/alpha\(opacity=(.*)\)/)) if(opacity[1]) return parseFloat(opacity[1]) / 100; return 1.0;}Element.setOpacity = function(element, value){ element= $(element); var els = element.style; if (value == 1){ els.opacity = '0.999999'; if(/MSIE/.test(navigator.userAgent)) els.filter = Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,''); } else { if(value < 0.00001) value = 0; els.opacity = value; if(/MSIE/.test(navigator.userAgent)) els.filter = Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + "alpha(opacity="+value*100+")"; } }Element.getInlineOpacity = function(element){ element= $(element); var op; op = element.style.opacity; if (typeof op != "undefined" && op != "") return op; return "";}Element.setInlineOpacity = function(element, value){ element= $(element); var els = element.style; els.opacity = value;}Element.getDimensions = function(element){ element = $(element); // All *Width and *Height properties give 0 on elements with display "none", // so enable the element temporarily if (Element.getStyle(element,'display') == "none"){ var els = element.style; var originalVisibility = els.visibility; var originalPosition = els.position; els.visibility = "hidden"; els.position = "absolute"; els.display = ""; var originalWidth = element.clientWidth; var originalHeight = element.clientHeight; els.display = "none"; els.position = originalPosition; els.visibility = originalVisibility; return {width: originalWidth, height: originalHeight}; } return {width: element.offsetWidth, height: element.offsetHeight};} /*--------------------------------------------------------------------------*/Position.positionedOffset = function(element) { var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; element = element.offsetParent; if (element) { p = Element.getStyle(element,'position'); if(p == 'relative' || p == 'absolute') break; } } while (element); return [valueL, valueT];}// Safari returns margins on body which is incorrect if the child is absolutely positioned.// for performance reasons, we create a specialized version of Position.cumulativeOffset for// KHTML/WebKit onlyif(/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { Position.cumulativeOffset = function(element) { var valueT = 0, valueL = 0; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; if (element.offsetParent==document.body) if (Element.getStyle(element,'position')=='absolute') break; element = element.offsetParent; } while (element); return [valueL, valueT]; }}Position.page = function(forElement) { var valueT = 0, valueL = 0; var element = forElement; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; // Safari fix if (element.offsetParent==document.body) if (Element.getStyle(element,'position')=='absolute') break; } while (element = element.offsetParent); element = forElement; do { valueT -= element.scrollTop || 0; valueL -= element.scrollLeft || 0; } while (element = element.parentNode); return [valueL, valueT];}// elements with display:none don't return an offsetParent, // fall back to manual calculationPosition.offsetParent = function(element) { if(element.offsetParent) return element.offsetParent; if(element == document.body) return element; while ((element = element.parentNode) && element != document.body) if (Element.getStyle(element,'position')!='static') return element; return document.body;}Position.clone = function(source, target) { var options = Object.extend({ setLeft: true, setTop: true, setWidth: true, setHeight: true, offsetTop: 0, offsetLeft: 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -