Browse Source

update

master
guy 7 years ago
parent
commit
0c4e52f1ca
  1. 4
      bi/base.js
  2. 282
      bi/widget.js
  3. 4
      dist/base.js
  4. 284
      dist/bundle.js
  5. 24
      dist/bundle.min.js
  6. 282
      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 () {
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 children = o.children;
if (BI.isEmpty(children)) {

282
bi/widget.js

@ -491,60 +491,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
item.element.mousedown(function () {
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 () {
return this.arrangement._getScrollOffset();
@ -605,99 +552,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
},
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this;
var map = {
top: [-1, 0],
bottom: [1, 0],
left: [0, -1],
right: [0, 1]
};
var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight();
function scrollTo(direction, callback) {
if (direction === "") {
self.lastActiveRegion = "";
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
return;
}
if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction;
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
var count = 0;
self._scrollInterval = setInterval(function () {
count++;
if (count <= 3) {
return;
}
var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) {
return;
}
callback({
offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40
});
self.scrollTo({
top: t,
left: l
});
}, 300);
}
}
// var self = this;
// var map = {
// top: [-1, 0],
// bottom: [1, 0],
// left: [0, -1],
// right: [0, 1]
// };
// var clientWidth = this.arrangement.getClientWidth();
// var clientHeight = this.arrangement.getClientHeight();
//
// function scrollTo(direction, callback) {
// if (direction === "") {
// self.lastActiveRegion = "";
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// return;
// }
// if (self.lastActiveRegion !== direction) {
// self.lastActiveRegion = direction;
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// var count = 0;
// self._scrollInterval = setInterval(function () {
// count++;
// if (count <= 3) {
// return;
// }
// var offset = self._getScrollOffset();
// var t = offset.top + map[direction][0] * 40;
// var l = offset.left + map[direction][1] * 40;
// if (t < 0 || l < 0) {
// return;
// }
// callback({
// offsetX: map[direction][1] * 40,
// offsetY: map[direction][0] * 40
// });
// self.scrollTo({
// top: t,
// left: l
// });
// }, 300);
// }
// }
cb({
offsetX: 0,
offsetY: 0
});
var offset = this.element.offset();
var p = {
left: e.pageX - offset.left,
top: e.pageY - offset.top
};
//向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb)
}
//向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb)
}
//向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb)
}
//向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb)
} else {
if (isOverflowScroll === true) {
if (p.top < 0) {
scrollTo("top", cb);
}
else if (p.top > clientHeight) {
scrollTo("bottom", cb);
}
else if (p.left < 0) {
scrollTo("left", cb);
}
else if (p.left > clientWidth) {
scrollTo("right", cb);
} else {
scrollTo("", cb);
}
} else {
scrollTo("", cb);
}
}
// var offset = this.element.offset();
// var p = {
// left: e.pageX - offset.left,
// top: e.pageY - offset.top
// };
// //向上滚
// if (isBorderScroll && p.top >= 0 && p.top <= 30) {
// scrollTo("top", cb)
// }
// //向下滚
// else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
// scrollTo("bottom", cb)
// }
// //向左滚
// else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
// scrollTo("left", cb)
// }
// //向右滚
// else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
// scrollTo("right", cb)
// } else {
// if (isOverflowScroll === true) {
// if (p.top < 0) {
// scrollTo("top", cb);
// }
// else if (p.top > clientHeight) {
// scrollTo("bottom", cb);
// }
// else if (p.left < 0) {
// scrollTo("left", cb);
// }
// else if (p.left > clientWidth) {
// scrollTo("right", cb);
// } else {
// scrollTo("", cb);
// }
// } else {
// scrollTo("", cb);
// }
// }
},
scrollEnd: function () {
@ -829,30 +776,30 @@ BI.Arrangement = BI.inherit(BI.Widget, {
});
this.container = BI.createWidget({
type: "bi.absolute",
scrollable: true,
cls: "arrangement-container",
items: o.items.concat([this.block, this.arrangement])
});
this.scrollContainer = BI.createWidget({
type: "bi.adaptive",
width: "100%",
height: "100%",
scrollable: true,
items: [this.container]
});
this.scrollContainer.element.scroll(function () {
this.container.element.scroll(function () {
self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
scrollLeft: self.scrollContainer.element.scrollLeft(),
scrollTop: self.scrollContainer.element.scrollTop(),
clientWidth: self.scrollContainer.element[0].clientWidth,
clientHeight: self.scrollContainer.element[0].clientHeight
scrollLeft: self.container.element.scrollLeft(),
scrollTop: self.container.element.scrollTop(),
clientWidth: self.container.element[0].clientWidth,
clientHeight: self.container.element[0].clientHeight
});
});
BI.createWidget({
type: "bi.adaptive",
type: "bi.absolute",
element: this,
items: [this.scrollContainer]
items: [{
el: this.container,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.regions = {};
if (o.items.length > 0) {
@ -1050,8 +997,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_getScrollOffset: function () {
return {
left: this.scrollContainer.element[0].scrollLeft,
top: this.scrollContainer.element[0].scrollTop
left: this.container.element[0].scrollLeft,
top: this.container.element[0].scrollTop
}
},
@ -1102,26 +1049,15 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
getClientWidth: function () {
return this.scrollContainer.element[0].clientWidth;
return this.container.element[0].clientWidth;
},
getClientHeight: function () {
return this.scrollContainer.element[0].clientHeight;
return this.container.element[0].clientHeight;
},
_applyContainer: function () {
//先掩藏后显示能够明确滚动条是否出现
this.scrollContainer.element.css("overflow", "hidden");
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;
},
@ -1692,8 +1628,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
scrollTo: function (scroll) {
this.scrollContainer.element.scrollTop(scroll.top);
this.scrollContainer.element.scrollLeft(scroll.left);
this.container.element.scrollTop(scroll.top);
this.container.element.scrollLeft(scroll.left);
},
zoom: function (ratio) {

4
dist/base.js vendored

@ -3639,10 +3639,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
_init: function () {
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 children = o.children;
if (BI.isEmpty(children)) {

284
dist/bundle.js vendored

@ -29380,10 +29380,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
_init: function () {
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 children = o.children;
if (BI.isEmpty(children)) {
@ -75509,61 +75509,8 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
item.element.mousedown(function () {
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 () {
return this.arrangement._getScrollOffset();
},
@ -75623,99 +75570,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
},
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this;
var map = {
top: [-1, 0],
bottom: [1, 0],
left: [0, -1],
right: [0, 1]
};
var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight();
function scrollTo(direction, callback) {
if (direction === "") {
self.lastActiveRegion = "";
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
return;
}
if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction;
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
var count = 0;
self._scrollInterval = setInterval(function () {
count++;
if (count <= 3) {
return;
}
var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) {
return;
}
callback({
offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40
});
self.scrollTo({
top: t,
left: l
});
}, 300);
}
}
// var self = this;
// var map = {
// top: [-1, 0],
// bottom: [1, 0],
// left: [0, -1],
// right: [0, 1]
// };
// var clientWidth = this.arrangement.getClientWidth();
// var clientHeight = this.arrangement.getClientHeight();
//
// function scrollTo(direction, callback) {
// if (direction === "") {
// self.lastActiveRegion = "";
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// return;
// }
// if (self.lastActiveRegion !== direction) {
// self.lastActiveRegion = direction;
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// var count = 0;
// self._scrollInterval = setInterval(function () {
// count++;
// if (count <= 3) {
// return;
// }
// var offset = self._getScrollOffset();
// var t = offset.top + map[direction][0] * 40;
// var l = offset.left + map[direction][1] * 40;
// if (t < 0 || l < 0) {
// return;
// }
// callback({
// offsetX: map[direction][1] * 40,
// offsetY: map[direction][0] * 40
// });
// self.scrollTo({
// top: t,
// left: l
// });
// }, 300);
// }
// }
cb({
offsetX: 0,
offsetY: 0
});
var offset = this.element.offset();
var p = {
left: e.pageX - offset.left,
top: e.pageY - offset.top
};
//向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb)
}
//向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb)
}
//向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb)
}
//向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb)
} else {
if (isOverflowScroll === true) {
if (p.top < 0) {
scrollTo("top", cb);
}
else if (p.top > clientHeight) {
scrollTo("bottom", cb);
}
else if (p.left < 0) {
scrollTo("left", cb);
}
else if (p.left > clientWidth) {
scrollTo("right", cb);
} else {
scrollTo("", cb);
}
} else {
scrollTo("", cb);
}
}
// var offset = this.element.offset();
// var p = {
// left: e.pageX - offset.left,
// top: e.pageY - offset.top
// };
// //向上滚
// if (isBorderScroll && p.top >= 0 && p.top <= 30) {
// scrollTo("top", cb)
// }
// //向下滚
// else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
// scrollTo("bottom", cb)
// }
// //向左滚
// else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
// scrollTo("left", cb)
// }
// //向右滚
// else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
// scrollTo("right", cb)
// } else {
// if (isOverflowScroll === true) {
// if (p.top < 0) {
// scrollTo("top", cb);
// }
// else if (p.top > clientHeight) {
// scrollTo("bottom", cb);
// }
// else if (p.left < 0) {
// scrollTo("left", cb);
// }
// else if (p.left > clientWidth) {
// scrollTo("right", cb);
// } else {
// scrollTo("", cb);
// }
// } else {
// scrollTo("", cb);
// }
// }
},
scrollEnd: function () {
@ -75847,30 +75794,30 @@ BI.Arrangement = BI.inherit(BI.Widget, {
});
this.container = BI.createWidget({
type: "bi.absolute",
scrollable: true,
cls: "arrangement-container",
items: o.items.concat([this.block, this.arrangement])
});
this.scrollContainer = BI.createWidget({
type: "bi.adaptive",
width: "100%",
height: "100%",
scrollable: true,
items: [this.container]
});
this.scrollContainer.element.scroll(function () {
this.container.element.scroll(function () {
self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
scrollLeft: self.scrollContainer.element.scrollLeft(),
scrollTop: self.scrollContainer.element.scrollTop(),
clientWidth: self.scrollContainer.element[0].clientWidth,
clientHeight: self.scrollContainer.element[0].clientHeight
scrollLeft: self.container.element.scrollLeft(),
scrollTop: self.container.element.scrollTop(),
clientWidth: self.container.element[0].clientWidth,
clientHeight: self.container.element[0].clientHeight
});
});
BI.createWidget({
type: "bi.adaptive",
type: "bi.absolute",
element: this,
items: [this.scrollContainer]
items: [{
el: this.container,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.regions = {};
if (o.items.length > 0) {
@ -76068,8 +76015,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_getScrollOffset: function () {
return {
left: this.scrollContainer.element[0].scrollLeft,
top: this.scrollContainer.element[0].scrollTop
left: this.container.element[0].scrollLeft,
top: this.container.element[0].scrollTop
}
},
@ -76120,26 +76067,15 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
getClientWidth: function () {
return this.scrollContainer.element[0].clientWidth;
return this.container.element[0].clientWidth;
},
getClientHeight: function () {
return this.scrollContainer.element[0].clientHeight;
return this.container.element[0].clientHeight;
},
_applyContainer: function () {
//先掩藏后显示能够明确滚动条是否出现
this.scrollContainer.element.css("overflow", "hidden");
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;
},
@ -76710,8 +76646,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
scrollTo: function (scroll) {
this.scrollContainer.element.scrollTop(scroll.top);
this.scrollContainer.element.scrollLeft(scroll.left);
this.container.element.scrollTop(scroll.top);
this.container.element.scrollLeft(scroll.left);
},
zoom: function (ratio) {

24
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

282
dist/widget.js vendored

@ -491,60 +491,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
item.element.mousedown(function () {
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 () {
return this.arrangement._getScrollOffset();
@ -605,99 +552,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
},
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this;
var map = {
top: [-1, 0],
bottom: [1, 0],
left: [0, -1],
right: [0, 1]
};
var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight();
function scrollTo(direction, callback) {
if (direction === "") {
self.lastActiveRegion = "";
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
return;
}
if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction;
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
var count = 0;
self._scrollInterval = setInterval(function () {
count++;
if (count <= 3) {
return;
}
var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) {
return;
}
callback({
offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40
});
self.scrollTo({
top: t,
left: l
});
}, 300);
}
}
// var self = this;
// var map = {
// top: [-1, 0],
// bottom: [1, 0],
// left: [0, -1],
// right: [0, 1]
// };
// var clientWidth = this.arrangement.getClientWidth();
// var clientHeight = this.arrangement.getClientHeight();
//
// function scrollTo(direction, callback) {
// if (direction === "") {
// self.lastActiveRegion = "";
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// return;
// }
// if (self.lastActiveRegion !== direction) {
// self.lastActiveRegion = direction;
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// var count = 0;
// self._scrollInterval = setInterval(function () {
// count++;
// if (count <= 3) {
// return;
// }
// var offset = self._getScrollOffset();
// var t = offset.top + map[direction][0] * 40;
// var l = offset.left + map[direction][1] * 40;
// if (t < 0 || l < 0) {
// return;
// }
// callback({
// offsetX: map[direction][1] * 40,
// offsetY: map[direction][0] * 40
// });
// self.scrollTo({
// top: t,
// left: l
// });
// }, 300);
// }
// }
cb({
offsetX: 0,
offsetY: 0
});
var offset = this.element.offset();
var p = {
left: e.pageX - offset.left,
top: e.pageY - offset.top
};
//向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb)
}
//向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb)
}
//向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb)
}
//向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb)
} else {
if (isOverflowScroll === true) {
if (p.top < 0) {
scrollTo("top", cb);
}
else if (p.top > clientHeight) {
scrollTo("bottom", cb);
}
else if (p.left < 0) {
scrollTo("left", cb);
}
else if (p.left > clientWidth) {
scrollTo("right", cb);
} else {
scrollTo("", cb);
}
} else {
scrollTo("", cb);
}
}
// var offset = this.element.offset();
// var p = {
// left: e.pageX - offset.left,
// top: e.pageY - offset.top
// };
// //向上滚
// if (isBorderScroll && p.top >= 0 && p.top <= 30) {
// scrollTo("top", cb)
// }
// //向下滚
// else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
// scrollTo("bottom", cb)
// }
// //向左滚
// else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
// scrollTo("left", cb)
// }
// //向右滚
// else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
// scrollTo("right", cb)
// } else {
// if (isOverflowScroll === true) {
// if (p.top < 0) {
// scrollTo("top", cb);
// }
// else if (p.top > clientHeight) {
// scrollTo("bottom", cb);
// }
// else if (p.left < 0) {
// scrollTo("left", cb);
// }
// else if (p.left > clientWidth) {
// scrollTo("right", cb);
// } else {
// scrollTo("", cb);
// }
// } else {
// scrollTo("", cb);
// }
// }
},
scrollEnd: function () {
@ -829,30 +776,30 @@ BI.Arrangement = BI.inherit(BI.Widget, {
});
this.container = BI.createWidget({
type: "bi.absolute",
scrollable: true,
cls: "arrangement-container",
items: o.items.concat([this.block, this.arrangement])
});
this.scrollContainer = BI.createWidget({
type: "bi.adaptive",
width: "100%",
height: "100%",
scrollable: true,
items: [this.container]
});
this.scrollContainer.element.scroll(function () {
this.container.element.scroll(function () {
self.fireEvent(BI.Arrangement.EVENT_SCROLL, {
scrollLeft: self.scrollContainer.element.scrollLeft(),
scrollTop: self.scrollContainer.element.scrollTop(),
clientWidth: self.scrollContainer.element[0].clientWidth,
clientHeight: self.scrollContainer.element[0].clientHeight
scrollLeft: self.container.element.scrollLeft(),
scrollTop: self.container.element.scrollTop(),
clientWidth: self.container.element[0].clientWidth,
clientHeight: self.container.element[0].clientHeight
});
});
BI.createWidget({
type: "bi.adaptive",
type: "bi.absolute",
element: this,
items: [this.scrollContainer]
items: [{
el: this.container,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.regions = {};
if (o.items.length > 0) {
@ -1050,8 +997,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_getScrollOffset: function () {
return {
left: this.scrollContainer.element[0].scrollLeft,
top: this.scrollContainer.element[0].scrollTop
left: this.container.element[0].scrollLeft,
top: this.container.element[0].scrollTop
}
},
@ -1102,26 +1049,15 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
getClientWidth: function () {
return this.scrollContainer.element[0].clientWidth;
return this.container.element[0].clientWidth;
},
getClientHeight: function () {
return this.scrollContainer.element[0].clientHeight;
return this.container.element[0].clientHeight;
},
_applyContainer: function () {
//先掩藏后显示能够明确滚动条是否出现
this.scrollContainer.element.css("overflow", "hidden");
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;
},
@ -1692,8 +1628,8 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
scrollTo: function (scroll) {
this.scrollContainer.element.scrollTop(scroll.top);
this.scrollContainer.element.scrollLeft(scroll.left);
this.container.element.scrollTop(scroll.top);
this.container.element.scrollLeft(scroll.left);
},
zoom: function (ratio) {

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

@ -32,10 +32,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
_init: function () {
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 children = o.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 () {
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 () {
return this.arrangement._getScrollOffset();
},
@ -186,99 +133,99 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
},
scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) {
var self = this;
var map = {
top: [-1, 0],
bottom: [1, 0],
left: [0, -1],
right: [0, 1]
};
var clientWidth = this.arrangement.getClientWidth();
var clientHeight = this.arrangement.getClientHeight();
function scrollTo(direction, callback) {
if (direction === "") {
self.lastActiveRegion = "";
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
return;
}
if (self.lastActiveRegion !== direction) {
self.lastActiveRegion = direction;
if (self._scrollInterval) {
clearInterval(self._scrollInterval);
self._scrollInterval = null;
}
var count = 0;
self._scrollInterval = setInterval(function () {
count++;
if (count <= 3) {
return;
}
var offset = self._getScrollOffset();
var t = offset.top + map[direction][0] * 40;
var l = offset.left + map[direction][1] * 40;
if (t < 0 || l < 0) {
return;
}
callback({
offsetX: map[direction][1] * 40,
offsetY: map[direction][0] * 40
});
self.scrollTo({
top: t,
left: l
});
}, 300);
}
}
// var self = this;
// var map = {
// top: [-1, 0],
// bottom: [1, 0],
// left: [0, -1],
// right: [0, 1]
// };
// var clientWidth = this.arrangement.getClientWidth();
// var clientHeight = this.arrangement.getClientHeight();
//
// function scrollTo(direction, callback) {
// if (direction === "") {
// self.lastActiveRegion = "";
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// return;
// }
// if (self.lastActiveRegion !== direction) {
// self.lastActiveRegion = direction;
// if (self._scrollInterval) {
// clearInterval(self._scrollInterval);
// self._scrollInterval = null;
// }
// var count = 0;
// self._scrollInterval = setInterval(function () {
// count++;
// if (count <= 3) {
// return;
// }
// var offset = self._getScrollOffset();
// var t = offset.top + map[direction][0] * 40;
// var l = offset.left + map[direction][1] * 40;
// if (t < 0 || l < 0) {
// return;
// }
// callback({
// offsetX: map[direction][1] * 40,
// offsetY: map[direction][0] * 40
// });
// self.scrollTo({
// top: t,
// left: l
// });
// }, 300);
// }
// }
cb({
offsetX: 0,
offsetY: 0
});
var offset = this.element.offset();
var p = {
left: e.pageX - offset.left,
top: e.pageY - offset.top
};
//向上滚
if (isBorderScroll && p.top >= 0 && p.top <= 30) {
scrollTo("top", cb)
}
//向下滚
else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
scrollTo("bottom", cb)
}
//向左滚
else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
scrollTo("left", cb)
}
//向右滚
else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
scrollTo("right", cb)
} else {
if (isOverflowScroll === true) {
if (p.top < 0) {
scrollTo("top", cb);
}
else if (p.top > clientHeight) {
scrollTo("bottom", cb);
}
else if (p.left < 0) {
scrollTo("left", cb);
}
else if (p.left > clientWidth) {
scrollTo("right", cb);
} else {
scrollTo("", cb);
}
} else {
scrollTo("", cb);
}
}
// var offset = this.element.offset();
// var p = {
// left: e.pageX - offset.left,
// top: e.pageY - offset.top
// };
// //向上滚
// if (isBorderScroll && p.top >= 0 && p.top <= 30) {
// scrollTo("top", cb)
// }
// //向下滚
// else if (isBorderScroll && p.top >= clientHeight - 30 && p.top <= clientHeight) {
// scrollTo("bottom", cb)
// }
// //向左滚
// else if (isBorderScroll && p.left >= 0 && p.left <= 30) {
// scrollTo("left", cb)
// }
// //向右滚
// else if (isBorderScroll && p.left >= clientWidth - 30 && p.left <= clientWidth) {
// scrollTo("right", cb)
// } else {
// if (isOverflowScroll === true) {
// if (p.top < 0) {
// scrollTo("top", cb);
// }
// else if (p.top > clientHeight) {
// scrollTo("bottom", cb);
// }
// else if (p.left < 0) {
// scrollTo("left", cb);
// }
// else if (p.left > clientWidth) {
// scrollTo("right", cb);
// } else {
// scrollTo("", cb);
// }
// } else {
// scrollTo("", cb);
// }
// }
},
scrollEnd: function () {

51
src/widget/arrangement/arrangement.js

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

Loading…
Cancel
Save