Skip to content

Commit 950f711

Browse files
committed
append load, show/hide events
1 parent fd8e69c commit 950f711

File tree

7 files changed

+88
-20
lines changed

7 files changed

+88
-20
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,21 @@ This method allow you to export current orgchart as png or pdf file.
755755
<td>chart</td>
756756
<td>Initialisation complete event - fired when Organization Chart has been fully initialised and data loaded.</td>
757757
</tr>
758+
<tr>
759+
<td>load-[relation].orgchart</td>
760+
<td></td>
761+
<td>This event is fired on a node after the onDemand loading completes.<b>[relation]</b> can be either parent, children or siblings.</td>
762+
</tr>
763+
<tr>
764+
<td>show-[relation].orgchart</td>
765+
<td></td>
766+
<td>This event is fired when related nodes of a node become visible.</td>
767+
</tr>
768+
<tr>
769+
<td>hide-[relation].orgchart</td>
770+
<td></td>
771+
<td>This event if fired when related nodes of a node are collapsed.</td>
772+
</tr>
758773
</tbody>
759774
</table>
760775

README.zh-cn.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,21 @@ Adds parent node(actullay it's always root node) for current orgchart.
756756
<td>chart</td>
757757
<td>当组织结构图初始化完成时,该事件触发。在响应事件处理器中,你可以访问到渲染出的任意节点。</td>
758758
</tr>
759+
<tr>
760+
<td>load-[relation].orgchart</td>
761+
<td></td>
762+
<td>在按需请求数据场景中,每次载入新节点后,触发该事件。<b>[relation]</b>的可选值是parent, children, siblings。</td>
763+
</tr>
764+
<tr>
765+
<td>show-[relation].orgchart</td>
766+
<td></td>
767+
<td>在显示指定节点的关联节点时,触发该事件。</td>
768+
</tr>
769+
<tr>
770+
<td>hide-[relation].orgchart</td>
771+
<td></td>
772+
<td>在隐藏指定节点的关联节点时,触发该事件。</td>
773+
</tr>
759774
</tbody>
760775
</table>
761776

README.zh-tw.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,21 @@ Adds parent node(actullay it's always root node) for current orgchart.
756756
<td>chart</td>
757757
<td>當組織結構圖初始化完成時,該事件觸發。在響應事件處理器中,你可以訪問到渲染出的任意節點。</td>
758758
</tr>
759+
<tr>
760+
<td>load-[relation].orgchart</td>
761+
<td></td>
762+
<td>在按需請求數據場景中,每次載入新節點後,觸發該事件。<b>[relation]</b>的可選值是parent, children, siblings。</td>
763+
</tr>
764+
<tr>
765+
<td>show-[relation].orgchart</td>
766+
<td></td>
767+
<td>在顯示指定節點的關聯節點時,觸發該事件。</td>
768+
</tr>
769+
<tr>
770+
<td>hide-[relation].orgchart</td>
771+
<td></td>
772+
<td>在隱藏指定節點的關聯節點時,觸發該事件。</td>
773+
</tr>
759774
</tbody>
760775
</table>
761776

dist/js/jquery.orgchart.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@
123123
});
124124
mo.observe(this.$chartContainer[0], { childList: true });
125125
},
126+
triggerLoadEvent: function ($target, rel) {
127+
var initEvent = $.Event('insert-' + rel +'.orgchart');
128+
$target.trigger(initEvent);
129+
},
130+
triggerShowEvent: function ($target, rel) {
131+
var initEvent = $.Event('show-' + rel + '.orgchart');
132+
$target.trigger(initEvent);
133+
},
134+
triggerHideEvent: function ($target, rel) {
135+
var initEvent = $.Event('hide-' + rel + '.orgchart');
136+
$target.trigger(initEvent);
137+
},
126138
//
127139
attachExportButton: function () {
128140
var that = this;
@@ -770,6 +782,7 @@
770782
} else {
771783
that.addSiblings($edge.parent(), data.siblings ? data.siblings : data);
772784
}
785+
that.triggerLoadEvent($edge.parent(), rel);
773786
}
774787
})
775788
.fail(function () {
@@ -802,8 +815,10 @@
802815
if (parentState.visible) {
803816
this.hideParent($node);
804817
$parent.one('transitionend', { 'topEdge': $topEdge }, this.HideFirstParentEnd.bind(this));
818+
this.triggerHideEvent($node, 'parent');
805819
} else { // show the ancestors and siblings
806820
this.showParent($node);
821+
this.triggerShowEvent($node, 'parent');
807822
}
808823
} else { // load the new parent node of the specified node by ajax request
809824
// start up loading status
@@ -826,8 +841,10 @@
826841
// hide the descendant nodes of the specified node
827842
if (childrenState.visible) {
828843
this.hideChildren($node);
844+
this.triggerHideEvent($node, 'children');
829845
} else { // show the descendants
830846
this.showChildren($node);
847+
this.triggerShowEvent($node, 'children');
831848
}
832849
} else { // load the new children nodes of the specified node by ajax request
833850
if (this.startLoading($bottomEdge)) {
@@ -853,21 +870,27 @@
853870
if ($hEdge.is('.leftEdge')) {
854871
if ($prevSib.is('.hidden')) {
855872
this.showSiblings($node, 'left');
873+
this.triggerShowEvent($node,'siblings');
856874
} else {
857875
this.hideSiblings($node, 'left');
876+
this.triggerHideEvent($node, 'siblings');
858877
}
859878
} else {
860879
if ($nextSib.is('.hidden')) {
861880
this.showSiblings($node, 'right');
881+
this.triggerShowEvent($node,'siblings');
862882
} else {
863883
this.hideSiblings($node, 'right');
884+
this.triggerHideEvent($node, 'siblings');
864885
}
865886
}
866887
} else {
867888
if (siblingsState.visible) {
868889
this.hideSiblings($node);
890+
this.triggerHideEvent($node, 'siblings');
869891
} else {
870892
this.showSiblings($node);
893+
this.triggerShowEvent($node, 'siblings');
871894
}
872895
}
873896
} else {

dist/js/jquery.orgchart.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/jquery.orgchart.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/jquery.orgchart.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,17 @@
123123
});
124124
mo.observe(this.$chartContainer[0], { childList: true });
125125
},
126-
triggerInsertEvent: function (edge,rel) {
127-
var initEvent = $.Event('insert.orgchart.'+rel);
128-
edge.trigger(initEvent);
126+
triggerLoadEvent: function ($target, rel) {
127+
var initEvent = $.Event('load-' + rel +'.orgchart');
128+
$target.trigger(initEvent);
129129
},
130-
triggerShowEvent: function (edge,rel) {
131-
var initEvent = $.Event('show.orgchart.'+rel);
132-
edge.trigger(initEvent);
130+
triggerShowEvent: function ($target, rel) {
131+
var initEvent = $.Event('show-' + rel + '.orgchart');
132+
$target.trigger(initEvent);
133133
},
134-
triggerHideEvent: function (edge,rel) {
135-
var initEvent = $.Event('hide.orgchart.'+rel);
136-
edge.trigger(initEvent);
134+
triggerHideEvent: function ($target, rel) {
135+
var initEvent = $.Event('hide-' + rel + '.orgchart');
136+
$target.trigger(initEvent);
137137
},
138138
//
139139
attachExportButton: function () {
@@ -782,7 +782,7 @@
782782
} else {
783783
that.addSiblings($edge.parent(), data.siblings ? data.siblings : data);
784784
}
785-
that.triggerInsertEvent($edge.parent(),rel);
785+
that.triggerLoadEvent($edge.parent(), rel);
786786
}
787787
})
788788
.fail(function () {
@@ -815,10 +815,10 @@
815815
if (parentState.visible) {
816816
this.hideParent($node);
817817
$parent.one('transitionend', { 'topEdge': $topEdge }, this.HideFirstParentEnd.bind(this));
818-
this.triggerHideEvent($node,'parent');
818+
this.triggerHideEvent($node, 'parent');
819819
} else { // show the ancestors and siblings
820820
this.showParent($node);
821-
this.triggerShowEvent($node,'parent');
821+
this.triggerShowEvent($node, 'parent');
822822
}
823823
} else { // load the new parent node of the specified node by ajax request
824824
// start up loading status
@@ -841,10 +841,10 @@
841841
// hide the descendant nodes of the specified node
842842
if (childrenState.visible) {
843843
this.hideChildren($node);
844-
this.triggerHideEvent($node,'children');
844+
this.triggerHideEvent($node, 'children');
845845
} else { // show the descendants
846846
this.showChildren($node);
847-
this.triggerShowEvent($node,'children');
847+
this.triggerShowEvent($node, 'children');
848848
}
849849
} else { // load the new children nodes of the specified node by ajax request
850850
if (this.startLoading($bottomEdge)) {
@@ -873,24 +873,24 @@
873873
this.triggerShowEvent($node,'siblings');
874874
} else {
875875
this.hideSiblings($node, 'left');
876-
this.triggerHideEvent($node,'siblings');
876+
this.triggerHideEvent($node, 'siblings');
877877
}
878878
} else {
879879
if ($nextSib.is('.hidden')) {
880880
this.showSiblings($node, 'right');
881881
this.triggerShowEvent($node,'siblings');
882882
} else {
883883
this.hideSiblings($node, 'right');
884-
this.triggerHideEvent($node,'siblings');
884+
this.triggerHideEvent($node, 'siblings');
885885
}
886886
}
887887
} else {
888888
if (siblingsState.visible) {
889889
this.hideSiblings($node);
890-
this.triggerHideEvent($node,'siblings');
890+
this.triggerHideEvent($node, 'siblings');
891891
} else {
892892
this.showSiblings($node);
893-
this.triggerShowEvent($node,'siblings');
893+
this.triggerShowEvent($node, 'siblings');
894894
}
895895
}
896896
} else {

0 commit comments

Comments
 (0)