class AdjustHelper {
//为避免js的小数自动向上转换的问题 比如说0.76666666666变成0.77
static ToFixed(num, fractionDigits) {
fractionDigits = fractionDigits || 0;
var numStr = num.toString();
var index = numStr.indexOf('.');
if (index !== -1) {
return numStr.substring(0, index + fractionDigits + 1) * 1;
}
else {
return num;
}
}
static Breaker(obj, id) {
if (obj && (obj.RowId == id || obj.CtrlId == id || obj.ElementId == id || obj.IndexFlag == id || (obj.ControlInfo && (
obj.ControlInfo.RowId == id || obj.ControlInfo.CtrlId == id || obj.ControlInfo.ElementId == id || obj.ControlInfo.IndexFlag == id
)))) debugger;
}
static GetCssPixelSize(ele, cssName) {
if (ele.length >= 1) {
var cssVal = ele.css(cssName);
if (cssVal) {
return cssVal.replace("px", "") * 1;
}
else {
return 0;
}
}
else {
return 0;
}
}
static GetScrollHeight(ele) {
return ele.length > 0 ? ele[0].scrollHeight : 0
}
static ReplaceEle(oriEle, newEle) {
//不可以用replaceWith 否则事件不会copy过来
var tempClassName = Math.random().toString().split(".")[1];
oriEle.replaceWith(`
`);
newEle.insertBefore($(`.${tempClassName}`));
$(`.${tempClassName}`).remove();
}
static GetPicSize(imgEle) {
if (imgEle.length > 0) {
return { width: imgEle[0].naturalWidth, height: imgEle[0].naturalHeight }
}
else {
return { width: 0, height: 0 }
}
}
static HasSetBgColor(color) {
return !(color === "rgba(0, 0, 0, 0)" || color === "transparent" || color == "");
}
static GetBackGround(ele) {
var re = /(#([0-9A-Fa-f]{3,6})\b)|(aqua)|(black)|(blue)|(fuchsia)|(gray)|(green)|(lime)|(maroon)|(navy)|(olive)|(orange)|(purple)|(red)|(silver)|(teal)|(white)|(yellow)|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\))/g;
var backgroundCss = ele.css('background');
var colors = (backgroundCss).match(re);
var color = "rgba(0, 0, 0, 0)";
if (colors) {
for (var i = 0; i < colors.length; i++) {
if (colors[i] != "rgb(0, 0, 0)") {
color = colors[i];
break;
}
}
}
return color;
}
static GetBackGroundColor(ele) {
var backgroundColor = ele.css("background-color");
var hasSetBgColor = AdjustHelper.HasSetBgColor(backgroundColor);
if (hasSetBgColor) {
return backgroundColor;
}
else {
return AdjustHelper.GetBackGround(ele);
}
}
static Sum(arr) {
return arr.reduce((partialSum, a) => partialSum + a, 0);
}
static ReplaceId2Temp(ele) {
ele.attr("id", ele.attr("id") + AdjustConfig.TempIdSuffix);
ele.find("[id]").each((a, b) => {
$(b).attr("id", $(b).attr("id") + AdjustConfig.TempIdSuffix);
});
}
static ResetTempId(ele) {
ele.attr("id", ele.attr("id").replace(AdjustConfig.TempIdSuffix, ""));
ele.find("[id]").each((a, b) => {
$(b).attr("id", $(b).attr("id").replace(AdjustConfig.TempIdSuffix, ""));
});
}
static GetQueryVal(key) {
var params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
return params[key];
}
}
class AdjustConfig {
static MinCtrlXPadding = 10;
static MinCtrlYPadding = 10;
static MinDocumentXPadding = 10;
static MinDocumentYPadding = 10;
//同一行控件上下位置的偏移量 要是误差低于该范围则自动上下对齐
static DeviationOffset = 10;
//判断是否同一行的偏移量 要是同一行的高度小于此高度则不算做同一行
static IntersectOffset = 10;
//判断为小控件的最大值
static TinyCtrlPixelSize = 100;
static DetectCommonColumnPadding = 50;
static DetectCommonColumnMaxWidth = 300;
static DetectHeaderRowMaxHeight = 160;
static MaxOffsetNotCenterPercent = 0.15;
static AutoNavHeight = 50;
static SmallScreenWidth = 640;
//延迟触发毫秒数
static AdjustDelay = 20;
static OffsetThreshold = 30;
static HighWidthProportionPercent = 0.75;
static BigFontSize = 26;
static SkipFixedCtrlWidth = 300;
static SkipCodeCtrlWidth = 100;
static MockMobileWidthThreshold = 420;
static MockMobileWidth = 375;
static TempIdSuffix = "_TEMP_ID";
//是否显示布局的说明
static NeedShowTips = false;
//文章列表等控件中,最小的图片宽度
static MinListPicWidth = 100;
static FixedCtrlFlag = "smartFixed"
//响应式跳过
static UnSupportCtrlList = ["codeCnzz", "qqservice", "form", "submit", "baiduBridge"];
static FullRowCtrlNames = ["navcontainer", "banner", "multicolumn", "fullpage", "dialog"];
static MaxReLoadCount = 50
}
class baseAdjuster {
ControlInfo;
IsSetMinZoom() {
return this.ControlInfo.ControlView && this.ControlInfo.ControlView.attr("MinZoom") !== undefined;
}
get MinZoom() {
if (this.IsSetMinZoom()) {
return this.ControlInfo.ControlView.attr("MinZoom") * 1;
}
return 0.618;
}
constructor(controlInfo) {
this.ControlInfo = controlInfo;
}
PassHiddenCtrls(func) {
var self = this;
var val = 0;
var size = func(self);
if (size > val) {
val = size;
}
return func(self);
}
get CurrentZoomVal() {
return this.ControlInfo.AdjustControlInfo.Width / this.ControlInfo.Width;
}
get CurrentZoomWithMinValLimit() {
return this.CurrentZoomVal > this.MinZoom ? this.CurrentZoomVal : this.MinZoom;
}
static ShowHiddenCtrls(func, scope) {
var filterList = [
"[ctype=tab] .w-label-content-item:not(.current)",
"[ctype=tab] .w-label-tips-item:not(.current)",
"[ctype=tab] .w-label-content-item:not(.current)>.smAreaC",
"[ctype=flexiblePanel] .w-label-item:not(.current)>.w-label-content",
"[ctype=dialog]"
];
var tabCtrlList = [];
filterList.forEach(filterStr => {
var hiddenTabs = $(filterStr);
hiddenTabs.each((a, b) => {
var item = $(b);
tabCtrlList.push(item);
item.addClass("forceShow");
});
});
func(scope);
tabCtrlList.forEach((b) => {
$(b).removeClass("forceShow");
});
}
AdjustListItem(func) {
var self = this;
var zoom = self.CurrentZoomWithMinValLimit;
var ctrlWidth = self.ControlInfo.AdjustControlInfo.Width;
var marginLeft = parseInt(zoom * self.OriMarginLeft || 0);
var oriBorderWidth = self.OriBorderWidth === undefined ? 1 : self.OriBorderWidth;
var newItemWidth = zoom * self.OriPicWidth;
var oneLineCount;
if (newItemWidth > ctrlWidth) {
newItemWidth = ctrlWidth;
marginLeft = 0;
}
else {
oneLineCount = parseInt(ctrlWidth / newItemWidth);
if (oneLineCount == 1) {
marginLeft = 0;
}
ctrlWidth -= marginLeft * (oneLineCount - 1) + (oneLineCount * oriBorderWidth * 2);//1px 左右border
newItemWidth = ctrlWidth / oneLineCount;
}
var newItemHeight = newItemWidth / self.OriPicWidth * self.OriPicHeight;
func(AdjustHelper.ToFixed(newItemWidth), AdjustHelper.ToFixed(newItemHeight), AdjustHelper.ToFixed(marginLeft), oneLineCount);
}
ShouldHideOriNav(ctrl) {
if (ctrl.ControlView && ctrl.ControlView.hasClass("notTransfer2HamburgNav")) {
return false;
}
return (CtrlAdjuster.GetCurrentBrowserWidth() < AdjustConfig.SmallScreenWidth || CtrlAdjuster.IsMobile) && !ctrl.IsChildNodeOfSpecCtrlName("area", "Style3");
}
AppendTips(tips) {
if (!this.ControlInfo.IsVirtualCtrl) {
if (AdjustConfig.NeedShowTips) {
var oriTitle = this.ControlInfo.ControlView.attr("title") || "";
oriTitle += `${oriTitle ? "" : "\n"}${tips}`;
this.ControlInfo.ControlView.attr("title", oriTitle)
}
else {
var oriTitle = this.ControlInfo.DebuggerMsg || [];
// oriTitle += `${oriTitle ? "" : ";"}${tips}`;
oriTitle.push(tips);
this.ControlInfo.DebuggerMsg = oriTitle;
this.ControlInfo.ControlView.attr("DebuggerMsg", oriTitle.join('-->'))
}
}
}
SetWidthAndHeight_OriSize() {
this.AppendTips("设置宽高:原始尺寸");
this.ControlInfo.AdjustControlInfo.Width = this.ControlInfo.DisplayWidth;
}
SetWidthAndHeight_JustWidth(newWidth) {
this.AppendTips("设置宽高:只调整宽度");
this.ControlInfo.AdjustControlInfo.Width = newWidth;
}
SetWidthAndHeight_ZoomHeight(newWidth) {
this.AppendTips("设置宽高:等比缩放");
var zoomVal = newWidth / this.ControlInfo.DisplayWidth;
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.ControlInfo.Height * zoomVal;
}
SetWidthAndHeight_IncreaseHeight(newWidth) {
this.AppendTips("设置宽高:面积保持一致");
var zoomVal = newWidth / this.ControlInfo.DisplayWidth;
this.ControlInfo.AdjustControlInfo.Width = newWidth;
if (zoomVal < 1) {
this.ControlInfo.AdjustControlInfo.Height = this.ControlInfo.DisplayHeight / zoomVal;
}
}
SetWidthAndHeight(newWidth) {
this.SetWidthAndHeight_JustWidth(newWidth);
}
SetSingleCellCtrlLayout_HundredPercent() {
this.AppendTips(`控件宽度与父容器宽度比值高于${AdjustConfig.HighWidthProportionPercent}:触发宽度铺满父级效果`);
var cell = this.ControlInfo;
cell.AdjustControlInfo.Left = cell.ParentXPadding;
cell.CtrlAdjuster.SetWidthAndHeight(cell.AdjustControlInfo.ParentWidthSubPadding);
}
SetSingleCellCtrlLayout_ZoomLayout() {
this.AppendTips("保持原宽度,缩放左边距");
var cell = this.ControlInfo;
cell.AdjustControlInfo.Left = cell.PreLoadAdjustControlInfo.ZoomLeft - (cell.DisplayWidth - cell.PreLoadAdjustControlInfo.ZoomWidth);
cell.CtrlAdjuster.SetWidthAndHeight(cell.DisplayWidth);
}
SetSingleCellCtrlLayout_Center() {
this.AppendTips("居中显示");
var cell = this.ControlInfo;
var adjWidth = cell.DisplayWidth > cell.AdjustControlInfo.ParentWidthSubPadding ? cell.AdjustControlInfo.ParentWidthSubPadding : cell.DisplayWidth;
var left = (cell.AdjustControlInfo.ParentWidthSubPadding - adjWidth) / 2 + cell.ParentXPadding;
cell.AdjustControlInfo.Left = left;
cell.CtrlAdjuster.SetWidthAndHeight(adjWidth);
}
ChangedRowAct(cell, headerCtrlLayout, header) {
this.ChangedRowAct_AlignLeft(cell, headerCtrlLayout, header);
}
ChangedRowAct_WidthAsHeader(cell, headerCtrlLayout, header) {
this.AppendTips("触发换行:与列头保持宽度一致");
cell.AdjustControlInfo.Left = headerCtrlLayout.Left;
cell.CtrlAdjuster.SetWidthAndHeight(headerCtrlLayout.Width);
}
ChangedRowAct_SetCenter(cell, headerCtrlLayout, header) {
this.AppendTips("触发换行:居中显示");
this.SetSingleCellCtrlLayout_Center();
}
ChangedRowAct_AlignLeft(cell, headerCtrlLayout, header) {
this.AppendTips("触发换行:左对齐");
cell.AdjustControlInfo.Left = headerCtrlLayout.Left;
var shouldSameWidthAsHeader = cell.Width / header.Width > AdjustConfig.HighWidthProportionPercent;
if (cell.AdjustControlInfo.Width >= headerCtrlLayout.Width) {
this.AppendTips("调整后宽度大于列头的宽度,则与列头一样宽");
}
if (shouldSameWidthAsHeader) {
this.AppendTips(`原宽度与列头原宽度比值大于${AdjustConfig.HighWidthProportionPercent},则与列头一样宽`);
}
if (//调整后宽度大于header宽度 则与父级一样宽
cell.AdjustControlInfo.Width >= headerCtrlLayout.Width
//或者原来的宽度近似 也与父级一样宽
|| shouldSameWidthAsHeader) {
cell.CtrlAdjuster.SetWidthAndHeight(headerCtrlLayout.Width);
}
}
//宽度达到了父级的宽度的75%以上
IsHightWidthProportion() {
var percent = this.ControlInfo.Width / this.ControlInfo.ParentWidth;
return (percent > AdjustConfig.HighWidthProportionPercent);
}
HundredPercentHandler() {
if (this.IsHightWidthProportion()) {
this.SetSingleCellCtrlLayout_HundredPercent();
}
else {
var cell = this.ControlInfo;
//如果原宽度小于当前父级宽度
if (cell.DisplayWidth > cell.AdjustControlInfo.ParentWidthSubPadding
//是容器
|| cell.IsContainer
//是居中的
|| (Math.abs(((cell.ParentWidth - cell.Width) / 2 - cell.Left)) < AdjustConfig.DeviationOffset)) {
this.SetSingleCellCtrlLayout_Center();
}
else {
this.SetSingleCellCtrlLayout_ZoomLayout();
}
}
}
TagMarkList = null;
ResetTag2OriCss() {
var tagMarkerFlag = "TM";
if (!this.ControlInfo.IsVirtualCtrl) {
if (this.TagMarkList === null) {
this.TagMarkList = [];
var self = this;
var childTagMarkerList = [];
this.ControlInfo.ControlView.find("[ctype]").find(`[${tagMarkerFlag}]`);
this.ControlInfo.ControlView.find(`[${tagMarkerFlag}]`).each((a, b) => {
childTagMarkerList.push($(b).attr(tagMarkerFlag))
});
this.ControlInfo.ControlView.find(`[${tagMarkerFlag}]`).each((a, b) => {
var tmId = $(b).attr(tagMarkerFlag);
if (childTagMarkerList.indexOf(tmId) === -1 && !$(b).attr("[ctype]")) {
self.TagMarkList.push(tmId);
}
});
var ctrlTm = this.ControlInfo.ControlView.attr(tagMarkerFlag);
if (ctrlTm) {
this.TagMarkList.push(ctrlTm);
}
}
this.TagMarkList.forEach(key => {
var css = baseAdjuster.EleOriCssList[key];
if (css != null) {
Object.keys(css).forEach(cssKey => {
$(`[${tagMarkerFlag}=${key}]`).css(cssKey, css[cssKey]);
});
}
});
}
}
Reset2OriCss() {
}
GetDisplayHeight() {
return this.ControlInfo.Height;
}
GetDisplayWidth() {
return this.ControlInfo.Width;
}
CalculateLIsInRow(ele) {
var liList = ele.find("ul").eq(0).find("li");
for (var i = 1; i < liList.length; i++) {
var li = liList.eq(i);
if (li.prev().position().top !== li.position().top) {
return i;
}
}
return liList.length;
}
SetCtrlCss(layout) {
layout = layout || this.ControlInfo.AdjustControlInfo;
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView, layout);
this.SetEleCss(this.ControlInfo.ControlView,
{
top: `${layout.TopWithOffset}px`,
left: `${layout.Left}px`
});
}
SetEleWidthAndHeightByAdjustControlInfo(ele, layout) {
layout = layout || this.ControlInfo.AdjustControlInfo;
this.SetEleCss(ele, {
width: `${layout.Width}px`,
height: `${layout.Height}px`,
})
}
static EleOriCssList = {};
SetEleCss(eleList, css) {
for (var x = 0; x < eleList.length; x++) {
var ele = eleList.eq(x);
if (css.left || css.top) {
//虚拟容器的子节点布局是相对布局
var virtualAreaTopOffset = 0;
var virtualAreaLeftOffset = 0
var parent = this.ControlInfo.Parent;
while (parent != null && parent.IsVirtualContainer) {
virtualAreaTopOffset += parent.AdjustControlInfo.TopWithOffset;
virtualAreaLeftOffset += parent.AdjustControlInfo.Left;
parent = parent.Parent;
}
if (css.top && typeof css.top === "string") {
css.top = css.top.replace("px", "") * 1 + virtualAreaTopOffset;
}
if (css.left && (typeof css.left === "string")) {
css.left = css.left.replace("px", "") * 1 + virtualAreaLeftOffset;
}
}
if (css.width && ele.css("min-width") !== "0px") {
css["min-width"] = css.width;
}
if (css.height && ele.css("min-height") !== "0px") {
css["min-height"] = css.height;
}
var tagMarker = ele.attr("TM");
var existingEle;
if (!baseAdjuster.EleOriCssList[tagMarker]) {
existingEle = baseAdjuster.EleOriCssList[tagMarker] = {};
}
else {
existingEle = baseAdjuster.EleOriCssList[tagMarker]
}
Object.keys(css).forEach(key => {
if (!(key in existingEle)) {
existingEle[key] = ele[0].style[key];
}
ele.css(key, css[key]);
});
}
}
static InitAdjuster(controlInfo) {
return eval(`typeof ${controlInfo.CtrlName}Adjuster==="function"?new ${controlInfo.CtrlName}Adjuster(controlInfo): new baseAdjuster(controlInfo)`);
}
AdjustLayout(ctrlAdjuster) {
var cell = this.ControlInfo;
cell.DebuggerMsg = null;
var ctrlId = cell.CtrlId;
var row = cell.RowInfo;
var cells = row.Cells;
var layoutTable = row.LayoutTable;
var newColumnCount = layoutTable.ColumnCount;
var prevCtrlList = cell.PrevCtrls;
var ctrlIndexOfRow = ctrlAdjuster.GetCtrlIndexOfRow(ctrlId, cells);
var headerCtrl = ctrlAdjuster.GetHeaderByIndex(ctrlIndexOfRow, cells, newColumnCount);
var header = cells.find(i => i.CtrlId == headerCtrl.CtrlId);
var headerCtrlLayout = header ? header.AdjustControlInfo : null;
var overflowStartIndex = CtrlAdjuster.GetOverflowStartIndex(row);
var oneLineCount = overflowStartIndex;
var isOverflowOfLine = overflowStartIndex !== null ? ctrlIndexOfRow >= overflowStartIndex : false;
var lastline = ctrlAdjuster.GetLastline(prevCtrlList);
function AfterLastCtrlAdjusted(firstLine) {
var firstCtrl = firstLine[0];
var lastCtrl = firstLine[firstLine.length - 1];
var firstPreLoadRowAdjustControlInfo = firstCtrl.RowInfo.PreLoadRowAdjustControlInfo.find(i => i.CtrlId === firstCtrl.CtrlId);
var lastPreLoadRowAdjustControlInfo = firstCtrl.RowInfo.PreLoadRowAdjustControlInfo.find(i => i.CtrlId === lastCtrl.CtrlId);
var firstLineWidth = firstLine.map(i => i.Width).reduce((a, b) => a + b, 0)
var widthOffset = firstCtrl.ParentWidth - firstPreLoadRowAdjustControlInfo.ZoomLeft - lastPreLoadRowAdjustControlInfo.ZoomRight;
if (widthOffset > 0) {
var totalRedundantWidthPerCtrl = 0;
for (var i = 0; i < firstLine.length; i++) {
var ctrl = firstLine[i];
var redundantWidthPerCtrl = ctrl.Width / firstLineWidth * widthOffset
ctrl.Left += totalRedundantWidthPerCtrl;
totalRedundantWidthPerCtrl += redundantWidthPerCtrl;
ctrl.ControlInfo.CtrlAdjuster.SetWidthAndHeight(ctrl.Width + redundantWidthPerCtrl);
}
}
}
//溢出了
if (isOverflowOfLine) {
this.AppendTips("行宽度溢出");
if (cell.IsFirstCell) {
this.AppendTips(`首个控件左边距调整为${cell.ParentXPadding}`);
cell.AdjustControlInfo.Left = cell.ParentXPadding;
cell.CtrlAdjuster.SetWidthAndHeight(cell.AdjustControlInfo.ParentWidthSubPadding);
}
else {
var createNewLine = lastline.length >= oneLineCount;
var lineNum = cell.AdjustControlInfo.LineNum;
if (createNewLine && lineNum === 1) {
AfterLastCtrlAdjusted(cell.AdjustControlInfo.LastLine);
}
//这种待验证
//cell.AdjustControlInfo.Top = cell.AdjustControlInfo.PrevLineCell.AdjustControlInfo.Bottom + cell.ParentYPadding;
//这种模式会有空白 如http://1178735479.puy.scd.wezhan.cn,主要问题是top是在子级高度变化之前调整的
var oriTop = cell.AdjustControlInfo.Top;
cell.AdjustControlInfo._top = Math.max.apply(Math, prevCtrlList.filter(i => i.AdjustControlInfo.LineNum == lineNum - 1).map(function (o) { return o.AdjustControlInfo.Bottom; })) + cell.ParentYPadding;
var topOffset = cell.AdjustControlInfo.Top - oriTop;
var heightOffset = cell.Height;
var prevLineCell = cell.AdjustControlInfo.PrevLineCell;
//以防有bug卡死
var maxLoop = 10000;
while (prevLineCell != null && prevLineCell.AdjustControlInfo.LineNum > 0 && --maxLoop > 0) {
//加上控件的原始高度,因为调整后的高度已经加过一次到parent了
heightOffset += prevLineCell.Height;
prevLineCell = prevLineCell.AdjustControlInfo.PrevLineCell;
}
if (maxLoop === 0) {
console.error(`触及了最大循环次数${maxLoop},已强制终止遍历`)
}
//取较小的差值
var smallOneOffset = heightOffset > topOffset ? topOffset : heightOffset
cell.AdjustControlInfo.AddParentHeight(smallOneOffset + (lineNum + 1) * cell.ParentYPadding);
this.ChangedRowAct(cell, headerCtrlLayout, header);
}
}
//没有溢出
else {
this.AppendTips("行宽度未溢出");
if (cells.length === 1) {
this.HundredPercentHandler(cell);
}
else {
cell.AdjustControlInfo.Left = cell.PreLoadAdjustControlInfo.ZoomLeft;
cell.CtrlAdjuster.SetWidthAndHeight(cell.PreLoadAdjustControlInfo.ZoomWidth);
}
}
if (!cell.IsVirtualCtrl) {
if (!cell.ControlView.attr("has_mousemove")) {
cell.ControlView.attr("has_mousemove", true);
cell.ControlView.on("mouseup", () => {
window.ctrlTester = cell;
console.log({
Ctrl: cell,
CtrlId: cell.CtrlId,
IndexFlag: cell.IndexFlag,
CtrlName: cell.CtrlName,
AdjustControlInfo: cell.AdjustControlInfo,
RowInfo: cell.RowInfo,
});
});
}
}
return cell;
}
static NavLiIndex = 0;
GenerateNav(navInfo) {
var self = this;
var tree = navInfo.Tree;
var templateStr = self.GenerateNavHtml(tree);
self.ControlInfo.ControlView.children().eq(0).hide();
var navId = `${self.ControlInfo.CtrlId}_nav`;
self.ControlInfo.ControlView.prepend(`${templateStr}
`);
var nav = $(`.${navId}`);
nav.slicknav({
label: "",
prependTo: self.ControlInfo.ControlView,
duration: 50,
openedSymbol: "",
closedSymbol: "",
afterOpen: function (trigger) {
// 打开同时把同级别的其他关闭
var current = $(trigger)
if (current.hasClass('slicknav_item')) {
current.parent('.slicknav_parent').siblings('.slicknav_open').children('a.slicknav_item').click();
}
}
});
nav.remove();
var autoCreatedNav = this.ControlInfo.ControlView.find(".slicknav_menu");
function FormatLayout() {
autoCreatedNav.find("li").css({
color: navInfo.ForegroundColor,
"margin-top": "10px",
"margin-left": 0,
"min-height": "40px"
})
autoCreatedNav.css({
"background-color": navInfo.BackgroundColor,
});
autoCreatedNav.find(".slicknav_item").css("color", navInfo.ForegroundColor);
autoCreatedNav.find(".mw-iconfont").remove();
}
FormatLayout();
}
static GetNavColor(foregroundEleList, backgroundEleList) {
var foregroundColorList = {};
var backgroundColorList = {};
foregroundEleList.each((a, b) => {
//以防只有一个导航时无法取到颜色
if ($(b).closest('ul').find('li').length <= 1 || $(b).closest(".current").length === 0) {
foregroundColorList[$(b).css("color")] = foregroundColorList[$(b).css("color")] || 1;
++foregroundColorList[$(b).css("color")];
}
})
backgroundEleList.each((a, b) => {
if ($(b).closest('ul').find('li').length <= 1 || $(b).closest(".current").length === 0) {
var bgColor = AdjustHelper.GetBackGroundColor($(b));
backgroundColorList[bgColor] = backgroundColorList[bgColor] || 1;
++backgroundColorList[bgColor];
}
});
var foregroundColorInfo = { Counter: 0, Color: "" };
var backgroundColorInfo = { Counter: 0, Color: "" };
Object.keys(backgroundColorList).forEach(key => {
if (backgroundColorList[key] > backgroundColorInfo.Counter) {
backgroundColorInfo.Counter = backgroundColorList[key];
backgroundColorInfo.Color = key;
}
})
Object.keys(foregroundColorList).forEach(key => {
if (foregroundColorList[key] > foregroundColorInfo.Counter && key !== backgroundColorInfo.Color) {
foregroundColorInfo.Counter = foregroundColorList[key];
foregroundColorInfo.Color = key;
}
})
return {
BackgroundColor: backgroundColorInfo.Color,
ForegroundColor: foregroundColorInfo.Color,
}
}
GenerateNavHtml(tree) {
var self = this;
var isATagRedirect = true;
if (this.ControlInfo.CtrlName === "category" && (this.ControlInfo.StyleName === "Style4")) {
isATagRedirect = false;
}
if (tree.length > 0) {
var html = "";
tree.forEach(item => {
var clickId = baseAdjuster.NavLiIndex++;
item.ele.attr("nav-click-id", clickId);
html += `- ${item.text}${self.GenerateNavHtml(item.children)}
`;//
})
html += "
"
return html;
}
else {
return "";
}
}
SetLzparallax(lzparallaxEle) {
var data = lzparallaxEle.data("lzparallax");
if (data && data.status && data.status.boxSize.length > 0) {
var methods = data.methods;
methods._getWindowSize();
methods._getBoxSize();
methods._getBoxPosition();
methods.$ele.children('.lz-parallax-bg').find('.lz-parallax-bg-inner').css({
left: data.status.boxPosition[0],
width: data.status.boxSize[0]
});
methods._movePosition(false);
}
}
GetAllChildrenByParentId(ctrlId) {
var children = CtrlAdjuster.StaticCtrlList.filter(i => i.Parent && i.ParentId == ctrlId);
if (children.length === 0) {
return children;
}
else {
for (var x = 0; x < children.length; x++) {
children = children.concat(this.GetAllChildrenByParentId(children[x].CtrlId));
}
return children;
}
}
}
class fixMinZoomAs1Adjuster extends baseAdjuster {
get MinZoom() {
return this.IsSetMinZoom() ? super.MinZoom : 1;
}
constructor(controlInfo) {
super(controlInfo);
}
}
class imageAdjuster extends baseAdjuster {
FillType = null;
constructor(controlInfo) {
super(controlInfo);
var cutFillBox = this.ControlInfo.ControlView.find(".w-image-box");
if (cutFillBox.length) {
this.FillType = cutFillBox.attr("data-filltype");
}
}
get MinZoom() {
return this.IsSetMinZoom() ? super.MinZoom : (this.IsTinyImage ? 1 : super.MinZoom);
}
get MaxZoom() {
return 1.618;
}
get IsTinyImage() {
return this.ControlInfo.DisplayWidth <= AdjustConfig.TinyCtrlPixelSize;
}
IsReachMaxZoom(newWidth) {
var zoomVal = newWidth / this.ControlInfo.DisplayWidth;
return zoomVal > this.MaxZoom
}
SetWidthAndHeight(newWidth) {
if (this.IsReachMaxZoom(newWidth)) {
var maxWidth = this.ControlInfo.Width * this.MaxZoom;
this.ControlInfo.AdjustControlInfo.Width = maxWidth;
this.ControlInfo.AdjustControlInfo.Height = this.ControlInfo.Height * this.MaxZoom;
this.ControlInfo.AdjustControlInfo.Left += (newWidth - maxWidth) / 2;
}
else {
this.SetWidthAndHeight_ZoomHeight(newWidth);
}
}
GetImageLayout() {
return this.IsReachMaxZoom(this.ControlInfo.AdjustControlInfo.Width) ? {
Left: this.ControlInfo.AdjustControlInfo.Left += (this.ControlInfo.AdjustControlInfo.Width - this.ControlInfo.Width * this.MaxZoom) / 2,
Width: this.ControlInfo.Width * this.MaxZoom,
Height: this.ControlInfo.AdjustControlInfo.Height,
Top: this.ControlInfo.AdjustControlInfo.Top,
TopWithOffset: this.ControlInfo.AdjustControlInfo.TopWithOffset
} :
{
Left: this.ControlInfo.AdjustControlInfo.Left,
Width: this.ControlInfo.AdjustControlInfo.Width,
Height: this.ControlInfo.AdjustControlInfo.Height,
Top: this.ControlInfo.AdjustControlInfo.Top,
TopWithOffset: this.ControlInfo.AdjustControlInfo.TopWithOffset
}
}
Reset2OriCss() {
if (this.FillType !== null) {
InitImageSmv(this.ControlInfo.CtrlId, this.ControlInfo.Width, this.ControlInfo.Height, this.FillType, this.ControlInfo.ControlView.find("img")[0]);
}
}
SetCtrlCss() {
var layout = this.GetImageLayout();
super.SetCtrlCss(layout);
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find("img"));
if (this.FillType !== null) {
InitImageSmv(this.ControlInfo.CtrlId, this.ControlInfo.AdjustControlInfo.Width, this.ControlInfo.AdjustControlInfo.Height, this.FillType, this.ControlInfo.ControlView.find("img")[0])
}
//要在image-clip-wrap调节后再调节父级
if (this.ControlInfo.MightBeBackground) {
this.SetEleCss(this.ControlInfo.ControlView, { "z-index": -99 })
}
}
}
class logoimageAdjuster extends imageAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class lineAdjuster extends baseAdjuster {
get MinZoom() {
return this.IsSetMinZoom() ? super.MinZoom : (this.IsVerticalLine_Local ? 0.1 : super.MinZoom);
}
constructor(controlInfo) {
super(controlInfo);
}
get IsLine() {
return this.ControlInfo.CtrlName === "line";
}
get IsVerticalLine() {
return false;// return this.IsLine && this.ControlInfo.ControlView.attr("re-direction") === "y";
}
//x是横线,y是竖线
//是否竖线
get IsVerticalLine_Local() {
return this.IsLine && this.ControlInfo.ControlView.attr("re-direction") === "y";
}
IsOnCtrlLeft;
LeanOnCtrl = null;
LeanOnPadding = 0;
SetWidthAndHeight(newWidth) {
if (this.IsVerticalLine_Local) {
return;
}
else {
this.SetWidthAndHeight_JustWidth(newWidth);
}
}
SetCtrlCss() {
super.SetCtrlCss();
//横线才设置宽度,竖线不设置
if (!this.IsVerticalLine_Local) {
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find("a"));
this.SetEleCss(this.ControlInfo.ControlView.find(".w-line"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
}
}
}
class buttonAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
super.SetCtrlCss();
switch (this.ControlInfo.StyleName) {
//case "Style1": {
// break;
//}
default: {
var el = this.ControlInfo.ControlView.find("a")
this.SetEleCss(el, {
'box-sizing': 'border-box'
})
this.SetEleWidthAndHeightByAdjustControlInfo(el);
}
}
}
}
class multicolumnVirtualItemAdjuster extends baseAdjuster {
// multicolumn 响应式优化
get MinZoom() {
return CtrlAdjuster.GetCurrentBrowserWidth() <= 500 ? 1 : super.MinZoom;
}
constructor(controlInfo) {
super(controlInfo);
}
get IsFullScreen() {
return this.ControlInfo.Parent.CtrlAdjuster.IsFullScreen;
}
Reset2OriCss() {
// multicolumn 响应式优化
super.Reset2OriCss();
}
SetWidthAndHeight(newWidth) {
this.SetWidthAndHeight_JustWidth(newWidth);
}
SetCtrlCss() {
// multicolumn 响应式优化
var zoomVal = Math.min(this.CurrentZoomVal , 1)
var spacing = this.ControlInfo.Parent.ControlView.find('.w-columns').attr("data-spacing");
spacing = parseInt(spacing * zoomVal / 2)
var topOffset = AdjustConfig.MinCtrlYPadding
switch (this.ControlInfo.StyleName) {
case "Style1":
{
if (this.IsFullScreen) {
//this.ControlInfo.ControlView.css({ width: `${this.ControlInfo.AdjustControlInfo.Width}px`, height: `${this.ControlInfo.AdjustControlInfo.Height}px` });
//this.ControlInfo.ControlView.find(".w-columns-content-inner").css({ width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
//this.ControlInfo.ControlView.find(".w-columns-interval").css({ padding: `0` });
this.SetEleCss(this.ControlInfo.ControlView, {
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
marginTop: `${topOffset}px`
});
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-content-inner"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-interval"), { 'padding': `0 ${spacing}px` })
}
else {
this.SetEleCss(this.ControlInfo.ControlView, {
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
marginTop: `${topOffset}px`
});
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-content-inner"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-interval"), { 'padding': `0 ${spacing}px` })
}
break;
}
case "Style2":
{
if (this.IsFullScreen) {
// this.ControlInfo.ControlView.find(".lz-parallax-bg-inner").css({ width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
// this.ControlInfo.ControlView.find(".lz-parallax-bg").css({ clip: `rect(0px, ${this.ControlInfo.AdjustControlInfo.Width}px, ${this.ControlInfo.AdjustControlInfo.Height}px, 0px)` });
// this.ControlInfo.ControlView.css({ width: `${this.ControlInfo.AdjustControlInfo.Width}px`, height: `${this.ControlInfo.AdjustControlInfo.Height}px` });
// this.ControlInfo.ControlView.find(".w-columns-content-inner").css({ width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
// this.ControlInfo.ControlView.find(".w-columns-interval").css({ padding: `0` });
this.SetEleCss(this.ControlInfo.ControlView.find(".lz-parallax-bg-inner"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".lz-parallax-bg"), { clip: `rect(0px, ${this.ControlInfo.AdjustControlInfo.Width}px, ${this.ControlInfo.AdjustControlInfo.Height}px, 0px)` })
this.SetEleCss(this.ControlInfo.ControlView, {
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
marginTop: `${topOffset}px`
});
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-content-inner"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-interval"), { 'padding': `0 ${spacing}px` })
}
else {
this.SetEleCss(this.ControlInfo.ControlView.find(".lz-parallax-bg-inner"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".lz-parallax-bg"), { clip: `rect(0px, ${this.ControlInfo.AdjustControlInfo.Width}px, ${this.ControlInfo.AdjustControlInfo.Height}px, 0px)` })
this.SetEleCss(this.ControlInfo.ControlView, {
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
marginTop: `${topOffset}px`
});
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-content-inner"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns-interval"), { 'padding': `0 ${spacing}px` })
}
break;
}
default: {
break;
}
}
}
}
class multicolumnAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
get IsFullScreen() {
return this.ControlInfo.ControlView.find(".fullScreen").length !== 0;
}
Reset2OriCss() {
// multicolumn 响应式优化
super.Reset2OriCss()
if (this.IsFullScreen) {
var browserWidth = CtrlAdjuster.GetCurrentBrowserWidth();
var left = (browserWidth - CtrlAdjuster.GetOriPageWidth()) / 2;
var mc = $(`#mc_${this.ControlInfo.CtrlId}.fullScreen`);
mc.css({ width: `${browserWidth}px`, "left": `-${left}px` });
var width = browserWidth;
var spacing = parseInt(mc.attr("data-spacing"));
// fix jira XSWZ-73 选择器错误选择了嵌套的子控件相同class的元素
var items = mc.find("li.w-columns-item");
width = width - (items.length - 1) * spacing;
var self = this;
var totalwidth = 0;
items.each(function () {
var perw = parseInt($(this).attr("data-width"));
var itemPx = AdjustHelper.ToFixed(width * perw / 100, 3);
$(this).css({ "width": (itemPx + spacing) + "px", height: `${self.ControlInfo.Height}px` });
totalwidth = totalwidth + itemPx;
});
var offset = width - totalwidth;
if (offset > 0) {
var lastItem = items.last();
var lastwidth = parseInt(lastItem.css("width")) + offset;
lastItem.css("width", lastwidth + "px");
}
try {
if (this.ControlInfo.StyleName == 'Style2') {
$(`#mc_${this.ControlInfo.CtrlId}`).lzparallax({ effect: $(`#mc_${this.ControlInfo.CtrlId}`).data("lzparallaxParam").effect, autoPosition: false, clone: true });
this.ControlInfo.ControlView.find(".w-columns-content-inner").each((a, b) => {
if ($(b).parent().data("lzparallaxParam")) {
var effect = $(b).parent().data("lzparallaxParam").effect
$(b).parent().lzparallax({
effect: effect,
autoPosition: false,
clone: true
});
}
});
}
}
catch (ex) {
//ignore
console.log(ex);
}
}
}
SetCtrlCss() {
// multicolumn 响应式优化
switch (this.ControlInfo.StyleName) {
//case "Style1": {
// break;
//}
default: {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns").children(), { "margin-left": "0px" });
this.SetEleCss(this.ControlInfo.ControlView.find(".w-columns"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px`, left: `0px` });
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView);
this.SetEleCss(this.ControlInfo.ControlView,
{
left: `${this.ControlInfo.AdjustControlInfo.Left}px`,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`
});
super.SetLzparallax(this.ControlInfo.ControlView.find(`#mc_${this.ControlInfo.CtrlId}`));
this.ControlInfo.ControlView.find(`#mc_${this.ControlInfo.CtrlId}`).find(".w-columns-content-inner").each((a, b) => {
super.SetLzparallax($(b).parent());
});
}
}
}
}
class areaAdjuster extends baseAdjuster {
LeftBorder = 0;
RightBorder = 0;
constructor(controlInfo) {
super(controlInfo);
this.LeftBorder = AdjustHelper.GetCssPixelSize(controlInfo.ControlView.find(".w-container"), "border-left-width");
this.RightBorder = AdjustHelper.GetCssPixelSize(controlInfo.ControlView.find(".w-container"), "border-right-width");
}
SetWidthAndHeight(newWidth) {
super.SetWidthAndHeight(newWidth);
this.ControlInfo.AdjustControlInfo.Width4Children = newWidth - this.LeftBorder - this.RightBorder;
}
SetCtrlCss() {
super.SetCtrlCss();
this.SetEleCss(this.ControlInfo.ControlView.find(".smAreaC.expandFlag"), { height: `${this.ControlInfo.AdjustControlInfo.Height}px` });
}
}
class virtualAreaAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetWidthAndHeight(newWidth) {
this.SetWidthAndHeight_JustWidth(newWidth);
}
SetCtrlCss() {
return;
}
}
class textAdjuster extends baseAdjuster {
HasBigFont = null;
constructor(controlInfo) {
super(controlInfo);
var self = this;
this.HasBigFont = false;
self.ControlInfo.ControlView.find("p,span").each((a, b) => {
if (!self.HasBigFont) {
var ele = $(b);
var currentSize = AdjustHelper.GetCssPixelSize(ele, "font-size");
if (currentSize > AdjustConfig.BigFontSize) {
self.HasBigFont = true;
}
}
});
}
//不知道super里面为什么不动子级的样式,text控件单独写个,免得影响别的控件
ResetTag2OriCss() {
var tagMarkerFlag = "TM";
if (!this.ControlInfo.IsVirtualCtrl) {
if (this.TagMarkList === null) {
this.TagMarkList = [];
var self = this;
this.ControlInfo.ControlView.find(`[${tagMarkerFlag}]`).each((a, b) => {
var tmId = $(b).attr(tagMarkerFlag);
self.TagMarkList.push(tmId);
});
var ctrlTm = this.ControlInfo.ControlView.attr(tagMarkerFlag);
if (ctrlTm) {
this.TagMarkList.push(ctrlTm);
}
}
this.TagMarkList.forEach(key => {
var css = baseAdjuster.EleOriCssList[key];
if (css != null) {
Object.keys(css).forEach(cssKey => {
$(`[${tagMarkerFlag}=${key}]`).css(cssKey, css[cssKey]);
});
}
});
}
}
GetDisplayHeightNotLimit(newWidth) {
//有图片的取不到真实高度,因为图片延迟加载才能拿得到高度
if (this.ControlInfo.ControlView.attr("use-real-height")) {
return this.ControlInfo.Height;
}
return this.PassHiddenCtrls((self) => {
self.ControlInfo.ControlView.width(newWidth);
var height = 0;
var children = self.ControlInfo.ControlView.find(".editableContent").children();
for (var i = 0; i < children.length; i++) {
var child = children.eq(i);
height += child.height();
}
if (height <= 0) {
height = self.ControlInfo.Height;
}
self.ControlInfo.ControlView.width(self.ControlInfo.Width);
return height;
});
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
if (this.HasBigFont) {
this.ResetTag2OriCss();
this.SetLayout();
this.ControlInfo.AdjustControlInfo.Height = this.GetDisplayHeightNotLimit(newWidth);
}
else {
var adjustHeight = this.GetDisplayHeightNotLimit(newWidth);;
this.ControlInfo.AdjustControlInfo.Height = adjustHeight > this.ControlInfo.Height ? adjustHeight : this.ControlInfo.Height;
}
}
SetLayout() {
super.SetCtrlCss();
var self = this;
var maxFontSize = AdjustConfig.BigFontSize;
var minFontSize = AdjustConfig.BigFontSize;
self.ControlInfo.ControlView.find("p,span").each((a, b) => {
var ele = $(b);
var currentSize = AdjustHelper.GetCssPixelSize(ele, "font-size");
if (currentSize > maxFontSize && super.CurrentZoomVal > 0 && super.CurrentZoomVal < 1) {
var newSize = currentSize * super.CurrentZoomVal;
newSize = newSize < minFontSize ? minFontSize : newSize;
self.SetEleCss(ele, { "font-size": `${newSize}px` })
}
});
}
}
class altasAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
OriUlMarginLeft = null;
OriPicWidth = null;
OriPicHeight = null;
GetHeight() {
this.ControlInfo.ControlView.find("li").addClass("notransition");
var ele = this.ControlInfo.ControlView;
var newHeight = ele.find(".xn-resize").height();
var pagerHeight = ele.find(".xn-pager").length * 70;//xn-pager高度是70
this.ControlInfo.ControlView.find("li").removeClass("notransition");
return newHeight + pagerHeight;;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.SetCtrlCss();
var height = this.GetHeight();
this.ControlInfo.ControlView.width(this.ControlInfo.Width);
this.ControlInfo.AdjustControlInfo.Height = height;
}
GetLiMarginLeft() {
var ul = this.ControlInfo.ControlView.find("ul").eq(0);
switch (this.ControlInfo.StyleName) {
case "Style2": {
return AdjustHelper.GetCssPixelSize(ul.find("a"), "margin-left");
break;
}
case "Style1":
case "Style3":
case "Style4": {
return AdjustHelper.GetCssPixelSize(ul.find("li"), "margin-left");
break;
}
}
}
OriPicWidth = null;
OriPicHeight = null;
OriMarginLeft = null;
GetOriPicWidth() {
if (this.OriPicWidth === null) {
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style3":
case "Style4":
{
var item = this.ControlInfo.ControlView.find(".w-imglist-item").eq(0);
this.OriPicWidth = item.width();
this.OriPicHeight = item.height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(item, "margin-left");
this.OriBorderWidth = 0;
break;
}
case "Style2":
{
var item = this.ControlInfo.ControlView.find(".w-atlas-ul>li").eq(0);
this.OriPicWidth = item.width();
this.OriPicHeight = item.height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(item.find("a"), "margin-left");
this.OriBorderWidth = 0;
break;
}
}
}
}
SetCtrlCss() {
this.GetOriPicWidth();
this.ResetTag2OriCss();
super.SetCtrlCss();
this.ControlInfo.ControlView.find(".CutFill").off('load');
var self = this;
switch (this.ControlInfo.StyleName) {
case "Style1": {
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-imglist-item").each((a, b) => {
var liItem = $(b);
this.SetEleCss(liItem, { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": `${marginLeft}px` });
this.SetEleCss(liItem.find("img").eq(0), { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-top": 0, "margin-left": 0 });
this.SetEleCss(liItem.find(".w-imglist-in").eq(0), { "width": `${newItemWidth}px`, height: `${newItemHeight}px` });
this.SetEleCss(liItem.find(".w-imglist-img").eq(0), { "width": `${newItemWidth}px`, height: `${newItemHeight}px` });
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-imglist-ul"), { "margin-left": `-${marginLeft}px`, });
});
break;
}
case "Style2": {
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-atlas-ul>li").each((a, b) => {
var liItem = $(b);
var marginTop = newItemHeight - liItem.find("h3").eq(0).height();
this.SetEleCss(liItem, { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": `${marginLeft}px`, "margin-top": `${10}px` });
this.SetEleCss(liItem.find("img").eq(0), { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-top": 0 });
this.SetEleCss(liItem.find("a").eq(0), { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": 0 });
this.SetEleCss(liItem.find("h3").eq(0), { "width": `${newItemWidth}px`, "padding": 0, "margin-top": `${marginTop}px` });
$(`#smv_${this.ControlInfo.CtrlId} .w-atlas-ul li img`).unbind('mouseenter mouseleave');
$(`#smv_${this.ControlInfo.CtrlId} .w-atlas-ul li img`).hover(function () {
$(this).css("width", $(this).width() - 10 + "px");
$(this).css("height", $(this).height() - 10 + "px");
}, function () {
$(this).css("width", $(this).width() + 10 + "px");
$(this).css("height", $(this).height() + 10 + "px");
});
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-atlas-ul"), { "margin-left": `-${marginLeft}px`, });
});
break;
}
case "Style3": {
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-imglist-item").each((a, b) => {
var liItem = $(b);
this.SetEleCss(liItem, { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": `${marginLeft}px` });
this.SetEleCss(liItem.find(".w-imglist-img,.w-imglist-in"), { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-top": 0 });
this.SetEleCss(liItem.find(".w-imglist-img>img"), { "width": `${newItemWidth}px`, height: `${newItemHeight}px` });
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-imglist-ul"), { "margin-left": `-${marginLeft}px`, });
});
break;
}
case "Style4": {
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-imglist-item").each((a, b) => {
var liItem = $(b);
this.SetEleCss(liItem, { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": `${marginLeft}px` });
this.SetEleCss(liItem.find("img").eq(0), { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-top": 0 });
this.SetEleCss(liItem.find("a").eq(0), { "width": `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": 0 });
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-imglist-ul"), { "margin-left": `-${marginLeft}px`, });
});
break;
}
}
}
}
class browserdeviceAdjuster extends fixMinZoomAs1Adjuster {
SetWidthAndHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
ele.width(newWidth);
var newHeight = ele.find(".w-pcmonile").height();
ele.width(this.ControlInfo.Width);
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = newHeight;
}
constructor(controlInfo) {
super(controlInfo);
}
}
class cartAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
super.SetCtrlCss();
switch (this.ControlInfo.StyleName) {
case "Style1": {
var promptBoxDefaultWidth = 350;
//当该元素隐藏时,无法获取真实位置,比如说在汉堡导航中隐藏了
var left = this.ControlInfo.ControlView[0].getBoundingClientRect().left - AdjustConfig.MinCtrlXPadding;
if (left < promptBoxDefaultWidth) {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-shoppingcart-prompt"), { left: 0, right: '' });
}
else {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-shoppingcart-prompt"), { right: 0, left: '' });
}
break;
}
default: {
break;
}
}
}
}
class cartQuantityAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class cartSubmitButtonAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class categoryAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
HundredPercentHandler() {
if (!this.ControlInfo.IsTemplateCtrl && this.ShouldHideOriNav(this.ControlInfo)) {
this.SetSingleCellCtrlLayout_HundredPercent();
}
else {
super.HundredPercentHandler()
}
}
GetNavInfo() {
var self = this;
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style2":
case "Style4": {
var firstNode = self.ControlInfo.ControlView.find(".w-category-list-item");
var firstTree = [];
firstNode.each((a, b) => {
var item = $(b);
var node0 = { text: item.find("a").html(), children: [], ele: item };
var secondNode = item.find(".w-category-listsecond-item");
secondNode.each((a1, b1) => {
var item1 = $(b1);
var node1 = { text: item1.find("a").eq(0).html(), children: [], ele: item1 }
node0.children.push(node1)
var thridNode = item1.find(".w-category-listthird-item");
thridNode.each((a2, b2) => {
var item2 = $(b2);
var node2 = { text: item2.find("a").eq(0).html(), children: [], ele: item2 }
node1.children.push(node2)
});
});
firstTree.push(node0);
});
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(self.ControlInfo.ControlView.find(".w-category-list-title").find("a"), self.ControlInfo.ControlView.find(".w-category-list-title"));
return {
BackgroundColor: BackgroundColor,
ForegroundColor: ForegroundColor,
Tree: firstTree,
}
}
case "Style3": {
var firstNode = self.ControlInfo.ControlView.find(".w-classify-once");
var firstTree = [];
firstNode.each((a, b) => {
var item = $(b);
var node0 = { text: item.find(".w-classify-once-content").html(), children: [], ele: item.find(".w-classify-once-item.click").eq(0) };
var secondNode = item.find(".w-classify-second");
secondNode.each((a1, b1) => {
var item1 = $(b1);
var node1 = { text: item1.find(".w-classify-second-link").html(), children: [], ele: item1.find(".w-classify-second-item.click").eq(0) }
node0.children.push(node1)
var thridNode = item1.find(".w-classify-third-item");
thridNode.each((a2, b2) => {
var item2 = $(b2);
var node2 = { text: item2.find(".w-classify-third-link").html(), children: [], ele: item2.find(".w-classify-third-link.click").eq(0) }
node1.children.push(node2)
});
});
firstTree.push(node0);
});
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(self.ControlInfo.ControlView.find(".w-classify-title-txt"), self.ControlInfo.ControlView.find(".w-classify-title"));
return {
BackgroundColor: BackgroundColor,
ForegroundColor: ForegroundColor,
Tree: firstTree,
}
break;
}
case "Style5": {
var firstNode = self.ControlInfo.ControlView.find(".w-first-item");
var firstTree = [];
firstNode.each((a, b) => {
var item = $(b);
var node0 = { text: item.find(".w-first-link").html(), children: [], ele: item.find(".w-first-link") };
var secondNode = item.find(".w-second-item");
secondNode.each((a1, b1) => {
var item1 = $(b1);
var node1 = { text: item1.find(".w-second-link").html(), children: [], ele: item1.find(".w-second-link") };
node0.children.push(node1)
var thridNode = item1.find(".w-third-item");
thridNode.each((a2, b2) => {
var item2 = $(b2);
var node2 = { text: item2.find(".w-third-link").html(), children: [], ele: item2.find(".w-third-link") };
node1.children.push(node2)
});
});
firstTree.push(node0);
});
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(self.ControlInfo.ControlView.find(".w-first-link"), self.ControlInfo.ControlView.find(".w-first-title"));
return {
BackgroundColor: BackgroundColor,
ForegroundColor: ForegroundColor,
Tree: firstTree,
}
break;
}
default: {
break;
}
}
}
SetCtrlCss_WideScreen() {
switch (this.ControlInfo.StyleName) {
case "Style1": {
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-category"));
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find("ul.w-category-list"))
var rightWidth = CtrlAdjuster.GetCurrentBrowserWidth() - this.ControlInfo.ControlView[0].getBoundingClientRect().right;
var listItems = this.ControlInfo.ControlView.find(".w-category-list-item");
var self = this;
listItems.toArray().forEach(li => {
var liEle = $(li);
var level = liEle.find(".w-category-listsecond").length + liEle.find(".w-category-listthird").length + 1;
var perWidth = (rightWidth < self.ControlInfo.AdjustControlInfo.Width * (level - 1)) ? ((rightWidth + self.ControlInfo.AdjustControlInfo.Width) / level) : self.ControlInfo.AdjustControlInfo.Width
self.SetEleCss(liEle.find(".w-category-listsecond"), { "width": `${perWidth}px`, left: `${perWidth}px` });
self.SetEleCss(liEle.find(".w-category-listthird"), { "width": `${perWidth}px`, left: `${perWidth}px` });
});
break;
}
case "Style2": {
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-category"));
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find("ul.w-category-list"))
break;
}
case "Style3": {
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-classify"));
var listItems = this.ControlInfo.ControlView.find(".w-classify-once");
var self = this;
listItems.toArray().forEach(li => {
var liEle = $(li);
self.SetEleCss(liEle.find(".w-classify-once-inner"), { left: `${self.ControlInfo.AdjustControlInfo.Width}px` });
});
break;
}
case "Style4": {
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-category"));
var listItems = this.ControlInfo.ControlView.find(".w-category-list-item");
var self = this;
listItems.each((x, li) => {
var liEle = $(li);
let a = { left: `${self.ControlInfo.AdjustControlInfo.Width}px` };
self.SetEleCss(liEle.find(".w-category-listthird"), a);
});
break;
}
case "Style5":
default: {
break;
}
}
super.SetCtrlCss();
}
SetWidthAndHeight(newWidth) {
if (!this.ControlInfo.IsTemplateCtrl && this.ShouldHideOriNav(this.ControlInfo)) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = AdjustConfig.AutoNavHeight;
}
else {
super.SetWidthAndHeight(newWidth);
}
}
SetCtrlCss() {
if (this.ControlInfo.IsTemplateCtrl) {
this.SetCtrlCss_WideScreen();
}
else {
if (super.ShouldHideOriNav(this.ControlInfo)) {
if (this.ControlInfo.ControlView.find(".slicknav_menu").length === 0) {
super.GenerateNav(this.GetNavInfo());
}
super.SetCtrlCss();
this.ControlInfo.ControlView.children().eq(0).show();
this.ControlInfo.ControlView.children().eq(1).hide();
}
else {
if (this.ControlInfo.ControlView.children().length === 2) {
this.ControlInfo.ControlView.children().eq(0).hide();
this.ControlInfo.ControlView.children().eq(1).show();
}
this.SetCtrlCss_WideScreen();
}
}
}
Reset2OriCss() {
if (!this.ControlInfo.IsTemplateCtrl && this.ControlInfo.ControlView.children().length === 2) {
this.ControlInfo.ControlView.children().eq(0).hide();
this.ControlInfo.ControlView.children().eq(1).show();
}
}
}
class commentAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetHeight() {
return AdjustHelper.GetScrollHeight(this.ControlInfo.ControlView.find(".w-comment"))
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.SetCtrlCss();
var height = this.GetHeight();
this.ControlInfo.ControlView.width(this.ControlInfo.Width);
this.ControlInfo.AdjustControlInfo.Height = height;
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style1": {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-comment"), { "min-width": "0px" });
break;
}
default: {
break;
}
}
super.SetCtrlCss();
}
// 解决评论控件ajax获取列表后高度变高,显示不全
Reset2OriCss() {
// 和原始高度对比,不怕多次调用,但页面出现多个评论控件计算就会有问题,一般不会使用多个评论控件
//var heightOffset = this.GetHeight() - this.ControlInfo.AdjustControlInfo.Height;
//if (heightOffset > 0) {
// CtrlAdjuster.MainEle.height(window.xa.Adjuster.OriMainHeight + heightOffset);
//}
}
}
class companyinfoAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetHeight() {
return AdjustHelper.GetScrollHeight(this.ControlInfo.ControlView)
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.SetCtrlCss();
var height = this.GetHeight();
this.ControlInfo.ControlView.width(this.ControlInfo.Width);
this.ControlInfo.AdjustControlInfo.Height = height;
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style2": {
this.SetEleCss(this.ControlInfo.ControlView.find(".companyinfo_Style2"), { "overflow": "visible" });
break;
}
case "Style3": {
this.SetEleCss(this.ControlInfo.ControlView.find(".company-info-text"), { "word-wrap": "break-word" });
break;
}
default: {
break;
}
}
super.SetCtrlCss();
}
}
class companyIntroductionAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-info").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-info").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class favoritesAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style1": {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-collection"), { width: `${this.ControlInfo.AdjustControlInfo.Width}` });
break;
}
default: {
break;
}
}
super.SetCtrlCss();
}
}
class languagesAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
HundredPercentHandler(layoutData) {
this.SetSingleCellCtrlLayout_Center(layoutData);
}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView.find(".w-language");
var oriCss = {
width: this.ControlInfo.Width,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-language-group").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
switch (this.ControlInfo.StyleName) {
case "Style2":
case "Style3":
{
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
break;
}
default: {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
break;
}
}
}
PrivateMethods = {
mobileClick: function (event) {
event.preventDefault()
var target = $(event.currentTarget).find(".w-language-dropdown")
if (target.is(":visible")) {
target.css('display', 'none')
} else {
target.css('display', 'block')
}
}
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style1":
{
var view = this.ControlInfo.ControlView.find(".w-language")
this.SetEleCss(view, { width: `${this.ControlInfo.AdjustControlInfo.Width}` });
view.find(".w-language-dropdown").css('display', 'none')
view.off('click').on('click', this.PrivateMethods.mobileClick)
// this.ControlInfo.ControlView.find(".w-language").on('mouseleave', this.mobileBlur)
break;
}
case "Style2":
case "Style3":
{
this.SetEleCss(this.ControlInfo.ControlView.find(".w-language"), { width: `${this.ControlInfo.AdjustControlInfo.Width}` });
break;
}
default: {
break;
}
}
super.SetCtrlCss();
}
Reset2OriCss() {
switch (this.ControlInfo.StyleName) {
case "Style1": {
this.ControlInfo.ControlView.find(".w-language-dropdown").css('display', '')
this.ControlInfo.ControlView.find(".w-language").off('click', this.PrivateMethods.mobileClick)
// this.ControlInfo.ControlView.find(".w-language").off('mouseleave', this.mobileBlur)
break;
}
}
}
}
class leavewordAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetHiddenHeight(newWidth) {
var ele0 = this.ControlInfo.ControlView.find(".w-guestbook");
var ele1 = this.ControlInfo.ControlView.find(".w-guestbook-container");
var ele2 = this.ControlInfo.ControlView.find(".w-guestbook-bottom");
ele0.css("width", `${newWidth}px`);
ele1.css("width", `${newWidth}px`);
ele2.css("width", `${newWidth}px`);
var newHeight = AdjustHelper.GetScrollHeight(this.ControlInfo.ControlView);
ele0.css("width", `${this.ControlInfo.Width}px`);
ele1.css("width", `${this.ControlInfo.Width}px`);
ele2.css("width", `${this.ControlInfo.Width}px`);
return newHeight;
}
SetWidthAndHeight(newWidth) {
switch (this.ControlInfo.StyleName) {
case "Style6":
{
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
break;
}
default: {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
break;
}
}
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style3": {
//w-guestbook-table
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-guestbook-table"));
break;
}
case "Style6": {
//避免调节leftPart/rightPart后无法判断是否同一行的问题
super.ResetTag2OriCss();
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-guestbook"));
this.SetEleCss(this.ControlInfo.ControlView.find(".w-guestbook-container"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
this.SetEleCss(this.ControlInfo.ControlView.find(".w-guestbook-bottom"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
var leftPart = this.ControlInfo.ControlView.find(".w-guestbook-both-left");
var rightPart = this.ControlInfo.ControlView.find(".w-item-textarea");
if (leftPart[0].getBoundingClientRect().y !== rightPart[0].getBoundingClientRect().y) {
this.SetEleCss(leftPart, { width: "100%" })
this.SetEleCss(rightPart, { width: "100%" })
}
break;
}
default: {
break;
}
}
super.SetCtrlCss();
}
}
class listnewsAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetHiddenHeight() {
this.SetCtrlCss();
//需完全设置样式后再获取高度
var newHeight = this.GetHeight();
this.ResetTag2OriCss();
return newHeight <= 0 ? this.ControlInfo.Height : newHeight;
}
SetWidthAndHeight(newWidth) {
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style4":
case "Style5":
case "Style6":
case "Style7":
case "Style8":
case "Style9":
case "Style10":
case "listnewscategory_Style8":
case "listnewssearch_Style8":
{
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight();
break;
}
default: {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
break;
}
}
}
GetHeight() {
//避免有动效取高度的时候动效还没执行完导致高度取的异常
this.ControlInfo.ControlView.find("li").addClass("notransition");
var realHeight = this.PassHiddenCtrls((self) => {
switch (self.ControlInfo.StyleName) {
case "Style1":
case "Style4":
case "Style6":
case "Style9":
case "listnewscategory_Style8":
case "listnewssearch_Style8":
{
var xnPagerHeight = self.ControlInfo.ControlView.find(".xn-pager").length === 1 ? AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".xn-pager")) + 40 : 0;
return AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".pager")) + xnPagerHeight + AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".w-list"))
break;
}
case "Style5":
case "Style7":
case "Style8":
{
var xnPagerHeight = self.ControlInfo.ControlView.find(".xn-pager").length === 1 ? AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".xn-pager")) + 40 : 0;
return AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".pager")) + xnPagerHeight + AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".w-al-list"))
break;
}
case "Style10": {
var xnPagerHeight = self.ControlInfo.ControlView.find(".xn-pager").length === 1 ? AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".xn-pager")) + parseInt(self.ControlInfo.ControlView.find(".xn-pager").css('marginTop')) : parseInt(self.ControlInfo.ControlView.find(".m-list-arrow").css('marginTop')) + parseInt(self.ControlInfo.ControlView.find(".m-list-arrow").css('height'));
var listHeight = AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".w-list"))
return listHeight + xnPagerHeight
}
default: {
return super.GetDisplayHeight();
break;
}
}
});
this.ControlInfo.ControlView.find("li").removeClass("notransition");
return realHeight;
}
Reset2OriCss() {
switch (this.ControlInfo.StyleName) {
case "Style2":
//case "Style3":
{
//jssor插件无法重置width,只能删除重新渲染
this.SetSliderStyle(this.ControlInfo.Width);
break;
}
case "Style3":
{
//jssor插件无法重置width,只能删除重新渲染
this.SetSliderStyle(this.ControlInfo.Width);
break;
}
default: {
break;
}
}
}
//jssor插件无法重置width,只能删除重新渲染
SetSliderStyle(newWidth) {
var self = this;
switch (this.ControlInfo.StyleName) {
case "Style2":
{
LayoutConverter.ResetSlider(self.ControlInfo.CtrlId, newWidth, () => {
//需要设置轮播的宽度 因为在样式文件中有设置
self.SetEleCss(self.ControlInfo.ControlView.find(".w-article"), { width: `${newWidth}px` });
self.SetEleCss(self.ControlInfo.ControlView.find(".w-article-list"), { width: `${newWidth}px` });
});
break;
}
case "Style3":
{
LayoutConverter.ResizeCallback(self.ControlInfo.CtrlId);
break;
}
default: {
break;
}
}
}
OriPicWidth = null;
OriPicHeight = null;
OriMarginLeft = null;
GetOriPicWidth() {
if (this.OriPicWidth === null) {
switch (this.ControlInfo.StyleName) {
case "Style4":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-piclink").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-piclink").height();
break;
}
case "Style5":
case "Style7":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-al-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-al-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-al-unit"), "margin-left");
break;
}
case "Style6":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-left");
break;
}
case "Style8":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-al-unit").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-al-unit").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-al-unit"), "margin-left");
break;
}
case "Style9":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-left");
break;
}
case "Style10":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-right");
break;
}
}
}
}
SetCtrlCss() {
this.GetOriPicWidth();
this.ResetTag2OriCss();
super.SetCtrlCss();
switch (this.ControlInfo.StyleName) {
case "Style2":
{
this.SetSliderStyle(this.ControlInfo.AdjustControlInfo.Width);
break;
}
case "Style3":
{
this.SetSliderStyle(this.ControlInfo.AdjustControlInfo.Width);
break;
}
case "Style4":
{
if (super.CurrentZoomVal < 1) {
var self = this;
var zoom = super.CurrentZoomVal;
zoom = zoom <= super.MinZoom ? super.MinZoom : super.CurrentZoomVal;
var newPicWidth = AdjustHelper.ToFixed(this.OriPicWidth * zoom);
var newPicHeight = AdjustHelper.ToFixed(this.OriPicHeight * zoom);
var isPicHide = self.ControlInfo.ControlView.find(".w-list-pic").eq(0).css("display") === "none";
if (newPicWidth < AdjustConfig.MinListPicWidth) {
newPicWidth = AdjustConfig.MinListPicWidth;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
var totalWidth = this.ControlInfo.AdjustControlInfo.Width;
var textWidth = totalWidth - newPicWidth;
if (textWidth / totalWidth < 0.5) {
newPicWidth = totalWidth / 2;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
this.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
if (isPicHide) {
self.SetEleCss(item.find(".w-list-pic"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-list-piclink"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-listpic-in"), { width: `${newPicWidth}px`, height: `${newPicHeight}px`, "margin-top": 0, "margin-left": 0 });
}
else {
self.SetEleCss(item.find(".w-list-pic"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-list-piclink"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-listpic-in"), { width: `${newPicWidth}px`, height: `${newPicHeight}px`, "margin-top": 0, "margin-left": 0 });
self.SetEleCss(item.find(".w-list-r"), { "padding-left": `${newPicWidth}px`, });
self.SetEleCss(item, { height: `${newPicHeight}px`, });
}
});
}
break;
}
case "Style5":
{
if (super.CurrentZoomVal < 1) {
var self = this;
var zoom = super.CurrentZoomVal;
zoom = zoom <= super.MinZoom ? super.MinZoom : super.CurrentZoomVal;
var newPicWidth = AdjustHelper.ToFixed(this.OriPicWidth * zoom);
var newPicHeight = AdjustHelper.ToFixed(this.OriPicHeight * zoom);
if (newPicWidth < AdjustConfig.MinListPicWidth) {
newPicWidth = AdjustConfig.MinListPicWidth;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
var totalWidth = this.ControlInfo.AdjustControlInfo.Width;
var textWidth = totalWidth - newPicWidth;
if (textWidth / totalWidth < 0.5) {
newPicWidth = totalWidth / 2;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
this.ControlInfo.ControlView.find(".w-al-unit").each((a, b) => {
var item = $(b);
//padding-bottom是22
self.SetEleCss(item.find(".w-al-pic"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find("img"), { width: `${newPicWidth}px`, height: `${newPicHeight}px`, "margin-top": 0, "margin-left": 0 });
self.SetEleCss(item.find(".w-al-pic>a"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-al-r-in"), { "margin-left": `${newPicWidth}px`, });
});
}
break;
}
case "Style6":
{
var self = this;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-link"), { width: `${newItemWidth}px` });
self.SetEleCss(item.find(".w-list-pic"), { width: `${newItemWidth}px`, height: `${newItemHeight}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { width: `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": 0, "margin-top": 0 });
self.SetEleCss(item.find(".w-listpic-in"), { width: `${newItemWidth}px` });
self.SetEleCss(item, { width: `${newItemWidth}px`, "margin-left": `${marginLeft}px` });
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-list-ul"), { "margin-left": `-${marginLeft}px`, });
});
break;
}
case "Style7":
{
var self = this;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-al-unit").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-al-pic"), { width: `${newItemWidth}px`, height: `${newItemHeight}px` });
self.SetEleCss(item.find(".w-al-pic").find("img"), { width: `${newItemWidth}px`, "display": "block", "margin-left": 0, "margin-top": 0, height: `${newItemHeight}px` });
self.SetEleCss(item.find(".w-al-text"), { width: `${newItemWidth}px` });
self.SetEleCss(item, { width: `${newItemWidth}px`, "margin-left": `${marginLeft}px` });
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-al-list"), { "margin-left": `-${marginLeft}px`, });
});
break;
}
case "Style8":
{
var self = this;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-al-unit").each((a, b) => {
var item = $(b);
self.SetEleCss(item, { width: `${newItemWidth}px`, "margin-left": `${marginLeft}px` });
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-al-list"), { "margin-left": `-${marginLeft}px`, });
});
break;
}
case "Style9":
{
var self = this;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-link"), { maxWidth: `100%` });
self.SetEleCss(item.find(".w-list-pic"), { width: `${newItemWidth}px`, height: `${newItemHeight}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { width: `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-top": 0 });
self.SetEleCss(item.find(".w-list-desc"), { width: `${newItemWidth - 10}px` });//-10px padding
self.SetEleCss(item, { width: `${newItemWidth}px`, "margin-right": 0, "margin-left": `${a % oneLineCount == 0 ? 0 : marginLeft}px` });
})
});
break;
}
case "listnewscategory_Style8":
{
var self = this;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-pic"), { width: `${newItemWidth}px`, height: `${newItemHeight}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { width: `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-top": 0 });
self.SetEleCss(item.find(".w-list-desc"), { width: `${newItemWidth - 10}px` });//-10px padding
self.SetEleCss(item, { width: `${newItemWidth}px`, "margin-left": `${a % oneLineCount == 0 ? 0 : marginLeft}px` });
})
});
break;
}
case "Style10":
{
super.SetCtrlCss();
var self = this;
if (CtrlAdjuster.GetCurrentBrowserWidth() >= CtrlAdjuster.OriPageWidth) {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list"), { left: `0px`, width: `${CtrlAdjuster.OriPageWidth}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list-ul"), { left: `0px`, width: `${CtrlAdjuster.OriPageWidth}px`, margin: 'auto' })
this.SetEleCss(this.ControlInfo.ControlView.find(".list-wrapper"), { left: `${parseInt((this.ControlInfo.ControlView.find(".w-list").width() - CtrlAdjuster.GetCurrentBrowserWidth()) / 2)}px`, width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-left"), { left: `0px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-right"), { left: `${this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 16}px` })
} else {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px`, width: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.9)}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list-ul"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px`, width: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.9)}px`, margin: '0' })
this.SetEleCss(this.ControlInfo.ControlView.find(".list-wrapper"), { left: `${-parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px`, width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-left"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-right"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1 + this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 16)}px` })
if (this.ControlInfo.ControlView.find(".xn-pager")[0]) {
if (this.ControlInfo.ControlView.find(".xn-pager").attr('jp-align') == 'left') {
console.log(this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect())
if (this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect().height > 30) {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `${this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 40}px`, marginLeft: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px` })
}
if (200 + this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect().width < CtrlAdjuster.GetCurrentBrowserWidth()) {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `20px`, marginLeft: `160px` })
}
}
if (this.ControlInfo.ControlView.find(".m-list-arrow.u-right")[0].getBoundingClientRect().right > this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect().left) {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `${this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 40}px` })
} else {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `20px` })
}
}
if (CtrlAdjuster.IsMobile) {
this.ControlInfo.ControlView.find(".w-list").addClass('mobileState')
} else {
this.ControlInfo.ControlView.find(".w-list").removeClass('mobileState')
}
var zoom = super.CurrentZoomVal;
zoom = zoom <= super.MinZoom ? super.MinZoom : super.CurrentZoomVal;
var newPicWidth = AdjustHelper.ToFixed(this.OriPicWidth * zoom);
var newPicHeight = AdjustHelper.ToFixed(this.OriPicHeight * zoom);
if (newPicWidth < AdjustConfig.MinListPicWidth) {
newPicWidth = AdjustConfig.MinListPicWidth;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
this.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-pic"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { width: `${newPicWidth}px`, height: `${newPicHeight}px`, "margin-top": 0, "margin-left": 0 });
self.SetEleCss(item, { width: `${newPicWidth}px`, flex: `0 0 ${newPicWidth}px` });
})
}
break;
}
default: {
break;
}
}
}
}
class listnewscategoryAdjuster extends listnewsAdjuster {
constructor(controlInfo) {
if (controlInfo.StyleName === "Style8") {
controlInfo.StyleName = 'listnewscategory_Style8';
}
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// var pagerHeight = self.ControlInfo.ControlView.find(".pager").length === 1 ? AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".pager")) : 0;
// return pagerHeight + super.GetDisplayHeight();
// });
//}
}
class listnewssearchAdjuster extends listnewsAdjuster {
constructor(controlInfo) {
if (controlInfo.StyleName === "Style8") {
controlInfo.StyleName = 'listnewssearch_Style8';
}
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// var pagerHeight = self.ControlInfo.ControlView.find(".pager").length === 1 ? AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".pager")) : 0;
// return pagerHeight + super.GetDisplayHeight();
// });
//}
}
class listproductAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
this.BaseSetCtrlCss = super.SetCtrlCss
}
GetHiddenHeight() {
this.SetCtrlCss();
//需完全设置样式后再获取高度
var newHeight = this.GetHeight();
this.ResetTag2OriCss();
return newHeight;
}
Reset2OriCss() {
this.ControlInfo.ControlView.find(".DisableCutFill").removeClass("NoCutFill").removeClass("DisableCutFill");
switch (this.ControlInfo.StyleName) {
case "Style3":
case "Style4":
{
this.GetOriPicWidth();
//jssor插件无法重置width,只能删除重新渲染
// this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView, { Width: this.ControlInfo.Width, Height: this.ControlInfo.Height });
this.SetSliderStyle(this.ControlInfo.Width);
break;
}
case "Style7":
{
this.SetCtrlCss();
break;
}
default: {
break;
}
}
}
SetWidthAndHeight(newWidth) {
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style2":
case "Style5":
case "Style6":
case "Style7":
case "productRelateBind_Style2":
{
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight();
break;
}
default: {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
break;
}
}
}
GetHeight() {
//避免有动效取高度的时候动效还没执行完导致高度取的异常
var notransitionDom = this.ControlInfo.ControlView.find("li,.w-list-desc");
notransitionDom.addClass("notransition");
var realHeight = this.PassHiddenCtrls((self) => {
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style2":
case "Style5":
case "Style6":
case "productRelateBind_Style2":
{
var xnPagerHeight = self.ControlInfo.ControlView.find(".xn-pager").length === 1 ? AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".xn-pager")) + 40 : 0;
var listEle = self.ControlInfo.ControlView.find(".w-list");
var oriDisplay = listEle.css("display");
listEle.css("display", "inline-block");
var height = AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".pager")) + xnPagerHeight + AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".w-list"));
listEle.css("display", oriDisplay);
return height;
break;
}
case "Style7": {
var xnPagerHeight = self.ControlInfo.ControlView.find(".xn-pager").length === 1 ? AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".xn-pager")) + parseInt(self.ControlInfo.ControlView.find(".xn-pager").css('marginTop')) : parseInt(self.ControlInfo.ControlView.find(".m-list-arrow").css('marginTop')) + parseInt(self.ControlInfo.ControlView.find(".m-list-arrow").css('height'));
var listHeight = AdjustHelper.GetScrollHeight(self.ControlInfo.ControlView.find(".w-list"))
return listHeight + xnPagerHeight
}
case "Style3":
case "Style4": {
return AdjustHelper.GetCssPixelSize(self.ControlInfo.ControlView.find(".w-list-item"), "height");//todo
}
default: {
return super.GetDisplayHeight();
break;
}
}
});
notransitionDom.removeClass("notransition");
return realHeight;
}
GetArrowWidth() {
return AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".m-list-arrow"), "width") + 5;
}
SetSliderStyle(ctrlWidth) {
var self = this;
LayoutConverter.ResetSlider(this.ControlInfo.CtrlId, null, (jssorCache) => {
//重置原来的样式
if (self.OriSlideWidth === undefined) {
self.OriSlideWidth = jssorCache.JssorOpt.$SlideWidth;
}
jssorCache.JssorOpt.$SlideWidth = self.OriSlideWidth;
self.ControlInfo.ControlView.find(".w-list-pic>img").each((a, b) => {
self.SetEleCss($(b), { "margin-left": `${0}px` });
});
var listEles = self.ControlInfo.ControlView.find(".w-list-item");
var picwidth = listEles.width();
var spacingwidth = jssorCache.JssorOpt.$SlideSpacing;
var totalcount = 1;
if (picwidth + spacingwidth > 0) {
var tempCount = ((ctrlWidth - picwidth) / (picwidth + spacingwidth)) + 1;
totalcount = tempCount > totalcount ? tempCount : totalcount;
}
totalcount = totalcount < listEles.length ? totalcount : listEles.length;
jssorCache.JssorOpt.$Cols = totalcount;
self.ControlInfo.ControlView.find(".w-list-ul").each((a, b) => {
self.SetEleCss($(b), { width: `${ctrlWidth}px` });
});
self.ControlInfo.ControlView.find(".w-list").each((a, b) => {
self.SetEleCss($(b), { width: `${ctrlWidth}px` });
});
if (jssorCache.JssorOpt.$SlideWidth > ctrlWidth) {
var left = (jssorCache.JssorOpt.$SlideWidth - ctrlWidth) / 2
self.ControlInfo.ControlView.find(".w-list-pic>img").each((a, b) => {
self.SetEleCss($(b), { "margin-left": `-${left}px` });
});
jssorCache.JssorOpt.$SlideWidth = ctrlWidth;
}
});
}
OriPicWidth = null;
OriPicHeight = null;
OriMarginLeft = null;
GetOriPicWidth() {
if (this.OriPicWidth === null) {
switch (this.ControlInfo.StyleName) {
case "Style1":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
break;
}
case "Style2":
case "Style3":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-left");
break;
}
case "Style4":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-piclink").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-piclink").height();
break;
}
case "Style5":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-left");
break;
}
case "Style6":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-left") || AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-right");
break;
}
case "Style7":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-right");
break;
}
case "Style9":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
break;
}
case "productRelateBind_Style2":
{
this.OriPicWidth = this.ControlInfo.ControlView.find(".w-list-pic").width();
this.OriPicHeight = this.ControlInfo.ControlView.find(".w-list-pic").height();
this.OriMarginLeft = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "margin-left");
break;
}
}
}
}
SetCtrlCss() {
this.GetOriPicWidth();
//reset 之后有动画效果 导致不能正确CalculateLIsInRow 会让缩小后放大一直是一行
this.ResetTag2OriCss();
var self = this;
switch (this.ControlInfo.StyleName) {
case "Style1":
{
super.SetCtrlCss();
var zoom = super.CurrentZoomVal;
zoom = zoom <= super.MinZoom ? super.MinZoom : super.CurrentZoomVal;
var newPicWidth = AdjustHelper.ToFixed(this.OriPicWidth * zoom);
var newPicHeight = AdjustHelper.ToFixed(this.OriPicHeight * zoom);
if (newPicWidth < AdjustConfig.MinListPicWidth) {
newPicWidth = AdjustConfig.MinListPicWidth;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
var totalWidth = this.ControlInfo.AdjustControlInfo.Width;
var textWidth = totalWidth - newPicWidth;
if (textWidth / totalWidth < 0.5) {
newPicWidth = totalWidth / 2;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
this.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-pic"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { width: `${newPicWidth}px`, height: `${newPicHeight}px`, "margin-top": 0, "margin-left": 0 });
self.SetEleCss(item, { width: `${self.ControlInfo.AdjustControlInfo.Width}px`, height: `${newPicHeight}px`, "margin-left": 0 });
self.SetEleCss(item.find(".w-list-r"), { "padding-left": `${newPicWidth}px`, });
})
break;
}
case "Style2":
case "productRelateBind_Style2":
{
super.SetCtrlCss();
var self = this;
var borderWidth = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-list-item"), "border-left-width") * 2;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
self.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-pic"), { "text-align": "center", height: `${newItemHeight}px`, width: `${newItemWidth}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { height: `${newItemHeight}px`, width: `${newItemWidth}px`, "margin-left": 0, "margin-top": 0 });
item.find(".w-list-pic").find("img:not(.NoCutFill)").addClass("NoCutFill").addClass("DisableCutFill");
self.SetEleCss(item, { width: `${newItemWidth - borderWidth}px`, "margin-left": `${a % oneLineCount == 0 ? 0 : marginLeft}px` });
});
self.SetEleCss(self.ControlInfo.ControlView.find(".w-list-ul"), { width: `${self.ControlInfo.AdjustControlInfo.Width}px`, "margin-left": 0 });
});
break;
}
case "Style3":
case "Style4":
{
var arrowWidth = this.GetArrowWidth();
var width = this.ControlInfo.AdjustControlInfo.Width - arrowWidth * 2;
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView, { Width: width, Height: this.ControlInfo.AdjustControlInfo.Height });
this.SetEleCss(this.ControlInfo.ControlView,
{
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`,
left: `${this.ControlInfo.AdjustControlInfo.Left + arrowWidth}px`
});
this.SetSliderStyle(width);
break;
}
case "Style5":
{
super.SetCtrlCss();
var self = this;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
this.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
var linkItem = item.find(".w-list-link");
var linkPadding = AdjustHelper.GetCssPixelSize(linkItem, "padding");
self.SetEleCss(item.find(".w-list-pic"), { "text-align": "center", height: `${newItemHeight}px`, width: `${newItemWidth - AdjustHelper.GetCssPixelSize(linkItem, "padding-left") * 2}px` });
self.SetEleCss(item.find(".w-list-pic>img"), { height: `${newItemHeight}px`, width: `${newItemWidth - AdjustHelper.GetCssPixelSize(linkItem, "padding-left") * 2}px`, "margin-left": 0, "margin-top": 0 });
self.SetEleCss(item.find(".w-list-bottom"), { width: `${newItemWidth - linkPadding * 2}px` });
self.SetEleCss(linkItem, { width: `${newItemWidth - linkPadding * 2}px` });
self.SetEleCss(item, { width: `${newItemWidth}px`, "margin-left": `${a % oneLineCount == 0 ? 0 : marginLeft}px` });
});
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list-ul"), { "margin-left": 0 })
});
break;
}
case "Style6":
{
super.SetCtrlCss();
var self = this;
self.AdjustListItem((newItemWidth, newItemHeight, marginLeft, oneLineCount) => {
this.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-pic"), { "text-align": "center", height: `${newItemHeight}px`, width: `${newItemWidth}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { width: `${newItemWidth}px`, height: `${newItemHeight}px`, "margin-left": "0", "margin-top": "0" });
//有2px的border
self.SetEleCss(item, { width: `${newItemWidth - 2}px`, "margin-left": `${a % oneLineCount == 0 ? 0 : marginLeft}px`, "margin-right": "0" });
})
});
break;
}
case "Style7":
{
super.SetCtrlCss();
var self = this;
if (CtrlAdjuster.GetCurrentBrowserWidth() >= CtrlAdjuster.OriPageWidth) {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list"), { left: `0px`, width: `${CtrlAdjuster.OriPageWidth}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list-ul"), { left: `0px`, width: `${CtrlAdjuster.OriPageWidth}px`, margin: 'auto' })
this.SetEleCss(this.ControlInfo.ControlView.find(".list-wrapper"), { left: `${parseInt((this.ControlInfo.ControlView.find(".w-list").width() - CtrlAdjuster.GetCurrentBrowserWidth()) / 2)}px`, width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-left"), { left: `0px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-right"), { left: `${this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 16}px` })
} else {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px`, width: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.9)}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".w-list-ul"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px`, width: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.9)}px`, margin: '0' })
this.SetEleCss(this.ControlInfo.ControlView.find(".list-wrapper"), { left: `${-parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px`, width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-left"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px` })
this.SetEleCss(this.ControlInfo.ControlView.find(".m-list-arrow.u-right"), { left: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1 + this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 16)}px` })
if (this.ControlInfo.ControlView.find(".xn-pager")[0]) {
if (this.ControlInfo.ControlView.find(".xn-pager").attr('jp-align') == 'left') {
console.log(this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect())
if (this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect().height > 30) {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `${this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 40}px`, marginLeft: `${parseInt(CtrlAdjuster.GetCurrentBrowserWidth() * 0.1)}px` })
}
if (200 + this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect().width < CtrlAdjuster.GetCurrentBrowserWidth()) {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `20px`, marginLeft: `160px` })
}
}
if (this.ControlInfo.ControlView.find(".m-list-arrow.u-right")[0].getBoundingClientRect().right > this.ControlInfo.ControlView.find(".xn-pager")[0].getBoundingClientRect().left) {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `${this.ControlInfo.ControlView.find(".m-list-arrow.u-right").width() + 40}px` })
} else {
this.SetEleCss(this.ControlInfo.ControlView.find(".xn-pager"), { marginTop: `20px` })
}
}
if (CtrlAdjuster.IsMobile) {
this.ControlInfo.ControlView.find(".w-list").addClass('mobileState')
} else {
this.ControlInfo.ControlView.find(".w-list").removeClass('mobileState')
}
var zoom = super.CurrentZoomVal;
zoom = zoom <= super.MinZoom ? super.MinZoom : super.CurrentZoomVal;
var newPicWidth = AdjustHelper.ToFixed(this.OriPicWidth * zoom);
var newPicHeight = AdjustHelper.ToFixed(this.OriPicHeight * zoom);
if (newPicWidth < AdjustConfig.MinListPicWidth) {
newPicWidth = AdjustConfig.MinListPicWidth;
newPicHeight = newPicWidth / this.OriPicWidth * this.OriPicHeight;
}
this.ControlInfo.ControlView.find(".w-list-item").each((a, b) => {
var item = $(b);
self.SetEleCss(item.find(".w-list-pic"), { width: `${newPicWidth}px`, height: `${newPicHeight}px` });
self.SetEleCss(item.find(".w-list-pic").find("img"), { width: `${newPicWidth}px`, height: `${newPicHeight}px`, "margin-top": 0, "margin-left": 0 });
self.SetEleCss(item, { width: `${newPicWidth}px`, flex: `0 0 ${newPicWidth}px` });
})
}
break;
}
default: {
super.SetCtrlCss();
break;
}
}
}
}
class listproductcategoryAdjuster extends listproductAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class listproductsearchAdjuster extends listproductcategoryAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class loginAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
this.SetEleCss(this.ControlInfo.ControlView.find(".w-login"), { width: `${this.ControlInfo.AdjustControlInfo.Width}` });
super.SetCtrlCss();
}
}
class navAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetHiddenHeight() {
switch (this.ControlInfo.StyleName) {
case "Style2":
case "Style7": {
this.SetCtrlCss();
var height = AdjustHelper.GetScrollHeight(this.ControlInfo.ControlView);
this.ResetTag2OriCss()
return height;
}
default: {
return this.ControlInfo.Height;
}
}
}
SetWidthAndHeight(newWidth) {
if (!this.ControlInfo.IsTemplateCtrl && this.ShouldHideOriNav(this.ControlInfo)) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = AdjustConfig.AutoNavHeight;
}
else {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight();
}
}
HundredPercentHandler() {
if (!this.ControlInfo.IsTemplateCtrl && this.ShouldHideOriNav(this.ControlInfo)) {
this.SetSingleCellCtrlLayout_HundredPercent();
}
else {
super.HundredPercentHandler()
}
}
GetNavInfo() {
var self = this;
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style5":
case "Style6":
case "Style7":
case "Style8":
case "Style11": {
var firstNode = self.ControlInfo.ControlView.find(".w-nav-inner");
var firstTree = [];
firstNode.each((a, b) => {
var item = $(b);
var textNode = item.find(".w-nav-item-link").eq(0);
var node0 = { text: textNode.html(), children: [], ele: textNode };
var secondNode = item.find(".w-subnav-item");
secondNode.each((a1, b1) => {
var item1 = $(b1);
var textNode1 = item1.find(".w-subnav-link").eq(0);
var node1 = { text: textNode1.html(), children: [], ele: textNode1 }
node0.children.push(node1)
});
firstTree.push(node0);
});
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(self.ControlInfo.ControlView.find(".w-nav-item-link"), self.ControlInfo.ControlView.find(".w-nav-inner"));
return {
BackgroundColor: BackgroundColor,
ForegroundColor: ForegroundColor,
Tree: firstTree,
}
}
case "Style2":
case "Style3":
case "Style4":
case "Style9":
case "Style10":
case "Style13": {
var firstNode = self.ControlInfo.ControlView.find(".w-nav-inner");
var firstTree = [];
firstNode.each((a, b) => {
var item = $(b);
var textNode = item.find(".w-nav-item-link").eq(0);
var node0 = { text: textNode.html(), children: [], ele: textNode };
var secondNode = item.find(".w-subnav-item");
secondNode.each((a1, b1) => {
var item1 = $(b1);
var textNode1 = item1.find(".w-subnav-link").eq(0);
var node1 = { text: textNode1.html(), children: [], ele: textNode1 }
node0.children.push(node1)
});
firstTree.push(node0);
});
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(self.ControlInfo.ControlView.find(".w-nav-item-link"), self.ControlInfo.ControlView.find(".w-nav"));
return {
BackgroundColor: BackgroundColor,
ForegroundColor: ForegroundColor,
Tree: firstTree,
}
}
case "Style12": {
var firstNode = self.ControlInfo.ControlView.find(".w-nav-item");
var firstTree = [];
firstNode.each((a, b) => {
var item = $(b);
var node0 = { text: item.find("a").eq(0).html(), children: [], ele: item.find("a").eq(0) };
var secondNode = item.find(".w-subnav").find("li");
secondNode.each((a1, b1) => {
var item1 = $(b1);
var node1 = { text: item1.find("a").eq(0).html(), children: [], ele: item1.find("a").eq(0) }
node0.children.push(node1)
});
firstTree.push(node0);
});
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(self.ControlInfo.ControlView.find(".w-nav-item>a"), self.ControlInfo.ControlView.find(".w-nav-item>a"));
return {
BackgroundColor: BackgroundColor,
ForegroundColor: ForegroundColor,
Tree: firstTree,
}
}
}
}
SetCtrlCss_WideScreen() {
super.SetCtrlCss();
switch (this.ControlInfo.StyleName) {
case "Style1":
{
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-nav"));
//var self = this;
//var width = this.ControlInfo.ControlView.find(".w-nav-inner").width();
//this.ControlInfo.ControlView.find(".w-subnav").each((a, b) => {
// self.SetEleCss($(b), {
// "z-index": 999,
// width: `${width}px`
// })
//})
break
}
case "Style2":
case "Style7":
{
//this.SetEleCss(this.ControlInfo.ControlView.find(".w-nav"), {
// width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
// height: `${this.ControlInfo.AdjustControlInfo.Height - 20}px`
//})
var self = this;
this.ControlInfo.ControlView.find(".w-subnav").each((a, b) => {
self.SetEleCss($(b), {
"z-index": 999
})
})
}
case "Style3":
case "Style4":
case "Style5":
case "Style6":
{
this.SetEleCss(this.ControlInfo.ControlView.find(".sliding-box"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
//var self = this;
//var width = this.ControlInfo.ControlView.find(".w-nav-inner").width();
//this.ControlInfo.ControlView.find(".w-subnav").each((a, b) => {
// self.SetEleCss($(b), {
// "z-index": 999,
// width: `${width}px`
// })
//})
break;
}
case "Style8":
case "Style9":
case "Style10":
case "Style11":
{
this.SetEleCss(this.ControlInfo.ControlView.find(".sliding-box"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-nav"));
//var width = this.ControlInfo.AdjustControlInfo.Width;
//var self = this;
//this.ControlInfo.ControlView.find(".w-subnav").each((a, b) => {
// self.SetEleCss($(b), {
// left: `${width}px`,
// width: `${width}px`
// })
//})
break;
}
case "Style13":
{
this.SetEleCss(this.ControlInfo.ControlView.find(".sliding-box"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
//var width = this.ControlInfo.ControlView.find(".w-nav-inner").width();
//var self = this;
//this.ControlInfo.ControlView.find(".w-subnav").each((a, b) => {
// self.SetEleCss($(b), {
// "z-index": 999,
// width: `${width}px`
// })
//})
break;
}
default: {
break
}
}
}
Reset2OriCss() {
if (!this.ControlInfo.IsTemplateCtrl && this.ControlInfo.ControlView.children().length === 2) {
this.ControlInfo.ControlView.children().eq(0).hide();
this.ControlInfo.ControlView.children().eq(1).show();
}
}
SetCtrlCss() {
if (this.ControlInfo.IsTemplateCtrl) {
this.SetCtrlCss_WideScreen();
}
else {
if (super.ShouldHideOriNav(this.ControlInfo)) {
if (this.ControlInfo.ControlView.find(".slicknav_menu").length === 0) {
super.GenerateNav(this.GetNavInfo());
}
super.SetCtrlCss();
this.ControlInfo.ControlView.children().eq(0).show();
this.ControlInfo.ControlView.children().eq(1).hide();
}
else {
if (this.ControlInfo.ControlView.children().length === 2) {
this.ControlInfo.ControlView.children().eq(0).hide();
this.ControlInfo.ControlView.children().eq(1).show();
}
this.SetCtrlCss_WideScreen();
}
}
}
}
class navcontainerAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
this.LogoPercent = AdjustHelper.ToFixed(this.ControlInfo.ControlView.find(".logo-area").attr("data-width") * 1 / 100, 3)
this.NavPercent = AdjustHelper.ToFixed(this.ControlInfo.ControlView.find(".nav-area").attr("data-width") * 1 / 100, 3)
var items = this.ControlInfo.ControlView.find(".nav-item");
this.OriItemWidth = items.width()
}
get IsFullScreen() {
return this.ControlInfo.ControlView.find(".fullScreen").length !== 0;
}
Reset2OriCss() {
var width = this.IsFullScreen ? CtrlAdjuster.GetCurrentBrowserWidth() : CtrlAdjuster.OriPageWidth;
if (!this.IsFullScreen) {
this.ControlInfo.ControlView.find(".nav-container").css({
width: `${width}px`,
left: `${(CtrlAdjuster.GetCurrentBrowserWidth() - width) / 2}px`
});
}
this.ControlInfo.ControlView.find(".nav-content").css({
left: `50%`,
width: `${width}px`
});
this.ControlInfo.ControlView.find(".logo-area").css({ width: `${width * this.LogoPercent}px` })
this.ControlInfo.ControlView.find(".nav-area").css({ width: `${width * this.NavPercent}px` })
var self = this;
var items = this.ControlInfo.ControlView.find(".nav-item");
items.each((a, b) => {
self.SetEleCss($(b), {
"min-width": "0",
width: `${self.OriItemWidth}px`
});
});
}
LogoPercent;
NavPercent;
OriItemWidth;
SetCtrlCss() {
super.SetCtrlCss();
var areaWidth = AdjustHelper.ToFixed(this.ControlInfo.AdjustControlInfo.Width * this.NavPercent);
this.SetEleCss(this.ControlInfo.ControlView.find(".logo-area"), { width: `${AdjustHelper.ToFixed(this.ControlInfo.AdjustControlInfo.Width * this.LogoPercent)}px` });
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-area"), { width: `${areaWidth}px` });
var self = this;
var items = this.ControlInfo.ControlView.find(".nav-item");
var currentItemWidth = AdjustHelper.ToFixed(areaWidth / items.length, 0);
items.each((a, b) => {
self.SetEleCss($(b), {
"min-width": "0",
width: `${currentItemWidth < self.OriItemWidth ? currentItemWidth : self.OriItemWidth}px`
});
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-content"), {
width: `${this.ControlInfo.AdjustControlInfo.Width}px`
, left: `${this.ControlInfo.AdjustControlInfo.Width / 2}px`
})
if (!this.IsFullScreen) {
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-container"), {
width: `100%`
, left: `0`
})
}
}
}
class newsItemContentBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetDisplayHeight() {
return this.PassHiddenCtrls((self) => {
return self.ControlInfo.ControlView.find(".w-detail").height();
});
}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-detail").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class newsItemCrumbsBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-crumbs").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-crumbs").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class newsItemNextBindAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-next").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-next").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class newsItemPreviousBindAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-previous").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-previous").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class newsItemHitsBindAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-pageviews").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-pageviews").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class newsItemSummaryBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetDisplayHeight() {
return this.PassHiddenCtrls((self) => {
return self.ControlInfo.ControlView.find(".w-info").height();
});
}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-info").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class newsItemTitleBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-title").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-title").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class productCategoryCrumbsAdjuster extends newsItemCrumbsBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class productCrumbsBindAdjuster extends newsItemCrumbsBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class productContentBindAdjuster extends newsItemContentBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class productCurrentPriceBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-cuprice").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-cuprice").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class productHitsBindAdjuster extends newsItemHitsBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class productNextBindAdjuster extends newsItemNextBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class productPreviousBindAdjuster extends newsItemPreviousBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
//当前价格有错别字 所以不能直接继承
class productOriginalPriceBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
//GetDisplayHeight() {
// return this.PassHiddenCtrls((self) => {
// return self.ControlInfo.ControlView.find(".w-coprice").height();
// });
//}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-coprice").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
class productParameterBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetDisplayHeight() {
return this.PassHiddenCtrls((self) => {
return self.ControlInfo.ControlView.find(".w-parameter").height();
});
}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
var newHeight = ele.find(".w-parameter").height();
ele.css(oriCss);
return newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
}
//class productRelateBindAdjuster extends listproductAdjuster {
// constructor(controlInfo) {
// switch (controlInfo.StyleName) {
// case "Style2":
// {
// controlInfo.StyleName = `productRelateBind_${controlInfo.StyleName}`;
// break;
// }
// default: {
// break
// }
// }
// super(controlInfo);
// }
//}
class productRelateBindAdjuster extends listproductAdjuster {
constructor(controlInfo) {
super(controlInfo);
switch (controlInfo.StyleName) {
// productRelateBind_Style2 的逻辑和Style2一样 ???暂时注释
//case "Style2":
// {
// controlInfo.StyleName = `productRelateBind_Style2`;
// break;
// }
case "Style3":
{
controlInfo.StyleName = `productRelateBind_Style3`;
this.IsJssorSlide = true;
break;
}
default: {
break
}
}
}
SetWidthAndHeight(newWidth) {
// this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
if (this.IsJssorSlide) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
var ctrlId = this.ControlInfo.CtrlId;
var jssorCache = LayoutConverter.CtrlJsVariableList.find(i => i.CtrlId === ctrlId);
if (!jssorCache) return;
jssorCache.Jssor.$ScaleWidth(newWidth, 1);
this.ControlInfo.ControlView.find('[data-scale-ratio="1"]').css('left', 0)
this.SetEleCss(this.ControlInfo.ControlView, { overflow: 'hidden' });
var left = this.ControlInfo.ControlView.find('.u-left');
var right = this.ControlInfo.ControlView.find('.u-right');
this.SetEleCss(
left,
{ left: '20px' }
);
this.SetEleCss(
right,
{ right: '20px' }
);
} else {
super.SetWidthAndHeight(newWidth)
}
}
SetCtrlCss() {
if (this.IsJssorSlide) {
this.BaseSetCtrlCss();
} else {
super.SetCtrlCss()
}
}
}
class productSlideBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
switch (this.ControlInfo.StyleName) {
case "Style3":
{
this.FillType = this.ControlInfo.ControlView.attr("fillType");
this.OriMainPicHeight = this.ControlInfo.ControlView.find(".w-slider").children().eq(0).height();
this.OriThumbHeight = this.ControlInfo.ControlView.find('[data-u="thumbnavigator"]').eq(0).height();
this.OriThumbWidth = this.ControlInfo.ControlView.find('[data-u="thumb"]').eq(0).width();
break;
}
case "Style4":
{
this.OriThumbHeight = 30;
break;
}
default: {
break;
}
}
}
SetWidthAndHeight(newWidth) {
switch (this.ControlInfo.StyleName) {
case "Style3": {
this.AppendTips("设置宽高:等比缩放");
var zoomVal = newWidth / this.ControlInfo.DisplayWidth;
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.OriMainPicHeight * zoomVal + this.OriThumbHeight;
break;
}
case "Style4":
{
this.AppendTips("设置宽高:等比缩放");
var zoomVal = newWidth / this.ControlInfo.DisplayWidth;
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height *= zoomVal
//super.SetWidthAndHeight_ZoomHeight(newWidth);
// 他的指示器在外边,加上指示器高度,以免重叠
this.ControlInfo.AdjustControlInfo.Height += this.OriThumbHeight;
break;
}
default: {
return super.SetWidthAndHeight(newWidth);
}
}
}
SetSliderStyle(newWidth, newHeight, isReset) {
var self = this;
var navLength = self.ControlInfo.ControlView.find(".w-point-item").length;
LayoutConverter.ResetSlider(this.ControlInfo.CtrlId, null, (jssorCache) => {
switch (self.ControlInfo.StyleName) {
case "Style3": {
if (self.OriPicWidth === undefined) {
var img = self.ControlInfo.ControlView.find('[data-u="image"]').eq(0);
img.on("load", () => {
self.OriPicWidth = img.width();
self.OriPicHeight = img.height();
console.log("加载图片完毕,重新设置样式");
self.SetCtrlCss();
});
}
var mainPicHeight;
if (!isReset) {
mainPicHeight = self.OriMainPicHeight * self.CurrentZoomVal;
} else {
mainPicHeight = self.OriMainPicHeight;
}
var totalHeight = mainPicHeight + self.OriThumbHeight;
self.SetEleCss(self.ControlInfo.ControlView.find(".w-bigimglist"), { width: `${newWidth}px`, height: `${mainPicHeight}px` });
self.SetEleCss(self.ControlInfo.ControlView, { width: `${newWidth}px`, height: `${totalHeight}px` });
self.SetEleCss(self.ControlInfo.ControlView.find(".w-slider"), { width: `${newWidth}px`, height: `${totalHeight}px` });
self.SetEleCss(self.ControlInfo.ControlView.find(".w-bigimglist"), { width: `${newWidth}px` });
// self.FillType 下次上线才会生效,先用脚本查找
var shouldAdjustTextAlign = self.FillType === 'Auto' || self.ControlInfo.ControlView.find("script").eq(0).text().indexOf("var fillType = 'Auto';") !== -1;
if (shouldAdjustTextAlign) {
window.setTimeout(function () {
self.SetEleCss(self.ControlInfo.ControlView.find(".w-bigimglist .w-imglink"), { textAlign: "center" });
self.SetEleCss(self.ControlInfo.ControlView.find(".w-bigimglist img"), { width: "auto", "height": "auto", position: "static", maxWidth: "100%", maxHeight: "100%", textAlign: "center", verticalAlign: "middle" });
}, 500);
}
var hasZoomEffect = self.ControlInfo.ControlView.find(".jqueryzoom").length > 0;
if (!CtrlAdjuster.IsMobile && hasZoomEffect) {
$(`#${self.ControlInfo.CtrlId}_w-slider3`).find(".jqueryzoom").jqueryzoom({
xzoom: 400,
yzoom: 400,
position: "right",
preload: 1,
lens: 1,
clickAction: function (event) {
var linkurl = $(".bigimg").attr("src");
window.open(linkurl);
},
hover: function (event) {
jssorCache.Jssor.$Pause();
},
hoverout: function () {
if (hasZoomEffect) {
jssorCache.Jssor.$Play();
}
}
});
}
break;
}
case "Style4": {
var navWidth = navLength * (42 + 10);//42宽度+10左边距;
if (navWidth > self.ControlInfo.AdjustControlInfo.ParentWidthSubPadding) {
self.ControlInfo.ControlView.find(".w-point-item").css("width", `${parseInt((self.ControlInfo.AdjustControlInfo.ParentWidthSubPadding / navLength) - 10)}px`);
}
self.ControlInfo.ControlView.width(newWidth);
self.ControlInfo.ControlView.height(newHeight);
self.ControlInfo.ControlView.find(".w-slider").width(newWidth);
self.ControlInfo.ControlView.find(".w-slider").height(newHeight);
self.ControlInfo.ControlView.find(".w-slider-wrap").width(newWidth);
self.ControlInfo.ControlView.find(".w-slider-wrap").height(newHeight);
self.ControlInfo.ControlView.find(".w-slider-title").width(newWidth);
self.ControlInfo.ControlView.find(".w-slider-titlein").width(newWidth);
setTimeout(() => {
var bigImgWidth = self.ControlInfo.ControlView.attr("oripicwidth") * 1;
if (bigImgWidth) {
$(`#slider_smv_${self.ControlInfo.CtrlId} .w-imglink`).css({ textAlign: "center" });
$(`#slider_smv_${self.ControlInfo.CtrlId} .w-imglink img`).css({ width: "auto", "height": "auto", position: "static", maxWidth: "100%", maxHeight: "100%", textAlign: "center", verticalAlign: "middle", "margin-top": 0 });
}
}, 500)
break;
}
}
}, () => {
switch (self.ControlInfo.StyleName) {
case "Style3": {
self.SetEleCss(self.ControlInfo.ControlView.find('[data-u="thumbnavigator"]').parent(), { width: `${newWidth}px`, left: 0 })
var thumbnavigator = self.ControlInfo.ControlView.find('[data-u="thumbnavigator"]').children().eq(0);
var thumbnavigatorWidth = thumbnavigator.width();
var left = (newWidth - thumbnavigatorWidth) / 2;
left = left < 0 ? 0 : left;
self.SetEleCss(thumbnavigator, { left: `${left}px` })
self.SetEleCss(self.ControlInfo.ControlView.find('[data-u="thumbnavigator"]'), { width: `${newWidth}px` })
break;
}
case "Style4": {
var bigImgWidth = self.ControlInfo.ControlView.attr("oripicwidth") * 1;
if (!bigImgWidth) {
$(`#slider_smv_${self.ControlInfo.CtrlId} .w-imglink img`).cutFill(newWidth - 2, newHeight - 2);
}
break;
}
}
});
}
Reset2OriCss() {
switch (this.ControlInfo.StyleName) {
case "Style3":
case "Style4":
{
this.ControlInfo.ControlView.find(".DisableCutFill").removeClass("NoCutFill").removeClass("DisableCutFill");
//jssor插件无法重置width,只能删除重新渲染
this.SetSliderStyle(this.ControlInfo.Width, this.ControlInfo.Height, true);
break;
}
default: {
break;
}
}
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style3":
{
this.SetEleCss(this.ControlInfo.ControlView, {
left: `${this.ControlInfo.AdjustControlInfo.Left}px`,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`
})
this.SetSliderStyle(this.ControlInfo.AdjustControlInfo.Width, this.ControlInfo.AdjustControlInfo.Height, false);
break;
}
case "Style4":
{
this.SetEleCss(this.ControlInfo.ControlView, {
left: `${this.ControlInfo.AdjustControlInfo.Left}px`,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`
})
// 他的指示器在外边,减去指示器高度
this.SetSliderStyle(this.ControlInfo.AdjustControlInfo.Width, this.ControlInfo.AdjustControlInfo.Height-this.OriThumbHeight, false);
break;
}
default: {
break
}
}
}
}
class productSummaryBindAdjuster extends newsItemSummaryBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class productTitleBindAdjuster extends newsItemTitleBindAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
// 2023-08-02 新增Adjuster
class productSpecificationsBindAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetHiddenHeight(newWidth) {
// 获取DOM的真实高度
//
this.AppendTips("赋值宽度取真实高度");
// this.ControlInfo.ControlView.css('width', newWidth)
this.SetEleCss(this.ControlInfo.ControlView, { width: newWidth })
var content = this.ControlInfo.ControlView.find(".w-productattrs");
// 没有配置规格,空白的直接显示高度0;
return content.height() || 0;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
//SetCtrlCss() {
// super.SetCtrlCss()
// this.GetHiddenHeight(this.ControlInfo.AdjustControlInfo.Width);
//}
//Reset2OriCss() {
// this.GetHiddenHeight(this.ControlInfo.AdjustControlInfo.Width);
//}
}
// 2023-08-02 新增Adjuster END
class registerAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
super.SetCtrlCss()
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-register"));
}
}
class searchAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
super.SetCtrlCss()
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style2":
case "Style3":
{
this.SetEleCss(this.ControlInfo.ControlView.find(".w-search"),
{
width: `${this.ControlInfo.AdjustControlInfo.Width}px`
})
break;
}
default: {
break
}
}
}
}
class shareAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
GetHiddenHeight(newWidth) {
var ele = this.ControlInfo.ControlView;
var oriCss = {
width: this.ControlInfo.Width,
height: this.ControlInfo.Height,
};
ele.css({ width: newWidth });
this.ControlInfo.ControlView.find(".bdsharebuttonbox").css({ width: newWidth })
var newHeight = AdjustHelper.GetScrollHeight(ele.find(".bdsharebuttonbox"));
ele.css(oriCss);
this.ControlInfo.ControlView.find(".bdsharebuttonbox").css({ width: this.ControlInfo.Width })
return newHeight < 36 ? 36 : newHeight;
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.GetHiddenHeight(newWidth);
}
SetCtrlCss() {
super.SetCtrlCss();
this.SetEleCss(this.ControlInfo.ControlView.find(".bdsharebuttonbox"),
{
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
})
}
}
class slideAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
switch (this.ControlInfo.StyleName) {
case "Style3":
{
this.OriMainPicHeight = this.ControlInfo.ControlView.find(".w-slider").children().eq(0).height();
this.OriThumbHeight = this.ControlInfo.ControlView.find('[data-u="thumbnavigator"]').eq(0).height();
this.OriThumbWidth = this.ControlInfo.ControlView.find('[data-u="thumb"]').eq(0).width();
break;
}
case "Style5":
{
this.OriMainPicHeight = this.ControlInfo.ControlView.find(".w-slider").children().eq(0).height();
this.OriThumbHeight = this.ControlInfo.ControlView.find(".w-thumb-s").eq(0).height();
break;
}
case "Style7": {
this.OriMainPicHeight = this.ControlInfo.Height;
this.OriThumbHeight = this.ControlInfo.ControlView.find('.w-thumb-p').eq(0).height();
this.OriThumbWidth = this.ControlInfo.ControlView.find('.w-thumb-p').eq(0).width();
break;
}
default: {
break;
}
}
}
Reset2OriCss() {
switch (this.ControlInfo.StyleName) {
case "Style1":
{
this.SetSliderStyle(CtrlAdjuster.GetCurrentBrowserWidth(), this.ControlInfo.Height, true);
this.ControlInfo.ControlView.css("left", `${-(CtrlAdjuster.GetCurrentBrowserWidth() - CtrlAdjuster.OriPageWidth) / 2}px`)
break;
}
case "Style2":
case "Style3":
case "Style4":
case "Style5":
case "Style6":
{
this.SetSliderStyle(this.ControlInfo.Width, this.ControlInfo.Height, true);
break;
}
default: {
break;
}
}
}
SetWidthAndHeight(newWidth) {
switch (this.ControlInfo.StyleName) {
case "Style6": {
super.SetWidthAndHeight_JustWidth(newWidth);
break;
}
default: {
super.SetWidthAndHeight_ZoomHeight(newWidth);
break;
}
}
}
OriMainPicHeight = null;
OriThumbHeight = null;
OriThumbWidth = null;
SetSliderStyle(newWidth, newHeight, isReset) {
var self = this;
LayoutConverter.ResetSlider(this.ControlInfo.CtrlId, null, (jssorCache) => {
switch (self.ControlInfo.StyleName) {
case "Style1":
{
var screenWidth = CtrlAdjuster.GetCurrentBrowserWidth();
this.SetEleCss(self.ControlInfo.ControlView, { width: `${screenWidth}px`, height: `${newHeight}px`, left: 0 })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider"), { width: `${screenWidth}px`, height: `${newHeight}px`, left: 0 })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider-wrap"), { width: `${screenWidth}px`, height: `${newHeight}px`, left: 0 })
break;
}
case "Style2":
{
this.SetEleCss(self.ControlInfo.ControlView, { width: `${newWidth}px`, height: `${newHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider"), { width: `${newWidth}px`, height: `${newHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider-wrap"), { width: `${newWidth}px`, height: `${newHeight}px` });
break;
}
case "Style3":
{
var mainPicHeight;
if (!isReset) {
mainPicHeight = self.OriMainPicHeight * self.CurrentZoomVal;
} else {
mainPicHeight = self.OriMainPicHeight;
}
var totalHeight = mainPicHeight + self.OriThumbHeight;
self.SetEleCss(self.ControlInfo.ControlView, { width: `${newWidth}px`, height: `${totalHeight}px` });
self.SetEleCss(self.ControlInfo.ControlView.find(".w-slider"), { width: `${newWidth}px`, height: `${totalHeight}px` });
self.SetEleCss(self.ControlInfo.ControlView.find(".w-bigimglist"), { width: `${newWidth}px`, height: `${mainPicHeight}px` });
setTimeout(() => {
var bigImgWidth = self.ControlInfo.ControlView.attr("oripicwidth") * 1;
if (bigImgWidth && newWidth > 264) {
var bigImgHeight = self.ControlInfo.ControlView.attr("oripicheight") * 1;
self.ControlInfo.ControlView.find(".w-bigimglist img").cutFill(bigImgWidth, bigImgHeight);
self.ControlInfo.ControlView.find(".w-bigimglist img").each((a, b) => {
$(b).css("left", `${(newWidth - bigImgWidth) / 2}px`)
});
}
}, 500)
break;
}
case "Style4": {
self.ControlInfo.ControlView.css({ width: `${newWidth}px`, height: `${newHeight}px` });
self.ControlInfo.ControlView.find(".w-slider").css({ width: `${newWidth}px`, height: `${newHeight}px` });
self.ControlInfo.ControlView.find(".w-slider-wrap").css({ width: `${newWidth}px`, height: `${newHeight}px` });
self.ControlInfo.ControlView.find(".w-slider-title").css({ width: `${newWidth}px`, });
self.ControlInfo.ControlView.find(".w-slider-titlein").css({ width: `${newWidth}px` });
setTimeout(() => {
var bigImgWidth = self.ControlInfo.ControlView.attr("oripicwidth") * 1;
if (bigImgWidth && newWidth > 264) {
var bigImgHeight = self.ControlInfo.ControlView.attr("oripicheight") * 1;
self.ControlInfo.ControlView.find(".w-imglink img").cutFill(bigImgWidth, bigImgHeight);
self.ControlInfo.ControlView.find(".w-imglink img").each((a, b) => {
$(b).css("left", `${(newWidth - bigImgWidth) / 2}px`)
});
}
}, 500)
break;
}
case "Style5":
{
var mainPicHeight;
if (!isReset) {
mainPicHeight = this.OriMainPicHeight * super.CurrentZoomVal;
} else {
mainPicHeight = this.OriMainPicHeight;
}
var totalHeight = mainPicHeight + 10 + this.OriThumbHeight
this.SetEleCss(self.ControlInfo.ControlView, { width: `${newWidth}px`, height: `${totalHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider"), { width: `${newWidth}px`, height: `${totalHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider-wrap"), { width: `${newWidth}px`, height: `${mainPicHeight}px` })
break;
}
case "Style6":
{
this.SetEleCss(self.ControlInfo.ControlView, { width: `${newWidth}px`, height: `${newHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider"), { width: `${newWidth}px`, height: `${newHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider-wrap"), { width: `${newWidth}px`, height: `${newHeight}px` })
break;
}
case "Style7":
{
var thumbHeight = 0;
if (!isReset) {
this.SetEleCss(self.ControlInfo.ControlView.find(".w-thumb-p"), { width: `${this.OriThumbWidth * super.CurrentZoomVal}px`, height: `${thumbHeight = this.OriThumbHeight * super.CurrentZoomVal}px` });
}
else {
this.SetEleCss(self.ControlInfo.ControlView.find(".w-thumb-p"), { width: `${this.OriThumbWidth}px`, height: `${thumbHeight = this.OriThumbHeight}px` });
}
this.SetEleCss(self.ControlInfo.ControlView.find(".w-thumb-bg"), { width: `${newWidth}px`, height: `${thumbHeight + 20}px` });
this.SetEleCss(self.ControlInfo.ControlView.find('[data-u="arrowleft"],[data-u="arrowright"]'), { bottom: `${(thumbHeight + 20) / 2 - 17}px` });
this.SetEleCss(self.ControlInfo.ControlView, { width: `${newWidth}px`, height: `${newHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider"), { width: `${newWidth}px`, height: `${newHeight}px` })
this.SetEleCss(self.ControlInfo.ControlView.find(".w-slider-wrap"), { width: `${newWidth}px`, height: `${newHeight}px` })
this.ControlInfo.ControlView.find(".w-thumb-s").css('max-width', `${newWidth - 100}px`);;
break;
}
}
//移除空href避免跳转
self.ControlInfo.ControlView.find("a").each((a, b) => {
if (!$(b).attr("href")) {
$(b).removeAttr("href");
}
});
}, (jssorCache) => {
switch (self.ControlInfo.StyleName) {
case "Style2": {
$(`#slider_smv_${this.ControlInfo.CtrlId} img`).cutFill(newWidth, newHeight);
break;
}
case "Style3": {
self.SetEleCss(self.ControlInfo.ControlView.find('[data-u="thumbnavigator"]').parent(), { width: `${newWidth}px`, left: 0 })
self.SetEleCss(self.ControlInfo.ControlView.find('[data-u="thumbnavigator"]').children().eq(0), { left: 0 })
self.SetEleCss(self.ControlInfo.ControlView.find('[data-u="thumbnavigator"]'), { width: `${newWidth}px` })
var hasZoomEffect = self.ControlInfo.ControlView.find(".jqueryzoom").length > 0;
if (!CtrlAdjuster.IsMobile && hasZoomEffect) {
$(`#${self.ControlInfo.CtrlId}_w-slider3`).find(".jqueryzoom").jqueryzoom({
xzoom: 400,
yzoom: 400,
position: "right",
preload: 1,
lens: 1,
clickAction: function (event) {
var linkurl = $(".bigimg").attr("src");
window.open(linkurl);
},
hover: function (event) {
jssorCache.Jssor.$Pause();
},
hoverout: function () {
if (hasZoomEffect) {
jssorCache.Jssor.$Play();
}
}
});
}
break;
}
case "Style4": {
if (jssorCache.FillType !== "Auto") {
var imgList = self.ControlInfo.ControlView.find(".w-imglink img");
imgList.cutFill(self.ControlInfo.AdjustControlInfo.Width, self.ControlInfo.AdjustControlInfo.Height);
}
//当底部切换按钮设置为隐藏时,需要将父级也隐藏,避免手机端可以左右滑动显示空白
var navigator = self.ControlInfo.ControlView.find('[data-u=navigator]');
if (navigator.hasClass("f-hide")) {
self.ControlInfo.ControlView.find('[data-u=navigator]').parent().css("display", "none");
}
break;
}
case "Style5":
{
var identityFlag = `#slider_smv_${this.ControlInfo.CtrlId}`;
var imgWidth = $(`${identityFlag} .list`).width();
var imgHeight = $(`${identityFlag} .list`).height();
$(`${identityFlag} .list img`).cutFill(imgWidth, imgHeight);
var thunWidth = $(`${identityFlag} .w-thumb-t`).width();
var thunHeight = $(`${identityFlag} .w-thumb-t`).height();
$(`${identityFlag} .w-thumb-t img`).cutFill(thunWidth, thunHeight);
break;
}
case "Style6": {
var identityFlag = `#slider_smv_${this.ControlInfo.CtrlId}`;
var imgWidth = $(`${identityFlag} .list`).width();
var imgHeight = $(`${identityFlag} .list`).height();
$(`${identityFlag} img`).cutFill(imgWidth, imgHeight);
break;
}
}
});
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style1":
{
this.SetEleCss(this.ControlInfo.ControlView,
{
left: 0,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`
})
this.SetSliderStyle(this.ControlInfo.AdjustControlInfo.Width, this.ControlInfo.AdjustControlInfo.Height, false);
break;
}
case "Style2":
case "Style3":
case "Style4":
case "Style5":
case "Style6":
case "Style7":
{
this.SetEleCss(this.ControlInfo.ControlView,
{
left: `${this.ControlInfo.AdjustControlInfo.Left}px`,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`
})
this.SetSliderStyle(this.ControlInfo.AdjustControlInfo.Width, this.ControlInfo.AdjustControlInfo.Height, false);
break;
}
default: {
super.SetCtrlCss();
}
}
}
}
class slidesetAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
this.SetSliderStyle()
}
SetWidthAndHeight(newWidth) {
this.SetWidthAndHeight_MatchMaxHeight(newWidth);
}
SetWidthAndHeight_MatchMaxHeight(newWidth) {
var virAreaCtrlIdList = CtrlAdjuster.StaticCtrlList.filter(i => i.ParentId === this.ControlInfo.CtrlId).map(i => i.CtrlId);
var childList = CtrlAdjuster.StaticCtrlList.filter(i => virAreaCtrlIdList.indexOf(i.ParentId) !== -1).map(i => i.AdjustControlInfo)
var minTop = Math.min.apply(Math, childList.map(function (o) { return o.TopWithOffset }));
var maxBottom = Math.max.apply(Math, childList.map(function (o) { return o.TopWithOffset + o.Height; })) + minTop;
var zoomVal = newWidth / this.ControlInfo.DisplayWidth;
var zoomHeight = this.ControlInfo.Height * zoomVal;
if (maxBottom > zoomHeight) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = maxBottom;
}
else {
super.SetWidthAndHeight_ZoomHeight(newWidth);
}
}
Reset2OriCss() {
this.SetSliderStyle(true);
}
RemoveAnimated(ele) {
ele.removeClass("animated");
ele.find(".animated").removeClass("animated");
if (ele.css("opacity") == "0") {
ele.css("opacity", 1)
}
}
//jssor插件无法重置width,只能删除重新渲染
SetSliderStyle(isReset2OriCss) {
var self = this;
//这些元素的样式在css文件里面写死了 得重新赋值
var height = this.ControlInfo.AdjustControlInfo.Height;
var width = this.ControlInfo.AdjustControlInfo.Width;
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style3":
{
var filterStrList = [".w-slide", ".w-slide-inner", ".content-box>.smAreaC"]
this.SetEleCss(this.ControlInfo.ControlView, {
height: `${height}px`,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`,
})
var ctrlIdList = CtrlAdjuster.StaticCtrlList.filter(i => !i.IsVirtualCtrl && i.RealParentId === self.ControlInfo.CtrlId).map(i => i.CtrlId);
//var ctrlIdList = self.ControlInfo.ControlView.find("[ctype]").toArray().filter(i => $(i).attr("pvid") === self.ControlInfo.CtrlId).map(ctrl => ctrl.id.replace("smv_", ""));
//先获取调节后的ControlView
var existingCtrlList = CtrlAdjuster.StaticCtrlList.filter(i => i.ControlView && ctrlIdList.indexOf(i.CtrlId) !== -1).map(i => {
return { CtrlId: i.CtrlId, ControlView: i.ControlView, ParentId: i.ParentId, RealParentId: i.RealParentId, AreaId: i.AreaId, ElementId: i.ElementId };
});
$(document.body).append("")
existingCtrlList.forEach(item => {
$("#hiddenCtrlHolder").append(item.ControlView);
//需要替换id,否则会在替换元素时重复导致bug
AdjustHelper.ReplaceId2Temp(item.ControlView);
});
LayoutConverter.ResetSlider(self.ControlInfo.CtrlId, null, () => {
//预览模式下重载html会导致控件父级转移后多次加载控件的问题,所以得移除已不在该容器下的控件
self.ControlInfo.ControlView.find("[pvid]").each((a, b) => {
var ele = $(b);
var ctrlId = b.id.replace("smv_", "");
var goneCtrl = CtrlAdjuster.StaticCtrlList.find(i => i.CtrlId == ctrlId);
if (goneCtrl == null || ele.attr("pvid") != goneCtrl.RealParentId) {
ele.remove();
}
});
filterStrList.forEach(filterStr => {
var ele = self.ControlInfo.ControlView.find(filterStr);
//样式有important
ele.each((a, b) => {
b.style.setProperty('width', `${width}px`, 'important');
b.style.setProperty('height', `${height}px`, 'important');
})
});
$("#hiddenCtrlHolder").children().each((a, b) => {
var existingCtrl = existingCtrlList.find(i => i.CtrlId === b.id.replace("smv_", "").replace(AdjustConfig.TempIdSuffix, ""));
if (existingCtrl) {
// 暂时注释了 重启动画功能 测试下是否有其他bug
//self.RemoveAnimated(existingCtrl.ControlView);
//existingCtrl.ControlView.find("[ctype]").each((a, b) => {
// self.RemoveAnimated($(b));
//})
self.ControlInfo.ControlView.find(".animated").smanimate("stop");
self.ControlInfo.ControlView.find(`#${existingCtrl.ElementId}`).remove();
self.ControlInfo.ControlView.find(`#smc_${existingCtrl.AreaId}[cid=${existingCtrl.RealParentId}]`).append(existingCtrl.ControlView);
}
});
self.ControlInfo.ControlView.find(`[id$='${AdjustConfig.TempIdSuffix}']`).each((a, b) => {
AdjustHelper.ResetTempId($(b));
});
LayoutConverter.ResizeCallback(self.ControlInfo.CtrlId);
});
$("#hiddenCtrlHolder").remove();
self.ControlInfo.ControlView.find(".content-box-inner").each((a, b) => {
b.style.setProperty('height', `${height}px`, 'important');
});
this.SetEleCss(this.ControlInfo.ControlView, {
width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px`,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`,
})
break;
}
case "Style2":
case "Style4":
{
super.SetCtrlCss();
var filterStrList = [".w-slide", ".w-slide-inner", ".content-box", ".content-box>.smAreaC"]
var ctrlIdList = CtrlAdjuster.StaticCtrlList.filter(i => !i.IsVirtualCtrl && i.RealParentId === self.ControlInfo.CtrlId).map(i => i.CtrlId);
//var ctrlIdList = self.ControlInfo.ControlView.find("[ctype]").toArray().filter(i => $(i).attr("pvid") === self.ControlInfo.CtrlId).map(ctrl => ctrl.id.replace("smv_", ""));
var existingCtrlList = CtrlAdjuster.StaticCtrlList.filter(i => i.ControlView && ctrlIdList.indexOf(i.CtrlId) !== -1).map(i => {
return { CtrlId: i.CtrlId, ControlView: i.ControlView, ParentId: i.ParentId, RealParentId: i.RealParentId, AreaId: i.AreaId, ElementId: i.ElementId };
});
$(document.body).append("")
existingCtrlList.forEach(item => {
$("#hiddenCtrlHolder").append(item.ControlView);
//需要替换id,否则会在替换元素时重复导致bug
AdjustHelper.ReplaceId2Temp(item.ControlView);
});
LayoutConverter.ResetSlider(self.ControlInfo.CtrlId, null, () => {
//预览模式下重载html会导致控件父级转移后多次加载控件的问题,所以得移除已不在该容器下的控件
self.ControlInfo.ControlView.find("[pvid]").each((a, b) => {
var ele = $(b);
var ctrlId = b.id.replace("smv_", "");
var goneCtrl = CtrlAdjuster.StaticCtrlList.find(i => i.CtrlId == ctrlId);
if (goneCtrl == null || ele.attr("pvid") != goneCtrl.RealParentId) {
ele.remove();
}
});
filterStrList.forEach(filterStr => {
var ele = self.ControlInfo.ControlView.find(filterStr);
//样式有important
ele.each((a, b) => {
b.style.setProperty('width', `${width}px`, 'important');
b.style.setProperty('height', `${height}px`, 'important');
})
})
$("#hiddenCtrlHolder").children().each((a, b) => {
var existingCtrl = existingCtrlList.find(i => i.CtrlId === b.id.replace("smv_", "").replace(AdjustConfig.TempIdSuffix, ""));
if (existingCtrl) {
self.RemoveAnimated(existingCtrl.ControlView);
existingCtrl.ControlView.find("[ctype]").each((a, b) => {
self.RemoveAnimated($(b));
})
self.ControlInfo.ControlView.find(`#${existingCtrl.ElementId}`).remove();
self.ControlInfo.ControlView.find(`#smc_${existingCtrl.AreaId}[cid=${existingCtrl.RealParentId}]`).append(existingCtrl.ControlView);
}
});
self.ControlInfo.ControlView.find(`[id$='${AdjustConfig.TempIdSuffix}']`).each((a, b) => {
AdjustHelper.ResetTempId($(b));
});
});
$("#hiddenCtrlHolder").remove();
self.ControlInfo.ControlView.find(".content-box-inner").each((a, b) => {
b.style.setProperty('width', `${width}px`, 'important');
b.style.setProperty('height', `${height}px`, 'important');
});
break;
}
}
}
}
class tabAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
this.ControlInfo.ControlView.attr("lastHeight", this.ControlInfo.Height);
switch (this.ControlInfo.StyleName) {
case "Style1":
case "Style2":
case "Style7": {
this.TabTitleHeight = this.ControlInfo.ControlView.find("li.w-label-tips-item[data-area]").eq(0).height();
break;
}
case "Style10":
case "Style11": {
this.OriginalHeight = this.ControlInfo.ControlView.children().find(">.w-label").height();
break;
}
default: {
break;
}
}
}
OriginalHeight = 0;
TabTitleHeight = 0;
OriMarginLeft;
CalculateMultiContainerHeight() {
return; 不执行
if (!this.ControlInfo.StyleName === "Style2") {
return;
}
var areaMap = {};
this.ControlInfo.Children.forEach(function (child) {
if (!areaMap[child.AreaId]) {
areaMap[child.AreaId] = []
}
areaMap[child.AreaId].push(child)
})
for (var areaId in areaMap) {
var maxBottom = Math.max.apply(Math, areaMap[areaId].map(ctrl => {
return ctrl.AdjustControlInfo.Bottom + AdjustConfig.MinCtrlYPadding;
}));
var contentArea = this.ControlInfo.ControlView.find(`.w-label>.w-label-content>li[data-area="${areaId}"]>.smAreaC`);
contentArea.height(maxBottom);
// TODO 计算高度小于原始高度,使用原始高度? (暂不优化,看设计师的使用情况)
// Math.max(maxBottom, contentArea.height())
}
}
SetContentAreaCss(titleTabHeight) {
var self = this;
var contentAreaList = this.ControlInfo.ControlView.find(`.w-label-content>li[data-area]>.smAreaC[cid="${this.ControlInfo.CtrlId}"]`);
contentAreaList.each((a, b) => {
self.SetEleWidthAndHeightByAdjustControlInfo($(b), { Width: self.ControlInfo.AdjustControlInfo.Width, Height: self.ControlInfo.AdjustControlInfo.Height - titleTabHeight });
});
super.SetCtrlCss()
}
GetDisplayHeight() {
var forceShowEles = this.ControlInfo.ControlView.find(".forceShow");
if (forceShowEles.length > 0) {
forceShowEles.each((a, b) => {
$(b).removeClass("forceShow");
});
}
var tabHeight;
switch (this.ControlInfo.StyleName) {
case "Style6":
{
tabHeight = this.ControlInfo.ControlView.find("ul").eq(0).height();
break;
}
//style7会先撑高然后再缩小,所以得用它的预设style的height
case "Style7":
{
tabHeight = this.ControlInfo.ControlView[0].style.height.replace("px", "") * 1;
break;
}
case "Style10":
{
tabHeight = this.ControlInfo.ControlView.children().find(">.w-label").height();
break;
}
default: {
tabHeight = super.GetDisplayHeight();;
}
}
forceShowEles.each((a, b) => {
$(b).addClass("forceShow")
});
return tabHeight;
}
_styleHeightDisplay(StyleName) {
var forceShowEles = this.ControlInfo.ControlView.find(".forceShow");
forceShowEles.removeClass('forceShow')
var height;
var matchMedia750 = window.matchMedia("(max-width:750px)").matches;
switch (StyleName) {
case "Style10":
{
if (matchMedia750) {
var $TabContentH = 63 + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height()
var $tabItemLength = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item>.mobile-label-tips-item ").length
var smAreaC = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item.current>.smAreaC");
if (smAreaC.length > 0) {
var b = smAreaC[0];
var maxHeight = 0;
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
if (maxHeight != 0) {
this.SetEleCss($(b), { height: `${maxHeight + AdjustConfig.MinCtrlYPadding}px`, width: "" });
height = maxHeight + AdjustConfig.MinCtrlYPadding + $TabContentH * $tabItemLength + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height();
} else {
this.SetEleCss($(b), { height: `${496}px`, width: "" });
height = 496 + $TabContentH * $tabItemLength + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height();
}
} else {
height = $TabContentH * $tabItemLength + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height();
}
} else {
var contentHeight = 0;
var smAreaC = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item.current>.smAreaC");
if (smAreaC.length > 0) {
var b = smAreaC[0];
var maxHeight = 0;
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
contentHeight = Math.max(maxHeight, this.OriginalHeight - this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips").height());
contentHeight += AdjustConfig.MinCtrlYPadding;
this.SetEleCss($(b), { height: `${contentHeight}px` });
height = contentHeight + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips").height();
} else {
height = this.OriginalHeight;
}
}
break;
}
case "Style11":
{
if (matchMedia750) {
var $TabContentH = 63 + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height()
var $tabItemLength = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item>.mobile-label-tips-item ").length
var smAreaC = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item.current>.smAreaC");
if (smAreaC.length > 0) {
var b = smAreaC[0];
var maxHeight = 0;
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
if (maxHeight != 0) {
this.SetEleCss($(b), { height: `${maxHeight + AdjustConfig.MinCtrlYPadding}px` });
height = maxHeight + AdjustConfig.MinCtrlYPadding + $TabContentH * $tabItemLength + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height();
} else {
this.SetEleCss($(b), { height: `${496}px` });
height = 496 + $TabContentH * $tabItemLength + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height();
}
} else {
height = $TabContentH * $tabItemLength + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.mobile-label-tips-line").height();
}
} else {
var smAreaC = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item.current>.smAreaC");
if (smAreaC.length > 0) {
var b = smAreaC[0];
var maxHeight = 0;
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
maxHeight += AdjustConfig.MinCtrlYPadding;
height = Math.max(maxHeight, this.OriginalHeight);
this.SetEleCss($(b), { height: `${height}px` });
} else {
height = this.OriginalHeight;
}
}
break;
}
}
this.ControlInfo.AdjustControlInfo.Height = height;
forceShowEles.addClass('forceShow')
}
SetWidthAndHeight(newWidth) {
super.SetWidthAndHeight(newWidth);
switch (this.ControlInfo.StyleName) {
case "Style3":
case "Style4":
case "Style5":
{
//this.ControlInfo.AdjustControlInfo.Width4Children = newWidth - this.ControlInfo.WidthOffset;;
//debugger
break;
}
case "Style10": {
var contentTab10 = this.ControlInfo.ControlView.children().children().children(".w-label-content");
var contenttabArea = contentTab10.children(".w-label-content-item.current").children(".smAreaC");
var border_width = parseInt(contenttabArea.css("border-left-width")) * 2
this.ControlInfo.AdjustControlInfo.Width4Children = newWidth - border_width;
this.SetContentAreaCssForStyle10And11(10);
break;
}
case "Style11":
{
var contentTab10 = this.ControlInfo.ControlView.children().children().children(".w-label-content");
var contenttabArea = contentTab10.children(".w-label-content-item.current").children(".smAreaC");
var border_width = parseInt(contenttabArea.css("border-left-width")) * 2
var labelTipsWidth = window.matchMedia("(max-width:750px)").matches ? 0 : this.ControlInfo.ControlView.find(".w-label-tips").width();
this.ControlInfo.AdjustControlInfo.Width4Children = newWidth - labelTipsWidth - border_width;
//this.SetContentAreaCssForStyle10And11(11);
break;
}
//{
// this.ControlInfo.AdjustControlInfo.Width4Children = newWidth - this.ControlInfo.ControlView.find(".w-label-tips").width();
// break;
//}
}
}
Reset2OriCss() {
var self = this;
switch (this.ControlInfo.StyleName) {
case "Style10":
{
var style10Isclose = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status") == "close"
if (style10Isclose) {
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status", "open");
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips>.w-label-tips-item").eq(0).click();
}
this.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item"), { "height": "auto" });
this.OriMarginLeft = this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(0).width();
var titleLiList = this.ControlInfo.ControlView.find("ul").eq(0).find("[data-area]");
var totalLength = this.ControlInfo.ControlView.find("ul").eq(0).find("li").length;
var width = AdjustHelper.ToFixed((this.ControlInfo.AdjustControlInfo.Width - this.OriMarginLeft * (totalLength - titleLiList.length)) / titleLiList.length);
var tabStyleOffset = this.ControlInfo.AdjustControlInfo.Width - (width * titleLiList.length + this.OriMarginLeft * (totalLength - titleLiList.length))
titleLiList.each((a, b) => {
self.SetEleCss($(b), { width: `${width}px` });
});
self.SetEleCss(titleLiList.eq(0), { width: `${width + tabStyleOffset}px` });
super.SetCtrlCss();
// 选中样式
var currItem = this.ControlInfo.ControlView.children().find(">.w-label >.w-label-tips >.w-label-tips-item.current");
currItem.prev().addClass('current');
currItem.next().addClass('current');
// 选中样式 END
break;
}
case "Style11":
{
var style11Isclose = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status") == "close"
if (style11Isclose) {
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status", "open");
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips>.w-label-tips-item").eq(0).click();
}
this.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item"), { "height": "auto" });
super.SetCtrlCss();
// 选中样式
var currItem = this.ControlInfo.ControlView.children().find(">.w-label >.w-label-tips >.w-label-tips-item.current");
currItem.prev().addClass('current');
currItem.next().addClass('current');
// 选中样式 END
break;
}
}
}
SetCtrlCss() {
var self = this;
switch (this.ControlInfo.StyleName) {
case "Style1":
{
this.OriMarginLeft = this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(0).width();
var titleLiList = this.ControlInfo.ControlView.find("ul").eq(0).find("[data-area]");
var totalLength = this.ControlInfo.ControlView.find("ul").eq(0).find("li").length;
var width = AdjustHelper.ToFixed((this.ControlInfo.AdjustControlInfo.Width - ((totalLength - titleLiList.length) * this.OriMarginLeft)) / titleLiList.length);
titleLiList.each((a, b) => {
self.SetEleCss($(b), { width: `${width}px` });
});
this.SetContentAreaCss(this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(0).height());
break;
}
case "Style2": {
super.ResetTag2OriCss();
this.OriMarginLeft = this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(1).width()
var titleLiList = this.ControlInfo.ControlView.find("ul").eq(0).find("[data-area]");
var titleTotalWidth = 0;
titleLiList.each((a, b) => {
titleTotalWidth += $(b).width();
});
var totalLength = this.ControlInfo.ControlView.find("ul").eq(0).find("li").length - 2;
var marginWidth = ((totalLength - titleLiList.length) * this.OriMarginLeft) + 2;
var isOverflow = titleTotalWidth > (this.ControlInfo.AdjustControlInfo.Width - marginWidth);
if (isOverflow) {
var width = AdjustHelper.ToFixed((this.ControlInfo.AdjustControlInfo.Width - marginWidth) / titleLiList.length);
titleLiList.each((a, b) => {
var liEle = $(b);
self.SetEleCss(liEle, { width: `${width}px` });
self.SetEleCss(liEle.find("a"), {
overflow: "hidden",
"white-space": "nowrap",
"text-overflow": "ellipsis",
"padding": "0"
});
});
}
this.SetContentAreaCss(this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(0).height());
break;
}
case "Style3":
case "Style4":
{
var contentAreaList = this.ControlInfo.ControlView.find(".w-label-content>li[data-area]>.smAreaC");
contentAreaList.each((a, b) => {
self.SetEleCss($(b), { width: `${this.ControlInfo.AdjustControlInfo.Width4Children}px` })
});
super.SetCtrlCss()
break;
}
case "Style5":
{
var contentAreaList = this.ControlInfo.ControlView.find(".w-label-tips>li[data-area]>.w-label-content");
contentAreaList.each((a, b) => {
self.SetEleCss($(b), { width: `${self.ControlInfo.AdjustControlInfo.Width - self.ControlInfo.WidthOffset}px`, height: `${self.ControlInfo.AdjustControlInfo.Height}px` })
});
super.SetCtrlCss()
break;
}
case "Style6":
{
super.ResetTag2OriCss();
this.OriMarginLeft = this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(0).width()
var titleLiList = this.ControlInfo.ControlView.find("ul").eq(0).find("[data-area]");
var titleTotalWidth = 0;
titleLiList.each((a, b) => {
titleTotalWidth += $(b).width();
});
var totalLength = this.ControlInfo.ControlView.find("ul").eq(0).find("li").length;
var marginWidth = ((totalLength - titleLiList.length) * this.OriMarginLeft);
var isOverflow = titleTotalWidth > (this.ControlInfo.AdjustControlInfo.Width - marginWidth);
if (isOverflow) {
var width = AdjustHelper.ToFixed((this.ControlInfo.AdjustControlInfo.Width - marginWidth) / titleLiList.length);
titleLiList.each((a, b) => {
var liEle = $(b);
self.SetEleCss(liEle, { width: `${width}px` });
self.SetEleCss(liEle.find("a"), {
overflow: "hidden",
"white-space": "nowrap",
"text-overflow": "ellipsis",
"padding": "0"
});
});
}
var contentAreaList = this.ControlInfo.ControlView.find(".w-label-content>li[data-area]>.smAreaC");
contentAreaList.each((a, b) => {
var maxHeight = 0;
var bTop = b.getBoundingClientRect().top;
$(b).parent().addClass("current");
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
$(b).parent().removeClass("current");
self.SetEleCss($(b), { width: `${self.ControlInfo.AdjustControlInfo.Width}px` });
if (maxHeight) {
self.SetEleCss($(b), { height: `${maxHeight + AdjustConfig.MinCtrlYPadding}px` });
}
});
super.SetCtrlCss()
break;
}
case "Style7":
{
super.ResetTag2OriCss();
this.OriMarginLeft = this.ControlInfo.ControlView.find("ul").eq(1).find("li").eq(0).width()
var titleLiList = this.ControlInfo.ControlView.find("ul").eq(1).find("[data-area]");
var titleTotalWidth = 0;
titleLiList.each((a, b) => {
titleTotalWidth += $(b).width();
});
var totalLength = this.ControlInfo.ControlView.find("ul").eq(1).find("li").length;
var marginWidth = ((totalLength - titleLiList.length) * this.OriMarginLeft);
var isOverflow = titleTotalWidth > (this.ControlInfo.AdjustControlInfo.Width - marginWidth);
if (isOverflow) {
var width = AdjustHelper.ToFixed((this.ControlInfo.AdjustControlInfo.Width - marginWidth) / titleLiList.length);
titleLiList.each((a, b) => {
var liEle = $(b);
self.SetEleCss(liEle, { width: `${width}px` });
self.SetEleCss(liEle.find("a"), {
overflow: "hidden",
"white-space": "nowrap",
"text-overflow": "ellipsis",
"padding": "0"
});
});
}
this.SetContentAreaCss(this.ControlInfo.ControlView.find("ul").eq(1).find("li").eq(0).height())
break;
}
case "Style10":
{
this._styleHeightDisplay("Style10")
if (window.matchMedia("(max-width:750px)").matches) {
this.SetContentAreaCssForStyle10And11(10)
self.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item>.mobile-label-tips-item a"), { width: `${this.ControlInfo.AdjustControlInfo.Width - 100}px` })
this.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item"), { "height": "" });
// 选中样式
var currItem = this.ControlInfo.ControlView.children().find(">.w-label >.w-label-content >.w-label-content-item.current");
currItem.siblings().removeClass('current').children('.mobile-label-tips-line,.mobile-label-tips-item').removeClass('current');
currItem.children('.mobile-label-tips-line,.mobile-label-tips-item').addClass('current');
var prev = currItem.prev();
if (prev.hasClass('mobile-label-tips-line')) {
prev.addClass('current');
} else {
prev.children('.mobile-label-tips-line').addClass('current');
}
// 选中样式 END
} else {
this.SetContentAreaCssForStyle10And11(10)
var style10Isclose = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status") == "close"
if (style10Isclose) {
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status", "open");
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips>.w-label-tips-item").eq(0).click();
}
this.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item"), { "height": "" });
this.OriMarginLeft = this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(0).width();
var titleLiList = this.ControlInfo.ControlView.find("ul").eq(0).find("[data-area]");
var totalLength = this.ControlInfo.ControlView.find("ul").eq(0).find("li").length;
var width = AdjustHelper.ToFixed((this.ControlInfo.AdjustControlInfo.Width - this.OriMarginLeft * (totalLength - titleLiList.length)) / titleLiList.length);
titleLiList.each((a, b) => {
self.SetEleCss($(b), { width: `${width}px` });
});
var tabStyleOffset = this.ControlInfo.AdjustControlInfo.Width - (width * titleLiList.length + this.OriMarginLeft * (totalLength - titleLiList.length))
self.SetEleCss(titleLiList.eq(0), { width: `${width + tabStyleOffset}px` });
this.SetContentAreaCss(this.ControlInfo.ControlView.find("ul").eq(0).find("li").eq(0).height());
// 选中样式
var currItem = this.ControlInfo.ControlView.children().find(">.w-label >.w-label-tips >.w-label-tips-item.current");
currItem.prev().addClass('current');
currItem.next().addClass('current');
// 选中样式 END
}
super.SetCtrlCss();
break;
}
case "Style11":
{
this._styleHeightDisplay("Style11")
if (window.matchMedia("(max-width:750px)").matches) {
this.SetContentAreaCssForStyle10And11(11);
//this.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label >.w-label-tips >.w-label-content-item"), { "height": "" });
self.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item>.mobile-label-tips-item a"), { width: `${this.ControlInfo.AdjustControlInfo.Width - 120}px` })
// 选中样式
var currItem = this.ControlInfo.ControlView.children().find(">.w-label >.w-label-content >.w-label-content-item.current");
currItem.siblings().removeClass('current').children('.mobile-label-tips-line,.mobile-label-tips-item').removeClass('current');
currItem.children('.mobile-label-tips-line,.mobile-label-tips-item').addClass('current');
var prev = currItem.prev();
if (prev.hasClass('mobile-label-tips-line')) {
prev.addClass('current');
} else {
prev.children('.mobile-label-tips-line').addClass('current');
}
// 选中样式 END
} else {
var style11Isclose = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status") == "close"
if (style11Isclose) {
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content").attr("status", "open");
this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips>.w-label-tips-item").eq(0).click();
}
var titleLiListStyle11 = this.ControlInfo.ControlView.children().find(">.w-label >.w-label-tips >.w-label-tips-item");
// self.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label >w-label-content"), { height: `${style11Height}px` });
var style11OriMarginLeft = parseInt(this.ControlInfo.ControlView.children().find(">.w-label >.w-label-tips >.w-label-tips-line").eq(0).css("height"));
var totalStyle11Length = this.ControlInfo.ControlView.children().find(">.w-label > .w-label-tips").children().length;
var style11Height = (this.ControlInfo.AdjustControlInfo.Height - style11OriMarginLeft * (totalStyle11Length - titleLiListStyle11.length)) / titleLiListStyle11.length;
titleLiListStyle11.each((a, b) => {
self.SetEleCss($(b), { height: `${style11Height}px` });
self.SetEleCss($(b).children(".tabImg"), { "max-height": `${style11Height}px` });
});
this.SetEleCss(this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item"), { "height": "auto" });
// 选中样式
var currItem = this.ControlInfo.ControlView.children().find(">.w-label >.w-label-tips >.w-label-tips-item.current");
currItem.prev().addClass('current');
currItem.next().addClass('current');
// 选中样式 END
}
super.SetCtrlCss()
break;
}
default: {
super.SetCtrlCss()
}
}
}
SetContentAreaCssForStyle10And11(type) {
var forceShowEles = this.ControlInfo.ControlView.find(".forceShow");
forceShowEles.removeClass('forceShow')
var contentAreaList = this.ControlInfo.ControlView.children().children().children(".w-label-content").children(".w-label-content-item").children(".smAreaC");
var contentAreaCurrentList = this.ControlInfo.ControlView.children().children().children(".w-label-content").children(".w-label-content-item.current")
var tipsAreaCurrentList = this.ControlInfo.ControlView.children().children().children(".w-label-tips").children(".w-label-tips-item.current")
var contentAreaCurrent = this.ControlInfo.ControlView.children().children().children(".w-label-content").children(".w-label-content-item.current").children(".smAreaC");
var contentTab10 = this.ControlInfo.ControlView.children().children().children(".w-label-content");
var contentTab10Border = Number(this.ControlInfo.ControlView.children().children().children(".w-label-content").css("border-left-width").replace("px", ""))
var contenttabArea = contentTab10.children(".current").children(".smAreaC");
if (window.matchMedia("(max-width:750px)").matches) {
if (contentAreaCurrentList.length > 0) {
if (contentAreaCurrentList.find(">.mobile-label-tips-item>.tabImg").attr("hoverurl") != "''") {
contentAreaCurrentList.find(">.mobile-label-tips-item>.tabImg").css("background-image", "url(" + contentAreaCurrentList.find(">.mobile-label-tips-item>.tabImg").attr("hoverurl") + ")")
}
}
contentAreaCurrentList.siblings(".w-label-content-item").each((index, item) => {
if ($(item).find(">.mobile-label-tips-item>.tabImg").attr("picurl") != "''") {
$(item).find(">.mobile-label-tips-item>.tabImg").css("background-image", "url(" + $(item).find(">.mobile-label-tips-item>.tabImg").attr("picurl") + ")")
} else {
$(item).find(">.mobile-label-tips-item>.tabImg").css("background-image", "")
}
})
contentAreaList.each((a, b) => {
$(b).css("display", "none")
})
contentAreaCurrent.each((a, b) => {
$(b).css("display", "block")
var maxHeight = 0;
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
if (maxHeight != 0) {
this.SetEleCss($(b), { height: `${maxHeight + AdjustConfig.MinCtrlYPadding}px` });
} else {
this.SetEleCss($(b), { height: `${496}px` });
}
})
} else {
contentAreaCurrent.each((a, b) => {
$(b).css("display", "")
})
if (type == 10) {
if (tipsAreaCurrentList.length > 0) {
if (contentAreaCurrentList.find(">.mobile-label-tips-item>.tabImg").attr("hoverurl") != "''") {
tipsAreaCurrentList.find(">.contetWraper>.tabImg").css("background-image", "url(" + contentAreaCurrentList.find(">.mobile-label-tips-item>.tabImg").attr("hoverurl") + ")")
}
contentAreaCurrentList.siblings(".w-label-content-item").each((index, item) => {
if ($(item).find(">.mobile-label-tips-item>.tabImg").attr("picurl") != "''") {
$(item).parent().parent().find(">.w-label-tips>.w-label-tips-item").eq($(item).index() - 1).find(">.contetWraper>.tabImg").css("background-image", "url(" + $(item).find(">.mobile-label-tips-item>.tabImg").attr("picurl") + ")")
} else {
$(item).parent().parent().find(">.w-label-tips>.w-label-tips-item").eq($(item).index() - 1).find(">.contetWraper>.tabImg").css("background-image", "")
}
})
}
var smAreaC = this.ControlInfo.ControlView.children().find(">.w-label>.w-label-content>.w-label-content-item.current>.smAreaC");
if (smAreaC.length > 0) {
var b = smAreaC[0];
var maxHeight = 0;
var height = 0
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
height = Math.max(maxHeight, this.OriginalHeight - this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips").height());
height += AdjustConfig.MinCtrlYPadding
this.SetEleCss($(b), { height: `${height}px` });
this.ControlInfo.AdjustControlInfo.Height = height + this.ControlInfo.ControlView.children().find(">.w-label>.w-label-tips").height();
} else {
this.ControlInfo.AdjustControlInfo.Height = this.OriginalHeight;
}
} else {
if (tipsAreaCurrentList.length > 0) {
if (contentAreaCurrentList.find(">.mobile-label-tips-item>.tabImg").attr("hoverurl") != "''") {
tipsAreaCurrentList.find(">.tabImg").css("background-image", "url(" + contentAreaCurrentList.find(">.mobile-label-tips-item>.tabImg").attr("hoverurl") + ")")
}
contentAreaCurrentList.siblings(".w-label-content-item").each((index, item) => {
if ($(item).find(">.mobile-label-tips-item>.tabImg").attr("picurl") != "''") {
$(item).parent().parent().find(">.w-label-tips>.w-label-tips-item").eq($(item).index() - 1).find(">.tabImg").css("background-image", "url(" + $(item).find(">.mobile-label-tips-item>.tabImg").attr("picurl") + ")")
} else {
$(item).parent().parent().find(">.w-label-tips>.w-label-tips-item").eq($(item).index() - 1).find(">.tabImg").css("background-image", "")
}
})
}
contentAreaCurrentList.each((a, b) => {
var maxHeight = 0;
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
maxHeight = maxHeight + AdjustConfig.MinCtrlYPadding;
if (maxHeight > this.OriginalHeight) {
this.SetEleCss($(b), { height: `${maxHeight + AdjustConfig.MinCtrlYPadding}px` });
this.ControlInfo.AdjustControlInfo.Height = maxHeight + AdjustConfig.MinCtrlYPadding;
} else {
this.SetEleCss($(b), { height: `${this.OriginalHeight}px` });
}
});
}
}
forceShowEles.addClass('forceShow')
}
}
class dialogAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
case "Style1": {
this.SetEleCss(this.ControlInfo.ControlView, { "margin-left": "", left: `${this.ControlInfo.AdjustControlInfo.Left}px` });
break;
}
default: {
break;
}
}
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView);
}
}
class videoAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetWidthAndHeight(newWidth) {
this.SetWidthAndHeight_ZoomHeight(newWidth);
}
SetCtrlCss() {
super.SetCtrlCss();
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".video_Style1"))
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".w-video"))
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find("iframe"))
this.SetEleCss(this.ControlInfo.ControlView.find(".w-video>div"), { "line-height": `${this.ControlInfo.AdjustControlInfo.Height}px` });
}
}
class alivideoAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetWidthAndHeight(newWidth) {
this.SetWidthAndHeight_ZoomHeight(newWidth);
}
SetCtrlCss() {
super.SetCtrlCss();
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".alivideo_Style1"))
this.SetEleCss(this.ControlInfo.ControlView.find(".defaultTitle"), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` })
}
}
class bannerAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
Reset2OriCss() {
this.ControlInfo.ControlView.css("width", "100%")
LayoutConverter.ResizeCallback(this.ControlInfo.CtrlId);
}
SetCtrlCss() {
//switch (this.ControlInfo.StyleName) {
// case "Style2": {
// LayoutConverter.ResizeCallback(this.ControlInfo.CtrlId);
// }
//}
//width会自动计算,存储起来反而会干预其计算效果
//height不会自动计算
//Style2固定屏幕会瞎设置left 给他整成0即可
sessionStorage.setItem('bannerLeft', 0);
this.SetEleCss(this.ControlInfo.ControlView.find(".fullcolumn-outer"), {
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
left: 0
})
this.SetEleCss(this.ControlInfo.ControlView.find(`.fullcolumn-inner[cid=${this.ControlInfo.CtrlId}]`), {
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
})
this.SetEleCss(this.ControlInfo.ControlView, {
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
top: `${this.ControlInfo.AdjustControlInfo.TopWithOffset}px`,
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
});
super.SetLzparallax(this.ControlInfo.ControlView.find(`#bannerWrap_${this.ControlInfo.CtrlId} > .w-banner-image`));
}
}
class codeAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetWidthAndHeight(newWidth) {
var zoomMode = this.ControlInfo.ControlView.attr("zoomMode");
switch (zoomMode) {
case "SetWidthAndHeight_JustWidth": {
super.SetWidthAndHeight_JustWidth(newWidth);
break;
}
default: {
super.SetWidthAndHeight_ZoomHeight(newWidth);
break;
}
}
}
SetCtrlCss() {
super.SetCtrlCss();
this.SetEleCss(this.ControlInfo.ControlView.find(".w-code"), {
height: `${this.ControlInfo.AdjustControlInfo.Height}px`,
width: `${this.ControlInfo.AdjustControlInfo.Width}px`,
})
}
}
class mustacheAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
var self = this;
this.ControlInfo.ControlView.find(".w-resulte-btn-more").on("click", (e) => {
if (self.HeightOffset === null) {
self.HeightOffset = self.ControlInfo.ControlView.height() - self.ControlInfo.Height;
}
self.IsOpen = self.ClickCounter++ % 2 === 0;
if (CtrlAdjuster.GetCurrentBrowserWidth() > CtrlAdjuster.GetOriPageWidth()) {
window.xa.Adjuster.AddOriMainHeight(self.HeightOffset * (self.IsOpen ? 1 : -1));
}
//else {
// if (self.IsOpen) {
// window.xa.Adjuster.AddOriMainHeight(-self.HeightOffset);
// }
//}
});
}
HeightOffset = null;
ClickCounter = 0;
IsOpen = false;
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = this.IsOpen ? this.ControlInfo.ControlView.height() : this.ControlInfo.Height;
}
}
class qrcodeAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
SetWidthAndHeight(newWidth) {
this.SetWidthAndHeight_ZoomHeight(newWidth);
}
SetCtrlCss() {
this.SetEleWidthAndHeightByAdjustControlInfo(this.ControlInfo.ControlView.find(".qrcode_Style1,.qrcode_Style1,.w-qrcode,img"));
super.SetCtrlCss();
}
ChangedRowAct(cell, headerCtrl, header) {
super.ChangedRowAct_AlignLeft(cell, headerCtrl, header);
}
}
class newsItemCreatedDatetimeBindAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class newsItemFavoritesBindAdjuster extends fixMinZoomAs1Adjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class formpanelAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
this.OriBtnWidth = controlInfo.ControlView.find(".w-submit").width();
}
OriBtnWidth;
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
super.SetCtrlCss();
var newHeight = this.ControlInfo.ControlView.height();
this.ControlInfo.AdjustControlInfo.Width = this.ControlInfo.Width;
super.SetCtrlCss();
super.ResetTag2OriCss();
this.ControlInfo.AdjustControlInfo.Width = newWidth;
this.ControlInfo.AdjustControlInfo.Height = newHeight;
}
SetCtrlCss() {
super.SetCtrlCss();
var padding = AdjustHelper.GetCssPixelSize(this.ControlInfo.ControlView.find(".w-submit-outer"), "padding-left") * 2;
var btnWidth = this.OriBtnWidth > this.ControlInfo.AdjustControlInfo.Width ? (this.ControlInfo.AdjustControlInfo.Width) : this.OriBtnWidth;
this.SetEleCss(this.ControlInfo.ControlView.find(".w-submit"), { "min-width": `${btnWidth - padding}px` })
}
}
class fullpageSlideAdjuster extends slidesetAdjuster {
constructor(controlInfo) {
super(controlInfo);
}
}
class multinavAdjuster extends baseAdjuster {
constructor(controlInfo) {
super(controlInfo);
this.LogoPercent = AdjustHelper.ToFixed(this.ControlInfo.ControlView.find(".logo-area").attr("data-width") * 1 / 100, 3)
this.NavPercent = AdjustHelper.ToFixed(this.ControlInfo.ControlView.find(".nav-area").attr("data-width") * 1 / 100, 3)
var items = this.ControlInfo.ControlView.find(".nav-item");
this.OriItemWidth = items.width()
}
LogoPercent;
NavPercent;
OriItemWidth;
get IsFullScreen() {
return this.ControlInfo.ControlView.find(".fullScreen").length !== 0;
}
Reset2OriCss() {
this.SetCtrlCss();
}
SetCtrlCss() {
this.SetEleCss(this.ControlInfo.ControlView, {
width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-content"), {
width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-container"), {
width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px`,
left: `0px`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav_Area"), {
width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px`
})
if (CtrlAdjuster.GetCurrentBrowserWidth() <= 750 || CtrlAdjuster.IsMobile) {
this.SetEleCss(this.ControlInfo.ControlView.find(".logo-area"), {
display: `none`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-area"), {
display: `none`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav_Area"), {
display: `none`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav_mobile_wrapper"), {
display: `flex`
})
this.ControlInfo.ControlView.find(".nav-container").addClass("navMobile-container");
if (this.ControlInfo.ControlView.find(".areaWrapper > div").length == 0) {
this.ControlInfo.ControlView.find(".nav_Area > div").appendTo(this.ControlInfo.ControlView.find(".areaWrapper"))
}
var slef = this;
this.ControlInfo.ControlView.find(".areaWrapper > div").each((index, item) => {
slef.SetEleCss($(item), {
position: "relative",
left: "0",
top: "0",
zIndex: `${slef.ControlInfo.ControlView.find(".areaWrapper > div").length - index}`,
width: "240px",
marginTop: "30px"
})
if ($(item).attr("ctype") == "languages") {
slef.SetEleCss($(item).find('.w-language'), {
width: "100%"
})
}
if ($(item).attr("ctype") == "search") {
slef.SetEleCss($(item).find('.w-search'), {
width: "100%"
})
}
if ($(item).attr("ctype") == "share") {
slef.SetEleCss($(item), {
height: "auto"
})
slef.SetEleCss($(item).find('.w-share'), {
width: "100%"
})
}
})
} else {
if (this.ControlInfo.ControlView.find(".areaWrapper > div").length > 0) {
this.ControlInfo.ControlView.find(".areaWrapper > div").appendTo(this.ControlInfo.ControlView.find(".nav_Area"))
this.ControlInfo.ControlView.find(".nav_Area > div").each((index, item) => {
this.SetEleCss($(item), {
position: "absolute",
marginTop: "0"
})
})
}
this.ControlInfo.ControlView.find(".nav-container").removeClass("navMobile-container");
this.SetEleCss(this.ControlInfo.ControlView.find(".nav_mobile_wrapper"), {
display: `none`
})
var areaWidth = AdjustHelper.ToFixed(CtrlAdjuster.GetCurrentBrowserWidth() * this.NavPercent);
this.SetEleCss(this.ControlInfo.ControlView.find(".logo-area"), {
width: `${AdjustHelper.ToFixed(CtrlAdjuster.GetCurrentBrowserWidth() * this.LogoPercent)}px`,
display: `block`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-area"), {
width: `${areaWidth}px`,
display: `block`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav_Area"), {
display: `block`
})
if (CtrlAdjuster.GetCurrentBrowserWidth() > CtrlAdjuster.OriPageWidth) {
this.SetEleCss(this.ControlInfo.ControlView.find(".nav_Area"), {
width: `${CtrlAdjuster.OriPageWidth}px`
})
if (!this.IsFullScreen) {
this.SetEleCss(this.ControlInfo.ControlView, {
width: `${CtrlAdjuster.OriPageWidth}px`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-content"), {
width: `${CtrlAdjuster.OriPageWidth}px`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-container"), {
width: `${CtrlAdjuster.OriPageWidth}px`,
left: `${(CtrlAdjuster.GetCurrentBrowserWidth() - CtrlAdjuster.OriPageWidth) / 2}px`
})
var areaWidth = AdjustHelper.ToFixed(CtrlAdjuster.OriPageWidth * this.NavPercent);
this.SetEleCss(this.ControlInfo.ControlView.find(".logo-area"), {
width: `${AdjustHelper.ToFixed(CtrlAdjuster.OriPageWidth * this.LogoPercent)}px`,
display: `block`
})
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-area"), {
width: `${areaWidth}px`,
display: `block`
})
}
}
var items = this.ControlInfo.ControlView.find(".nav-area .nav-item");
var currentItemWidth = AdjustHelper.ToFixed(this.ControlInfo.ControlView.find(".nav-area").width() / items.length, 0);
items.each((a, b) => {
this.SetEleCss($(b), {
width: `${currentItemWidth < this.OriItemWidth ? currentItemWidth : this.OriItemWidth}px`
});
})
if (CtrlAdjuster.GetCurrentBrowserWidth() <= 1200) {
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-list .nav-contentWrapper"), {
width: `${CtrlAdjuster.GetCurrentBrowserWidth()}px`,
padding: `48px 50px 0`
})
} else {
this.SetEleCss(this.ControlInfo.ControlView.find(".nav-list .nav-contentWrapper"), {
width: `1200px`,
padding: `48px 0 0`
})
}
}
}
}
class flexiblePanelAdjuster extends baseAdjuster {
OriginalHeight = 0;
LeftBorder = 0;
RightBorder = 0;
constructor(controlInfo) {
super(controlInfo);
switch (this.ControlInfo.StyleName) {
case "Style1": {
this.OriginalHeight = this.GetDisplayHeight();
this.LeftBorder = AdjustHelper.GetCssPixelSize(controlInfo.ControlView.find(".w-label-content"), "border-left-width");
this.RightBorder = AdjustHelper.GetCssPixelSize(controlInfo.ControlView.find(".w-label-content"), "border-right-width");
break;
}
default: {
break;
}
}
}
GetDisplayHeight() {
//var DisplayHeight = super.GetDisplayHeight();;
//switch (this.ControlInfo.StyleName) {
// default: {
// // DisplayHeight = super.GetDisplayHeight();
// DisplayHeight = this.ControlInfo.ControlView.children().children().children(".w-label-item").height() * 3;
// }
//}
//return DisplayHeight;
var forceShowEles = this.ControlInfo.ControlView.find(".forceShow");
if (forceShowEles.length > 0) {
forceShowEles.each((a, b) => {
$(b).removeClass("forceShow")
})
}
var tabHeight;
switch (this.ControlInfo.StyleName) {
case "Style1":
{
tabHeight = this.ControlInfo.ControlView.children().find(">.w-label").height();
break;
}
default: {
tabHeight = super.GetDisplayHeight();;
}
}
forceShowEles.each((a, b) => {
$(b).addClass("forceShow")
})
return tabHeight;
}
Reset2OriCss() {
this._ClearControlEffect();
this._ResizeControlEffect();
}
SetWidthAndHeight(newWidth) {
super.SetWidthAndHeight(newWidth);
// 容器宽度计算 减去边框
this.ControlInfo.AdjustControlInfo.Width4Children = newWidth - this.LeftBorder - this.RightBorder;
}
SetContentAreaCss() {
var contentAreaList = this.ControlInfo.ControlView.children().children().children(".w-label-item").find(">.w-label-content>.smAreaC");
contentAreaList.each((a, b) => {
var maxHeight = 0;
$(b).parent().show();
var bTop = b.getBoundingClientRect().top;
$(b).find("[ctype]").each((x, y) => {
var bottom = y.getBoundingClientRect().bottom;
var height = bottom - bTop;
if (height > maxHeight) {
maxHeight = height;
}
});
$(b).parent().hide();
//this.SetEleCss($(b), { width: `${this.ControlInfo.AdjustControlInfo.Width}px` });
if (maxHeight) {
this.SetEleCss($(b), { height: `${maxHeight + AdjustConfig.MinCtrlYPadding}px` });
}
});
}
SetHeight(newHeight) {
this.ControlInfo.AdjustControlInfo.Height = newHeight;
super.SetCtrlCss();
}
_ClearControlEffect() {
//var ControlView = this.ControlInfo.ControlView;
//if (ControlView.data("smart.remcopute")) {
// ControlView.find(".w-label-item.current").removeClass("current")
// .find(">.w-label-content").hide();
// ControlView.smrecompute("recomputeTo", parseInt(ControlView.attr("origh")));
// ControlView.data("smart.remcopute", null);
//};
var ControlView = this.ControlInfo.ControlView;
var selectarea = this.SelectArea = ControlView.attr('selectarea');
if (ControlView.data("smart.remcopute")) {
ControlView.children().children().children('[data-area="' + selectarea + '"]').children('.w-label-title').click();
};
}
_ResizeControlEffect() {
// 重新打开选择的
if (Promise) {
Promise.resolve().then(() => {
var selectarea = this.SelectArea;
if (selectarea) {
this.ControlInfo.ControlView.children().children().children('[data-area="' + selectarea + '"]').children('.w-label-title').click();
}
})
}
}
SetCtrlCss() {
switch (this.ControlInfo.StyleName) {
default: {
//var $contentArea = ControlView.children().children().children(".w-label-item.current").find(">.w-label-content>.smAreaC");
//var maxHeight = 0;
//if ($contentArea.length > 0) {
// maxHeight = $contentArea.height();
//}
this._ClearControlEffect();
this.SetHeight(this.OriginalHeight);
super.SetCtrlCss();
this.SetContentAreaCss();
this._ResizeControlEffect();
}
}
}
}
class breadcrumbAdjuster extends baseAdjuster {
GetDisplayHeight() {
return this.ControlInfo.ControlView.find(".w-crumbs").height();
}
SetWidthAndHeight(newWidth) {
this.ControlInfo.AdjustControlInfo.Width = newWidth;
super.SetCtrlCss();
this.ControlInfo.AdjustControlInfo.Height = this.GetDisplayHeight();
}
}
class AdjustControlInfo {
constructor(ctrlInfo, width, height, left, top) {
this.ControlInfo = ctrlInfo;
this._height = height;
this._top = top;
this._left = left;
this._width = width;
}
ControlInfo;
DebuggerMsg = "";
get CtrlId() {
return this.ControlInfo.CtrlId;
}
get TopWithOffset() {
var isFixOnTop = this.ControlInfo.Top < 400;
if (this.ControlInfo.IsFixedCtrl && !isFixOnTop) {
return $(window).height() - this.Height;
}
else {
return this.Top + this.ControlInfo.RowInfo.TopOffsetOfRow;
}
}
InitLineNum() {
if (this.ControlInfo.IsFirstCell) {
this.LineNum = 0;
}
else {
var overflowStartIndex = this.ControlInfo.RowInfo.OverflowStartIndex;
var isOverflowOfLine = overflowStartIndex !== null ? this.ControlInfo.IndexOfRow >= overflowStartIndex : false;
if (isOverflowOfLine) {
var lastLineNum = Math.max.apply(Math, this.ControlInfo.PrevCtrls.map(function (o) { return o.AdjustControlInfo.LineNum; }))
var createNewLine = this.ControlInfo.RowInfo.Cells.filter(i => i.AdjustControlInfo.LineNum === lastLineNum).length >= overflowStartIndex;
this.LineNum = lastLineNum + (createNewLine ? 1 : 0);
}
else {
this.LineNum = 0;
}
}
}
LineNum = null;
get RowInfo() {
return this.ControlInfo.RowInfo;
}
get NextRow() {
return this.ControlInfo.RowInfo.NextRow;
}
get NextLineCell() {
var nextLine =
this.ControlInfo.RowInfo.Cells.find(i => (i.AdjustControlInfo.IndexOfLine === (this.IndexOfLine)
&& i.AdjustControlInfo.LineNum === this.LineNum + 1));
return nextLine;
}
get PrevLineCell() {
var prevLine =
this.ControlInfo.RowInfo.Cells.find(i => (i.AdjustControlInfo.IndexOfLine === (this.IndexOfLine)
&& i.AdjustControlInfo.LineNum === this.LineNum - 1));
return prevLine;
}
get LastLine() {
return this.ControlInfo.RowInfo.Cells.filter(i => i.AdjustControlInfo.LineNum === this.LineNum - 1).map(i => i.AdjustControlInfo);
}
get ThisLine() {
return this.ControlInfo.RowInfo.Cells.filter(i => i.AdjustControlInfo.LineNum === this.LineNum).map(i => i.AdjustControlInfo);
}
get IndexOfLine() {
var columnCount = this.RowInfo.LayoutTable.ColumnCount;
return this.ControlInfo.IndexOfRow % columnCount;
}
get IsLastCellOfLine() {
return this.ControlInfo.RowInfo.Cells.find(i => i.AdjustControlInfo.LineNum === this.LineNum).length === this.IndexOfLine + 1;
}
get IsFirstCellOfLine() {
return this.ControlInfo.RowInfo.Cells.find(i => i.AdjustControlInfo.LineNum === this.LineNum).length === 1;
}
get TreeIndex() {
return this.ControlInfo.TreeIndex;
}
get Parent() {
return this.ControlInfo.Parent;
}
_top;
get Top() {
return this._top;
}
set Top(top) {
top = AdjustHelper.ToFixed(top, 3)
var offset = top - this._top;
this._top = top;
this.AddParentHeight(offset);
}
AddParentHeight(val2Add) {
if (val2Add) {
if (!this.SkipAddParentHeight() && this.ControlInfo.IsLastCell) {
if (this.Parent != null) {
this.Parent.AdjustControlInfo.Height += val2Add;
}
}
}
}
_height;
set Height(height) {
//height = AdjustHelper.ToFixed(height, 3)
// 现代浏览器支持小数点渲染,但是这样可能会使某些控件中的定位元素出现偏移,所以这里还是使用整数
// fix http://jira.clouddream.net/browse/XSWZ-729
// 更改位置2-1
height = AdjustHelper.ToFixed(height)
var offset = height - this._height;
this._height = height;
if (offset) {
this.FormatRowOffset(offset);
}
}
get Height() {
return this._height;
}
SkipAddParentHeight() {
if (this.ControlInfo.MightBeBackground || this.ControlInfo.SkipFormatRowOffset || (this.Parent && this.Parent.IsMultiContainer)) {
return true;
}
return false;
}
FormatRowOffset(offset) {
if (!this.SkipAddParentHeight()) {
var maxHeightOffsetOfLine = this.RowInfo.Cells.filter(i => i.AdjustControlInfo.LineNum == this.LineNum).map(i => i.AdjustControlInfo.Height - i.Height).sort((a, b) => { return b - a; })[0];
var maxHeightOfLine = this.RowInfo.Cells.filter(i => i.AdjustControlInfo.LineNum == this.LineNum).map(i => i.AdjustControlInfo.Height).sort((a, b) => { return b - a; })[0];
var lastTimeLineOffset = this.RowInfo.LineOffset[this.LineNum] || 0;
this.RowInfo.LineOffset[this.LineNum] = maxHeightOffsetOfLine;
var height = maxHeightOffsetOfLine - lastTimeLineOffset;
if (this.Height >= maxHeightOfLine) {
if (this.Parent != null) {
this.Parent.AdjustControlInfo.Height += height;
}
}
}
this.AddNextLineTopOffset(offset);
}
AddNextLineTopOffset(offset) {
if (this.NextLineCell != null) {
this.NextLineCell.AdjustControlInfo._top += offset;
this.NextLineCell.AdjustControlInfo.AddNextLineTopOffset(offset);
}
}
_width4Children = null;
set Width4Children(width4Children) {
this._width4Children = width4Children;
}
get Width4Children() {
return this._width4Children === null ? this.Width : (this._width4Children > this.ParentWidthSubPadding ? this.ParentWidthSubPadding : this._width4Children);
}
get ParentWidth() {
return this.Parent ? this.Parent.AdjustControlInfo.Width4Children : CtrlAdjuster.GetCurrentBrowserWidth();
}
get ParentWidthSubPadding() {
return this.ParentWidth - this.ControlInfo.ParentXPadding * 2;
}
_left;
get Left() {
return this._left <= this.ControlInfo.ParentXPadding ? this.ControlInfo.ParentXPadding : this._left;
}
set Left(left) {
this._left = AdjustHelper.ToFixed(left, 3);
}
_width;
set Width(width) {
this._width = AdjustHelper.ToFixed(width, 3);
}
ForceGetWidth = false;
get Width() {
if (this.ForceGetWidth) {
return this._width;
}
else {
return this._width > this.ParentWidthSubPadding ? this.ParentWidthSubPadding : this._width;
}
}
get Right() { return this.Left + this.Width; }
get Bottom() { return this.Top + this.Height; }
get Size() { return this.Width * this.Height; }
IsHide = false;
}
class ControlInfo {
constructor(width, height, left, top) {
this.Width = width;
this.Left = left;
this.Top = top;
this.Height = height;
this.IndexFlag = ControlInfo.Counter++;
}
get ControlView() {
if (this.ElementId) {
//防止不能找到复制的控件
var currentEle = $(`#${this.ElementId}`);
if (currentEle[0] !== this._controlView[0]) {
return this._controlView = currentEle;
}
else {
return this._controlView;
}
}
else {
return this._controlView;
}
}
set ControlView(controlView) { this._controlView = controlView; }
_controlView;
IndexFlag = 0;
static Counter = 0;
//ControlView;
_level = null;
Color;
IsFullRowCtrl = false;
get IsTemplateCtrl() {
return this.CtrlLocation !== "main";
}
HasHandleVirtualArea = false;
CtrlLocation;
CtrlId;
ElementId;
ParentId;
Parent;
Children = [];
IndexOfRow;
StyleName;
get IsVirtualCtrl() {
return this.ControlView == undefined;
}
//获取父级ID 不包括AreaId
get RealParentId() {
var parent = this.Parent;
while (parent != null && parent.IsVirtualCtrl) {
parent = parent.Parent;
}
return parent ? parent.CtrlId : null;
}
RowId;
AreaId;
SkipThisCtrl = false;
_mightBeBackground = null;
get MightBeBackground() {
if (this._mightBeBackground === null) {
return this._mightBeBackground = (this.CtrlName === "dialog" || this.IsFixedCtrl);
}
else {
return this._mightBeBackground;
}
}
set MightBeBackground(mightBeBackground) {
this._mightBeBackground = mightBeBackground;
}
ParentControlAreaId;
CtrlName;
RowInfo;
AdjustControlInfo;
CtrlAdjuster;
IsContainer = false;
EleOriCssList = [];
get IsFirstCell() { return this.IndexOfRow === 0; }
get IsLastCell() { return this.IndexOfRow === this.RowInfo.Cells.length - 1; }
_displayHeight = null;
set DisplayHeight(displayHeight) {
this._displayHeight = displayHeight;
}
get DisplayHeight() {
if (this._displayHeight) {
return this._displayHeight;
}
else {
return this._displayHeight = this.CtrlAdjuster.GetDisplayHeight();
}
}
_displayWidth = null;
set DisplayWidth(displayWidth) {
this._displayWidth = displayWidth;
}
get DisplayWidth() {
if (this._displayWidth) {
return this._displayWidth;
}
else {
return this._displayWidth = this.CtrlAdjuster.GetDisplayWidth();
}
}
get DisplayBottom() {
return this.Top + this.DisplayHeight;
}
get DisplayRight() {
return this.Left + this.DisplayWidth;
}
ResetAdjustControlInfo() {
this.AdjustControlInfo = new AdjustControlInfo(this, this.DisplayWidth, this.Height, this.Left, this.Top);
}
MatchAdjuster() {
this.CtrlAdjuster = baseAdjuster.InitAdjuster(this);
this.ResetAdjustControlInfo();
}
get PrevCtrls() {
var list = [];
var prevCtrl = this.PrevCtrl;
while (prevCtrl != null) {
list.push(prevCtrl);
prevCtrl = prevCtrl.PrevCtrl;
}
return list.sort((a, b) => { return a.IndexOfRow - b.IndexOfRow; });
}
_level = null;
GetLevel(ctrlList) {
//更改父级关系后,要重新设置_level
if (this.ParentId == null) {
return 0;
}
else {
return this._level === null ? (this._level = ctrlList.find(i => i.CtrlId == this.ParentId).GetLevel(ctrlList) + 1) : this._level;
}
}
get PrevCtrl() {
var currentIndex = this.RowInfo.Cells.indexOf(this);
if (currentIndex === 0) {
return null;
}
else {
return this.RowInfo.Cells[currentIndex - 1];
}
}
get NextCtrl() {
var currentIndex = this.RowInfo.Cells.indexOf(this);
if (currentIndex == this.RowInfo.Cells.length - 1) {
return null;
}
else {
return this.RowInfo.Cells[currentIndex + 1];
}
}
get IsLastChildOfLine() {
//todo
}
GetCtrlBehind() {
var currentIndex = this.RowInfo.Cells.indexOf(this);
if (currentIndex == this.RowInfo.Cells.Count - 1) {
return [];
}
else {
return this.RowInfo.Cells.slice(currentIndex + 1);
}
}
_isMultiContainer = null;
set IsMultiContainer(isMultiContainer) {
this._isMultiContainer = isMultiContainer;
}
//是否是slideset,tab这种可以切换,有多个子级的控件,这种只需要计算一次最大高度,否则多次叠加会撑的很高
get IsMultiContainer() {
var containerList = ["slideset", "fullpageSlide", "tab", "flexiblePanel"]//
if (this._isMultiContainer === null) {
if (this.CtrlName === "area" && this.StyleName === "Style3") {
return this._isMultiContainer = true;
}
else {
return this._isMultiContainer = containerList.indexOf(this.CtrlName) !== -1;
}
}
else {
return this._isMultiContainer
}
}
MultiContainerHeightOffset = 0;
get SkipFormatRowOffset() {
if (
(this.Parent && this.Parent.CtrlName === "tab" && this.Parent.StyleName === "Style6")
|| (this.Parent && this.Parent.CtrlName === "tab" && this.Parent.StyleName === "Style2")
|| (this.Parent && this.Parent.CtrlName === "tab" && this.Parent.StyleName === "Style11")
|| (this.Parent && this.Parent.CtrlName === "tab" && this.Parent.StyleName === "Style12")
|| this.CtrlName === "dialog"
|| this.CtrlName === "multinav"
|| this.CtrlName === "flexiblePanel"
) {
return true;
}
else {
return false;
}
};
get SkipHeightCalc() {
if (this.SkipFormatRowOffset) {
return true;
}
else {
if (this.Parent) {
return this.Parent.SkipHeightCalc;
}
else {
return false;
}
}
}
AttachArg = {};
_treeIndex = null;
get TreeIndex() {
var indexStr = "#";
if (this._treeIndex === null) {
var parent = this.Parent;
while (parent != null) {
indexStr += `${parent.CtrlId}#`
parent = parent.Parent;
}
return this._treeIndex = indexStr;
}
else {
return this._treeIndex;
}
}
//是否为虚拟容器
IsVirtualContainer = false;
_parentWidth = null;
set ParentWidth(parentWidth) {
this._parentWidth = parentWidth;
}
get ParentWidth() {
if (this._parentWidth === null) {
return this.Parent ? this.Parent.DisplayWidth : CtrlAdjuster.OriPageWidth;
}
else {
return this._parentWidth;
}
}
get ParentXPadding() {
//return (this.ParentWidth - this.RowInfo.DisplayWidth) < AdjustConfig.MinCtrlXPadding ? 0 : AdjustConfig.MinCtrlXPadding;
return (this.RowInfo.FirstCell.Left < AdjustConfig.MinCtrlXPadding) || (this.ParentWidth - this.RowInfo.LastCell.Right < AdjustConfig.MinCtrlXPadding) ? 0 : AdjustConfig.MinCtrlXPadding;
}
get ParentYPadding() {
//this.CtrlName === "multicolumnVirtualItem" ? 0 : // multicolumn 响应式优化
return (this.Parent ? AdjustConfig.MinCtrlYPadding : AdjustConfig.MinDocumentYPadding);
}
get PreLoadAdjustControlInfo() {
return this.RowInfo.PreLoadRowAdjustControlInfo.find(i => i.CtrlId === this.CtrlId);
}
IsSupportResponsive(ctrlList) {
var invisCtrlList = AdjustConfig.UnSupportCtrlList;
if (this.ParentId) {
var parent = ctrlList.find(i => i.CtrlId == this.ParentId);
if (!parent) {
return false;
}
else {
return !invisCtrlList.some(i => this.CtrlName.startsWith(i)) && parent.IsSupportResponsive(ctrlList);
}
}
else {
return !invisCtrlList.some(i => this.CtrlName.startsWith(i));
}
}
WidthOffset = 0;
get GlobalLeft() {
return this.Parent ? this.Parent.GlobalLeft + this.Left : this.Left;
}
get GlobalTop() {
return this.Parent ? this.Parent.GlobalTop + this.Top : this.Top;
}
get Size() {
return this.Height * this.Width;
}
_isFixedCtrl = null;
get IsFixedCtrl() {
return this._isFixedCtrl === null ? this._isFixedCtrl = this.ControlView && this.ControlView.hasClass(AdjustConfig.FixedCtrlFlag) : this._isFixedCtrl;
}
//响应式跳过
get SkipSpecCtrl() {
if (this.IsFixedCtrl && this.Width <= AdjustConfig.SkipFixedCtrlWidth) {
return true;
}
//跳过小尺寸的代码控件
else if (this.CtrlName === "code" && this.ControlView.find(".w-code>div").find(":not(style,script,link)").length === 0) {
this.ControlView.css("display", "none");
return true;
}
else {
if (this.Parent) {
return this.Parent.SkipSpecCtrl;
}
else {
return false;
}
}
}
//避免类似0.333333333333这种变成0.333333333334导致0.33333333*3大于1
_width;
set Width(width) {
this._width = AdjustHelper.ToFixed(width, 3);
}
get Width() {
return this._width;
}
_left;
get Left() {
return this._left;
}
set Left(left) {
this._left = AdjustHelper.ToFixed(left, 3);
}
_height;
get Height() {
return this._height;
}
set Height(height) {
// this._height = AdjustHelper.ToFixed(height, 3);
// 现代浏览器支持小数点渲染,但是这样可能会使某些控件中的定位元素出现偏移,所以这里还是使用整数
// fix http://jira.clouddream.net/browse/XSWZ-729
// 更改位置2-2
this._height = AdjustHelper.ToFixed(height);
}
_top;
get Top() {
return this._top;
}
set Top(top) {
this._top = AdjustHelper.ToFixed(top, 3)
}
get Right() { return this.Left + this.Width; }
get Bottom() { return this.Top + this.Height; }
//与上个控件的间隔,若是第一个控件则直接返回Left
get LeftGap() {
return (this.IsFirstCell ? this.Left : (this.Left - this.PrevCtrl.Right));
}
//是否为指定控件类型的子级
IsChildNodeOfSpecCtrlName(parentCtrlName, styleName) {
if (this.Parent) {
if (this.Parent.CtrlName === parentCtrlName && (!styleName || this.Parent.StyleName === styleName)) {
return true;
}
else {
return this.Parent.IsChildNodeOfSpecCtrlName(parentCtrlName, styleName);
}
}
else {
return false;
}
}
}
class RowInfo {
RowId = `row_${RowInfo.Counter++}`;
NextRow;
PrevRow;
Level = 0;
static Counter = 0;
get ColumnCount() {
return this.Cells.map(i => i.AdjustControlInfo).filter(i => i.LineNum === 0).length;
}
Cells = [];
_topOffsetOfRow = null;
set TopOffsetOfRow(topOffsetOfRow) {
this._topOffsetOfRow = topOffsetOfRow;
}
get TopOffsetOfRow() {
if (this._topOffsetOfRow === null) {
return this.PrevRow ? (this.PrevRow.NewBottom - this.PrevRow.Bottom + this.PrevRow.TopOffsetOfRow) : 0
}
else {
return this._topOffsetOfRow;
}
};
_bottom = null;
get Bottom() {
return this._bottom === null ? this._bottom = Math.max.apply(Math, this.Cells.map(function (o) { return o.Bottom; })) : this._bottom;
}
_top = null;
get Top() {
return this._top === null ? this._top = Math.min.apply(Math, this.Cells.map(function (o) { return o.Top; })) : this._top;
}
get NewBottom() {
var list = this.Cells.map(i => i.AdjustControlInfo);
return Math.max.apply(Math, list.map(function (o) { return o.Bottom; }));
}
get NewTop() {
var list = this.Cells.map(i => i.AdjustControlInfo);
return Math.min.apply(Math, list.map(function (o) { return o.Top; }));
}
get Left() {
return Math.min.apply(Math, this.Cells.map(function (o) { return o.Left; }))
}
get DisplayRight() {
return Math.max.apply(Math, this.Cells.map(function (o) { return o.DisplayRight; }))
}
get Height() {
return this.Bottom - this.Top;
}
get DisplayWidth() {
return this.DisplayRight - this.Left;
}
get NewWidth() {
return this.Cells[0].AdjustControlInfo.ParentWidth;
}
get OriWidth() {
return this.Cells[0].ParentWidth;
}
get NewHeight() {
return this.NewBottom - this.NewTop
}
get RowHeightOffset() {
return this.NewHeight - this.Height;
}
get AreaId() {
return this.FirstCell.AreaId;
}
get Parent() {
return this.FirstCell.Parent;
};
get MightBeBackground() {
return this.FirstCell.MightBeBackground;
}
get CtrlLocation() {
return this.FirstCell.CtrlLocation;
};
get ParentControlAreaId() {
return this.FirstCell.ParentControlAreaId;
}
get SkipFormatRowOffset() {
return this.FirstCell.SkipFormatRowOffset;
}
get FirstCell() {
return this.Cells[0];
}
get LastCell() {
return this.Cells.find(i => i.IsLastCell);
}
GetAllCtrls(ctrlList) {
//if (this.Cells.length === 1 && this.Cells[0].IsContainer) {
//todo fix汉堡导航内从上到下 从左到右顺序
//}
var ctrls = [];
function GetChildren(cellList) {
cellList.forEach(ctrl => {
ctrls.push(ctrl);
var children = ctrlList.filter(i => i.ParentId === ctrl.CtrlId);
GetChildren(children);
});
}
GetChildren(this.Cells);
this.Cells.forEach(cell => {
if (!ctrls.some(i => i.CtrlId === cell.CtrlId)) {
ctrls.push(cell);
}
})
return ctrls.sort((a, b) => {
return a.Left - b.Left;
});
}
LineOffset = {};
LayoutTable;
get OverflowStartIndex() {
return CtrlAdjuster.GetOverflowStartIndex(this);
}
PreLoadRowAdjustControlInfo = [];
}
class PreloadItem {
constructor(preloadInfoRow, cell) {
this._cell = cell;
this._preloadInfoRow = preloadInfoRow;
}
_cell;
_preloadInfoRow;
get CtrlId() {
return this.Cell.CtrlId;
}
get IndexOfRow() {
return this.Cell.IndexOfRow;
}
get PrevItem() {
return this.IndexOfRow > 0 ? this._preloadInfoRow.Items[this.IndexOfRow - 1] : null;
}
get NextItem() {
return this.IndexOfRow >= this._preloadInfoRow.Items.length ? null : this._preloadInfoRow.Items[this.IndexOfRow + 1];
}
get Cell() {
return this._cell;
}
ZoomMode = 0;
LeftGapOffset = 0;
_zoomWidth;
set ZoomWidth(zoomWidth) {
this._zoomWidth = zoomWidth;
}
get ZoomWidth() {
return AdjustHelper.ToFixed(this._zoomWidth);
}
get OriLeftGap() {
return this.Cell.LeftGap;
}
_zoomedLeftGap;
set ZoomedLeftGap(zoomedLeftGap) {
this._zoomedLeftGap = zoomedLeftGap;
}
get ZoomedLeftGap() {
return this.ZoomMode === 0 ? (this._zoomedLeftGap - this.LeftGapOffset) : this.MinZoomedLeftGap;
}
_zoomLeft = null;
set ZoomLeft(zoomLeft) {
this._zoomLeft = zoomLeft;
}
get MinZoomedLeftGap() {
return this.Cell.LeftGap < AdjustConfig.MinCtrlXPadding ? this.Cell.LeftGap : AdjustConfig.MinCtrlXPadding;
}
get ZoomLeft() {
if (this._zoomLeft === null) {
return AdjustHelper.ToFixed(this.PrevItem === null ? this.ZoomedLeftGap : this.PrevItem.ZoomRight + this.ZoomedLeftGap);
}
else {
return AdjustHelper.ToFixed(this._zoomLeft);
}
}
get ZoomRight() {
return AdjustHelper.ToFixed(this.ZoomLeft + this.ZoomWidth);
}
}
class PreloadRow {
constructor(row) {
for (var x = 0; x < row.Cells.length; x++) {
this.Items.push(new PreloadItem(this, row.Cells[x]));
}
}
Items = [];
HandleItem(cell, func) {
var item = this.Items[cell.IndexOfRow];
func(item);
}
AdjustSubWidthOffset(rowId) {
for (var x = 0; x < this.Items.length; x++) {
var item = this.Items[x];
var width2Sub = AdjustConfig.MinCtrlXPadding - item.ZoomedLeftGap;
if (item.Cell.LeftGap >= AdjustConfig.MinCtrlXPadding && width2Sub > 0) {
for (var y = 0; y < this.Items.length; y++) {
if (y !== x) {
var anotherItem = this.Items[y];
if (anotherItem.ZoomedLeftGap > AdjustConfig.MinCtrlXPadding) {
var subVal = anotherItem.ZoomedLeftGap - AdjustConfig.MinCtrlXPadding;
if (subVal > width2Sub) {
anotherItem.LeftGapOffset += width2Sub;
item.LeftGapOffset -= width2Sub;
break;
}
else {
anotherItem.LeftGapOffset += subVal;
item.LeftGapOffset -= subVal;
width2Sub -= subVal;
}
}
}
}
}
}
}
}
class CtrlAdjuster {
constructor(ctrlList) {
this.CtrlList = ctrlList;
this.BackOriPageInfo();
this.CtrlTable = [];
this.InitTable();
this.InitOriFixedWidthEleList();
CtrlAdjuster.StaticCtrlList = this.CtrlList;
}
static MockPageWidth() {
var mockPageWidth = AdjustHelper.GetQueryVal("mockPageWidth") * 1;
if (mockPageWidth) {
Object.defineProperty(document.documentElement, 'clientWidth', {
configurable: true,
get: function () {
return mockPageWidth;
}
});
}
else {
if (window.UseMockPageWidth) {
Object.defineProperty(document.documentElement, 'clientWidth', {
configurable: true,
get: function () {
if (CtrlAdjuster.IsMobile && document.documentElement.offsetWidth <= AdjustConfig.MockMobileWidthThreshold && document.documentElement.offsetWidth > AdjustConfig.MockMobileWidth) {
return AdjustConfig.MockMobileWidth
}
else {
return document.documentElement.offsetWidth
}
},
});
}
}
}
static GetCurrentBrowserWidth() {
return $(window).width();
}
static get HeaderEle() { return $("#smv_Area0"); }
static get MainEle() { return $("#smv_Main"); }
static get FooterEle() {
//有多个id为smv_Area3的,主界面的footer是个数字
return $($("[id=smv_Area3]").toArray().find(i => !isNaN($(i).attr("cpid"))));
}
static OriPageWidth;
OriMainHeightOffset = 0;
OriMainHeight;
OriHeaderHeight;
OriFooterHeight;
LastBrowserWidth;
CtrlList;
CtrlTable;
OriFixedWidthEleList = [];
InitOriFixedWidthEleList() {
this.OriFixedWidthEleList.push($(document.body));
var eles = $(document.body).find("*")
for (var i = 0; i < eles.length; i++) {
var ele = eles.eq(i);
if ((ele[0].style["width"] === `${CtrlAdjuster.OriPageWidth}px` || ele[0].style["min-width"] === `${CtrlAdjuster.OriPageWidth}px`) && !ele.attr("ctype") && ele[0].nodeType === 1) {
ele.attr('oriWidth', ele.css("width"))
ele.attr('oriMinWidth', ele.css("min-width"))
this.OriFixedWidthEleList.push(ele);
}
}
}
static StaticCtrlList;
static StaticCtrlTable;
ResetLayout() {
this.ResetNavHeader();
this.CtrlList.forEach(ctrl => {
ctrl.ResetAdjustControlInfo();
});
this.CtrlTable.forEach(row => {
row.LineOffset = {};
row.TopOffsetOfRow = null;
row._bottom = null;
});
}
static IsInSameArea(ctrlA, ctrlB) {
return ctrlA.CtrlLocation == ctrlB.CtrlLocation
&& ((ctrlA.ParentId == null && ctrlB.ParentId == null) || (ctrlA.ParentId == ctrlB.ParentId && ctrlA.AreaId == ctrlB.AreaId))
}
static InitRow(ctrlList2Load) {
ctrlList2Load.forEach(ctrl => {
ctrl._level = null;
});
var ctrlList = ctrlList2Load.sort((a, b) => {
var aLevel = a.GetLevel(ctrlList2Load);
var bLevel = b.GetLevel(ctrlList2Load);
if (aLevel === bLevel) {
return a.Top - b.Top;
}
return aLevel > bLevel ? 1 : -1;
});
var table = [];
var ctrl = ctrlList.find(i => !i.HasLoad2Table);
while (ctrl != null) {
var row = table.find(x => x.Cells.some(i => (!i.MightBeBackground)
&& i.CtrlLocation == ctrl.CtrlLocation
&& ((i.ParentId == null && ctrl.ParentId == null) || (i.ParentId == ctrl.ParentId && i.AreaId == ctrl.AreaId))
&& ((i.Top + AdjustConfig.IntersectOffset) < ctrl.DisplayBottom)
&& (ctrl.Top + AdjustConfig.IntersectOffset) < i.DisplayBottom
&& !i.IsFullRowCtrl
&& !i.CtrlAdjuster.IsVerticalLine
));
if (row == null || ctrl.MightBeBackground || ctrl.IsFullRowCtrl || ctrl.CtrlAdjuster.IsVerticalLine) {
row = new RowInfo();
row.Level = ctrl.GetLevel(ctrlList2Load);
table.push(row);
}
row.Cells.push(ctrl);
ctrl.HasLoad2Table = true;
ctrl = ctrlList.find(i => !i.HasLoad2Table);
}
ctrlList.forEach(ctrl => {
delete ctrl.HasLoad2Table;
});
table.sort((a, b) => {
var aLevel = a.Level;
var bLevel = b.Level;
if (aLevel === bLevel) {
return a.Top - b.Top;
}
return aLevel > bLevel ? 1 : -1;
});
table.forEach(row => {
if (row.Cells.some(x => x.MightBeBackground || x.CtrlAdjuster.IsVerticalLine)) {
return;
}
else {
var tableArea = table.filter(i => i.CtrlLocation === row.CtrlLocation
&& ((i.Parent == null && row.Parent == null) || (i.Parent === row.Parent && i.AreaId === row.AreaId))
&& i.Top >= row.Top
&& i.RowId != row.RowId
&& i.NextRow == null
&& !i.MightBeBackground
).sort((a, b) => {
if (a.Top === b.Top) {
return a.Height - b.Height;
}
return a.Top - b.Top;
});
var nextRow = tableArea.find(i => i);
row.NextRow = nextRow;
if (nextRow) {
nextRow.PrevRow = row;
}
}
});
return table;
}
InitTable() {
var self = this;
self.CtrlList.forEach(item => {
item.Parent = self.CtrlList.find(i => i.CtrlId == item.ParentId) || null;
if (item.Parent != null) {
item.Parent.Children.push(item);
}
});
//不可合并到FilterInvisCtrl处,否则dialog控件会出问题
self.CtrlList = self.CtrlList.filter(i => !i.SkipSpecCtrl);
self.CtrlTable = CtrlAdjuster.InitRow(self.CtrlList);
self.CtrlTable.forEach(row => {
//修正top偏移量,防止某些top不对齐
var average = row.Cells.reduce((total, next) => total + next.Top, 0) / row.Cells.length;
if (!row.Cells.some(n => Math.abs(n.Top - average) > AdjustConfig.DeviationOffset)
//如果全是同一种控件才自动对齐
&& row.Cells.filter(x => x.CtrlName === row.FirstCell.CtrlName).length === row.Cells.length) {
for (var x in row.Cells) {
var cell = row.Cells[x];
cell.Top = row.Cells[0].Top;
}
}
row.Cells = row.Cells.sort((a, b) => {
if (a.Left === b.Left) {
return a.Top - b.Top;
}
return a.Left > b.Left ? 1 : -1;
});
row.Cells.forEach(cell => {
cell.RowId = row.RowId;
cell.RowInfo = row;
cell.IndexOfRow = row.Cells.indexOf(cell);;
cell.CtrlAdjuster.CalculateMultiContainerHeight && cell.CtrlAdjuster.CalculateMultiContainerHeight()
})
});
CtrlAdjuster.StaticCtrlTable = this.CtrlTable;
}
static GetOriPageWidth() {
return CtrlAdjuster.MainEle.width() || CtrlAdjuster.HeaderEle.width();
}
static InitOriMainHeight() {
return CtrlAdjuster.MainEle.height();
}
static InitOriHeaderHeight() {
return CtrlAdjuster.HeaderEle.height();
}
static InitOriFooterHeight() {
return CtrlAdjuster.FooterEle.height();
}
BackOriPageInfo() {
CtrlAdjuster.OriPageWidth = CtrlAdjuster.GetOriPageWidth();
this.OriMainHeight = CtrlAdjuster.InitOriMainHeight();
this.OriHeaderHeight = CtrlAdjuster.InitOriHeaderHeight();
this.OriFooterHeight = CtrlAdjuster.InitOriFooterHeight();
}
AddOriMainHeight(val2Add) {
this.OriMainHeightOffset += val2Add;
}
ResetPage2OriCss() {
this.SetPageWidth(CtrlAdjuster.OriPageWidth);
CtrlAdjuster.HeaderEle.height(this.OriHeaderHeight);
CtrlAdjuster.MainEle.height(this.OriMainHeight + this.OriMainHeightOffset);
//CtrlAdjuster.MainEle.height( Math.max(CtrlAdjuster.MainEle.height(), this.OriMainHeight + this.OriMainHeightOffset) ); // demo
CtrlAdjuster.FooterEle.height(this.OriFooterHeight);
Object.keys(baseAdjuster.EleOriCssList).forEach(key => {
var css = baseAdjuster.EleOriCssList[key];
Object.keys(css).forEach(cssKey => {
$(`[TM=${key}]`).css(cssKey, css[cssKey]);
delete css[cssKey];
});
});
this.CtrlList.forEach(ctrl => {
ctrl.CtrlAdjuster.Reset2OriCss();
});
this.SetIcpWidth();
}
//这个要最后处理 否则会让页面撑高有滚动条导致宽度减少8px
SetIcpWidth() {
var icp = $("#all-icp-bottom");
if (icp) {
icp.find(".bottom-content").width(CtrlAdjuster.GetCurrentBrowserWidth());
}
}
SetPageWidth(width) {
$(".smvWrapper").css("min-width", `${width}px`);
$("#mainContentWrapper").css("min-width", `${width}px`);
var mainChildren = $("#mainContentWrapper").children();
if (mainChildren.length >= 3) {
mainChildren.eq(0).css("min-width", `${width}px`);
mainChildren.eq(2).css("min-width", `${width}px`);
}
CtrlAdjuster.HeaderEle.width(width);
CtrlAdjuster.MainEle.width(width);
CtrlAdjuster.FooterEle.width(width);
}
SetPageHeight() {
function GetBottom(ctrl) {
if (ctrl.AdjustControlInfo.IsHide) {
return 0;
}
var bottom = ctrl.AdjustControlInfo.TopWithOffset + ctrl.AdjustControlInfo.Height;
return isNaN(bottom) ? 0 : bottom;
}
//var xx = this.CtrlList.filter(x => x.CtrlLocation === "main" && !x.SkipHeightCalc && x.AdjustControlInfo.TopWithOffset + x.AdjustControlInfo.Height === 2275)
var headerAreaBottom = Math.max.apply(Math, this.CtrlList.filter(x => x.CtrlLocation === "header" && !x.SkipHeightCalc).map(GetBottom)) || 0;
var mainAreaBottom = Math.max.apply(Math, this.CtrlList.filter(x => x.CtrlLocation === "main" && !x.SkipHeightCalc).map(GetBottom)) || 0;
var footerAreaBottom = Math.max.apply(Math, this.CtrlList.filter(x => x.CtrlLocation === "footer" && !x.SkipHeightCalc).map(GetBottom)) || 0;
//没有控件时会为-Infinity
headerAreaBottom = Math.abs(headerAreaBottom) === Infinity ? CtrlAdjuster.HeaderEle.height() : headerAreaBottom;
mainAreaBottom = Math.abs(mainAreaBottom) === Infinity ? CtrlAdjuster.MainEle.height() : mainAreaBottom;
footerAreaBottom = Math.abs(footerAreaBottom) === Infinity ? CtrlAdjuster.FooterEle.height() : footerAreaBottom;
var oriMaxBottom = Math.max.apply(Math, this.CtrlList.filter(x => x.CtrlLocation === "main" && !x.SkipHeightCalc).map(i => i.Bottom));
//原来的内页与底部的距离
var bottomPadding = this.OriMainHeight - oriMaxBottom;
var mainAreaHeight = mainAreaBottom + (bottomPadding > 0 ? bottomPadding : 0);
CtrlAdjuster.HeaderEle.height(headerAreaBottom <= AdjustConfig.AutoNavHeight ? AdjustConfig.AutoNavHeight : headerAreaBottom);
CtrlAdjuster.MainEle.height(mainAreaHeight);
CtrlAdjuster.FooterEle.height(footerAreaBottom);
this.SetIcpWidth();
}
GetHeightOfTab(tabId) {
var tab = CtrlAdjuster.StaticCtrlList.find(i => i.CtrlId === tabId);
var areaId = tab.ControlView.find("li.w-label-tips-item.current").attr("data-area");
var ctrls = CtrlAdjuster.StaticCtrlList.filter(x => x.ParentId === tabId && !x.SkipHeightCalc && x.AreaId === areaId);
var maxBottom = Math.max.apply(Math, ctrls.map(ctrl => {
return ctrl.AdjustControlInfo.TopWithOffset + ctrl.AdjustControlInfo.Height;
}));
var minTop = Math.min.apply(Math, ctrls.map(x => x.AdjustControlInfo.TopWithOffset));
minTop = minTop > 0 ? minTop : 0;
var height = maxBottom + minTop;
return height + tab.CtrlAdjuster.TabTitleHeight
}
GetHeightOfTabV2(tabId) {
var tab = CtrlAdjuster.StaticCtrlList.find(i => i.CtrlId === tabId);
var areaId = tab.ControlView.find("li.w-label-tips-item.current").attr("data-area");
var ctrls = CtrlAdjuster.StaticCtrlList.filter(x => x.ParentId === tabId && x.AreaId === areaId);
var maxBottom = Math.max.apply(Math, ctrls.map(ctrl => {
return ctrl.AdjustControlInfo.TopWithOffset + ctrl.AdjustControlInfo.Height;
}));
var minTop = Math.min.apply(Math, ctrls.map(x => x.AdjustControlInfo.TopWithOffset));
minTop = minTop > 0 ? minTop : 0;
var height = maxBottom + minTop;
return height + tab.CtrlAdjuster.TabTitleHeight
}
GetHeightOfMultiContainer(multiContainerId) {
var ctrls = CtrlAdjuster.StaticCtrlList.filter(x => x.ParentId === multiContainerId && !x.SkipHeightCalc);
var dict = {};
ctrls.forEach(ctrl => {
if (dict[ctrl.AreaId]) {
dict[ctrl.AreaId].push(ctrl);
}
else {
dict[ctrl.AreaId] = [ctrl];
}
});
var offset = 0;
Object.keys(dict).forEach(key => {
var item = dict[key];
var heightOffset = Math.max.apply(Math, item.map(x => x.AdjustControlInfo.Bottom)) - Math.max.apply(Math, item.map(x => x.Bottom));
if (offset < heightOffset) {
offset = heightOffset;
}
})
return offset;
}
//todo
SwitchPageBackup() {
var currentBrowserWidth = CtrlAdjuster.GetCurrentBrowserWidth();
if (currentBrowserWidth >= CtrlAdjuster.OriPageWidth) {
if (this.PageBackUp.HasBeenModified) {
this.PageBackUp.ReplacePageToClonedBody();
this.PageBackUp.HasBeenModified = false;
}
return true;
} else {
if (!this.PageBackUp.HasBeenModified) {
this.PageBackUp.ReplacePageToClonedBody();
this.PageBackUp.HasBeenModified = true;
}
return false;
}
}
LaunchAdjuster(opt) {
var isFirstTime = opt.IsFirstTime;
var self = this;
function Engage() {
var currentBrowserWidth = CtrlAdjuster.GetCurrentBrowserWidth();
if (isFirstTime && currentBrowserWidth >= CtrlAdjuster.OriPageWidth) {
return;
}
self.ResetLayout();
if (currentBrowserWidth >= CtrlAdjuster.OriPageWidth) {
self.ToggleHeader();
self.ResetPage2OriCss();
return;
}
self.SetPageWidth(currentBrowserWidth);
baseAdjuster.ShowHiddenCtrls((scope) => {
var levelList = scope.CtrlTable.map(i => i.Level).filter((item, i, ar) => ar.indexOf(item) === i).sort();
levelList.forEach(level => {
//从父级向子级计算
var rows = scope.CtrlTable.filter(i => i.Level == level).sort((a, b) => { return a.Top - b.Top; });
rows.forEach(row => {
row.PreLoadRowAdjustControlInfo = scope.PreLoadRowAdjustControlInfo(row);
row.LayoutTable = scope.GetLayoutTableInfo(row);
row.Cells.forEach(ctrl => { ctrl.AdjustControlInfo.InitLineNum(); });
});
rows.forEach(row => {
row.Cells.forEach(ctrl => {
try {
ctrl.CtrlAdjuster.AdjustLayout(scope);
}
catch (ex) {
console.error(`浏览器宽度:${currentBrowserWidth}px`, ctrl, ex);
}
})
});
})
//调整多容器控件的高度
function AdjustMultiContainerHeight() {
var containerList = scope.CtrlList.filter(i => i.IsMultiContainer).sort((a, b) => {
var aLevel = a.GetLevel(scope.CtrlList);
var bLevel = b.GetLevel(scope.CtrlList);
if (aLevel === bLevel) {
return a.Top - b.Top;
}
return aLevel > bLevel ? -1 : 1;
});
containerList.forEach(container => {
switch (container.CtrlName) {
case "tab": {
var tabHeight = scope.GetHeightOfTab(container.CtrlId);
if (container.StyleName) {
tabHeight = scope.GetHeightOfTabV2(container.CtrlId);
}
if (!isNaN(tabHeight)) {
container.AdjustControlInfo.Height = tabHeight
}
break;
}
case "slideset":
case "fullpageSlide":
{
container.AdjustControlInfo.Height += scope.GetHeightOfMultiContainer(container.CtrlId);
break;
}
case "area": {
if (container.StyleName === "Style3") {
container.AdjustControlInfo.Height += scope.GetHeightOfMultiContainer(container.CtrlId);
}
break;
}
default: {
break;
}
}
});
}
AdjustMultiContainerHeight();
//让全部行一样高
levelList.forEach(level => {
var rows = scope.CtrlTable.filter(i => i.Level == level).sort((a, b) => { return a.Top - b.Top; });
rows.forEach(row => {
var lines = row.Cells.filter(i => i.IsContainer).map(x => x.AdjustControlInfo.LineNum).filter((item, i, ar) => ar.indexOf(item) === i);
lines.forEach(lineNum => {
var line = row.Cells.filter(i => i.AdjustControlInfo.LineNum == lineNum && i.IsContainer);
if (line.length > 1) {
var maxHeight = Math.max.apply(Math, line.map(function (o) { return o.AdjustControlInfo.Height; }));
//直接更改_height 避免增加父级高度,加_top
line.filter(i => i.AdjustControlInfo.Height !== maxHeight).forEach(x => {
var offset = maxHeight - x.AdjustControlInfo.Height;
x.AdjustControlInfo.AddNextLineTopOffset(offset);
x.AdjustControlInfo._height = maxHeight
});
}
})
})
})
var hideCtrlsFunc = scope.ToggleHeader();
var resizeCallBack = [];
levelList.sort((a, b) => { return b - a; }).forEach(level => {
var rows = scope.CtrlTable.filter(i => i.Level == level).sort((a, b) => { return a.Top - b.Top; });
rows.forEach(row => {
row.Cells.forEach(ctrl => {
try {
var callBack = ctrl.CtrlAdjuster.SetCtrlCss();
if (callBack) {
resizeCallBack.push(callBack);
}
}
catch (ex) {
console.error(ctrl, ex);
}
})
});
})
if (hideCtrlsFunc) {
hideCtrlsFunc();
}
resizeCallBack.forEach(callBack => { callBack(); });
}, self);
self.SetPageHeight();
}
Engage();
self.SpecHandle(isFirstTime);
CtrlAdjuster.OnAdjustFinished(opt);
}
static PrevAnimation() {
// // prev 也会触发动画初始化
//$("[smanim]").each((a, b) => {
// $(b).smanimate("prev")
//})
}
static StopAnimation() {
//$("[smanim]").each((a, b) => {
// // stop 也会触发动画初始化
// $(b).smanimate("stop")
//})
}
static OnAdjustFinished(opt) {
if (opt.FireFrom === 'init') {
// 初始化init之后再初始化动画
//$('.animated').smanimate('removeDoneAtt');
//safari浏览器执行动画页面宽度会出现问题,添加setTimeout
//var isSafari = (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));
//if (isSafari) {
// setTimeout(function () {
// // 某些情况下动画被其他代码触发了,无法再次播放了 replay 也不行 可能是smanimate的实现方案...
// // 移除完成的属性 [sm - finished] 可以再次播放
// $('.animated').removeAttr('sm-finished').smanimate();
// },1000)
//} else {
// // 某些情况下动画被其他代码触发了,无法再次播放了 replay 也不行 可能是smanimate的实现方案...
// // 移除完成的属性 [sm - finished] 可以再次播放
// $('.animated').removeAttr('sm-finished').smanimate();
//}
$('.animated').removeAttr('sm-finished').smanimate();
// 轮播图除了第一页,控制其他页第二次再次播放时处于停止状态
$('[ctype="slideset"]').each(function () {
$(this).find('.content-box:gt(0) .animated').smanimate('stop');
})
}
}
SpecHandle(isFirstTime) {
//取一下宽度才能去掉让从右到左动画效果的空白
function fixGap() {
var delayTime = 0;
$("[smanim]").each((a, b) => {
var json = JSON.parse($(b).attr("smanim"));
var delay = (json.duration + json.delay) * 1000;
delayTime = delay > delayTime ? delay : delayTime;
});
setTimeout(() => {
$("[ctype]").each((a, b) => {
$(b).width();
})
}, delayTime)
}
if (isFirstTime) {
CtrlAdjuster.PrevAnimation();
fixGap();
}
}
GetLastline(row) {
return row.filter(x => x.AdjustControlInfo.LineNum == Math.max.apply(Math, row.map(function (o) { return o.AdjustControlInfo.LineNum; }))).map(i => i.AdjustControlInfo);
}
GetZoomValue(ctrl) {
var minZoom = ctrl.AdjustControlInfo.ParentWidthSubPadding / ctrl.ParentWidth;
var zoomVal = minZoom;
if (minZoom < ctrl.CtrlAdjuster.MinZoom) {
minZoom = ctrl.CtrlAdjuster.MinZoom;
}
return { ZoomVal: zoomVal, MinZoom: AdjustHelper.ToFixed(minZoom, 3) };
}
PreLoadRowAdjustControlInfo(row) {
var preloadRow = new PreloadRow(row);
var firstCell = row.Cells[0];
var parentWidthSubPadding = firstCell.AdjustControlInfo.ParentWidthSubPadding;
var oriParentWidth = row.OriWidth;
var zoomVal = parentWidthSubPadding / oriParentWidth;
//缩放比例大于1则直接缩放
if (zoomVal > 1) {
row.Cells.forEach(cell => {
preloadRow.HandleItem(cell, (item) => {
item.ZoomLeft = item.Cell.Left * zoomVal;
item.ZoomWidth = item.Cell.DisplayWidth * zoomVal;
});
});
}
else {
//最小缩放间隙总和
var totalMinGap = 0;
//总共需要缩放的间隙
var totalNeedZoomGap = 0;
var cellsOriTotalWidth = 0;
row.Cells.forEach(cell => {
//记录大于0的左侧间隙
//当原始间隙小于10px则用原始间隙,当大于10px则取10px;
if (cell.LeftGap < AdjustConfig.MinCtrlXPadding) {
var gap = cell.LeftGap > 0 ? cell.LeftGap : 0;;
totalMinGap += gap
}
else {
totalMinGap += AdjustConfig.MinCtrlXPadding;
totalNeedZoomGap += cell.LeftGap;
}
cellsOriTotalWidth += cell.DisplayWidth;
});
//0:控件之间还有可缩放的间隙,不缩放控件宽度
//1:控件宽度不能继续缩小了,缩放控件
var zoomMode = parentWidthSubPadding - totalMinGap >= cellsOriTotalWidth ? 0 : 1;
//当zoomModel等于1时才需要用的上zoomVal
zoomVal = (parentWidthSubPadding - totalMinGap) / cellsOriTotalWidth;
//该行需要减去的差值
var rowWidthSubVal = oriParentWidth - parentWidthSubPadding - (oriParentWidth - row.LastCell.DisplayRight);
row.Cells.forEach(cell => {
var minZoom = zoomVal <= cell.CtrlAdjuster.MinZoom ? cell.CtrlAdjuster.MinZoom : zoomVal;
var zoomedLeftGap;
//不可与下面混写,因为为负数时越乘越小
if (cell.LeftGap < 0) {
zoomedLeftGap = cell.LeftGap;
}
else {
if (cell.LeftGap < AdjustConfig.MinCtrlXPadding) {
zoomedLeftGap = cell.LeftGap;
}
else {
//除去最右侧间隙后>0才触发
if (rowWidthSubVal > 0) {
var percent = cell.LeftGap / totalNeedZoomGap;
zoomedLeftGap = (totalNeedZoomGap === 0 ? 0 : (cell.LeftGap - (percent * rowWidthSubVal)));
}
else {
zoomedLeftGap = cell.LeftGap;
}
}
}
var zoomWidth = zoomMode === 0 ? cell.DisplayWidth : cell.DisplayWidth * minZoom;
preloadRow.HandleItem(cell, (item) => {
item.ZoomedLeftGap = zoomedLeftGap;
item.ZoomWidth = zoomWidth;
item.ZoomMode = zoomMode;
});
});
// preloadRow.AdjustSubWidthOffset(row.RowId);
}
return preloadRow.Items;
}
static GetOverflowStartIndex(row) {
var cellsLayout = row.PreLoadRowAdjustControlInfo;
var firstCell = cellsLayout[0];
for (var i = 0; i < cellsLayout.length; i++) {
var cell = cellsLayout[i];
if (cell.ZoomRight > firstCell.Cell.AdjustControlInfo.ParentWidthSubPadding) {
return i;
}
}
return null;
}
GetLayoutTableInfo(row) {
var changeRowStartIndex = CtrlAdjuster.GetOverflowStartIndex(row);
if (changeRowStartIndex === null) {
return { RowCount: 1, ColumnCount: row.Cells.length };
}
else {
if (changeRowStartIndex === 0 || changeRowStartIndex === 1) {
return { RowCount: row.Cells.length, ColumnCount: 1 };
}
return { RowCount: Math.ceil(row.Cells.length / changeRowStartIndex), ColumnCount: changeRowStartIndex };
}
}
GetNewTableRowLength(overflowCtrlLength, totalColumnCount, firstRowColumnLength, counter) {
counter = counter || 1;
if (overflowCtrlLength <= 0) {
return 1;
}
else if (overflowCtrlLength >= totalColumnCount) {
return totalColumnCount;
}
else {
firstRowColumnLength = firstRowColumnLength || (totalColumnCount - overflowCtrlLength);
if (overflowCtrlLength > firstRowColumnLength) {
return this.GetNewTableRowLength(overflowCtrlLength - firstRowColumnLength, totalColumnCount, firstRowColumnLength, ++counter);
}
else {
return ++counter;
}
}
}
GetHeaderByIndex(ctrlIndex, row, adjustedColumnCount) {
var firstRowHeaderIndex = (ctrlIndex) % adjustedColumnCount;
return row[firstRowHeaderIndex];
}
GetCtrlIndexOfRow(ctrlId, row) {
var ctrlIndex = row.indexOf(row.find(i => i.CtrlId == ctrlId));
return ctrlIndex;
}
static get IsMobile() {
let check = false;
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
return check;
}
static get IsWeChat() {
return (/(micromessenger)/i).test(navigator.userAgent);
}
GetFirstRow(location) {
var rows = CtrlAdjuster.HeaderEle.length !== 0 ? this.CtrlTable.filter(i => i.Level === 0 && i.CtrlLocation === location) : this.CtrlTable.filter(i => i.Level === 0);
return rows.sort((a, b) => {
return a.Top - b.Top;
}).find(i => i);
}
ResetNavHeader() {
var self = this;
var headerRow = this.GetFirstRow("header");
var headerEle = CtrlAdjuster.HeaderEle;
if (!headerRow || headerEle.length === 0) {
return;
}
var allCtrl = headerRow.GetAllCtrls(self.CtrlList);
var oriNavCtrlIdList = allCtrl.map(i => i.CtrlId);
headerEle.css({ "z-index": "auto" });
oriNavCtrlIdList.forEach(ctrlId => {
var ctrl = self.CtrlList.find(i => i.CtrlId === ctrlId);
ctrl.CtrlAdjuster.ResetTag2OriCss();
ctrl.CtrlAdjuster.Reset2OriCss();
var ctrlHolder = $(`.ctrlHolder_${ctrlId}`);
if (ctrlHolder.length) {
AdjustHelper.ReplaceEle(ctrlHolder, $(`#smv_${ctrlId}`));
}
else {
//不可用.show(),否则会设置为block 会让banner Style2固定屏幕的sessionStorage.getItem('initCss')) 受影响
$(`#smv_${ctrlId}`).css("display", "");
}
});
$("[auto-ctrl-index]").attr("auto-ctrl-index", "");
headerRow.TopOffsetOfRow = 0;
$(".headerNavBox").remove();
}
ToggleHeader() {
var self = this;
var headerRow = this.GetFirstRow("header");
var headerEle = CtrlAdjuster.HeaderEle;
if (!headerRow || headerEle.length === 0) {
return;
}
var allCtrl = headerRow.GetAllCtrls(self.CtrlList);
var skipCtrlList = ['multinav'];
var skipToggle = false;
allCtrl.map(i => i.CtrlName).forEach((ctrlName) => {
if (skipCtrlList.indexOf(ctrlName) !== -1) {
skipToggle = true;
}
});
if (skipToggle) {
return;
}
var oriNavCtrlIdList = allCtrl.map(i => i.CtrlId);
var changeRow = false;
if (headerRow) {
changeRow = (headerRow.Cells.length === 1 && headerRow.NewHeight > headerRow.Height) || headerRow.Cells.find(i => i.AdjustControlInfo.LineNum > 0) !== undefined;
}
var isHeaderFixed = headerRow.Cells.length === 1 && ((headerRow.Cells[0].StyleName === "Style2" && headerRow.Cells[0].CtrlName === "banner") || (headerRow.Cells[0].IsContainer && headerRow.Cells[0].ControlView && headerRow.Cells[0].ControlView.css("position") === "fixed"));
if ((changeRow || (CtrlAdjuster.GetCurrentBrowserWidth() < AdjustConfig.SmallScreenWidth || CtrlAdjuster.IsMobile))
&& oriNavCtrlIdList.length > 0
&& headerRow.Bottom <= AdjustConfig.DetectHeaderRowMaxHeight) {
if (headerRow.NextRow) {
headerRow.NextRow.TopOffsetOfRow = -(headerRow.NextRow.Top - AdjustConfig.AutoNavHeight);
}
function FixMainPageHeader() {
var mainPageHeader = self.GetFirstRow("main");
//为负数或者有小的偏差则自动将top归零
if (mainPageHeader && (mainPageHeader.Top < 0 || mainPageHeader.Top <= AdjustConfig.IntersectOffset)) {
mainPageHeader.TopOffsetOfRow = -mainPageHeader.Top;
}
}
FixMainPageHeader();
var templateStr = ""
// 获取背景色 页头 -> 页脚 -> 默认
function getBackgroundColor() {
var backgroundColor = AdjustHelper.GetBackGroundColor(CtrlAdjuster.HeaderEle.parent());
if (!(AdjustHelper.HasSetBgColor(backgroundColor))) {
backgroundColor = AdjustHelper.GetBackGroundColor(CtrlAdjuster.FooterEle.parent());
}
return backgroundColor || 'transparent';
}
var backgroundColor = getBackgroundColor();
var foregroundColor = "rgb(0, 0, 0)";
var logoImg = {
Src: null,
IndexFlag: null,
CtrlId: null,
Ctype: null,
OnLoad: null
};
var indexFlag = 0;
var smallNav;
function LoadImage() {
var imgCtrls = allCtrl.filter(i => i.CtrlName === "logoimage");
if (imgCtrls.length === 0) {
imgCtrls = allCtrl.filter(i => i.CtrlName === "image");
}
var firstImg = imgCtrls.sort((a, b) => {
return b.Size - a.Size;
}).find(i => i);
if (firstImg) {
logoImg.Src = firstImg.ControlView.find("img").attr("src");
logoImg.IndexFlag = ++indexFlag;
logoImg.CtrlId = firstImg.CtrlId;
logoImg.CtrlName = firstImg.CtrlName;
logoImg.OnLoad = function (img) {
if ($(img).attr("src") != firstImg.ControlView.find("img").attr("src")) {
firstImg.ControlView.find("img").attr("src", $(img).attr("src"));
console.log("响应式Logo 切换");
}
}
firstImg.ControlView.find("a").attr("auto-ctrl-index", indexFlag);
}
}
var hasSetBgColor = AdjustHelper.HasSetBgColor(backgroundColor);
function LoadLiItems() {
allCtrl.filter(i => i.CtrlId !== logoImg.CtrlId).forEach(ctrl => {
var isChildNodeOfTab = ctrl.IsChildNodeOfSpecCtrlName("tab");
var parentTabId = "";
if (isChildNodeOfTab) {
//以防有什么异常情况一直死循环
var maxParentLevel = 100;
var parent = ctrl.Parent;
var areaId = ctrl.AreaId;
while (parent.CtrlName !== "tab" && --maxParentLevel > 0) {
areaId = parent.AreaId;
parent = parent.Parent;
}
parentTabId = `parentTabId='${parent.CtrlId}_${areaId}'`;
}
switch (ctrl.CtrlName) {
case "nav":
{
var topUlClass = ctrl.StyleName === "Style12" ? ".w-nav-item" : ".w-nav-inner";
var firstClass = ctrl.StyleName === "Style12" ? "a" : ".w-nav-item-link";
var secondLiClass = ctrl.StyleName === "Style12" ? "li" : ".w-subnav-item";
var secondClass = ctrl.StyleName === "Style12" ? "a" : ".w-subnav-link";
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(ctrl.ControlView.find(firstClass), ctrl.ControlView.find(".w-nav"))
backgroundColor = hasSetBgColor ? backgroundColor : BackgroundColor;
foregroundColor = ForegroundColor;
ctrl.ControlView.find(topUlClass).each((a, b) => {
var item = $(b);
var navItemLink = item.find(firstClass).eq(0);
if (ctrl.StyleName === "Style12") {
backgroundColor = hasSetBgColor ? backgroundColor : AdjustHelper.GetBackGroundColor(navItemLink);
}
navItemLink.attr("auto-ctrl-index", ++indexFlag);
templateStr += `- ${navItemLink.html()}`;
var subNav = item.find(".w-subnav");
if (subNav.length > 0) {
templateStr += `
`;
subNav.find(secondLiClass).each((x, y) => {
var navItem = $(y).find(secondClass);
navItem.attr("auto-ctrl-index", ++indexFlag);
templateStr += `- ${navItem.html()}
`
});
templateStr += `
`;
}
templateStr += " ";
});
if (ctrl.ControlView) {
ctrl.ControlView.hide();
}
break;
}
case "navcontainer": {
if (logoImg.Src === null) {
var logoImgCtrl = ctrl.ControlView.find("img");
logoImg.Src = logoImgCtrl.attr("src");
logoImg.IndexFlag = ++indexFlag;
logoImgCtrl.attr("auto-ctrl-index", indexFlag);
logoImg.CtrlName = "navcontainer";
logoImg.OnLoad = function (img) {
if ($(img).attr("src") != logoImg.Src) {
logoImgCtrl.attr("src", $(img).attr("src"));
}
}
}
ctrl.ControlView.find(".nav-item").each((a, b) => {
var item = $(b);
var navText = item.find(".nav-text");
navText.attr("auto-ctrl-index", ++indexFlag);
templateStr += `- ${navText.html()}`;
var subNav = item.find(".nav-subnav");
if (subNav.length > 0) {
templateStr += `
`;
subNav.find(".subnav-item").each((x, y) => {
var navItem = $(y);
navItem.attr("auto-ctrl-index", ++indexFlag)
templateStr += `- ${navItem.html()}
`
});
templateStr += `
`;
}
templateStr += " ";
})
var { ForegroundColor, BackgroundColor } = baseAdjuster.GetNavColor(ctrl.ControlView.find(".nav-text"), ctrl.ControlView.find(".nav-container"))
backgroundColor = hasSetBgColor ? backgroundColor : BackgroundColor;
foregroundColor = ForegroundColor;
if (ctrl.ControlView) {
ctrl.ControlView.hide();
}
break;
}
case "tab": {
var itemList = ctrl.ControlView.find('.w-label-content-item')
ctrl.ControlView.find('.w-label-tips-item>.f-ellipsis').each((x, b) => {
var text = $(b).html();
text = text ? text : " ";
var titleTagParent = $(b.parentElement);
var bgimg = titleTagParent.css("background-image")
var bgUrlMatch = bgimg.match(/url\(["']?([^"']*)["']?\)/);
var bgUrl = bgUrlMatch ? bgUrlMatch[1] : "";
var imgStr = bgUrl ? `
` : "";
var clickEvent = `onclick='location.href="${$(b).attr("href") ? $(b).attr("href") : "#"}"'`
templateStr += `- ${imgStr}${text}
`;
});
break;
}
default: {
if (isChildNodeOfTab) {
//是虚拟容器直接忽略
if (ctrl.IsVirtualCtrl || ctrl.IsContainer) {
break
}
else {
//并且有父级,父级是虚拟容器,则未被加入到导航中
if (ctrl.Parent.IsVirtualCtrl) {
templateStr += ``;
break;
}
else {
templateStr += ``;
break;
}
}
}
else {
if (!ctrl.IsContainer) {
templateStr += ``
}
else {
if (ctrl.ControlView) {
ctrl.ControlView.hide();
}
}
}
break;
}
}
});
templateStr += "
";
}
function MoveItem2TabLi() {
headerEle.find("[parentTabId]").each((a, b) => {
var parentTabId = $(b).attr("parentTabId");
headerEle.find(`[tabId=${parentTabId}]`).append(b);
});
$("[tabId]").each((a, b) => {
if (!$(b).html()) {
$(b).remove();
}
});
}
function LoadNav2Body() {
headerEle.append(`${templateStr}
`);
MoveItem2TabLi();
headerEle.prepend(``);
$(".hideNav").slicknav({
label: "",
prependTo: ".headerNavBox",
duration: 0,//不可用动画,否则下方 item[0].parentElement.click() 触发两次点击事件时会很奇怪
openedSymbol: "",
closedSymbol: ""
});
headerEle.css("z-index", 999999);
smallNav = $(".headerNavBox").find(".slicknav_menu");
var maxWidth = CtrlAdjuster.GetCurrentBrowserWidth() - 40 * 2;
smallNav.find("[nav-holder]").each((a, b) => {
var ctrlId = $(b).attr("nav-holder");
var ctrlInfo = self.CtrlList.find(i => i.CtrlId === ctrlId);
var liHolder = $(document.createElement("div"));
liHolder.addClass(`liHolder_${ctrlId}`);
$(b).append(liHolder);
var controlViewHolder = $(document.createElement("div"));
controlViewHolder.addClass(`ctrlHolder_${ctrlId}`);
$(controlViewHolder).height(ctrlInfo.AdjustControlInfo.Height);
controlViewHolder.insertBefore(ctrlInfo.ControlView)
AdjustHelper.ReplaceEle($(`.liHolder_${ctrlId}`), ctrlInfo.ControlView);
//忽略父级最大宽度
ctrlInfo.AdjustControlInfo.ForceGetWidth = true;
var isImage = ctrlInfo.CtrlName === "image" || ctrlInfo.CtrlName === "logoimage" || ctrlInfo.CtrlName === "qrcode";
ctrlInfo.AdjustControlInfo.Left = ctrlInfo.AdjustControlInfo.Top = 0;
ctrlInfo.CtrlAdjuster.SetWidthAndHeight(isImage ? (ctrlInfo.Width < maxWidth ? ctrlInfo.Width : maxWidth) : maxWidth);
ctrlInfo.CtrlAdjuster.SetEleCss(ctrlInfo.ControlView, { position: "inherit" });
});
if (logoImg.Src !== null) {
//未取得logo top值时第一次取一次,第二次直接拿,否则logo每次取的话会上下跳动 很难看
CtrlAdjuster.LogoOnLoad = function (img) {
logoImg.OnLoad(img)
CtrlAdjuster.SetLogoImgLayout();
console.log("响应式Logo加载");
}
smallNav.prepend(`
`);
//if (CtrlAdjuster.LogoImgTop === null) {
// smallNav.prepend(`
`);
//}
//else {
// smallNav.prepend(`
`);
//}
}
$(".hideNav").remove();
}
function SetStyle() {
if (!AdjustHelper.HasSetBgColor(backgroundColor)) {
smallNav.css("background-color", "#4c4c4c");
smallNav.find(".auto-nav-li").css("color", "#ffffff")
smallNav.find(".slicknav_row").css("color", "#ffffff")
smallNav.find(".slicknav_item").css("color", "#ffffff")
}
else {
smallNav.css("background-color", backgroundColor);
smallNav.find(".auto-nav-li").css("color", foregroundColor)
smallNav.find(".slicknav_row").css("color", foregroundColor)
smallNav.find(".slicknav_item").css("color", foregroundColor)
}
}
function MapEvents() {
$("[auto-nav-index]").each((a, b) => {
var item = $(b);
var indexFlag = item.attr("auto-nav-index");
item.click((e) => {
var oriTarget = $(`[auto-ctrl-index=${indexFlag}]`)[0];
oriTarget.click();
var href = oriTarget.href || "";
var targetHrefHash = href.indexOf("#") !== -1;
//当是锚点时,自动收起汉堡导航
if (href && href.split('#')[0] === window.location.href.split('#')[0] && targetHrefHash) {
smallNav.find('[tabindex="0"].slicknav_btn.slicknav_open').click()
}
//避免又点击又展开菜单,
//不可使用取消向上冒泡事件,手机上touch直接不触发了
//直接再点击下收起导航
item[0].parentElement.click()
})
});
}
function HideCtrls() {
oriNavCtrlIdList.forEach(ctrlId => {
var ctrl = self.CtrlList.find(i => i.CtrlId === ctrlId);
ctrl.AdjustControlInfo.IsHide = true;
if (!ctrl.IsVirtualCtrl) {
//tab的子元素把里面的容器变为static
if (ctrl.IsChildNodeOfSpecCtrlName("tab")) {
ctrl.CtrlAdjuster.SetEleCss(ctrl.ControlView.find(".w-container"), { position: "static" });
}
//否则向上隐藏
else {
ctrl.CtrlAdjuster.SetEleCss(ctrl.ControlView, { top: "-999px" });
}
}
})
}
LoadImage();
LoadLiItems();
LoadNav2Body();
SetStyle();
MapEvents();
window.SetImgHeight = function () {
console.log($(".auto-nav-img").height())
}
return HideCtrls;
}
}
static SetLogoImgLayout() {
if (CtrlAdjuster.LogoImgTop) return;
var logoImg = $(".auto-nav-img");
var top = (AdjustConfig.AutoNavHeight - logoImg.height()) / 2;
logoImg.css("top", `${top}px`);
CtrlAdjuster.LogoImgTop = top;
}
static LogoImgTop = null;
}
class PageBackup {
OriBody = null;
MainContentFlag = "#mainContentWrapper";
constructor() {
this.OriBody = this.CurrentBody;
}
get OriBodyClone() {
var node = $(this.OriBody[0].cloneNode(true));
//node.find("[ctype=slideset]").find("script").remove()
return node;
//return $(this.OriBody.clone(true,true));
}
get CurrentBody() {
return $(this.MainContentFlag);
}
ReplacePageToClonedBody() {
AdjustHelper.ReplaceEle(this.CurrentBody, this.OriBodyClone);
}
HasBeenModified = false;
//get HasBeenModified() {
// return !!$(`#${AdjustConfig.ModifiedFlag}`).val();
//}
}
class LayoutConverter {
Adjuster;
Tester;
TimerIndex = -1;
LastLaunchPageWidth = null;
constructor(notCallResizeFunc) {
this.Init();
var self = this;
// 第一次给宽度赋值 修复 IOS Safari浏览器bug
self.LastLaunchPageWidth = CtrlAdjuster.GetCurrentBrowserWidth();
if (!notCallResizeFunc) {
window.addEventListener('resize', function (event) {
//不是窗口触发的则返回,否则有莫名其妙的异常,比如说视频控件
//页面宽度和上次一样则不触发Resize事件
if (event.target === window && self.LastLaunchPageWidth !== CtrlAdjuster.GetCurrentBrowserWidth()) {
clearTimeout(self.TimerIndex);
self.LastLaunchPageWidth = CtrlAdjuster.GetCurrentBrowserWidth();
self.TimerIndex = setTimeout(function () {
self.LaunchAdjuster({ FireFrom: "resize" });//fire from
}, AdjustConfig.AdjustDelay);
}
}, true);
}
self.LaunchAdjuster({ IsFirstTime: true, FireFrom: "init" });
LayoutConverter.DebugFunc();
}
static DebugFunc() {
$(".m-deviceSwitch").remove();
console.log("响应式已加载");
}
static CtrlStandardDetect() {
var result = {
IntersectionCtrlIdList: [],
MulitRowCtrlIdMap: {},
NotCenterCtrlInfoList: [],
OverflowCtrlIdList: [],
ShowTips() {
return this.IntersectionCtrlIdList.length != 0
|| this.OverflowCtrlIdList.length != 0
|| Object.keys(this.MulitRowCtrlIdMap).length != 0
|| this.NotCenterCtrlInfoList.length != 0;
}
}
try {
var headerCtrlList = CtrlAdjuster.HeaderEle.find("[ctype]:not(.smart-deleted)").toArray();
var mainCtrlList = CtrlAdjuster.MainEle.find("[ctype]:not(.smart-deleted)").toArray();
var footerCtrlList = CtrlAdjuster.FooterEle.find("[ctype]:not(.smart-deleted)").toArray();
headerCtrlList.forEach(i => $(i).attr("ctrl-location", "header"));
mainCtrlList.forEach(i => $(i).attr("ctrl-location", "main"));
footerCtrlList.forEach(i => $(i).attr("ctrl-location", "footer"));
var ctrlList = headerCtrlList.concat(mainCtrlList).concat(footerCtrlList);
var ctrls = ctrlList.map(domEle => {
var ele = $(domEle);
var left = ele.css("left").replace("px", "") * 1;
var top = ele.css("top").replace("px", "") * 1
if (isNaN(left)) {
left = (CtrlAdjuster.GetOriPageWidth() - ele.width()) / 2
}
if (isNaN(top)) {
top = 0;
}
var ctrlInfo = new ControlInfo(ele.width(), ele.height(), left, top);
ctrlInfo.AreaId = ele.attr("areaid") || null;
ctrlInfo.ParentId = ele.attr("pvid") || null;
ctrlInfo.CtrlName = ele.attr("ctype");
ctrlInfo.CtrlLocation = ele.attr("ctrl-location");
ctrlInfo.CtrlId = ele.attr("id").replace("smv_", "");
ctrlInfo.IsContainer = ele.attr("iscontainer") === "True";
ctrlInfo.ControlView = ele;
ctrlInfo.ElementId = ele.attr("id");
ctrlInfo.StyleName = ele.attr("cstyle");
return ctrlInfo;
});
ctrls = LayoutConverter.FilterInvisCtrl(ctrls).filter(i => i.CtrlName !== "dialog" && !i.SkipSpecCtrl);
var allCtrls = ctrls;
ctrls = ctrls.filter(i => !i.IsFullRowCtrl);
ctrls.sort((a, b) => {
var aPos = a.ControlView[0].getBoundingClientRect();
var bPos = b.ControlView[0].getBoundingClientRect();
if (aPos.top === bPos.top) {
return aPos.left - bPos.left;
}
return aPos.top - bPos.top;
});
//检测重叠
ctrls.filter(i => (AdjustConfig.FullRowCtrlNames.indexOf(i.CtrlName) === -1)).forEach(ctrlA => {
ctrls.forEach(ctrlB => {
if (CtrlAdjuster.IsInSameArea(ctrlA, ctrlB)
&& ctrlA !== ctrlB
//已经存在的则跳过
&& (!result.IntersectionCtrlIdList.some(i => i.some(x => x.CtrlId === ctrlA.CtrlId) && i.some(x => x.CtrlId === ctrlB.CtrlId)))) {
if (((ctrlA.Top < ctrlB.Bottom) && (ctrlB.Top < ctrlA.Bottom))
&& ((ctrlA.Left < ctrlB.Right) && (ctrlB.Left < ctrlA.Right))) {
result.IntersectionCtrlIdList.push([
{ CtrlId: ctrlA.CtrlId, ElementId: ctrlA.ElementId, CtrlName: ctrlA.CtrlName },
{ CtrlId: ctrlB.CtrlId, ElementId: ctrlB.ElementId, CtrlName: ctrlB.CtrlName },
])
}
}
})
});
//检测是否超出父控件的边界&检测是否居中
ctrls.forEach(ctrl => {
var parent = allCtrls.find(i => i.CtrlId === ctrl.ParentId);
var parentWidth = parent ? parent.Width : ctrl.ControlView.parents().find(".smvContainer").width();
if (parentWidth < ctrl.Right || ctrl.Left < 0) {
if (AdjustConfig.FullRowCtrlNames.indexOf(ctrl.CtrlName) === -1) {
result.OverflowCtrlIdList.push({
ParentCtrlName: parent ? parent.CtrlName : "",
ParentId: ctrl.ParentId,
CtrlId: ctrl.CtrlId,
Offset: ctrl.Left < 0 ? ctrl.Left : ctrl.Right - parentWidth,
ElementId: ctrl.ElementId,
CtrlName: ctrl.CtrlName
});
}
}
var offset = Math.abs(ctrl.Left - (parentWidth - ctrl.Right));
//是>1而不是>0因为可能宽度是单数&&该行只有一个控件时
if (offset > 1
//标签控件3,4,5跳过检测
&& !(parent && parent.CtrlName === "tab" && (parent.StyleName === "Style3" || parent.StyleName === "Style4" || parent.StyleName === "Style5"))
&& ((offset <= parentWidth * AdjustConfig.MaxOffsetNotCenterPercent) || offset < 10)
&& ctrls.find(i => CtrlAdjuster.IsInSameArea(ctrl, i)
&& (ctrl.Top < i.Bottom) && (i.Top < ctrl.Bottom) && i.CtrlId !== ctrl.CtrlId) === undefined) {
result.NotCenterCtrlInfoList.push({
CtrlId: ctrl.CtrlId,
Offset: offset,
ElementId: ctrl.ElementId,
CtrlName: ctrl.CtrlName,
Left: ctrl.Left > (parentWidth - ctrl.Right) ? AdjustHelper.ToFixed(ctrl.Left - offset / 2) : AdjustHelper.ToFixed(ctrl.Left + offset / 2),
ShowBtn: ctrl.IsTemplateCtrl && CtrlAdjuster.MainEle.length > 0 ? false : true
});
}
});
//检测是否有控件和多个控件属于同一行
ctrls.forEach(ctrlA => {
var arr = [];
ctrls.forEach(ctrlB => {
if (CtrlAdjuster.IsInSameArea(ctrlA, ctrlB)
&& ctrlA !== ctrlB) {
if (((ctrlA.Top < ctrlB.Bottom) && (ctrlB.Top < ctrlA.Bottom)) && !(((ctrlA.Left < ctrlB.Right) && (ctrlB.Left < ctrlA.Right)))) {
arr.push(ctrlB);
}
}
});
if (arr.length > 1) {
arr.forEach(itemA => {
arr.forEach(itemB => {
if (itemA !== itemB) {
//不在同一行
if (!((itemA.Top < itemB.Bottom) && (itemB.Top < itemA.Bottom))) {
result.MulitRowCtrlIdMap[ctrlA.CtrlId] = result.MulitRowCtrlIdMap[ctrlA.CtrlId] || { CtrlName: ctrlA.CtrlName, CtrlInfoList: [] };
if (!result.MulitRowCtrlIdMap[ctrlA.CtrlId].CtrlInfoList.some(x => x.CtrlId === itemA.CtrlId)) {
result.MulitRowCtrlIdMap[ctrlA.CtrlId].CtrlInfoList.push({
CtrlId: itemA.CtrlId, ElementId: itemA.ElementId, CtrlName: itemA.CtrlName
});
}
}
}
});
});
}
});
return result;
}
catch (ex) {
console.log(ex);
return result;
}
}
InitCtrl(domEle) {
var ele = $(domEle);
var left = ele.css("left").replace("px", "") * 1;
var top = ele.css("top").replace("px", "") * 1;
var mainPageWidth = CtrlAdjuster.GetOriPageWidth();
if (isNaN(left)) {
left = (mainPageWidth - ele.width()) / 2
}
if (isNaN(top)) {
top = 0;
}
var width = ele.width();
var ctrlName = ele.attr("ctype");
var styleName = ele.attr("cstyle");
var ctrlLocation = ele.attr("ctrl-location");
//轮播图在页头的时候宽度固定死了是1000,此时需取主页面的宽度
if ((ctrlName === "slideset" || ctrlName === "fullpageSlide") && (styleName === "Style1" || styleName === "Style3")) {
if (ctrlLocation !== "main") {
width = mainPageWidth;
}
else {
if (ele.hasClass(AdjustConfig.FixedCtrlFlag)) {
ele.removeClass(AdjustConfig.FixedCtrlFlag);
width = ele.width();
ele.addClass(AdjustConfig.FixedCtrlFlag);
}
}
}
var ctrlInfo = new ControlInfo(width, ele.height(), left, top);
ctrlInfo.AreaId = ele.attr("areaid") || null;
ctrlInfo.ParentId = ele.attr("pvid") || null;
ctrlInfo.CtrlName = ctrlName;
ctrlInfo.CtrlLocation = ctrlLocation;
ctrlInfo.CtrlId = ele.attr("id").replace("smv_", "");
ctrlInfo.IsContainer = ele.attr("iscontainer") === "True";
ctrlInfo.ControlView = ele;
ctrlInfo.ElementId = ele.attr("id");
ctrlInfo.StyleName = styleName;
ctrlInfo.MatchAdjuster(ctrlInfo);
ctrlInfo.Height = ctrlInfo.DisplayHeight;
//width设置为显示的width的话居中文字会有问题
// ctrlInfo.Width = ctrlInfo.DisplayWidth;
return ctrlInfo;
}
Init() {
CtrlAdjuster.MainEle.find("[ctype=newsItemContentBind]").each((a, b) => {
$(b).find("[ctype]").each((x, y) => {
$(y).removeAttr("id");
$(y).removeAttr("ctype");
});
})
var allTags = $(document.body).find("*");
allTags.each((a, b) => {
$(b).attr("TM", a);
})
var headerCtrlList = CtrlAdjuster.HeaderEle.find("[ctype]").toArray();
var mainCtrlList = CtrlAdjuster.MainEle.find("[ctype]").toArray();
var footerCtrlList = CtrlAdjuster.FooterEle.find("[ctype]").toArray();
headerCtrlList.forEach(i => $(i).attr("ctrl-location", "header"));
mainCtrlList.forEach(i => $(i).attr("ctrl-location", "main"));
footerCtrlList.forEach(i => $(i).attr("ctrl-location", "footer"));
var ctrlList = headerCtrlList.concat(mainCtrlList).concat(footerCtrlList);
var self = this;
var ctrls = [];
baseAdjuster.ShowHiddenCtrls((scope) => {
ctrls = ctrlList.map(domEle => {
return self.InitCtrl(domEle);
});
ctrls = LayoutConverter.FilterInvisCtrl(ctrls);
LayoutConverter.DetectIsFullRowCtrl(ctrls, true);
scope.HandleVirtualContainer(ctrls);
scope.Adjuster = new CtrlAdjuster(ctrls);
}, self);
}
static FilterInvisCtrl(ctrls) {
var arr = ctrls.filter(i => i.IsSupportResponsive(ctrls));
return arr.concat(ctrls.filter(i => i.CtrlName == "formpanel"))
}
static DetectIsFullRowCtrl(ctrls, tooWideIsFullRow) {
ctrls.forEach(ctrl => {
if (AdjustConfig.FullRowCtrlNames.indexOf(ctrl.CtrlName) !== -1) {
ctrl.IsFullRowCtrl = true;
return;
}
if (tooWideIsFullRow && ctrl.Width >= (CtrlAdjuster.GetOriPageWidth() - AdjustConfig.MinDocumentXPadding * 2)) {
ctrl.IsFullRowCtrl = true;
return;
}
});
}
HandleVirtualContainer(ctrls) {
function NoiseFilter() {
var ctrlTable = CtrlAdjuster.InitRow(ctrls);
ctrlTable.forEach(row => {
var loadList = [];
row.Cells.forEach(ctrl => {
var sameColumnCtrls = row.Cells.filter(i =>
(i.Left + AdjustConfig.IntersectOffset) < ctrl.DisplayRight
&& (ctrl.Left + AdjustConfig.IntersectOffset) < i.DisplayRight
&& !i.IsFullRowCtrl
&& loadList.indexOf(ctrl.CtrlId) === -1
&& i.CtrlLocation == ctrl.CtrlLocation
&& i.ParentId == ctrl.ParentId
&& i.AreaId == ctrl.AreaId
);
//太大且与别的控件相交的控件 则视为背景图 单独作为一行
if (sameColumnCtrls.length > 1 && ctrl.CtrlName === "image" && (ctrl.Width >= 500 || ctrl.Height >= 500) && !ctrl.IsVirtualContainer) {
ctrl.MightBeBackground = true;
}
});
});
}
function HandleColumn2VirtualArea() {
var ctrlTable = CtrlAdjuster.InitRow(ctrls);
ctrlTable.forEach(row => {
var loadList = [];
row.Cells.forEach(ctrl => {
if (ctrl.HasHandleVirtualArea) {
return;
}
var rowCells = row.Cells;
var sameColumnCtrls = rowCells.filter(i => !i.MightBeBackground
&& !i.HasHandleVirtualArea
&& (i.Left + AdjustConfig.IntersectOffset) < ctrl.DisplayRight
&& (ctrl.Left + AdjustConfig.IntersectOffset) < i.DisplayRight
&& !i.IsFullRowCtrl
&& loadList.indexOf(ctrl.CtrlId) === -1
&& i.CtrlLocation == ctrl.CtrlLocation
&& i.ParentId == ctrl.ParentId
&& i.AreaId == ctrl.AreaId
);
if (sameColumnCtrls.length > 1) {
var firstCtrl = sameColumnCtrls[0];
var parentWidth = CtrlAdjuster.GetOriPageWidth();
if (firstCtrl.Parent != null) {
parentWidth = firstCtrl.ParentWidth;
}
var left = Math.min.apply(Math, sameColumnCtrls.map(x => x.Left));
var top = Math.min.apply(Math, sameColumnCtrls.map(x => x.Top));
var width = Math.max.apply(Math, sameColumnCtrls.map(x => x.DisplayRight)) - left;
var height = Math.max.apply(Math, sameColumnCtrls.map(x => x.DisplayBottom)) - top;
if (width > parentWidth) {
width = parentWidth;
}
var virtualArea = new ControlInfo(width, height, left, top);
virtualArea.AreaId = firstCtrl.AreaId || null;
virtualArea.ParentId = firstCtrl.ParentId;
virtualArea.CtrlLocation = firstCtrl.CtrlLocation;
virtualArea.CtrlName = "virtualArea";
virtualArea.CtrlId = `${firstCtrl.ParentId || "body"}_${Math.random()}`;
virtualArea.IsContainer = true;
virtualArea.ControlView = null;
virtualArea.IsVirtualContainer = true;
virtualArea.DisplayWidth = Math.max.apply(Math, sameColumnCtrls.map(x => x.Left + x.DisplayWidth)) - left;
virtualArea.DisplayHeight = Math.max.apply(Math, sameColumnCtrls.map(x => x.Top + x.DisplayHeight)) - top;;
virtualArea.MatchAdjuster(virtualArea);
ctrls.push(virtualArea);
sameColumnCtrls.forEach(cell => {
cell.ParentId = virtualArea.CtrlId;
cell.Left -= left;
cell.Top -= top;
cell.HandleVirtualArea = true;
loadList.push(cell.CtrlId);
});
}
});
});
}
function HandleMulticolumnVirtualItem() {
ctrls.filter(i => i.ParentId != null).forEach(ctrl => {
var parent = ctrls.find(i => i.CtrlId == ctrl.ParentId);
if (parent.CtrlName == "multicolumn") {
ctrl.ParentId = `${ctrl.ParentId}_${ctrl.AreaId}`;
}
})
ctrls.filter(i => i.CtrlName == "multicolumn").forEach(parentCtrlInfo => {
var liList = parentCtrlInfo.ControlView.find("ul").eq(0).children();
var left = 0;
liList.toArray().forEach((ele, index) => {
var jqEle = liList.eq(index);
var areaId = jqEle.attr("data-area");
var itemWidth = jqEle.attr("data-width");
var width = (parentCtrlInfo.Width * itemWidth) / 100;
var ctrlInfo = new ControlInfo(width, parentCtrlInfo.Height, left, 0);
ctrlInfo.AreaId = parentCtrlInfo.AreaId || null;
ctrlInfo.ParentId = parentCtrlInfo.CtrlId;
ctrlInfo.CtrlName = "multicolumnVirtualItem";
ctrlInfo.CtrlId = `${parentCtrlInfo.CtrlId}_${areaId}`;
ctrlInfo.IsContainer = true;
ctrlInfo.CtrlLocation = parentCtrlInfo.CtrlLocation;
ctrlInfo.ControlView = jqEle;
ctrlInfo.ParentControlAreaId = areaId;
ctrlInfo.StyleName = parentCtrlInfo.StyleName;
ctrlInfo.MatchAdjuster(ctrlInfo);
ctrls.push(ctrlInfo);
left += width;
});
});
}
function HandleSlidesetItem() {
ctrls.filter(i => (i.CtrlName == "slideset" || i.CtrlName == "fullpageSlide")).forEach(parentCtrlInfo => {
var children = ctrls.filter(i => i.ParentId === parentCtrlInfo.CtrlId);
children.forEach(ctrl => {
var virtualAreaId = `${parentCtrlInfo.CtrlId}_${ctrl.AreaId}`;;
ctrl.ParentId = virtualAreaId;
var ctrlInfo = ctrls.find(i => i.CtrlId === virtualAreaId);
if (!ctrlInfo) {
ctrlInfo = new ControlInfo(parentCtrlInfo.Width, parentCtrlInfo.Height, 0, 0);
ctrlInfo.AreaId = ctrl.AreaId || null;
ctrlInfo.ParentId = parentCtrlInfo.CtrlId;
ctrlInfo.CtrlName = "virtualArea";
ctrlInfo.CtrlId = virtualAreaId;
ctrlInfo.IsContainer = true;
ctrlInfo.CtrlLocation = parentCtrlInfo.CtrlLocation;
ctrlInfo.ParentControlAreaId = ctrl.AreaId;
ctrlInfo.IsVirtualContainer = true;
ctrlInfo.StyleName = parentCtrlInfo.StyleName;
ctrlInfo.MatchAdjuster(ctrlInfo);
ctrls.push(ctrlInfo);
}
});
});
}
//line暂时弃用
function HandleLine() {
ctrls.filter(i => i.CtrlName == "line").forEach(line => {
if (line.CtrlAdjuster.IsVerticalLine) {
line.SkipFormatRowOffset = true;
var ctrlFilter = ctrls.filter(i => !(i.MightBeBackground || i.IsFullRowCtrl)
&& i.CtrlLocation == line.CtrlLocation
&& ((i.ParentId == null && line.ParentId == null) || (i.ParentId == line.ParentId && i.AreaId == line.AreaId))
&& ((i.Top + AdjustConfig.IntersectOffset) < line.DisplayBottom)
&& (line.Top + AdjustConfig.IntersectOffset) < i.DisplayBottom
);
//AdjustHelper.Debugger(line, "con_34_51");
var leanOnCtrl = ctrlFilter.filter(i => i.Left < line.Left).sort((a, b) => { return b.DisplayRight - a.DisplayRight; }).find(i => i);
if (leanOnCtrl) {
line.CtrlAdjuster.IsOnCtrlLeft = false;
line.CtrlAdjuster.LeanOnCtrl = leanOnCtrl;
line.CtrlAdjuster.LeanOnPadding = leanOnCtrl.DisplayRight - line.Left;
}
else {
leanOnCtrl = ctrlFilter.filter(i => i.Left > line.DisplayRight).sort((a, b) => { return a.Left - b.Left; }).find(i => i);
if (leanOnCtrl) {
line.CtrlAdjuster.IsOnCtrlLeft = true;
line.CtrlAdjuster.LeanOnPadding = leanOnCtrl.Left - line.DisplayRight;
}
}
}
});
}
function HandleTabContent() {
ctrls.filter(i => i.CtrlName == "tab").forEach(parentCtrlInfo => {
switch (parentCtrlInfo.StyleName) {
case "Style3":
case "Style4":
case "Style5":
case "Style11":
{
var children = ctrls.filter(i => i.ParentId === parentCtrlInfo.CtrlId);
var width = parentCtrlInfo.ControlView.find(".smAreaC").eq(0).width();
parentCtrlInfo.WidthOffset = parentCtrlInfo.Width - width;
children.forEach(ctrl => {
ctrl.ParentWidth = width;
})
break;
};
}
});
}
function ConvertCtrl2VirtualContainer() {
var mightBeVirtualContainerCtrlNameList = ["button", "image", "text"]
ctrls.forEach(ctrl => {
var mightBeVirtualContainerCtrlList = ctrls.filter(i => mightBeVirtualContainerCtrlNameList.indexOf(i.CtrlName) !== -1
&& i.CtrlLocation == ctrl.CtrlLocation
&& i.ParentId === ctrl.ParentId
&& i.AreaId === ctrl.AreaId
&& i.CtrlId !== ctrl.CtrlId
).sort((a, b) => { return a.Size - b.Size; });
var parent = mightBeVirtualContainerCtrlList.find(i => i.Size > ctrl.Size
&& i.Top < ctrl.Top
&& i.Left < ctrl.Left
&& i.DisplayRight > ctrl.DisplayRight
&& i.DisplayBottom > ctrl.DisplayBottom
);
if (parent) {
ctrl.ParentId = parent.CtrlId;
ctrl.Top -= parent.Top;
ctrl.Left -= parent.Left;
parent.IsVirtualContainer = parent.IsContainer = true;
}
})
}
ConvertCtrl2VirtualContainer();
NoiseFilter();
//HandleTabItem();
HandleTabContent();
HandleColumn2VirtualArea();
HandleMulticolumnVirtualItem();
//勿删除
//HandleListItem();
HandleSlidesetItem();
//HandleLine();
}
InCalculation = false;
LaunchAdjuster(opt) {
opt = opt || { IsFirstTime: false };
this.InCalculation = true;
try {
var desc = `响应式计算[${opt.FireFrom}]`;
console.time(desc);
this.Adjuster.LaunchAdjuster(opt);
console.timeEnd(desc);
}
catch (ex) {
console.error('响应式计算出错', ex);
}
this.InCalculation = false;
}
GetCtrlInfoById(ctrlId) {
return this.Adjuster.CtrlList.find(i => i.ElementId == ctrlId);
}
GetCtrlInfoByCtrlId(ctrlId) {
return this.Adjuster.CtrlList.find(i => i.CtrlId == ctrlId);
}
GetCtrlInfoByIndex(index) {
return this.Adjuster.CtrlList.find(i => i.IndexFlag == index);
}
GetCtrlListByParentIndex(index) {
return this.Adjuster.CtrlList.filter(i => i.Parent && i.Parent.IndexFlag == index);
}
static CtrlJsVariableList = [];
static ResetSlider(ctrlId, newWidth, setStyleFunc, afterInitFunc) {
var jssorCache = LayoutConverter.CtrlJsVariableList.find(i => i.CtrlId === ctrlId);
if (jssorCache) {
jssorCache.Jssor.$Pause();
if (jssorCache.Html) {
//替换原有cutFill事件,避免再次触发导致子级控件调整好的样式被覆盖
var html = jssorCache.Html.replace(/"\)\.cutFill\("/g, '").attr("duplicateCutFill_');
$(`#${jssorCache.SliderId}`).parent().html(html);
}
if (setStyleFunc) {
setStyleFunc(jssorCache);
}
if (newWidth) {
jssorCache.JssorOpt.$SlideWidth = newWidth;
}
jssorCache.Jssor = new $JssorSlider$(jssorCache.SliderId, jssorCache.JssorOpt);
// new 实例之后需要重新注册事件
if (jssorCache.On) {
jssorCache.Jssor.$On($JssorSlider$.$EVT_PARK, jssorCache.On);
}
}
else {
if (setStyleFunc) {
setStyleFunc(jssorCache);
}
}
if (afterInitFunc) {
afterInitFunc(jssorCache);
}
}
static ResizeCallback(ctrlId, delay) {
var resizeCache = LayoutConverter.CtrlJsVariableList.find(i => i.CtrlId === ctrlId);
if (resizeCache) {
if (delay) {
return resizeCache.ResizeFunc;
}
else {
resizeCache.ResizeFunc(true);
}
}
}
}
var __maxloadCount = AdjustConfig.MaxReLoadCount;
function LaunchLayoutConverter(notCallResizeFunc) {
function needLazyLoad() {
return window.location.pathname.toLowerCase().startsWith("/newsinfo")
|| window.location.pathname.toLowerCase().startsWith("/productinfo")
|| window.location.pathname.toLowerCase().startsWith("/prevnewscontentpage")
|| window.location.pathname.toLowerCase().startsWith("/prevproductcontentpage")
}
function loadResp() {
window.xa = new LayoutConverter(notCallResizeFunc);
$(document).ajaxComplete(function (event, xhr, settings) {
if (__maxloadCount <= 0) return;
var ignorePathList = [
"/AliVideo/CheckSiteOverCapacity",
"/Customer/GetCurrentUser",
"/BaiDuShare/GetShareCount",
"/Common/GetIdHitDic",
"/Common/GetCommentInfo",
"/pagevisit/FormPageViewInCrease",
"/PageVisit/Index",
"/ebusiness/AjaxGetCartItem",
"/ebusiness/GetCartItemCount",
"/Designer/Common/IsShowVerificationCode"
];
var shouldLaunch = true;
for (var x = 0; x < ignorePathList.length; x++) {
var targetUrl = ignorePathList[x].toLowerCase();
if (settings.url.toLowerCase().indexOf(targetUrl) !== -1) {
shouldLaunch = false;
}
}
if (shouldLaunch) {
__maxloadCount--;
window.xa.LaunchAdjuster({ FireFrom: "ajaxCallback" });
console.log("Ajax回调刷新响应式", settings.url);
}
});
}
function injectTabClickEvent() {
$(".w-label-tips-item").on("click", (event) => {
var target = event.target.parentElement;
var jqData = jQuery._data(target, "events");
var tab = $(event.target).closest("[ctype]");
var styleName = tab.attr("cstyle");
var handleHeightStyleList = ["Style1", "Style2"];
if (handleHeightStyleList.indexOf(styleName) !== -1) {
var heightOffset = tab.height() - tab.attr("lastHeight") * 1;
window.xa.Adjuster.AddOriMainHeight(heightOffset);
tab.attr("lastHeight", tab.height());
}
window.xa.LaunchAdjuster({ FireFrom: "tabClick", target: event.target });
if (jqData && jqData.mouseover) {
$(target).trigger("mouseover");
}
});
}
function loadFinished() {
loadResp();
injectTabClickEvent();
}
//微信无法触发loadedmetadata,只能用这种方式
function handleWeChatVideos() {
if (CtrlAdjuster.IsWeChat) {
document.write('');
document.addEventListener("WeixinJSBridgeReady", function () {
$("video").each(function (a, b) {
// b.muted = true;
b.play();
});
});
}
}
//有视频等视频延迟加载完毕后计算
function notExistVideos() {
var contents = $("[ctype=newsItemContentBind],[ctype=productContentBind]");
function loadVideoCounter() {
if (--window.VideoCounter === 0) {
contents.smrecompute();
loadFinished();
console.log("加载视频完毕,触发响应式");
}
}
var videos = contents.find("video");
window.VideoCounter = videos.length;
videos.each((a, videoEle) => {
if (videoEle.readyState >= 3) {
loadVideoCounter();
}
else {
videoEle.addEventListener('loadedmetadata', function () {
loadVideoCounter();
}, false);
}
});
return videos.length === 0;
}
function init() {
handleWeChatVideos();
//停止所有动画效果,避免导致取页面高度,宽度异常
// CtrlAdjuster.MainEle.css("z-index", 1);
CtrlAdjuster.StopAnimation();
//文章产品详情页是.html结尾 内容不固定,需要等Img全加载完后再延迟启动
if (needLazyLoad()) {
if (notExistVideos()) {
window.addEventListener('load', loadFinished);
}
}
else {
//普通页面可以直接dom加载完就启动
$(loadFinished);
}
CtrlAdjuster.MockPageWidth();
}
init();
}
LaunchLayoutConverter();