Skip to content

Commit f2608dc

Browse files
committed
Merge branch 'master' of https://github.com/dabeng/OrgChart
2 parents bab7edb + 6cb7d83 commit f2608dc

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

dist/js/jquery.orgchart.js

+42-42
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
return this;
183183
},
184184
//
185-
setOptions (opts, val) {
185+
setOptions: function (opts, val) {
186186
if (typeof opts === 'string') {
187187
if (opts === 'pan') {
188188
if (val) {
@@ -223,7 +223,7 @@
223223
return this;
224224
},
225225
//
226-
panStartHandler (e) {
226+
panStartHandler: function (e) {
227227
var $chart = $(e.delegateTarget);
228228
if ($(e.target).closest('.node').length || (e.touches && e.touches.length > 1)) {
229229
$chart.data('panning', false);
@@ -291,47 +291,47 @@
291291
});
292292
},
293293
//
294-
panEndHandler (e) {
294+
panEndHandler: function (e) {
295295
if (e.data.chart.data('panning')) {
296296
e.data.chart.data('panning', false).css('cursor', 'default').off('mousemove');
297297
}
298298
},
299299
//
300-
bindPan () {
300+
bindPan: function () {
301301
this.$chartContainer.css('overflow', 'hidden');
302302
this.$chart.on('mousedown touchstart', this.panStartHandler);
303303
$(document).on('mouseup touchend', { 'chart': this.$chart }, this.panEndHandler);
304304
},
305305
//
306-
unbindPan () {
306+
unbindPan: function () {
307307
this.$chartContainer.css('overflow', 'auto');
308308
this.$chart.off('mousedown touchstart', this.panStartHandler);
309309
$(document).off('mouseup touchend', this.panEndHandler);
310310
},
311311
//
312-
zoomWheelHandler (e) {
312+
zoomWheelHandler: function (e) {
313313
var oc = e.data.oc;
314314
e.preventDefault();
315315
var newScale = 1 + (e.originalEvent.deltaY > 0 ? -0.2 : 0.2);
316316
oc.setChartScale(oc.$chart, newScale);
317317
},
318318
//
319-
zoomStartHandler (e) {
319+
zoomStartHandler: function (e) {
320320
if(e.touches && e.touches.length === 2) {
321321
var oc = e.data.oc;
322322
oc.$chart.data('pinching', true);
323323
var dist = oc.getPinchDist(e);
324324
oc.$chart.data('pinchDistStart', dist);
325325
}
326326
},
327-
zoomingHandler (e) {
327+
zoomingHandler: function (e) {
328328
var oc = e.data.oc;
329329
if(oc.$chart.data('pinching')) {
330330
var dist = oc.getPinchDist(e);
331331
oc.$chart.data('pinchDistEnd', dist);
332332
}
333333
},
334-
zoomEndHandler (e) {
334+
zoomEndHandler: function (e) {
335335
var oc = e.data.oc;
336336
if(oc.$chart.data('pinching')) {
337337
oc.$chart.data('pinching', false);
@@ -344,25 +344,25 @@
344344
}
345345
},
346346
//
347-
bindZoom () {
347+
bindZoom: function () {
348348
this.$chartContainer.on('wheel', { 'oc': this }, this.zoomWheelHandler);
349349
this.$chartContainer.on('touchstart', { 'oc': this }, this.zoomStartHandler);
350350
$(document).on('touchmove', { 'oc': this }, this.zoomingHandler);
351351
$(document).on('touchend', { 'oc': this }, this.zoomEndHandler);
352352
},
353-
unbindZoom () {
353+
unbindZoom: function () {
354354
this.$chartContainer.off('wheel', this.zoomWheelHandler);
355355
this.$chartContainer.off('touchstart', this.zoomStartHandler);
356356
$(document).off('touchmove', this.zoomingHandler);
357357
$(document).off('touchend', this.zoomEndHandler);
358358
},
359359
//
360-
getPinchDist (e) {
360+
getPinchDist: function (e) {
361361
return Math.sqrt((e.touches[0].clientX - e.touches[1].clientX) * (e.touches[0].clientX - e.touches[1].clientX) +
362362
(e.touches[0].clientY - e.touches[1].clientY) * (e.touches[0].clientY - e.touches[1].clientY));
363363
},
364364
//
365-
setChartScale ($chart, newScale) {
365+
setChartScale: function ($chart, newScale) {
366366
var opts = $chart.data('options');
367367
var lastTf = $chart.css('transform');
368368
var matrix = '';
@@ -385,7 +385,7 @@
385385
}
386386
},
387387
//
388-
buildJsonDS ($li) {
388+
buildJsonDS: function ($li) {
389389
var that = this;
390390
var subObj = {
391391
'name': $li.contents().eq(0).text().trim(),
@@ -401,7 +401,7 @@
401401
return subObj;
402402
},
403403
//
404-
attachRel (data, flags) {
404+
attachRel: function (data, flags) {
405405
var that = this;
406406
data.relationship = flags + (data.children && data.children.length > 0 ? 1 : 0);
407407
if (data.children) {
@@ -412,7 +412,7 @@
412412
return data;
413413
},
414414
//
415-
loopChart ($chart) {
415+
loopChart: function ($chart) {
416416
var that = this;
417417
var $tr = $chart.find('tr:first');
418418
var subObj = { 'id': $tr.find('.node')[0].id };
@@ -423,15 +423,15 @@
423423
return subObj;
424424
},
425425
//
426-
getHierarchy ($chart) {
426+
getHierarchy: function ($chart) {
427427
var $chart = $chart || this.$chart;
428428
if (!$chart.find('.node:first')[0].id) {
429429
return 'Error: Nodes of orghcart to be exported must have id attribute!';
430430
}
431431
return this.loopChart($chart);
432432
},
433433
// detect the exist/display state of related node
434-
getNodeState ($node, relation) {
434+
getNodeState: function ($node, relation) {
435435
var $target = {};
436436
if (relation === 'parent') {
437437
$target = $node.closest('.nodes').siblings(':first');
@@ -449,7 +449,7 @@
449449
return { 'exist': false, 'visible': false };
450450
},
451451
// find the related nodes
452-
getRelatedNodes ($node, relation) {
452+
getRelatedNodes: function ($node, relation) {
453453
if (relation === 'parent') {
454454
return $node.closest('.nodes').parent().children(':first').find('.node');
455455
} else if (relation === 'children') {
@@ -459,7 +459,7 @@
459459
}
460460
},
461461
// recursively hide the ancestor node and sibling nodes of the specified node
462-
hideParent ($node) {
462+
hideParent: function ($node) {
463463
var $temp = $node.closest('table').closest('tr').siblings();
464464
if ($temp.eq(0).find('.spinner').length) {
465465
$node.closest('.orgchart').data('inAjax', false);
@@ -487,7 +487,7 @@
487487
}
488488
},
489489
// show the parent node of the specified node
490-
showParent ($node) {
490+
showParent: function ($node) {
491491
var that = this;
492492
// just show only one superior level
493493
var $temp = $node.closest('table').closest('tr').siblings().removeClass('hidden');
@@ -504,7 +504,7 @@
504504
});
505505
},
506506
// recursively hide the descendant nodes of the specified node
507-
hideChildren ($node) {
507+
hideChildren: function ($node) {
508508
var that = this;
509509
var $temp = $node.closest('tr').siblings();
510510
if ($temp.last().find('.spinner').length) {
@@ -529,7 +529,7 @@
529529
});
530530
},
531531
// show the children nodes of the specified node
532-
showChildren ($node) {
532+
showChildren: function ($node) {
533533
var that = this;
534534
var $levels = $node.closest('tr').siblings();
535535
var isVerticalDesc = $levels.is('.verticalNodes') ? true : false;
@@ -546,7 +546,7 @@
546546
});
547547
},
548548
// hide the sibling nodes of the specified node
549-
hideSiblings ($node, direction) {
549+
hideSiblings: function ($node, direction) {
550550
var that = this;
551551
var $nodeContainer = $node.closest('table').parent();
552552
if ($nodeContainer.siblings().find('.spinner').length) {
@@ -580,7 +580,7 @@
580580
});
581581
},
582582
// show the sibling nodes of the specified node
583-
showSiblings ($node, direction) {
583+
showSiblings: function ($node, direction) {
584584
var that = this;
585585
// firstly, show the sibling td tags
586586
var $siblings = $();
@@ -619,7 +619,7 @@
619619
});
620620
},
621621
// start up loading status for requesting new nodes
622-
startLoading ($arrow, $node, options) {
622+
startLoading: function ($arrow, $node, options) {
623623
var $chart = $node.closest('.orgchart');
624624
if (typeof $chart.data('inAjax') !== 'undefined' && $chart.data('inAjax') === true) {
625625
return false;
@@ -633,7 +633,7 @@
633633
return true;
634634
},
635635
// terminate loading status for requesting new nodes
636-
endLoading ($arrow, $node, options) {
636+
endLoading: function ($arrow, $node, options) {
637637
var $chart = $node.closest('div.orgchart');
638638
$arrow.removeClass('hidden');
639639
$node.find('.spinner').remove();
@@ -642,15 +642,15 @@
642642
$('.oc-export-btn' + (options.chartClass !== '' ? '.' + options.chartClass : '')).prop('disabled', false);
643643
},
644644
// whether the cursor is hovering over the node
645-
isInAction ($node) {
645+
isInAction: function ($node) {
646646
return $node.children('.edge').attr('class').indexOf('fa-') > -1 ? true : false;
647647
},
648648
//
649-
switchVerticalArrow ($arrow) {
649+
switchVerticalArrow: function ($arrow) {
650650
$arrow.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
651651
},
652652
//
653-
switchHorizontalArrow ($node) {
653+
switchHorizontalArrow: function ($node) {
654654
var opts = $node.closest('.orgchart').data('options');
655655
if (opts.toggleSiblingsResp && (typeof opts.ajaxURL === 'undefined' || $node.closest('.nodes').data('siblingsLoaded'))) {
656656
var $prevSib = $node.closest('table').parent().prev();
@@ -677,13 +677,13 @@
677677
}
678678
},
679679
//
680-
repaint (node) {
680+
repaint: function (node) {
681681
if (node) {
682682
node.style.offsetWidth = node.offsetWidth;
683683
}
684684
},
685685
// create node
686-
createNode(nodeData, level, opts) {
686+
createNode: function (nodeData, level, opts) {
687687
var that = this;
688688
$.each(nodeData.children, function (index, child) {
689689
child.parentId = nodeData.id;
@@ -1038,7 +1038,7 @@
10381038
return dtd.promise();
10391039
},
10401040
// recursively build the tree
1041-
buildHierarchy ($appendTo, nodeData, level, opts, callback) {
1041+
buildHierarchy: function ($appendTo, nodeData, level, opts, callback) {
10421042
var that = this;
10431043
var $nodeWrapper;
10441044
// Construct the node
@@ -1108,14 +1108,14 @@
11081108
}
11091109
},
11101110
// build the child nodes of specific node
1111-
buildChildNode ($appendTo, nodeData, opts, callback) {
1111+
buildChildNode: function ($appendTo, nodeData, opts, callback) {
11121112
var opts = opts || $appendTo.closest('.orgchart').data('options');
11131113
var data = nodeData.children || nodeData.siblings;
11141114
$appendTo.find('td:first').attr('colspan', data.length * 2);
11151115
this.buildHierarchy($appendTo, { 'children': data }, 0, opts, callback);
11161116
},
11171117
// exposed method
1118-
addChildren ($node, data, opts) {
1118+
addChildren: function ($node, data, opts) {
11191119
var that = this;
11201120
var opts = opts || $node.closest('.orgchart').data('options');
11211121
var count = 0;
@@ -1132,7 +1132,7 @@
11321132
});
11331133
},
11341134
// build the parent node of specific node
1135-
buildParentNode ($currentRoot, nodeData, opts, callback) {
1135+
buildParentNode: function ($currentRoot, nodeData, opts, callback) {
11361136
var that = this;
11371137
var $table = $('<table>');
11381138
nodeData.relationship = nodeData.relationship || '001';
@@ -1153,7 +1153,7 @@
11531153
});
11541154
},
11551155
// exposed method
1156-
addParent ($currentRoot, data, opts) {
1156+
addParent: function ($currentRoot, data, opts) {
11571157
var that = this;
11581158
this.buildParentNode($currentRoot, data, opts, function() {
11591159
if (!$currentRoot.children('.topEdge').length) {
@@ -1163,7 +1163,7 @@
11631163
});
11641164
},
11651165
// subsequent processing of build sibling nodes
1166-
complementLine ($oneSibling, siblingCount, existingSibligCount) {
1166+
complementLine: function ($oneSibling, siblingCount, existingSibligCount) {
11671167
var lines = '';
11681168
for (var i = 0; i < existingSibligCount; i++) {
11691169
lines += '<td class="leftLine topLine">&nbsp;</td><td class="rightLine topLine">&nbsp;</td>';
@@ -1172,7 +1172,7 @@
11721172
.end().next().children(':first').after(lines);
11731173
},
11741174
// build the sibling nodes of specific node
1175-
buildSiblingNode ($nodeChart, nodeData, opts, callback) {
1175+
buildSiblingNode: function ($nodeChart, nodeData, opts, callback) {
11761176
var that = this;
11771177
var opts = opts || $nodeChart.closest('.orgchart').data('options');
11781178
var newSiblingCount = nodeData.siblings ? nodeData.siblings.length : nodeData.children.length;
@@ -1216,7 +1216,7 @@
12161216
}
12171217
},
12181218
//
1219-
addSiblings ($node, data, opts) {
1219+
addSiblings: function ($node, data, opts) {
12201220
var that = this;
12211221
this.buildSiblingNode($node.closest('table'), data, opts, function() {
12221222
$node.closest('.nodes').data('siblingsLoaded', true);
@@ -1227,7 +1227,7 @@
12271227
});
12281228
},
12291229
//
1230-
removeNodes ($node) {
1230+
removeNodes: function ($node) {
12311231
var $parent = $node.closest('table').parent();
12321232
var $sibs = $parent.parent().siblings();
12331233
if ($parent.is('td')) {
@@ -1250,4 +1250,4 @@
12501250
return new OrgChart(this, opts).init();
12511251
};
12521252

1253-
}));
1253+
}));

0 commit comments

Comments
 (0)