Skip to content

Commit fd8e69c

Browse files
authored
Merge pull request #532 from shahimclt/master
Add events for ajax insert, show and hide
2 parents 2b9cc7a + 10054a0 commit fd8e69c

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
@@ -123,6 +123,18 @@
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);
129+
},
130+
triggerShowEvent: function (edge,rel) {
131+
var initEvent = $.Event('show.orgchart.'+rel);
132+
edge.trigger(initEvent);
133+
},
134+
triggerHideEvent: function (edge,rel) {
135+
var initEvent = $.Event('hide.orgchart.'+rel);
136+
edge.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.triggerInsertEvent($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 {

0 commit comments

Comments
 (0)