guy 8 years ago
parent
commit
791dec91f7
  1. 122
      Gruntfile.js
  2. 2615
      bi/base.css
  3. 34933
      bi/base.js
  4. 11314
      bi/case.js
  5. 9925
      bi/core.css
  6. 19418
      bi/core.js
  7. 1588
      bi/widget.css
  8. 17922
      bi/widget.js
  9. 179
      dist/core.js
  10. 84
      dist/widget.js
  11. 0
      src/component/treevaluechooser/combo.treevaluechooser.js
  12. 0
      src/component/valuechooser/combo.valuechooser.js
  13. 2
      src/core/controller/controller.layer.js
  14. 2
      src/core/listener/listener.show.js
  15. 38
      src/core/utils/xml.js
  16. 20
      src/core/widget.js
  17. 40
      src/core/wrapper/layout.js
  18. 10
      src/core/wrapper/layout/adapt/adapt.leftrightvertical.js
  19. 2
      src/core/wrapper/layout/adapt/float.center.js
  20. 2
      src/core/wrapper/layout/adapt/inline.center.js
  21. 2
      src/core/wrapper/layout/layout.absolute.js
  22. 2
      src/core/wrapper/layout/layout.border.js
  23. 22
      src/core/wrapper/layout/layout.card.js
  24. 4
      src/core/wrapper/layout/layout.division.js
  25. 11
      src/core/wrapper/layout/layout.grid.js
  26. 4
      src/core/wrapper/layout/layout.table.js
  27. 4
      src/core/wrapper/layout/layout.tape.js
  28. 2
      src/core/wrapper/layout/layout.td.js
  29. 4
      src/core/wrapper/layout/layout.window.js
  30. 2
      src/core/wrapper/layout/middle/middle.center.js
  31. 2
      src/core/wrapper/layout/middle/middle.float.center.js
  32. 2
      src/core/wrapper/layout/middle/middle.horizontal.js
  33. 2
      src/core/wrapper/layout/middle/middle.vertical.js
  34. 84
      src/widget/arrangement/arrangement.js

122
Gruntfile.js

@ -30,6 +30,41 @@ module.exports = function (grunt) {
],
dest: 'dist/core.js'
},
biCoreJs: {
src: [
'src/core/underscore.js',
'src/core/foundation.js',
'src/core/mvc/**/*.js',
'src/core/base.js',
'src/core/alias.js',
'src/core/events.js',
'src/core/var.js',
'src/core/ob.js',
'src/core/widget.js',
'src/core/model.js',
'src/core/view.js',
'src/core/shortcut.js',
'src/core/plugin.js',
'src/core/controller.js',
'src/core/proto/**/*.js',
'src/core/utils/**/*.js',
'src/core/behavior/behavior.js',
'src/core/wrapper/layout.js',
'src/core/action/**/*.js',
'src/core/adapter/**/*.js',
'src/core/controller/**/*.js',
'src/core/event/**/*.js',
'src/core/func/**/*.js',
'src/core/listener/**/*.js',
'src/core/loader/**/*.js',
'src/core/logic/**/*.js',
'src/data/data.js',
'src/data/**/*.js',
'src/config.js'
],
dest: 'bi/core.js'
},
//最基础的控件
baseJs: {
src: [
@ -87,6 +122,93 @@ module.exports = function (grunt) {
demoCss: {
src: ['demo/css/**/*.css'],
dest: 'demo/dist/demo.css'
},
bi_coreJs: {
src: [
'src/core/underscore.js',
'src/core/foundation.js',
'src/core/mvc/**/*.js',
'src/core/base.js',
'src/core/alias.js',
'src/core/events.js',
'src/core/var.js',
'src/core/ob.js',
'src/core/widget.js',
'src/core/model.js',
'src/core/view.js',
'src/core/shortcut.js',
'src/core/plugin.js',
'src/core/controller.js',
'src/core/proto/**/*.js',
'src/core/utils/**/*.js',
'src/core/behavior/behavior.js',
'src/core/behavior/**/*.js',
'src/core/wrapper/layout.js',
'src/core/wrapper/**/*.js',
'src/core/action/**/*.js',
'src/core/adapter/**/*.js',
'src/core/controller/**/*.js',
'src/core/event/**/*.js',
'src/core/func/**/*.js',
'src/core/listener/**/*.js',
'src/core/loader/**/*.js',
'src/core/logic/**/*.js',
'src/data/data.js',
'src/data/**/*.js',
'src/config.js'
],
dest: 'bi/core.js'
},
//最基础的控件
bi_baseJs: {
src: [
'src/third/**/*.js',
'src/base/pane.js',
'src/base/single/single.js',
'src/base/single/text.js',
'src/base/single/button/button.basic.js',
'src/base/single/button/button.node.js',
'src/base/single/tip/tip.js',
'src/base/combination/group.button.js',
'src/base/combination/tree.button.js',
'src/base/combination/map.button.js',
'src/base/tree/treeview.js',
'src/base/tree/synctree.js',
'src/base/tree/parttree.js',
'src/base/**/*.js'
],
dest: 'bi/base.js'
},
//实现好的一些基础实例
bi_caseJs: {
src: [
'src/case/combo/popup.bubble.js',
'src/case/**/*.js'
],
dest: 'bi/case.js'
},
bi_widgetJs: {
src: [
'src/widget/paramsettingcombo/popup.param.js',
'src/widget/sequencetable/treenumber.sequencetable.js',
'src/widget/**/*.js',
'src/component/**/*.js'
],
dest: "bi/widget.js"
},
bi_coreCss: {
src: ['src/css/core/**/*.css', 'src/css/utils/**/*.css'],
dest: 'bi/core.css'
},
bi_baseCss: {
src: ['src/css/base/**/*.css'],
dest: 'bi/base.css'
},
bi_widgetCss: {
src: ['src/css/widget/**/*.css'],
dest: 'bi/widget.css'
}
},

2615
bi/base.css

File diff suppressed because it is too large Load Diff

34933
bi/base.js

File diff suppressed because it is too large Load Diff

11314
bi/case.js

File diff suppressed because it is too large Load Diff

9925
bi/core.css

File diff suppressed because it is too large Load Diff

19418
bi/core.js

File diff suppressed because it is too large Load Diff

1588
bi/widget.css

File diff suppressed because it is too large Load Diff

17922
bi/widget.js

File diff suppressed because it is too large Load Diff

179
dist/core.js vendored

@ -14467,7 +14467,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._isMounted = true;
this._mountChildren();
BI.each(this._children, function (i, widget) {
widget._mount&&widget._mount();
widget._mount && widget._mount();
});
this.mounted();
},
@ -14494,6 +14494,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._children = {};
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed();
},
@ -14507,6 +14508,14 @@ BI.Widget = BI.inherit(BI.OB, {
this._initElementHeight();
},
setElement: function (widget) {
if (widget == this) {
return;
}
this.element = BI.isWidget(widget) ? widget.element : $(widget);
return this;
},
setEnable: function (enable) {
if (enable === true) {
this.options.disabled = false;
@ -14672,9 +14681,16 @@ BI.Widget = BI.inherit(BI.OB, {
},
destroy: function () {
this._unMount();
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this.purgeListeners();
}
});BI.Model = BI.inherit(BI.M, {
_defaultConfig: function () {
@ -18943,8 +18959,9 @@ BI.Region.prototype = {
};
XML.getNSResolver = function (str) {
if (!str)
if (!str) {
return null;
}
var list = str.split(' ');
var namespaces = {};
for (var i = 0; i < list.length; i++) {
@ -18996,7 +19013,7 @@ BI.Region.prototype = {
XML.eval2 = function (context, xpathExp, resultType, namespaces) {
if (resultType !== "single" && resultType !== undefined && resultType !== null) {
throw new Error("justep.SimpleXML.eval只支持resultType='single', 不支持" + resultType);
throw new Error("justep.SimpleXML.eval only be resultType='single', not" + resultType);
}
if (context === null || context === undefined || xpathExp === null || xpathExp === undefined) {
@ -19159,8 +19176,9 @@ BI.Region.prototype = {
XML.setNodeText = function (context, xpathExp, text) {
var finded = this.eval(context, xpathExp, this.ResultType.single);
if (finded === null)
if (finded === null) {
return;
}
if (finded.nodeType == XML.Document.NodeType.ELEMENT) {
var textNode = this.eval(finded, "./text()", this.ResultType.single);
if (!textNode) {
@ -19200,26 +19218,36 @@ BI.Region.prototype = {
JUSTEP: "http://www.justep.com/x5#",
'get': function (type) {
type = type ? type.toLowerCase() : "string";
if ("string" == type)
if ("string" == type) {
return XML.Namespaces.XMLSCHEMA_STRING;
else if ("integer" == type)
}
else if ("integer" == type) {
return XML.Namespaces.XMLSCHEMA_INTEGER;
else if ("long" == type)
}
else if ("long" == type) {
return XML.Namespaces.XMLSCHEMA_LONG;
else if ("float" == type)
}
else if ("float" == type) {
return XML.Namespaces.XMLSCHEMA_FLOAT;
else if ("double" == type)
}
else if ("double" == type) {
return XML.Namespaces.XMLSCHEMA_DOUBLE;
else if ("decimal" == type)
}
else if ("decimal" == type) {
return XML.Namespaces.XMLSCHEMA_DECIMAL;
else if ("date" == type)
}
else if ("date" == type) {
return XML.Namespaces.XMLSCHEMA_DATE;
else if ("time" == type)
}
else if ("time" == type) {
return XML.Namespaces.XMLSCHEMA_TIME;
else if ("datetime" == type)
}
else if ("datetime" == type) {
return XML.Namespaces.XMLSCHEMA_DATETIME;
else if ("boolean" == type)
}
else if ("boolean" == type) {
return XML.Namespaces.XMLSCHEMA_BOOLEAN;
}
}
};
})(BI);BI.BehaviorFactory = {
@ -19362,15 +19390,21 @@ BI.Layout = BI.inherit(BI.Widget, {
//不比较函数
function eq(a, b, aStack, bStack) {
if (a === b) return a !== 0 || 1 / a === 1 / b;
if (a == null || b == null) return a === b;
if (a === b) {
return a !== 0 || 1 / a === 1 / b;
}
if (a == null || b == null) {
return a === b;
}
var className = Object.prototype.toString.call(a);
switch (className) {
case '[object RegExp]':
case '[object String]':
return '' + a === '' + b;
case '[object Number]':
if (+a !== +a) return +b !== +b;
if (+a !== +a) {
return +b !== +b;
}
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]':
case '[object Boolean]':
@ -19390,7 +19424,9 @@ BI.Layout = BI.inherit(BI.Widget, {
bStack = bStack || [];
var length = aStack.length;
while (length--) {
if (aStack[length] === a) return bStack[length] === b;
if (aStack[length] === a) {
return bStack[length] === b;
}
}
aStack.push(a);
@ -19398,17 +19434,25 @@ BI.Layout = BI.inherit(BI.Widget, {
if (areArrays) {
length = a.length;
if (length !== b.length) return false;
if (length !== b.length) {
return false;
}
while (length--) {
if (!eq(a[length], b[length], aStack, bStack)) return false;
if (!eq(a[length], b[length], aStack, bStack)) {
return false;
}
}
} else {
var keys = _.keys(a), key;
length = keys.length;
if (_.keys(b).length !== length) return false;
if (_.keys(b).length !== length) {
return false;
}
while (length--) {
key = keys[length];
if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) {
return false;
}
}
}
aStack.pop();
@ -19445,7 +19489,7 @@ BI.Layout = BI.inherit(BI.Widget, {
},
prependItem: function (item) {
return this.addItemAt(0,item);
return this.addItemAt(0, item);
},
addItemAt: function (index, item) {
@ -19467,8 +19511,9 @@ BI.Layout = BI.inherit(BI.Widget, {
if (index < 0 || index > this.options.items.length - 1) {
return;
}
this._children[this._getChildName(index)].destroy();
var child = this._children[this._getChildName(index)];
this._removeItemAt(index);
child.destroy();
},
updateItemAt: function (index, item) {
@ -19514,7 +19559,8 @@ BI.Layout = BI.inherit(BI.Widget, {
},
prependItems: function (items) {
var self =this,items = items || [];
var self = this;
items = items || [];
var fragment = document.createDocumentFragment();
var added = [];
for (var i = items.length - 1; i >= 0; i--) {
@ -21061,7 +21107,7 @@ BI.LayerController = BI.inherit(BI.Controller, {
add: function (name, layer, layout) {
if (this.has(name)) {
throw new Error("该弹出面板已经存在了,不能添加该key值");
throw new Error("name is already exist");
}
layout.setVisible(false);
this.layerManager[name] = layer;
@ -22869,7 +22915,7 @@ BI.ShowListener = BI.inherit(BI.OB, {
v = v || o.eventObj.getValue();
v = BI.isArray(v) ? (v.length > 1 ? v.toString() : v[0]) : v;
if (BI.isNull(v)) {
throw new Error("value值不能为空");
throw new Error("value cannot be null");
}
var cardName = o.cardNameCreator(v);
if (!o.cardLayout.isCardExisted(cardName)) {
@ -25410,7 +25456,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -25471,12 +25517,12 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
console.log("left_vertical_adapt布局不需要resize");
// console.log("left_vertical_adapt布局不需要resize");
},
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -25519,12 +25565,12 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
console.log("right_vertical_adapt布局不需要resize");
},
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -25753,7 +25799,7 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
mounted: function () {
@ -25938,7 +25984,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, {
},
addItem: function (item) {
throw new Error("不能添加元素");
throw new Error("cannot be added");
},
stroke: function (items) {
@ -26504,7 +26550,7 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
BI.each(items, function (i, item) {
if (!!item) {
if (!BI.isWidget(item) && !item.el) {
throw new Error("absolute布局中el 是必要属性");
throw new Error("el must be exist");
}
self._addElement(i, item);
}
@ -26631,7 +26677,7 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function(regions){
@ -26774,6 +26820,9 @@ BI.CardLayout = BI.inherit(BI.Layout, {
if (!self.hasWidget(self._getCardName(item.cardName))) {
var w = BI.createWidget(item);
self.addWidget(self._getCardName(item.cardName), w);
w.on(BI.Events.DESTROY, function () {
delete self._children[self._getCardName(item.cardName)];
});
} else {
var w = self.getWidgetByName(self._getCardName(item.cardName));
}
@ -26783,6 +26832,9 @@ BI.CardLayout = BI.inherit(BI.Layout, {
});
},
update: function () {
},
populate: function (items) {
BI.CardLayout.superclass.populate.apply(this, arguments);
this._mount();
@ -26790,32 +26842,32 @@ BI.CardLayout = BI.inherit(BI.Layout, {
},
isCardExisted: function (cardName) {
return this.hasWidget(this._getCardName(cardName))
&& $(this.getWidgetByName(this._getCardName(cardName)).element).length !== 0;
return this.hasWidget(this._getCardName(cardName));
},
getCardByName: function (cardName) {
if (!this.hasWidget(this._getCardName(cardName))) {
throw new Error("cardName不存在,无法获取");
throw new Error("cardName is not exist");
}
return this._children[this._getCardName(cardName)];
},
deleteCardByName: function (cardName) {
if (!this.hasWidget(this._getCardName(cardName))) {
throw new Error("cardName不存在,无法删除");
return;
}
this.getWidgetByName(this._getCardName(cardName)).destroy();
var index = BI.findKey(this.options.items, function (i, item) {
return item.cardName == cardName;
});
this.options.items.splice(index, 1);
var child = this.getWidgetByName(this._getCardName(cardName));
delete this._children[this._getCardName(cardName)];
child.destroy();
},
addCardByName: function (cardName, cardItem) {
if (this.hasWidget(this._getCardName(cardName))) {
throw new Error("cardName已经存在了");
throw new Error("cardName is already exist");
}
this.options.items.push({el: cardItem, cardName: cardName});
var widget = BI.createWidget(cardItem);
@ -26890,9 +26942,9 @@ BI.CardLayout = BI.inherit(BI.Layout, {
isAllCardHide: function () {
var flag = true;
BI.each(this._children, function (i, el) {
BI.some(this._children, function (i, el) {
if (el.isVisible()) {
flag = true;
flag = false;
return false;
}
});
@ -27006,7 +27058,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function(items){
@ -27069,7 +27121,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
var totalW = 0;
for (var j = 0; j < columns; j++) {
if (!map[i][j]) {
throw new Error("缺少item项");
throw new Error("item be required");
}
if(!this.hasWidget(this.getName() + i + "_" + j)) {
var w = BI.createWidget(map[i][j]);
@ -27284,15 +27336,17 @@ BI.GridLayout = BI.inherit(BI.Layout, {
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
var o = this.options;
var rows = o.rows || o.items.length, columns = o.columns || ((o.items[0] && o.items[0].length) | 0);
var width = 100 / columns, height = 100 / rows;
var els = new Array(rows);
var els = [];
for (var i = 0; i < rows; i++) {
els[i] = [];
}
function firstElement(item, row, col) {
if (row === 0) {
item.addClass("first-row")
@ -27330,9 +27384,6 @@ BI.GridLayout = BI.inherit(BI.Layout, {
}
}
BI.each(els, function (i) {
els[i] = new Array(columns);
});
BI.each(items, function (i, item) {
if (BI.isArray(item)) {
BI.each(item, function (j, el) {
@ -27763,7 +27814,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
}, arr[j]))
right += o.columnSize[j] + (o.columnSize[j] < 1 ? 0 : o.hgap);
} else {
throw new Error("只能有一个fill属性的item");
throw new Error("item with fill can only be one");
}
}
if (i >= 0 && i < arr.length) {
@ -27798,7 +27849,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
addItem: function (arr) {
if (!BI.isArray(arr)) {
throw new Error("item 必须是数组");
throw new Error("item must be array");
}
return BI.TableLayout.superclass.addItem.apply(this, arguments);
},
@ -27849,7 +27900,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
},
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -27954,7 +28005,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -28146,7 +28197,7 @@ BI.TdLayout = BI.inherit(BI.Layout, {
addItem: function (arr) {
if (!BI.isArray(arr)) {
throw new Error("item 必须是数组");
throw new Error("item must be array");
}
return BI.TdLayout.superclass.addItem.apply(this, arguments);
},
@ -28260,7 +28311,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -28311,7 +28362,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < o.rows; i++) {
for (var j = 0; j < o.columns; j++) {
if (!o.items[i][j]) {
throw new Error("缺少item项");
throw new Error("item be required");
}
if (!this.hasWidget(this.getName() + i + "_" + j)) {
var w = BI.createWidget(o.items[i][j]);
@ -28433,7 +28484,7 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素");
throw new Error("cannot be added");
},
stroke: function (items) {
@ -28506,7 +28557,7 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -28579,7 +28630,7 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -28651,7 +28702,7 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {

84
dist/widget.js vendored

@ -1889,8 +1889,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (lefts.length > 0) lefts = this._getTopAlignRegions(lefts[0].id).left;
if (rights.length > 0) rights = this._getTopAlignRegions(rights[0].id).right;
if (lefts.length > 0) {
lefts = this._getTopAlignRegions(lefts[0].id).left;
}
if (rights.length > 0) {
rights = this._getTopAlignRegions(rights[0].id).right;
}
}
}
//有下方居中drop
@ -1937,8 +1941,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (lefts.length > 0) lefts = this._getBottomAlignRegions(lefts[0].id).left;
if (rights.length > 0) rights = this._getBottomAlignRegions(rights[0].id).right;
if (lefts.length > 0) {
lefts = this._getBottomAlignRegions(lefts[0].id).left;
}
if (rights.length > 0) {
rights = this._getBottomAlignRegions(rights[0].id).right;
}
}
}
//有左方居中drop
@ -1986,8 +1994,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (tops.length > 0) tops = this._getLeftAlignRegions(tops[0].id).top;
if (bottoms.length > 0) bottoms = this._getLeftAlignRegions(bottoms[0].id).bottom;
if (tops.length > 0) {
tops = this._getLeftAlignRegions(tops[0].id).top;
}
if (bottoms.length > 0) {
bottoms = this._getLeftAlignRegions(bottoms[0].id).bottom;
}
}
}
//有右方居中drop
@ -2034,8 +2046,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (tops.length > 0) tops = this._getRightAlignRegions(tops[0].id).top;
if (bottoms.length > 0) bottoms = this._getRightAlignRegions(bottoms[0].id).bottom;
if (tops.length > 0) {
tops = this._getRightAlignRegions(tops[0].id).top;
}
if (bottoms.length > 0) {
bottoms = this._getRightAlignRegions(bottoms[0].id).bottom;
}
}
}
var lefts = this._getEquivalentRelativeRegions(name, ["left"]);
@ -3004,24 +3020,38 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_moveElement: function (layout, l, x, y, isUserAction) {
var self = this;
if (l.static) return layout;
if (l.static) {
return layout;
}
if (l.y === y && l.x === x) return layout;
if (l.y === y && l.x === x) {
return layout;
}
var movingUp = y && l.y > y;
if (typeof x === 'number') l.x = x;
if (typeof y === 'number') l.y = y;
if (typeof x === 'number') {
l.x = x;
}
if (typeof y === 'number') {
l.y = y;
}
l.moved = true;
var sorted = this._sortLayoutItemsByRowCol(layout);
if (movingUp) sorted = sorted.reverse();
if (movingUp) {
sorted = sorted.reverse();
}
var collisions = getAllCollisions(sorted, l);
for (var i = 0, len = collisions.length; i < len; i++) {
var collision = collisions[i];
if (collision.moved) continue;
if (collision.moved) {
continue;
}
if (l.y > collision.y && l.y - collision.y > collision.h / 4) continue;
if (l.y > collision.y && l.y - collision.y > collision.h / 4) {
continue;
}
if (collision.static) {
layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction);
@ -3049,17 +3079,29 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
_collides: function (l1, l2) {
if (l1 === l2) return false; // same element
if (l1.x + l1.w <= l2.x) return false; // l1 is left of l2
if (l1.x >= l2.x + l2.w) return false; // l1 is right of l2
if (l1.y + l1.h <= l2.y) return false; // l1 is above l2
if (l1.y >= l2.y + l2.h) return false; // l1 is below l2
if (l1 === l2) {
return false;
} // same element
if (l1.x + l1.w <= l2.x) {
return false;
} // l1 is left of l2
if (l1.x >= l2.x + l2.w) {
return false;
} // l1 is right of l2
if (l1.y + l1.h <= l2.y) {
return false;
} // l1 is above l2
if (l1.y >= l2.y + l2.h) {
return false;
} // l1 is below l2
return true; // boxes overlap
},
_getFirstCollision: function (layout, layoutItem) {
for (var i = 0, len = layout.length; i < len; i++) {
if (this._collides(layout[i], layoutItem)) return layout[i];
if (this._collides(layout[i], layoutItem)) {
return layout[i];
}
}
},

0
src/component/combo.treevaluechooser.js → src/component/treevaluechooser/combo.treevaluechooser.js

0
src/component/combo.valuechooser.js → src/component/valuechooser/combo.valuechooser.js

2
src/core/controller/controller.layer.js

@ -137,7 +137,7 @@ BI.LayerController = BI.inherit(BI.Controller, {
add: function (name, layer, layout) {
if (this.has(name)) {
throw new Error("该弹出面板已经存在了,不能添加该key值");
throw new Error("name is already exist");
}
layout.setVisible(false);
this.layerManager[name] = layer;

2
src/core/listener/listener.show.js

@ -27,7 +27,7 @@ BI.ShowListener = BI.inherit(BI.OB, {
v = v || o.eventObj.getValue();
v = BI.isArray(v) ? (v.length > 1 ? v.toString() : v[0]) : v;
if (BI.isNull(v)) {
throw new Error("value值不能为空");
throw new Error("value cannot be null");
}
var cardName = o.cardNameCreator(v);
if (!o.cardLayout.isCardExisted(cardName)) {

38
src/core/utils/xml.js

@ -59,8 +59,9 @@
};
XML.getNSResolver = function (str) {
if (!str)
if (!str) {
return null;
}
var list = str.split(' ');
var namespaces = {};
for (var i = 0; i < list.length; i++) {
@ -112,7 +113,7 @@
XML.eval2 = function (context, xpathExp, resultType, namespaces) {
if (resultType !== "single" && resultType !== undefined && resultType !== null) {
throw new Error("justep.SimpleXML.eval只支持resultType='single', 不支持" + resultType);
throw new Error("justep.SimpleXML.eval only be resultType='single', not" + resultType);
}
if (context === null || context === undefined || xpathExp === null || xpathExp === undefined) {
@ -275,8 +276,9 @@
XML.setNodeText = function (context, xpathExp, text) {
var finded = this.eval(context, xpathExp, this.ResultType.single);
if (finded === null)
if (finded === null) {
return;
}
if (finded.nodeType == XML.Document.NodeType.ELEMENT) {
var textNode = this.eval(finded, "./text()", this.ResultType.single);
if (!textNode) {
@ -316,26 +318,36 @@
JUSTEP: "http://www.justep.com/x5#",
'get': function (type) {
type = type ? type.toLowerCase() : "string";
if ("string" == type)
if ("string" == type) {
return XML.Namespaces.XMLSCHEMA_STRING;
else if ("integer" == type)
}
else if ("integer" == type) {
return XML.Namespaces.XMLSCHEMA_INTEGER;
else if ("long" == type)
}
else if ("long" == type) {
return XML.Namespaces.XMLSCHEMA_LONG;
else if ("float" == type)
}
else if ("float" == type) {
return XML.Namespaces.XMLSCHEMA_FLOAT;
else if ("double" == type)
}
else if ("double" == type) {
return XML.Namespaces.XMLSCHEMA_DOUBLE;
else if ("decimal" == type)
}
else if ("decimal" == type) {
return XML.Namespaces.XMLSCHEMA_DECIMAL;
else if ("date" == type)
}
else if ("date" == type) {
return XML.Namespaces.XMLSCHEMA_DATE;
else if ("time" == type)
}
else if ("time" == type) {
return XML.Namespaces.XMLSCHEMA_TIME;
else if ("datetime" == type)
}
else if ("datetime" == type) {
return XML.Namespaces.XMLSCHEMA_DATETIME;
else if ("boolean" == type)
}
else if ("boolean" == type) {
return XML.Namespaces.XMLSCHEMA_BOOLEAN;
}
}
};
})(BI);

20
src/core/widget.js

@ -168,7 +168,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._isMounted = true;
this._mountChildren();
BI.each(this._children, function (i, widget) {
widget._mount&&widget._mount();
widget._mount && widget._mount();
});
this.mounted();
},
@ -195,6 +195,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._children = {};
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed();
},
@ -208,6 +209,14 @@ BI.Widget = BI.inherit(BI.OB, {
this._initElementHeight();
},
setElement: function (widget) {
if (widget == this) {
return;
}
this.element = BI.isWidget(widget) ? widget.element : $(widget);
return this;
},
setEnable: function (enable) {
if (enable === true) {
this.options.disabled = false;
@ -373,8 +382,15 @@ BI.Widget = BI.inherit(BI.OB, {
},
destroy: function () {
this._unMount();
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
this.purgeListeners();
}
});

40
src/core/wrapper/layout.js

@ -102,15 +102,21 @@ BI.Layout = BI.inherit(BI.Widget, {
//不比较函数
function eq(a, b, aStack, bStack) {
if (a === b) return a !== 0 || 1 / a === 1 / b;
if (a == null || b == null) return a === b;
if (a === b) {
return a !== 0 || 1 / a === 1 / b;
}
if (a == null || b == null) {
return a === b;
}
var className = Object.prototype.toString.call(a);
switch (className) {
case '[object RegExp]':
case '[object String]':
return '' + a === '' + b;
case '[object Number]':
if (+a !== +a) return +b !== +b;
if (+a !== +a) {
return +b !== +b;
}
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]':
case '[object Boolean]':
@ -130,7 +136,9 @@ BI.Layout = BI.inherit(BI.Widget, {
bStack = bStack || [];
var length = aStack.length;
while (length--) {
if (aStack[length] === a) return bStack[length] === b;
if (aStack[length] === a) {
return bStack[length] === b;
}
}
aStack.push(a);
@ -138,17 +146,25 @@ BI.Layout = BI.inherit(BI.Widget, {
if (areArrays) {
length = a.length;
if (length !== b.length) return false;
if (length !== b.length) {
return false;
}
while (length--) {
if (!eq(a[length], b[length], aStack, bStack)) return false;
if (!eq(a[length], b[length], aStack, bStack)) {
return false;
}
}
} else {
var keys = _.keys(a), key;
length = keys.length;
if (_.keys(b).length !== length) return false;
if (_.keys(b).length !== length) {
return false;
}
while (length--) {
key = keys[length];
if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) {
return false;
}
}
}
aStack.pop();
@ -185,7 +201,7 @@ BI.Layout = BI.inherit(BI.Widget, {
},
prependItem: function (item) {
return this.addItemAt(0,item);
return this.addItemAt(0, item);
},
addItemAt: function (index, item) {
@ -207,8 +223,9 @@ BI.Layout = BI.inherit(BI.Widget, {
if (index < 0 || index > this.options.items.length - 1) {
return;
}
this._children[this._getChildName(index)].destroy();
var child = this._children[this._getChildName(index)];
this._removeItemAt(index);
child.destroy();
},
updateItemAt: function (index, item) {
@ -254,7 +271,8 @@ BI.Layout = BI.inherit(BI.Widget, {
},
prependItems: function (items) {
var self =this,items = items || [];
var self = this;
items = items || [];
var fragment = document.createDocumentFragment();
var added = [];
for (var i = items.length - 1; i >= 0; i--) {

10
src/core/wrapper/layout/adapt/adapt.leftrightvertical.js

@ -31,7 +31,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -92,12 +92,12 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
console.log("left_vertical_adapt布局不需要resize");
// console.log("left_vertical_adapt布局不需要resize");
},
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -140,12 +140,12 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
console.log("right_vertical_adapt布局不需要resize");
},
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {

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

@ -25,7 +25,7 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
mounted: function () {

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

@ -78,7 +78,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, {
},
addItem: function (item) {
throw new Error("不能添加元素");
throw new Error("cannot be added");
},
stroke: function (items) {

2
src/core/wrapper/layout/layout.absolute.js

@ -92,7 +92,7 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
BI.each(items, function (i, item) {
if (!!item) {
if (!BI.isWidget(item) && !item.el) {
throw new Error("absolute布局中el 是必要属性");
throw new Error("el must be exist");
}
self._addElement(i, item);
}

2
src/core/wrapper/layout/layout.border.js

@ -22,7 +22,7 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function(regions){

22
src/core/wrapper/layout/layout.card.js

@ -34,6 +34,9 @@ BI.CardLayout = BI.inherit(BI.Layout, {
if (!self.hasWidget(self._getCardName(item.cardName))) {
var w = BI.createWidget(item);
self.addWidget(self._getCardName(item.cardName), w);
w.on(BI.Events.DESTROY, function () {
delete self._children[self._getCardName(item.cardName)];
});
} else {
var w = self.getWidgetByName(self._getCardName(item.cardName));
}
@ -43,6 +46,9 @@ BI.CardLayout = BI.inherit(BI.Layout, {
});
},
update: function () {
},
populate: function (items) {
BI.CardLayout.superclass.populate.apply(this, arguments);
this._mount();
@ -50,32 +56,32 @@ BI.CardLayout = BI.inherit(BI.Layout, {
},
isCardExisted: function (cardName) {
return this.hasWidget(this._getCardName(cardName))
&& $(this.getWidgetByName(this._getCardName(cardName)).element).length !== 0;
return this.hasWidget(this._getCardName(cardName));
},
getCardByName: function (cardName) {
if (!this.hasWidget(this._getCardName(cardName))) {
throw new Error("cardName不存在,无法获取");
throw new Error("cardName is not exist");
}
return this._children[this._getCardName(cardName)];
},
deleteCardByName: function (cardName) {
if (!this.hasWidget(this._getCardName(cardName))) {
throw new Error("cardName不存在,无法删除");
return;
}
this.getWidgetByName(this._getCardName(cardName)).destroy();
var index = BI.findKey(this.options.items, function (i, item) {
return item.cardName == cardName;
});
this.options.items.splice(index, 1);
var child = this.getWidgetByName(this._getCardName(cardName));
delete this._children[this._getCardName(cardName)];
child.destroy();
},
addCardByName: function (cardName, cardItem) {
if (this.hasWidget(this._getCardName(cardName))) {
throw new Error("cardName已经存在了");
throw new Error("cardName is already exist");
}
this.options.items.push({el: cardItem, cardName: cardName});
var widget = BI.createWidget(cardItem);
@ -150,9 +156,9 @@ BI.CardLayout = BI.inherit(BI.Layout, {
isAllCardHide: function () {
var flag = true;
BI.each(this._children, function (i, el) {
BI.some(this._children, function (i, el) {
if (el.isVisible()) {
flag = true;
flag = false;
return false;
}
});

4
src/core/wrapper/layout/layout.division.js

@ -47,7 +47,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function(items){
@ -110,7 +110,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
var totalW = 0;
for (var j = 0; j < columns; j++) {
if (!map[i][j]) {
throw new Error("缺少item项");
throw new Error("item be required");
}
if(!this.hasWidget(this.getName() + i + "_" + j)) {
var w = BI.createWidget(map[i][j]);

11
src/core/wrapper/layout/layout.grid.js

@ -41,15 +41,17 @@ BI.GridLayout = BI.inherit(BI.Layout, {
addItem: function () {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
var o = this.options;
var rows = o.rows || o.items.length, columns = o.columns || ((o.items[0] && o.items[0].length) | 0);
var width = 100 / columns, height = 100 / rows;
var els = new Array(rows);
var els = [];
for (var i = 0; i < rows; i++) {
els[i] = [];
}
function firstElement(item, row, col) {
if (row === 0) {
item.addClass("first-row")
@ -87,9 +89,6 @@ BI.GridLayout = BI.inherit(BI.Layout, {
}
}
BI.each(els, function (i) {
els[i] = new Array(columns);
});
BI.each(items, function (i, item) {
if (BI.isArray(item)) {
BI.each(item, function (j, el) {

4
src/core/wrapper/layout/layout.table.js

@ -98,7 +98,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
}, arr[j]))
right += o.columnSize[j] + (o.columnSize[j] < 1 ? 0 : o.hgap);
} else {
throw new Error("只能有一个fill属性的item");
throw new Error("item with fill can only be one");
}
}
if (i >= 0 && i < arr.length) {
@ -133,7 +133,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
addItem: function (arr) {
if (!BI.isArray(arr)) {
throw new Error("item 必须是数组");
throw new Error("item must be array");
}
return BI.TableLayout.superclass.addItem.apply(this, arguments);
},

4
src/core/wrapper/layout/layout.tape.js

@ -39,7 +39,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
},
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -144,7 +144,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {

2
src/core/wrapper/layout/layout.td.js

@ -129,7 +129,7 @@ BI.TdLayout = BI.inherit(BI.Layout, {
addItem: function (arr) {
if (!BI.isArray(arr)) {
throw new Error("item 必须是数组");
throw new Error("item must be array");
}
return BI.TdLayout.superclass.addItem.apply(this, arguments);
},

4
src/core/wrapper/layout/layout.window.js

@ -41,7 +41,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {
@ -92,7 +92,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < o.rows; i++) {
for (var j = 0; j < o.columns; j++) {
if (!o.items[i][j]) {
throw new Error("缺少item项");
throw new Error("item be required");
}
if (!this.hasWidget(this.getName() + i + "_" + j)) {
var w = BI.createWidget(o.items[i][j]);

2
src/core/wrapper/layout/middle/middle.center.js

@ -27,7 +27,7 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素");
throw new Error("cannot be added");
},
stroke: function (items) {

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

@ -26,7 +26,7 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {

2
src/core/wrapper/layout/middle/middle.horizontal.js

@ -26,7 +26,7 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {

2
src/core/wrapper/layout/middle/middle.vertical.js

@ -26,7 +26,7 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
//do nothing
throw new Error("不能添加元素")
throw new Error("cannot be added")
},
stroke: function (items) {

84
src/widget/arrangement/arrangement.js

@ -952,8 +952,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (lefts.length > 0) lefts = this._getTopAlignRegions(lefts[0].id).left;
if (rights.length > 0) rights = this._getTopAlignRegions(rights[0].id).right;
if (lefts.length > 0) {
lefts = this._getTopAlignRegions(lefts[0].id).left;
}
if (rights.length > 0) {
rights = this._getTopAlignRegions(rights[0].id).right;
}
}
}
//有下方居中drop
@ -1000,8 +1004,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (lefts.length > 0) lefts = this._getBottomAlignRegions(lefts[0].id).left;
if (rights.length > 0) rights = this._getBottomAlignRegions(rights[0].id).right;
if (lefts.length > 0) {
lefts = this._getBottomAlignRegions(lefts[0].id).left;
}
if (rights.length > 0) {
rights = this._getBottomAlignRegions(rights[0].id).right;
}
}
}
//有左方居中drop
@ -1049,8 +1057,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (tops.length > 0) tops = this._getLeftAlignRegions(tops[0].id).top;
if (bottoms.length > 0) bottoms = this._getLeftAlignRegions(bottoms[0].id).bottom;
if (tops.length > 0) {
tops = this._getLeftAlignRegions(tops[0].id).top;
}
if (bottoms.length > 0) {
bottoms = this._getLeftAlignRegions(bottoms[0].id).bottom;
}
}
}
//有右方居中drop
@ -1097,8 +1109,12 @@ BI.Arrangement = BI.inherit(BI.Widget, {
break;
}
if (tops.length > 0) tops = this._getRightAlignRegions(tops[0].id).top;
if (bottoms.length > 0) bottoms = this._getRightAlignRegions(bottoms[0].id).bottom;
if (tops.length > 0) {
tops = this._getRightAlignRegions(tops[0].id).top;
}
if (bottoms.length > 0) {
bottoms = this._getRightAlignRegions(bottoms[0].id).bottom;
}
}
}
var lefts = this._getEquivalentRelativeRegions(name, ["left"]);
@ -2067,24 +2083,38 @@ BI.Arrangement = BI.inherit(BI.Widget, {
_moveElement: function (layout, l, x, y, isUserAction) {
var self = this;
if (l.static) return layout;
if (l.static) {
return layout;
}
if (l.y === y && l.x === x) return layout;
if (l.y === y && l.x === x) {
return layout;
}
var movingUp = y && l.y > y;
if (typeof x === 'number') l.x = x;
if (typeof y === 'number') l.y = y;
if (typeof x === 'number') {
l.x = x;
}
if (typeof y === 'number') {
l.y = y;
}
l.moved = true;
var sorted = this._sortLayoutItemsByRowCol(layout);
if (movingUp) sorted = sorted.reverse();
if (movingUp) {
sorted = sorted.reverse();
}
var collisions = getAllCollisions(sorted, l);
for (var i = 0, len = collisions.length; i < len; i++) {
var collision = collisions[i];
if (collision.moved) continue;
if (collision.moved) {
continue;
}
if (l.y > collision.y && l.y - collision.y > collision.h / 4) continue;
if (l.y > collision.y && l.y - collision.y > collision.h / 4) {
continue;
}
if (collision.static) {
layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction);
@ -2112,17 +2142,29 @@ BI.Arrangement = BI.inherit(BI.Widget, {
},
_collides: function (l1, l2) {
if (l1 === l2) return false; // same element
if (l1.x + l1.w <= l2.x) return false; // l1 is left of l2
if (l1.x >= l2.x + l2.w) return false; // l1 is right of l2
if (l1.y + l1.h <= l2.y) return false; // l1 is above l2
if (l1.y >= l2.y + l2.h) return false; // l1 is below l2
if (l1 === l2) {
return false;
} // same element
if (l1.x + l1.w <= l2.x) {
return false;
} // l1 is left of l2
if (l1.x >= l2.x + l2.w) {
return false;
} // l1 is right of l2
if (l1.y + l1.h <= l2.y) {
return false;
} // l1 is above l2
if (l1.y >= l2.y + l2.h) {
return false;
} // l1 is below l2
return true; // boxes overlap
},
_getFirstCollision: function (layout, layoutItem) {
for (var i = 0, len = layout.length; i < len; i++) {
if (this._collides(layout[i], layoutItem)) return layout[i];
if (this._collides(layout[i], layoutItem)) {
return layout[i];
}
}
},

Loading…
Cancel
Save