Browse Source

update

master
guy 7 years ago
parent
commit
0c4e52f1ca
  1. 4
      bi/base.js
  2. 280
      bi/widget.js
  3. 4
      dist/base.js
  4. 284
      dist/bundle.js
  5. 24
      dist/bundle.min.js
  6. 280
      dist/widget.js
  7. 4
      src/base/combination/group.combo.js
  8. 229
      src/widget/adaptivearrangement/adaptivearrangement.js
  9. 51
      src/widget/arrangement/arrangement.js

4
bi/base.js

@ -3639,10 +3639,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ComboGroup.superclass._init.apply(this, arguments); BI.ComboGroup.superclass._init.apply(this, arguments);
this.populate(this.options.el); this._populate(this.options.el);
}, },
populate: function (item) { _populate: function (item) {
var self = this, o = this.options; var self = this, o = this.options;
var children = o.children; var children = o.children;
if (BI.isEmpty(children)) { if (BI.isEmpty(children)) {

280
bi/widget.js

@ -491,61 +491,8 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
item.element.mousedown(function () { item.element.mousedown(function () {
self._setSelect(item) self._setSelect(item)
}); });
// o.resizable && item.element.resizable({
// handles: "e, s, se",
// minWidth: 20,
// minHeight: 20,
// autoHide: true,
// helper: "bi-resizer",
// start: function () {
// item.element.css("zIndex", ++self.zIndex);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
// },
// resize: function (e, ui) {
// // self._resize(item.attr("id"), ui.size);
// self._resize(item.attr("id"), e, ui.size, ui.position);
// },
// stop: function (e, ui) {
// self._stopResize(item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
// }
// });
}, },
// _resize: function (name, e, size, position) {
// var self = this;
// this.scrollInterval(e, false, true, function (changedSize) {
// size.width += changedSize.offsetX;
// size.height += changedSize.offsetY;
// var containerWidth = self.arrangement.container.element.width();
// var containerHeight = self.arrangement.container.element.height();
// self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
// self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
// switch (self.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// self.setRegionSize(name, size);
// break;
// }
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
// });
// },
//
// _stopResize: function (name, size) {
// var self = this;
// this.scrollEnd();
// switch (this.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// this.setRegionSize(name, size);
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// this.setRegionSize(name, size);
// break;
// }
// },
_getScrollOffset: function () { _getScrollOffset: function () {
return this.arrangement._getScrollOffset(); return this.arrangement._getScrollOffset();
}, },
@ -605,99 +552,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
}, },
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this; // var self = this;
var map = { // var map = {
top: [-1, 0], // top: [-1, 0],
bottom: [1, 0], // bottom: [1, 0],
left: [0, -1], // left: [0, -1],
right: [0, 1] // right: [0, 1]
}; // };
var clientWidth = this.arrangement.getClientWidth(); // var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight(); // var clientHeight = this.arrangement.getClientHeight();
//
function scrollTo(direction, callback) { // function scrollTo(direction, callback) {
if (direction === "") { // if (direction === "") {
self.lastActiveRegion = ""; // self.lastActiveRegion = "";
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
return; // return;
} // }
if (self.lastActiveRegion !== direction) { // if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction; // self.lastActiveRegion = direction;
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
var count = 0; // var count = 0;
self._scrollInterval = setInterval(function () { // self._scrollInterval = setInterval(function () {
count++; // count++;
if (count <= 3) { // if (count <= 3) {
return; // return;
} // }
var offset = self._getScrollOffset(); // var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40; // var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40; // var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) { // if (t < 0 || l < 0) {
return; // return;
} // }
callback({ // callback({
offsetX: map[direction][1] * 40, // offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40 // offsetY: map[direction][0] * 40
}); // });
self.scrollTo({ // self.scrollTo({
top: t, // top: t,
left: l // left: l
}); // });
}, 300); // }, 300);
} // }
} // }
cb({ cb({
offsetX: 0, offsetX: 0,
offsetY: 0 offsetY: 0
}); });
var offset = this.element.offset(); // var offset = this.element.offset();
var p = { // var p = {
left: e.pageX - offset.left, // left: e.pageX - offset.left,
top: e.pageY - offset.top // top: e.pageY - offset.top
}; // };
//向上滚 // //向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) { // if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb) // scrollTo("top", cb)
} // }
//向下滚 // //向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) { // else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb) // scrollTo("bottom", cb)
} // }
//向左滚 // //向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) { // else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb) // scrollTo("left", cb)
} // }
//向右滚 // //向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) { // else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb) // scrollTo("right", cb)
} else { // } else {
if (isOverflowScroll === true) { // if (isOverflowScroll === true) {
if (p.top < 0) { // if (p.top < 0) {
scrollTo("top", cb); // scrollTo("top", cb);
} // }
else if (p.top > clientHeight) { // else if (p.top > clientHeight) {
scrollTo("bottom", cb); // scrollTo("bottom", cb);
} // }
else if (p.left < 0) { // else if (p.left < 0) {
scrollTo("left", cb); // scrollTo("left", cb);
} // }
else if (p.left > clientWidth) { // else if (p.left > clientWidth) {
scrollTo("right", cb); // scrollTo("right", cb);
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} // }
}, },
scrollEnd: function () { scrollEnd: function () {
@ -829,30 +776,30 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}); });
this.container = BI.createWidget({ this.container = BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
scrollable: true,
cls: "arrangement-container", cls: "arrangement-container",
items: o.items.concat([this.block, this.arrangement]) items: o.items.concat([this.block, this.arrangement])
}); });
this.scrollContainer = BI.createWidget({ this.container.element.scroll(function () {
type: "bi.adaptive",
width: "100%",
height: "100%",
scrollable: true,
items: [this.container]
});
this.scrollContainer.element.scroll(function () {
self.fireEvent(BI.Arrangement.EVENT_SCROLL, { self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
scrollLeft: self.scrollContainer.element.scrollLeft(), scrollLeft: self.container.element.scrollLeft(),
scrollTop: self.scrollContainer.element.scrollTop(), scrollTop: self.container.element.scrollTop(),
clientWidth: self.scrollContainer.element[0].clientWidth, clientWidth: self.container.element[0].clientWidth,
clientHeight: self.scrollContainer.element[0].clientHeight clientHeight: self.container.element[0].clientHeight
}); });
}); });
BI.createWidget({ BI.createWidget({
type: "bi.adaptive", type: "bi.absolute",
element: this, element: this,
items: [this.scrollContainer] items: [{
el: this.container,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
}); });
this.regions = {}; this.regions = {};
if (o.items.length > 0) { if (o.items.length > 0) {
@ -1050,8 +997,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_getScrollOffset: function () { _getScrollOffset: function () {
return { return {
left: this.scrollContainer.element[0].scrollLeft, left: this.container.element[0].scrollLeft,
top: this.scrollContainer.element[0].scrollTop top: this.container.element[0].scrollTop
} }
}, },
@ -1102,26 +1049,15 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
getClientWidth: function () { getClientWidth: function () {
return this.scrollContainer.element[0].clientWidth; return this.container.element[0].clientWidth;
}, },
getClientHeight: function () { getClientHeight: function () {
return this.scrollContainer.element[0].clientHeight; return this.container.element[0].clientHeight;
}, },
_applyContainer: function () { _applyContainer: function () {
//先掩藏后显示能够明确滚动条是否出现
this.scrollContainer.element.css("overflow", "hidden");
var occupied = this._getRegionOccupied(); var occupied = this._getRegionOccupied();
if (this.container._width !== occupied.left + occupied.width) {
this.container.element.width(occupied.left + occupied.width);
this.container._width = occupied.left + occupied.width;
}
if (this.container._height !== occupied.top + occupied.height) {
this.container.element.height(occupied.top + occupied.height);
this.container._height = occupied.top + occupied.height;
}
this.scrollContainer.element.css("overflow", "auto");
return occupied; return occupied;
}, },
@ -1692,8 +1628,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
scrollTo: function (scroll) { scrollTo: function (scroll) {
this.scrollContainer.element.scrollTop(scroll.top); this.container.element.scrollTop(scroll.top);
this.scrollContainer.element.scrollLeft(scroll.left); this.container.element.scrollLeft(scroll.left);
}, },
zoom: function (ratio) { zoom: function (ratio) {

4
dist/base.js vendored

@ -3639,10 +3639,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ComboGroup.superclass._init.apply(this, arguments); BI.ComboGroup.superclass._init.apply(this, arguments);
this.populate(this.options.el); this._populate(this.options.el);
}, },
populate: function (item) { _populate: function (item) {
var self = this, o = this.options; var self = this, o = this.options;
var children = o.children; var children = o.children;
if (BI.isEmpty(children)) { if (BI.isEmpty(children)) {

284
dist/bundle.js vendored

@ -29380,10 +29380,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ComboGroup.superclass._init.apply(this, arguments); BI.ComboGroup.superclass._init.apply(this, arguments);
this.populate(this.options.el); this._populate(this.options.el);
}, },
populate: function (item) { _populate: function (item) {
var self = this, o = this.options; var self = this, o = this.options;
var children = o.children; var children = o.children;
if (BI.isEmpty(children)) { if (BI.isEmpty(children)) {
@ -75509,61 +75509,8 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
item.element.mousedown(function () { item.element.mousedown(function () {
self._setSelect(item) self._setSelect(item)
}); });
// o.resizable && item.element.resizable({
// handles: "e, s, se",
// minWidth: 20,
// minHeight: 20,
// autoHide: true,
// helper: "bi-resizer",
// start: function () {
// item.element.css("zIndex", ++self.zIndex);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
// },
// resize: function (e, ui) {
// // self._resize(item.attr("id"), ui.size);
// self._resize(item.attr("id"), e, ui.size, ui.position);
// },
// stop: function (e, ui) {
// self._stopResize(item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
// }
// });
}, },
// _resize: function (name, e, size, position) {
// var self = this;
// this.scrollInterval(e, false, true, function (changedSize) {
// size.width += changedSize.offsetX;
// size.height += changedSize.offsetY;
// var containerWidth = self.arrangement.container.element.width();
// var containerHeight = self.arrangement.container.element.height();
// self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
// self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
// switch (self.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// self.setRegionSize(name, size);
// break;
// }
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
// });
// },
//
// _stopResize: function (name, size) {
// var self = this;
// this.scrollEnd();
// switch (this.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// this.setRegionSize(name, size);
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// this.setRegionSize(name, size);
// break;
// }
// },
_getScrollOffset: function () { _getScrollOffset: function () {
return this.arrangement._getScrollOffset(); return this.arrangement._getScrollOffset();
}, },
@ -75623,99 +75570,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
}, },
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this; // var self = this;
var map = { // var map = {
top: [-1, 0], // top: [-1, 0],
bottom: [1, 0], // bottom: [1, 0],
left: [0, -1], // left: [0, -1],
right: [0, 1] // right: [0, 1]
}; // };
var clientWidth = this.arrangement.getClientWidth(); // var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight(); // var clientHeight = this.arrangement.getClientHeight();
//
function scrollTo(direction, callback) { // function scrollTo(direction, callback) {
if (direction === "") { // if (direction === "") {
self.lastActiveRegion = ""; // self.lastActiveRegion = "";
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
return; // return;
} // }
if (self.lastActiveRegion !== direction) { // if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction; // self.lastActiveRegion = direction;
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
var count = 0; // var count = 0;
self._scrollInterval = setInterval(function () { // self._scrollInterval = setInterval(function () {
count++; // count++;
if (count <= 3) { // if (count <= 3) {
return; // return;
} // }
var offset = self._getScrollOffset(); // var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40; // var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40; // var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) { // if (t < 0 || l < 0) {
return; // return;
} // }
callback({ // callback({
offsetX: map[direction][1] * 40, // offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40 // offsetY: map[direction][0] * 40
}); // });
self.scrollTo({ // self.scrollTo({
top: t, // top: t,
left: l // left: l
}); // });
}, 300); // }, 300);
} // }
} // }
cb({ cb({
offsetX: 0, offsetX: 0,
offsetY: 0 offsetY: 0
}); });
var offset = this.element.offset(); // var offset = this.element.offset();
var p = { // var p = {
left: e.pageX - offset.left, // left: e.pageX - offset.left,
top: e.pageY - offset.top // top: e.pageY - offset.top
}; // };
//向上滚 // //向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) { // if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb) // scrollTo("top", cb)
} // }
//向下滚 // //向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) { // else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb) // scrollTo("bottom", cb)
} // }
//向左滚 // //向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) { // else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb) // scrollTo("left", cb)
} // }
//向右滚 // //向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) { // else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb) // scrollTo("right", cb)
} else { // } else {
if (isOverflowScroll === true) { // if (isOverflowScroll === true) {
if (p.top < 0) { // if (p.top < 0) {
scrollTo("top", cb); // scrollTo("top", cb);
} // }
else if (p.top > clientHeight) { // else if (p.top > clientHeight) {
scrollTo("bottom", cb); // scrollTo("bottom", cb);
} // }
else if (p.left < 0) { // else if (p.left < 0) {
scrollTo("left", cb); // scrollTo("left", cb);
} // }
else if (p.left > clientWidth) { // else if (p.left > clientWidth) {
scrollTo("right", cb); // scrollTo("right", cb);
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} // }
}, },
scrollEnd: function () { scrollEnd: function () {
@ -75847,30 +75794,30 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}); });
this.container = BI.createWidget({ this.container = BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
scrollable: true,
cls: "arrangement-container", cls: "arrangement-container",
items: o.items.concat([this.block, this.arrangement]) items: o.items.concat([this.block, this.arrangement])
}); });
this.scrollContainer = BI.createWidget({ this.container.element.scroll(function () {
type: "bi.adaptive",
width: "100%",
height: "100%",
scrollable: true,
items: [this.container]
});
this.scrollContainer.element.scroll(function () {
self.fireEvent(BI.Arrangement.EVENT_SCROLL, { self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
scrollLeft: self.scrollContainer.element.scrollLeft(), scrollLeft: self.container.element.scrollLeft(),
scrollTop: self.scrollContainer.element.scrollTop(), scrollTop: self.container.element.scrollTop(),
clientWidth: self.scrollContainer.element[0].clientWidth, clientWidth: self.container.element[0].clientWidth,
clientHeight: self.scrollContainer.element[0].clientHeight clientHeight: self.container.element[0].clientHeight
}); });
}); });
BI.createWidget({ BI.createWidget({
type: "bi.adaptive", type: "bi.absolute",
element: this, element: this,
items: [this.scrollContainer] items: [{
el: this.container,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
}); });
this.regions = {}; this.regions = {};
if (o.items.length > 0) { if (o.items.length > 0) {
@ -76068,8 +76015,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_getScrollOffset: function () { _getScrollOffset: function () {
return { return {
left: this.scrollContainer.element[0].scrollLeft, left: this.container.element[0].scrollLeft,
top: this.scrollContainer.element[0].scrollTop top: this.container.element[0].scrollTop
} }
}, },
@ -76120,26 +76067,15 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
getClientWidth: function () { getClientWidth: function () {
return this.scrollContainer.element[0].clientWidth; return this.container.element[0].clientWidth;
}, },
getClientHeight: function () { getClientHeight: function () {
return this.scrollContainer.element[0].clientHeight; return this.container.element[0].clientHeight;
}, },
_applyContainer: function () { _applyContainer: function () {
//先掩藏后显示能够明确滚动条是否出现
this.scrollContainer.element.css("overflow", "hidden");
var occupied = this._getRegionOccupied(); var occupied = this._getRegionOccupied();
if (this.container._width !== occupied.left + occupied.width) {
this.container.element.width(occupied.left + occupied.width);
this.container._width = occupied.left + occupied.width;
}
if (this.container._height !== occupied.top + occupied.height) {
this.container.element.height(occupied.top + occupied.height);
this.container._height = occupied.top + occupied.height;
}
this.scrollContainer.element.css("overflow", "auto");
return occupied; return occupied;
}, },
@ -76710,8 +76646,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
scrollTo: function (scroll) { scrollTo: function (scroll) {
this.scrollContainer.element.scrollTop(scroll.top); this.container.element.scrollTop(scroll.top);
this.scrollContainer.element.scrollLeft(scroll.left); this.container.element.scrollLeft(scroll.left);
}, },
zoom: function (ratio) { zoom: function (ratio) {

24
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

280
dist/widget.js vendored

@ -491,61 +491,8 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
item.element.mousedown(function () { item.element.mousedown(function () {
self._setSelect(item) self._setSelect(item)
}); });
// o.resizable && item.element.resizable({
// handles: "e, s, se",
// minWidth: 20,
// minHeight: 20,
// autoHide: true,
// helper: "bi-resizer",
// start: function () {
// item.element.css("zIndex", ++self.zIndex);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
// },
// resize: function (e, ui) {
// // self._resize(item.attr("id"), ui.size);
// self._resize(item.attr("id"), e, ui.size, ui.position);
// },
// stop: function (e, ui) {
// self._stopResize(item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
// }
// });
}, },
// _resize: function (name, e, size, position) {
// var self = this;
// this.scrollInterval(e, false, true, function (changedSize) {
// size.width += changedSize.offsetX;
// size.height += changedSize.offsetY;
// var containerWidth = self.arrangement.container.element.width();
// var containerHeight = self.arrangement.container.element.height();
// self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
// self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
// switch (self.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// self.setRegionSize(name, size);
// break;
// }
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
// });
// },
//
// _stopResize: function (name, size) {
// var self = this;
// this.scrollEnd();
// switch (this.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// this.setRegionSize(name, size);
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// this.setRegionSize(name, size);
// break;
// }
// },
_getScrollOffset: function () { _getScrollOffset: function () {
return this.arrangement._getScrollOffset(); return this.arrangement._getScrollOffset();
}, },
@ -605,99 +552,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
}, },
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this; // var self = this;
var map = { // var map = {
top: [-1, 0], // top: [-1, 0],
bottom: [1, 0], // bottom: [1, 0],
left: [0, -1], // left: [0, -1],
right: [0, 1] // right: [0, 1]
}; // };
var clientWidth = this.arrangement.getClientWidth(); // var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight(); // var clientHeight = this.arrangement.getClientHeight();
//
function scrollTo(direction, callback) { // function scrollTo(direction, callback) {
if (direction === "") { // if (direction === "") {
self.lastActiveRegion = ""; // self.lastActiveRegion = "";
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
return; // return;
} // }
if (self.lastActiveRegion !== direction) { // if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction; // self.lastActiveRegion = direction;
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
var count = 0; // var count = 0;
self._scrollInterval = setInterval(function () { // self._scrollInterval = setInterval(function () {
count++; // count++;
if (count <= 3) { // if (count <= 3) {
return; // return;
} // }
var offset = self._getScrollOffset(); // var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40; // var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40; // var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) { // if (t < 0 || l < 0) {
return; // return;
} // }
callback({ // callback({
offsetX: map[direction][1] * 40, // offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40 // offsetY: map[direction][0] * 40
}); // });
self.scrollTo({ // self.scrollTo({
top: t, // top: t,
left: l // left: l
}); // });
}, 300); // }, 300);
} // }
} // }
cb({ cb({
offsetX: 0, offsetX: 0,
offsetY: 0 offsetY: 0
}); });
var offset = this.element.offset(); // var offset = this.element.offset();
var p = { // var p = {
left: e.pageX - offset.left, // left: e.pageX - offset.left,
top: e.pageY - offset.top // top: e.pageY - offset.top
}; // };
//向上滚 // //向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) { // if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb) // scrollTo("top", cb)
} // }
//向下滚 // //向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) { // else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb) // scrollTo("bottom", cb)
} // }
//向左滚 // //向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) { // else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb) // scrollTo("left", cb)
} // }
//向右滚 // //向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) { // else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb) // scrollTo("right", cb)
} else { // } else {
if (isOverflowScroll === true) { // if (isOverflowScroll === true) {
if (p.top < 0) { // if (p.top < 0) {
scrollTo("top", cb); // scrollTo("top", cb);
} // }
else if (p.top > clientHeight) { // else if (p.top > clientHeight) {
scrollTo("bottom", cb); // scrollTo("bottom", cb);
} // }
else if (p.left < 0) { // else if (p.left < 0) {
scrollTo("left", cb); // scrollTo("left", cb);
} // }
else if (p.left > clientWidth) { // else if (p.left > clientWidth) {
scrollTo("right", cb); // scrollTo("right", cb);
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} // }
}, },
scrollEnd: function () { scrollEnd: function () {
@ -829,30 +776,30 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}); });
this.container = BI.createWidget({ this.container = BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
scrollable: true,
cls: "arrangement-container", cls: "arrangement-container",
items: o.items.concat([this.block, this.arrangement]) items: o.items.concat([this.block, this.arrangement])
}); });
this.scrollContainer = BI.createWidget({ this.container.element.scroll(function () {
type: "bi.adaptive",
width: "100%",
height: "100%",
scrollable: true,
items: [this.container]
});
this.scrollContainer.element.scroll(function () {
self.fireEvent(BI.Arrangement.EVENT_SCROLL, { self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
scrollLeft: self.scrollContainer.element.scrollLeft(), scrollLeft: self.container.element.scrollLeft(),
scrollTop: self.scrollContainer.element.scrollTop(), scrollTop: self.container.element.scrollTop(),
clientWidth: self.scrollContainer.element[0].clientWidth, clientWidth: self.container.element[0].clientWidth,
clientHeight: self.scrollContainer.element[0].clientHeight clientHeight: self.container.element[0].clientHeight
}); });
}); });
BI.createWidget({ BI.createWidget({
type: "bi.adaptive", type: "bi.absolute",
element: this, element: this,
items: [this.scrollContainer] items: [{
el: this.container,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
}); });
this.regions = {}; this.regions = {};
if (o.items.length > 0) { if (o.items.length > 0) {
@ -1050,8 +997,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_getScrollOffset: function () { _getScrollOffset: function () {
return { return {
left: this.scrollContainer.element[0].scrollLeft, left: this.container.element[0].scrollLeft,
top: this.scrollContainer.element[0].scrollTop top: this.container.element[0].scrollTop
} }
}, },
@ -1102,26 +1049,15 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
getClientWidth: function () { getClientWidth: function () {
return this.scrollContainer.element[0].clientWidth; return this.container.element[0].clientWidth;
}, },
getClientHeight: function () { getClientHeight: function () {
return this.scrollContainer.element[0].clientHeight; return this.container.element[0].clientHeight;
}, },
_applyContainer: function () { _applyContainer: function () {
//先掩藏后显示能够明确滚动条是否出现
this.scrollContainer.element.css("overflow", "hidden");
var occupied = this._getRegionOccupied(); var occupied = this._getRegionOccupied();
if (this.container._width !== occupied.left + occupied.width) {
this.container.element.width(occupied.left + occupied.width);
this.container._width = occupied.left + occupied.width;
}
if (this.container._height !== occupied.top + occupied.height) {
this.container.element.height(occupied.top + occupied.height);
this.container._height = occupied.top + occupied.height;
}
this.scrollContainer.element.css("overflow", "auto");
return occupied; return occupied;
}, },
@ -1692,8 +1628,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
scrollTo: function (scroll) { scrollTo: function (scroll) {
this.scrollContainer.element.scrollTop(scroll.top); this.container.element.scrollTop(scroll.top);
this.scrollContainer.element.scrollLeft(scroll.left); this.container.element.scrollLeft(scroll.left);
}, },
zoom: function (ratio) { zoom: function (ratio) {

4
src/base/combination/group.combo.js

@ -32,10 +32,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
_init: function () { _init: function () {
BI.ComboGroup.superclass._init.apply(this, arguments); BI.ComboGroup.superclass._init.apply(this, arguments);
this.populate(this.options.el); this._populate(this.options.el);
}, },
populate: function (item) { _populate: function (item) {
var self = this, o = this.options; var self = this, o = this.options;
var children = o.children; var children = o.children;
if (BI.isEmpty(children)) { if (BI.isEmpty(children)) {

229
src/widget/adaptivearrangement/adaptivearrangement.js

@ -72,61 +72,8 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
item.element.mousedown(function () { item.element.mousedown(function () {
self._setSelect(item) self._setSelect(item)
}); });
// o.resizable && item.element.resizable({
// handles: "e, s, se",
// minWidth: 20,
// minHeight: 20,
// autoHide: true,
// helper: "bi-resizer",
// start: function () {
// item.element.css("zIndex", ++self.zIndex);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE);
// },
// resize: function (e, ui) {
// // self._resize(item.attr("id"), ui.size);
// self._resize(item.attr("id"), e, ui.size, ui.position);
// },
// stop: function (e, ui) {
// self._stopResize(item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size);
// self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
// }
// });
}, },
// _resize: function (name, e, size, position) {
// var self = this;
// this.scrollInterval(e, false, true, function (changedSize) {
// size.width += changedSize.offsetX;
// size.height += changedSize.offsetY;
// var containerWidth = self.arrangement.container.element.width();
// var containerHeight = self.arrangement.container.element.height();
// self.arrangement.container.element.width(containerWidth + changedSize.offsetX);
// self.arrangement.container.element.height(containerHeight + changedSize.offsetY);
// switch (self.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// self.setRegionSize(name, size);
// break;
// }
// self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size);
// });
// },
//
// _stopResize: function (name, size) {
// var self = this;
// this.scrollEnd();
// switch (this.getLayoutType()) {
// case BI.Arrangement.LAYOUT_TYPE.FREE:
// this.setRegionSize(name, size);
// break;
// case BI.Arrangement.LAYOUT_TYPE.GRID:
// this.setRegionSize(name, size);
// break;
// }
// },
_getScrollOffset: function () { _getScrollOffset: function () {
return this.arrangement._getScrollOffset(); return this.arrangement._getScrollOffset();
}, },
@ -186,99 +133,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
}, },
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this; // var self = this;
var map = { // var map = {
top: [-1, 0], // top: [-1, 0],
bottom: [1, 0], // bottom: [1, 0],
left: [0, -1], // left: [0, -1],
right: [0, 1] // right: [0, 1]
}; // };
var clientWidth = this.arrangement.getClientWidth(); // var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight(); // var clientHeight = this.arrangement.getClientHeight();
//
function scrollTo(direction, callback) { // function scrollTo(direction, callback) {
if (direction === "") { // if (direction === "") {
self.lastActiveRegion = ""; // self.lastActiveRegion = "";
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
return; // return;
} // }
if (self.lastActiveRegion !== direction) { // if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction; // self.lastActiveRegion = direction;
if (self._scrollInterval) { // if (self._scrollInterval) {
clearInterval(self._scrollInterval); // clearInterval(self._scrollInterval);
self._scrollInterval = null; // self._scrollInterval = null;
} // }
var count = 0; // var count = 0;
self._scrollInterval = setInterval(function () { // self._scrollInterval = setInterval(function () {
count++; // count++;
if (count <= 3) { // if (count <= 3) {
return; // return;
} // }
var offset = self._getScrollOffset(); // var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40; // var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40; // var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) { // if (t < 0 || l < 0) {
return; // return;
} // }
callback({ // callback({
offsetX: map[direction][1] * 40, // offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40 // offsetY: map[direction][0] * 40
}); // });
self.scrollTo({ // self.scrollTo({
top: t, // top: t,
left: l // left: l
}); // });
}, 300); // }, 300);
} // }
} // }
cb({ cb({
offsetX: 0, offsetX: 0,
offsetY: 0 offsetY: 0
}); });
var offset = this.element.offset(); // var offset = this.element.offset();
var p = { // var p = {
left: e.pageX - offset.left, // left: e.pageX - offset.left,
top: e.pageY - offset.top // top: e.pageY - offset.top
}; // };
//向上滚 // //向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) { // if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb) // scrollTo("top", cb)
} // }
//向下滚 // //向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) { // else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb) // scrollTo("bottom", cb)
} // }
//向左滚 // //向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) { // else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb) // scrollTo("left", cb)
} // }
//向右滚 // //向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) { // else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb) // scrollTo("right", cb)
} else { // } else {
if (isOverflowScroll === true) { // if (isOverflowScroll === true) {
if (p.top < 0) { // if (p.top < 0) {
scrollTo("top", cb); // scrollTo("top", cb);
} // }
else if (p.top > clientHeight) { // else if (p.top > clientHeight) {
scrollTo("bottom", cb); // scrollTo("bottom", cb);
} // }
else if (p.left < 0) { // else if (p.left < 0) {
scrollTo("left", cb); // scrollTo("left", cb);
} // }
else if (p.left > clientWidth) { // else if (p.left > clientWidth) {
scrollTo("right", cb); // scrollTo("right", cb);
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} else { // } else {
scrollTo("", cb); // scrollTo("", cb);
} // }
} // }
}, },
scrollEnd: function () { scrollEnd: function () {

51
src/widget/arrangement/arrangement.js

@ -29,30 +29,30 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}); });
this.container = BI.createWidget({ this.container = BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
scrollable: true,
cls: "arrangement-container", cls: "arrangement-container",
items: o.items.concat([this.block, this.arrangement]) items: o.items.concat([this.block, this.arrangement])
}); });
this.scrollContainer = BI.createWidget({ this.container.element.scroll(function () {
type: "bi.adaptive",
width: "100%",
height: "100%",
scrollable: true,
items: [this.container]
});
this.scrollContainer.element.scroll(function () {
self.fireEvent(BI.Arrangement.EVENT_SCROLL, { self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
scrollLeft: self.scrollContainer.element.scrollLeft(), scrollLeft: self.container.element.scrollLeft(),
scrollTop: self.scrollContainer.element.scrollTop(), scrollTop: self.container.element.scrollTop(),
clientWidth: self.scrollContainer.element[0].clientWidth, clientWidth: self.container.element[0].clientWidth,
clientHeight: self.scrollContainer.element[0].clientHeight clientHeight: self.container.element[0].clientHeight
}); });
}); });
BI.createWidget({ BI.createWidget({
type: "bi.adaptive", type: "bi.absolute",
element: this, element: this,
items: [this.scrollContainer] items: [{
el: this.container,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
}); });
this.regions = {}; this.regions = {};
if (o.items.length > 0) { if (o.items.length > 0) {
@ -250,8 +250,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_getScrollOffset: function () { _getScrollOffset: function () {
return { return {
left: this.scrollContainer.element[0].scrollLeft, left: this.container.element[0].scrollLeft,
top: this.scrollContainer.element[0].scrollTop top: this.container.element[0].scrollTop
} }
}, },
@ -302,26 +302,15 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
getClientWidth: function () { getClientWidth: function () {
return this.scrollContainer.element[0].clientWidth; return this.container.element[0].clientWidth;
}, },
getClientHeight: function () { getClientHeight: function () {
return this.scrollContainer.element[0].clientHeight; return this.container.element[0].clientHeight;
}, },
_applyContainer: function () { _applyContainer: function () {
//先掩藏后显示能够明确滚动条是否出现
this.scrollContainer.element.css("overflow", "hidden");
var occupied = this._getRegionOccupied(); var occupied = this._getRegionOccupied();
if (this.container._width !== occupied.left + occupied.width) {
this.container.element.width(occupied.left + occupied.width);
this.container._width = occupied.left + occupied.width;
}
if (this.container._height !== occupied.top + occupied.height) {
this.container.element.height(occupied.top + occupied.height);
this.container._height = occupied.top + occupied.height;
}
this.scrollContainer.element.css("overflow", "auto");
return occupied; return occupied;
}, },
@ -892,8 +881,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
}, },
scrollTo: function (scroll) { scrollTo: function (scroll) {
this.scrollContainer.element.scrollTop(scroll.top); this.container.element.scrollTop(scroll.top);
this.scrollContainer.element.scrollLeft(scroll.left); this.container.element.scrollLeft(scroll.left);
}, },
zoom: function (ratio) { zoom: function (ratio) {

Loading…
Cancel
Save