From 826705f98ab691fad7682f55ea56c5de4b4fa5e9 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Mar 2017 16:24:01 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/{ => button}/demo.button.js | 0 demo/js/base/{ => button}/demo.icon_button.js | 0 .../js/base/{ => button}/demo.image_button.js | 0 demo/js/base/{ => button}/demo.text_button.js | 0 demo/js/base/{ => editor}/demo.code_editor.js | 0 demo/js/base/{ => editor}/demo.editor.js | 0 .../base/{ => editor}/demo.formula_editor.js | 0 .../{ => editor}/demo.multifile_editor.js | 0 .../base/{ => editor}/demo.textarea_editor.js | 0 demo/js/base/table/demo.collection_table.js | 62 +++ demo/js/base/table/demo.grid_table.js | 57 +++ demo/js/base/table/demo.table_view.js | 367 ++++++++++++++++++ demo/js/base/{ => tip}/demo.bubble.js | 0 demo/js/base/{ => tip}/demo.title.js | 0 demo/js/base/{ => tip}/demo.toast.js | 0 demo/js/case/tree/demo.branch_tree.js | 233 +++++++++++ demo/js/case/tree/demo.display_tree.js | 43 ++ .../case/tree/demo.handstand_branch_tree.js | 103 +++++ demo/js/case/tree/demo.level_tree.js | 87 +++++ demo/js/case/tree/demo.simple_tree.js | 86 ++++ demo/js/config/base.js | 9 +- demo/js/config/case.js | 140 +++---- demo/js/config/core.js | 4 +- demo/js/core/abstract/demo.collection_view.js | 39 ++ demo/js/core/abstract/demo.grid_view.js | 50 +++ dist/base.css | 6 +- dist/base.js | 190 --------- dist/core.js | 3 + src/base/table/table.js | 190 --------- src/core/proto/array.js | 3 + src/css/base/tree/display.tree.css | 6 +- src/less/base/tree/display.tree.less | 6 +- 32 files changed, 1220 insertions(+), 464 deletions(-) rename demo/js/base/{ => button}/demo.button.js (100%) rename demo/js/base/{ => button}/demo.icon_button.js (100%) rename demo/js/base/{ => button}/demo.image_button.js (100%) rename demo/js/base/{ => button}/demo.text_button.js (100%) rename demo/js/base/{ => editor}/demo.code_editor.js (100%) rename demo/js/base/{ => editor}/demo.editor.js (100%) rename demo/js/base/{ => editor}/demo.formula_editor.js (100%) rename demo/js/base/{ => editor}/demo.multifile_editor.js (100%) rename demo/js/base/{ => editor}/demo.textarea_editor.js (100%) create mode 100644 demo/js/base/table/demo.collection_table.js create mode 100644 demo/js/base/table/demo.grid_table.js create mode 100644 demo/js/base/table/demo.table_view.js rename demo/js/base/{ => tip}/demo.bubble.js (100%) rename demo/js/base/{ => tip}/demo.title.js (100%) rename demo/js/base/{ => tip}/demo.toast.js (100%) create mode 100644 demo/js/case/tree/demo.branch_tree.js create mode 100644 demo/js/case/tree/demo.display_tree.js create mode 100644 demo/js/case/tree/demo.handstand_branch_tree.js create mode 100644 demo/js/case/tree/demo.level_tree.js create mode 100644 demo/js/case/tree/demo.simple_tree.js create mode 100644 demo/js/core/abstract/demo.collection_view.js create mode 100644 demo/js/core/abstract/demo.grid_view.js diff --git a/demo/js/base/demo.button.js b/demo/js/base/button/demo.button.js similarity index 100% rename from demo/js/base/demo.button.js rename to demo/js/base/button/demo.button.js diff --git a/demo/js/base/demo.icon_button.js b/demo/js/base/button/demo.icon_button.js similarity index 100% rename from demo/js/base/demo.icon_button.js rename to demo/js/base/button/demo.icon_button.js diff --git a/demo/js/base/demo.image_button.js b/demo/js/base/button/demo.image_button.js similarity index 100% rename from demo/js/base/demo.image_button.js rename to demo/js/base/button/demo.image_button.js diff --git a/demo/js/base/demo.text_button.js b/demo/js/base/button/demo.text_button.js similarity index 100% rename from demo/js/base/demo.text_button.js rename to demo/js/base/button/demo.text_button.js diff --git a/demo/js/base/demo.code_editor.js b/demo/js/base/editor/demo.code_editor.js similarity index 100% rename from demo/js/base/demo.code_editor.js rename to demo/js/base/editor/demo.code_editor.js diff --git a/demo/js/base/demo.editor.js b/demo/js/base/editor/demo.editor.js similarity index 100% rename from demo/js/base/demo.editor.js rename to demo/js/base/editor/demo.editor.js diff --git a/demo/js/base/demo.formula_editor.js b/demo/js/base/editor/demo.formula_editor.js similarity index 100% rename from demo/js/base/demo.formula_editor.js rename to demo/js/base/editor/demo.formula_editor.js diff --git a/demo/js/base/demo.multifile_editor.js b/demo/js/base/editor/demo.multifile_editor.js similarity index 100% rename from demo/js/base/demo.multifile_editor.js rename to demo/js/base/editor/demo.multifile_editor.js diff --git a/demo/js/base/demo.textarea_editor.js b/demo/js/base/editor/demo.textarea_editor.js similarity index 100% rename from demo/js/base/demo.textarea_editor.js rename to demo/js/base/editor/demo.textarea_editor.js diff --git a/demo/js/base/table/demo.collection_table.js b/demo/js/base/table/demo.collection_table.js new file mode 100644 index 000000000..c2b46675a --- /dev/null +++ b/demo/js/base/table/demo.collection_table.js @@ -0,0 +1,62 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + var items = [], header = [], columnSize = []; + + var rowCount = 100, columnCount = 100; + for (var i = 0; i < 1; i++) { + header[i] = []; + for (var j = 0; j < columnCount; j++) { + header[i][j] = { + type: "bi.label", + text: "表头" + i + "-" + j + } + columnSize[j] = 100; + } + } + for (var i = 0; i < rowCount; i++) { + items[i] = []; + for (var j = 0; j < columnCount; j++) { + items[i][j] = { + type: "bi.label", + text: (i < 3 ? 0 : i) + "-" + j + } + } + } + + var table = BI.createWidget({ + type: "bi.resizable_table", + el: { + type: "bi.collection_table" + }, + width: 600, + height: 500, + isResizeAdapt: true, + isNeedResize: true, + isNeedMerge: true, + mergeCols: [0, 1], + mergeRule: function (col1, col2) { + return BI.isEqual(col1, col2); + }, + isNeedFreeze: true, + freezeCols: [0, 1], + columnSize: columnSize, + items: items, + header: header + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: table, + left: 10, + right: 10, + top: 10, + bottom: 10 + }] + }) + } +}); +$.shortcut("demo.collection_table", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/table/demo.grid_table.js b/demo/js/base/table/demo.grid_table.js new file mode 100644 index 000000000..11748f972 --- /dev/null +++ b/demo/js/base/table/demo.grid_table.js @@ -0,0 +1,57 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + var items = [], header = [], columnSize = []; + + var rowCount = 100, columnCount = 100; + for (var i = 0; i < 1; i++) { + header[i] = []; + for (var j = 0; j < columnCount; j++) { + header[i][j] = { + type: "bi.label", + text: "表头" + i + "-" + j + } + columnSize[j] = 100; + } + } + for (var i = 0; i < rowCount; i++) { + items[i] = []; + for (var j = 0; j < columnCount; j++) { + items[i][j] = { + type: "bi.label", + text: (i < 3 ? 0 : i) + "-" + j + } + } + } + + var table = BI.createWidget({ + type: "bi.resizable_table", + el: { + type: "bi.grid_table", + }, + width: 600, + height: 500, + isResizeAdapt: true, + isNeedResize: true, + isNeedFreeze: true, + freezeCols: [0, 1], + columnSize: columnSize, + items: items, + header: header + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: table, + left: 10, + right: 10, + top: 10, + bottom: 10 + }] + }) + } +}); +$.shortcut("demo.grid_table", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/table/demo.table_view.js b/demo/js/base/table/demo.table_view.js new file mode 100644 index 000000000..9f5a37b77 --- /dev/null +++ b/demo/js/base/table/demo.table_view.js @@ -0,0 +1,367 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + var items = [[{ + text: "第一行第一列" + }, { + text: "第一行第一列" + }, { + text: "第一行第一列" + }], [{ + text: "第一行第一列" + }, { + text: "第一行第一列" + }, { + text: "第一行第一列" + }], [{ + text: "第三行第一列" + }, { + text: "第三行第二列" + }, { + text: "第三行第三列" + }], [{ + text: "第四行第一列" + }, { + text: "第四行第二列" + }, { + text: "第四行第三列" + }], [{ + text: "第五行第一列" + }, { + text: "第五行第二列" + }, { + text: "第五行第三列" + }], [{ + text: "第六行第一列" + }, { + text: "第六行第二列" + }, { + text: "第六行第三列" + }], [{ + text: "第七行第一列" + }, { + text: "第七行第二列" + }, { + text: "第七行第三列" + }], [{ + text: "第八行第一列" + }, { + text: "第八行第二列" + }, { + text: "第八行第三列" + }], [{ + text: "第九行第一列" + }, { + text: "第九行第二列" + }, { + text: "第九行第三列" + }], [{ + text: "第十行第一列" + }, { + text: "第十行第二列" + }, { + text: "第十行第三列" + }], [{ + text: "第十一行第一列" + }, { + text: "第十一行第二列" + }, { + text: "第十一行第三列" + }], [{ + text: "第十二行第一列" + }, { + text: "第十二行第二列" + }, { + text: "第十二行第三列" + }], [{ + text: "第十三行第一列" + }, { + text: "第十三行第二列" + }, { + text: "第十三行第三列" + }], [{ + text: "第十四行第一列" + }, { + text: "第十四行第二列" + }, { + text: "第十四行第三列" + }], [{ + text: "第十五行第一列" + }, { + text: "第十五行第二列" + }, { + text: "第十五行第三列" + }], [{ + text: "第十六行第一列" + }, { + text: "第十六行第二列" + }, { + text: "第十六行第三列" + }], [{ + text: "第十七行第一列" + }, { + text: "第十七行第二列" + }, { + text: "第十七行第三列" + }], [{ + text: "第十八行第一列" + }, { + text: "第十八行第二列" + }, { + text: "第十八行第三列" + }]]; + + + var items2 = [[{ + text: "第一行第一列" + }, { + text: "第一行第二列" + }, { + text: "第一行第三列" + }, { + text: "第一行第四列" + }, { + text: "第一行第五列" + }], [{ + text: "第二行第一列" + }, { + text: "第二行第二列" + }, { + text: "第二行第三列" + }, { + text: "第二行第四列" + }, { + text: "第二行第五列" + }], [{ + text: "第二行第一列" + }, { + text: "第二行第二列" + }, { + text: "第三行第三列" + }, { + text: "第三行第四列" + }, { + text: "第三行第五列" + }], [{ + text: "第二行第一列" + }, { + text: "第四行第二列" + }, { + text: "第四行第三列" + }, { + text: "第四行第四列" + }, { + text: "第四行第五列" + }] + + + , [{ + text: "第五行第一列" + }, { + text: "第五行第一列" + }, { + text: "第五行第三列" + }, { + text: "第五行第四列" + }, { + text: "第五行第五列" + }], [{ + text: "第六行第一列" + }, { + text: "第六行第一列" + }, { + text: "第六行第三列" + }, { + text: "第六行第四列" + }, { + text: "第六行第五列" + }], [{ + text: "第七行第一列" + }, { + text: "第七行第二列" + }, { + text: "第七行第三列" + }, { + text: "第七行第四列" + }, { + text: "第七行第五列" + }], [{ + text: "第八行第一列" + }, { + text: "第八行第二列" + }, { + text: "第八行第三列" + }, { + text: "第八行第四列" + }, { + text: "第八行第五列" + }], [{ + text: "第九行第一列" + }, { + text: "第九行第二列" + }, { + text: "第九行第三列" + }, { + text: "第九行第四列" + }, { + text: "第九行第五列" + }], [{ + text: "第十行第一列" + }, { + text: "第十行第二列" + }, { + text: "第十行第三列" + }, { + text: "第十行第四列" + }, { + text: "第十行第五列" + }], [{ + text: "第十一行第一列" + }, { + text: "第十一行第二列" + }, { + text: "第十一行第三列" + }, { + text: "第十一行第四列" + }, { + text: "第十一行第五列" + }], [{ + text: "第十二行第一列" + }, { + text: "第十二行第二列" + }, { + text: "第十二行第三列" + }, { + text: "第十二行第四列" + }, { + text: "第十二行第五列" + }], [{ + text: "第十三行第一列" + }, { + text: "第十三行第二列" + }, { + text: "第十三行第三列" + }, { + text: "第十三行第四列" + }, { + text: "第十三行第五列" + }], [{ + text: "第十四行第一列" + }, { + text: "第十四行第二列" + }, { + text: "第十四行第三列" + }, { + text: "第十四行第四列" + }, { + text: "第十四行第五列" + }]]; + + var header = [[{ + text: "表头1" + }, { + text: "表头2" + }, { + text: "表头3" + }]]; + + var header2 = [[{ + text: "表头1" + }, { + text: "表头2" + }, { + text: "表头3" + }, { + text: "表头4" + }, { + text: "表头5" + }]]; + + var table1 = BI.createWidget({ + type: "bi.table_view", + isNeedResize: true, + isNeedMerge: true, + mergeCols: [0, 1], + columnSize: [100, 200, 300], + items: items, + header: header + }); + var table2 = BI.createWidget({ + type: "bi.table_view", + isNeedMerge: true, + isNeedFreeze: true, + freezeCols: [0, 1], + mergeCols: [0, 1], + columnSize: [100, 200, 300, 400, 500], + items: items2, + header: header2 + }); + var table3 = BI.createWidget({ + type: "bi.table_view", + isNeedMerge: true, + isNeedFreeze: true, + freezeCols: [4], + mergeCols: [0, 1], + columnSize: [100, 200, 300, 400, 100], + items: items2, + header: header2 + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: { + type: "bi.grid", + columns: 2, + rows: 2, + items: [{ + column: 0, + row: 0, + el: table1 + }, { + column: 1, + row: 0, + el: table2 + }, { + column: 0, + row: 1, + el: table3 + }, { + column: 1, + row: 1, + el: { + type: "bi.vertical", + items: [{ + type: "bi.button", + text: "第一个表setColumnSize([300, 200, 100])", + handler: function () { + table1.setColumnSize([300, 200, 100]); + } + }, { + type: "bi.button", + text: "第二个表setColumnSize([50, 100, 150, 200, 250])", + handler: function () { + table2.setColumnSize([50, 100, 150, 200, 250]); + } + }, { + type: "bi.button", + text: "第三个表setColumnSize([50, 100, 150, 200, 50])", + handler: function () { + table3.setColumnSize([50, 100, 150, 200, 50]); + } + }], + vgap: 10 + } + }] + }, + left: 10, + right: 10, + top: 10, + bottom: 10 + }] + }) + } +}); +$.shortcut("demo.table_view", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/demo.bubble.js b/demo/js/base/tip/demo.bubble.js similarity index 100% rename from demo/js/base/demo.bubble.js rename to demo/js/base/tip/demo.bubble.js diff --git a/demo/js/base/demo.title.js b/demo/js/base/tip/demo.title.js similarity index 100% rename from demo/js/base/demo.title.js rename to demo/js/base/tip/demo.title.js diff --git a/demo/js/base/demo.toast.js b/demo/js/base/tip/demo.toast.js similarity index 100% rename from demo/js/base/demo.toast.js rename to demo/js/base/tip/demo.toast.js diff --git a/demo/js/case/tree/demo.branch_tree.js b/demo/js/case/tree/demo.branch_tree.js new file mode 100644 index 000000000..76d1ad7ba --- /dev/null +++ b/demo/js/case/tree/demo.branch_tree.js @@ -0,0 +1,233 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + _createBranchTree: function () { + var tree = BI.createWidget({ + type: "bi.branch_tree", + items: [{ + el: { + text: "且", + value: "且1", + cls: "layout-bg7" + }, + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1", + value: "这里是一段文字1" + }, { + el: { + text: "或", + value: "或2", + cls: "layout-bg7" + }, + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1435", + value: "这里是一段文字1435" + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1xx", + value: "这里是一段文字1xx" + }, { + el: { + text: "且", + value: "且3", + cls: "layout-bg7" + }, + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "可以理解为一个条件", + value: "可以理解为一个条件" + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "可以理解为一个条件v", + value: "可以理解为一个条件v" + }] + }] + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1xa", + value: "这里是一段文字1xa" + }] + }] + }); + return tree; + }, + + _createBranchMapTree: function () { + var tree = BI.createWidget({ + type: "bi.branch_tree", + el: { + type: "bi.button_group" + }, + items: [{ + text: "且", + value: "且1", + cls: "layout-bg7", + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1", + value: "这里是一段文字1" + }, { + text: "或", + value: "或2", + cls: "layout-bg7", + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1435", + value: "这里是一段文字1435" + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1xx", + value: "这里是一段文字1xx" + }, { + text: "且", + value: "且3", + cls: "layout-bg7", + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "可以理解为一个条件", + value: "可以理解为一个条件" + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "可以理解为一个条件v", + value: "可以理解为一个条件v" + }] + }] + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1xa", + value: "这里是一段文字1xa" + }] + }] + }); + return tree; + }, + + render: function () { + var tree = this._createBranchTree(); + var mapTree = this._createBranchMapTree(); + + function getItems() { + return [{ + text: "且", + value: "且", + cls: "layout-bg7", + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字", + value: "这里是一段文字" + }, { + text: "或", + value: "或2", + cls: "layout-bg7", + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字", + value: "这里是一段文字" + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字" + BI.UUID(), + value: "这里是一段文字" + BI.UUID() + }, { + text: "且", + value: "且3", + cls: "layout-bg7", + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "可以理解为一个条件", + value: "可以理解为一个条件" + }] + }] + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1xa", + value: "这里是一段文字1xa" + }] + }]; + } + + BI.createWidget({ + type: "bi.center", + element: this, + items: [{ + type: "bi.vtape", + items: [{ + el: tree + }, { + height: 30, + el: { + type: "bi.button", + height: 30, + text: "getValue", + handler: function () { + BI.Msg.alert("", tree.getValue()); + } + } + }] + }, { + type: "bi.vtape", + items: [{ + el: mapTree + }, { + height: 30, + el: { + type: "bi.button", + height: 30, + text: "populate", + handler: function () { + mapTree.populate(getItems()); + } + } + }, { + height: 30, + el: { + type: "bi.button", + height: 30, + text: "getValue", + handler: function () { + BI.Msg.alert("", mapTree.getValue()); + } + } + }] + }] + }) + } +}); +$.shortcut("demo.branch_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/case/tree/demo.display_tree.js b/demo/js/case/tree/demo.display_tree.js new file mode 100644 index 000000000..2fc41ab2e --- /dev/null +++ b/demo/js/case/tree/demo.display_tree.js @@ -0,0 +1,43 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + var tree = BI.createWidget({ + type: "bi.display_tree", + element: this + }); + + tree.initTree([{ + id: 1, + text: "第一项", + open: true + }, { + id: 2, + text: "第二项" + }, { + id: 11, + pId: 1, + text: "子项1(共2个)", + open: true + }, { + id: 111, + pId: 11, + text: "子子项1" + }, { + id: 112, + pId: 11, + text: "子子项2" + }, { + id: 12, + pId: 1, + text: "子项2" + }, { + id: 13, + pId: 1, + text: "子项3" + }]); + } +}); +$.shortcut("demo.display_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/case/tree/demo.handstand_branch_tree.js b/demo/js/case/tree/demo.handstand_branch_tree.js new file mode 100644 index 000000000..e8a6342ef --- /dev/null +++ b/demo/js/case/tree/demo.handstand_branch_tree.js @@ -0,0 +1,103 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + _createHandStandBranchTree: function () { + var tree = BI.createWidget({ + type: "bi.handstand_branch_tree", + expander: {}, + el: { + layouts: [{ + type: "bi.horizontal_adapt", + verticalAlign: BI.VerticalAlign.Top + }] + }, + items: [{ + el: { + text: "且", + value: "且1", + cls: "layout-bg7" + }, + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1", + value: "这里是一段文字1" + }, { + el: { + text: "或", + value: "或2", + cls: "layout-bg7" + }, + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1435", + value: "这里是一段文字1435" + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1xx", + value: "这里是一段文字1xx" + }, { + el: { + text: "且", + value: "且3", + cls: "layout-bg7" + }, + children: [{ + type: "bi.label", + height: 30, + textAlign: "left", + text: "可以理解为一个条件", + value: "可以理解为一个条件" + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "可以理解为一个条件v", + value: "可以理解为一个条件v" + }] + }] + }, { + type: "bi.label", + height: 30, + textAlign: "left", + text: "这里是一段文字1xa", + value: "这里是一段文字1xa" + }] + }] + }); + return tree; + }, + + render: function () { + var tree = this._createHandStandBranchTree(); + + BI.createWidget({ + type: "bi.center", + element: this, + items: [{ + type: "bi.vtape", + items: [{ + el: tree + }, { + height: 30, + el: { + type: "bi.button", + height: 30, + text: "getValue", + handler: function () { + BI.Msg.alert("", tree.getValue()); + } + } + }] + }] + }) + } +}); +$.shortcut("demo.handstand_branch_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/case/tree/demo.level_tree.js b/demo/js/case/tree/demo.level_tree.js new file mode 100644 index 000000000..6dc4bc74a --- /dev/null +++ b/demo/js/case/tree/demo.level_tree.js @@ -0,0 +1,87 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + var tree = BI.createWidget({ + type: "bi.level_tree", + chooseType: 0, + items: [{ + id: 1, + text: "第一项", + value: 1, + isParent: true + }, { + id: 2, + text: "第二项", + value: 2, + isParent: true + }, { + id: 3, + text: "第三项", + value: 1, + isParent: true, + open: true + }, { + id: 4, + text: "第四项", + value: 1 + }, { + id: 11, + pId: 1, + text: "子项1", + value: 11 + }, { + id: 12, + pId: 1, + text: "子项2", + value: 12 + }, { + id: 13, + pId: 1, + text: "子项3", + value: 13 + }, { + id: 21, + pId: 2, + text: "子项1", + value: 21 + }, { + id: 31, + pId: 3, + text: "子项1", + value: 31 + }, { + id: 32, + pId: 3, + text: "子项2", + value: 32 + }, { + id: 33, + pId: 3, + text: "子项3", + value: 33 + }] + }) + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: tree + }, { + height: 30, + el: { + type: "bi.button", + height: 30, + text: "getValue", + handler: function () { + BI.Msg.alert("", tree.getValue()); + } + } + }] + }) + } +}); +$.shortcut("demo.level_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/case/tree/demo.simple_tree.js b/demo/js/case/tree/demo.simple_tree.js new file mode 100644 index 000000000..bd2f27c06 --- /dev/null +++ b/demo/js/case/tree/demo.simple_tree.js @@ -0,0 +1,86 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + //value值一定要是字符串 + var tree = BI.createWidget({ + type: "bi.simple_tree", + items: [] + }); + + tree.populate([{ + id: 1, + text: "第一项", + value: "1" + }, { + id: 2, + text: "第二项", + value: "2" + }, { + id: 3, + text: "第三项", + value: "3", + open: true + }, { + id: 11, + pId: 1, + text: "子项1", + value: "11" + }, { + id: 12, + pId: 1, + text: "子项2", + value: "12" + }, { + id: 13, + pId: 1, + text: "子项3", + value: "13" + }, { + id: 31, + pId: 3, + text: "子项1", + value: "31" + }, { + id: 32, + pId: 3, + text: "子项2", + value: "32" + }, { + id: 33, + pId: 3, + text: "子项3", + value: "33" + }], "z"); + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: tree + }, { + height: 30, + el: { + type: "bi.button", + height: 30, + text: "setValue(['31', '32', '33'])", + handler: function () { + tree.setValue(['31', '32', '33']); + } + } + }, { + height: 30, + el: { + type: "bi.button", + height: 30, + text: "getValue", + handler: function () { + BI.Msg.alert("", JSON.stringify(tree.getValue())); + } + } + }] + }) + } +}); +$.shortcut("demo.simple_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/config/base.js b/demo/js/config/base.js index 15c4018ee..8f5de28a4 100644 --- a/demo/js/config/base.js +++ b/demo/js/config/base.js @@ -1,6 +1,7 @@ Demo.BASE_CONFIG = [{ id: 2, text: "基础控件", + open: true }, { pId: 2, text: "bi.label", @@ -91,12 +92,12 @@ Demo.BASE_CONFIG = [{ value: "demo.table_view" }, { pId: 204, - text: "bi.table_grid", - value: "demo.table_grid" + text: "bi.grid_table", + value: "demo.grid_table" }, { pId: 204, - text: "bi.table_collection", - value: "demo.table_collection" + text: "bi.collection_table", + value: "demo.collection_table" }, { pId: 2, text: "bi.canvas", diff --git a/demo/js/config/case.js b/demo/js/config/case.js index 78ec8086e..da7cdbfb5 100644 --- a/demo/js/config/case.js +++ b/demo/js/config/case.js @@ -30,6 +30,30 @@ Demo.CASE_CONFIG = [{ pId: 302, text: "bi.bubble_combo", value: "demo.bubble_combo" +}, { + pId: 3, + id: 303, + text: "tree" +}, { + pId: 303, + text: "bi.branch_tree", + value: "demo.branch_tree" +}, { + pId: 303, + text: "bi.handstand_branch_tree", + value: "demo.handstand_branch_tree" +}, { + pId: 303, + text: "bi.display_tree", + value: "demo.display_tree" +}, { + pId: 303, + text: "bi.simple_tree", + value: "demo.simple_tree" +}, { + pId: 303, + text: "bi.level_tree", + value: "demo.level_tree" }, { pId: 3, text: "bi.calendar", @@ -46,72 +70,50 @@ Demo.CASE_CONFIG = [{ pId: 3, text: "bi.color_chooser", value: "demo.color_chooser" -}, { - pId: 3, - text: "各种checkbox", - value: "demo.checkboxes" -}, { - pId: 3, - text: "各种tip", - value: "demo.tips" -}, { - pId: 3, - text: "bi.branch_expander", - value: "demo.branch_expander" -}, { - pId: 3, - text: "bi.float_box", - value: "demo.float_box" -}, { - pId: 3, - text: "bi.float_box", - value: "demo.float_box" -}, { - pId: 3, - text: "bi.segment", - value: "demo.segment" -}, { - pId: 3, - id: 12, - text: "各种表格" -}, { - pId: 3, - id: 13, - text: "各种tree" -}, { - pId: 3, - text: "各种trigger", - value: "demo.triggers" -}, { - pId: 12, - text: "bi.adaptive_table", - value: "demo.adaptive_table" -}, { - pId: 12, - text: "bi.table_tree", - value: "demo.table_tree" -}, { - pId: 12, - text: "bi.layer_tree_table", - value: "demo.layer_tree_table" -}, { - pId: 13, - text: "bi.branch_tree", - value: "demo.branch_tree" -}, { - pId: 13, - text: "bi.display_tree", - value: "demo.display_tree" -}, { - pId: 13, - text: "bi.level_tree", - value: "demo.level_tree" -}, { - pId: 13, - text: "bi.simple_tree", - value: "demo.simple_tree" -}, { - pId: 13, - text: "bi.handstand_branch_tree", - value: "demo.handstand_branch_tree" -}]; \ No newline at end of file +}, + + { + pId: 3, + text: "各种checkbox", + value: "demo.checkboxes" + }, { + pId: 3, + text: "各种tip", + value: "demo.tips" + }, { + pId: 3, + text: "bi.float_box", + value: "demo.float_box" + }, { + pId: 3, + text: "bi.float_box", + value: "demo.float_box" + }, { + pId: 3, + text: "bi.segment", + value: "demo.segment" + }, { + pId: 3, + id: 12, + text: "各种表格" + }, { + pId: 3, + id: 13, + text: "各种tree" + }, { + pId: 3, + text: "各种trigger", + value: "demo.triggers" + }, { + pId: 12, + text: "bi.adaptive_table", + value: "demo.adaptive_table" + }, { + pId: 12, + text: "bi.table_tree", + value: "demo.table_tree" + }, { + pId: 12, + text: "bi.layer_tree_table", + value: "demo.layer_tree_table" + }]; \ No newline at end of file diff --git a/demo/js/config/core.js b/demo/js/config/core.js index ab185ddde..bd8792d5b 100644 --- a/demo/js/config/core.js +++ b/demo/js/config/core.js @@ -159,8 +159,8 @@ Demo.CORE_CONFIG = [{ value: "demo.grid_view" }, { pId: 102, - text: "bi.collection", - value: "demo.collection" + text: "bi.collection_view", + value: "demo.collection_view" }, { pId: 1, text: "widget", diff --git a/demo/js/core/abstract/demo.collection_view.js b/demo/js/core/abstract/demo.collection_view.js new file mode 100644 index 000000000..f98c84934 --- /dev/null +++ b/demo/js/core/abstract/demo.collection_view.js @@ -0,0 +1,39 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + var items = []; + var cellCount = 100; + for (var i = 0; i < cellCount; i++) { + items[i] = { + type: "bi.label", + text: i + }; + } + var grid = BI.createWidget({ + type: "bi.collection_view", + items: items, + cellSizeAndPositionGetter: function (index) { + return { + x: index % 10 * 50, + y: Math.floor(index / 10) * 50, + width: 50, + height: 50 + } + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: grid, + left: 10, + right: 10, + top: 10, + bottom: 10 + }] + }) + } +}); +$.shortcut("demo.collection_view", Demo.Func); \ No newline at end of file diff --git a/demo/js/core/abstract/demo.grid_view.js b/demo/js/core/abstract/demo.grid_view.js new file mode 100644 index 000000000..a524e684d --- /dev/null +++ b/demo/js/core/abstract/demo.grid_view.js @@ -0,0 +1,50 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + var items = []; + var rowCount = 10000, columnCount = 100; + for (var i = 0; i < rowCount; i++) { + items[i] = []; + for (var j = 0; j < columnCount; j++) { + items[i][j] = { + type: "bi.label", + text: i + "-" + j + } + } + } + var grid = BI.createWidget({ + type: "bi.grid_view", + items: items, + scrollTop: 100, + rowHeightGetter: function () { + return 30; + }, + columnWidthGetter: function () { + return 100; + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: { + type: "bi.grid", + columns: 1, + rows: 1, + items: [{ + column: 0, + row: 0, + el: grid + }] + }, + left: 10, + right: 10, + top: 10, + bottom: 10 + }] + }) + } +}); +$.shortcut("demo.grid_view", Demo.Func); \ No newline at end of file diff --git a/dist/base.css b/dist/base.css index 67ef3c40e..2a8560251 100644 --- a/dist/base.css +++ b/dist/base.css @@ -2190,13 +2190,13 @@ ul.ztree.zTreeDragUL { color: #808080; } .bi-display-tree .ztree li span.button.switch.center_open { - background-image: url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-3.png"); + background-image: url("icon/tree-vertical-line-3.png"); } .bi-display-tree .ztree li span.button.switch.roots_open { - background-image: url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-2.png"); + background-image: url("icon/tree-vertical-line-2.png"); } .bi-display-tree .ztree li span.button.switch.bottom_open { - background-image: url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-4.png"); + background-image: url("icon/tree-vertical-line-4.png"); } .bi-display-tree .ztree li a, .bi-display-tree .ztree li span { diff --git a/dist/base.js b/dist/base.js index 8406bf687..4e032f162 100644 --- a/dist/base.js +++ b/dist/base.js @@ -30238,9 +30238,6 @@ BI.Table = BI.inherit(BI.Widget, { dynamic: false }, - isNeedResize: false,//是否需要调整列宽 - isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 - isNeedFreeze: false,//是否需要冻结单元格 freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 @@ -30518,111 +30515,6 @@ BI.Table = BI.inherit(BI.Widget, { return o.columnSize[col] > 1 ? o.columnSize[col] + 1 : o.columnSize[col]; }); - if (o.isNeedResize) { - var resizer; - var createResizer = function (size, position) { - var rowSize = self.getCalculateRegionRowSize(); - resizer = BI.createWidget({ - type: "bi.layout", - cls: "bi-resizer", - width: size.width, - height: rowSize[0] + rowSize[1] - }); - BI.createWidget({ - type: "bi.absolute", - element: "body", - items: [{ - el: resizer, - left: position.left, - top: position.top - rowSize[0] - }] - }); - }; - var resizeResizer = function (size, position) { - var rowSize = self.getCalculateRegionRowSize(); - var columnSize = self.getCalculateRegionColumnSize(); - var height = rowSize[0] + rowSize[1]; - var sumSize = columnSize[0] + columnSize[1]; - if (size.width > sumSize / 5 * 4) { - size.width = sumSize / 5 * 4; - } - if (size.width < 10) { - size.width = 10; - } - resizer.element.css({ - "left": position.left + "px", - "width": size.width + "px", - "height": height + "px" - }); - }; - var stopResizer = function () { - resizer && resizer.destroy(); - resizer = null; - }; - var handle; - if (o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - if (isRight) { - var options = { - handles: "w", - minWidth: 15, - helper: "clone", - start: function (event, ui) { - createResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE); - }, - resize: function (e, ui) { - resizeResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE); - e.stopPropagation(); - //return false; - }, - stop: function (e, ui) { - stopResizer(); - if (o.isResizeAdapt) { - var increment = ui.size.width - (BI.sum(self.columnRight) + self.columnRight.length); - o.columnSize[self.columnLeft.length] += increment; - } else { - self.setRegionColumnSize(["fill", ui.size.width]); - } - self._resize(); - ui.element.css("left", ""); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE); - } - }; - self.bottomRight.element.resizable(options); - handle = $(".ui-resizable-handle", this.bottomRight.element).css("top", -1 * headerHeight); - } else { - var options = { - handles: "e", - minWidth: 15, - helper: "clone", - start: function (event, ui) { - createResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE); - }, - resize: function (e, ui) { - resizeResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE); - e.stopPropagation(); - //return false; - }, - stop: function (e, ui) { - stopResizer(); - if (o.isResizeAdapt) { - var increment = ui.size.width - (BI.sum(self.columnLeft) + self.columnLeft.length); - o.columnSize[self.columnLeft.length - 1] += increment; - } else { - self.setRegionColumnSize([ui.size.width, "fill"]); - } - self._resize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE); - } - }; - self.bottomLeft.element.resizable(options); - handle = $(".ui-resizable-handle", this.bottomLeft.element).css("top", -1 * headerHeight); - } - } - } this._resize = function () { if (self.scrollBottomLeft.element.is(":visible")) { self.scrollBottomLeft.element.css({"overflow-x": "auto"}); @@ -30650,10 +30542,6 @@ BI.Table = BI.inherit(BI.Widget, { self.scrollTopLeft.element[0].scrollLeft = self.scrollBottomLeft.element[0].scrollLeft; self.scrollTopRight.element[0].scrollLeft = self.scrollBottomRight.element[0].scrollLeft; self.scrollBottomLeft.element[0].scrollTop = self.scrollBottomRight.element[0].scrollTop; - //调整拖拽handle的高度 - if (o.isNeedResize) { - handle && handle.css("height", self.bottomLeft.element.height() + headerHeight); - } } }; @@ -31121,70 +31009,6 @@ BI.Table = BI.inherit(BI.Widget, { start || (start = 0); var frag = this._createCells(items, columnSize, BI.range(o.columnSize.length), TDs, Ws, start, o.headerRowSize || o.rowSize); - if (o.isNeedResize === true) { - var tds = TDs[BI.size(TDs) - 1]; - BI.each(tds, function (j, td) { - j = j | 0; - var resizer; - var getHeight = function (size, position) { - var rowSize = self.getCalculateRegionRowSize(); - if (o.isNeedFreeze === true) { - var tableHeight = self.bottomRightContainer.element.outerHeight(); - return size.height + Math.min(rowSize[1], tableHeight); - } else { - var tableHeight = self.tableContainer.element.outerHeight(); - var offset = self.tableContainer.element.offset(); - var offsetTop = position.top - offset.top; - var height = tableHeight - offsetTop; - height = Math.min(height, rowSize[0] - offsetTop); - return height; - } - }; - if (j < BI.size(tds) - 1) { - td.resizable({ - handles: "e", - minWidth: 15, - helper: "clone", - start: function (event, ui) { - var height = getHeight(ui.size, ui.position); - resizer = BI.createWidget({ - type: "bi.layout", - cls: "bi-resizer", - width: ui.size.width, - height: height - }); - - BI.createWidget({ - type: "bi.absolute", - element: "body", - items: [{ - el: resizer, - left: ui.position.left, - top: ui.position.top - }] - }); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE); - }, - resize: function (e, ui) { - var height = getHeight(ui.size, ui.position); - resizer.element.css({"width": ui.size.width + "px", "height": height + "px"}); - //o.columnSize[start + j] = ui.size.width; - //self.setColumnSize(o.columnSize); - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE); - e.stopPropagation(); - //return false; - }, - stop: function (e, ui) { - resizer.destroy(); - resizer = null; - o.columnSize[start + j] = ui.size.width - 1; - self.setColumnSize(o.columnSize); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE); - } - }) - } - }) - } return frag; }, @@ -31576,13 +31400,6 @@ BI.Table = BI.inherit(BI.Widget, { this.bottomRightContainer.element.width(isRight ? lw : rw); this.scrollTopLeft.element[0].scrollLeft = this.scrollBottomLeft.element[0].scrollLeft; this.scrollTopRight.element[0].scrollLeft = this.scrollBottomRight.element[0].scrollLeft; - if (o.isNeedResize && o.isResizeAdapt) { - var leftWidth = BI.sum(o.freezeCols, function (i, col) { - return o.columnSize[col] > 1 ? o.columnSize[col] + 1 : o.columnSize[col]; - }); - this.partitions.attr("columnSize", isRight ? ['fill', leftWidth] : [leftWidth, 'fill']); - this.partitions.resize(); - } } else { BI.each(this.colgroupTds, function (i, colgroup) { var width = colgroup.attr("width") | 0; @@ -32044,13 +31861,6 @@ BI.Table = BI.inherit(BI.Widget, { this.topRightContainer.element.width(isRight ? lw : rw); this.scrollTopLeft.element[0].scrollLeft = this.scrollBottomLeft.element[0].scrollLeft; this.scrollTopRight.element[0].scrollLeft = this.scrollBottomRight.element[0].scrollLeft; - if (o.isNeedResize && o.isResizeAdapt) { - var leftWidth = BI.sum(o.freezeCols, function (i, col) { - return columnSize[col] > 1 ? columnSize[col] + 1 : columnSize[col]; - }); - this.partitions.attr("columnSize", isRight ? ['fill', leftWidth] : [leftWidth, 'fill']); - this.partitions.resize(); - } } else { BI.each(this.colgroupTds, function (i, colgroup) { var width = colgroup.attr("width") | 0; diff --git a/dist/core.js b/dist/core.js index 53619f129..0ed721a35 100644 --- a/dist/core.js +++ b/dist/core.js @@ -23083,6 +23083,9 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, { * @class Array */ $.extend(Array.prototype, { + contains: function (o) { + return this.indexOf(o) > -1; + }, /** * 检查指定的值是否在数组中 * @param {Object} o 要检查的值 diff --git a/src/base/table/table.js b/src/base/table/table.js index 91d1b03de..01da6ef40 100644 --- a/src/base/table/table.js +++ b/src/base/table/table.js @@ -17,9 +17,6 @@ BI.Table = BI.inherit(BI.Widget, { dynamic: false }, - isNeedResize: false,//是否需要调整列宽 - isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 - isNeedFreeze: false,//是否需要冻结单元格 freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 @@ -297,111 +294,6 @@ BI.Table = BI.inherit(BI.Widget, { return o.columnSize[col] > 1 ? o.columnSize[col] + 1 : o.columnSize[col]; }); - if (o.isNeedResize) { - var resizer; - var createResizer = function (size, position) { - var rowSize = self.getCalculateRegionRowSize(); - resizer = BI.createWidget({ - type: "bi.layout", - cls: "bi-resizer", - width: size.width, - height: rowSize[0] + rowSize[1] - }); - BI.createWidget({ - type: "bi.absolute", - element: "body", - items: [{ - el: resizer, - left: position.left, - top: position.top - rowSize[0] - }] - }); - }; - var resizeResizer = function (size, position) { - var rowSize = self.getCalculateRegionRowSize(); - var columnSize = self.getCalculateRegionColumnSize(); - var height = rowSize[0] + rowSize[1]; - var sumSize = columnSize[0] + columnSize[1]; - if (size.width > sumSize / 5 * 4) { - size.width = sumSize / 5 * 4; - } - if (size.width < 10) { - size.width = 10; - } - resizer.element.css({ - "left": position.left + "px", - "width": size.width + "px", - "height": height + "px" - }); - }; - var stopResizer = function () { - resizer && resizer.destroy(); - resizer = null; - }; - var handle; - if (o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - if (isRight) { - var options = { - handles: "w", - minWidth: 15, - helper: "clone", - start: function (event, ui) { - createResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE); - }, - resize: function (e, ui) { - resizeResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE); - e.stopPropagation(); - //return false; - }, - stop: function (e, ui) { - stopResizer(); - if (o.isResizeAdapt) { - var increment = ui.size.width - (BI.sum(self.columnRight) + self.columnRight.length); - o.columnSize[self.columnLeft.length] += increment; - } else { - self.setRegionColumnSize(["fill", ui.size.width]); - } - self._resize(); - ui.element.css("left", ""); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE); - } - }; - self.bottomRight.element.resizable(options); - handle = $(".ui-resizable-handle", this.bottomRight.element).css("top", -1 * headerHeight); - } else { - var options = { - handles: "e", - minWidth: 15, - helper: "clone", - start: function (event, ui) { - createResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE); - }, - resize: function (e, ui) { - resizeResizer(ui.size, ui.position); - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE); - e.stopPropagation(); - //return false; - }, - stop: function (e, ui) { - stopResizer(); - if (o.isResizeAdapt) { - var increment = ui.size.width - (BI.sum(self.columnLeft) + self.columnLeft.length); - o.columnSize[self.columnLeft.length - 1] += increment; - } else { - self.setRegionColumnSize([ui.size.width, "fill"]); - } - self._resize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE); - } - }; - self.bottomLeft.element.resizable(options); - handle = $(".ui-resizable-handle", this.bottomLeft.element).css("top", -1 * headerHeight); - } - } - } this._resize = function () { if (self.scrollBottomLeft.element.is(":visible")) { self.scrollBottomLeft.element.css({"overflow-x": "auto"}); @@ -429,10 +321,6 @@ BI.Table = BI.inherit(BI.Widget, { self.scrollTopLeft.element[0].scrollLeft = self.scrollBottomLeft.element[0].scrollLeft; self.scrollTopRight.element[0].scrollLeft = self.scrollBottomRight.element[0].scrollLeft; self.scrollBottomLeft.element[0].scrollTop = self.scrollBottomRight.element[0].scrollTop; - //调整拖拽handle的高度 - if (o.isNeedResize) { - handle && handle.css("height", self.bottomLeft.element.height() + headerHeight); - } } }; @@ -900,70 +788,6 @@ BI.Table = BI.inherit(BI.Widget, { start || (start = 0); var frag = this._createCells(items, columnSize, BI.range(o.columnSize.length), TDs, Ws, start, o.headerRowSize || o.rowSize); - if (o.isNeedResize === true) { - var tds = TDs[BI.size(TDs) - 1]; - BI.each(tds, function (j, td) { - j = j | 0; - var resizer; - var getHeight = function (size, position) { - var rowSize = self.getCalculateRegionRowSize(); - if (o.isNeedFreeze === true) { - var tableHeight = self.bottomRightContainer.element.outerHeight(); - return size.height + Math.min(rowSize[1], tableHeight); - } else { - var tableHeight = self.tableContainer.element.outerHeight(); - var offset = self.tableContainer.element.offset(); - var offsetTop = position.top - offset.top; - var height = tableHeight - offsetTop; - height = Math.min(height, rowSize[0] - offsetTop); - return height; - } - }; - if (j < BI.size(tds) - 1) { - td.resizable({ - handles: "e", - minWidth: 15, - helper: "clone", - start: function (event, ui) { - var height = getHeight(ui.size, ui.position); - resizer = BI.createWidget({ - type: "bi.layout", - cls: "bi-resizer", - width: ui.size.width, - height: height - }); - - BI.createWidget({ - type: "bi.absolute", - element: "body", - items: [{ - el: resizer, - left: ui.position.left, - top: ui.position.top - }] - }); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE); - }, - resize: function (e, ui) { - var height = getHeight(ui.size, ui.position); - resizer.element.css({"width": ui.size.width + "px", "height": height + "px"}); - //o.columnSize[start + j] = ui.size.width; - //self.setColumnSize(o.columnSize); - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE); - e.stopPropagation(); - //return false; - }, - stop: function (e, ui) { - resizer.destroy(); - resizer = null; - o.columnSize[start + j] = ui.size.width - 1; - self.setColumnSize(o.columnSize); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE); - } - }) - } - }) - } return frag; }, @@ -1355,13 +1179,6 @@ BI.Table = BI.inherit(BI.Widget, { this.bottomRightContainer.element.width(isRight ? lw : rw); this.scrollTopLeft.element[0].scrollLeft = this.scrollBottomLeft.element[0].scrollLeft; this.scrollTopRight.element[0].scrollLeft = this.scrollBottomRight.element[0].scrollLeft; - if (o.isNeedResize && o.isResizeAdapt) { - var leftWidth = BI.sum(o.freezeCols, function (i, col) { - return o.columnSize[col] > 1 ? o.columnSize[col] + 1 : o.columnSize[col]; - }); - this.partitions.attr("columnSize", isRight ? ['fill', leftWidth] : [leftWidth, 'fill']); - this.partitions.resize(); - } } else { BI.each(this.colgroupTds, function (i, colgroup) { var width = colgroup.attr("width") | 0; @@ -1823,13 +1640,6 @@ BI.Table = BI.inherit(BI.Widget, { this.topRightContainer.element.width(isRight ? lw : rw); this.scrollTopLeft.element[0].scrollLeft = this.scrollBottomLeft.element[0].scrollLeft; this.scrollTopRight.element[0].scrollLeft = this.scrollBottomRight.element[0].scrollLeft; - if (o.isNeedResize && o.isResizeAdapt) { - var leftWidth = BI.sum(o.freezeCols, function (i, col) { - return columnSize[col] > 1 ? columnSize[col] + 1 : columnSize[col]; - }); - this.partitions.attr("columnSize", isRight ? ['fill', leftWidth] : [leftWidth, 'fill']); - this.partitions.resize(); - } } else { BI.each(this.colgroupTds, function (i, colgroup) { var width = colgroup.attr("width") | 0; diff --git a/src/core/proto/array.js b/src/core/proto/array.js index b0fb78129..fc1c3b977 100644 --- a/src/core/proto/array.js +++ b/src/core/proto/array.js @@ -3,6 +3,9 @@ * @class Array */ $.extend(Array.prototype, { + contains: function (o) { + return this.indexOf(o) > -1; + }, /** * 检查指定的值是否在数组中 * @param {Object} o 要检查的值 diff --git a/src/css/base/tree/display.tree.css b/src/css/base/tree/display.tree.css index 8856e6f4d..4655bd027 100644 --- a/src/css/base/tree/display.tree.css +++ b/src/css/base/tree/display.tree.css @@ -5,13 +5,13 @@ color: #808080; } .bi-display-tree .ztree li span.button.switch.center_open { - background-image: url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-3.png"); + background-image: url("icon/tree-vertical-line-3.png"); } .bi-display-tree .ztree li span.button.switch.roots_open { - background-image: url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-2.png"); + background-image: url("icon/tree-vertical-line-2.png"); } .bi-display-tree .ztree li span.button.switch.bottom_open { - background-image: url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-4.png"); + background-image: url("icon/tree-vertical-line-4.png"); } .bi-display-tree .ztree li a, .bi-display-tree .ztree li span { diff --git a/src/less/base/tree/display.tree.less b/src/less/base/tree/display.tree.less index 3dd14f167..23bdbcf94 100644 --- a/src/less/base/tree/display.tree.less +++ b/src/less/base/tree/display.tree.less @@ -5,15 +5,15 @@ color: @color-bi-text-gray; } & .ztree li span.button.switch.center_open{ - background-image:url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-3.png"); + background-image:url("icon/tree-vertical-line-3.png"); } & .ztree li span.button.switch.roots_open{ - background-image:url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-2.png"); + background-image:url("icon/tree-vertical-line-2.png"); } & .ztree li span.button.switch.bottom_open{ - background-image:url("${servletURL}?op=resource&resource=/com/fr/bi/web/images/icon/tree-vertical-line-4.png"); + background-image:url("icon/tree-vertical-line-4.png"); } & .ztree li a, & .ztree li span{ cursor: default !important; From 7b5bbc48f38c746c3358e3a35de7c153e5802a27 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Mar 2017 16:49:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/table/demo.resizable_table.js | 57 +++++ demo/js/base/tree/demo.part_tree.js | 9 + demo/js/base/tree/demo.sync_tree.js | 9 + demo/js/base/tree/demo.tree_view.js | 52 +++++ demo/js/config/base.js | 20 +- demo/js/config/case.js | 68 ++---- demo/js/config/core.js | 4 +- demo/js/core/abstract/mvc.custom_tree.js | 245 +++++++++++++++++++++ dist/base.js | 10 +- dist/case.js | 4 +- src/base/combination/tree.button.js | 8 +- src/base/tree/treeview.js | 2 +- src/case/table/table.tree.js | 2 +- src/case/tree/tree.simple.js | 2 +- 14 files changed, 421 insertions(+), 71 deletions(-) create mode 100644 demo/js/base/table/demo.resizable_table.js create mode 100644 demo/js/base/tree/demo.part_tree.js create mode 100644 demo/js/base/tree/demo.sync_tree.js create mode 100644 demo/js/base/tree/demo.tree_view.js create mode 100644 demo/js/core/abstract/mvc.custom_tree.js diff --git a/demo/js/base/table/demo.resizable_table.js b/demo/js/base/table/demo.resizable_table.js new file mode 100644 index 000000000..f3d3540a9 --- /dev/null +++ b/demo/js/base/table/demo.resizable_table.js @@ -0,0 +1,57 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + var items = [], header = [], columnSize = []; + + var rowCount = 100, columnCount = 100; + for (var i = 0; i < 1; i++) { + header[i] = []; + for (var j = 0; j < columnCount; j++) { + header[i][j] = { + type: "bi.label", + text: "表头" + i + "-" + j + } + columnSize[j] = 100; + } + } + for (var i = 0; i < rowCount; i++) { + items[i] = []; + for (var j = 0; j < columnCount; j++) { + items[i][j] = { + type: "bi.label", + text: (i < 3 ? 0 : i) + "-" + j + } + } + } + + var table = BI.createWidget({ + type: "bi.resizable_table", + el: { + type: "bi.grid_table", + }, + width: 600, + height: 500, + isResizeAdapt: true, + isNeedResize: true, + isNeedFreeze: true, + freezeCols: [0, 1], + columnSize: columnSize, + items: items, + header: header + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: table, + left: 10, + right: 10, + top: 10, + bottom: 10 + }] + }) + } +}); +$.shortcut("demo.resizable_table", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/tree/demo.part_tree.js b/demo/js/base/tree/demo.part_tree.js new file mode 100644 index 000000000..d7741dd31 --- /dev/null +++ b/demo/js/base/tree/demo.part_tree.js @@ -0,0 +1,9 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + } +}); +$.shortcut("demo.part_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/tree/demo.sync_tree.js b/demo/js/base/tree/demo.sync_tree.js new file mode 100644 index 000000000..a2c06ff92 --- /dev/null +++ b/demo/js/base/tree/demo.sync_tree.js @@ -0,0 +1,9 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + } +}); +$.shortcut("demo.sync_tree", Demo.Func); \ No newline at end of file diff --git a/demo/js/base/tree/demo.tree_view.js b/demo/js/base/tree/demo.tree_view.js new file mode 100644 index 000000000..2255b32b7 --- /dev/null +++ b/demo/js/base/tree/demo.tree_view.js @@ -0,0 +1,52 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + _createDefaultTree: function(){ + var tree = BI.createWidget({ + type: "bi.tree_view" + }); + tree.initTree([ + {"id":1, "pId":0, "text":"test1", open:true}, + {"id":11, "pId":1, "text":"test11"}, + {"id":12, "pId":1, "text":"test12"}, + {"id":111, "pId":11, "text":"test111"}, + {"id":2, "pId":0, "text":"test2", open:true}, + {"id":21, "pId":2, "text":"test21"}, + {"id":22, "pId":2, "text":"test22"} + ]) + return tree; + }, + + render: function () { + var self = this; + BI.createWidget({ + type: "bi.grid", + columns: 1, + rows: 1, + element: this, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.vtape", + items: [ + { + el: this._createDefaultTree() + }, + { + el: { + type: "bi.label", + text: 'tree.initTree([{"id":1, "pId":0, "text":"test1", open:true},{"id":11, "pId":1, "text":"test11"},{"id":12, "pId":1, "text":"test12"},{"id":111, "pId":11, "text":"test111"}])', + whiteSpace: "normal" + }, + height: 50 + } + ] + } + }] + }) + } +}); +$.shortcut("demo.tree_view", Demo.Func); \ No newline at end of file diff --git a/demo/js/config/base.js b/demo/js/config/base.js index 8f5de28a4..54056d547 100644 --- a/demo/js/config/base.js +++ b/demo/js/config/base.js @@ -69,23 +69,23 @@ Demo.BASE_CONFIG = [{ }, { pId: 2, id: 203, - text: "树控件" + text: "tree" }, { pId: 203, - text: "bi.treeview", - value: "demo.treeview" + text: "bi.tree_view", + value: "demo.tree_view" }, { pId: 203, - text: "bi.synctree", - value: "demo.synctree" + text: "bi.sync_tree", + value: "demo.sync_tree" }, { pId: 203, - text: "bi.parttree", - value: "demo.parttree" + text: "bi.part_tree", + value: "demo.part_tree" }, { pId: 2, id: 204, - text: "表格" + text: "table" }, { pId: 204, text: "bi.table_view", @@ -98,6 +98,10 @@ Demo.BASE_CONFIG = [{ pId: 204, text: "bi.collection_table", value: "demo.collection_table" +}, { + pId: 204, + text: "bi.resizable_table", + value: "demo.resizable_table" }, { pId: 2, text: "bi.canvas", diff --git a/demo/js/config/case.js b/demo/js/config/case.js index da7cdbfb5..062049d7b 100644 --- a/demo/js/config/case.js +++ b/demo/js/config/case.js @@ -54,6 +54,22 @@ Demo.CASE_CONFIG = [{ pId: 303, text: "bi.level_tree", value: "demo.level_tree" +}, { + pId: 3, + id: 304, + text: "table" +}, { + pId: 304, + text: "bi.adaptive_table", + value: "demo.adaptive_table" +}, { + pId: 304, + text: "bi.tree_table", + value: "demo.tree_table" +}, { + pId: 304, + text: "bi.layer_tree_table", + value: "demo.layer_tree_table" }, { pId: 3, text: "bi.calendar", @@ -70,50 +86,8 @@ Demo.CASE_CONFIG = [{ pId: 3, text: "bi.color_chooser", value: "demo.color_chooser" -}, - - { - pId: 3, - text: "各种checkbox", - value: "demo.checkboxes" - }, { - pId: 3, - text: "各种tip", - value: "demo.tips" - }, { - pId: 3, - text: "bi.float_box", - value: "demo.float_box" - }, { - pId: 3, - text: "bi.float_box", - value: "demo.float_box" - }, { - pId: 3, - text: "bi.segment", - value: "demo.segment" - }, { - pId: 3, - id: 12, - text: "各种表格" - }, { - pId: 3, - id: 13, - text: "各种tree" - }, { - pId: 3, - text: "各种trigger", - value: "demo.triggers" - }, { - pId: 12, - text: "bi.adaptive_table", - value: "demo.adaptive_table" - }, { - pId: 12, - text: "bi.table_tree", - value: "demo.table_tree" - }, { - pId: 12, - text: "bi.layer_tree_table", - value: "demo.layer_tree_table" - }]; \ No newline at end of file +}, { + pId: 3, + text: "bi.segment", + value: "demo.segment" +}]; \ No newline at end of file diff --git a/demo/js/config/core.js b/demo/js/config/core.js index bd8792d5b..6d83a0f9b 100644 --- a/demo/js/config/core.js +++ b/demo/js/config/core.js @@ -151,8 +151,8 @@ Demo.CORE_CONFIG = [{ value: "demo.layer_searcher" }, { pId: 102, - text: "bi.customtree", - value: "demo.customtree" + text: "bi.custom_tree", + value: "demo.custom_tree" }, { pId: 102, text: "bi.grid_view", diff --git a/demo/js/core/abstract/mvc.custom_tree.js b/demo/js/core/abstract/mvc.custom_tree.js new file mode 100644 index 000000000..b3088af63 --- /dev/null +++ b/demo/js/core/abstract/mvc.custom_tree.js @@ -0,0 +1,245 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + _createDefaultTree: function () { + var TREEITEMS = [{id: -1, pId: -2, value: "根目录", open: true, type: "bi.plus_group_node", height: 25}, + {id: 1, pId: -1, value: "第一级目录1", type: "bi.plus_group_node", height: 25}, + {id: 11, pId: 1, value: "第二级文件1", type: "bi.single_select_item", height: 25}, + {id: 12, pId: 1, value: "第二级目录2", type: "bi.plus_group_node", height: 25}, + {id: 121, pId: 12, value: "第三级目录1", type: "bi.plus_group_node", height: 25}, + {id: 122, pId: 12, value: "第三级文件1", type: "bi.single_select_item", height: 25}, + {id: 1211, pId: 121, value: "第四级目录1", type: "bi.plus_group_node", height: 25}, + {id: 12111, pId: 1211, value: "第五级文件1", type: "bi.single_select_item", height: 25}, + {id: 2, pId: -1, value: "第一级目录2", type: "bi.plus_group_node", height: 25}, + {id: 21, pId: 2, value: "第二级目录3", type: "bi.plus_group_node", height: 25}, + {id: 22, pId: 2, value: "第二级文件2", type: "bi.single_select_item", height: 25}, + {id: 211, pId: 21, value: "第三级目录2", type: "bi.plus_group_node", height: 25}, + {id: 212, pId: 21, value: "第三级文件2", type: "bi.single_select_item", height: 25}, + {id: 2111, pId: 211, value: "第四级文件1", type: "bi.single_select_item", height: 25}]; + this.tree = BI.createWidget({ + type: "bi.custom_tree", + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical", + hgap: 30 + }] + }, + items: BI.deepClone(TREEITEMS) + }); + return this.tree; + }, + + _createAsyncTree: function () { + this.asyncTree = BI.createWidget({ + type: "bi.custom_tree", + itemsCreator: function (op, callback) { + if (!op.node) {//根节点 + callback([{ + "id": 1, + "pId": 0, + type: "bi.plus_group_node", + text: "test1", + value: 1, + height: 25, + isParent: true + }, { + "id": 2, + "pId": 0, + type: "bi.plus_group_node", + "text": "test2", + value: 1, + isParent: true, + open: true, + height: 25 + }]) + } else { + if (op.node.id == 1) { + callback([ + { + "id": 11, + "pId": 1, + type: "bi.plus_group_node", + "text": "test11", + value: 11, + height: 25, + isParent: true + }, + { + "id": 12, + "pId": 1, + type: "bi.single_select_item", + "text": "test12", + value: 12, + height: 35 + }, + { + "id": 13, + "pId": 1, + type: "bi.single_select_item", + "text": "test13", + value: 13, + height: 35 + }, + { + "id": 14, + "pId": 1, + type: "bi.single_select_item", + "text": "test14", + value: 14, + height: 35 + }, + { + "id": 15, + "pId": 1, + type: "bi.single_select_item", + "text": "test15", + value: 15, + height: 35 + }, + { + "id": 16, + "pId": 1, + type: "bi.single_select_item", + "text": "test16", + value: 16, + height: 35 + }, + {"id": 17, "pId": 1, type: "bi.single_select_item", "text": "test17", value: 17, height: 35} + ]) + } else if (op.node.id == 2) { + callback([{ + "id": 21, + "pId": 2, + type: "bi.single_select_item", + "text": "test21", + value: 21, + height: 35 + }, + { + "id": 22, + "pId": 2, + type: "bi.single_select_item", + "text": "test22", + value: 22, + height: 35 + }]) + } else if (op.node.id == 11) { + callback([{ + "id": 111, + "pId": 11, + type: "bi.single_select_item", + "text": "test111", + value: 111, + height: 35 + }]) + } + } + }, + el: { + type: "bi.loader", + next: false, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical", + hgap: 30, + vgap: 0 + }] + } + } + }); + return this.asyncTree; + }, + + render: function () { + var self = this; + BI.createWidget({ + type: "bi.grid", + columns: 2, + rows: 1, + element: this, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.vtape", + items: [ + { + el: this._createDefaultTree() + }, + { + el: { + type: "bi.center", + hgap: 10, + items: [{ + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getValue", + height: 30, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.tree.getValue())); + } + }, { + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getNodeByValue(第一级目录1)", + height: 30, + handler: function () { + BI.Msg.alert("", "节点名称为: " + self.tree.getNodeByValue("第一级目录1").getValue()); + } + }] + }, + height: 30 + } + ] + } + }, { + column: 1, + row: 0, + el: { + type: "bi.vtape", + items: [ + { + type: "bi.label", + text: "异步加载数据", + height: 30 + }, + { + el: this._createAsyncTree() + }, + { + el: { + type: "bi.center", + hgap: 10, + items: [{ + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getValue", + height: 30, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.asyncTree.getValue())); + } + }, { + type: "bi.text_button", + cls: "mvc-button layout-bg2", + text: "getNodeById(11)", + height: 30, + handler: function () { + BI.Msg.alert("", "节点名称为: " + (self.asyncTree.getNodeById(11) && self.asyncTree.getNodeById(11).getText())); + } + }] + }, + height: 30 + } + ] + } + }] + }) + } +}); +$.shortcut("demo.custom_tree", Demo.Func); \ No newline at end of file diff --git a/dist/base.js b/dist/base.js index 4e032f162..f47bfd398 100644 --- a/dist/base.js +++ b/dist/base.js @@ -1438,13 +1438,13 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, { var node; BI.any(this.buttons, function (i, item) { if (item.isEnabled()) { - if (item.getValue() === value) { - node = item; - return true; - } else if (BI.isFunction(item.getNodeByValue)) { + if (BI.isFunction(item.getNodeByValue)) { if (node = item.getNodeByValue(value)) { return true; } + } else if (item.attr("value") === value) { + node = item; + return true; } } }); @@ -2073,7 +2073,7 @@ BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE"; BI.TreeView.EVENT_INIT = BI.Events.INIT; BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT; -$.shortcut("bi.tree", BI.TreeView);/** +$.shortcut("bi.tree_view", BI.TreeView);/** * guy * 同步树 * @class BI.SyncTree diff --git a/dist/case.js b/dist/case.js index af3840251..704fdb1e5 100644 --- a/dist/case.js +++ b/dist/case.js @@ -9890,7 +9890,7 @@ BI.extend(BI.TableTree, { } }); -$.shortcut("bi.table_tree", BI.TableTree);/** +$.shortcut("bi.tree_table", BI.TableTree);/** * guy * 复选导航条 * Created by GUY on 2015/8/25. @@ -10344,7 +10344,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, { var self = this, o = this.options; this.structure = new BI.Tree(); this.tree = BI.createWidget({ - type: "bi.tree", + type: "bi.tree_view", element: this, itemsCreator: function (op, callback) { var fn = function (items) { diff --git a/src/base/combination/tree.button.js b/src/base/combination/tree.button.js index 85afc684d..b4822e087 100644 --- a/src/base/combination/tree.button.js +++ b/src/base/combination/tree.button.js @@ -164,13 +164,13 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, { var node; BI.any(this.buttons, function (i, item) { if (item.isEnabled()) { - if (item.getValue() === value) { - node = item; - return true; - } else if (BI.isFunction(item.getNodeByValue)) { + if (BI.isFunction(item.getNodeByValue)) { if (node = item.getNodeByValue(value)) { return true; } + } else if (item.attr("value") === value) { + node = item; + return true; } } }); diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index e38896200..17e84d100 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -504,4 +504,4 @@ BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE"; BI.TreeView.EVENT_INIT = BI.Events.INIT; BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT; -$.shortcut("bi.tree", BI.TreeView); \ No newline at end of file +$.shortcut("bi.tree_view", BI.TreeView); \ No newline at end of file diff --git a/src/case/table/table.tree.js b/src/case/table/table.tree.js index 4d78a07c3..a53479066 100644 --- a/src/case/table/table.tree.js +++ b/src/case/table/table.tree.js @@ -327,4 +327,4 @@ BI.extend(BI.TableTree, { } }); -$.shortcut("bi.table_tree", BI.TableTree); \ No newline at end of file +$.shortcut("bi.tree_table", BI.TableTree); \ No newline at end of file diff --git a/src/case/tree/tree.simple.js b/src/case/tree/tree.simple.js index 6b4f1c2cb..677ee6e63 100644 --- a/src/case/tree/tree.simple.js +++ b/src/case/tree/tree.simple.js @@ -18,7 +18,7 @@ BI.SimpleTreeView = BI.inherit(BI.Widget, { var self = this, o = this.options; this.structure = new BI.Tree(); this.tree = BI.createWidget({ - type: "bi.tree", + type: "bi.tree_view", element: this, itemsCreator: function (op, callback) { var fn = function (items) { From b0522e57ee98aab55e1034064cbf73f4fa21fa9c Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Mar 2017 17:43:58 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/css/main.css | 3 - demo/js/base/demo.pager.js | 120 +++++++++++ demo/js/case/tree/demo.branch_relation.js | 149 ++++++++++++++ demo/js/config/case.js | 4 + demo/less/main.less | 3 - dist/base.js | 19 +- src/base/pager/pager.js | 18 +- src/base/svg/svg.js | 1 + src/css/normalize.css | 230 --------------------- src/css/reset.css | 128 ++++++++++++ src/less/normalize.less | 231 ---------------------- src/less/reset.less | 48 +++++ 12 files changed, 469 insertions(+), 485 deletions(-) create mode 100644 demo/js/base/demo.pager.js create mode 100644 demo/js/case/tree/demo.branch_relation.js delete mode 100644 src/css/normalize.css create mode 100644 src/css/reset.css delete mode 100644 src/less/normalize.less create mode 100644 src/less/reset.less diff --git a/demo/css/main.css b/demo/css/main.css index 7a34fff76..039fce052 100644 --- a/demo/css/main.css +++ b/demo/css/main.css @@ -1,6 +1,3 @@ -* { - font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} .layout-bg-white { background-color: #ffffff; } diff --git a/demo/js/base/demo.pager.js b/demo/js/base/demo.pager.js new file mode 100644 index 000000000..a131fbce1 --- /dev/null +++ b/demo/js/base/demo.pager.js @@ -0,0 +1,120 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + render: function () { + return { + type: "bi.vertical", + items: [{ + type: "bi.label", + height: 30, + text: "默认的分页" + }, { + type: "bi.pager", + height: 50, + pages: 18, + groups: 5, + curr: 6, + first: "首页", + last: "尾页" + }, { + type: "bi.label", + height: 30, + text: "显示上一页、下一页、首页、尾页" + }, { + type: "bi.pager", + dynamicShow: false, + height: 50, + pages: 18, + groups: 5, + curr: 1, + first: "首页>", + last: "<尾页" + }, { + type: "bi.label", + height: 30, + text: "显示上一页、下一页" + }, { + type: "bi.pager", + dynamicShow: false, + dynamicShowFirstLast: true, + height: 50, + pages: 18, + groups: 5, + curr: 1, + first: "首页>", + last: "<尾页" + }, { + type: "bi.label", + height: 30, + text: "自定义上一页、下一页" + }, { + type: "bi.pager", + dynamicShow: false, + height: 50, + pages: 18, + groups: 5, + curr: 6, + prev: { + type: "bi.button", + cls: "", + text: "上一页", + value: "prev", + once: false, + height: 30, + handler: function () { + + } + }, + next: { + type: "bi.button", + cls: "", + text: "下一页", + value: "next", + once: false, + handler: function () { + + } + } + }, { + type: "bi.label", + height: 30, + text: "不知道总页数的情况(测试条件 1<=page<=3)" + }, { + type: "bi.pager", + dynamicShow: false, + height: 50, + pages: false, + curr: 1, + prev: { + type: "bi.button", + cls: "", + text: "上一页", + value: "prev", + once: false, + height: 30, + handler: function () { + + } + }, + next: { + type: "bi.button", + cls: "", + text: "下一页", + value: "next", + once: false, + handler: function () { + + } + }, + hasPrev: function (v) { + return v > 1; + }, + hasNext: function (v) { + return v < 3; + } + }] + } + } +}); +$.shortcut("demo.pager", Demo.Func); \ No newline at end of file diff --git a/demo/js/case/tree/demo.branch_relation.js b/demo/js/case/tree/demo.branch_relation.js new file mode 100644 index 000000000..af7036280 --- /dev/null +++ b/demo/js/case/tree/demo.branch_relation.js @@ -0,0 +1,149 @@ +Demo.Func = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-func" + }, + + render: function () { + var relation = BI.createWidget({ + type: "bi.branch_relation", + items: [ + { + id: -1, + value: "根目录", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 1, + pId: -1, + value: "第一级目录1", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 11, + pId: 1, + value: "第二级文件1", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 12, + pId: 1, + value: "第二级目录1", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 121, + pId: 12, + value: "第三级目录1", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 122, + pId: 12, + value: "第三级文件1", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 1211, + pId: 121, + value: "第四级目录", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 12111, + pId: 1211, + value: "第五级文件1", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 2, + pId: -1, + value: "第一级目录2", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 21, + pId: 2, + value: "第二级目录2", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 22, + pId: 2, + value: "第二级文件2", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 211, + pId: 21, + value: "第三级目录2", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 212, + pId: 21, + value: "第三级文件2", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + }, + { + id: 2111, + pId: 211, + value: "第四级文件2", + type: "bi.text_button", + cls: "layout-bg2", + width: 180, + height: 100 + } + ], + + direction: BI.Direction.Right, + align: BI.HorizontalAlign.Right, + + centerOffset: -50 + }); + BI.createWidget({ + type: "bi.adaptive", + element: this, + items: [relation] + }) + } +}); +$.shortcut("demo.branch_relation", Demo.Func); \ No newline at end of file diff --git a/demo/js/config/case.js b/demo/js/config/case.js index 062049d7b..be8bedf97 100644 --- a/demo/js/config/case.js +++ b/demo/js/config/case.js @@ -54,6 +54,10 @@ Demo.CASE_CONFIG = [{ pId: 303, text: "bi.level_tree", value: "demo.level_tree" +}, { + pId: 303, + text: "bi.branch_relation", + value: "demo.branch_relation" }, { pId: 3, id: 304, diff --git a/demo/less/main.less b/demo/less/main.less index 02d570723..3d7de426a 100644 --- a/demo/less/main.less +++ b/demo/less/main.less @@ -1,6 +1,3 @@ -* { - font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} .layout-bg-white { background-color: #ffffff; diff --git a/dist/base.js b/dist/base.js index f47bfd398..66653a559 100644 --- a/dist/base.js +++ b/dist/base.js @@ -15479,10 +15479,10 @@ BI.Pager = BI.inherit(BI.Widget, { var self = this; this.currPage = BI.result(this.options, "curr"); //翻页太灵敏 - this._lock = false; - this._debouce = BI.debounce(function () { - self._lock = false; - }, 300); + // this._lock = false; + // this._debouce = BI.debounce(function () { + // self._lock = false; + // }, 300); this._populate(); }, @@ -15618,11 +15618,11 @@ BI.Pager = BI.inherit(BI.Widget, { layouts: o.layouts }); this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (self._lock === true) { - return; - } - self._lock = true; - self._debouce(); + // if (self._lock === true) { + // return; + // } + // self._lock = true; + // self._debouce(); if (type === BI.Events.CLICK) { var v = self.button_group.getValue()[0]; switch (v) { @@ -28233,6 +28233,7 @@ BI.Svg = BI.inherit(BI.Widget, { BI.Svg.superclass._init.apply(this, arguments); this.paper = Raphael(this.element[0]); + this.element.css("overflow", "hidden"); $(this.paper.canvas).width("100%").height("100%").css({"left": "0", "top": "0"}).appendTo(this.element); this.top = this.paper.top; diff --git a/src/base/pager/pager.js b/src/base/pager/pager.js index f4128c0fa..6dcf6ca02 100644 --- a/src/base/pager/pager.js +++ b/src/base/pager/pager.js @@ -45,10 +45,10 @@ BI.Pager = BI.inherit(BI.Widget, { var self = this; this.currPage = BI.result(this.options, "curr"); //翻页太灵敏 - this._lock = false; - this._debouce = BI.debounce(function () { - self._lock = false; - }, 300); + // this._lock = false; + // this._debouce = BI.debounce(function () { + // self._lock = false; + // }, 300); this._populate(); }, @@ -184,11 +184,11 @@ BI.Pager = BI.inherit(BI.Widget, { layouts: o.layouts }); this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (self._lock === true) { - return; - } - self._lock = true; - self._debouce(); + // if (self._lock === true) { + // return; + // } + // self._lock = true; + // self._debouce(); if (type === BI.Events.CLICK) { var v = self.button_group.getValue()[0]; switch (v) { diff --git a/src/base/svg/svg.js b/src/base/svg/svg.js index adb3f3ab7..83b0e769a 100644 --- a/src/base/svg/svg.js +++ b/src/base/svg/svg.js @@ -17,6 +17,7 @@ BI.Svg = BI.inherit(BI.Widget, { BI.Svg.superclass._init.apply(this, arguments); this.paper = Raphael(this.element[0]); + this.element.css("overflow", "hidden"); $(this.paper.canvas).width("100%").height("100%").css({"left": "0", "top": "0"}).appendTo(this.element); this.top = this.paper.top; diff --git a/src/css/normalize.css b/src/css/normalize.css deleted file mode 100644 index 65b0635b2..000000000 --- a/src/css/normalize.css +++ /dev/null @@ -1,230 +0,0 @@ -/*! normalize.css v1.0.0 | MIT License | git.io/normalize */ -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -nav, -section, -summary { - display: block; -} -audio, -canvas, -video { - display: inline-block; - *display: inline; - *zoom: 1; -} -audio:not([controls]) { - display: none; - height: 0; -} -[hidden] { - display: none; -} -html { - font-size: 100%; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} -html, -button, -input, -select, -textarea { - font-family: sans-serif; -} -body { - margin: 0; -} -a:focus { - outline: thin dotted; -} -a:active, -a:hover { - outline: 0; -} -h1 { - font-size: 2em; - margin: 0.67em 0; -} -h2 { - font-size: 1.5em; - margin: 0.83em 0; -} -h3 { - font-size: 1.17em; - margin: 1em 0; -} -h4 { - font-size: 1em; - margin: 1.33em 0; -} -h5 { - font-size: .83em; - margin: 1.67em 0; -} -h6 { - font-size: .75em; - margin: 2.33em 0; -} -abbr[title] { - border-bottom: 1px dotted; -} -b, -strong { - font-weight: bold; -} -blockquote { - margin: 1em 40px; -} -dfn { - font-style: italic; -} -mark { - background: #ff0; - color: #000000; -} -p, -pre { - margin: 1em 0; -} -code, -kbd, -pre, -samp { - font-family: monospace, serif; - _font-family: 'courier new', monospace; - font-size: 1em; -} -pre { - white-space: pre; - white-space: pre-wrap; - word-wrap: break-word; -} -q { - quotes: none; -} -q:before, -q:after { - content: ''; - content: none; -} -small { - font-size: 75%; -} -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} -sup { - top: -0.5em; -} -sub { - bottom: -0.25em; -} -dl, -menu, -ol, -ul { - margin: 1em 0; -} -dd { - margin: 0 0 0 40px; -} -menu, -ol, -ul { - padding: 0 0 0 40px; -} -nav ul, -nav ol { - list-style: none; - list-style-image: none; -} -img { - border: 0; - -ms-interpolation-mode: bicubic; -} -svg:not(:root) { - overflow: hidden; -} -figure { - margin: 0; -} -form { - margin: 0; -} -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} -legend { - border: 0; - padding: 0; - white-space: normal; - *margin-left: -7px; -} -button, -input, -select, -textarea { - font-size: 100%; - margin: 0; - vertical-align: baseline; - *vertical-align: middle; -} -button, -input { - line-height: normal; -} -button, -html input[type="button"], -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; - cursor: pointer; - *overflow: visible; -} -button[disabled], -input[disabled] { - cursor: default; -} -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; - padding: 0; - *height: 13px; - *width: 13px; -} -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box; -} -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} -textarea { - overflow: auto; - vertical-align: top; -} -table { - border-collapse: collapse; - border-spacing: 0; -} diff --git a/src/css/reset.css b/src/css/reset.css new file mode 100644 index 000000000..0007ead9b --- /dev/null +++ b/src/css/reset.css @@ -0,0 +1,128 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ +html, +body, +div, +span, +applet, +object, +iframe, +h1, +h2, +h3, +h4, +h5, +h6, +p, +blockquote, +pre, +a, +abbr, +acronym, +address, +big, +cite, +code, +del, +dfn, +em, +img, +ins, +kbd, +q, +s, +samp, +small, +strike, +strong, +sub, +sup, +tt, +var, +b, +u, +i, +center, +dl, +dt, +dd, +ol, +ul, +li, +fieldset, +form, +label, +legend, +table, +caption, +tbody, +tfoot, +thead, +tr, +th, +td, +article, +aside, +canvas, +details, +embed, +figure, +figcaption, +footer, +header, +hgroup, +menu, +nav, +output, +ruby, +section, +summary, +time, +mark, +audio, +video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +menu, +nav, +section { + display: block; +} +body { + line-height: 1; +} +ol, +ul { + list-style: none; +} +blockquote, +q { + quotes: none; +} +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/src/less/normalize.less b/src/less/normalize.less deleted file mode 100644 index baf3cb1df..000000000 --- a/src/less/normalize.less +++ /dev/null @@ -1,231 +0,0 @@ -/*! normalize.css v1.0.0 | MIT License | git.io/normalize */ - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -nav, -section, -summary { - display: block -} -audio, -canvas, -video { - display: inline-block; - *display: inline; - *zoom: 1 -} -audio:not([controls]) { - display: none; - height: 0 -} -[hidden] { - display: none -} -html { - font-size: 100%; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100% -} -html, -button, -input, -select, -textarea { - font-family: sans-serif -} -body { - margin: 0 -} -a:focus { - outline: thin dotted -} -a:active, -a:hover { - outline: 0 -} -h1 { - font-size: 2em; - margin: .67em 0 -} -h2 { - font-size: 1.5em; - margin: .83em 0 -} -h3 { - font-size: 1.17em; - margin: 1em 0 -} -h4 { - font-size: 1em; - margin: 1.33em 0 -} -h5 { - font-size: .83em; - margin: 1.67em 0 -} -h6 { - font-size: .75em; - margin: 2.33em 0 -} -abbr[title] { - border-bottom: 1px dotted -} -b, -strong { - font-weight: bold -} -blockquote { - margin: 1em 40px -} -dfn { - font-style: italic -} -mark { - background: #ff0; - color: #000 -} -p, -pre { - margin: 1em 0 -} -code, -kbd, -pre, -samp { - font-family: monospace, serif; - _font-family: 'courier new', monospace; - font-size: 1em -} -pre { - white-space: pre; - white-space: pre-wrap; - word-wrap: break-word -} -q { - quotes: none -} -q:before, -q:after { - content: ''; - content: none -} -small { - font-size: 75% -} -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline -} -sup { - top: -0.5em -} -sub { - bottom: -0.25em -} -dl, -menu, -ol, -ul { - margin: 1em 0 -} -dd { - margin: 0 0 0 40px -} -menu, -ol, -ul { - padding: 0 0 0 40px -} -nav ul, -nav ol { - list-style: none; - list-style-image: none -} -img { - border: 0; - -ms-interpolation-mode: bicubic -} -svg:not(:root) { - overflow: hidden -} -figure { - margin: 0 -} -form { - margin: 0 -} -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: .35em .625em .75em -} -legend { - border: 0; - padding: 0; - white-space: normal; - *margin-left: -7px -} -button, -input, -select, -textarea { - font-size: 100%; - margin: 0; - vertical-align: baseline; - *vertical-align: middle -} -button, -input { - line-height: normal -} -button, -html input[type="button"], -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; - cursor: pointer; - *overflow: visible -} -button[disabled], -input[disabled] { - cursor: default -} -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; - padding: 0; - *height: 13px; - *width: 13px -} -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box -} -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none -} -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0 -} -textarea { - overflow: auto; - vertical-align: top -} -table { - border-collapse: collapse; - border-spacing: 0 -} \ No newline at end of file diff --git a/src/less/reset.less b/src/less/reset.less new file mode 100644 index 000000000..3df61e8d9 --- /dev/null +++ b/src/less/reset.less @@ -0,0 +1,48 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} \ No newline at end of file From 0721c5e2692b41b854f0a6a23d8aa9603dbfd17d Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Mar 2017 20:45:35 +0800 Subject: [PATCH 4/5] add --- dist/base.css | 18 -- dist/base.js | 117 --------- dist/case.js | 236 +++++++++--------- src/base/layer/layer.scroll.js | 118 --------- .../expander/expander.branch.handstand.js | 0 .../{ => tree}/expander/expander.branch.js | 0 src/css/base/view/scrollview.css | 18 -- src/less/base/logintimeout/login.timeout.less | 30 --- src/less/base/reqloading/loading.request.less | 20 -- .../timeouttoast/widget.timeouttoast.less | 25 -- src/less/base/view/scrollview.less | 19 -- 11 files changed, 118 insertions(+), 483 deletions(-) delete mode 100644 src/base/layer/layer.scroll.js rename src/case/{ => tree}/expander/expander.branch.handstand.js (100%) rename src/case/{ => tree}/expander/expander.branch.js (100%) delete mode 100644 src/css/base/view/scrollview.css delete mode 100644 src/less/base/logintimeout/login.timeout.less delete mode 100644 src/less/base/reqloading/loading.request.less delete mode 100644 src/less/base/timeouttoast/widget.timeouttoast.less delete mode 100644 src/less/base/view/scrollview.less diff --git a/dist/base.css b/dist/base.css index 2a8560251..0400f6ab9 100644 --- a/dist/base.css +++ b/dist/base.css @@ -2287,24 +2287,6 @@ ul.ztree.zTreeDragUL { .bi-list-view .list-view-toolbar > .first-element { border-left: none; } -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-scroll-view .scroll-container { - border-left: 1px solid #d4dadd; - border-right: 1px solid #d4dadd; - border-bottom: 1px solid #d4dadd; -} -.bi-scroll-view .scroll-drop-down-icon { - font-size: 14px; - border-bottom: 1px solid #d4dadd; - border-left: 1px solid #d4dadd; - border-right: 1px solid #d4dadd; - background: #f4f4f4; -} -.bi-scroll-view .scroll-drop-down-icon:active { - background: #d4dadd; -} .bi-flex-center-layout { display: box; /* OLD - Android 4.4- */ diff --git a/dist/base.js b/dist/base.js index 66653a559..345bc1725 100644 --- a/dist/base.js +++ b/dist/base.js @@ -15178,123 +15178,6 @@ BI.PopupView = BI.inherit(BI.Widget, { }); BI.PopupView.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut("bi.popup_view", BI.PopupView);/** - * guy - * @class BI.ScrollView - * @extends BI.Widget - */ -BI.ScrollView = BI.inherit(BI.Widget, { - - _const: { - dropDownHeight: 15, - expandIcon: "column-next-page-h-font", - collapseIcon: "column-pre-page-h-font" - }, - - _defaultConfig: function() { - return BI.extend(BI.ScrollView.superclass._defaultConfig.apply(this, arguments), { - baseCls:"bi-scroll-view", - scrollHeight: 50, - maxHeight: 300 - }) - }, - - _init : function() { - BI.ScrollView.superclass._init.apply(this, arguments); - - this.scrollUp = false; - this.scroll = BI.createWidget({ - type: "bi.vertical", - cls: "scroll-container", - scrolly: true - }) - BI.createWidget({ - type: "bi.vertical", - element: this, - scrolly: false, - items: [this.scroll] - }) - - this.dropdown = BI.createWidget({ - type: "bi.icon_button", - height: this._const.dropDownHeight, - cls: "scroll-drop-down-icon " + this._const.expandIcon, - handler: BI.bind(this._dropDownOrUp, this) - }) - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.dropdown, - left: 0, - right: 0, - bottom: -1 * this._const.dropDownHeight - }] - }) - this.populate(this.options.items); - }, - - _dropDownOrUp: function(){ - if(!this.scrollUp){ - var height = this.element.height(); - height += this.options.scrollHeight; - height = Math.min(height, this.scroll.element[0].scrollHeight, this.options.maxHeight); - this.element.height(height); - this._checkDropDownState(); - } else { - var height = this.element.height(); - height -= this.options.scrollHeight; - height = Math.max(height, this.options.height); - this.element.height(height); - this._checkDropDownState(); - } - }, - - _checkDropDownState: function(){ - var height = this.element.height(); - if(!this._checkScroll() || height >= this.options.maxHeight){ - this.scrollUp = true; - this.dropdown.element.removeClass(this._const.expandIcon).addClass(this._const.collapseIcon); - } else if(height <= this.options.height){ - this.scrollUp = false; - this.dropdown.element.addClass(this._const.expandIcon); - } else { - this.dropdown.element.addClass(this.scrollUp ? this._const.collapseIcon : this._const.expandIcon); - } - }, - - _checkScroll: function(){ - this.scroll.element.height(this.element.height()); - return this.scroll.element[0].scrollHeight > this.scroll.element[0].clientHeight; - }, - - _checkDropDown: function(){ - if(this._checkScroll()){ - this.dropdown.visible(); - //this.scrollUp = false; - this._checkDropDownState(); - } else { - this.dropdown.invisible(); - } - }, - - populate: function(){ - this.scroll.populate.apply(this.scroll, arguments); - this.resize(); - }, - - resize: function(){ - this.element.height(this.options.height); - BI.nextTick(BI.bind(this._checkDropDown, this)); - }, - - addItem: function(){ - this.scroll.addItem.apply(this.scroll, arguments); - BI.nextTick(BI.bind(this._checkDropDown, this)); - } -}); - -$.shortcut("bi.scroll_view", BI.ScrollView);/** * 搜索面板 * * Created by GUY on 2015/9/28. diff --git a/dist/case.js b/dist/case.js index 704fdb1e5..7ea957f9b 100644 --- a/dist/case.js +++ b/dist/case.js @@ -6165,124 +6165,6 @@ BI.SimpleStateEditor.EVENT_SPACE = "EVENT_SPACE"; BI.SimpleStateEditor.EVENT_EMPTY = "EVENT_EMPTY"; $.shortcut("bi.simple_state_editor", BI.SimpleStateEditor);/** - * 倒立的Branch - * @class BI.HandStandBranchExpander - * @extend BI.Widget - * create by young - */ -BI.HandStandBranchExpander = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.HandStandBranchExpander.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-handstand-branch-expander", - direction: BI.Direction.Top, - logic: { - dynamic: true - }, - el: {type: "bi.label"}, - popup: {} - }) - }, - - _init: function () { - BI.HandStandBranchExpander.superclass._init.apply(this, arguments); - var o = this.options; - this._initExpander(); - this._initBranchView(); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(o.direction, { - type: "bi.center_adapt", - items: [this.expander] - }, this.branchView) - })))); - }, - - _initExpander: function () { - var self = this, o = this.options; - this.expander = BI.createWidget(o.el); - this.expander.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - _initBranchView: function () { - var self = this, o = this.options; - this.branchView = BI.createWidget(o.popup, {}); - this.branchView.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - populate: function (items) { - this.branchView.populate.apply(this.branchView, arguments); - }, - - getValue: function () { - return this.branchView.getValue(); - } -}); -BI.HandStandBranchExpander.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.handstand_branch_expander", BI.HandStandBranchExpander);/** - * @class BI.BranchExpander - * @extend BI.Widget - * create by young - */ -BI.BranchExpander = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.BranchExpander.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-branch-expander", - direction: BI.Direction.Left, - logic: { - dynamic: true - }, - el: {}, - popup: {} - }) - }, - - _init: function () { - BI.BranchExpander.superclass._init.apply(this, arguments); - var o = this.options; - this._initExpander(); - this._initBranchView(); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.expander, this.branchView) - })))); - }, - - _initExpander: function () { - var self = this, o = this.options; - this.expander = BI.createWidget(o.el, { - type: "bi.label", - width: 30, - height: "100%" - }); - this.expander.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - _initBranchView: function () { - var self = this, o = this.options; - this.branchView = BI.createWidget(o.popup, {}); - this.branchView.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - populate: function (items) { - this.branchView.populate.apply(this.branchView, arguments); - }, - - getValue: function () { - return this.branchView.getValue(); - } -}); -BI.BranchExpander.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.branch_expander", BI.BranchExpander);/** * 有确定取消按钮的弹出层 * @class BI.BarFloatSection * @extends BI.FloatSection @@ -10024,6 +9906,124 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }); BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE"; $.shortcut("bi.multi_select_bar", BI.MultiSelectBar);/** + * 倒立的Branch + * @class BI.HandStandBranchExpander + * @extend BI.Widget + * create by young + */ +BI.HandStandBranchExpander = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.HandStandBranchExpander.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-handstand-branch-expander", + direction: BI.Direction.Top, + logic: { + dynamic: true + }, + el: {type: "bi.label"}, + popup: {} + }) + }, + + _init: function () { + BI.HandStandBranchExpander.superclass._init.apply(this, arguments); + var o = this.options; + this._initExpander(); + this._initBranchView(); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection(o.direction, { + type: "bi.center_adapt", + items: [this.expander] + }, this.branchView) + })))); + }, + + _initExpander: function () { + var self = this, o = this.options; + this.expander = BI.createWidget(o.el); + this.expander.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + _initBranchView: function () { + var self = this, o = this.options; + this.branchView = BI.createWidget(o.popup, {}); + this.branchView.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + populate: function (items) { + this.branchView.populate.apply(this.branchView, arguments); + }, + + getValue: function () { + return this.branchView.getValue(); + } +}); +BI.HandStandBranchExpander.EVENT_CHANGE = "EVENT_CHANGE"; +$.shortcut("bi.handstand_branch_expander", BI.HandStandBranchExpander);/** + * @class BI.BranchExpander + * @extend BI.Widget + * create by young + */ +BI.BranchExpander = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.BranchExpander.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-branch-expander", + direction: BI.Direction.Left, + logic: { + dynamic: true + }, + el: {}, + popup: {} + }) + }, + + _init: function () { + BI.BranchExpander.superclass._init.apply(this, arguments); + var o = this.options; + this._initExpander(); + this._initBranchView(); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.expander, this.branchView) + })))); + }, + + _initExpander: function () { + var self = this, o = this.options; + this.expander = BI.createWidget(o.el, { + type: "bi.label", + width: 30, + height: "100%" + }); + this.expander.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + _initBranchView: function () { + var self = this, o = this.options; + this.branchView = BI.createWidget(o.popup, {}); + this.branchView.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + populate: function (items) { + this.branchView.populate.apply(this.branchView, arguments); + }, + + getValue: function () { + return this.branchView.getValue(); + } +}); +BI.BranchExpander.EVENT_CHANGE = "EVENT_CHANGE"; +$.shortcut("bi.branch_expander", BI.BranchExpander);/** * @class BI.HandStandBranchTree * @extends BI.Widget * create by young diff --git a/src/base/layer/layer.scroll.js b/src/base/layer/layer.scroll.js deleted file mode 100644 index 01fe2652f..000000000 --- a/src/base/layer/layer.scroll.js +++ /dev/null @@ -1,118 +0,0 @@ -/** - * guy - * @class BI.ScrollView - * @extends BI.Widget - */ -BI.ScrollView = BI.inherit(BI.Widget, { - - _const: { - dropDownHeight: 15, - expandIcon: "column-next-page-h-font", - collapseIcon: "column-pre-page-h-font" - }, - - _defaultConfig: function() { - return BI.extend(BI.ScrollView.superclass._defaultConfig.apply(this, arguments), { - baseCls:"bi-scroll-view", - scrollHeight: 50, - maxHeight: 300 - }) - }, - - _init : function() { - BI.ScrollView.superclass._init.apply(this, arguments); - - this.scrollUp = false; - this.scroll = BI.createWidget({ - type: "bi.vertical", - cls: "scroll-container", - scrolly: true - }) - BI.createWidget({ - type: "bi.vertical", - element: this, - scrolly: false, - items: [this.scroll] - }) - - this.dropdown = BI.createWidget({ - type: "bi.icon_button", - height: this._const.dropDownHeight, - cls: "scroll-drop-down-icon " + this._const.expandIcon, - handler: BI.bind(this._dropDownOrUp, this) - }) - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.dropdown, - left: 0, - right: 0, - bottom: -1 * this._const.dropDownHeight - }] - }) - this.populate(this.options.items); - }, - - _dropDownOrUp: function(){ - if(!this.scrollUp){ - var height = this.element.height(); - height += this.options.scrollHeight; - height = Math.min(height, this.scroll.element[0].scrollHeight, this.options.maxHeight); - this.element.height(height); - this._checkDropDownState(); - } else { - var height = this.element.height(); - height -= this.options.scrollHeight; - height = Math.max(height, this.options.height); - this.element.height(height); - this._checkDropDownState(); - } - }, - - _checkDropDownState: function(){ - var height = this.element.height(); - if(!this._checkScroll() || height >= this.options.maxHeight){ - this.scrollUp = true; - this.dropdown.element.removeClass(this._const.expandIcon).addClass(this._const.collapseIcon); - } else if(height <= this.options.height){ - this.scrollUp = false; - this.dropdown.element.addClass(this._const.expandIcon); - } else { - this.dropdown.element.addClass(this.scrollUp ? this._const.collapseIcon : this._const.expandIcon); - } - }, - - _checkScroll: function(){ - this.scroll.element.height(this.element.height()); - return this.scroll.element[0].scrollHeight > this.scroll.element[0].clientHeight; - }, - - _checkDropDown: function(){ - if(this._checkScroll()){ - this.dropdown.visible(); - //this.scrollUp = false; - this._checkDropDownState(); - } else { - this.dropdown.invisible(); - } - }, - - populate: function(){ - this.scroll.populate.apply(this.scroll, arguments); - this.resize(); - }, - - resize: function(){ - this.element.height(this.options.height); - BI.nextTick(BI.bind(this._checkDropDown, this)); - }, - - addItem: function(){ - this.scroll.addItem.apply(this.scroll, arguments); - BI.nextTick(BI.bind(this._checkDropDown, this)); - } -}); - -$.shortcut("bi.scroll_view", BI.ScrollView); \ No newline at end of file diff --git a/src/case/expander/expander.branch.handstand.js b/src/case/tree/expander/expander.branch.handstand.js similarity index 100% rename from src/case/expander/expander.branch.handstand.js rename to src/case/tree/expander/expander.branch.handstand.js diff --git a/src/case/expander/expander.branch.js b/src/case/tree/expander/expander.branch.js similarity index 100% rename from src/case/expander/expander.branch.js rename to src/case/tree/expander/expander.branch.js diff --git a/src/css/base/view/scrollview.css b/src/css/base/view/scrollview.css deleted file mode 100644 index 151b8a0fb..000000000 --- a/src/css/base/view/scrollview.css +++ /dev/null @@ -1,18 +0,0 @@ -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-scroll-view .scroll-container { - border-left: 1px solid #d4dadd; - border-right: 1px solid #d4dadd; - border-bottom: 1px solid #d4dadd; -} -.bi-scroll-view .scroll-drop-down-icon { - font-size: 14px; - border-bottom: 1px solid #d4dadd; - border-left: 1px solid #d4dadd; - border-right: 1px solid #d4dadd; - background: #f4f4f4; -} -.bi-scroll-view .scroll-drop-down-icon:active { - background: #d4dadd; -} diff --git a/src/less/base/logintimeout/login.timeout.less b/src/less/base/logintimeout/login.timeout.less deleted file mode 100644 index ebfa99736..000000000 --- a/src/less/base/logintimeout/login.timeout.less +++ /dev/null @@ -1,30 +0,0 @@ -@import "../../bibase"; -.bi-login-timeout-center{ - & .input-wrapper{ - border-bottom: 1px solid @color-bi-border-line; - & .login-input{ - font-size: @font-size-16; - } - & .error-mask{ - background: @color-bi-background-black; - .opacity(0.25); - color: @color-bi-text; - font-size: @font-size-16; - } - } - & .login-button{ - background: @color-bi-background-highlight; - .border-radius(25px); - font-size: @font-size-22; - color: @color-bi-text; - &:hover{ - .opacity(0.8); - } - } -} -.bi-login-timeout-south{ - & .keep-state{ - font-size: @font-size-14; - color: @color-bi-text-gray; - } -} \ No newline at end of file diff --git a/src/less/base/reqloading/loading.request.less b/src/less/base/reqloading/loading.request.less deleted file mode 100644 index ea2affda2..000000000 --- a/src/less/base/reqloading/loading.request.less +++ /dev/null @@ -1,20 +0,0 @@ -@import "../../bibase"; - -.bi-request-loading { - & .mask-pane { - background: @color-bi-background-default; - .opacity(0.8); - } - & .loading-comment { - font-size: 20px; - color: @color-bi-text-gray; - } - & .load-fail-comment { - font-size: 20px; - color: @color-bi-text-gray; - } - & .load-timeout-warning { - font-size: @font-size-16; - color: @color-bi-text-warning; - } -} \ No newline at end of file diff --git a/src/less/base/timeouttoast/widget.timeouttoast.less b/src/less/base/timeouttoast/widget.timeouttoast.less deleted file mode 100644 index b9447cd36..000000000 --- a/src/less/base/timeouttoast/widget.timeouttoast.less +++ /dev/null @@ -1,25 +0,0 @@ -@import "../../bibase"; - -.bi-timeout-toast { - font-size: @font-size-14; - .border-radius(2px); - background: @color-bi-tip-warning-background; - color: @color-bi-text-warning; - & .cancel-button { - background: @color-bi-background-default; - border: 1px solid @color-bi-border-normal; - color: @color-bi-text-black; - .border-radius(2px); - &:hover { - .opacity(0.8); - } - } - & .retry-button { - background: @color-bi-background-highlight; - .border-radius(2px); - color: @color-bi-text; - &:hover { - .opacity(0.8); - } - } -} \ No newline at end of file diff --git a/src/less/base/view/scrollview.less b/src/less/base/view/scrollview.less deleted file mode 100644 index 666adb59f..000000000 --- a/src/less/base/view/scrollview.less +++ /dev/null @@ -1,19 +0,0 @@ -@import "../../bibase"; - -.bi-scroll-view{ - .scroll-container{ - border-left: 1px solid @color-bi-split-dark; - border-right: 1px solid @color-bi-split-dark; - border-bottom: 1px solid @color-bi-split-dark; - } - & .scroll-drop-down-icon{ - font-size: @font-size-14; - border-bottom: 1px solid @color-bi-split-dark; - border-left: 1px solid @color-bi-split-dark; - border-right: 1px solid @color-bi-split-dark; - background: @color-bi-background-gray; - &:active{ - background: @color-bi-background-dark; - } - } -} \ No newline at end of file From dcd68ab9f6a55d48437a98134c39f78fb83bdc44 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Mar 2017 23:33:56 +0800 Subject: [PATCH 5/5] add --- dist/core.js | 71 ++++++++++++++++--- src/core/wrapper/layout.js | 12 ++-- src/core/wrapper/layout/adapt/adapt.center.js | 10 ++- .../wrapper/layout/adapt/adapt.horizontal.js | 10 ++- .../wrapper/layout/adapt/adapt.vertical.js | 10 ++- .../flex/wrapper/flex.wrapper.center.js | 10 ++- .../flex/wrapper/flex.wrapper.horizontal.js | 10 ++- .../wrapper/flex.wrapper.vertical.center.js | 9 +++ 8 files changed, 120 insertions(+), 22 deletions(-) diff --git a/dist/core.js b/dist/core.js index 0ed721a35..f21704bf5 100644 --- a/dist/core.js +++ b/dist/core.js @@ -19357,17 +19357,17 @@ BI.Layout = BI.inherit(BI.Widget, { */ addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.element); + w._mount(); return w; }, prependItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.unshift(item); w.element.prependTo(this.element); + w._mount(); return w; }, @@ -19379,10 +19379,10 @@ BI.Layout = BI.inherit(BI.Widget, { }, prependItems: function (items) { - var self = this; - BI.each(items, function (i, item) { - self.prependItem(item); - }) + items = items || []; + for (var i = items.length - 1; i >= 0; i--) { + this.prependItem(items[i]); + } }, getValue: function () { @@ -25051,9 +25051,17 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$tr); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$tr); + w._mount(); return w; }, @@ -25172,9 +25180,17 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$tr); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$tr); + w._mount(); return w; }, @@ -25459,9 +25475,17 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$tr); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$tr); + w._mount(); return w; }, @@ -26041,9 +26065,17 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$wrapper); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$wrapper); + w._mount(); return w; }, @@ -26130,9 +26162,17 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$wrapper); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$wrapper); + w._mount(); return w; }, @@ -26219,6 +26259,15 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { var w = this._addElement(this.options.items.length, item); this.options.items.push(item); w.element.appendTo(this.$wrapper); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$wrapper); + w._mount(); return w; }, diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 79bd7d4a4..4bc18481d 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -100,17 +100,17 @@ BI.Layout = BI.inherit(BI.Widget, { */ addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.element); + w._mount(); return w; }, prependItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.unshift(item); w.element.prependTo(this.element); + w._mount(); return w; }, @@ -122,10 +122,10 @@ BI.Layout = BI.inherit(BI.Widget, { }, prependItems: function (items) { - var self = this; - BI.each(items, function (i, item) { - self.prependItem(item); - }) + items = items || []; + for (var i = items.length - 1; i >= 0; i--) { + this.prependItem(items[i]); + } }, getValue: function () { diff --git a/src/core/wrapper/layout/adapt/adapt.center.js b/src/core/wrapper/layout/adapt/adapt.center.js index d1269d07e..072d929bd 100644 --- a/src/core/wrapper/layout/adapt/adapt.center.js +++ b/src/core/wrapper/layout/adapt/adapt.center.js @@ -109,9 +109,17 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$tr); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$tr); + w._mount(); return w; }, diff --git a/src/core/wrapper/layout/adapt/adapt.horizontal.js b/src/core/wrapper/layout/adapt/adapt.horizontal.js index bc8cc16b6..dbcb42a15 100644 --- a/src/core/wrapper/layout/adapt/adapt.horizontal.js +++ b/src/core/wrapper/layout/adapt/adapt.horizontal.js @@ -108,9 +108,17 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$tr); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$tr); + w._mount(); return w; }, diff --git a/src/core/wrapper/layout/adapt/adapt.vertical.js b/src/core/wrapper/layout/adapt/adapt.vertical.js index f6588c063..e4cf6de7a 100644 --- a/src/core/wrapper/layout/adapt/adapt.vertical.js +++ b/src/core/wrapper/layout/adapt/adapt.vertical.js @@ -102,9 +102,17 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$tr); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$tr); + w._mount(); return w; }, diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js index 7abf1a554..1f23508c9 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js @@ -42,9 +42,17 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$wrapper); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$wrapper); + w._mount(); return w; }, diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js index 1ea52dcfc..1aff0d676 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js @@ -72,9 +72,17 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { addItem: function (item) { var w = this._addElement(this.options.items.length, item); - w._mount(); this.options.items.push(item); w.element.appendTo(this.$wrapper); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$wrapper); + w._mount(); return w; }, diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js index 4e6cfb417..32da933fd 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js @@ -72,6 +72,15 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, { var w = this._addElement(this.options.items.length, item); this.options.items.push(item); w.element.appendTo(this.$wrapper); + w._mount(); + return w; + }, + + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + this.options.items.unshift(item); + w.element.appendTo(this.$wrapper); + w._mount(); return w; },