orgchart 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -1
- package/demo/edit-chart.html +0 -3
- package/demo/edit-hybrid-chart.html +0 -3
- package/demo/get-related-nodes.html +149 -0
- package/demo/index.html +1 -0
- package/dist/css/jquery.orgchart.css +1 -3
- package/dist/css/jquery.orgchart.min.css +1 -1
- package/dist/js/jquery.orgchart.js +18 -9
- package/dist/js/jquery.orgchart.min.js +1 -1
- package/dist/js/jquery.orgchart.min.js.map +1 -1
- package/package.json +3 -2
- package/src/css/jquery.orgchart.css +1 -3
- package/src/js/jquery.orgchart.js +18 -9
- package/test/integration/init-tests.js +1 -1
- package/test/unit/tests.js +33 -1
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
$chartContainer.append($chart);
|
|
90
90
|
|
|
91
91
|
// append the export button
|
|
92
|
-
if (this.options.exportButton && !$
|
|
92
|
+
if (this.options.exportButton && !$('.oc-export-btn').length) {
|
|
93
93
|
this.attachExportButton();
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -136,18 +136,18 @@
|
|
|
136
136
|
var initEvent = $.Event('hide-' + rel + '.orgchart');
|
|
137
137
|
$target.trigger(initEvent);
|
|
138
138
|
},
|
|
139
|
-
//
|
|
139
|
+
// add export button for orgchart
|
|
140
140
|
attachExportButton: function () {
|
|
141
141
|
var that = this;
|
|
142
142
|
var $exportBtn = $('<button>', {
|
|
143
|
-
'class': 'oc-export-btn'
|
|
143
|
+
'class': 'oc-export-btn',
|
|
144
144
|
'text': this.options.exportButtonName,
|
|
145
145
|
'click': function(e) {
|
|
146
146
|
e.preventDefault();
|
|
147
147
|
that.export();
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
|
-
this.$chartContainer.
|
|
150
|
+
this.$chartContainer.after($exportBtn);
|
|
151
151
|
},
|
|
152
152
|
setOptions: function (opts, val) {
|
|
153
153
|
if (typeof opts === 'string') {
|
|
@@ -471,6 +471,15 @@
|
|
|
471
471
|
}
|
|
472
472
|
return { 'exist': false, 'visible': false };
|
|
473
473
|
},
|
|
474
|
+
getParent: function ($node) {
|
|
475
|
+
return this.getRelatedNodes($node, 'parent');
|
|
476
|
+
},
|
|
477
|
+
getChildren: function ($node) {
|
|
478
|
+
return this.getRelatedNodes($node, 'children');
|
|
479
|
+
},
|
|
480
|
+
getSiblings: function ($node) {
|
|
481
|
+
return this.getRelatedNodes($node, 'siblings');
|
|
482
|
+
},
|
|
474
483
|
// find the related nodes
|
|
475
484
|
getRelatedNodes: function ($node, relation) {
|
|
476
485
|
if (!$node || !($node instanceof $) || !$node.is('.node')) {
|
|
@@ -693,7 +702,7 @@
|
|
|
693
702
|
$edge.parent().append('<i class="oci oci-spinner spinner"></i>')
|
|
694
703
|
.children().not('.spinner').css('opacity', 0.2);
|
|
695
704
|
$chart.data('inAjax', true);
|
|
696
|
-
$('.oc-export-btn'
|
|
705
|
+
$('.oc-export-btn').prop('disabled', true);
|
|
697
706
|
return true;
|
|
698
707
|
},
|
|
699
708
|
// terminate loading status for requesting new nodes
|
|
@@ -703,7 +712,7 @@
|
|
|
703
712
|
$node.find('.spinner').remove();
|
|
704
713
|
$node.children().removeAttr('style');
|
|
705
714
|
this.$chart.data('inAjax', false);
|
|
706
|
-
$('.oc-export-btn'
|
|
715
|
+
$('.oc-export-btn').prop('disabled', false);
|
|
707
716
|
},
|
|
708
717
|
// whether the cursor is hovering over the node
|
|
709
718
|
isInAction: function ($node) {
|
|
@@ -1041,7 +1050,7 @@
|
|
|
1041
1050
|
event.originalEvent.dataTransfer.dropEffect = 'none';
|
|
1042
1051
|
} else {
|
|
1043
1052
|
// default action for drag-and-drop of div is not to drop, so preventing default action for nodes which have allowedDrop class
|
|
1044
|
-
//to fix drag and drop on IE and Edge
|
|
1053
|
+
//to fix drag and drop on IE and Edge
|
|
1045
1054
|
event.preventDefault();
|
|
1046
1055
|
}
|
|
1047
1056
|
},
|
|
@@ -1059,7 +1068,7 @@
|
|
|
1059
1068
|
this.$chart.triggerHandler({ 'type': 'otherdropped.orgchart', 'draggedItem': $dragged, 'dropZone': $dropZone });
|
|
1060
1069
|
return;
|
|
1061
1070
|
}
|
|
1062
|
-
|
|
1071
|
+
|
|
1063
1072
|
if (!$dropZone.hasClass('allowedDrop')) {
|
|
1064
1073
|
// We are trying to drop a node into a node which isn't allowed
|
|
1065
1074
|
// IE/Edge have a habit of allowing this, so we need our own double-check
|
|
@@ -1461,7 +1470,7 @@
|
|
|
1461
1470
|
.end().end().remove();
|
|
1462
1471
|
}
|
|
1463
1472
|
} else { // if $node is root node
|
|
1464
|
-
$wrapper.closest('.orgchart').
|
|
1473
|
+
$wrapper.closest('.orgchart').remove();
|
|
1465
1474
|
}
|
|
1466
1475
|
},
|
|
1467
1476
|
//
|
|
@@ -181,7 +181,7 @@ describe('orgchart -- integration tests', function () {
|
|
|
181
181
|
'data': ds,
|
|
182
182
|
'exportButton': true
|
|
183
183
|
});
|
|
184
|
-
$
|
|
184
|
+
$('.oc-export-btn').prop('outerHTML').should.equal('<button class="oc-export-btn">Export</button>');
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
it('initialize chart with "bottom to top" direction', function () {
|
package/test/unit/tests.js
CHANGED
|
@@ -184,7 +184,8 @@ describe('orgchart -- unit tests', function () {
|
|
|
184
184
|
|
|
185
185
|
it('getRelatedNodes()', function () {
|
|
186
186
|
oc.getRelatedNodes().should.deep.equal($());
|
|
187
|
-
oc.getRelatedNodes(
|
|
187
|
+
oc.getRelatedNodes({}, 'children').should.deep.equal($());
|
|
188
|
+
oc.getRelatedNodes($('.hierarchy:first'), 'children').should.deep.equal($());
|
|
188
189
|
oc.getRelatedNodes($('.node:first'), 'child').should.deep.equal($());
|
|
189
190
|
|
|
190
191
|
oc.getRelatedNodes($laolao, 'parent').should.deep.equal($());
|
|
@@ -196,6 +197,37 @@ describe('orgchart -- unit tests', function () {
|
|
|
196
197
|
oc.getRelatedNodes($bomiao, 'siblings').toArray().should.members([$sumiao[0], $hongmiao[0]]);
|
|
197
198
|
});
|
|
198
199
|
|
|
200
|
+
it('getParent()', function () {
|
|
201
|
+
oc.getParent().should.deep.equal($());
|
|
202
|
+
oc.getParent({}).should.deep.equal($());
|
|
203
|
+
oc.getParent($('.hierarchy:first')).should.deep.equal($());
|
|
204
|
+
|
|
205
|
+
oc.getParent($laolao).should.deep.equal($());
|
|
206
|
+
oc.getParent($bomiao).should.deep.equal($laolao);
|
|
207
|
+
oc.getParent($sandan).should.deep.equal($pangpang);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('getSiblings()', function () {
|
|
211
|
+
oc.getSiblings().should.deep.equal($());
|
|
212
|
+
oc.getSiblings({}).should.deep.equal($());
|
|
213
|
+
oc.getSiblings($('.hierarchy:first')).should.deep.equal($());
|
|
214
|
+
|
|
215
|
+
oc.getSiblings($laolao).should.deep.equal($());
|
|
216
|
+
oc.getSiblings($bomiao).toArray().should.members([$sumiao[0], $hongmiao[0]]);
|
|
217
|
+
oc.getSiblings($sandan).should.deep.equal($());
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('getChildren()', function () {
|
|
221
|
+
oc.getChildren().should.deep.equal($());
|
|
222
|
+
oc.getChildren({}).should.deep.equal($());
|
|
223
|
+
oc.getChildren($('.hierarchy:first')).should.deep.equal($());
|
|
224
|
+
|
|
225
|
+
oc.getChildren($laolao).toArray().should.members([$bomiao[0], $sumiao[0], $hongmiao[0]]);
|
|
226
|
+
oc.getChildren($bomiao).should.deep.equal($());
|
|
227
|
+
oc.getChildren($sumiao).toArray().should.members([$tiehua[0], $heihei[0], $pangpang[0]]);
|
|
228
|
+
oc.getChildren($sandan).should.deep.equal($());
|
|
229
|
+
});
|
|
230
|
+
|
|
199
231
|
it('hideParent()', function () {
|
|
200
232
|
var spy = sinon.spy(oc, 'hideParent');
|
|
201
233
|
var spy2 = sinon.spy(oc, 'hideSiblings');
|