function initWdDragHeight(offsetheight, topNum) {
line(offsetheight);
if(true)return
var reduceHeight = window.innerHeight - document.body.offsetHeight
var TAGATTRIBUTE = "ssDragh"; // = "wdDragHeight"。Lin
var iframes = document.querySelectorAll("[" + TAGATTRIBUTE + "]");
var lines = document.querySelectorAll("#line");
var maxHeight = (window.innerHeight || window.screen.availHeight) - offsetheight;
for (var i = 0; i < iframes.length; i++) {
iframes[i].setHeight = function (v) {
this.style.height = v + "px";
this.height = v;
}
}
if(iframes.length>0&&lines.length==0){
var line_div = document.createElement('div'); // 新增元素
line_div.className ="content-hSeperator";
line_div.id = "line";
line_div.innerHTML = "
";
iframes[1].parentNode.insertBefore(line_div, iframes[1]); // 在这个元素前面增加上去
}
//抽取top数值与topNum相同iframes。
if (topNum != null) {
var temp = [];
for (var i = 0; i < iframes.length; i++) {
var array = /top\s*?:\s*?(\d+)/ig.exec(iframes[i].getAttribute(TAGATTRIBUTE))
if (array != null && array[1] == topNum) {//无top参数并且topNum为1时
temp.push(iframes[i]);
}
}
iframes = temp
} else {//topNum为null默认为第一层
var temp = [];
for (var i = 0; i < iframes.length; i++) {
if (!/top\s*?:\s*?(\d+)/ig.test(iframes[i].getAttribute(TAGATTRIBUTE))) {//无top参数并且topNum为1时
temp.push(iframes[i]);
} else if (/top\s*?:\s*?1/ig.test(iframes[i].getAttribute(TAGATTRIBUTE))) {
temp.push(iframes[i]);
}
}
iframes = temp;
}
if (iframes.length == 0) return;
//如果iframes的长度大于0执行自适应
var usableHeight = 0;
if (topNum == null || topNum < 2) {//第一层的处理,iframes可以适应的高度计算
usableHeight = reduceHeight;
for (var i = 0; i < iframes.length; i++) {
usableHeight += iframes[i].offsetHeight;
}
//如果有bjgd数据,优先使用bjgd
if (offsetheight != null) {
usableHeight = maxHeight;
}
} else {
var p = findParent(iframes[0], topNum - 1);//查找上一级的自适应元素,用于获取高
var pWdFitHeight = p.getAttribute(TAGATTRIBUTE);
var array = /fixHeight\s*?:\s*?(\d+)/ig.exec(pWdFitHeight);
if (array != null) {
usableHeight = p.offsetHeight - parseInt(array[1]);
} else {
usableHeight = p.offsetHeight;
}
}
// console.log("usableHeight: " + usableHeight);
//禁止滚动条
document.body.style.overflow = "hidden";
var heightArr = [];//存放计算后得到的height百分
var minHighArr = [];//存放iframe的minHigh
var maxHighArr = [];//存放iframe的maxHigh
var currentHeight = 0;//当前百分比
var hasHeightCount = 0;
for (var i = 0; i < iframes.length; i++) {
var wdFitHeight = iframes[i].getAttribute(TAGATTRIBUTE);
var array = /(\d+)%/.exec(wdFitHeight);
if (!!array) {
heightArr[i] = parseInt(array[1]);
currentHeight += parseInt(array[1]);
hasHeightCount++;
}
array = /min\s*?:\s*?(\d+)/.exec(wdFitHeight)
if (!!array) {
minHighArr[i] = parseInt(array[1]);
}
array = /max\s*?:\s*?(\d+)/.exec(wdFitHeight)
if (!!array) {
maxHighArr[i] = parseInt(array[1]);
}
}
//重新计算heightArr;
//计算百分比
if (currentHeight < 100) {
var a = (100 - currentHeight) / (iframes.length - hasHeightCount);
for (var i = 0; i < iframes.length; i++) {
if (!!!heightArr[i]) {
heightArr[i] = a;
currentHeight += a;
}
}
}
var temp = usableHeight;
// tip("usableHeight:"+usableHeight,true)
//min max 限制百分比高度
for (var i = 0; i < iframes.length; i++) {
//百分比高度
var height = usableHeight * heightArr[i] / 100;
//限定高度最大值
if (height > temp) {
height = temp;
temp = 0;
} else {
//最小值
if (!!minHighArr[i] && minHighArr[i] > height) {
height = minHighArr[i];
//最大值
} else if (!!maxHighArr[i] && maxHighArr[i] < height) {
height = maxHighArr[i];
}
temp -= height;
}
// if(iframes[i].name && iframes[i].name.indexOf('Edit') != -1) {
// height -= 107;
// }
// console.log("height:" + height);
iframes[i].style.height = height + "px";
// iframes[i].setHeight(height);
// var ifr=iframes[i].querySelector("iframe");
// if(ifr){
// ifr.height=height;
// ifr.style.height=height;
// }
}
//计算内层wdFitHeight元素
if (topNum == null) {
arguments.callee(offsetheight, 2)
} else {
arguments.callee(offsetheight, topNum + 1);
}
line(offsetheight);
function findParent(ele, topNum) {
var cur = ele;
do {
cur = cur.parentElement;
if (cur == null)
return null;
if (new RegExp('top\s*?:\s*?' + topNum, 'ig').test(cur.getAttribute(TAGATTRIBUTE))) {
return cur;
}
} while (true);
return null;
}
}
//初始化拖动线
function line(offsetheight) {
var iframes = document.querySelectorAll("[ssDragh]"); // ("[" + "wdDragheight" + "]")。Lin
if (iframes.length != 2) return
for (var i = 0; i < iframes.length; i++) {
iframes[i].setHeight = function (v) {
this.style.height = v + "px";
this.height = v;
}
}
var lines = document.querySelectorAll("#line");
if(iframes.length>0&&lines.length==0){
var line_div = document.createElement('div'); // 新增元素
line_div.className ="content-hSeperator";
line_div.id = "line";
//拖动遮罩层
var mask="