Browse Source

Merge pull request #9 in FUI/fineui from ~GUY/fineui:2.0 to 2.0

* commit 'b657cd695fe8698e2360cdcbbbaba0db35116f4e':
  add
  add
  update
  add
  add
  update
  update
  add
  常量替换
  add
  add
  add
  add
  add
  add
es6
guy 8 years ago
parent
commit
867606c2c6
  1. 9
      bi/base.js
  2. 128
      bi/core.css
  3. 182
      bi/core.js
  4. 8
      bi/widget.css
  5. 521
      bi/widget.js
  6. 12
      demo/js/config/widget.js
  7. 233
      demo/js/widget/table/demo.preview_table.js
  8. 158
      demo/js/widget/table/demo.responsive_table.js
  9. 9
      dist/base.js
  10. 128
      dist/core.css
  11. 182
      dist/core.js
  12. 8
      dist/widget.css
  13. 521
      dist/widget.js
  14. 3
      src/base/combination/group.button.js
  15. 6
      src/base/table/table.js
  16. 22
      src/core/alias.js
  17. 80
      src/core/mvc/fbi.js
  18. 5
      src/core/ob.js
  19. 19
      src/core/view.js
  20. 44
      src/core/widget.js
  21. 3
      src/core/wrapper/layout.js
  22. 2
      src/core/wrapper/layout/adapt/float.center.js
  23. 2
      src/core/wrapper/layout/adapt/float.horizontal.js
  24. 128
      src/css/core/reset.css
  25. 8
      src/css/widget/responsivetable/responsivetable.css
  26. 48
      src/less/core/reset.less
  27. 11
      src/less/widget/responsivetable/responsivetable.less
  28. 29
      src/widget/adaptivearrangement/adaptivearrangement.js
  29. 125
      src/widget/date/trigger.date.js
  30. 5
      src/widget/previewtable/previewtable.js
  31. 363
      src/widget/responsivetable/responsivetable.js

9
bi/base.js

@ -1078,10 +1078,9 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
//如果是一个简单的layout
_isSimpleLayout: function () {
var o = this.options;
return o.layouts.length === 1
return o.layouts.length === 1 && !BI.isArray(o.items[0])
},
doBehavior: function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(this.buttons);
@ -30424,11 +30423,9 @@ BI.Table = BI.inherit(BI.Widget, {
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT);
}
});
BI.Resizers.add(this.getName(), function (e) {
if (BI.isWindow(e.target) && self.element.is(":visible")) {
BI.ResizeDetector.addResizeListener(this, function () {
self._resize();
self.fireEvent(BI.Table.EVENT_TABLE_RESIZE);
}
});
},
@ -30810,6 +30807,7 @@ BI.Table = BI.inherit(BI.Widget, {
.addClass(c === rows.length - 1 ? "last-col" : "");
var w = BI.createWidget(map[r][c], {
type: "bi.table_cell",
root: true,
textAlign: "left",
width: BI.isNumeric(width) ? width : "",
height: BI.isNumeric(height) ? height : "",
@ -30889,6 +30887,7 @@ BI.Table = BI.inherit(BI.Widget, {
return this.footer;
},
_createBody: function () {
var self = this, o = this.options;
this.body = this._body();

128
bi/core.css

@ -1,131 +1,3 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
@charset "UTF-8";
/*!
* animate.css -http://daneden.me/animate

182
bi/core.js

@ -173,6 +173,10 @@ BI.Factory = {
return this;
},
un: function () {
this.off.apply(this, arguments);
},
// Trigger one or many events, firing all bound callbacks. Callbacks are
// passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to
@ -188,6 +192,10 @@ BI.Factory = {
return this;
},
fireEvent: function () {
this.trigger.apply(this, arguments);
},
// Inversion-of-control versions of `on` and `once`. Tell *this* object to
// listen to an event in another object ... keeping track of what it's
// listening to.
@ -274,11 +282,21 @@ BI.Factory = {
var triggerEvents = function (events, args) {
var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
switch (args.length) {
case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
case 0:
while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
return;
case 2:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
return;
case 3:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
return;
default:
while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
return;
}
};
@ -329,10 +347,17 @@ BI.Factory = {
// CouchDB users may want to set this to `"_id"`.
idAttribute: 'ID',
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
init: function () {
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
this.init();
},
// Return a copy of the model's `attributes` object.
toJSON: function (options) {
@ -695,12 +720,15 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// The JSON representation of a Collection is an array of the
// models' attributes.
toJSON: function (options) {
return this.map(function(model){ return model.toJSON(options); });
return this.map(function (model) {
return model.toJSON(options);
});
},
// Proxy `BI.sync` by default.
@ -1124,18 +1152,23 @@ BI.Factory = {
return this.$el.find(selector);
},
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
//容器,默认放在this.element上
_vessel: function(){return this.element},
_vessel: function () {
return this
},
// **render** is the core function that your view should override, in order
// to populate its element (`this.el`), with the appropriate HTML. The
// convention is for **render** to always return `this`.
_render: function(vessel) {
render: function (vessel) {
return this;
},
@ -1162,8 +1195,8 @@ BI.Factory = {
setElement: function (element) {
this.undelegateEvents();
this._setElement(element);
this.$vessel = this._vessel();
this._render(this.$vessel);
this.vessel = this._vessel();
this.render(this.vessel);
this.delegateEvents();
return this;
},
@ -1230,21 +1263,21 @@ BI.Factory = {
// using `selector`). This only works for delegate-able events: not `focus`,
// `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
delegate: function (eventName, selector, listener) {
this.$vessel.on(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Clears all callbacks previously bound to the view by `delegateEvents`.
// You usually don't need to use this, but may wish to if you have multiple
// BI views attached to the same DOM element.
undelegateEvents: function () {
if (this.$vessel) this.$vessel.off('.delegateEvents' + this.cid);
if (this.vessel) this.vessel.element.off('.delegateEvents' + this.cid);
return this;
},
// A finer-grained `undelegateEvents` for removing a single delegated event.
// `selector` and `listener` are both optional.
undelegate: function (eventName, selector, listener) {
this.$vessel.off(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Produces a DOM element to be assigned to your view. Exposed for
@ -1394,7 +1427,8 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// Manually bind a single named route to a callback. For example:
//
@ -1766,7 +1800,9 @@ BI.Factory = {
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){ return parent.apply(this, arguments); };
child = function () {
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function, if supplied.
@ -1774,7 +1810,9 @@ BI.Factory = {
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
var Surrogate = function(){ this.constructor = child; };
var Surrogate = function () {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate;
@ -3143,7 +3181,14 @@ if (!window.BI) {
}
}
});
})(jQuery);BI.cjkEncode = function (text) {
})(jQuery);;(function () {
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
return result;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') {
return text;
@ -3277,12 +3322,12 @@ BI.jsonEncode = function (o) {
};
BI.contentFormat = function (cv, fmt) {
if (BI.isEmpty(cv)) {
if (isEmpty(cv)) {
//原值为空,返回空字符
return '';
}
var text = cv.toString();
if (BI.isEmpty(fmt)) {
if (isEmpty(fmt)) {
//格式为空,返回原字符
return text;
}
@ -3491,7 +3536,7 @@ BI._dealWithRight = function (tright, fright) {
var c = tright.charAt(j);
switch (ch) {
case '0':
if (BI.isEmpty(c)) {
if (isEmpty(c)) {
c = '0';
}
right += c;
@ -3508,7 +3553,7 @@ BI._dealWithRight = function (tright, fright) {
}
var rll = tright.substr(j);
var result = {};
if (!BI.isEmpty(rll) && rll.charAt(0) > 4) {
if (!isEmpty(rll) && rll.charAt(0) > 4) {
//有多余字符,需要四舍五入
result.leftPlus = true;
var numReg = right.match(/^[0-9]+/);
@ -3562,7 +3607,7 @@ BI._dealWithLeft = function (tleft, fleft) {
var c = tleft.charAt(j);
switch (ch) {
case '0':
if (BI.isEmpty(c)) {
if (isEmpty(c)) {
c = '0';
}
last = -1;
@ -3575,7 +3620,7 @@ BI._dealWithLeft = function (tleft, fleft) {
j--;
break;
case ',':
if (!BI.isEmpty(c)) {
if (!isEmpty(c)) {
//计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/);
if (com) {
@ -3604,7 +3649,7 @@ BI._dealWithLeft = function (tleft, fleft) {
newstr = res.substr(n, combo) + ',' + newstr;
}
var lres = res.substr(0, n + combo);
if (!BI.isEmpty(lres)) {
if (!isEmpty(lres)) {
newstr = lres + ',' + newstr;
}
}
@ -3733,7 +3778,9 @@ BI._eFormat = function (text, fmt) {
}
}
return text;
};/**
};
})();
/**
* 事件集合
* @class BI.Events
*/
@ -4254,8 +4301,7 @@ BI.OB = function (config) {
};
$.extend(BI.OB.prototype, {
props: {},
init: function () {
},
init: null,
_defaultConfig: function (config) {
return {};
@ -4263,7 +4309,7 @@ $.extend(BI.OB.prototype, {
_init: function () {
this._initListeners();
this.init();
this.init && this.init();
},
_initListeners: function () {
@ -4386,6 +4432,7 @@ $.extend(BI.OB.prototype, {
BI.Widget = BI.inherit(BI.OB, {
_defaultConfig: function () {
return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
@ -4401,41 +4448,30 @@ BI.Widget = BI.inherit(BI.OB, {
},
//生命周期函数
beforeCreate: function () {
beforeCreate: null,
},
created: null,
created: function () {
render: null,
},
beforeMounted: null,
render: function () {
},
beforeMounted: function () {
},
mounted: function () {
},
mounted: null,
update: null,
destroyed: function () {
},
destroyed: null,
_init: function () {
BI.Widget.superclass._init.apply(this, arguments);
this.beforeCreate();
this.beforeCreate && this.beforeCreate();
this._initRoot();
this._initElementWidth();
this._initElementHeight();
this._initVisualEffects();
this._initState();
this._initElement();
this.created();
this.created && this.created();
},
/**
@ -4445,6 +4481,7 @@ BI.Widget = BI.inherit(BI.OB, {
_initRoot: function () {
var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget");
this._isRoot = o.root;
if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) {
this._parent = o.element;
@ -4508,7 +4545,7 @@ BI.Widget = BI.inherit(BI.OB, {
_initElement: function () {
var self = this;
var els = this.render();
var els = this.render && this.render();
if (BI.isPlainObject(els)) {
els = [els];
}
@ -4542,13 +4579,13 @@ BI.Widget = BI.inherit(BI.OB, {
if (!isMounted) {
return;
}
this.beforeMounted();
this.beforeMounted && this.beforeMounted();
this._isMounted = true;
this._mountChildren();
BI.each(this._children, function (i, widget) {
widget._mount && widget._mount();
});
this.mounted();
this.mounted && this.mounted();
},
_mountChildren: function () {
@ -4574,7 +4611,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed();
this.destroyed && this.destroyed();
},
setWidth: function (w) {
@ -4636,6 +4673,9 @@ BI.Widget = BI.inherit(BI.OB, {
widget = name;
name = widget.getName();
}
if (BI.isKey(name)) {
name = name + "";
}
name = name || widget.getName() || BI.uniqueId("widget");
if (this._children[name]) {
throw new Error("name has already been existed");
@ -4761,7 +4801,7 @@ BI.Widget = BI.inherit(BI.OB, {
empty: function () {
BI.each(this._children, function (i, widget) {
widget._unMount();
widget._unMount && widget._unMount();
});
this._children = {};
this.element.empty();
@ -4774,7 +4814,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed();
this.destroyed && this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this.purgeListeners();
@ -5370,10 +5410,10 @@ BI.View = BI.inherit(BI.V, {
});
var vessel = BI.createWidget();
this._cardLayouts[this.getName()].addCardByName(this.getName(), vessel);
return vessel.element;
return vessel;
},
_render: function (vessel) {
render: function (vessel) {
return this;
},
@ -5741,15 +5781,26 @@ BI.View = BI.inherit(BI.V, {
},
_unMount: function () {
BI.each(this._cardLayouts, function (name, card) {
card && card._unMount();
});
delete this._cardLayouts;
delete this._cards;
this.off();
this.destroyed();
},
destroy: function () {
BI.each(this._cardLayouts, function (name, card) {
card && card.destroy();
card && card._unMount();
});
delete this._cardLayouts;
delete this._cards;
this.destroyed();
this.remove();
this.trigger(BI.Events.DESTROY);
this.destroyed();
this.off();
},
destroyed: function () {
@ -11509,9 +11560,8 @@ BI.Layout = BI.inherit(BI.Widget, {
removeIndex = nameOrWidget;
}
if (removeIndex) {
this.options.items.splice(removeIndex, 1);
this._removeItemAt(removeIndex | 0);
}
BI.Layout.superclass.removeWidget.apply(this, arguments);
},
empty: function () {
@ -12305,7 +12355,7 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
element: this,
items: [this.left]
});
this.removeWidget(this.container.getName());
this.removeWidget(this.container);
},
stroke: function (items) {
@ -12368,7 +12418,7 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
element: this,
items: [this.left]
});
this.removeWidget(this.container.getName());
this.removeWidget(this.container);
},
_addElement: function (i, item) {

8
bi/widget.css

@ -632,6 +632,14 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-sequence-table-dynamic-number .sequence-table-title-cell {
overflow: hidden;
overflow-x: hidden;

521
bi/widget.js

@ -419,8 +419,10 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
if (o.isNeedResizeContainer) {
var isResizing = false;
var needEnd = false;
var height;
var interval;
var startSize;
var resize = function (e, ui) {
if (isResizing) {
return;
@ -442,20 +444,26 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
minHeight: 20,
helper: "bi-resizer",
autoHide: true,
start: function (e, ui) {
startSize = BI.clone(ui.size);
},
resize: function (e, ui) {
if (ui.size.height >= self.arrangement.container.element.height()) {
if (ui.size.height >= startSize.height - 10) {
resize(e, ui);
} else {
interval && clearInterval(interval);
needEnd = true;
}
},
stop: function (e, ui) {
var size = ui.size;
if (isResizing) {
if (isResizing && !needEnd) {
size.height = height;
}
self.arrangement.setContainerSize(ui.size);
needEnd = false;
isResizing = false;
startSize = null;
interval && clearInterval(interval);
self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
}
@ -484,17 +492,21 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
return this.arrangement._isEqual.apply(this.arrangement, arguments);
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
_setSelect: function (item) {
if (!item.element.hasClass("selected")) {
item.element.css("zIndex", ++self.zIndex);
BI.each(self.getAllRegions(), function (i, region) {
item.element.css("zIndex", ++this.zIndex);
BI.each(this.getAllRegions(), function (i, region) {
region.el.element.removeClass("selected");
});
item.element.addClass("selected");
}
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
self._setSelect(item)
});
o.resizable && item.element.resizable({
handles: "e, s, se",
@ -663,6 +675,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
addRegion: function (region, position) {
this._initResizable(region.el);
this._setSelect(region.el);
var self = this, flag;
var old = this.arrangement.getAllRegions();
if (BI.isNotNull(this.position)) {
@ -4892,6 +4905,9 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.DateTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.DateTrigger.EVENT_VALID);
});
@ -4907,7 +4923,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
if (BI.isNotEmptyString(value)) {
var date = value.split("-");
self.store_value = {
type: BICst.MULTI_DATE_CALENDAR,
type: BI.DateTrigger.MULTI_DATE_CALENDAR,
value:{
year: date[0] | 0,
month: date[1] - 1,
@ -4975,7 +4991,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
var date = new Date();
this.store_value = v;
if (BI.isNotNull(v)) {
type = v.type || BICst.MULTI_DATE_CALENDAR; value = v.value;
type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
if(BI.isNull(value)){
value = v;
}
@ -4987,88 +5003,88 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
self.setTitle(text + ":" + dateStr);
};
switch (type) {
case BICst.MULTI_DATE_YEAR_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_PREV];
case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_AFTER];
case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_BEGIN];
case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
date = new Date(date.getFullYear(), 0, 1);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_END];
case BI.DateTrigger.MULTI_DATE_YEAR_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
date = new Date(date.getFullYear(), 11, 31);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_PREV];
case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
date = new Date().getBeforeMulQuarter(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_AFTER];
case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
date = new Date().getAfterMulQuarter(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_BEGIN];
case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
date = new Date().getQuarterStartDate();
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_END];
case BI.DateTrigger.MULTI_DATE_QUARTER_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
date = new Date().getQuarterEndDate();
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_PREV];
case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
date = new Date().getBeforeMultiMonth(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_AFTER];
case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
date = new Date().getAfterMultiMonth(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_BEGIN];
case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
date = new Date(date.getFullYear(), date.getMonth(), 1);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_END];
case BI.DateTrigger.MULTI_DATE_MONTH_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_WEEK_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_PREV];
case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
date = date.getOffsetDate(-7 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_WEEK_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_AFTER];
case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
date = date.getOffsetDate(7 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_PREV];
case BI.DateTrigger.MULTI_DATE_DAY_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
date = date.getOffsetDate(-1 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_AFTER];
case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
date = date.getOffsetDate(1 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_TODAY:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_TODAY];
case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
date = new Date();
_setInnerValue(date, text);
break;
@ -5095,8 +5111,58 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
}
});
BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
BI.DateTrigger.MULTI_DATE_PARAM = 18;
BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DateTrigger.EVENT_START = "EVENT_START";
BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
@ -13801,11 +13867,6 @@ BI.PreviewTable = BI.inherit(BI.Widget, {
populate: function (items, header) {
this.table.populate(items, header);
},
destroy: function () {
this.table.destroy();
BI.PreviewTable.superclass.destroy.apply(this, arguments);
}
});
BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE";
@ -14691,6 +14752,368 @@ BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/**
* 自适应宽度的表格
*
* Created by GUY on 2016/2/3.
* @class BI.ResponisveTable
* @extends BI.Widget
*/
BI.ResponisveTable = BI.inherit(BI.Widget, {
_const: {
perColumnSize: 100
},
_defaultConfig: function () {
return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-responsive-table",
isNeedFreeze: false,//是否需要冻结单元格
freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
isNeedMerge: false,//是否需要合并单元格
mergeCols: [], //合并的单元格列号
mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
return BI.isEqual(row1, row2);
},
columnSize: [],
headerRowSize: 25,
footerRowSize: 25,
rowSize: 25,
regionColumnSize: false,
header: [],
footer: false,
items: [], //二维数组
//交叉表头
crossHeader: [],
crossItems: []
});
},
_init: function () {
BI.ResponisveTable.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.table = BI.createWidget({
type: "bi.table_view",
element: this,
isNeedFreeze: o.isNeedFreeze,
freezeCols: o.freezeCols,
isNeedMerge: o.isNeedMerge,
mergeCols: o.mergeCols,
mergeRule: o.mergeRule,
columnSize: o.columnSize,
headerRowSize: o.headerRowSize,
footerRowSize: o.footerRowSize,
rowSize: o.rowSize,
regionColumnSize: o.regionColumnSize,
header: o.header,
footer: o.footer,
items: o.items,
//交叉表头
crossHeader: o.crossHeader,
crossItems: o.crossItems
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
self._initRegionSize();
self.table.resize();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
self._resizeRegion();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () {
self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () {
//important:在冻结并自适应列宽的情况下要随时变更表头宽度
if (o.isNeedResize === true && self._isAdaptiveColumn()) {
self._resizeHeader();
}
self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () {
self._resizeBody();
self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () {
self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
self._resizeRegion();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
});
},
_initRegionSize: function () {
var o = this.options;
if (o.isNeedFreeze === true) {
var regionColumnSize = this.table.getRegionColumnSize();
var maxWidth = this.table.element.width();
if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) {
var freezeCols = o.freezeCols;
if (freezeCols.length === 0) {
this.table.setRegionColumnSize([0, "fill"]);
} else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) {
var size = maxWidth / 3;
if (freezeCols.length > o.columnSize.length / 2) {
size = maxWidth * 2 / 3;
}
this.table.setRegionColumnSize([size, "fill"]);
} else {
this.table.setRegionColumnSize(["fill", 0]);
}
}
}
},
_getBlockSize: function () {
var o = this.options;
var columnSize = this.table.getCalculateColumnSize();
if (o.isNeedFreeze === true) {
var columnSizeLeft = [], columnSizeRight = [];
BI.each(columnSize, function (i, size) {
if (o.freezeCols.contains(i)) {
columnSizeLeft.push(size);
} else {
columnSizeRight.push(size);
}
});
//因为有边框,所以加上数组长度的参数调整
var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, sumRight = BI.sum(columnSizeRight) + columnSizeRight.length;
return {
sumLeft: sumLeft,
sumRight: sumRight,
left: columnSizeLeft,
right: columnSizeRight
}
}
return {
size: columnSize,
sum: BI.sum(columnSize) + columnSize.length
};
},
_isAdaptiveColumn: function (columnSize) {
return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05);
},
_resizeHeader: function () {
var self = this, o = this.options;
if (o.isNeedFreeze === true) {
//若是当前处于自适应调节阶段
if (this._isAdaptiveColumn()) {
var columnSize = this.table.getCalculateColumnSize();
this.table.setHeaderColumnSize(columnSize);
} else {
var regionColumnSize = this.table.getClientRegionColumnSize();
var block = this._getBlockSize();
var sumLeft = block.sumLeft, sumRight = block.sumRight;
var columnSizeLeft = block.left, columnSizeRight = block.right;
columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft;
columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight;
var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight);
newLeft[newLeft.length - 1] = "";
newRight[newRight.length - 1] = "";
this.table.setColumnSize(newLeft.concat(newRight));
block = self._getBlockSize();
if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) {
columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]
}
if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) {
columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]
}
self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight));
}
} else {
if (!this._isAdaptiveColumn()) {
var regionColumnSize = this.table.getClientRegionColumnSize();
var block = this._getBlockSize();
var sum = block.sum;
var size = block.size;
size[size.length - 1] += regionColumnSize[0] - sum;
var newSize = BI.clone(size);
newSize[newSize.length - 1] = "";
this.table.setColumnSize(newSize);
block = this._getBlockSize();
if (size[size.length - 1] < block.size[block.size.length - 1]) {
size[size.length - 1] = block.size[block.size.length - 1]
}
this.table.setColumnSize(size);
}
}
},
_resizeBody: function () {
if (this._isAdaptiveColumn()) {
var columnSize = this.table.getCalculateColumnSize();
this.setColumnSize(columnSize);
}
},
_adjustRegion: function () {
var o = this.options;
var regionColumnSize = this.table.getCalculateRegionColumnSize();
if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
var block = this._getBlockSize();
var sumLeft = block.sumLeft, sumRight = block.sumRight;
if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) {
this.table.setRegionColumnSize([sumLeft, "fill"]);
}
this._resizeRegion();
}
},
_resizeRegion: function () {
var o = this.options;
var regionColumnSize = this.table.getCalculateRegionColumnSize();
if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
var maxWidth = this.table.element.width();
if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) {
var freezeCols = o.freezeCols;
var size = maxWidth / 3;
if (freezeCols.length > o.columnSize.length / 2) {
size = maxWidth * 2 / 3;
}
this.table.setRegionColumnSize([size, "fill"]);
}
}
},
resize: function () {
this.table.resize();
this._resizeRegion();
this._resizeHeader();
},
setColumnSize: function (columnSize) {
this.table.setColumnSize(columnSize);
this._adjustRegion();
this._resizeHeader();
},
getColumnSize: function () {
return this.table.getColumnSize();
},
getCalculateColumnSize: function () {
return this.table.getCalculateColumnSize();
},
setHeaderColumnSize: function (columnSize) {
this.table.setHeaderColumnSize(columnSize);
this._adjustRegion();
this._resizeHeader();
},
setRegionColumnSize: function (columnSize) {
this.table.setRegionColumnSize(columnSize);
this._resizeHeader();
},
getRegionColumnSize: function () {
return this.table.getRegionColumnSize();
},
getCalculateRegionColumnSize: function () {
return this.table.getCalculateRegionColumnSize();
},
getCalculateRegionRowSize: function () {
return this.table.getCalculateRegionRowSize();
},
getClientRegionColumnSize: function () {
return this.table.getClientRegionColumnSize();
},
getScrollRegionColumnSize: function () {
return this.table.getScrollRegionColumnSize();
},
getScrollRegionRowSize: function () {
return this.table.getScrollRegionRowSize();
},
hasVerticalScroll: function () {
return this.table.hasVerticalScroll();
},
setVerticalScroll: function (scrollTop) {
this.table.setVerticalScroll(scrollTop);
},
setLeftHorizontalScroll: function (scrollLeft) {
this.table.setLeftHorizontalScroll(scrollLeft);
},
setRightHorizontalScroll: function (scrollLeft) {
this.table.setRightHorizontalScroll(scrollLeft);
},
getVerticalScroll: function () {
return this.table.getVerticalScroll();
},
getLeftHorizontalScroll: function () {
return this.table.getLeftHorizontalScroll();
},
getRightHorizontalScroll: function () {
return this.table.getRightHorizontalScroll();
},
getColumns: function () {
return this.table.getColumns();
},
attr: function () {
BI.ResponisveTable.superclass.attr.apply(this, arguments);
this.table.attr.apply(this.table, arguments);
},
populate: function (items) {
var self = this, o = this.options;
this.table.populate.apply(this.table, arguments);
if (o.isNeedFreeze === true) {
BI.nextTick(function () {
if (self.element.is(":visible")) {
self._initRegionSize();
self.table.resize();
self._resizeHeader();
}
});
}
}
});
BI.shortcut('bi.responsive_table', BI.ResponisveTable);/**
* 加号表示的组节点
* Created by GUY on 2015/9/6.
* @class BI.SelectTreeFirstPlusGroupNode

12
demo/js/config/widget.js

@ -1,6 +1,18 @@
Demo.WIDGET_CONFIG = [{
id: 4,
text: "详细控件"
}, {
id: 401,
pId: 4,
text: "table"
}, {
pId: 401,
text: "bi.preview_table",
value: "demo.preview_table"
}, {
pId: 401,
text: "bi.responsive_table",
value: "demo.responsive_table"
}, {
pId: 4,
text: "bi.multi_select_combo",

233
demo/js/widget/table/demo.preview_table.js

@ -0,0 +1,233 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
var items = [[{
text: "第一行第一列"
}, {
text: "第一行第二列"
}, {
text: "第一行第三列"
}], [{
text: "第二行第一列"
}, {
text: "第二行第二列"
}, {
text: "第二行第三列"
}], [{
text: "第二行第一列"
}, {
text: "第三行第二列"
}, {
text: "第三行第三列"
}], [{
text: "第二行第一列"
}, {
text: "第四行第二列"
}, {
text: "第四行第三列"
}], [{
text: "第五行第一列"
}, {
text: "第五行第二列"
}, {
text: "第五行第三列"
}], [{
text: "第六行第一列"
}, {
text: "第六行第二列"
}, {
text: "第六行第三列"
}], [{
text: "第七行第一列"
}, {
text: "第七行第二列"
}, {
text: "第七行第三列"
}], [{
text: "第八行第一列"
}, {
text: "第八行第二列"
}, {
text: "第八行第三列"
}], [{
text: "第九行第一列"
}, {
text: "第九行第二列"
}, {
text: "第九行第三列"
}], [{
text: "第十行第一列"
}, {
text: "第十行第二列"
}, {
text: "第十行第三列"
}], [{
text: "第十一行第一列"
}, {
text: "第十一行第二列"
}, {
text: "第十一行第三列"
}], [{
text: "第十二行第一列"
}, {
text: "第十二行第二列"
}, {
text: "第十二行第三列"
}], [{
text: "第十三行第一列"
}, {
text: "第十三行第二列"
}, {
text: "第十三行第三列"
}], [{
text: "第十四行第一列"
}, {
text: "第十四行第二列"
}, {
text: "第十四行第三列"
}], [{
text: "第十五行第一列"
}, {
text: "第十五行第二列"
}, {
text: "第十五行第三列"
}], [{
text: "第十六行第一列"
}, {
text: "第十六行第二列"
}, {
text: "第十六行第三列"
}], [{
text: "第十七行第一列"
}, {
text: "第十七行第二列"
}, {
text: "第十七行第三列"
}], [{
text: "第十八行第一列"
}, {
text: "第十八行第二列"
}, {
text: "第十八行第三列"
}]];
var header = [[{
text: "表头1"
}, {
text: "表头2"
}, {
text: "表头3"
}]];
var table1 = BI.createWidget({
type: "bi.preview_table",
columnSize: ["", "", ""],
header: header,
items: items
});
var table2 = BI.createWidget({
type: "bi.preview_table",
header: header,
columnSize: [100, "", 50],
items: items
});
var table3 = BI.createWidget({
type: "bi.preview_table",
header: header,
columnSize: [0.2, 0.4, 0.4],
headerRowSize: 30,
items: items
});
var table4 = BI.createWidget({
type: "bi.preview_table",
header: header,
isNeedFreeze: true,
freezeCols: [0, 1],
columnSize: [0.2, "", 0.4],
items: items
});
var table5 = BI.createWidget({
type: "bi.preview_table",
header: header,
isNeedFreeze: true,
freezeCols: [0, 1],
columnSize: [200, 100, ""],
items: items
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.grid",
columns: 3,
rows: 2,
items: [[{
el: {
type: "bi.absolute",
items: [{
el: table1,
left: 5,
right: 5,
top: 5,
bottom: 5
}]
}
}, {
el: {
type: "bi.absolute",
items: [{
el: table2,
left: 5,
right: 5,
top: 5,
bottom: 5
}]
}
}, {
el: {
type: "bi.absolute",
items: [{
el: table3,
left: 5,
right: 5,
top: 5,
bottom: 5
}]
}
}], [{
el: {
type: "bi.absolute",
items: [{
el: table4,
left: 5,
right: 5,
top: 5,
bottom: 5
}]
}
}, {
el: {
type: "bi.absolute",
items: [{
el: table5,
left: 5,
right: 5,
top: 5,
bottom: 5
}]
}
}]]
},
left: 10,
right: 10,
top: 10,
bottom: 10
}]
})
}
});
BI.shortcut("demo.preview_table", Demo.Func);

158
demo/js/widget/table/demo.responsive_table.js

@ -0,0 +1,158 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
var items = [[{
text: "第一行第一列"
}, {
text: "第一行第一列"
}, {
text: "第一行第一列"
}], [{
text: "第一行第一列"
}, {
text: "第一行第一列"
}, {
text: "第一行第一列"
}], [{
text: "第三行第一列"
}, {
text: "第三行第二列"
}, {
text: "第三行第三列"
}], [{
text: "第四行第一列"
}, {
text: "第四行第二列"
}, {
text: "第四行第三列"
}], [{
text: "第五行第一列"
}, {
text: "第五行第二列"
}, {
text: "第五行第三列"
}], [{
text: "第六行第一列"
}, {
text: "第六行第二列"
}, {
text: "第六行第三列"
}], [{
text: "第七行第一列"
}, {
text: "第七行第二列"
}, {
text: "第七行第三列"
}], [{
text: "第八行第一列"
}, {
text: "第八行第二列"
}, {
text: "第八行第三列"
}], [{
text: "第九行第一列"
}, {
text: "第九行第二列"
}, {
text: "第九行第三列"
}], [{
text: "第十行第一列"
}, {
text: "第十行第二列"
}, {
text: "第十行第三列"
}], [{
text: "第十一行第一列"
}, {
text: "第十一行第二列"
}, {
text: "第十一行第三列"
}], [{
text: "第十二行第一列"
}, {
text: "第十二行第二列"
}, {
text: "第十二行第三列"
}], [{
text: "第十三行第一列"
}, {
text: "第十三行第二列"
}, {
text: "第十三行第三列"
}], [{
text: "第十四行第一列"
}, {
text: "第十四行第二列"
}, {
text: "第十四行第三列"
}], [{
text: "第十五行第一列"
}, {
text: "第十五行第二列"
}, {
text: "第十五行第三列"
}], [{
text: "第十六行第一列"
}, {
text: "第十六行第二列"
}, {
text: "第十六行第三列"
}], [{
text: "第十七行第一列"
}, {
text: "第十七行第二列"
}, {
text: "第十七行第三列"
}], [{
text: "第十八行第一列"
}, {
text: "第十八行第二列"
}, {
text: "第十八行第三列"
}]];
var header = [[{
text: "表头1"
}, {
text: "表头2"
}, {
text: "表头3"
}]];
var table1 = BI.createWidget({
type: "bi.responsive_table",
isNeedMerge: true,
isNeedFreeze: true,
mergeCols: [0, 1],
columnSize: ["", "", ""],
items: items,
header: header
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.grid",
columns: 2,
rows: 2,
items: [{
column: 0,
row: 0,
el: table1
}]
},
left: 10,
right: 10,
top: 10,
bottom: 10
}]
})
}
});
BI.shortcut("demo.responsive_table", Demo.Func);

9
dist/base.js vendored

@ -1078,10 +1078,9 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
//如果是一个简单的layout
_isSimpleLayout: function () {
var o = this.options;
return o.layouts.length === 1
return o.layouts.length === 1 && !BI.isArray(o.items[0])
},
doBehavior: function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(this.buttons);
@ -30424,11 +30423,9 @@ BI.Table = BI.inherit(BI.Widget, {
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT);
}
});
BI.Resizers.add(this.getName(), function (e) {
if (BI.isWindow(e.target) && self.element.is(":visible")) {
BI.ResizeDetector.addResizeListener(this, function () {
self._resize();
self.fireEvent(BI.Table.EVENT_TABLE_RESIZE);
}
});
},
@ -30810,6 +30807,7 @@ BI.Table = BI.inherit(BI.Widget, {
.addClass(c === rows.length - 1 ? "last-col" : "");
var w = BI.createWidget(map[r][c], {
type: "bi.table_cell",
root: true,
textAlign: "left",
width: BI.isNumeric(width) ? width : "",
height: BI.isNumeric(height) ? height : "",
@ -30889,6 +30887,7 @@ BI.Table = BI.inherit(BI.Widget, {
return this.footer;
},
_createBody: function () {
var self = this, o = this.options;
this.body = this._body();

128
dist/core.css vendored

@ -1,131 +1,3 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
@charset "UTF-8";
/*!
* animate.css -http://daneden.me/animate

182
dist/core.js vendored

@ -11189,6 +11189,10 @@ BI.Factory = {
return this;
},
un: function () {
this.off.apply(this, arguments);
},
// Trigger one or many events, firing all bound callbacks. Callbacks are
// passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to
@ -11204,6 +11208,10 @@ BI.Factory = {
return this;
},
fireEvent: function () {
this.trigger.apply(this, arguments);
},
// Inversion-of-control versions of `on` and `once`. Tell *this* object to
// listen to an event in another object ... keeping track of what it's
// listening to.
@ -11290,11 +11298,21 @@ BI.Factory = {
var triggerEvents = function (events, args) {
var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
switch (args.length) {
case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
case 0:
while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
return;
case 2:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
return;
case 3:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
return;
default:
while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
return;
}
};
@ -11345,10 +11363,17 @@ BI.Factory = {
// CouchDB users may want to set this to `"_id"`.
idAttribute: 'ID',
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
init: function () {
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
this.init();
},
// Return a copy of the model's `attributes` object.
toJSON: function (options) {
@ -11711,12 +11736,15 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// The JSON representation of a Collection is an array of the
// models' attributes.
toJSON: function (options) {
return this.map(function(model){ return model.toJSON(options); });
return this.map(function (model) {
return model.toJSON(options);
});
},
// Proxy `BI.sync` by default.
@ -12140,18 +12168,23 @@ BI.Factory = {
return this.$el.find(selector);
},
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
//容器,默认放在this.element上
_vessel: function(){return this.element},
_vessel: function () {
return this
},
// **render** is the core function that your view should override, in order
// to populate its element (`this.el`), with the appropriate HTML. The
// convention is for **render** to always return `this`.
_render: function(vessel) {
render: function (vessel) {
return this;
},
@ -12178,8 +12211,8 @@ BI.Factory = {
setElement: function (element) {
this.undelegateEvents();
this._setElement(element);
this.$vessel = this._vessel();
this._render(this.$vessel);
this.vessel = this._vessel();
this.render(this.vessel);
this.delegateEvents();
return this;
},
@ -12246,21 +12279,21 @@ BI.Factory = {
// using `selector`). This only works for delegate-able events: not `focus`,
// `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
delegate: function (eventName, selector, listener) {
this.$vessel.on(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Clears all callbacks previously bound to the view by `delegateEvents`.
// You usually don't need to use this, but may wish to if you have multiple
// BI views attached to the same DOM element.
undelegateEvents: function () {
if (this.$vessel) this.$vessel.off('.delegateEvents' + this.cid);
if (this.vessel) this.vessel.element.off('.delegateEvents' + this.cid);
return this;
},
// A finer-grained `undelegateEvents` for removing a single delegated event.
// `selector` and `listener` are both optional.
undelegate: function (eventName, selector, listener) {
this.$vessel.off(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Produces a DOM element to be assigned to your view. Exposed for
@ -12410,7 +12443,8 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// Manually bind a single named route to a callback. For example:
//
@ -12782,7 +12816,9 @@ BI.Factory = {
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){ return parent.apply(this, arguments); };
child = function () {
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function, if supplied.
@ -12790,7 +12826,9 @@ BI.Factory = {
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
var Surrogate = function(){ this.constructor = child; };
var Surrogate = function () {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate;
@ -14175,8 +14213,7 @@ BI.OB = function (config) {
};
$.extend(BI.OB.prototype, {
props: {},
init: function () {
},
init: null,
_defaultConfig: function (config) {
return {};
@ -14184,7 +14221,7 @@ $.extend(BI.OB.prototype, {
_init: function () {
this._initListeners();
this.init();
this.init && this.init();
},
_initListeners: function () {
@ -14307,6 +14344,7 @@ $.extend(BI.OB.prototype, {
BI.Widget = BI.inherit(BI.OB, {
_defaultConfig: function () {
return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
@ -14322,41 +14360,30 @@ BI.Widget = BI.inherit(BI.OB, {
},
//生命周期函数
beforeCreate: function () {
},
created: function () {
},
beforeCreate: null,
render: function () {
created: null,
},
render: null,
beforeMounted: function () {
beforeMounted: null,
},
mounted: function () {
},
mounted: null,
update: null,
destroyed: function () {
},
destroyed: null,
_init: function () {
BI.Widget.superclass._init.apply(this, arguments);
this.beforeCreate();
this.beforeCreate && this.beforeCreate();
this._initRoot();
this._initElementWidth();
this._initElementHeight();
this._initVisualEffects();
this._initState();
this._initElement();
this.created();
this.created && this.created();
},
/**
@ -14366,6 +14393,7 @@ BI.Widget = BI.inherit(BI.OB, {
_initRoot: function () {
var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget");
this._isRoot = o.root;
if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) {
this._parent = o.element;
@ -14429,7 +14457,7 @@ BI.Widget = BI.inherit(BI.OB, {
_initElement: function () {
var self = this;
var els = this.render();
var els = this.render && this.render();
if (BI.isPlainObject(els)) {
els = [els];
}
@ -14463,13 +14491,13 @@ BI.Widget = BI.inherit(BI.OB, {
if (!isMounted) {
return;
}
this.beforeMounted();
this.beforeMounted && this.beforeMounted();
this._isMounted = true;
this._mountChildren();
BI.each(this._children, function (i, widget) {
widget._mount && widget._mount();
});
this.mounted();
this.mounted && this.mounted();
},
_mountChildren: function () {
@ -14495,7 +14523,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed();
this.destroyed && this.destroyed();
},
setWidth: function (w) {
@ -14557,6 +14585,9 @@ BI.Widget = BI.inherit(BI.OB, {
widget = name;
name = widget.getName();
}
if (BI.isKey(name)) {
name = name + "";
}
name = name || widget.getName() || BI.uniqueId("widget");
if (this._children[name]) {
throw new Error("name has already been existed");
@ -14682,7 +14713,7 @@ BI.Widget = BI.inherit(BI.OB, {
empty: function () {
BI.each(this._children, function (i, widget) {
widget._unMount();
widget._unMount && widget._unMount();
});
this._children = {};
this.element.empty();
@ -14695,7 +14726,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed();
this.destroyed && this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this.purgeListeners();
@ -15291,10 +15322,10 @@ BI.View = BI.inherit(BI.V, {
});
var vessel = BI.createWidget();
this._cardLayouts[this.getName()].addCardByName(this.getName(), vessel);
return vessel.element;
return vessel;
},
_render: function (vessel) {
render: function (vessel) {
return this;
},
@ -15662,15 +15693,26 @@ BI.View = BI.inherit(BI.V, {
},
_unMount: function () {
BI.each(this._cardLayouts, function (name, card) {
card && card._unMount();
});
delete this._cardLayouts;
delete this._cards;
this.off();
this.destroyed();
},
destroy: function () {
BI.each(this._cardLayouts, function (name, card) {
card && card.destroy();
card && card._unMount();
});
delete this._cardLayouts;
delete this._cards;
this.destroyed();
this.remove();
this.trigger(BI.Events.DESTROY);
this.destroyed();
this.off();
},
destroyed: function () {
@ -19651,9 +19693,8 @@ BI.Layout = BI.inherit(BI.Widget, {
removeIndex = nameOrWidget;
}
if (removeIndex) {
this.options.items.splice(removeIndex, 1);
this._removeItemAt(removeIndex | 0);
}
BI.Layout.superclass.removeWidget.apply(this, arguments);
},
empty: function () {
@ -19809,7 +19850,14 @@ BI.PopoverSection = BI.inherit(BI.Widget, {
}
});
BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";BI.cjkEncode = function (text) {
BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
return result;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') {
return text;
@ -19943,12 +19991,12 @@ BI.jsonEncode = function (o) {
};
BI.contentFormat = function (cv, fmt) {
if (BI.isEmpty(cv)) {
if (isEmpty(cv)) {
//原值为空,返回空字符
return '';
}
var text = cv.toString();
if (BI.isEmpty(fmt)) {
if (isEmpty(fmt)) {
//格式为空,返回原字符
return text;
}
@ -20157,7 +20205,7 @@ BI._dealWithRight = function (tright, fright) {
var c = tright.charAt(j);
switch (ch) {
case '0':
if (BI.isEmpty(c)) {
if (isEmpty(c)) {
c = '0';
}
right += c;
@ -20174,7 +20222,7 @@ BI._dealWithRight = function (tright, fright) {
}
var rll = tright.substr(j);
var result = {};
if (!BI.isEmpty(rll) && rll.charAt(0) > 4) {
if (!isEmpty(rll) && rll.charAt(0) > 4) {
//有多余字符,需要四舍五入
result.leftPlus = true;
var numReg = right.match(/^[0-9]+/);
@ -20228,7 +20276,7 @@ BI._dealWithLeft = function (tleft, fleft) {
var c = tleft.charAt(j);
switch (ch) {
case '0':
if (BI.isEmpty(c)) {
if (isEmpty(c)) {
c = '0';
}
last = -1;
@ -20241,7 +20289,7 @@ BI._dealWithLeft = function (tleft, fleft) {
j--;
break;
case ',':
if (!BI.isEmpty(c)) {
if (!isEmpty(c)) {
//计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/);
if (com) {
@ -20270,7 +20318,7 @@ BI._dealWithLeft = function (tleft, fleft) {
newstr = res.substr(n, combo) + ',' + newstr;
}
var lres = res.substr(0, n + combo);
if (!BI.isEmpty(lres)) {
if (!isEmpty(lres)) {
newstr = lres + ',' + newstr;
}
}
@ -20399,7 +20447,9 @@ BI._eFormat = function (text, fmt) {
}
}
return text;
};/**
};
})();
/**
* guy
*
* @class BI.HighlightBehavior
@ -25719,7 +25769,7 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
element: this,
items: [this.left]
});
this.removeWidget(this.container.getName());
this.removeWidget(this.container);
},
stroke: function (items) {
@ -25782,7 +25832,7 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
element: this,
items: [this.left]
});
this.removeWidget(this.container.getName());
this.removeWidget(this.container);
},
_addElement: function (i, item) {

8
dist/widget.css vendored

@ -632,6 +632,14 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-sequence-table-dynamic-number .sequence-table-title-cell {
overflow: hidden;
overflow-x: hidden;

521
dist/widget.js vendored

@ -419,8 +419,10 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
if (o.isNeedResizeContainer) {
var isResizing = false;
var needEnd = false;
var height;
var interval;
var startSize;
var resize = function (e, ui) {
if (isResizing) {
return;
@ -442,20 +444,26 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
minHeight: 20,
helper: "bi-resizer",
autoHide: true,
start: function (e, ui) {
startSize = BI.clone(ui.size);
},
resize: function (e, ui) {
if (ui.size.height >= self.arrangement.container.element.height()) {
if (ui.size.height >= startSize.height - 10) {
resize(e, ui);
} else {
interval && clearInterval(interval);
needEnd = true;
}
},
stop: function (e, ui) {
var size = ui.size;
if (isResizing) {
if (isResizing && !needEnd) {
size.height = height;
}
self.arrangement.setContainerSize(ui.size);
needEnd = false;
isResizing = false;
startSize = null;
interval && clearInterval(interval);
self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
}
@ -484,17 +492,21 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
return this.arrangement._isEqual.apply(this.arrangement, arguments);
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
_setSelect: function (item) {
if (!item.element.hasClass("selected")) {
item.element.css("zIndex", ++self.zIndex);
BI.each(self.getAllRegions(), function (i, region) {
item.element.css("zIndex", ++this.zIndex);
BI.each(this.getAllRegions(), function (i, region) {
region.el.element.removeClass("selected");
});
item.element.addClass("selected");
}
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
self._setSelect(item)
});
o.resizable && item.element.resizable({
handles: "e, s, se",
@ -663,6 +675,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
addRegion: function (region, position) {
this._initResizable(region.el);
this._setSelect(region.el);
var self = this, flag;
var old = this.arrangement.getAllRegions();
if (BI.isNotNull(this.position)) {
@ -4892,6 +4905,9 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.DateTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.DateTrigger.EVENT_VALID);
});
@ -4907,7 +4923,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
if (BI.isNotEmptyString(value)) {
var date = value.split("-");
self.store_value = {
type: BICst.MULTI_DATE_CALENDAR,
type: BI.DateTrigger.MULTI_DATE_CALENDAR,
value:{
year: date[0] | 0,
month: date[1] - 1,
@ -4975,7 +4991,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
var date = new Date();
this.store_value = v;
if (BI.isNotNull(v)) {
type = v.type || BICst.MULTI_DATE_CALENDAR; value = v.value;
type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
if(BI.isNull(value)){
value = v;
}
@ -4987,88 +5003,88 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
self.setTitle(text + ":" + dateStr);
};
switch (type) {
case BICst.MULTI_DATE_YEAR_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_PREV];
case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_AFTER];
case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_BEGIN];
case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
date = new Date(date.getFullYear(), 0, 1);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_END];
case BI.DateTrigger.MULTI_DATE_YEAR_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
date = new Date(date.getFullYear(), 11, 31);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_PREV];
case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
date = new Date().getBeforeMulQuarter(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_AFTER];
case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
date = new Date().getAfterMulQuarter(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_BEGIN];
case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
date = new Date().getQuarterStartDate();
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_END];
case BI.DateTrigger.MULTI_DATE_QUARTER_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
date = new Date().getQuarterEndDate();
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_PREV];
case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
date = new Date().getBeforeMultiMonth(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_AFTER];
case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
date = new Date().getAfterMultiMonth(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_BEGIN];
case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
date = new Date(date.getFullYear(), date.getMonth(), 1);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_END];
case BI.DateTrigger.MULTI_DATE_MONTH_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_WEEK_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_PREV];
case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
date = date.getOffsetDate(-7 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_WEEK_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_AFTER];
case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
date = date.getOffsetDate(7 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_PREV];
case BI.DateTrigger.MULTI_DATE_DAY_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
date = date.getOffsetDate(-1 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_AFTER];
case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
date = date.getOffsetDate(1 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_TODAY:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_TODAY];
case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
date = new Date();
_setInnerValue(date, text);
break;
@ -5095,8 +5111,58 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
}
});
BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
BI.DateTrigger.MULTI_DATE_PARAM = 18;
BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DateTrigger.EVENT_START = "EVENT_START";
BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.DateTrigger.EVENT_VALID = "EVENT_VALID";
@ -13801,11 +13867,6 @@ BI.PreviewTable = BI.inherit(BI.Widget, {
populate: function (items, header) {
this.table.populate(items, header);
},
destroy: function () {
this.table.destroy();
BI.PreviewTable.superclass.destroy.apply(this, arguments);
}
});
BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE";
@ -14691,6 +14752,368 @@ BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN";
BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT";
BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW";
BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/**
* 自适应宽度的表格
*
* Created by GUY on 2016/2/3.
* @class BI.ResponisveTable
* @extends BI.Widget
*/
BI.ResponisveTable = BI.inherit(BI.Widget, {
_const: {
perColumnSize: 100
},
_defaultConfig: function () {
return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-responsive-table",
isNeedFreeze: false,//是否需要冻结单元格
freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
isNeedMerge: false,//是否需要合并单元格
mergeCols: [], //合并的单元格列号
mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
return BI.isEqual(row1, row2);
},
columnSize: [],
headerRowSize: 25,
footerRowSize: 25,
rowSize: 25,
regionColumnSize: false,
header: [],
footer: false,
items: [], //二维数组
//交叉表头
crossHeader: [],
crossItems: []
});
},
_init: function () {
BI.ResponisveTable.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.table = BI.createWidget({
type: "bi.table_view",
element: this,
isNeedFreeze: o.isNeedFreeze,
freezeCols: o.freezeCols,
isNeedMerge: o.isNeedMerge,
mergeCols: o.mergeCols,
mergeRule: o.mergeRule,
columnSize: o.columnSize,
headerRowSize: o.headerRowSize,
footerRowSize: o.footerRowSize,
rowSize: o.rowSize,
regionColumnSize: o.regionColumnSize,
header: o.header,
footer: o.footer,
items: o.items,
//交叉表头
crossHeader: o.crossHeader,
crossItems: o.crossItems
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
self._initRegionSize();
self.table.resize();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
self._resizeRegion();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () {
self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () {
//important:在冻结并自适应列宽的情况下要随时变更表头宽度
if (o.isNeedResize === true && self._isAdaptiveColumn()) {
self._resizeHeader();
}
self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () {
self._resizeBody();
self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () {
self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
self._resizeRegion();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
});
},
_initRegionSize: function () {
var o = this.options;
if (o.isNeedFreeze === true) {
var regionColumnSize = this.table.getRegionColumnSize();
var maxWidth = this.table.element.width();
if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) {
var freezeCols = o.freezeCols;
if (freezeCols.length === 0) {
this.table.setRegionColumnSize([0, "fill"]);
} else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) {
var size = maxWidth / 3;
if (freezeCols.length > o.columnSize.length / 2) {
size = maxWidth * 2 / 3;
}
this.table.setRegionColumnSize([size, "fill"]);
} else {
this.table.setRegionColumnSize(["fill", 0]);
}
}
}
},
_getBlockSize: function () {
var o = this.options;
var columnSize = this.table.getCalculateColumnSize();
if (o.isNeedFreeze === true) {
var columnSizeLeft = [], columnSizeRight = [];
BI.each(columnSize, function (i, size) {
if (o.freezeCols.contains(i)) {
columnSizeLeft.push(size);
} else {
columnSizeRight.push(size);
}
});
//因为有边框,所以加上数组长度的参数调整
var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, sumRight = BI.sum(columnSizeRight) + columnSizeRight.length;
return {
sumLeft: sumLeft,
sumRight: sumRight,
left: columnSizeLeft,
right: columnSizeRight
}
}
return {
size: columnSize,
sum: BI.sum(columnSize) + columnSize.length
};
},
_isAdaptiveColumn: function (columnSize) {
return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05);
},
_resizeHeader: function () {
var self = this, o = this.options;
if (o.isNeedFreeze === true) {
//若是当前处于自适应调节阶段
if (this._isAdaptiveColumn()) {
var columnSize = this.table.getCalculateColumnSize();
this.table.setHeaderColumnSize(columnSize);
} else {
var regionColumnSize = this.table.getClientRegionColumnSize();
var block = this._getBlockSize();
var sumLeft = block.sumLeft, sumRight = block.sumRight;
var columnSizeLeft = block.left, columnSizeRight = block.right;
columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft;
columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight;
var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight);
newLeft[newLeft.length - 1] = "";
newRight[newRight.length - 1] = "";
this.table.setColumnSize(newLeft.concat(newRight));
block = self._getBlockSize();
if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) {
columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]
}
if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) {
columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]
}
self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight));
}
} else {
if (!this._isAdaptiveColumn()) {
var regionColumnSize = this.table.getClientRegionColumnSize();
var block = this._getBlockSize();
var sum = block.sum;
var size = block.size;
size[size.length - 1] += regionColumnSize[0] - sum;
var newSize = BI.clone(size);
newSize[newSize.length - 1] = "";
this.table.setColumnSize(newSize);
block = this._getBlockSize();
if (size[size.length - 1] < block.size[block.size.length - 1]) {
size[size.length - 1] = block.size[block.size.length - 1]
}
this.table.setColumnSize(size);
}
}
},
_resizeBody: function () {
if (this._isAdaptiveColumn()) {
var columnSize = this.table.getCalculateColumnSize();
this.setColumnSize(columnSize);
}
},
_adjustRegion: function () {
var o = this.options;
var regionColumnSize = this.table.getCalculateRegionColumnSize();
if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
var block = this._getBlockSize();
var sumLeft = block.sumLeft, sumRight = block.sumRight;
if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) {
this.table.setRegionColumnSize([sumLeft, "fill"]);
}
this._resizeRegion();
}
},
_resizeRegion: function () {
var o = this.options;
var regionColumnSize = this.table.getCalculateRegionColumnSize();
if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
var maxWidth = this.table.element.width();
if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) {
var freezeCols = o.freezeCols;
var size = maxWidth / 3;
if (freezeCols.length > o.columnSize.length / 2) {
size = maxWidth * 2 / 3;
}
this.table.setRegionColumnSize([size, "fill"]);
}
}
},
resize: function () {
this.table.resize();
this._resizeRegion();
this._resizeHeader();
},
setColumnSize: function (columnSize) {
this.table.setColumnSize(columnSize);
this._adjustRegion();
this._resizeHeader();
},
getColumnSize: function () {
return this.table.getColumnSize();
},
getCalculateColumnSize: function () {
return this.table.getCalculateColumnSize();
},
setHeaderColumnSize: function (columnSize) {
this.table.setHeaderColumnSize(columnSize);
this._adjustRegion();
this._resizeHeader();
},
setRegionColumnSize: function (columnSize) {
this.table.setRegionColumnSize(columnSize);
this._resizeHeader();
},
getRegionColumnSize: function () {
return this.table.getRegionColumnSize();
},
getCalculateRegionColumnSize: function () {
return this.table.getCalculateRegionColumnSize();
},
getCalculateRegionRowSize: function () {
return this.table.getCalculateRegionRowSize();
},
getClientRegionColumnSize: function () {
return this.table.getClientRegionColumnSize();
},
getScrollRegionColumnSize: function () {
return this.table.getScrollRegionColumnSize();
},
getScrollRegionRowSize: function () {
return this.table.getScrollRegionRowSize();
},
hasVerticalScroll: function () {
return this.table.hasVerticalScroll();
},
setVerticalScroll: function (scrollTop) {
this.table.setVerticalScroll(scrollTop);
},
setLeftHorizontalScroll: function (scrollLeft) {
this.table.setLeftHorizontalScroll(scrollLeft);
},
setRightHorizontalScroll: function (scrollLeft) {
this.table.setRightHorizontalScroll(scrollLeft);
},
getVerticalScroll: function () {
return this.table.getVerticalScroll();
},
getLeftHorizontalScroll: function () {
return this.table.getLeftHorizontalScroll();
},
getRightHorizontalScroll: function () {
return this.table.getRightHorizontalScroll();
},
getColumns: function () {
return this.table.getColumns();
},
attr: function () {
BI.ResponisveTable.superclass.attr.apply(this, arguments);
this.table.attr.apply(this.table, arguments);
},
populate: function (items) {
var self = this, o = this.options;
this.table.populate.apply(this.table, arguments);
if (o.isNeedFreeze === true) {
BI.nextTick(function () {
if (self.element.is(":visible")) {
self._initRegionSize();
self.table.resize();
self._resizeHeader();
}
});
}
}
});
BI.shortcut('bi.responsive_table', BI.ResponisveTable);/**
* 加号表示的组节点
* Created by GUY on 2015/9/6.
* @class BI.SelectTreeFirstPlusGroupNode

3
src/base/combination/group.button.js

@ -115,10 +115,9 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
//如果是一个简单的layout
_isSimpleLayout: function () {
var o = this.options;
return o.layouts.length === 1
return o.layouts.length === 1 && !BI.isArray(o.items[0])
},
doBehavior: function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(this.buttons);

6
src/base/table/table.js

@ -359,11 +359,9 @@ BI.Table = BI.inherit(BI.Widget, {
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT);
}
});
BI.Resizers.add(this.getName(), function (e) {
if (BI.isWindow(e.target) && self.element.is(":visible")) {
BI.ResizeDetector.addResizeListener(this, function () {
self._resize();
self.fireEvent(BI.Table.EVENT_TABLE_RESIZE);
}
});
},
@ -745,6 +743,7 @@ BI.Table = BI.inherit(BI.Widget, {
.addClass(c === rows.length - 1 ? "last-col" : "");
var w = BI.createWidget(map[r][c], {
type: "bi.table_cell",
root: true,
textAlign: "left",
width: BI.isNumeric(width) ? width : "",
height: BI.isNumeric(height) ? height : "",
@ -824,6 +823,7 @@ BI.Table = BI.inherit(BI.Widget, {
return this.footer;
},
_createBody: function () {
var self = this, o = this.options;
this.body = this._body();

22
src/core/alias.js

@ -1,3 +1,10 @@
;(function () {
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
return result;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') {
@ -132,12 +139,12 @@ BI.jsonEncode = function (o) {
};
BI.contentFormat = function (cv, fmt) {
if (BI.isEmpty(cv)) {
if (isEmpty(cv)) {
//原值为空,返回空字符
return '';
}
var text = cv.toString();
if (BI.isEmpty(fmt)) {
if (isEmpty(fmt)) {
//格式为空,返回原字符
return text;
}
@ -346,7 +353,7 @@ BI._dealWithRight = function (tright, fright) {
var c = tright.charAt(j);
switch (ch) {
case '0':
if (BI.isEmpty(c)) {
if (isEmpty(c)) {
c = '0';
}
right += c;
@ -363,7 +370,7 @@ BI._dealWithRight = function (tright, fright) {
}
var rll = tright.substr(j);
var result = {};
if (!BI.isEmpty(rll) && rll.charAt(0) > 4) {
if (!isEmpty(rll) && rll.charAt(0) > 4) {
//有多余字符,需要四舍五入
result.leftPlus = true;
var numReg = right.match(/^[0-9]+/);
@ -417,7 +424,7 @@ BI._dealWithLeft = function (tleft, fleft) {
var c = tleft.charAt(j);
switch (ch) {
case '0':
if (BI.isEmpty(c)) {
if (isEmpty(c)) {
c = '0';
}
last = -1;
@ -430,7 +437,7 @@ BI._dealWithLeft = function (tleft, fleft) {
j--;
break;
case ',':
if (!BI.isEmpty(c)) {
if (!isEmpty(c)) {
//计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/);
if (com) {
@ -459,7 +466,7 @@ BI._dealWithLeft = function (tleft, fleft) {
newstr = res.substr(n, combo) + ',' + newstr;
}
var lres = res.substr(0, n + combo);
if (!BI.isEmpty(lres)) {
if (!isEmpty(lres)) {
newstr = lres + ',' + newstr;
}
}
@ -589,3 +596,4 @@ BI._eFormat = function (text, fmt) {
}
return text;
};
})();

80
src/core/mvc/fbi.js

@ -122,6 +122,10 @@
return this;
},
un: function () {
this.off.apply(this, arguments);
},
// Trigger one or many events, firing all bound callbacks. Callbacks are
// passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to
@ -137,6 +141,10 @@
return this;
},
fireEvent: function () {
this.trigger.apply(this, arguments);
},
// Inversion-of-control versions of `on` and `once`. Tell *this* object to
// listen to an event in another object ... keeping track of what it's
// listening to.
@ -223,11 +231,21 @@
var triggerEvents = function (events, args) {
var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
switch (args.length) {
case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
case 0:
while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
return;
case 2:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
return;
case 3:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
return;
default:
while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
return;
}
};
@ -278,10 +296,17 @@
// CouchDB users may want to set this to `"_id"`.
idAttribute: 'ID',
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
init: function () {
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
this.init();
},
// Return a copy of the model's `attributes` object.
toJSON: function (options) {
@ -644,12 +669,15 @@
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// The JSON representation of a Collection is an array of the
// models' attributes.
toJSON: function (options) {
return this.map(function(model){ return model.toJSON(options); });
return this.map(function (model) {
return model.toJSON(options);
});
},
// Proxy `BI.sync` by default.
@ -1073,18 +1101,23 @@
return this.$el.find(selector);
},
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
//容器,默认放在this.element上
_vessel: function(){return this.element},
_vessel: function () {
return this
},
// **render** is the core function that your view should override, in order
// to populate its element (`this.el`), with the appropriate HTML. The
// convention is for **render** to always return `this`.
_render: function(vessel) {
render: function (vessel) {
return this;
},
@ -1111,8 +1144,8 @@
setElement: function (element) {
this.undelegateEvents();
this._setElement(element);
this.$vessel = this._vessel();
this._render(this.$vessel);
this.vessel = this._vessel();
this.render(this.vessel);
this.delegateEvents();
return this;
},
@ -1179,21 +1212,21 @@
// using `selector`). This only works for delegate-able events: not `focus`,
// `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
delegate: function (eventName, selector, listener) {
this.$vessel.on(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Clears all callbacks previously bound to the view by `delegateEvents`.
// You usually don't need to use this, but may wish to if you have multiple
// BI views attached to the same DOM element.
undelegateEvents: function () {
if (this.$vessel) this.$vessel.off('.delegateEvents' + this.cid);
if (this.vessel) this.vessel.element.off('.delegateEvents' + this.cid);
return this;
},
// A finer-grained `undelegateEvents` for removing a single delegated event.
// `selector` and `listener` are both optional.
undelegate: function (eventName, selector, listener) {
this.$vessel.off(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Produces a DOM element to be assigned to your view. Exposed for
@ -1343,7 +1376,8 @@
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// Manually bind a single named route to a callback. For example:
//
@ -1715,7 +1749,9 @@
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){ return parent.apply(this, arguments); };
child = function () {
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function, if supplied.
@ -1723,7 +1759,9 @@
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
var Surrogate = function(){ this.constructor = child; };
var Surrogate = function () {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate;

5
src/core/ob.js

@ -14,8 +14,7 @@ BI.OB = function (config) {
};
$.extend(BI.OB.prototype, {
props: {},
init: function () {
},
init: null,
_defaultConfig: function (config) {
return {};
@ -23,7 +22,7 @@ $.extend(BI.OB.prototype, {
_init: function () {
this._initListeners();
this.init();
this.init && this.init();
},
_initListeners: function () {

19
src/core/view.js

@ -130,10 +130,10 @@ BI.View = BI.inherit(BI.V, {
});
var vessel = BI.createWidget();
this._cardLayouts[this.getName()].addCardByName(this.getName(), vessel);
return vessel.element;
return vessel;
},
_render: function (vessel) {
render: function (vessel) {
return this;
},
@ -501,15 +501,26 @@ BI.View = BI.inherit(BI.V, {
},
_unMount: function () {
BI.each(this._cardLayouts, function (name, card) {
card && card._unMount();
});
delete this._cardLayouts;
delete this._cards;
this.off();
this.destroyed();
},
destroy: function () {
BI.each(this._cardLayouts, function (name, card) {
card && card.destroy();
card && card._unMount();
});
delete this._cardLayouts;
delete this._cards;
this.destroyed();
this.remove();
this.trigger(BI.Events.DESTROY);
this.destroyed();
this.off();
},
destroyed: function () {

44
src/core/widget.js

@ -8,6 +8,7 @@
BI.Widget = BI.inherit(BI.OB, {
_defaultConfig: function () {
return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), {
root: false,
tagName: "div",
attributes: null,
data: null,
@ -23,41 +24,30 @@ BI.Widget = BI.inherit(BI.OB, {
},
//生命周期函数
beforeCreate: function () {
beforeCreate: null,
},
created: function () {
},
render: function () {
},
created: null,
beforeMounted: function () {
render: null,
},
mounted: function () {
beforeMounted: null,
},
mounted: null,
update: null,
destroyed: function () {
},
destroyed: null,
_init: function () {
BI.Widget.superclass._init.apply(this, arguments);
this.beforeCreate();
this.beforeCreate && this.beforeCreate();
this._initRoot();
this._initElementWidth();
this._initElementHeight();
this._initVisualEffects();
this._initState();
this._initElement();
this.created();
this.created && this.created();
},
/**
@ -67,6 +57,7 @@ BI.Widget = BI.inherit(BI.OB, {
_initRoot: function () {
var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget");
this._isRoot = o.root;
if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) {
this._parent = o.element;
@ -130,7 +121,7 @@ BI.Widget = BI.inherit(BI.OB, {
_initElement: function () {
var self = this;
var els = this.render();
var els = this.render && this.render();
if (BI.isPlainObject(els)) {
els = [els];
}
@ -164,13 +155,13 @@ BI.Widget = BI.inherit(BI.OB, {
if (!isMounted) {
return;
}
this.beforeMounted();
this.beforeMounted && this.beforeMounted();
this._isMounted = true;
this._mountChildren();
BI.each(this._children, function (i, widget) {
widget._mount && widget._mount();
});
this.mounted();
this.mounted && this.mounted();
},
_mountChildren: function () {
@ -196,7 +187,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed();
this.destroyed && this.destroyed();
},
setWidth: function (w) {
@ -258,6 +249,9 @@ BI.Widget = BI.inherit(BI.OB, {
widget = name;
name = widget.getName();
}
if (BI.isKey(name)) {
name = name + "";
}
name = name || widget.getName() || BI.uniqueId("widget");
if (this._children[name]) {
throw new Error("name has already been existed");
@ -383,7 +377,7 @@ BI.Widget = BI.inherit(BI.OB, {
empty: function () {
BI.each(this._children, function (i, widget) {
widget._unMount();
widget._unMount && widget._unMount();
});
this._children = {};
this.element.empty();
@ -396,7 +390,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed();
this.destroyed && this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this.purgeListeners();

3
src/core/wrapper/layout.js

@ -361,9 +361,8 @@ BI.Layout = BI.inherit(BI.Widget, {
removeIndex = nameOrWidget;
}
if (removeIndex) {
this.options.items.splice(removeIndex, 1);
this._removeItemAt(removeIndex | 0);
}
BI.Layout.superclass.removeWidget.apply(this, arguments);
},
empty: function () {

2
src/core/wrapper/layout/adapt/float.center.js

@ -37,7 +37,7 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
element: this,
items: [this.left]
});
this.removeWidget(this.container.getName());
this.removeWidget(this.container);
},
stroke: function (items) {

2
src/core/wrapper/layout/adapt/float.horizontal.js

@ -32,7 +32,7 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
element: this,
items: [this.left]
});
this.removeWidget(this.container.getName());
this.removeWidget(this.container);
},
_addElement: function (i, item) {

128
src/css/core/reset.css

@ -1,128 +0,0 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

8
src/css/widget/responsivetable/responsivetable.css

@ -0,0 +1,8 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}

48
src/less/core/reset.less

@ -1,48 +0,0 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

11
src/less/widget/responsivetable/responsivetable.less

@ -0,0 +1,11 @@
@import "../../bibase";
.bi-responsive-table {
& > div.bottom-left > div > div > table, & > div.bottom-right > div > div > table, > div > div > table {
& > * > * > td {
&.last-col {
min-width: 80px;
}
}
}
}

29
src/widget/adaptivearrangement/adaptivearrangement.js

@ -37,8 +37,10 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
if (o.isNeedResizeContainer) {
var isResizing = false;
var needEnd = false;
var height;
var interval;
var startSize;
var resize = function (e, ui) {
if (isResizing) {
return;
@ -60,20 +62,26 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
minHeight: 20,
helper: "bi-resizer",
autoHide: true,
start: function (e, ui) {
startSize = BI.clone(ui.size);
},
resize: function (e, ui) {
if (ui.size.height >= self.arrangement.container.element.height()) {
if (ui.size.height >= startSize.height - 10) {
resize(e, ui);
} else {
interval && clearInterval(interval);
needEnd = true;
}
},
stop: function (e, ui) {
var size = ui.size;
if (isResizing) {
if (isResizing && !needEnd) {
size.height = height;
}
self.arrangement.setContainerSize(ui.size);
needEnd = false;
isResizing = false;
startSize = null;
interval && clearInterval(interval);
self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
}
@ -102,17 +110,21 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
return this.arrangement._isEqual.apply(this.arrangement, arguments);
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
_setSelect: function (item) {
if (!item.element.hasClass("selected")) {
item.element.css("zIndex", ++self.zIndex);
BI.each(self.getAllRegions(), function (i, region) {
item.element.css("zIndex", ++this.zIndex);
BI.each(this.getAllRegions(), function (i, region) {
region.el.element.removeClass("selected");
});
item.element.addClass("selected");
}
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
self._setSelect(item)
});
o.resizable && item.element.resizable({
handles: "e, s, se",
@ -281,6 +293,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
addRegion: function (region, position) {
this._initResizable(region.el);
this._setSelect(region.el);
var self = this, flag;
var old = this.arrangement.getAllRegions();
if (BI.isNotNull(this.position)) {

125
src/widget/date/trigger.date.js

@ -51,6 +51,9 @@ BI.DateTrigger = BI.inherit(BI.Trigger, {
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.DateTrigger.EVENT_FOCUS);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.DateTrigger.EVENT_STOP);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.DateTrigger.EVENT_VALID);
});
@ -66,7 +69,7 @@ BI.DateTrigger = BI.inherit(BI.Trigger, {
if (BI.isNotEmptyString(value)) {
var date = value.split("-");
self.store_value = {
type: BICst.MULTI_DATE_CALENDAR,
type: BI.DateTrigger.MULTI_DATE_CALENDAR,
value:{
year: date[0] | 0,
month: date[1] - 1,
@ -134,7 +137,7 @@ BI.DateTrigger = BI.inherit(BI.Trigger, {
var date = new Date();
this.store_value = v;
if (BI.isNotNull(v)) {
type = v.type || BICst.MULTI_DATE_CALENDAR; value = v.value;
type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value;
if(BI.isNull(value)){
value = v;
}
@ -146,88 +149,88 @@ BI.DateTrigger = BI.inherit(BI.Trigger, {
self.setTitle(text + ":" + dateStr);
};
switch (type) {
case BICst.MULTI_DATE_YEAR_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_PREV];
case BI.DateTrigger.MULTI_DATE_YEAR_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];
date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_AFTER];
case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];
date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_BEGIN];
case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];
date = new Date(date.getFullYear(), 0, 1);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_YEAR_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_YEAR_END];
case BI.DateTrigger.MULTI_DATE_YEAR_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];
date = new Date(date.getFullYear(), 11, 31);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_PREV];
case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];
date = new Date().getBeforeMulQuarter(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_AFTER];
case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];
date = new Date().getAfterMulQuarter(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_BEGIN];
case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];
date = new Date().getQuarterStartDate();
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_QUARTER_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_QUARTER_END];
case BI.DateTrigger.MULTI_DATE_QUARTER_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];
date = new Date().getQuarterEndDate();
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_PREV];
case BI.DateTrigger.MULTI_DATE_MONTH_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];
date = new Date().getBeforeMultiMonth(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_AFTER];
case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];
date = new Date().getAfterMultiMonth(value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_BEGIN:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_BEGIN];
case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];
date = new Date(date.getFullYear(), date.getMonth(), 1);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_MONTH_END:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_MONTH_END];
case BI.DateTrigger.MULTI_DATE_MONTH_END:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];
date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate());
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_WEEK_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_PREV];
case BI.DateTrigger.MULTI_DATE_WEEK_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];
date = date.getOffsetDate(-7 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_WEEK_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_WEEK_AFTER];
case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];
date = date.getOffsetDate(7 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_PREV:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_PREV];
case BI.DateTrigger.MULTI_DATE_DAY_PREV:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];
date = date.getOffsetDate(-1 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_AFTER:
var text = value + BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_AFTER];
case BI.DateTrigger.MULTI_DATE_DAY_AFTER:
var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];
date = date.getOffsetDate(1 * value);
_setInnerValue(date, text);
break;
case BICst.MULTI_DATE_DAY_TODAY:
var text = BICst.MULTI_DATE_SEGMENT_NUM[BICst.MULTI_DATE_DAY_TODAY];
case BI.DateTrigger.MULTI_DATE_DAY_TODAY:
var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];
date = new Date();
_setInnerValue(date, text);
break;
@ -254,8 +257,58 @@ BI.DateTrigger = BI.inherit(BI.Trigger, {
}
});
BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1;
BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2;
BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3;
BI.DateTrigger.MULTI_DATE_YEAR_END = 4;
BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5;
BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6;
BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7;
BI.DateTrigger.MULTI_DATE_MONTH_END = 8;
BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9;
BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10;
BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11;
BI.DateTrigger.MULTI_DATE_QUARTER_END = 12;
BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13;
BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14;
BI.DateTrigger.MULTI_DATE_DAY_PREV = 15;
BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16;
BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17;
BI.DateTrigger.MULTI_DATE_PARAM = 18;
BI.DateTrigger.MULTI_DATE_CALENDAR = 19;
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {};
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next");
BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today");
BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.DateTrigger.EVENT_START = "EVENT_START";
BI.DateTrigger.EVENT_STOP = "EVENT_STOP";
BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.DateTrigger.EVENT_VALID = "EVENT_VALID";

5
src/widget/previewtable/previewtable.js

@ -198,11 +198,6 @@ BI.PreviewTable = BI.inherit(BI.Widget, {
populate: function (items, header) {
this.table.populate(items, header);
},
destroy: function () {
this.table.destroy();
BI.PreviewTable.superclass.destroy.apply(this, arguments);
}
});
BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE";

363
src/widget/responsivetable/responsivetable.js

@ -0,0 +1,363 @@
/**
* 自适应宽度的表格
*
* Created by GUY on 2016/2/3.
* @class BI.ResponisveTable
* @extends BI.Widget
*/
BI.ResponisveTable = BI.inherit(BI.Widget, {
_const: {
perColumnSize: 100
},
_defaultConfig: function () {
return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-responsive-table",
isNeedFreeze: false,//是否需要冻结单元格
freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效
isNeedMerge: false,//是否需要合并单元格
mergeCols: [], //合并的单元格列号
mergeRule: function (row1, row2) { //合并规则, 默认相等时合并
return BI.isEqual(row1, row2);
},
columnSize: [],
headerRowSize: 25,
footerRowSize: 25,
rowSize: 25,
regionColumnSize: false,
header: [],
footer: false,
items: [], //二维数组
//交叉表头
crossHeader: [],
crossItems: []
});
},
_init: function () {
BI.ResponisveTable.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.table = BI.createWidget({
type: "bi.table_view",
element: this,
isNeedFreeze: o.isNeedFreeze,
freezeCols: o.freezeCols,
isNeedMerge: o.isNeedMerge,
mergeCols: o.mergeCols,
mergeRule: o.mergeRule,
columnSize: o.columnSize,
headerRowSize: o.headerRowSize,
footerRowSize: o.footerRowSize,
rowSize: o.rowSize,
regionColumnSize: o.regionColumnSize,
header: o.header,
footer: o.footer,
items: o.items,
//交叉表头
crossHeader: o.crossHeader,
crossItems: o.crossItems
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () {
self._initRegionSize();
self.table.resize();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () {
self._resizeRegion();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () {
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () {
self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () {
//important:在冻结并自适应列宽的情况下要随时变更表头宽度
if (o.isNeedResize === true && self._isAdaptiveColumn()) {
self._resizeHeader();
}
self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () {
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () {
self._resizeBody();
self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () {
self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments);
});
this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () {
self._resizeRegion();
self._resizeHeader();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments);
});
},
_initRegionSize: function () {
var o = this.options;
if (o.isNeedFreeze === true) {
var regionColumnSize = this.table.getRegionColumnSize();
var maxWidth = this.table.element.width();
if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) {
var freezeCols = o.freezeCols;
if (freezeCols.length === 0) {
this.table.setRegionColumnSize([0, "fill"]);
} else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) {
var size = maxWidth / 3;
if (freezeCols.length > o.columnSize.length / 2) {
size = maxWidth * 2 / 3;
}
this.table.setRegionColumnSize([size, "fill"]);
} else {
this.table.setRegionColumnSize(["fill", 0]);
}
}
}
},
_getBlockSize: function () {
var o = this.options;
var columnSize = this.table.getCalculateColumnSize();
if (o.isNeedFreeze === true) {
var columnSizeLeft = [], columnSizeRight = [];
BI.each(columnSize, function (i, size) {
if (o.freezeCols.contains(i)) {
columnSizeLeft.push(size);
} else {
columnSizeRight.push(size);
}
});
//因为有边框,所以加上数组长度的参数调整
var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, sumRight = BI.sum(columnSizeRight) + columnSizeRight.length;
return {
sumLeft: sumLeft,
sumRight: sumRight,
left: columnSizeLeft,
right: columnSizeRight
}
}
return {
size: columnSize,
sum: BI.sum(columnSize) + columnSize.length
};
},
_isAdaptiveColumn: function (columnSize) {
return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05);
},
_resizeHeader: function () {
var self = this, o = this.options;
if (o.isNeedFreeze === true) {
//若是当前处于自适应调节阶段
if (this._isAdaptiveColumn()) {
var columnSize = this.table.getCalculateColumnSize();
this.table.setHeaderColumnSize(columnSize);
} else {
var regionColumnSize = this.table.getClientRegionColumnSize();
var block = this._getBlockSize();
var sumLeft = block.sumLeft, sumRight = block.sumRight;
var columnSizeLeft = block.left, columnSizeRight = block.right;
columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft;
columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight;
var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight);
newLeft[newLeft.length - 1] = "";
newRight[newRight.length - 1] = "";
this.table.setColumnSize(newLeft.concat(newRight));
block = self._getBlockSize();
if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) {
columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]
}
if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) {
columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]
}
self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight));
}
} else {
if (!this._isAdaptiveColumn()) {
var regionColumnSize = this.table.getClientRegionColumnSize();
var block = this._getBlockSize();
var sum = block.sum;
var size = block.size;
size[size.length - 1] += regionColumnSize[0] - sum;
var newSize = BI.clone(size);
newSize[newSize.length - 1] = "";
this.table.setColumnSize(newSize);
block = this._getBlockSize();
if (size[size.length - 1] < block.size[block.size.length - 1]) {
size[size.length - 1] = block.size[block.size.length - 1]
}
this.table.setColumnSize(size);
}
}
},
_resizeBody: function () {
if (this._isAdaptiveColumn()) {
var columnSize = this.table.getCalculateColumnSize();
this.setColumnSize(columnSize);
}
},
_adjustRegion: function () {
var o = this.options;
var regionColumnSize = this.table.getCalculateRegionColumnSize();
if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
var block = this._getBlockSize();
var sumLeft = block.sumLeft, sumRight = block.sumRight;
if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) {
this.table.setRegionColumnSize([sumLeft, "fill"]);
}
this._resizeRegion();
}
},
_resizeRegion: function () {
var o = this.options;
var regionColumnSize = this.table.getCalculateRegionColumnSize();
if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) {
var maxWidth = this.table.element.width();
if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) {
var freezeCols = o.freezeCols;
var size = maxWidth / 3;
if (freezeCols.length > o.columnSize.length / 2) {
size = maxWidth * 2 / 3;
}
this.table.setRegionColumnSize([size, "fill"]);
}
}
},
resize: function () {
this.table.resize();
this._resizeRegion();
this._resizeHeader();
},
setColumnSize: function (columnSize) {
this.table.setColumnSize(columnSize);
this._adjustRegion();
this._resizeHeader();
},
getColumnSize: function () {
return this.table.getColumnSize();
},
getCalculateColumnSize: function () {
return this.table.getCalculateColumnSize();
},
setHeaderColumnSize: function (columnSize) {
this.table.setHeaderColumnSize(columnSize);
this._adjustRegion();
this._resizeHeader();
},
setRegionColumnSize: function (columnSize) {
this.table.setRegionColumnSize(columnSize);
this._resizeHeader();
},
getRegionColumnSize: function () {
return this.table.getRegionColumnSize();
},
getCalculateRegionColumnSize: function () {
return this.table.getCalculateRegionColumnSize();
},
getCalculateRegionRowSize: function () {
return this.table.getCalculateRegionRowSize();
},
getClientRegionColumnSize: function () {
return this.table.getClientRegionColumnSize();
},
getScrollRegionColumnSize: function () {
return this.table.getScrollRegionColumnSize();
},
getScrollRegionRowSize: function () {
return this.table.getScrollRegionRowSize();
},
hasVerticalScroll: function () {
return this.table.hasVerticalScroll();
},
setVerticalScroll: function (scrollTop) {
this.table.setVerticalScroll(scrollTop);
},
setLeftHorizontalScroll: function (scrollLeft) {
this.table.setLeftHorizontalScroll(scrollLeft);
},
setRightHorizontalScroll: function (scrollLeft) {
this.table.setRightHorizontalScroll(scrollLeft);
},
getVerticalScroll: function () {
return this.table.getVerticalScroll();
},
getLeftHorizontalScroll: function () {
return this.table.getLeftHorizontalScroll();
},
getRightHorizontalScroll: function () {
return this.table.getRightHorizontalScroll();
},
getColumns: function () {
return this.table.getColumns();
},
attr: function () {
BI.ResponisveTable.superclass.attr.apply(this, arguments);
this.table.attr.apply(this.table, arguments);
},
populate: function (items) {
var self = this, o = this.options;
this.table.populate.apply(this.table, arguments);
if (o.isNeedFreeze === true) {
BI.nextTick(function () {
if (self.element.is(":visible")) {
self._initRegionSize();
self.table.resize();
self._resizeHeader();
}
});
}
}
});
BI.shortcut('bi.responsive_table', BI.ResponisveTable);
Loading…
Cancel
Save