Browse Source

Merge pull request #749 in VISUAL/fineui from ~WINDY/fineui:master to master

* commit '49b06237a0ed509b499b55c4d984b3282078248e':
  BI-34455 周数标准替换
  update
  BI-32702 布局
es6
windy 6 years ago
parent
commit
3bdfdbfe6a
  1. 259
      dist/bundle.ie.js
  2. 70
      dist/bundle.ie.min.js
  3. 259
      dist/bundle.js
  4. 70
      dist/bundle.min.js
  5. 259
      dist/core.js
  6. 25
      dist/demo.js
  7. 259
      dist/fineui.ie.js
  8. 70
      dist/fineui.ie.min.js
  9. 259
      dist/fineui.js
  10. 70
      dist/fineui.min.js
  11. 239
      dist/fineui_without_jquery_polyfill.js
  12. 43
      dist/utils.js
  13. 6
      dist/utils.min.js
  14. 43
      src/core/func/date.js
  15. 20
      src/core/platform/web/config.js
  16. 96
      src/core/wrapper/layout/adapt/adapt.horizontal.js

259
dist/bundle.ie.js vendored

@ -17835,21 +17835,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -17998,7 +17993,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];
@ -19030,7 +19045,19 @@ BI.prepares.push(function () {
return _isSupprtFlex; return _isSupprtFlex;
}; };
BI.Plugin.registerWidget("bi.horizontal", function (ob) { BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex() && ob.items && ob.items.length <= 1) { // center_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
// vertical_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Left) {
return ob;
}
// horizontal_adapt
if (ob.verticalAlign === BI.VerticalAlign.Top && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
if (!BI.isIE() && isSupportFlex()) {
return BI.extend(ob, {type: "bi.flex_horizontal"}); return BI.extend(ob, {type: "bi.flex_horizontal"});
} }
return ob; return ob;
@ -19057,6 +19084,12 @@ BI.prepares.push(function () {
} }
return ob; return ob;
}); });
BI.Plugin.registerWidget("bi.horizontal_adapt", function (ob) {
if (ob.items && ob.items.length <= 1) {
return BI.extend(ob, {type: "bi.horizontal_auto"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex()) { if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局 // 有滚动条的情况下需要用到flex_wrapper_center布局
@ -30472,6 +30505,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
baseCls: "bi-horizontal-adapt-layout", baseCls: "bi-horizontal-adapt-layout",
verticalAlign: BI.VerticalAlign.Top, verticalAlign: BI.VerticalAlign.Top,
columnSize: [], columnSize: [],
scrollx: false,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -30481,90 +30515,33 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options;
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({ return {
position: "relative", type: "bi.horizontal",
width: "100%", verticalAlign: BI.VerticalAlign.Top,
"white-space": "nowrap", horizontalAlign: BI.HorizontalAlign.Center,
"border-spacing": "0px", columnSize: o.columnSize,
border: "none", items: o.items,
"border-collapse": "separate" scrollx: o.scrollx,
}); ref: function (_ref) {
this.$tr = BI.Widget._renderEngine.createElement("<tr>"); self.layout = _ref;
this.$tr.appendTo(this.$table); },
this.populate(this.options.items); hgap: o.hgap,
}, vgap: o.vgap,
lgap: o.lgap,
_addElement: function (i, item) { rgap: o.rgap,
var o = this.options; tgap: o.tgap,
var td; bgap: o.bgap
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; };
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.attr("width", width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
"vertical-align": o.verticalAlign,
margin: "0",
padding: "0",
border: "none"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
}, },
resize: function () { resize: function () {
// console.log("horizontal_adapt布局不需要resize"); // console.log("horizontal_adapt布局不需要resize");
}, },
_getWrapper: function () {
return this.$tr;
},
populate: function (items) { populate: function (items) {
BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); this.layout.populate.apply(this, arguments);
this._mount();
} }
}); });
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/** BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/**
@ -30730,6 +30707,106 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
} }
}); });
BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/** BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/**
* 使用display:table和display:table-cell实现的horizontal布局
* @class BI.TableAdaptLayout
* @extends BI.Layout
*/
BI.TableAdaptLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.TableAdaptLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-table-center-adapt-layout",
columnSize: [],
verticalAlign: BI.VerticalAlign.Top,
horizontalAlign: BI.HorizontalAlign.Left,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
render: function () {
var o = this.options;
BI.TableAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<div>").css({
position: "relative",
display: "table",
height: o.verticalAlign === BI.VerticalAlign.Middle ? "100%" : "auto",
width: o.horizontalAlign === BI.HorizontalAlign.Center ? "100%" : "auto",
"white-space": "nowrap"
});
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
width: width,
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.width(width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
display: "table-cell",
"vertical-align": "middle",
margin: "0",
padding: "0",
height: "100%"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$table.append(frag);
this.element.append(this.$table);
},
resize: function () {
// console.log("center_adapt布局不需要resize");
},
populate: function (items) {
BI.TableAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
BI.shortcut("bi.table_adapt", BI.TableAdaptLayout);/**
* 垂直方向居中容器 * 垂直方向居中容器
* @class BI.VerticalAdaptLayout * @class BI.VerticalAdaptLayout
* @extends BI.Layout * @extends BI.Layout

70
dist/bundle.ie.min.js vendored

File diff suppressed because one or more lines are too long

259
dist/bundle.js vendored

@ -17835,21 +17835,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -17998,7 +17993,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];
@ -19030,7 +19045,19 @@ BI.prepares.push(function () {
return _isSupprtFlex; return _isSupprtFlex;
}; };
BI.Plugin.registerWidget("bi.horizontal", function (ob) { BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex() && ob.items && ob.items.length <= 1) { // center_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
// vertical_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Left) {
return ob;
}
// horizontal_adapt
if (ob.verticalAlign === BI.VerticalAlign.Top && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
if (!BI.isIE() && isSupportFlex()) {
return BI.extend(ob, {type: "bi.flex_horizontal"}); return BI.extend(ob, {type: "bi.flex_horizontal"});
} }
return ob; return ob;
@ -19057,6 +19084,12 @@ BI.prepares.push(function () {
} }
return ob; return ob;
}); });
BI.Plugin.registerWidget("bi.horizontal_adapt", function (ob) {
if (ob.items && ob.items.length <= 1) {
return BI.extend(ob, {type: "bi.horizontal_auto"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex()) { if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局 // 有滚动条的情况下需要用到flex_wrapper_center布局
@ -30472,6 +30505,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
baseCls: "bi-horizontal-adapt-layout", baseCls: "bi-horizontal-adapt-layout",
verticalAlign: BI.VerticalAlign.Top, verticalAlign: BI.VerticalAlign.Top,
columnSize: [], columnSize: [],
scrollx: false,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -30481,90 +30515,33 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options;
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({ return {
position: "relative", type: "bi.horizontal",
width: "100%", verticalAlign: BI.VerticalAlign.Top,
"white-space": "nowrap", horizontalAlign: BI.HorizontalAlign.Center,
"border-spacing": "0px", columnSize: o.columnSize,
border: "none", items: o.items,
"border-collapse": "separate" scrollx: o.scrollx,
}); ref: function (_ref) {
this.$tr = BI.Widget._renderEngine.createElement("<tr>"); self.layout = _ref;
this.$tr.appendTo(this.$table); },
this.populate(this.options.items); hgap: o.hgap,
}, vgap: o.vgap,
lgap: o.lgap,
_addElement: function (i, item) { rgap: o.rgap,
var o = this.options; tgap: o.tgap,
var td; bgap: o.bgap
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; };
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.attr("width", width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
"vertical-align": o.verticalAlign,
margin: "0",
padding: "0",
border: "none"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
}, },
resize: function () { resize: function () {
// console.log("horizontal_adapt布局不需要resize"); // console.log("horizontal_adapt布局不需要resize");
}, },
_getWrapper: function () {
return this.$tr;
},
populate: function (items) { populate: function (items) {
BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); this.layout.populate.apply(this, arguments);
this._mount();
} }
}); });
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/** BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/**
@ -30730,6 +30707,106 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
} }
}); });
BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/** BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/**
* 使用display:table和display:table-cell实现的horizontal布局
* @class BI.TableAdaptLayout
* @extends BI.Layout
*/
BI.TableAdaptLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.TableAdaptLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-table-center-adapt-layout",
columnSize: [],
verticalAlign: BI.VerticalAlign.Top,
horizontalAlign: BI.HorizontalAlign.Left,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
render: function () {
var o = this.options;
BI.TableAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<div>").css({
position: "relative",
display: "table",
height: o.verticalAlign === BI.VerticalAlign.Middle ? "100%" : "auto",
width: o.horizontalAlign === BI.HorizontalAlign.Center ? "100%" : "auto",
"white-space": "nowrap"
});
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
width: width,
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.width(width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
display: "table-cell",
"vertical-align": "middle",
margin: "0",
padding: "0",
height: "100%"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$table.append(frag);
this.element.append(this.$table);
},
resize: function () {
// console.log("center_adapt布局不需要resize");
},
populate: function (items) {
BI.TableAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
BI.shortcut("bi.table_adapt", BI.TableAdaptLayout);/**
* 垂直方向居中容器 * 垂直方向居中容器
* @class BI.VerticalAdaptLayout * @class BI.VerticalAdaptLayout
* @extends BI.Layout * @extends BI.Layout

70
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

259
dist/core.js vendored

@ -17835,21 +17835,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -17998,7 +17993,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];
@ -19030,7 +19045,19 @@ BI.prepares.push(function () {
return _isSupprtFlex; return _isSupprtFlex;
}; };
BI.Plugin.registerWidget("bi.horizontal", function (ob) { BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex() && ob.items && ob.items.length <= 1) { // center_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
// vertical_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Left) {
return ob;
}
// horizontal_adapt
if (ob.verticalAlign === BI.VerticalAlign.Top && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
if (!BI.isIE() && isSupportFlex()) {
return BI.extend(ob, {type: "bi.flex_horizontal"}); return BI.extend(ob, {type: "bi.flex_horizontal"});
} }
return ob; return ob;
@ -19057,6 +19084,12 @@ BI.prepares.push(function () {
} }
return ob; return ob;
}); });
BI.Plugin.registerWidget("bi.horizontal_adapt", function (ob) {
if (ob.items && ob.items.length <= 1) {
return BI.extend(ob, {type: "bi.horizontal_auto"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex()) { if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局 // 有滚动条的情况下需要用到flex_wrapper_center布局
@ -30472,6 +30505,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
baseCls: "bi-horizontal-adapt-layout", baseCls: "bi-horizontal-adapt-layout",
verticalAlign: BI.VerticalAlign.Top, verticalAlign: BI.VerticalAlign.Top,
columnSize: [], columnSize: [],
scrollx: false,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -30481,90 +30515,33 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options;
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({ return {
position: "relative", type: "bi.horizontal",
width: "100%", verticalAlign: BI.VerticalAlign.Top,
"white-space": "nowrap", horizontalAlign: BI.HorizontalAlign.Center,
"border-spacing": "0px", columnSize: o.columnSize,
border: "none", items: o.items,
"border-collapse": "separate" scrollx: o.scrollx,
}); ref: function (_ref) {
this.$tr = BI.Widget._renderEngine.createElement("<tr>"); self.layout = _ref;
this.$tr.appendTo(this.$table); },
this.populate(this.options.items); hgap: o.hgap,
}, vgap: o.vgap,
lgap: o.lgap,
_addElement: function (i, item) { rgap: o.rgap,
var o = this.options; tgap: o.tgap,
var td; bgap: o.bgap
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; };
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.attr("width", width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
"vertical-align": o.verticalAlign,
margin: "0",
padding: "0",
border: "none"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
}, },
resize: function () { resize: function () {
// console.log("horizontal_adapt布局不需要resize"); // console.log("horizontal_adapt布局不需要resize");
}, },
_getWrapper: function () {
return this.$tr;
},
populate: function (items) { populate: function (items) {
BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); this.layout.populate.apply(this, arguments);
this._mount();
} }
}); });
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/** BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/**
@ -30730,6 +30707,106 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
} }
}); });
BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/** BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/**
* 使用display:table和display:table-cell实现的horizontal布局
* @class BI.TableAdaptLayout
* @extends BI.Layout
*/
BI.TableAdaptLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.TableAdaptLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-table-center-adapt-layout",
columnSize: [],
verticalAlign: BI.VerticalAlign.Top,
horizontalAlign: BI.HorizontalAlign.Left,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
render: function () {
var o = this.options;
BI.TableAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<div>").css({
position: "relative",
display: "table",
height: o.verticalAlign === BI.VerticalAlign.Middle ? "100%" : "auto",
width: o.horizontalAlign === BI.HorizontalAlign.Center ? "100%" : "auto",
"white-space": "nowrap"
});
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
width: width,
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.width(width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
display: "table-cell",
"vertical-align": "middle",
margin: "0",
padding: "0",
height: "100%"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$table.append(frag);
this.element.append(this.$table);
},
resize: function () {
// console.log("center_adapt布局不需要resize");
},
populate: function (items) {
BI.TableAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
BI.shortcut("bi.table_adapt", BI.TableAdaptLayout);/**
* 垂直方向居中容器 * 垂直方向居中容器
* @class BI.VerticalAdaptLayout * @class BI.VerticalAdaptLayout
* @extends BI.Layout * @extends BI.Layout

25
dist/demo.js vendored

@ -6126,7 +6126,30 @@ Demo.HtapeLayout = BI.inherit(BI.Widget, {
}; };
} }
}); });
BI.shortcut("demo.htape", Demo.HtapeLayout);/** BI.shortcut("demo.htape", Demo.HtapeLayout);Demo.InlineVerticalLayout = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-absolute"
},
render: function () {
return {
type: "bi.inline_vertical_adapt",
items: [{
type: "bi.label",
text: "绝对布局",
cls: "layout-bg1",
width: 300,
height: 200
}, {
type: "bi.label",
text: "绝对布局",
cls: "layout-bg1",
width: 300,
height: 100
}]
};
}
});
BI.shortcut("demo.inline_vertical", Demo.InlineVerticalLayout);/**
* Created by User on 2017/3/22. * Created by User on 2017/3/22.
*/ */
Demo.LeftRightVerticalAdaptLayout = BI.inherit(BI.Widget, { Demo.LeftRightVerticalAdaptLayout = BI.inherit(BI.Widget, {

259
dist/fineui.ie.js vendored

@ -18077,21 +18077,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -18240,7 +18235,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];
@ -19272,7 +19287,19 @@ BI.prepares.push(function () {
return _isSupprtFlex; return _isSupprtFlex;
}; };
BI.Plugin.registerWidget("bi.horizontal", function (ob) { BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex() && ob.items && ob.items.length <= 1) { // center_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
// vertical_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Left) {
return ob;
}
// horizontal_adapt
if (ob.verticalAlign === BI.VerticalAlign.Top && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
if (!BI.isIE() && isSupportFlex()) {
return BI.extend(ob, {type: "bi.flex_horizontal"}); return BI.extend(ob, {type: "bi.flex_horizontal"});
} }
return ob; return ob;
@ -19299,6 +19326,12 @@ BI.prepares.push(function () {
} }
return ob; return ob;
}); });
BI.Plugin.registerWidget("bi.horizontal_adapt", function (ob) {
if (ob.items && ob.items.length <= 1) {
return BI.extend(ob, {type: "bi.horizontal_auto"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex()) { if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局 // 有滚动条的情况下需要用到flex_wrapper_center布局
@ -30714,6 +30747,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
baseCls: "bi-horizontal-adapt-layout", baseCls: "bi-horizontal-adapt-layout",
verticalAlign: BI.VerticalAlign.Top, verticalAlign: BI.VerticalAlign.Top,
columnSize: [], columnSize: [],
scrollx: false,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -30723,90 +30757,33 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options;
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({ return {
position: "relative", type: "bi.horizontal",
width: "100%", verticalAlign: BI.VerticalAlign.Top,
"white-space": "nowrap", horizontalAlign: BI.HorizontalAlign.Center,
"border-spacing": "0px", columnSize: o.columnSize,
border: "none", items: o.items,
"border-collapse": "separate" scrollx: o.scrollx,
}); ref: function (_ref) {
this.$tr = BI.Widget._renderEngine.createElement("<tr>"); self.layout = _ref;
this.$tr.appendTo(this.$table); },
this.populate(this.options.items); hgap: o.hgap,
}, vgap: o.vgap,
lgap: o.lgap,
_addElement: function (i, item) { rgap: o.rgap,
var o = this.options; tgap: o.tgap,
var td; bgap: o.bgap
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; };
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.attr("width", width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
"vertical-align": o.verticalAlign,
margin: "0",
padding: "0",
border: "none"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
}, },
resize: function () { resize: function () {
// console.log("horizontal_adapt布局不需要resize"); // console.log("horizontal_adapt布局不需要resize");
}, },
_getWrapper: function () {
return this.$tr;
},
populate: function (items) { populate: function (items) {
BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); this.layout.populate.apply(this, arguments);
this._mount();
} }
}); });
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/** BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/**
@ -30972,6 +30949,106 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
} }
}); });
BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/** BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/**
* 使用display:table和display:table-cell实现的horizontal布局
* @class BI.TableAdaptLayout
* @extends BI.Layout
*/
BI.TableAdaptLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.TableAdaptLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-table-center-adapt-layout",
columnSize: [],
verticalAlign: BI.VerticalAlign.Top,
horizontalAlign: BI.HorizontalAlign.Left,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
render: function () {
var o = this.options;
BI.TableAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<div>").css({
position: "relative",
display: "table",
height: o.verticalAlign === BI.VerticalAlign.Middle ? "100%" : "auto",
width: o.horizontalAlign === BI.HorizontalAlign.Center ? "100%" : "auto",
"white-space": "nowrap"
});
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
width: width,
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.width(width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
display: "table-cell",
"vertical-align": "middle",
margin: "0",
padding: "0",
height: "100%"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$table.append(frag);
this.element.append(this.$table);
},
resize: function () {
// console.log("center_adapt布局不需要resize");
},
populate: function (items) {
BI.TableAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
BI.shortcut("bi.table_adapt", BI.TableAdaptLayout);/**
* 垂直方向居中容器 * 垂直方向居中容器
* @class BI.VerticalAdaptLayout * @class BI.VerticalAdaptLayout
* @extends BI.Layout * @extends BI.Layout

70
dist/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

259
dist/fineui.js vendored

@ -18077,21 +18077,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -18240,7 +18235,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];
@ -19272,7 +19287,19 @@ BI.prepares.push(function () {
return _isSupprtFlex; return _isSupprtFlex;
}; };
BI.Plugin.registerWidget("bi.horizontal", function (ob) { BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex() && ob.items && ob.items.length <= 1) { // center_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
// vertical_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Left) {
return ob;
}
// horizontal_adapt
if (ob.verticalAlign === BI.VerticalAlign.Top && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
if (!BI.isIE() && isSupportFlex()) {
return BI.extend(ob, {type: "bi.flex_horizontal"}); return BI.extend(ob, {type: "bi.flex_horizontal"});
} }
return ob; return ob;
@ -19299,6 +19326,12 @@ BI.prepares.push(function () {
} }
return ob; return ob;
}); });
BI.Plugin.registerWidget("bi.horizontal_adapt", function (ob) {
if (ob.items && ob.items.length <= 1) {
return BI.extend(ob, {type: "bi.horizontal_auto"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex()) { if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局 // 有滚动条的情况下需要用到flex_wrapper_center布局
@ -30714,6 +30747,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
baseCls: "bi-horizontal-adapt-layout", baseCls: "bi-horizontal-adapt-layout",
verticalAlign: BI.VerticalAlign.Top, verticalAlign: BI.VerticalAlign.Top,
columnSize: [], columnSize: [],
scrollx: false,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -30723,90 +30757,33 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options;
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({ return {
position: "relative", type: "bi.horizontal",
width: "100%", verticalAlign: BI.VerticalAlign.Top,
"white-space": "nowrap", horizontalAlign: BI.HorizontalAlign.Center,
"border-spacing": "0px", columnSize: o.columnSize,
border: "none", items: o.items,
"border-collapse": "separate" scrollx: o.scrollx,
}); ref: function (_ref) {
this.$tr = BI.Widget._renderEngine.createElement("<tr>"); self.layout = _ref;
this.$tr.appendTo(this.$table); },
this.populate(this.options.items); hgap: o.hgap,
}, vgap: o.vgap,
lgap: o.lgap,
_addElement: function (i, item) { rgap: o.rgap,
var o = this.options; tgap: o.tgap,
var td; bgap: o.bgap
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; };
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.attr("width", width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
"vertical-align": o.verticalAlign,
margin: "0",
padding: "0",
border: "none"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
}, },
resize: function () { resize: function () {
// console.log("horizontal_adapt布局不需要resize"); // console.log("horizontal_adapt布局不需要resize");
}, },
_getWrapper: function () {
return this.$tr;
},
populate: function (items) { populate: function (items) {
BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); this.layout.populate.apply(this, arguments);
this._mount();
} }
}); });
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/** BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/**
@ -30972,6 +30949,106 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
} }
}); });
BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/** BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/**
* 使用display:table和display:table-cell实现的horizontal布局
* @class BI.TableAdaptLayout
* @extends BI.Layout
*/
BI.TableAdaptLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.TableAdaptLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-table-center-adapt-layout",
columnSize: [],
verticalAlign: BI.VerticalAlign.Top,
horizontalAlign: BI.HorizontalAlign.Left,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
render: function () {
var o = this.options;
BI.TableAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<div>").css({
position: "relative",
display: "table",
height: o.verticalAlign === BI.VerticalAlign.Middle ? "100%" : "auto",
width: o.horizontalAlign === BI.HorizontalAlign.Center ? "100%" : "auto",
"white-space": "nowrap"
});
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
width: width,
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.width(width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
display: "table-cell",
"vertical-align": "middle",
margin: "0",
padding: "0",
height: "100%"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$table.append(frag);
this.element.append(this.$table);
},
resize: function () {
// console.log("center_adapt布局不需要resize");
},
populate: function (items) {
BI.TableAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
BI.shortcut("bi.table_adapt", BI.TableAdaptLayout);/**
* 垂直方向居中容器 * 垂直方向居中容器
* @class BI.VerticalAdaptLayout * @class BI.VerticalAdaptLayout
* @extends BI.Layout * @extends BI.Layout

70
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

239
dist/fineui_without_jquery_polyfill.js vendored

@ -17581,21 +17581,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -17744,7 +17739,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];
@ -19483,6 +19498,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
baseCls: "bi-horizontal-adapt-layout", baseCls: "bi-horizontal-adapt-layout",
verticalAlign: BI.VerticalAlign.Top, verticalAlign: BI.VerticalAlign.Top,
columnSize: [], columnSize: [],
scrollx: false,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -19492,90 +19508,33 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options;
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({ return {
position: "relative", type: "bi.horizontal",
width: "100%", verticalAlign: BI.VerticalAlign.Top,
"white-space": "nowrap", horizontalAlign: BI.HorizontalAlign.Center,
"border-spacing": "0px", columnSize: o.columnSize,
border: "none", items: o.items,
"border-collapse": "separate" scrollx: o.scrollx,
}); ref: function (_ref) {
this.$tr = BI.Widget._renderEngine.createElement("<tr>"); self.layout = _ref;
this.$tr.appendTo(this.$table); },
this.populate(this.options.items); hgap: o.hgap,
}, vgap: o.vgap,
lgap: o.lgap,
_addElement: function (i, item) { rgap: o.rgap,
var o = this.options; tgap: o.tgap,
var td; bgap: o.bgap
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; };
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.attr("width", width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
"vertical-align": o.verticalAlign,
margin: "0",
padding: "0",
border: "none"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
}, },
resize: function () { resize: function () {
// console.log("horizontal_adapt布局不需要resize"); // console.log("horizontal_adapt布局不需要resize");
}, },
_getWrapper: function () {
return this.$tr;
},
populate: function (items) { populate: function (items) {
BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); this.layout.populate.apply(this, arguments);
this._mount();
} }
}); });
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/** BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);/**
@ -19741,6 +19700,106 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
} }
}); });
BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/** BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);/**
* 使用display:table和display:table-cell实现的horizontal布局
* @class BI.TableAdaptLayout
* @extends BI.Layout
*/
BI.TableAdaptLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.TableAdaptLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-table-center-adapt-layout",
columnSize: [],
verticalAlign: BI.VerticalAlign.Top,
horizontalAlign: BI.HorizontalAlign.Left,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0
});
},
render: function () {
var o = this.options;
BI.TableAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<div>").css({
position: "relative",
display: "table",
height: o.verticalAlign === BI.VerticalAlign.Middle ? "100%" : "auto",
width: o.horizontalAlign === BI.HorizontalAlign.Center ? "100%" : "auto",
"white-space": "nowrap"
});
this.populate(this.options.items);
},
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
width: width,
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.width(width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
display: "table-cell",
"vertical-align": "middle",
margin: "0",
padding: "0",
height: "100%"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$table.append(frag);
this.element.append(this.$table);
},
resize: function () {
// console.log("center_adapt布局不需要resize");
},
populate: function (items) {
BI.TableAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
BI.shortcut("bi.table_adapt", BI.TableAdaptLayout);/**
* 垂直方向居中容器 * 垂直方向居中容器
* @class BI.VerticalAdaptLayout * @class BI.VerticalAdaptLayout
* @extends BI.Layout * @extends BI.Layout

43
dist/utils.js vendored

@ -10595,21 +10595,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -10758,7 +10753,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];

6
dist/utils.min.js vendored

File diff suppressed because one or more lines are too long

43
src/core/func/date.js

@ -49,21 +49,16 @@ _.extend(BI, {
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
var week = d.getDay(); var week = d.getDay();
var startOfWeek = BI.StartOfWeek % 7; var startOfWeek = BI.StartOfWeek % 7;
if (date.getMonth() === 0) { var middleDay = (startOfWeek + 3) % 7;
var formatWeek = (week + 8 - startOfWeek) % 7; middleDay = middleDay || 7;
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { // 偏移到周周首之前需要多少天
return 1; var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek);
} var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek);
} d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount);
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); var ms = d.valueOf();
var ms = d.valueOf(); // GMT
d.setMonth(0); d.setMonth(0);
d.setDate(1); d.setDate(1);
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1;
if (d.getDay() !== startOfWeek) {
offset++;
}
return offset;
}, },
getQuarter: function (date) { getQuarter: function (date) {
@ -212,7 +207,27 @@ _.extend(BI, {
return s[par] || par; return s[par] || par;
}); });
} }
// 包含年周的格式化,ISO8601标准周的计数会影响年
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) {
switch (wn) {
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
case 1:
if (m === 11) {
s["%y"] = parseInt(s["%y"]) + 1;
s["%Y"] = parseInt(s["%Y"]) + 1;
}
break;
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
case 53:
if (m === 0) {
s["%y"] = parseInt(s["%y"]) - 1;
s["%Y"] = parseInt(s["%Y"]) - 1;
}
break;
default:
break;
}
}
var a = str.match(re); var a = str.match(re);
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];

20
src/core/platform/web/config.js

@ -9,7 +9,19 @@ BI.prepares.push(function () {
return _isSupprtFlex; return _isSupprtFlex;
}; };
BI.Plugin.registerWidget("bi.horizontal", function (ob) { BI.Plugin.registerWidget("bi.horizontal", function (ob) {
if (!BI.isIE() && isSupportFlex() && ob.items && ob.items.length <= 1) { // center_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
// vertical_adapt
if (ob.verticalAlign === BI.VerticalAlign.Middle && ob.horizontalAlign === BI.HorizontalAlign.Left) {
return ob;
}
// horizontal_adapt
if (ob.verticalAlign === BI.VerticalAlign.Top && ob.horizontalAlign === BI.HorizontalAlign.Center) {
return ob;
}
if (!BI.isIE() && isSupportFlex()) {
return BI.extend(ob, {type: "bi.flex_horizontal"}); return BI.extend(ob, {type: "bi.flex_horizontal"});
} }
return ob; return ob;
@ -36,6 +48,12 @@ BI.prepares.push(function () {
} }
return ob; return ob;
}); });
BI.Plugin.registerWidget("bi.horizontal_adapt", function (ob) {
if (ob.items && ob.items.length <= 1) {
return BI.extend(ob, {type: "bi.horizontal_auto"});
}
return ob;
});
BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) { BI.Plugin.registerWidget("bi.float_center_adapt", function (ob) {
if (!BI.isIE() && isSupportFlex()) { if (!BI.isIE() && isSupportFlex()) {
// 有滚动条的情况下需要用到flex_wrapper_center布局 // 有滚动条的情况下需要用到flex_wrapper_center布局

96
src/core/wrapper/layout/adapt/adapt.horizontal.js

@ -9,6 +9,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
baseCls: "bi-horizontal-adapt-layout", baseCls: "bi-horizontal-adapt-layout",
verticalAlign: BI.VerticalAlign.Top, verticalAlign: BI.VerticalAlign.Top,
columnSize: [], columnSize: [],
scrollx: false,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
lgap: 0, lgap: 0,
@ -18,90 +19,33 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options;
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = BI.Widget._renderEngine.createElement("<table>").attr({cellspacing: 0, cellpadding: 0}).css({ return {
position: "relative", type: "bi.horizontal",
width: "100%", verticalAlign: BI.VerticalAlign.Top,
"white-space": "nowrap", horizontalAlign: BI.HorizontalAlign.Center,
"border-spacing": "0px", columnSize: o.columnSize,
border: "none", items: o.items,
"border-collapse": "separate" scrollx: o.scrollx,
}); ref: function (_ref) {
this.$tr = BI.Widget._renderEngine.createElement("<tr>"); self.layout = _ref;
this.$tr.appendTo(this.$table); },
this.populate(this.options.items); hgap: o.hgap,
}, vgap: o.vgap,
lgap: o.lgap,
_addElement: function (i, item) { rgap: o.rgap,
var o = this.options; tgap: o.tgap,
var td; bgap: o.bgap
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; };
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
attributes: {
width: width
},
items: [w]
});
this.addWidget(this._getChildName(i), td);
} else {
td = this.getWidgetByName(this._getChildName(i));
td.element.attr("width", width);
}
td.element.css({"max-width": o.columnSize[i] + "px"});
if (i === 0) {
td.element.addClass("first-element");
}
td.element.css({
position: "relative",
"vertical-align": o.verticalAlign,
margin: "0",
padding: "0",
border: "none"
});
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) + "px"
});
}
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px"
});
}
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) + "px"
});
}
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) + "px"
});
}
return td;
},
appendFragment: function (frag) {
this.$tr.append(frag);
this.element.append(this.$table);
}, },
resize: function () { resize: function () {
// console.log("horizontal_adapt布局不需要resize"); // console.log("horizontal_adapt布局不需要resize");
}, },
_getWrapper: function () {
return this.$tr;
},
populate: function (items) { populate: function (items) {
BI.HorizontalAdaptLayout.superclass.populate.apply(this, arguments); this.layout.populate.apply(this, arguments);
this._mount();
} }
}); });
BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout); BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);
Loading…
Cancel
Save