window.growHeightList = window.growHeightList || {}; function getGrowHeight(id, maxHeight, buttons, type, acceptEnter) { var gh = growHeightList[id]; if (!gh) { if (maxHeight != null) { gh = new GrowHeight(id, maxHeight, buttons, type, acceptEnter); } else { console.info("找不到GrowHeight:" + id); } } return gh; } var GrowHeight = GrowHeight = function (id, maxHeight, buttons, type, acceptEnter) { var ele = document.getElementById(id); if (ele) { this.showPadding = 0; this.name = id; this.id = id; this.maxHeight = parseFloat(maxHeight) || 300; this.type = type; this.acceptEnter = new Boolean(acceptEnter) == true; this.srcElement = ele; this.fj = buttons.fj; this.init(); window.growHeightList[id] = this; } else { console.log("找不到元素:" + id); } } GrowHeight.prototype.getName = function () { return this.name; } GrowHeight.prototype.val = function (value) { if (this.container.tagName.toLowerCase() == "textarea") { if (arguments.length == 0) { value = this.input.value; } else { this.container.value = value; this.onInput(); } } else { if (arguments.length == 0) { value = this.input.value; } else { this.container.innerHTML = value; this.onInput(); } } if (this.isFocus != true) { this.container.initDot && this.container.initDot(); } return value; } GrowHeight.prototype.setOnInput = function (callback) { this.onInputCallback = callback; } GrowHeight.prototype.setOnfocus = function (callback) { this.onFocusCallback = callback; } GrowHeight.prototype.setOnblur = function (callback) { this.onBlurCallback = callback; } GrowHeight.prototype.show = function () { if (this.shadow) return; //缓存旧数据 var ori = this.oriInfo = { wrapper: this.wrapper.style.cssText, container: this.container.style.cssText, parent_: this.wrapper.parentNode.style.cssText }; var e = $HIDDENOVERFLOW(this.wrapper); var eb = e.getBoundingClientRect(); var pB = this.wrapper.parentNode.getBoundingClientRect(); var bound = this.wrapper.getBoundingClientRect(); //创建站位空格 var shadow = this.shadow = this.wrapper.cloneNode(); shadow.id = "shadow_" + (this.wrapper.name || this.wrapper.id || ""); shadow.name = ""; shadow.style.display="inline-block"; shadow.style.overflowY = "hidden"; shadow.style.visibility = "hidden"; var csstxt = this.wrapper.style.cssText; var csss=csstxt.split(";"); var hasCssWidth=false,hasCssHeight=false; for (var ci=0;ci 0) { this.wrapper.style.left = parseFloat(this.wrapper.style.left) - pd + "px"; //x左移 this.wrapper.style.width = $REALWIDTH(this.shadow) + pd * 2 + "px"; //y右移 this.wrapper.style.padding = pd + "px"; var b = this.wrapper.style.bottom; if (b != "") { this.wrapper.style.bottom = parseFloat(b) - pd + "px"; } else { b = this.wrapper.style.top; this.wrapper.style.top = parseFloat(b) - pd + "px"; } var maxH = $MAH(this.wrapper) /* this.maxHeight */ + pd; // var se=$HIDDENOVERFLOW(this.wrapper); //计算maxheight this.wrapper.style.maxHeight = maxH + "px"; } this.container.style.height = h + "px"; var sh = this.container.scrollHeight, mh = $MAH(this.wrapper) - ($ISBOX(this.wrapper) ? ($PT(this.wrapper) + $PB(this.wrapper)) : 0); h = Math.min(sh, mh); this.container.style.overflow = "hidden"; this.container.scrollTop = this.lastScrollTop; } else {} this.container.style.height = h + "px"; } GrowHeight.prototype.hide = function () { $(this.wrapper).removeClass("input-div-selected"); $(this.wrapper).addClass("input-s"); $(this.wrapper).find(".smallScrollbar").getNiceScroll().remove(); if (this.shadow) { if (this.shadow.parentNode != this.wrapper.parentNode) this.shadow.parentNode.insertBefore(this.wrapper, this.shadow); this.shadow.parentNode.removeChild(this.shadow); this.shadow = null; } var ori = this.oriInfo; if (ori) { this.wrapper.style.cssText = ori.wrapper; this.container.style.cssText = ori.container; this.wrapper.parentNode.style.cssText = ori.parent_; this.oriInfo = null; } if (this.cmsBtn) { //更新CMS按钮的位置 this.cmsBtn.updateButtonSize(); } } GrowHeight.prototype.initAsDiv = function () { if (this.inited === true) return; function _focus() { this.GrowHeight.show(); this.focus(); this.addEventListener("blur", _blur); this.GrowHeight.onFocus(); // this.innerHTML = this.GrowHeight.input.value; } function _blur() { this.GrowHeight.hide(); this.removeEventListener("blur", _blur); this.GrowHeight.onBlur(); this.GrowHeight.updateInputValue(); } // this.onInputCallback = function (container) { // this.updateInputValue(); // } var onDivInput = function (e) { if (!this.GrowHeight.acceptEnter) { var et = e || window.event; var keycode = et.charCode || et.keyCode; if (keycode == 13) { if (window.event) { window.event.returnValue = false; } else { e.preventDefault(); //for firefox } return; } } this.GrowHeight.onInput(); } this.initDot = null; this.container = this.srcElement; this.container.style.height = $height100(this.container) + "px"; this.container.style.overflow = "hidden"; this.container.setAttribute("contenteditable", "true"); this.container.addEventListener("focus", _focus); var inputEventNames = ["input", "propertychange", "keydown", "keyup", "DOMSubtreeModified"]; for (var iiii = 0; iiii < inputEventNames.length; iiii++) { this.container.addEventListener(inputEventNames[iiii], onDivInput); } this.input = document.createElement("textarea"); this.input.style.display = "none"; this.input.name = this.id; this.container.parentNode.appendChild(this.input); } GrowHeight.prototype.initPlay = function () { if (this.inited === true) return; this.showPadding = 6; function onmouseenter() { this.GrowHeight.val(this.GrowHeight.srcText); this.GrowHeight.show(); this.oriResize = this.style.resize; if (this.GrowHeight.cmsBtn) this.GrowHeight.cmsBtn.updateButtonSize(); this.addEventListener("mouseleave", onmouseleave); } function onmouseleave(event) { if (this.clicked || (event.ctrlKey && event.altKey)) return; this.style.resize = this.oriResize || ""; this.GrowHeight.val(this.GrowHeight.viewText); this.removeEventListener("mouseleave", onmouseleave); this.GrowHeight.hide(); } function onclick_() { this.clicked = !(this.clicked || false); if (this.clicked) { this.oriOutline = this.style.outline; this.oriResize = this.style.resize; this.style.outline = "1px blue auto"; this.style.resize = "both"; this.GrowHeight.onFocus(); } else { this.style.outline = this.oriOutline; this.style.resize = this.oriResize; this.GrowHeight.onBlur(); } } this.container = this.srcElement; // this.container.initDot = function () { // this.innerText = this.GrowHeight.srcText; // this.GrowHeight.viewText = wd.display.ellipsisContent(this, $maxHeight100(this)); // } this.container.style.minHeight = this.minHeight + "px"; //.... this.srcText = this.container.innerText; // this.innerHTML = ""; var ses = this.srcElement.style; var od = { wrapper: this.wrapper.style.cssText, container: this.container.style.cssText }; var initHeight = $maxHeight100(this.container) //平铺开,强制换行 // ses.visibility = "hidden"; // ses.height = ""; ses.wordBreak = "break-all"; ses.wordWrap = "break-word"; //弄成最大宽度,若么有,忽略 this.wrapper.style.width = $MAWS(this.srcElement, 0) + "px"; ses.width = $W(this.wrapper); var th = $MIH(this.container) || this.minHeight, h = $H(this.container); if (h > th) { var lh = $LH(this.container); if (lh > th) { console.info("注意,行高已经超过元素高度,导致元素被撑大") } // this.container.initDot(); this.container.innerText = this.srcText; this.viewText = wd.display.ellipsisContent(this.container, initHeight); this.wrapper.addEventListener("mouseenter", onmouseenter); this.wrapper.addEventListener("dblclick", onclick_) } this.wrapper.style.cssText = od.wrapper; this.container.style.cssText = od.container; this.input = document.createElement("input"); this.input.value = this.wrapper.innerHTML; this.input.type = "hidden"; this.wrapper.parentNode.insertBefore(this.input, this.wrapper); } GrowHeight.prototype.onInput = function () { this.lastScrollTop = this.container.scrollTop; this.updateContainerHeight(); if (this.cmsBtn) { //更新CMS按钮的位置 this.cmsBtn.updateButtonSize(); } this.updateInputValue && this.updateInputValue(); this.onInputCallback && this.onInputCallback.call(this, this.container); } GrowHeight.prototype.onFocus = function () { // { var textDom = this.container; if (textDom.setSelectionRange) { // IE Support textDom.focus(); textDom.setSelectionRange(this.cursorPos, this.cursorPos); } else if (textDom.createTextRange) { // Firefox support var range = textDom.createTextRange(); range.collapse(true); range.moveEnd('character', this.cursorPos); range.moveStart('character', this.cursorPos); range.select(); } this.isFocus = true; } if (this.cmsBtn) { //更新CMS按钮的位置 this.cmsBtn.updateButtonSize(); } this.onFocusCallback && this.onFocusCallback.call(this.GrowHeight, this); } GrowHeight.prototype.onBlur = function () { // { var textDom = this.container; if (document.selection) { // IE Support // 有bug,先注释了,IE会不断获取焦点 // textDom.focus(); var selectRange = document.selection.createRange(); selectRange.moveStart('character', -textDom.value.length); this.cursorPos = selectRange.text.length; } else if (textDom.selectionStart || textDom.selectionStart == '0') { // Firefox support this.cursorPos = textDom.selectionStart; } this.isFocus = false; } if (this.cmsBtn) { //更新CMS按钮的位置 this.cmsBtn.updateButtonSize(); } this.onBlurCallback && this.onBlurCallback.call(this.GrowHeight, this); } GrowHeight.prototype.updateInputValue = function () { function getText() { var nn = this.nodeName; if (nn == "TEXTAREA" || nn == "INPUT") { return this.value; } else if (nn == "DIV") { return this.innerHTML; } else { return this.innerText; } } if (this.input && this.container) { var value = getText.call(this.container); if (this.acceptEnter || this.type > 1) { //接受回车,或者是播放 this.input.value = value; } else { if (this.container.nodeName == 'DIV') { value = value.replace('
', ""); } value = value.replace(/\n/g, ''); this.input.value = value; } } } GrowHeight.prototype.initAsInput = function () { if (this.inited === true) return; var gh = this; var editorOninput = function (e) { if (!this.GrowHeight.acceptEnter) { var et = e || window.event; var keycode = et.charCode || et.keyCode; if (keycode == 13) { if (window.event) { window.event.returnValue = false; } else { e.preventDefault(); //for firefox } return; } } this.GrowHeight.onInput(); this.GrowHeight.updateInputValue(); } // this.onInputCallback = function (container) { // this.updateInputValue(); // } function editorOnfocus() { this.isFocus = true; //浮出来 this.value = this.GrowHeight.input.value; this.GrowHeight.show(); this.focus(); this.addEventListener("blur", editorOnblur); this.GrowHeight.onFocus(); editorOninput.call(this); } function editorOnblur() { this.isFocus = false; //弄回去 this.GrowHeight.updateInputValue(); this.GrowHeight.hide(); this.removeEventListener("blur", editorOnblur); this.GrowHeight.onBlur(); this.initDot(); } var container = this.container = document.createElement("textarea"); this.wrapper.insertBefore(this.container, this.srcElement); //placeholder支持 if (this.srcElement.getAttribute("placeholder")) container.setAttribute("placeholder", this.srcElement.getAttribute("placeholder")); container.GrowHeight = this; //克隆样式 container.className = "form-text"; container.style.width = "100%"; container.style.paddingLeft = "5px"; container.style.paddingTop = "5px"; container.style.resize = "none"; container.style.overflowY = "hidden"; container.style.height = $minHeight100(this.container) + "px"; container.style.minHeight = $minHeight100(this.container) + "px"; var stn = []; //["border", "border-radius"]; for (var i = 0; i < stn.length; i++) { container.style[stn[i]] = $CSS(this.srcElement, stn[i]); } if (this.srcElement.getAttribute("placeholder")) this.container.setAttribute("placeholder", this.srcElement.getAttribute("placeholder")); var inputEventNames = ["input", "propertychange", "keydown", "keyup"]; for (var i = 0; i < inputEventNames.length; i++) { (function (evname) { container.addEventListener(evname, editorOninput); })(inputEventNames[i]); } container.addEventListener("focus", editorOnfocus); container.initDot = function () { wd.display.ellipsisContent(this, $maxHeight100(this)); } this.input = document.createElement("textarea"); this.input.name = this.id; // this.input.style.cssText = container.style.cssText; this.input.style.display = "none"; this.input.GrowHeight = this; this.wrapper.insertBefore(this.input, this.container); this.val(this.srcElement.innerHTML); this.wrapper.removeChild(this.srcElement); this.updateContainerHeight(); } GrowHeight.prototype.getInputElement = function () { return this.container; } GrowHeight.prototype.getInput = function () { return this.container; } GrowHeight.prototype.initPlayHtml = function () { if (this.inited === true) return; this.showPadding = 6; var container = this.container = this.srcElement, that = this; this.minHeight = $minHeight100(container); container.style.height = $maxHeight100(container) + "px"; container.style.overflowY = "auto"; function enter(event) { this.GrowHeight.show(); this.GrowHeight.wrapper.style.overflow = "hidden"; } function leave(event) { this.GrowHeight.hide(); } this.wrapper.addEventListener("mouseenter", enter); this.wrapper.addEventListener("mouseleave", leave); } GrowHeight.prototype.getCmsBtn = function (mode) { if (this.fj == null || (mode == "play" && (this.fj.value == null || this.fj.value == ""))) return; if(mode=="edit"&&this.fj.value == ""){ this.fj.jlztm=1; } var fj = this.fj; var attachment = document.createElement("span"); var attachmentText = document.createTextNode("附件"); attachment.appendChild(attachmentText); this.wrapper.insertBefore(attachment, this.container.nextSibling); attachment.className = 'icon-attachment builtinButton'; //上浮。找到目标的样式修改当前的样式名 if ($(attachment).parents("abc").length > 0) { attachment.className = "123456789"; } var fjidHidden = document.querySelector("[name='" + fj.key + "']"); if (!fjidHidden) { fjidHidden = document.createElement("input"); fjidHidden.type = "hidden"; fjidHidden.name = fj.key; fjidHidden.value = fj.value; attachment.style.display = "none"; attachment.parentNode.insertBefore(fjidHidden, attachment); } var editor = attachment.editor = this.container; var oriTop = $MT(attachment), oriBottom = $MB(attachment), oriLeft = $ML(attachment); attachment.updateButtonSize = function () { var editor = attachment.editor; editor.style.resize = "none"; editor.style.width = $INNERWIDTH(editor.parentNode) - $ML(editor) - $MR(editor) - ($ISBOX(editor) ? 0 : ($BOXWIDTH(editor))) - $REALWIDTH(attachment) - $ML(attachment) - $MR(attachment) + "px"; var editor = attachment.editor; attachment.style.display = "none"; attachment.style.height = $INNERHEIGHT(attachment.parentNode) - oriTop - oriBottom + "px"; attachment.style.verticalAlign = "top"; attachment.style.lineHeight = $INNERHEIGHT(attachment.parentNode) - oriTop - oriBottom + 22 + "px"; attachment.style.display = "inline-block"; attachment.style.position = ''; if ($DSP(editor).indexOf("inline") > -1) { //行内元素 } else { //块元素,浮动在他身边 editor.style.display = "inline-block"; } } //编辑框去掉附件按钮的宽度 function updateCount() { var fjidInput = document.getElementsByName(fj.key)[0]; if (fjidInput == null) return; var fjid = fjidInput.value; if (fjid != null && fjid != "") $.ajax({ type: "post", url: "/service?ssServ=wrCcmsList", // =getSubNrCount",。Lin data: { nrid: "T-" + fjid, jlztm: fj.jlztm }, dataType: "json", // 增加,统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin success: function (data) { /* 改,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin * 去掉 JSON.parse(,改为用 Map 传输 var names = JSON.parse(data); */ if (data.ssCode != 0) { alert(data.ssMsg); return; } var names = data.ssData; var count = names.length; //if (count > 0) { var num = attachment.querySelector(".icon-num"); if (!num) { num = document.createElement("span"); num.className = "icon-num"; num.style.float = "right"; num.style.position = "absolute"; num.style.right = "2px"; num.style.top = "2px"; attachment.appendChild(num); } num.innerText = count; if (count == 0) { $(num).hide(); } else { $(num).show(); } var datas = []; for (var iii = 0; iii < names.length; iii++) { datas.push({ name: iii, value: names[iii] }) } $(attachment).off("mouseenter").on("mouseenter", function () { var menuelement = wd.display.initCmsMenu("cms" + fjid, fj.jlztm, datas); if (menuelement) { menuelement.showAt(attachment); $(attachment).off("mouseleave").on("mouseleave", function () { menuelement.hide(); }); } }); }, error: function (data) { console.log(data); } }); }; if ("play" == mode) { attachment.addEventListener("click", function (e) { var fn = window[fj.key + "fjPlay"]; fn && fn.call(this); e.stopPropagation() }); } else if ("edit" == mode) { var fnName = fj.key + "CallbackName"; var fnName = window[fnName] = fj.key + "mouseover"; window[fnName] = updateCount; attachment.addEventListener("mouseenter", window[fnName]); attachment.addEventListener("click", function (e) { var fn = window[fj.key + "fjEdit"]; fn && fn.call(this); e.stopPropagation() }); } attachment.updateButtonSize(); editor.initDot && editor.initDot(); updateCount(); return attachment; } GrowHeight.prototype.getElement = function () { return this.wrapper; } GrowHeight.prototype.init = function () { if (!this.inited) { var styleAttrNames = { "width": "width", "height": "height" }; for (var key in styleAttrNames) { var attrV = this.srcElement.getAttribute(key); if (attrV != null) { var styleName = styleAttrNames[key]; this.srcElement.style[styleName] = attrV; } this.srcElement.removeAttribute(key); } var h = $REALHEIGHT(this.srcElement); var lh = $LH(this.srcElement); this.minHeight = Math.max(lh || 28, h); this.oriWidth = $REALWIDTH(this.srcElement); this.wrapper = document.createElement("div"); this.wrapper.style.cssText = this.srcElement.style.cssText; this.wrapper.style.minHeight = this.minHeight + "px"; this.wrapper.className = this.srcElement.className; this.srcElement.GrowHeight = this; this.srcElement.className = ""; this.srcElement.style.width = ""; this.srcElement.style.maxWidth = ""; this.srcElement.style.cssText = ""; this.srcElement.parentNode.insertBefore(this.wrapper, this.srcElement); this.wrapper.appendChild(this.srcElement); this.wrapper.GrowHeight = this; this.wrapper.setAttribute("growHeight", this.name); this.id = this.srcElement.id; switch (this.type) { case 0: this.wrapper.className += " input-div"; this.initAsInput(); this.cmsBtn = this.getCmsBtn("edit"); break; case 1: this.wrapper.className += " input-div"; this.initAsDiv(); this.cmsBtn = this.getCmsBtn("edit"); break; case 2: this.initPlayHtml(); this.cmsBtn = this.getCmsBtn("play"); break; case 3: default: this.initPlay(); this.cmsBtn = this.getCmsBtn("play"); break; } if (this.container) { var that = this; this.container.id = this.id; this.container.className += " smallScrollbar"; var passiveSupported = false; try { var options = Object.defineProperty({}, "passive", { get: function () { passiveSupported = true; } }); window.addEventListener("test", null, options); } catch (err) {} this.container.addEventListener("mousewheel", function (e) { that.lastScrollTop = that.container.scrollTop; }, passiveSupported ? { passive: true } : false); this.container.addEventListener('paste', function (e) { console.log("paste") if (!this.GrowHeight.acceptEnter) { var vvv = (e.clipboardData || window.clipboardData).getData('text/plain').replace(/\n/g, ""); this.focus(); if (document.all) { var r = document.selection.createRange(); document.selection.empty(); r.text = vvv; r.collapse(); r.select(); } else { var newstart = this.selectionStart + vvv.length; var pfx = this.value.substr(0, this.selectionStart); var sfx = this.value.substring(this.selectionEnd); this.value = pfx + vvv + sfx; this.selectionStart = newstart; this.selectionEnd = newstart; } e.preventDefault(); e.stopPropagation(); return false; this.GrowHeight.onInput(); } }); } this.inited = true; this.hide(); } // loadSmallScorll($(this.wrapper).find(".smallScrollbar")); // 初始化伪滚动条 } function $ISBOX(element) { return $CSS(element, "box-sizing") == "border-box"; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// function $PT(element) { $ISBOX(element); return $NUMOFCSS(element, "padding-top", 0); } function $PR(element) { return $NUMOFCSS(element, "padding-right", 0); } function $PB(element) { return $NUMOFCSS(element, "padding-bottom", 0); } function $PL(element) { return $NUMOFCSS(element, "padding-left", 0); } function $CSS(element, name) { if (typeof(window.getComputedStyle) == 'undefined') { return element.currentStyle[name]; } return window.getComputedStyle(element)[name]; } function $DSP(element) { return $CSS(element, "display"); } function $NUMOFCSS(element, name, def) { var v = parseFloat($CSS(element, name)); v = isNaN(v) ? def : v; return v; } function $W(element) { return $NUMOFCSS(element, "width"); } function $H(element) { return $NUMOFCSS(element, "height"); } function $R(element) { return $NUMOFCSS(element, "right"); } function $MAH(element) { return $NUMOFCSS(element, "max-height"); } function $MIH(element) { return $NUMOFCSS(element, "min-height"); } function $MT(element) { return $NUMOFCSS(element, "margin-top", 0); } function $MB(element) { return $NUMOFCSS(element, "margin-bottom", 0); } function $ML(element) { return $NUMOFCSS(element, "margin-left", 0); } function $MR(element) { return $NUMOFCSS(element, "margin-right", 0); } function $BL(element) { return $NUMOFCSS(element, "border-left", 0); } function $BR(element) { return $NUMOFCSS(element, "border-right", 0); } function $BOXWIDTH(element) { return $PL(element) + $PR(element) + $BL(element) + $BR(element); } function $BOXHEIGHT(element) { return $PT(element) + $PB(element) + $BT(element) + $BB(element); } function $MAWS(element, def) { var va = $CSS(element, "max-width"); va = isNaN(parseFloat(va)) ? $CSS(element, "width") : va; return isNaN(parseFloat(va)) ? def : va; } function $REALHEIGHT(element) { var b = $ISBOX(element); var height = $NUMOFCSS(element, "height"); if (height == null || typeof(height) == 'undefined') { //兼容IE8 console.log("兼容IE8"); height = 35; } if (!b) { height += $BOXHEIGHT(element); } return height; } function $REALWIDTH(element) { var b = $ISBOX(element); var width = $NUMOFCSS(element, "width"); if (!b) { width += $BOXWIDTH(element); } return width; } function $INNERWIDTH(element) { var b = $ISBOX(element), width = $NUMOFCSS(element, "width"); if (b) { width -= $BOXWIDTH(element); } return width; } function $INNERHEIGHT(element) { var b = $ISBOX(element), height = $NUMOFCSS(element, "height"); if (height == null || typeof(height) == 'undefined') { //兼容IE8 height = 38 } if (b) { height -= $BOXHEIGHT(element); } return height; } function $LH(element, default_) { return $NUMOFCSS(element, "line-height", default_); } function $HIDDENOVERFLOW(element) { var h = []; var a = []; var p = element; while (p.parentNode && p.parentNode.nodeType == 1) { p = p.parentNode; if (p.parentNode.nodeType != 1) break; var ofy = $CSS(p, "overflow-y"); if ((ofy.indexOf("auto") > -1 || ofy.indexOf("scroll") > -1) && p.scrollHeight != p.clientHeight) { //滚动高度等于元素高度的就算了 a.push(p); } else if (ofy == "hidden") { h.push(p); var eb = element.getBoundingClientRect(); var pb = p.getBoundingClientRect(); var ph = $height100(p), eh = $maxHeight100(element) - pb.top + eb.top; if (ph < eh) { return p; } } } p = h.length > 0 ? h[0] : (a.length > 0 ? a[0] : document.body.parentNode); return p; } function $BT(element) { return $NUMOFCSS(element, "border-top", 0); } function $BB(element) { return $NUMOFCSS(element, "border-bottom", 0); } function debugLog() { event && event.ctrlKey && console.trace.apply(this, arguments); } function $innerHeight(element, height) { var p = element.parentNode; if ($ISBOX(p)) { //父级是box,要减掉padding,border height -= $BOXHEIGHT(p); } return height; } function $height100(element) { return $innerHeight(element, $INNERHEIGHT(element.parentNode)); } function $minHeight100(element) { return $innerHeight(element, element.GrowHeight.minHeight); } function $maxHeight100(element) { return $innerHeight(element, $INNERHEIGHT(element.parentNode)); } function $scrollHeight100(element) { return $innerHeight(element, element.scrollHeight); }