From 868b546de11b19a7a1d3780d306c0d1fc68a9d51 Mon Sep 17 00:00:00 2001 From: dabeng Date: Sun, 14 Jan 2018 22:14:33 +0800 Subject: [PATCH] refactor the core methods --- README.md | 21 +- demo/center-on-selected-node.html | 2 +- demo/edit-chart.html | 36 +- demo/expand-to-given-depth.html | 8 +- demo/export-chart.html | 2 +- demo/index.html | 6 +- demo/local-datasource.html | 2 +- demo/option-createNode.html | 2 +- ...ertical-depth.html => vertical-level.html} | 4 +- src/js/jquery.orgchart.js | 316 ++++++++---------- test/e2e/pan-zoom/page-model.js | 9 + test/e2e/pan-zoom/test.js | 33 ++ .../page-model.js | 0 .../test.js | 2 +- test/integration/init-tests.js | 218 ++++++++++++ test/integration/tests.js | 23 +- test/unit/tests.js | 8 +- 17 files changed, 452 insertions(+), 240 deletions(-) rename demo/{vertical-depth.html => vertical-level.html} (97%) create mode 100644 test/e2e/pan-zoom/page-model.js create mode 100644 test/e2e/pan-zoom/test.js rename test/e2e/{vertical-depth => vertical-level}/page-model.js (100%) rename test/e2e/{vertical-depth => vertical-level}/test.js (96%) create mode 100644 test/integration/init-tests.js diff --git a/README.md b/README.md index 0ded2064..8f2859b9 100644 --- a/README.md +++ b/README.md @@ -100,11 +100,11 @@ It's a so easy task, we just need to append id or className property to node dat In fact, this is a wonderful solution to display a orgchart which includes a huge number of node data. -- [I want a hybrid(horizontal + vertical) chart](https://rawgit.com/dabeng/OrgChart/master/demo/vertical-depth.html) +- [I want a hybrid(horizontal + vertical) chart](https://rawgit.com/dabeng/OrgChart/master/demo/vertical-level.html) This feature is inspired by the issues([Aligning Children Vertical](https://github.com/dabeng/OrgChart/issues/46), [Hybrid(horizontal + vertical) OrgChart](https://github.com/dabeng/OrgChart/issues/61)). Thank [mfahadi](https://github.com/mfahadi) and [Destructrix](https://github.com/Destructrix) for their constructive suggestions:blush: Special thanks to [tedliang](https://github.com/tedliang) for his wonderful hybrid mode solution. -From now on, users never have to worry about how to align a huge of nodes in one screen of browser. The option "verticalDepth" allows users to align child nodes vertically from the given depth. +From now on, users never have to worry about how to align a huge of nodes in one screen of browser. The option "verticalLevel" allows users to align child nodes vertically from the given level. **Note**: currently, this option is incompatible with many other options or methods, like direction, drag&drop, addChildren(), removeNodes(), getHierarchy() and so on. These conflicts will be solved one by one in the later versions. @@ -191,7 +191,7 @@ var oc = $('#chartContainerId').orgchart(options); directionstringno"t2b"The available values are t2b(implies "top to bottom", it's default value), b2t(implies "bottom to top"), l2r(implies "left to right"), r2l(implies "right to left"). - verticalDepthintegernoUsers can make use of this option to align the nodes vertically from the specified depth. + verticalLevelinteger(>=2)noUsers can make use of this option to align the nodes vertically from the specified level. toggleSiblingsRespbooleannofalseOnce enable this option, users can show/hide left/right sibling nodes respectively by clicking left/right arrow. @@ -200,7 +200,7 @@ var oc = $('#chartContainerId').orgchart(options); ajaxURLjsonnoIt inclueds four properites -- parent, children, siblings, families(ask for parent node and siblings nodes). As their names imply, different propety provides the URL to which ajax request for different nodes is sent. - depthpositive integerno999It indicates the level that at the very beginning orgchart is expanded to. + visibleLevelpositive integerno999It indicates the level that at the very beginning orgchart is expanded to. nodeTitlestringno"name"It sets one property of datasource as text content of title section of orgchart node. In fact, users can create a simple orghcart with only nodeTitle option. @@ -251,7 +251,7 @@ I'm sure that you can grasp the key points of the methods below after you try ou Embeds an organization chart in designated container. Accepts an options object and you can go through the "options" section to find which options are required. Variable oc is the instance of class OrgChart. #### init(newOptions) It's the useful way when users want to re-initialize or refresh orgchart based on new options or reload new data. -#### addParent(data, opts) +#### addParent(data) Adds parent node(actullay it's always root node) for current orgchart. @@ -259,11 +259,10 @@ Adds parent node(actullay it's always root node) for current orgchart. -
datajson objectyesdatasource for building root node
optsjson objectnoinitial options of current orgchartoptions used for overriding initial options
-#### addSiblings($node, data, opts) +#### addSiblings($node, data) Adds sibling nodes for designated node. @@ -271,12 +270,11 @@ Adds sibling nodes for designated node. - - +
$nodejquery objectyeswe'll add sibling nodes based on this node
datajson objectyesdatasource for building sibling nodes
optsjson objectnoinitial options of current orgchartoptions used for overriding initial options
dataarrayyesdatasource for building sibling nodes
-#### addChildren($node, data, opts) +#### addChildren($node, data) Adds child nodes for designed node. @@ -284,8 +282,7 @@ Adds child nodes for designed node. - - +
$nodejquery objectyeswe'll add child nodes based on this node
datajson objectyesdatasource for building child nodes
optsjson objectnoinitial options of current orgchartoptions used for overriding initial options
dataarrayyesdatasource for building child nodes
diff --git a/demo/center-on-selected-node.html b/demo/center-on-selected-node.html index 86229938..a6503cdf 100644 --- a/demo/center-on-selected-node.html +++ b/demo/center-on-selected-node.html @@ -47,7 +47,7 @@ }; $('#chart-container').orgchart({ - 'depth': 2, + 'visibleLevel': 2, 'pan': true, 'data' : datascource, 'nodeContent': 'title', diff --git a/demo/edit-chart.html b/demo/edit-chart.html index febebba4..854ee59b 100755 --- a/demo/edit-chart.html +++ b/demo/edit-chart.html @@ -8,10 +8,11 @@