From f44deb8d801bbb58f2f024c456330e805814f0d9 Mon Sep 17 00:00:00 2001 From: dabeng Date: Thu, 16 Jan 2020 07:38:54 +0800 Subject: [PATCH 1/6] remove the font-awesome dependency --- dist/css/jquery.orgchart.css | 165 ++- dist/css/jquery.orgchart.min.css | 2 +- dist/js/jquery.orgchart.js | 1558 ---------------------------- dist/js/jquery.orgchart.min.js | 2 - dist/js/jquery.orgchart.min.js.map | 1 - gulpfile.js | 2 +- src/css/jquery.orgchart.css | 165 ++- src/js/jquery.orgchart.js | 62 +- test/integration/init-tests.js | 28 +- 9 files changed, 367 insertions(+), 1618 deletions(-) delete mode 100644 dist/js/jquery.orgchart.js delete mode 100644 dist/js/jquery.orgchart.min.js delete mode 100644 dist/js/jquery.orgchart.min.js.map diff --git a/dist/css/jquery.orgchart.css b/dist/css/jquery.orgchart.css index 38a133cf..781f327e 100644 --- a/dist/css/jquery.orgchart.css +++ b/dist/css/jquery.orgchart.css @@ -233,10 +233,19 @@ .orgchart .node .title .symbol { float: left; - margin-top: 4px; + margin-top: 12px; margin-left: 2px; } +.orgchart .node .title .symbol::before { + background-color: #fff; + border-color: rgba(217, 83, 79, 0.8); +} + +.orgchart .node .title .symbol::after { + background-color: #fff; +} + .orgchart .node .content { box-sizing: border-box; padding: 2px; @@ -293,11 +302,11 @@ } .orgchart .node .topEdge { - top: -4px; + top: -2px; } .orgchart .node .bottomEdge { - bottom: -4px; + bottom: -6px; } .orgchart .node .horizontalEdge { @@ -309,11 +318,11 @@ } .orgchart .node .rightEdge { - right: -4px; + right: -6px; } .orgchart .node .leftEdge { - left: -4px; + left: -6px; } .orgchart .node .horizontalEdge::before { @@ -431,4 +440,150 @@ .orgchart.l2r .node.slide-left, .orgchart.r2l .node.slide-left { transform: translateX(-40px); +} + +.oc { + display: inline-block; + position: relative; + +} + +.oc-chevron-up::before { + content: ""; + display: inline-block; + box-sizing: border-box; + vertical-align: text-bottom; + width: 0.625rem; + height: 0.625rem; + border-width: 0 0.2rem 0.2rem 0; + border-style: solid; + border-color: #000; + background: transparent; + transform: rotate(-135deg); +} + +.oc-chevron-right::before { + content: ""; + display: inline-block; + box-sizing: border-box; + width: 0.625rem; + height: 0.625rem; + border-width: 0 0.2rem 0.2rem 0; + border-style: solid; + border-color: #000; + background: transparent; + transform: rotate(-45deg); +} + +.oc-chevron-down::before { + content: ""; + display: inline-block; + box-sizing: border-box; + width: 0.625rem; + height: 0.625rem; + border-width: 0 0.2rem 0.2rem 0; + border-style: solid; + border-color: #000; + background: transparent; + transform: rotate(45deg); +} + +.oc-chevron-left::before { + content: ""; + display: inline-block; + box-sizing: border-box; + width: 0.625rem; + height: 0.625rem; + border-width: 0 0.2rem 0.2rem 0; + border-style: solid; + border-color: #000; + background: transparent; + transform: rotate(135deg); +} + +.oc-leader::before { + position: absolute; + content: ""; + display: inline-block; + box-sizing: border-box; + width: 0.625rem; + height: 0.625rem; + border: 0.0625rem solid #fff; + border-radius: 0.3rem; + background: #000; + top: -0.75rem; + z-index: 1; +} + +.oc-leader::after { + position: absolute; + content: ""; + display: inline-block; + width: 0.875rem; + height: 0.375rem; + border-radius: 0.4rem 0.4rem 0 0; + background: #000; + top: -0.3rem; + left: -0.125rem; +} + +.oc-plus-square::before { + content: ""; + display: inline-block; + vertical-align: text-bottom; + width: 0.875rem; + height: 0.875rem; + background-color: #000; + z-index: -1; +} + +.oc-plus-square::after { + content: "+"; + position: absolute; + font-size: 1rem; + left: 0.125rem; + top: 0.05rem; + color: #fff; +} + +.oc-minus-square::before { + content: ""; + display: inline-block; + vertical-align: text-bottom; + width: 0.875rem; + height: 0.875rem; + background-color: #000; +} + +.oc-minus-square::after { + position: absolute; + content: ""; + display: inline-block; + width: 0.5rem; + height: 0.1rem; + background-color: #fff; + left: 0.1875rem; + top: 0.65rem; +} + +.oc-spinner::before { + content: ""; + vertical-align: text-bottom; + display: inline-block; + box-sizing: border-box; + width: 1rem; + height: 1rem; + border: 0.2rem solid #000; + border-right-color: transparent; + border-radius: 0.625rem; + animation: oc-infinite-spinning .75s linear infinite; +} + +@keyframes oc-infinite-spinning { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } \ No newline at end of file diff --git a/dist/css/jquery.orgchart.min.css b/dist/css/jquery.orgchart.min.css index b1f9866a..e621cc63 100644 --- a/dist/css/jquery.orgchart.min.css +++ b/dist/css/jquery.orgchart.min.css @@ -1 +1 @@ -.orgchart{box-sizing:border-box;display:inline-block;min-height:202px;min-width:202px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:linear-gradient(90deg,rgba(200,0,0,.15) 10%,rgba(0,0,0,0) 10%),linear-gradient(rgba(200,0,0,.15) 10%,rgba(0,0,0,0) 10%);background-size:10px 10px;border:1px dashed transparent;padding:20px}.orgchart .hidden,.orgchart~.hidden{display:none}.orgchart.b2t{transform:rotate(180deg)}.orgchart.l2r{position:absolute;transform:rotate(-90deg) rotateY(180deg);transform-origin:left top}.orgchart .verticalNodes ul{list-style:none;margin:0;padding-left:18px;text-align:left}.orgchart .verticalNodes ul:first-child{margin-top:2px}.orgchart .verticalNodes>td::before{content:'';border:1px solid rgba(217,83,79,.8)}.orgchart .verticalNodes>td>ul>li:first-child::before{box-sizing:border-box;top:-4px;height:30px;width:calc(50% - 2px);border-width:2px 0 0 2px}.orgchart .verticalNodes ul>li{position:relative}.orgchart .verticalNodes ul>li::after,.orgchart .verticalNodes ul>li::before{box-sizing:border-box;content:'';position:absolute;left:-6px;border-color:rgba(217,83,79,.8);border-style:solid;border-width:0 0 2px 2px}.orgchart .verticalNodes ul>li::before{top:-4px;height:30px;width:11px}.orgchart .verticalNodes ul>li::after{top:1px;height:100%}.orgchart .verticalNodes ul>li:first-child::after{box-sizing:border-box;top:24px;width:11px;border-width:2px 0 0 2px}.orgchart .verticalNodes ul>li:last-child::after{box-sizing:border-box;border-width:2px 0 0}.orgchart.r2l{position:absolute;transform:rotate(90deg);transform-origin:left top}.orgchart>.spinner{font-size:100px;margin-top:30px;color:rgba(68,157,68,.8)}.orgchart table{border-spacing:0;border-collapse:separate}.orgchart>table:first-child{margin:20px auto}.orgchart td{text-align:center;vertical-align:top;padding:0}.orgchart .lines:nth-child(3) td{box-sizing:border-box;height:20px}.orgchart .lines .topLine{border-top:2px solid rgba(217,83,79,.8)}.orgchart .lines .rightLine{border-right:1px solid rgba(217,83,79,.8);float:none;border-radius:0}.orgchart .lines .leftLine{border-left:1px solid rgba(217,83,79,.8);float:none;border-radius:0}.orgchart .lines .downLine{background-color:rgba(217,83,79,.8);margin:0 auto;height:20px;width:2px;float:none}.orgchart .node{box-sizing:border-box;display:inline-block;position:relative;margin:0;padding:3px;border:2px dashed transparent;text-align:center}.orgchart.l2r .node,.orgchart.r2l .node{width:50px;height:140px}.orgchart .node>.spinner{position:absolute;top:calc(50% - 15px);left:calc(50% - 15px);vertical-align:middle;font-size:30px;color:rgba(68,157,68,.8)}.orgchart .node:hover{background-color:rgba(238,217,54,.5);transition:.5s;cursor:default;z-index:20}.orgchart .node.focused{background-color:rgba(238,217,54,.5)}.orgchart .ghost-node{position:fixed;left:-10000px;top:-10000px}.orgchart .ghost-node rect{fill:#fff;stroke:#bf0000}.orgchart .node.allowedDrop{border-color:rgba(68,157,68,.9)}.orgchart .node .title{box-sizing:border-box;padding:2px;width:130px;text-align:center;font-size:.75rem;font-weight:700;height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background-color:rgba(217,83,79,.8);color:#fff;border-radius:4px 4px 0 0}.orgchart.b2t .node .title{transform:rotate(-180deg);transform-origin:center bottom}.orgchart.l2r .node .title{transform:rotate(-90deg) translate(-45px,-45px) rotateY(180deg);transform-origin:bottom center}.orgchart.r2l .node .title{transform:rotate(-90deg) translate(-45px,-45px);transform-origin:bottom center}.orgchart .node .title .symbol{float:left;margin-top:4px;margin-left:2px}.orgchart .node .content{box-sizing:border-box;padding:2px;height:20px;font-size:.625rem;border:1px solid rgba(217,83,79,.8);border-radius:0 0 4px 4px;text-align:center;background-color:#fff;color:#333;text-overflow:ellipsis;white-space:nowrap}.orgchart.b2t .node .content{transform:rotate(180deg);transform-origin:center top}.orgchart.l2r .node .content{transform:rotate(-90deg) translate(-45px,-45px) rotateY(180deg);transform-origin:top center;width:130px}.orgchart.r2l .node .content{transform:rotate(-90deg) translate(-45px,-45px);transform-origin:top center;width:130px}.orgchart .node .edge{font-size:15px;position:absolute;color:rgba(68,157,68,.5);cursor:default;transition:.2s}.orgchart.noncollapsable .node .edge{display:none}.orgchart .edge:hover{color:#449d44;cursor:pointer}.orgchart .node .verticalEdge{width:calc(100% - 10px);width:-webkit-calc(100% - 10px);width:-moz-calc(100% - 10px);left:5px}.orgchart .node .topEdge{top:-4px}.orgchart .node .bottomEdge{bottom:-4px}.orgchart .node .horizontalEdge{width:15px;height:calc(100% - 10px);height:-webkit-calc(100% - 10px);height:-moz-calc(100% - 10px);top:5px}.orgchart .node .rightEdge{right:-4px}.orgchart .node .leftEdge{left:-4px}.orgchart .node .horizontalEdge::before{position:absolute;top:calc(50% - 7px)}.orgchart .node .rightEdge::before{right:3px}.orgchart .node .leftEdge::before{left:3px}.orgchart .node .toggleBtn{position:absolute;left:5px;bottom:-2px;color:rgba(68,157,68,.6)}.orgchart .node .toggleBtn:hover{color:rgba(68,157,68,.8)}.oc-export-btn{display:inline-block;position:absolute;right:5px;top:5px;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;touch-action:manipulation;cursor:pointer;user-select:none;color:#fff;background-color:#5cb85c;border:1px solid transparent;border-color:#4cae4c;border-radius:4px}.oc-export-btn[disabled]{cursor:not-allowed;box-shadow:none;opacity:.3}.oc-export-btn:active,.oc-export-btn:focus,.oc-export-btn:hover{background-color:#449d44;border-color:#347a34}.orgchart~.mask{position:absolute;top:0;right:0;bottom:0;left:0;z-index:999;text-align:center;background-color:rgba(0,0,0,.3)}.orgchart~.mask .spinner{position:absolute;top:calc(50% - 54px);left:calc(50% - 54px);color:rgba(255,255,255,.8);font-size:108px}.orgchart .node{transition:transform .3s,opacity .3s}.orgchart .slide-down{opacity:0;transform:translateY(40px)}.orgchart.l2r .node.slide-down,.orgchart.r2l .node.slide-down{transform:translateY(130px)}.orgchart .slide-up{opacity:0;transform:translateY(-40px)}.orgchart.l2r .node.slide-up,.orgchart.r2l .node.slide-up{transform:translateY(-130px)}.orgchart .slide-right{opacity:0;transform:translateX(130px)}.orgchart.l2r .node.slide-right,.orgchart.r2l .node.slide-right{transform:translateX(40px)}.orgchart .slide-left{opacity:0;transform:translateX(-130px)}.orgchart.l2r .node.slide-left,.orgchart.r2l .node.slide-left{transform:translateX(-40px)} \ No newline at end of file +.orgchart{box-sizing:border-box;display:inline-block;min-height:202px;min-width:202px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:linear-gradient(90deg,rgba(200,0,0,.15) 10%,rgba(0,0,0,0) 10%),linear-gradient(rgba(200,0,0,.15) 10%,rgba(0,0,0,0) 10%);background-size:10px 10px;border:1px dashed transparent;padding:20px}.orgchart .hidden,.orgchart~.hidden{display:none}.orgchart.b2t{transform:rotate(180deg)}.orgchart.l2r{position:absolute;transform:rotate(-90deg) rotateY(180deg);transform-origin:left top}.orgchart .verticalNodes ul{list-style:none;margin:0;padding-left:18px;text-align:left}.orgchart .verticalNodes ul:first-child{margin-top:2px}.orgchart .verticalNodes>td::before{content:'';border:1px solid rgba(217,83,79,.8)}.orgchart .verticalNodes>td>ul>li:first-child::before{box-sizing:border-box;top:-4px;height:30px;width:calc(50% - 2px);border-width:2px 0 0 2px}.orgchart .verticalNodes ul>li{position:relative}.orgchart .verticalNodes ul>li::after,.orgchart .verticalNodes ul>li::before{box-sizing:border-box;content:'';position:absolute;left:-6px;border-color:rgba(217,83,79,.8);border-style:solid;border-width:0 0 2px 2px}.orgchart .verticalNodes ul>li::before{top:-4px;height:30px;width:11px}.orgchart .verticalNodes ul>li::after{top:1px;height:100%}.orgchart .verticalNodes ul>li:first-child::after{box-sizing:border-box;top:24px;width:11px;border-width:2px 0 0 2px}.orgchart .verticalNodes ul>li:last-child::after{box-sizing:border-box;border-width:2px 0 0}.orgchart.r2l{position:absolute;transform:rotate(90deg);transform-origin:left top}.orgchart>.spinner{font-size:100px;margin-top:30px;color:rgba(68,157,68,.8)}.orgchart table{border-spacing:0;border-collapse:separate}.orgchart>table:first-child{margin:20px auto}.orgchart td{text-align:center;vertical-align:top;padding:0}.orgchart .lines:nth-child(3) td{box-sizing:border-box;height:20px}.orgchart .lines .topLine{border-top:2px solid rgba(217,83,79,.8)}.orgchart .lines .rightLine{border-right:1px solid rgba(217,83,79,.8);float:none;border-radius:0}.orgchart .lines .leftLine{border-left:1px solid rgba(217,83,79,.8);float:none;border-radius:0}.orgchart .lines .downLine{background-color:rgba(217,83,79,.8);margin:0 auto;height:20px;width:2px;float:none}.orgchart .node{box-sizing:border-box;display:inline-block;position:relative;margin:0;padding:3px;border:2px dashed transparent;text-align:center}.orgchart.l2r .node,.orgchart.r2l .node{width:50px;height:140px}.orgchart .node>.spinner{position:absolute;top:calc(50% - 15px);left:calc(50% - 15px);vertical-align:middle;font-size:30px;color:rgba(68,157,68,.8)}.orgchart .node:hover{background-color:rgba(238,217,54,.5);transition:.5s;cursor:default;z-index:20}.orgchart .node.focused{background-color:rgba(238,217,54,.5)}.orgchart .ghost-node{position:fixed;left:-10000px;top:-10000px}.orgchart .ghost-node rect{fill:#fff;stroke:#bf0000}.orgchart .node.allowedDrop{border-color:rgba(68,157,68,.9)}.orgchart .node .title{box-sizing:border-box;padding:2px;width:130px;text-align:center;font-size:.75rem;font-weight:700;height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background-color:rgba(217,83,79,.8);color:#fff;border-radius:4px 4px 0 0}.orgchart.b2t .node .title{transform:rotate(-180deg);transform-origin:center bottom}.orgchart.l2r .node .title{transform:rotate(-90deg) translate(-45px,-45px) rotateY(180deg);transform-origin:bottom center}.orgchart.r2l .node .title{transform:rotate(-90deg) translate(-45px,-45px);transform-origin:bottom center}.orgchart .node .title .symbol{float:left;margin-top:12px;margin-left:2px}.orgchart .node .title .symbol::before{background-color:#fff;border-color:rgba(217,83,79,.8)}.orgchart .node .title .symbol::after{background-color:#fff}.orgchart .node .content{box-sizing:border-box;padding:2px;height:20px;font-size:.625rem;border:1px solid rgba(217,83,79,.8);border-radius:0 0 4px 4px;text-align:center;background-color:#fff;color:#333;text-overflow:ellipsis;white-space:nowrap}.orgchart.b2t .node .content{transform:rotate(180deg);transform-origin:center top}.orgchart.l2r .node .content{transform:rotate(-90deg) translate(-45px,-45px) rotateY(180deg);transform-origin:top center;width:130px}.orgchart.r2l .node .content{transform:rotate(-90deg) translate(-45px,-45px);transform-origin:top center;width:130px}.orgchart .node .edge{font-size:15px;position:absolute;color:rgba(68,157,68,.5);cursor:default;transition:.2s}.orgchart.noncollapsable .node .edge{display:none}.orgchart .edge:hover{color:#449d44;cursor:pointer}.orgchart .node .verticalEdge{width:calc(100% - 10px);width:-webkit-calc(100% - 10px);width:-moz-calc(100% - 10px);left:5px}.orgchart .node .topEdge{top:-2px}.orgchart .node .bottomEdge{bottom:-6px}.orgchart .node .horizontalEdge{width:15px;height:calc(100% - 10px);height:-webkit-calc(100% - 10px);height:-moz-calc(100% - 10px);top:5px}.orgchart .node .rightEdge{right:-6px}.orgchart .node .leftEdge{left:-6px}.orgchart .node .horizontalEdge::before{position:absolute;top:calc(50% - 7px)}.orgchart .node .rightEdge::before{right:3px}.orgchart .node .leftEdge::before{left:3px}.orgchart .node .toggleBtn{position:absolute;left:5px;bottom:-2px;color:rgba(68,157,68,.6)}.orgchart .node .toggleBtn:hover{color:rgba(68,157,68,.8)}.oc-export-btn{display:inline-block;position:absolute;right:5px;top:5px;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;touch-action:manipulation;cursor:pointer;user-select:none;color:#fff;background-color:#5cb85c;border:1px solid transparent;border-color:#4cae4c;border-radius:4px}.oc-export-btn[disabled]{cursor:not-allowed;box-shadow:none;opacity:.3}.oc-export-btn:active,.oc-export-btn:focus,.oc-export-btn:hover{background-color:#449d44;border-color:#347a34}.orgchart~.mask{position:absolute;top:0;right:0;bottom:0;left:0;z-index:999;text-align:center;background-color:rgba(0,0,0,.3)}.orgchart~.mask .spinner{position:absolute;top:calc(50% - 54px);left:calc(50% - 54px);color:rgba(255,255,255,.8);font-size:108px}.orgchart .node{transition:transform .3s,opacity .3s}.orgchart .slide-down{opacity:0;transform:translateY(40px)}.orgchart.l2r .node.slide-down,.orgchart.r2l .node.slide-down{transform:translateY(130px)}.orgchart .slide-up{opacity:0;transform:translateY(-40px)}.orgchart.l2r .node.slide-up,.orgchart.r2l .node.slide-up{transform:translateY(-130px)}.orgchart .slide-right{opacity:0;transform:translateX(130px)}.orgchart.l2r .node.slide-right,.orgchart.r2l .node.slide-right{transform:translateX(40px)}.orgchart .slide-left{opacity:0;transform:translateX(-130px)}.orgchart.l2r .node.slide-left,.orgchart.r2l .node.slide-left{transform:translateX(-40px)}.oc{display:inline-block;position:relative}.oc-chevron-up::before{content:"";display:inline-block;box-sizing:border-box;vertical-align:text-bottom;width:.625rem;height:.625rem;border-width:0 .2rem .2rem 0;border-style:solid;border-color:#000;background:0 0;transform:rotate(-135deg)}.oc-chevron-right::before{content:"";display:inline-block;box-sizing:border-box;width:.625rem;height:.625rem;border-width:0 .2rem .2rem 0;border-style:solid;border-color:#000;background:0 0;transform:rotate(-45deg)}.oc-chevron-down::before{content:"";display:inline-block;box-sizing:border-box;width:.625rem;height:.625rem;border-width:0 .2rem .2rem 0;border-style:solid;border-color:#000;background:0 0;transform:rotate(45deg)}.oc-chevron-left::before{content:"";display:inline-block;box-sizing:border-box;width:.625rem;height:.625rem;border-width:0 .2rem .2rem 0;border-style:solid;border-color:#000;background:0 0;transform:rotate(135deg)}.oc-leader::before{position:absolute;content:"";display:inline-block;box-sizing:border-box;width:.625rem;height:.625rem;border:.0625rem solid #fff;border-radius:.3rem;background:#000;top:-.75rem;z-index:1}.oc-leader::after{position:absolute;content:"";display:inline-block;width:.875rem;height:.375rem;border-radius:.4rem .4rem 0 0;background:#000;top:-.3rem;left:-.125rem}.oc-plus-square::before{content:"";display:inline-block;vertical-align:text-bottom;width:.875rem;height:.875rem;background-color:#000;z-index:-1}.oc-plus-square::after{content:"+";position:absolute;font-size:1rem;left:.125rem;top:.05rem;color:#fff}.oc-minus-square::before{content:"";display:inline-block;vertical-align:text-bottom;width:.875rem;height:.875rem;background-color:#000}.oc-minus-square::after{position:absolute;content:"";display:inline-block;width:.5rem;height:.1rem;background-color:#fff;left:.1875rem;top:.65rem}.oc-spinner::before{content:"";vertical-align:text-bottom;display:inline-block;box-sizing:border-box;width:1rem;height:1rem;border:.2rem solid #000;border-right-color:transparent;border-radius:.625rem;animation:oc-infinite-spinning .75s linear infinite}@keyframes oc-infinite-spinning{from{transform:rotate(0)}to{transform:rotate(360deg)}} \ No newline at end of file diff --git a/dist/js/jquery.orgchart.js b/dist/js/jquery.orgchart.js deleted file mode 100644 index 0790d8be..00000000 --- a/dist/js/jquery.orgchart.js +++ /dev/null @@ -1,1558 +0,0 @@ -/* - * jQuery OrgChart Plugin - * https://github.com/dabeng/OrgChart - * - * Copyright 2016, dabeng - * https://github.com/dabeng - * - * Licensed under the MIT license: - * http://www.opensource.org/licenses/MIT - */ -'use strict'; - -(function (factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - factory(require('jquery'), window, document); - } else { - factory(jQuery, window, document); - } -}(function ($, window, document, undefined) { - var OrgChart = function (elem, opts) { - this.$chartContainer = $(elem); - this.opts = opts; - this.defaultOptions = { - 'nodeTitle': 'name', - 'nodeId': 'id', - 'toggleSiblingsResp': false, - 'visibleLevel': 999, - 'chartClass': '', - 'exportButton': false, - 'exportFilename': 'OrgChart', - 'exportFileextension': 'png', - 'parentNodeSymbol': 'fa-users', - 'draggable': false, - 'direction': 't2b', - 'pan': false, - 'zoom': false, - 'zoominLimit': 7, - 'zoomoutLimit': 0.5 - }; - }; - // - OrgChart.prototype = { - // - init: function (opts) { - var that = this; - this.options = $.extend({}, this.defaultOptions, this.opts, opts); - // build the org-chart - var $chartContainer = this.$chartContainer; - if (this.$chart) { - this.$chart.remove(); - } - var data = this.options.data; - var $chart = this.$chart = $('
', { - 'data': { 'options': this.options }, - 'class': 'orgchart' + (this.options.chartClass !== '' ? ' ' + this.options.chartClass : '') + (this.options.direction !== 't2b' ? ' ' + this.options.direction : ''), - 'click': function(event) { - if (!$(event.target).closest('.node').length) { - $chart.find('.node.focused').removeClass('focused'); - } - } - }); - if (typeof MutationObserver !== 'undefined') { - this.triggerInitEvent(); - } - if ($.type(data) === 'object') { - if (data instanceof $) { // ul datasource - this.buildHierarchy($chart, this.buildJsonDS(data.children()), 0, this.options); - } else { // local json datasource - this.buildHierarchy($chart, this.options.ajaxURL ? data : this.attachRel(data, '00')); - } - } else { - $chart.append(''); - $.ajax({ - 'url': data, - 'dataType': 'json' - }) - .done(function(data, textStatus, jqXHR) { - that.buildHierarchy($chart, that.options.ajaxURL ? data : that.attachRel(data, '00'), 0, that.options); - }) - .fail(function(jqXHR, textStatus, errorThrown) { - console.log(errorThrown); - }) - .always(function() { - $chart.children('.spinner').remove(); - }); - } - $chartContainer.append($chart); - - // append the export button - if (this.options.exportButton && !$chartContainer.find('.oc-export-btn').length) { - this.attachExportButton(); - } - - if (this.options.pan) { - this.bindPan(); - } - - if (this.options.zoom) { - this.bindZoom(); - } - - return this; - }, - // - triggerInitEvent: function () { - var that = this; - var mo = new MutationObserver(function (mutations) { - mo.disconnect(); - initTime: - for (var i = 0; i < mutations.length; i++) { - for (var j = 0; j < mutations[i].addedNodes.length; j++) { - if (mutations[i].addedNodes[j].classList.contains('orgchart')) { - if (that.options.initCompleted && typeof that.options.initCompleted === 'function') { - that.options.initCompleted(that.$chart); - } - var initEvent = $.Event('init.orgchart'); - that.$chart.trigger(initEvent); - break initTime; - } - } - } - }); - mo.observe(this.$chartContainer[0], { childList: true }); - }, - // - attachExportButton: function () { - var that = this; - var $exportBtn = $('
', oc = {}; afterEach(function () { @@ -105,10 +105,10 @@ describe('orgchart -- integration tests', function () { }; it('verticalLevel=2 and visibleLevel=1', function () { - var fragment = '
Lao Lao
' + - '