guy 7 years ago
parent
commit
8919bd5f16
  1. 2
      bi/base.js
  2. 4
      bi/core.js
  3. 0
      demo/js/category/largeTable/largeTable.js
  4. 113
      demo/js/category/sortTree/demo.sortTree.js
  5. 4
      demo/js/config/category.js
  6. 17
      demo/js/core/layout/demo.horizontal.js
  7. 2
      dist/base.js
  8. 6
      dist/bundle.js
  9. 12
      dist/bundle.min.js
  10. 4
      dist/core.js
  11. 211
      dist/demo.js
  12. 2
      src/base/combination/group.virtual.js
  13. 2
      src/core/utils/tree.js
  14. 2
      src/core/wrapper/layout.js

2
bi/base.js

@ -3897,7 +3897,7 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

4
bi/core.js

@ -10504,7 +10504,7 @@ $.extend(BI, {
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {
@ -11612,7 +11612,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}

0
demo/js/category/largeTable/face.js → demo/js/category/largeTable/largeTable.js

113
demo/js/category/sortTree/demo.sortTree.js

@ -0,0 +1,113 @@
/**
* guy
* 二级树
* @class Demo.SortTree
* @extends BI.Widget
*/
Demo.SortTree = BI.inherit(BI.Widget, {
render: function () {
var self = this, o = this.options;
var tree = new BI.Tree();
tree.initTree(BI.Tree.transformToTreeFormat(Demo.CONSTANTS.TREEITEMS));
this.tree = BI.createWidget({
type: "bi.custom_tree",
element: this,
expander: {},
items: this._formatItems(0, tree.toJSON()),
el: {
type: "bi.virtual_group",
layouts: [{
type: "bi.vertical",
scrolly: false
}]
}
});
this.tree.element.sortable({
items: ".sort-item",
placeholder: {
element: function ($currentItem) {
var holder = BI.createWidget({
type: "bi.layout",
cls: "bi-sortable-holder",
height: $currentItem.outerHeight()
});
holder.element.css({
"margin-left": $currentItem.css("margin-left"),
"margin-right": $currentItem.css("margin-right"),
"margin-top": $currentItem.css("margin-top"),
"margin-bottom": $currentItem.css("margin-bottom"),
"margin": $currentItem.css("margin")
});
return holder.element;
},
update: function () {
}
},
update: function (event, ui) {
var node = ui.item.data("node");
var findTheNode = tree.search(node.id);
//这里简单处理下找到它的父节点
var currentIndex = 0, parentNode;
if (ui.item.next().length > 0) {
var n = ui.item.next().data("node");
var nextId = n.id;
var nextNode = tree.search(nextId)
parentNode = nextNode.getParent();
var nextIndex = parentNode.getChildIndex(nextId);
currentIndex = nextIndex > 0 && (nextIndex - 1);
} else if (ui.item.prev().length > 0) {
var n = ui.item.prev().data("node");
var prevId = n.id;
var prevNode = tree.search(prevId)
parentNode = prevNode.getParent();
var prevIndex = parentNode.getChildIndex(prevId);
currentIndex = prevIndex + 1;
}
findTheNode.getParent().removeChild(node.id);
parentNode.addChild(findTheNode, currentIndex);
self.tree.populate(self._formatItems(0, tree.toJSON()));
},
start: function (event, ui) {
},
stop: function (event, ui) {
},
over: function (event, ui) {
}
});
},
_formatItems: function (layer, nodes) {
var self = this;
BI.each(nodes, function (i, node) {
if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
BI.defaults(node, {
type: "bi.multilayer_icon_arrow_node",
height: 30,
layer: layer
});
self._formatItems(layer + 1, node.children);
} else {
BI.defaults(node, {
type: "bi.multilayer_icon_tree_leaf_item",
cls: "sort-item",
height: 30,
key: node.id,
layer: layer,
data: {
node: node
}
});
}
});
return nodes;
},
});
BI.shortcut("demo.sort_tree", Demo.SortTree);

4
demo/js/config/category.js

@ -9,4 +9,8 @@ Demo.CATEGORY_CONFIG = [{
pId: 100000,
text: "大表格",
value: "demo.large_table"
}, {
pId: 100000,
text: "可以排序的树",
value: "demo.sort_tree"
}];

17
demo/js/core/layout/demo.horizontal.js

@ -10,14 +10,27 @@ Demo.Horizontal = BI.inherit(BI.Widget, {
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "水平布局",
whiteSpace: "normal",
text: "因为大多数场景下都需要垂直居中,所以这个布局一般会被vertical_adapt布局设置scrollx=true取代",
cls: "layout-bg3",
width: 500,
height: 50
}, {
type: "bi.label",
text: "水平布局",
cls: "layout-bg4",
width: 300,
height: 30
}, {
type: "bi.label",
text: "水平布局",
cls: "layout-bg4",
cls: "layout-bg5",
width: 300,
height: 30
}, {
type: "bi.label",
text: "水平布局",
cls: "layout-bg6",
width: 300,
height: 30
}]

2
dist/base.js vendored

@ -3897,7 +3897,7 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

6
dist/bundle.js vendored

@ -18934,7 +18934,7 @@ $.extend(BI, {
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {
@ -19968,7 +19968,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}
@ -32902,7 +32902,7 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

12
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

4
dist/core.js vendored

@ -18883,7 +18883,7 @@ $.extend(BI, {
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {
@ -19917,7 +19917,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}

211
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
src/base/combination/group.virtual.js

@ -56,7 +56,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

2
src/core/utils/tree.js

@ -365,7 +365,7 @@
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {

2
src/core/wrapper/layout.js

@ -432,7 +432,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}

Loading…
Cancel
Save