Skip to content

Commit 9225daa

Browse files
committed
added events for ajax insert, show and hide
1 parent a4e69f2 commit 9225daa

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/js/jquery.orgchart.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@
122122
});
123123
mo.observe(this.$chartContainer[0], { childList: true });
124124
},
125+
triggerInsertEvent: function (edge,rel) {
126+
var initEvent = $.Event('insert.orgchart.'+rel);
127+
edge.trigger(initEvent);
128+
},
129+
triggerShowEvent: function (edge,rel) {
130+
var initEvent = $.Event('show.orgchart.'+rel);
131+
edge.trigger(initEvent);
132+
},
133+
triggerHideEvent: function (edge,rel) {
134+
var initEvent = $.Event('hide.orgchart.'+rel);
135+
edge.trigger(initEvent);
136+
},
125137
//
126138
attachExportButton: function () {
127139
var that = this;
@@ -761,6 +773,7 @@
761773
} else {
762774
that.addSiblings($edge.parent(), data.siblings ? data.siblings : data);
763775
}
776+
that.triggerInsertEvent($edge.parent(),rel);
764777
}
765778
})
766779
.fail(function () {
@@ -793,8 +806,10 @@
793806
if (parentState.visible) {
794807
this.hideParent($node);
795808
$parent.one('transitionend', { 'topEdge': $topEdge }, this.HideFirstParentEnd.bind(this));
809+
this.triggerHideEvent($node,'parent');
796810
} else { // show the ancestors and siblings
797811
this.showParent($node);
812+
this.triggerShowEvent($node,'parent');
798813
}
799814
} else { // load the new parent node of the specified node by ajax request
800815
// start up loading status
@@ -817,8 +832,10 @@
817832
// hide the descendant nodes of the specified node
818833
if (childrenState.visible) {
819834
this.hideChildren($node);
835+
this.triggerHideEvent($node,'children');
820836
} else { // show the descendants
821837
this.showChildren($node);
838+
this.triggerShowEvent($node,'children');
822839
}
823840
} else { // load the new children nodes of the specified node by ajax request
824841
if (this.startLoading($bottomEdge)) {
@@ -844,21 +861,27 @@
844861
if ($hEdge.is('.leftEdge')) {
845862
if ($prevSib.is('.hidden')) {
846863
this.showSiblings($node, 'left');
864+
this.triggerShowEvent($node,'siblings');
847865
} else {
848866
this.hideSiblings($node, 'left');
867+
this.triggerHideEvent($node,'siblings');
849868
}
850869
} else {
851870
if ($nextSib.is('.hidden')) {
852871
this.showSiblings($node, 'right');
872+
this.triggerShowEvent($node,'siblings');
853873
} else {
854874
this.hideSiblings($node, 'right');
875+
this.triggerHideEvent($node,'siblings');
855876
}
856877
}
857878
} else {
858879
if (siblingsState.visible) {
859880
this.hideSiblings($node);
881+
this.triggerHideEvent($node,'siblings');
860882
} else {
861883
this.showSiblings($node);
884+
this.triggerShowEvent($node,'siblings');
862885
}
863886
}
864887
} else {

0 commit comments

Comments
 (0)