📄 n2corelibs-utilities-54559.js
字号:
this.getObjectHeight = this.getElementHeight;this.getObjectLeft = this.getElementLeft;this.getObjectTop = this.getElementTop;this.sAnimationDivID = 'goN2UAnimatedBox'; //WARNING: events.js uses goN2U.sAnimationDivIDthis.bAnimateBoxRunning = false;this.initialized = true;;}this.isIE = function () { return this.bIsIE; }this.isW3C = function () { return this.bIsW3C; }this.isMozilla5 = function () { return this.bIsGecko && this.browser_version>=5 && !this.bIsSafari; }this.isFirefox = function () { return this.bIsFirefox && this.browser_version>=5; }this.isSafari = function () { return this.bIsSafari; }this.exists = function(obj) {return ( !this.isUndefOrNull(this.getElement(obj)) );}this.display = function (obj, type) {var oStyle = this.getElementStyle(obj);if (oStyle) {if(this.bIsIE || this.isMozilla5())oStyle.display = this.isDefined(type) ? type : "block";else {oStyle.display = "block";}}}this.undisplay = function (obj) {var oStyle = this.getElementStyle(obj);if (oStyle) {oStyle.display = 'none';}}this.isDisplayed = function(obj) {var oStyle = this.getElementStyle(obj);if (oStyle) {return oStyle.display != 'none';}return true;}this.toggleDisplay = function (obj, type) {var oStyle = this.getElementStyle(obj);if (oStyle) {if (oStyle.display == 'none')this.display (obj, type);elsethis.undisplay(obj);}}this.toggleDualDisplay = function (obj1, obj2) {this.toggleDisplay(obj1);this.toggleDisplay(obj2);}this.getScrollLeft = function() {if (document.documentElement.scrollLeft) {return document.documentElement.scrollLeft;} else {return document.body.scrollLeft;}}this.getScrollTop = function() {if (document.documentElement.scrollTop) {return document.documentElement.scrollTop;} else {return document.body.scrollTop;}}this.setScrollLeft = function(n) {if (document.documentElement.scrollLeft) {document.documentElement.scrollLeft = n;} else {document.body.scrollLeft = n;}}this.setScrollTop = function(n) {if (document.documentElement.scrollTop) {document.documentElement.scrollTop=n;} else {document.body.scrollTop=n;}}this.animateScrollTo = function(nTo, nStep, nDelay, nStepInc) {var nTop = goN2U.getScrollTop();nStepInc = this.isDefined(nStepInc) ? nStepInc : 20;nStep = nStep ? nStep+=nStepInc : 20;nDelay = nDelay ? nDelay : 25;if (nTop > nTo) {if (nTop > nTo+(nStep*1.5)) {goN2U.setScrollTop(nTop-nStep);setTimeout(function() { goN2U.animateScrollTo(nTo, nStep, nDelay, nStepInc); }, nDelay);} else {goN2U.setScrollTop(nTo);}} else {if (nTop < nTo-(nStep*1.5)) {goN2U.setScrollTop(nTop+nStep);setTimeout(function() { goN2U.animateScrollTo(nTo, nStep, nDelay, nStepInc); }, nDelay);} else {goN2U.setScrollTop(nTo);}}}this.removeElementById = function(sID) {var oElem = document.getElementById(sID);if (oElem && oElem.parentNode && oElem.parentNode.removeChild) {try {oElem.parentNode.removeChild(oElem);;} catch (e) {;}} else {;}}this.adjustBy = function (obj, deltaX, deltaY, deltaW, deltaH) {var oStyle = this.getElementStyle(obj);if (oStyle) {if (this.bIsCSS) {var units = (typeof oStyle.left == "string") ? "px" : 0;oStyle.left = this.getElementLeft(obj) + deltaX + units;oStyle.top = this.getElementTop(obj) + deltaY + units;oStyle.width = this.getElementWidth(obj) + deltaW; // + units;oStyle.height = this.getElementHeight(obj) + deltaH; // + units;} else if (this.bIsNN4) {oStyle.moveBy(deltaX, deltaY);}}}this.clip = function (obj, nTop, nRight, nBottom, nLeft) {var oStyle = this.getElementStyle(obj);oStyle.clip = "rect("+nTop+"px, " + nRight + "px, "+nBottom+"px, "+nLeft+"px)";}this.setContent = function (sID, sHtml, sClass) {var relem = this.getElement(sID);if (relem) relem.innerHTML = sHtml;if (sClass) this.setClass(sID, sClass);}this.setWidth = function (obj, n) {var oStyle = this.getElementStyle(obj);if (oStyle) {if ((typeof oStyle.width == "string") && (typeof n == "number")) {oStyle.width=n+"px";} else {oStyle.width = n;}}}this.setHeight = function (obj, n) {var oStyle = this.getElementStyle(obj);if (oStyle) {if ((typeof oStyle.height == "string") && (typeof n == "number")) {oStyle.height=n+"px";} else {oStyle.height = n;}}}this.getScrolledElementTop = function (elem) {var top = this.getPageElementTop(elem);if (elem) {var bod = document.body;var docParent = this.getParentElement(elem);while (docParent !== null && docParent !== bod) {top -= docParent.scrollTop;docParent = this.getParentElement(docParent);}}return top;}this.getScrolledElementLeft = function (elem) {var left = this.getPageElementLeft(elem);if (elem) {var bod = document.body;var docParent = this.getParentElement(elem);while (docParent !== null && docParent !== bod) {left -= docParent.scrollLeft;docParent = this.getParentElement(docParent);}}return left;}this.getPageElementTop = function (elem) {var top=0;if (elem) {top = elem.offsetTop;var parentObj = elem.offsetParent;while (parentObj != null) {if(this.bIsIE) {if( (parentObj.tagName != "TABLE") && (parentObj.tagName != "BODY") )top += parentObj.clientTop;}else {if(parentObj.tagName == "TABLE") {var nParBorder = parseInt(parentObj.border);if(isNaN(nParBorder)) {var nParFrame = parentObj.getAttribute('frame');if(nParFrame != null)top += 1;} else if(nParBorder > 0) {top += nParBorder;}}}top += parentObj.offsetTop;parentObj = parentObj.offsetParent;}}return top;}this.getPageElementLeft = function (elem) {var left=0;if (elem) {left = elem.offsetLeft;var parentObj = elem.offsetParent;while (parentObj != null) {if (this.bIsIE) {if( (parentObj.tagName != "TABLE") && (parentObj.tagName != "BODY") )left += parentObj.clientLeft;}else {if (parentObj.tagName == "TABLE") {var nParBorder = parseInt(parentObj.border);if(isNaN(nParBorder)) {var nParFrame = parentObj.getAttribute('frame');if(nParFrame != null)left += 1;} else if (nParBorder > 0) {left += nParBorder;}}}left += parentObj.offsetLeft;parentObj = parentObj.offsetParent;}}return left;}this.getParentElement = function (elem) {if (elem) {if (this.bIsIE) return elem.parentElement;return elem.parentNode;}return null;}this.elementIsContainedBy = function(elem, elemParent) {if (this.isUndefOrNull(elem) || this.isUndefOrNull(elemParent)) {return false;}while (true) {if (elem === elemParent) {return true;}var parent = this.getParentElement(elem);if (parent === null) {return false;}elem = parent;}}this.classfixup;if (document.all) this.classfixup = "className";else this.classfixup = "class";this.setClass = function (obj, style) {var obj = this.getElement (obj);;if (obj) obj.setAttribute(this.classfixup, style,0);}this.getClassX = function (obj) {var obj = this.getElement (obj);if (obj) return obj.getAttribute(this.classfixup, 0);return null;}this.addComma = function addComma(sNum) {if (typeof sNum != "string") sNum = sNum.toString();var aV = sNum.split('.');sNum = aV[0];var p0, p1, len, x=3;if (sNum.length >x) {for (x=3;(len=sNum.length)>x;x+=4 ) {p0 = sNum.substring(0, len-x);p1 = sNum.substring(len-x);sNum = p0 +',' + p1;}}if (aV[1]>=0) sNum += '.' + aV[1];return sNum;}this.preloadImages = new Array();this.preloadImage = function (sImage, id) {if (!id) id=this.preloadImages.length;if (!this.preloadImages[id]) {this.preloadImages[id]=new Image();this.preloadImages[id].src=sImage;;}}this.getLinkNameInfo = function (sLinkID, sNameOverride) {var oLNI = new N2LinkNameInfo(sLinkID, sNameOverride);return (oLNI.getLinkID() ? oLNI : null);}this.getIFrameDocument = function (id) {var oIFrame = this.getElement(id);if (oIFrame) {if (oIFrame.contentDocument) {return oIFrame.contentDocument;} else if (oIFrame.contentWindow) {return oIFrame.contentWindow.document;} else if (oIFrame.document) {return oIFrame.document;};return null;};return null;}this.getIFrameWindow = function (id) {var oIFrame = this.getElement(id);if (oIFrame) {if (oIFrame.contentWindow) {return oIFrame.contentWindow;};return null;};return null;}this.n2FlashElement = function (id, styleOn, styleOff, count) {n2DoFlashElement (id, styleOn, styleOff, count*2);}this.n2DoFlashElement = function (id, styleOn, styleOrig, count) {count--;if (count % 2)setClass(id, styleOn);elsesetClass(id, styleOrig);if (count) {setTimeout("n2DoFlashElement('" + id +"','" + styleOn + "','" + styleOrig + "'," + count +")", 500);}}this.animateBox = function (sl, st, sw, sh, fl, ft, fw, fh, nSteps, fnDone, style) {var nHInc = parseInt((fl -sl)/nSteps);var nVInc = parseInt((ft -st)/nSteps);var nWdInc = parseInt((fw-sw)/nSteps);var nHtInc = parseInt((fh-sh)/nSteps);var o = goN2U.getElement(this.sAnimationDivID);if (o && !this.bAnimateBoxRunning) {this.bAnimateBoxRunning = true;if (style) goN2U.setClass(this.sAnimationDivID, style);goN2U.shiftTo(o, sl, st);goN2U.show(o);goN2U.setWidth(o, sw);goN2U.setHeight(o, sh);var fn = function() { goN2U._animateBox(goN2U.sAnimationDivID, nHInc, nVInc, nWdInc, nHtInc, nSteps, fnDone); };setTimeout(fn, 25);} else if (fnDone) {fnDone();}}this._animateBox = function (sID, nHInc, nVInc, nWdInc, nHtInc, nSteps, fnDone) {goN2U.adjustBy(sID, nHInc, nVInc, nWdInc, nHtInc);if (--nSteps >0) {var fn = function() { goN2U._animateBox(sID, nHInc, nVInc, nWdInc, nHtInc, nSteps, fnDone); };setTimeout(fn, 25);} else {goN2U.hide(sID);if (fnDone) fnDone();this.bAnimateBoxRunning = false;}}this.expDivProcessing = false;this.expDivSize = 30;this.stepDone = true;this.toggleDivHeight = function (theDiv, hidableElem, delay, fnDone, displayableElem){var oParent = this.getElement(theDiv).parentNode;if (oParent.style.display != "none")this.collapseDivDual('h', theDiv, hidableElem, delay, fnDone, displayableElem);elsethis.expandDivDual('h', theDiv, hidableElem, delay, fnDone, displayableElem);}this.toggleDivWidth = function (theDiv, hidableElem, delay, fnDone, displayableElem){var oParent = this.getElement(theDiv).parentNode;if (oParent.style.display != "none")this.collapseDivDual('w', theDiv, hidableElem, delay, fnDone, displayableElem);elsethis.expandDivDual('w', theDiv, hidableElem, delay, fnDone, displayableElem);}this.expandDivWidth = function (theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate){this.expandDivDual('w', theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate);}this.expandDivHeight = function (theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate){this.expandDivDual('h', theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate);}this.collapseDivWidth = function (theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate){this.collapseDivDual('w', theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate);}this.collapseDivHeight = function (theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate){this.collapseDivDual('h', theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate);}this.collapseExpandDivsWidth = function (divA, divB, delay){this.collapseExpandDivsDual ('w', divA, divB, delay);}this.collapseExpandDivsHeight = function (divA, divB, delay){this.collapseExpandDivsDual ('h', divA, divB, delay);}this.expandCalcStep = function (h) {if (h <40) return h/2;if (h <225) return 20; //15if (h <900) return parseInt(h/10); // h/15return 100; // 60}this.expandDivDual = function (mode, theDiv, hidableElem, delay, fnDone, displayableElem, bImmediate){if (this.expDivProcessing) return;this.expDivProcessing = true;var theDivObj = this.getElement(theDiv);var parentDiv = theDivObj.parentNode;if (!parentDiv.id) { parentDiv.id = 'outer_' + theDivObj.id; }this.expDivSize=0;var maxSize;if (mode == 'w' ) {this.setWidth(parentDiv, this.expDivSize);this.display(parentDiv);maxSize = this.getElementWidth(theDivObj);} else {this.setHeight(parentDiv, this.expDivSize);this.display(parentDiv);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -