From 67ccafac44ff3b0d4f35811e174f2bff1c4a8f2b Mon Sep 17 00:00:00 2001 From: przemyslaw_lis Date: Thu, 8 Feb 2024 17:03:54 +0100 Subject: [PATCH] added src for jsPlumb --- .../Resources/public/angularjs/.gitignore | 3 +- .../Resources/public/angularjs/bower.json | 1 - .../bower_components/jsPlumb/.bower.json | 48 + .../bower_components/jsPlumb/bower.json | 39 + .../jsPlumb/css/external/cssgrids-min.css | 2 + .../jsPlumb/css/external/prettify-min.css | 1 + .../jsPlumb/css/ico-jsplumb.eot | Bin 0 -> 5328 bytes .../jsPlumb/css/ico-jsplumb.svg | 19 + .../jsPlumb/css/ico-jsplumb.ttf | Bin 0 -> 5164 bytes .../jsPlumb/css/ico-jsplumb.woff | Bin 0 -> 5240 bytes .../jsPlumb/css/jsPlumbToolkit-defaults.css | 553 + .../jsPlumb/css/jsPlumbToolkit-demo.css | 334 + .../jsPlumb/css/jsplumb-doc.css | 781 + .../bower_components/jsPlumb/css/jsplumb.css | 403 + .../bower_components/jsPlumb/css/main.css | 1247 ++ .../jsPlumb/dist/css/demo-all.css | 679 + .../dist/css/external/cssgrids-min.css | 2 + .../dist/css/external/prettify-min.css | 1 + .../jsPlumb/dist/css/gollum-template.css | 749 + .../jsPlumb/dist/css/ico-jsplumb.eot | Bin 0 -> 5328 bytes .../jsPlumb/dist/css/ico-jsplumb.svg | 19 + .../jsPlumb/dist/css/ico-jsplumb.ttf | Bin 0 -> 5164 bytes .../jsPlumb/dist/css/ico-jsplumb.woff | Bin 0 -> 5240 bytes .../dist/css/jsPlumbToolkit-defaults.css | 553 + .../jsPlumb/dist/css/jsPlumbToolkit-demo.css | 334 + .../jsPlumb/dist/css/jsplumb-doc.css | 781 + .../jsPlumb/dist/css/jsplumb.css | 403 + .../jsPlumb/dist/css/main.css | 1247 ++ .../jsPlumb/dist/external/jquery-1.9.0-min.js | 4 + .../dist/external/jquery-ui-1.9.2.min.js | 5 + .../jquery.ui.touch-punch-0.2.2.min.js | 11 + .../jsPlumb/dist/js/demo-list.js | 67 + .../jsPlumb/dist/js/dom.jsPlumb-1.7.6-min.js | 6 + .../jsPlumb/dist/js/dom.jsPlumb-1.7.6.js | 12729 ++++++++++++++++ .../dist/js/jquery.jsPlumb-1.7.6-min.js | 6 + .../jsPlumb/dist/js/jquery.jsPlumb-1.7.6.js | 11905 +++++++++++++++ .../jsPlumb/external/jquery-1.9.0-min.js | 4 + .../jsPlumb/external/jquery-ui-1.9.2.min.js | 5 + .../jquery.ui.touch-punch-0.2.2.min.js | 11 + .../jsPlumb/jsPlumb-GPLv2-LICENSE.txt | 278 + .../jsPlumb/jsPlumb-MIT-LICENSE.txt | 20 + .../bower_components/jsPlumb/logo-bw.png | Bin 0 -> 2486 bytes 42 files changed, 33248 insertions(+), 2 deletions(-) create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/.bower.json create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/bower.json create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/cssgrids-min.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/prettify-min.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.eot create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.svg create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.ttf create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.woff create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-defaults.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-demo.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb-doc.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/main.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/demo-all.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/cssgrids-min.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/prettify-min.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/gollum-template.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.eot create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.svg create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.ttf create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.woff create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-defaults.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-demo.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb-doc.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/main.css create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery-1.9.0-min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery-ui-1.9.2.min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery.ui.touch-punch-0.2.2.min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/demo-list.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6-min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/jquery.jsPlumb-1.7.6-min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/jquery.jsPlumb-1.7.6.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery-1.9.0-min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery-ui-1.9.2.min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery.ui.touch-punch-0.2.2.min.js create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-GPLv2-LICENSE.txt create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-MIT-LICENSE.txt create mode 100644 src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/logo-bw.png diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/.gitignore b/src/Concerto/PanelBundle/Resources/public/angularjs/.gitignore index b702acc68..678573b8a 100644 --- a/src/Concerto/PanelBundle/Resources/public/angularjs/.gitignore +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/.gitignore @@ -1,7 +1,8 @@ logs/* !.gitkeep node_modules/ -bower_components/ +bower_components/* +!bower_components/jsPlumb tmp .DS_Store .idea \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower.json b/src/Concerto/PanelBundle/Resources/public/angularjs/bower.json index a7b719e83..9ac306907 100644 --- a/src/Concerto/PanelBundle/Resources/public/angularjs/bower.json +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower.json @@ -26,7 +26,6 @@ "angular-ui-sortable": "*", "angular-breadcrumb": "0.4.x", "angular-ui-router": "0.4.x", - "jsPlumb": "1.7.6", "ng-context-menu-concerto": "1.0.x", "jquery-mousewheel": "3.1.x", "pdfmake": "0.1.33", diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/.bower.json b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/.bower.json new file mode 100644 index 000000000..7671bd12d --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/.bower.json @@ -0,0 +1,48 @@ +{ + "name": "jsPlumb", + "version": "1.7.6", + "ignore": [ + "demo", + "dist/apidocs", + "dist/demo", + "dist/doc", + "dist/lib", + "dist/tests", + "dist/index.html", + "doc", + "img", + "lib", + "jekyll", + "node_modules", + "src", + "tests", + "Gruntfile.js", + "README.md", + "changelog.txt", + "index.html", + "build-support.js", + "package.json", + "todo.txt", + "**/.*", + "bower_components", + "test" + ], + "main": [ + "dist/js/dom.jsPlumb-1.7.6.js" + ], + "homepage": "http://jsplumbtoolkit.com", + "authors": [ + "jsPlumb " + ], + "description": "Visual connectivity for webapps", + "license": "MIT/GPL2", + "_release": "1.7.6", + "_resolution": { + "type": "version", + "tag": "1.7.6", + "commit": "a6d541bccef174c5d39cb535f71f5113097e99ab" + }, + "_source": "https://github.com/sporritt/jsPlumb.git", + "_target": "1.7.6", + "_originalSource": "jsPlumb" +} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/bower.json b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/bower.json new file mode 100644 index 000000000..4b695d9eb --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/bower.json @@ -0,0 +1,39 @@ +{ + "name": "jsPlumb", + "version": "1.7.6", + "ignore": [ + "demo", + "dist/apidocs", + "dist/demo", + "dist/doc", + "dist/lib", + "dist/tests", + "dist/index.html", + "doc", + "img", + "lib", + "jekyll", + "node_modules", + "src", + "tests", + "Gruntfile.js", + "README.md", + "changelog.txt", + "index.html", + "build-support.js", + "package.json", + "todo.txt", + "**/.*", + "bower_components", + "test" + ], + "main": [ + "dist/js/dom.jsPlumb-1.7.6.js" + ], + "homepage": "http://jsplumbtoolkit.com", + "authors": [ + "jsPlumb " + ], + "description": "Visual connectivity for webapps", + "license": "MIT/GPL2" +} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/cssgrids-min.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/cssgrids-min.css new file mode 100644 index 000000000..e9a991a8a --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/cssgrids-min.css @@ -0,0 +1,2 @@ +/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */ +.yui3-g{letter-spacing:-0.31em;*letter-spacing:normal;*word-spacing:-0.43em;text-rendering:optimizespeed}.opera-only :-o-prefocus,.yui3-g{word-spacing:-0.43em}.yui3-u{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.yui3-u-1,.yui3-u-1-2,.yui3-u-1-3,.yui3-u-2-3,.yui3-u-1-4,.yui3-u-3-4,.yui3-u-1-5,.yui3-u-2-5,.yui3-u-3-5,.yui3-u-4-5,.yui3-u-1-6,.yui3-u-5-6,.yui3-u-1-8,.yui3-u-3-8,.yui3-u-5-8,.yui3-u-7-8,.yui3-u-1-12,.yui3-u-5-12,.yui3-u-7-12,.yui3-u-11-12,.yui3-u-1-24,.yui3-u-5-24,.yui3-u-7-24,.yui3-u-11-24,.yui3-u-13-24,.yui3-u-17-24,.yui3-u-19-24,.yui3-u-23-24{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.yui3-u-1{display:block}.yui3-u-1-2{width:50%}.yui3-u-1-3{width:33.33333%}.yui3-u-2-3{width:66.66666%}.yui3-u-1-4{width:25%}.yui3-u-3-4{width:75%}.yui3-u-1-5{width:20%}.yui3-u-2-5{width:40%}.yui3-u-3-5{width:60%}.yui3-u-4-5{width:80%}.yui3-u-1-6{width:16.656%}.yui3-u-5-6{width:83.33%}.yui3-u-1-8{width:12.5%}.yui3-u-3-8{width:37.5%}.yui3-u-5-8{width:62.5%}.yui3-u-7-8{width:87.5%}.yui3-u-1-12{width:8.3333%}.yui3-u-5-12{width:41.6666%}.yui3-u-7-12{width:58.3333%}.yui3-u-11-12{width:91.6666%}.yui3-u-1-24{width:4.1666%}.yui3-u-5-24{width:20.8333%}.yui3-u-7-24{width:29.1666%}.yui3-u-11-24{width:45.8333%}.yui3-u-13-24{width:54.1666%}.yui3-u-17-24{width:70.8333%}.yui3-u-19-24{width:79.1666%}.yui3-u-23-24{width:95.8333%}#yui3-css-stamp.cssgrids{display:none} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/prettify-min.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/prettify-min.css new file mode 100644 index 000000000..d44b3a228 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/external/prettify-min.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.eot b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.eot new file mode 100644 index 0000000000000000000000000000000000000000..a298d34b6af12cfd1ea14da46a74117e45907f34 GIT binary patch literal 5328 zcmbtYU2Gjk6`tAIo!Q;{vwQ!4e0_a?oNFg`li1hJO_Q{Ckdg+GwxKO)t3EVtk|vGn zIBEh)X{FvuAb~)okRU-HfCq&7fJ)&3RVr0o#7iXvMW|0aqzLFkkl+C!KuWIp&dgqW zow_YQqy0H^=FFM1=gj$LcHYS|HjSGzi)}8Py~v4k^w?%T$(pkF$hEOs+Zao;C)i20 z!j^Hbu=5Z|v-{X-c7}bHJ;|2XQ{WWYad4hu7a>bB4K~AevfWzt*4|*!fC<)Tg6+Qd z{#~;{R_z1lXSh$CTwc0x{ZsG10HGS{51d)LcmeMab$YvJo_zZ8f1N-06Vxw*-9LMJ z>6HD({2|6N|3v$qvtX#7i(fI8rQyfVE?>IbVf>G%KY;q&lPf2evagg+q5dV*Ys*WQ zFR%jtChFfuy>WhN`SgR8AN&RNUto+w7gjD_f}JS&B(*bPGyWoT7_+`@{Sut7nK%D4 z>vE6eVui!(&1I3X>!Da(TV;y^HyVe|C%Fbabl_;jJjSKgJhQcAlDTNZ@T~E^ydJLI zTw5b?)Y$bv*ZA5Ws&?T<)K53+2WK3zf!1cYm>j*^_0SvRe+-YawN>jHtgbTVv@`Ab z-u&F2-kp3uFSJ`yrTHlDs&>X&TBc_IlJ>SrmCCT ztxg+~XvMY80aJ6jvt;)C0X{$1nK#4PEIk?qV_~M2OlD=+2s7<$x}D4KC`}(7tu;Bf z_`zp-y%Q5MVGBEzOtlKBN-|kYREwoM$5mRYKsmnSc#hwxR2Nz!cQl%JZIda9t9^8G z`|;_oUpspA9v;?G=~BWPDBrdf_bNfq%z2?yz6dI==QV4iN2g^{;u5XV+C96Il~lTx z9_f~foirD=@ExmjXk?_LEWu3~o6qHoywFT0Qrs%GlgZTb@#F8F6-wCBPE^vVI_4lE zyS55Hud*_qfTwl1jQ=8M%yr1qQ3#Cl;T`ZMjDtSz2|upOqt`Cpp&1cfu`ntV!1X6$ z(rLAKP>^RJj~MD+QEW{BKl-WVNBO$O&4ihvG@~|O-B~?(KA^ggkJ)XpbFUvdeC*ia zL$9CPp!n{fk;#nb5o`*%bb^GUkU37$(Xn%!gzfmY9?RlW7D&HJQk}Ued8qoTTUG6Uk~|J}5s~C`=WLQ-#80 z{-dPD>Mb78zPa&^(XBt#x|=FlG8C!9g~j0jC$iUe9ov@<8K~UA^)jB9_wwUmrk)}% zw6eMv^2~+l%7*u-NZU5vgg4+yXyrWH3d2S^UC)H$IX~|~6Z9!$9ljp{fV>j$5k|Ib zI56s^vWdhoypX1A135GeG@roLL$b~m zfmhvlDq{&cz;VrMPi`b{96=1m83c$>N~1)3CKm&M?mphr(TPLF2Ci+!6+*_?wKdG_ zncW04aqJ_=OVbtqR{DCgip9*rH`6K>yJ&jEVah0JN%GUWO+BS&jZq)h`r*!a_5eT4 zALdUy!XLl!hREFbtH=ya>jbt0rHUnmtpGJr5T*f@bY|)NLULJrxFpqsDCZ&uI-As& zmM}O-xjR(37pgQO5Sm6Rfo#av^^`@f>(POAgaMvo1My69OF?3!4-laN(L%~&@uSPe z!c4e~4ocL>2=fIPN5c_4wLuXy49B6)F5u&qar7_*WdIa22H=AXaRbad0v#aE$SUBT zKGP$aP}eU^rG$$s)OhQfe)U_3{RN>Er2;6LqH z?OTiQ9K6fFf_8K;zA~`4RR|yg!NKqJ0%HjbpbK8>YUvX#m_bWVJPeSbxM?8Ar~7g} z4ESWy6pg2yqzL9ign_g~4H${6*XC>2(E3Qtx+|HWjX?1AbVC#plA;YIT9D=iR2e}V zQNXN`xjxj!939OvjACXPd>;!6Fv()iWB=V3kK#vW85pgz#_Tgq!i;_tY)?gCZEzx< z;@AO4_`-F9nvA@I>wU5j9OdG0x{=FG77N?6xn??5RIWStsZ0placq&0{7+cAh=%ia zW0A&!9=cxE_j9fnD3t)~oU7bIdhonbGW2Qth$2JJ52bX)NLcZ7sf6KpAwOMy391rm z@Ez((Y7>e-rsFoUCMT4h{X!LxB7i^O9g2{Srug5S$%Rs}JhNlRQ;R0CkhcrV+b4JFl=ixv&QecU zrCzPp&1H+&dRqKFY)l0~izgkA-b5YW#6)|<#9Nb))SWzOJ-7XEwL01!tKYY)vAGn{JFb}r8_n(3V}icj#SHdb{39h5cBM{Iy4a&BnMRGWSHc_uOWVr5 zMzDv^BcNCKeq72Pe2WKD)$0Dn&im?PZEkHFs~@{fLpMQ$C9TfEN@Yw~xkf6LSD3g# z#g{*VPN?<;T#Mf(P+7u7b(>_KIJvUCvU2{Gv%k&few#Y5!}{d!5^LaO@HEZ<={#_WUBdem bc#pBC@%*GdNxVBcN!&?})Msl%Y+e2h=t331 literal 0 HcmV?d00001 diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.svg b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.svg new file mode 100644 index 000000000..fbee15942 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.svg @@ -0,0 +1,19 @@ + + + +Generated by IcoMoon + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.ttf b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/ico-jsplumb.ttf new file mode 100644 index 0000000000000000000000000000000000000000..9ed2fe64a52cdd3f01faf6efb61f7c56fa106fb0 GIT binary patch literal 5164 zcmbtYU2Gjk6`r5nncclVd;fpz>+AdDTsyIw*uHjdo20dal(dNShqR=v`p~$En;+G2 z)C82$N_8cWK%hcNkf0C1144a3rSO0%m8ve{B@%)n)F&QV1oR3AV;0o4)t{J+om>?*r#&_#Z#9vUL91r`~&>Fh)IrqLcd zy>jtVhw(q6{Q%l?PpqC;%Dr4UiT0P!uB|LxI?syyn`nO@?Z&yKmE{MkKllsUzrY-a z&aYm$2s=>vEsuVui!(?PZa%YZ*5_)J;a#X&bH@!^K*N9ckunZ*lsDE<|DkT+gY)=zP6UF zls~=j{KJ)+*7CdguPzGq3O}{?SiRnOCGh>B>_b29lVLP>!(s9`dm4>2hZ21Uht8g* zck}Vx+$t{?O2s-a8_u}t1*g2pnJ&!Ors-<8I&Daz7j=^Zrr~sF$?W+9e15JoZ>Muu zdL$E$X0o+pGN&?)Otzg%xATQv<*6ehwI=6+AAGvkJ3g)wj&xGVRI8Y(CX=PaP^o;! zm`*DlYBz9Q-wis|p@r7)?TzN0J5)-cwvSBgJT~>hJ4cS(!!xy1x||Sw9XO8Wel-l6 zc|W6cAj7KX`_0yW3T5LoBK zJK&952YuWXe%zGDs6D(xD6~ zgk7SvqPExWtXVuCP+cs<>=x|oYljZsci-VdubthZ_;lFFX2%K$HicZdVM0^LTsP^O z*tu@PaRbNo9oKUlC8ZL=5fm|{bRI&SYn_t5Qfc4I`9UEF>zS~T$&6;gdZ<#Gv_J(7 zb|k7Rgy2GIkGm?BhZ2MyEJsLJO6^GBabSxvMc#n#59P3SZ1FnQt&U39y zrjbt9vzf7cQ1GD%`ZTf*&yN5=UQ750GYba}j7I5PA~77^Lnb-$e{sNvxeM4l$g>)2 zvVH6kEYbksqFKd}R8~H4plhWSuPmue$M6#ujvdqs|*oZY6IVK`h2u1c*?| zphSBn9|M5yKHf9Yi9^K}u5HH^LdICVIn3;x-3Bvp>?6oaQ;k0>J-ywM{LCZ#@$0Y4?DfCOY=7A#u#l80LPAqL|0=_1Pz0EXs`$P zc;7r`8iFzaik$=SL56rC)*XQk5NCKDa8HlvkWnx^^4y2Gw?{UdB|I&`gZ$uvG~P`vLrC9BX_l`0oDO{440k0P8CYdp8RKL?GDzo!MZ7 z!~~|`wyBmLQNRq^dg5V#48_d=IUYSwn_<8slcs1s<0MTmpFtQ%OVojx$a-VGaSiQ{ z)NO{63C0Kn-z+yoA)zSRP+|mWT|ku;bPxrs8kJvz+L)uGRfbvYDueH1K>;QS_8iXN zYw}Tcl&t`xP1e|RrcIcUkAm&V2&^qm#8Vt6;0Ry1Nl=@Sw{vq&wt^#E9!@v%`H50- zXD;7Nr%KxM`ae|(>A0>V6N>){TNlxA-ZVC8Z0H%!&jmr=^Fyr@V4d}}S4{Vx(^_Q$ zIzFPPj2~o_^5k%)>YGx{WX6hxsmhB`mC*g~&`?sF(EKq&znCfqiJa#pEkEgbxkOM- zz4>Nks!$xu-1uR#sBtLubTRq47zzJr)`I_jFBjMpTVkJQud?5;YaH(^aZg&%85Jc1 z$`-S+?a{HD&fmQq@x3gDXT@@RzGEbefOTjTobhtZmC-h7x6kN+7r7tkYOBG@g|rcRQV>o)qO?t=7%wN;rB7{w@xtlAy&`u1|NOj%{P2 zKVsr;NJyGNz7o&wJUlcs(jKiJ-P71VG&GqODyW87YYOM88s$6c%!7^QPVtzeXZNsz zeGl(QNsUvfn^YdoXj-MwqU=>LhrrSi`Bw?{@OT9D8qbfao&L9YI5{-5zp?vheYDNR zj?wykw;1Rqh!9G24pyt9Qsf({R6%3mhSfm*2s)uUkZ>(tn?Ql_pYm{~;Tvzt4fzIp zg0UU9@)@7wg5|h(4$EW@t@2KbkYdm^V1)Drr3$pT23-TjCLtWnhVEM3*#sIkJPZG0XCm5VCA6%(!VI$! z9k4leg1+83J~*V)(pIOXtxii@otCybEv+#2wrH%?c?Nn{vDdBQca9xn%j`*Zft@j} z2Ag5K*)&=)nKLI=S5{ZgZD(S;TxO@(XOR|5P_S(PJ8YC)WDQ6xV-lKTiCx6~BzTXp Xr*QqGnd0uqjNRl&^KFfYo0oqBE;ctZIadwB5o0BTH2DP>O^9Gv}Mx{lYy93yd?Q;zgD+|C98*QM%{;UDJ$l4{gV(gn7O1#PZ@3 z;GIVO0V-EN{r>Z(7S9v!r>K)GmFU#tPdx_S&q1zI`PaFFKR&&*c#^UFC(*u_iu1Geubd#c-=bcll7D63DH|GNF>e`Yh>M?IN1 z)NM`kj9rc7+WH!smndj7K8=MM=3n4RmWp^%YmqrdG7S$2(3~~iS68F;>+9=AzVSZ0 z8k!nk|HGhDx)%2{jpo4_hisUz1smPljOk7LAH(BpeNDWJQ4ccawsY;-?(Cku-8=Yx zUTU|L&hlYCquV(#zqY!X8>oC{?)irXYFf+h6}~nv*sJ{1-lO$;%o4i24NOYh`kJGoU}Dwa!iUNM|8(+W;ygR{FhWviyC-RiUMOa3spr(&@a48d0vD&$bK29hJ$$!?h;of**Xk+dV#} zQjT;o=}fDXsixEA)L^-C$EeOK9cnjlUEd8l)xo*e(Cv-po!eAKA-4~YZ$CQujdu?p zKEk6~CR<5~o(>#GbH5sf&4M2(9mufi`F^uDe0Wl&6|!s%*N*H?S2NjKc4($j?qs=i zWZ;UNma9%I`$w|c6|+gUSk7% z44yX2W&IaBV^4=X9WQ}(KD-0on03&{J>kaoLEL}7jWZ=HR-h4J7|%o zAdfXPz2ddC3wZOVkssz88n+U5i_(tTnrEiX=J}B7QZX@Z!Op&ZXyM*_7Y@CCc9Y_} z!$vMQTEt@0k}Ee%X<9PZO}l38TsP&of#dp)>p6~+QVHP*S}~<`0YaQ>osqs$S>Mb1 zK`{vHQP_y0ktnQ(Dx*mYR8VI}BD+EeE~NIjt1<;B!P0}}23(Oj+(hJ)!;(eu-;gXE@tub4^?hIT^5@lt7`T%IVE#)~(TmTMpI zi1E#}x2rHqAu7p<3^Q|aqWV7{LG+GFXJ~Tm}M$}>cSOCat2_M0-aNxkWm(HhB zL*Wq`k|X~Y2Yi&ffX)3ltFb2A#~wzkHEpov3_Q&=E%xN%cx&foa)1H9)vzc5y6~lMh@!)}E^j3=Iub=Gx-rO}aO^x;md3@cba~y@AXoCD`gFXLU8G zX0wf4eNVAak!wcF4K!X`<7+)Y_-4mVss{|;)V|L6+C75TleqiS|?>0RS`mc-O2>5-K)vZ7Z%2GA8nkVP^027MMw5 zA3Zxah(Kr>s|2zkUN=G(v2Lsb>j(pU*8$?$;8v2vNFN}=0HQ$1Dft;6LM7<6FUZ_TJ%N zMLRlJUs>3@(Goxeg1z6F14c*~FbRJfYH5lB!=R%lxeSn@bu&PYsRwFf88Bti6x%aS z(ggDnmVvay4X{L`H^Vosq4SZNO;;L%83Y#JY&WbzO3`XVi4mlI0aaGe!75?+JG6p8Ej9)U~O?C8REDB$N0ic zfZB+>ott~I6&&VrA=@Yv#>=Jc`9d?BDQnN`{Y0gt z9|Q%@54BE#b=K2fDcgHaYZV1_eMC}`A4E!daww|$CRL+ov{alNcoC{ny7yh`N@`P@ zKWgX~GnF8f_q?>_r#&y93M!c^R|Y1FrP1j657H%#OR1+z>CY!f_)oJI{P%k~$0pe# z`yzXd{hD3ncxOp^(t^&2C>v0=n2lqPuHAJ1?ruw-WeGehRob&1BVh!rL*vC6t0Y_* zACva@j4ybx`+=@D8*D7$V8QEyeS@$-Iuiq`S@}6m=gSSx;FM@8M!930i#R`t(oK(Jf50$4vYi5|XBquf((47X}B1+avY+b~W}74o+l+3aTOY zn!>%RM)8h3^3y4r6N7{M8$0i-kF>eiHd4R$76aV`5kiU1!D@9xib5lkDQaxouo|czLMK!Q z60XH-6DTnLQy%U#eEo`Cmv6Gi8QXR%pYk~#*p7SmV4LisUEXOCQuLepjF8@-RFO7U zzp2j{;b4}hY3KKw`iwc=S3M^G*?Wt3?V0AtOLPpuJxcW6>b*thFOD+LxkUb=D>d(e zYtFxL zGtj$&vu*{ybL=QvVo$R3?2M^3*c98zcB7V%IdfuVd1d9?Rwjqf1zS3> p1*7Z&Yd~TNM##h>yMX_b;62Ko!t+zc#NF{Qc9J9MOV>@(zX5o735x&# literal 0 HcmV?d00001 diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-defaults.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-defaults.css new file mode 100644 index 000000000..1fb967b39 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-defaults.css @@ -0,0 +1,553 @@ +/* + Default styles for jsPlumb Toolkit + + Copyright 2015 https://jsplumbtoolkit.com +*/ + +/* --------------------------------------------------------------------------------------------- */ +/* --- SURFACE WIDGET -------------------------------------------------------------------------- */ +/* --------------------------------------------------------------------------------------------- */ + +/* + Assigned to every node managed by an instance of the Toolkit. They are required to be positioned absolute, to + enable dragging to work properly. +*/ +.jtk-node { + position: absolute; +} + +/* + This style was created in response to this Chrome bug: + http://stackoverflow.com/questions/13758215/artifacts-when-css-scaled-in-chrome + + Basically it's about how sometimes there can be artefacts left on screen when the user drags an element. It seems + the issue has been fixed in more recent versions of Chrome, but the style is left here in case you come across + the problem. +*/ +.jtk-node.jsplumb-drag { + /*-webkit-backface-visibility: hidden;*/ +} + +/* + Assigned to an element that is the `Container` in a `render` call. + Elements that are acting as Surface widgets should have overflow:hidden set to prevent libs from + scrolling them during drag (we don't want scrollbars; we have an infinite canvas). Position is set to + `relative` as this is the parent for nodes, which are positioned absolute (and for absolute positioning + to work, you need to ensure the parent node has `position:relative`). This style also sets some default + values for the cursor - using a `grab` cursor where supported. +*/ +.jtk-surface { + overflow: hidden !important; + position: relative; + cursor: move; + cursor: -moz-grab; + cursor: -webkit-grab; + + /* + For IE10+. As discussed on this page: + + https://msdn.microsoft.com/en-us/library/ie/jj583807(v=vs.85).aspx + + Microsoft have very helpfully implemented default behaviours for a bunch of touch events and + then consumed the events so you don't have to be bothered by them. They've "done a lot of research" + about this stuff and put together a really great default experience for everyone in the entire world. + */ + touch-action:none; + + /* + Another Chrome issue that appears to have been fixed in later versions + http://stackoverflow.com/questions/15464055/css-transition-effect-makes-image-blurry-moves-image-1px-in-chrome + */ + /* + -webkit-backface-visibility: hidden; + -webkit-transform: translateZ(0) scale(1.0, 1.0); + */ +} + +/* + Assigned to the surface when it is being panned. The default is to change the cursor (in browsers that support + a `grabbing` cursor), and to disable tex selection. +*/ +.jtk-surface-panning { + cursor: -moz-grabbing; + cursor: -webkit-grabbing; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* + The work area in a surface renderer. +*/ +.jtk-surface-canvas { + overflow: visible !important; +} + +/* + For IE10+. Discussed above in the .jtk-surface styles. This one is specific to elements that are configured + to be droppable on a Surface via its `registerDroppableNodes` method. +*/ +.jtk-surface-droppable-node { + touch-action:none; +} + +/* + Assigned to a Surface widget when panning is disabled (and therefore the app is relying on scrollbars when the content overflows). +*/ +.jtk-surface-nopan { + overflow: scroll !important; + cursor:default; +} + +/* +Assigned to tile images in a tiled background +*/ +.jtk-surface-tile { + border:none; + outline:none; + margin:0; + -webkit-transition: opacity .3s ease .15s; + -moz-transition: opacity .3s ease .15s; + -o-transition: opacity .3s ease .15s; + -ms-transition: opacity .3s ease .15s; + transition: opacity .3s ease .15s; +} + +/* + Assigned to the element used for node select with the mouse ("lasso"). +*/ +.jtk-lasso { + border: 2px solid rgb(49, 119, 184); + background-color: WhiteSmoke; + opacity: 0.5; + filter: alpha(opacity=50); + display: none; + z-index: 20000; + position: absolute; +} + +/* + This class is added to the document body on lasso drag start and removed at the end of lasso dragging. Its purpose + is to switch off text selection on all elements while the user is dragging the lasso. +*/ +.jtk-lasso-select-defeat * { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* + Assigned to some element that has been selected (either via lasso or programmatically). +*/ +.jtk-surface-selected-element { + border: 2px dashed #f76258 !important; +} + +/* + Assigned to all pan buttons in a surface widget. +*/ +.jtk-surface-pan { + background-color: Azure; + opacity: 0.4; + filter: alpha(opacity=40); + text-align: center; + cursor: pointer; + z-index: 2; + -webkit-transition: background-color 0.15s ease-in; + -moz-transition: background-color 0.15s ease-in; + -o-transition: background-color 0.15s ease-in; + transition: background-color 0.15s ease-in; +} + +/* + Specific styles for the top and bottom pan buttons. + Top/bottom are 100% width and 20px high by default +*/ +.jtk-surface-pan-top, .jtk-surface-pan-bottom { + width: 100%; + height: 20px; +} + +/* + Hover styles for all pan buttons. + On hover, change color, background color, font weight and opacity. +*/ +.jtk-surface-pan-top:hover, .jtk-surface-pan-bottom:hover, .jtk-surface-pan-left:hover, .jtk-surface-pan-right:hover { + opacity: 0.6; + filter: alpha(opacity=60); + background-color: rgb(49, 119, 184); + color: white; + font-weight: bold; +} + +/* + Specific styles for the left and right pan buttons. + Left/right pan buttons are 100% height and 20px wide +*/ +.jtk-surface-pan-left, .jtk-surface-pan-right { + width: 20px; + height: 100%; + line-height: 40; +} + + +/* + Assigned to a pan button when the user is pressing it. +*/ +.jtk-surface-pan-active, .jtk-surface-pan-active:hover { + background-color: #f76258; +} + +/* --------------------------------------------------------------------------------------------- */ +/* --- MINIVIEW WIDGET ------------------------------------------------------------------------- */ +/* --------------------------------------------------------------------------------------------- */ + +/* + Assigned to an element that is acting as a Miniview. + As with Surface, Miniview elements should have overflow:hidden set to prevent + libs from scrolling them during drag. This style also provides a default width/height for a miniview, + which you may wish to override. +*/ +.jtk-miniview { + overflow: hidden !important; + width: 125px; + height: 125px; + position: relative; + background-color: #B2C9CD; + border: 1px solid #E2E6CD; + border-radius: 4px; + opacity: 0.8; +} + +/* + Assigned to the element that shows the size of the related viewport in a Miniview widget, and which can be dragged to + move the surface. +*/ +.jtk-miniview-panner { + border: 5px dotted WhiteSmoke; + opacity: 0.4; + filter: alpha(opacity=40); + background-color: rgb(79, 111, 126); + cursor: move; + cursor: -moz-grab; + cursor: -webkit-grab; +} + +/* + Assigned to the miniview's panner when it is being dragged. +*/ +.jtk-miniview-panning { + cursor: -moz-grabbing; + cursor: -webkit-grabbing; +} + +/* + Added to all elements displayed in a miniview. +*/ +.jtk-miniview-element { + background-color: rgb(96, 122, 134); + position: absolute; +} + +/* + Assigned to the collapse/expand miniview button +*/ +.jtk-miniview-collapse { + color: whiteSmoke; + position: absolute; + font-size: 18px; + top: -1px; + right: 3px; + cursor: pointer; + font-weight: bold; +} + +/* + The '-' symbol when the miniview is expanded +*/ +.jtk-miniview-collapse:before { + content: "\2012"; +} + +/* + Assigned to the miniview element when it is collapsed. +*/ +.jtk-miniview-collapsed { + background-color: #449ea6; + border-radius: 4px; + height: 22px; + margin-right: 0; + padding: 4px; + width: 21px; +} + +/* + Hide all children of the miniview (except the expand button) when it is collapsed so you don't see anything + poking through under the + icon. +*/ +.jtk-miniview-collapsed .jtk-miniview-element, .jtk-miniview-collapsed .jtk-miniview-panner { + visibility: hidden; +} + +/* + The '+' symbol when the miniview is collapsed. +*/ +.jtk-miniview-collapsed .jtk-miniview-collapse:before { + content: "+"; +} + +/* + Hover state for the collapse/expand icon. +*/ +.jtk-miniview-collapse:hover { + color: #E4F013; +} + +/* ------------------------------------------------------------------------------------------- */ +/* --- DIALOGS --------------------------------------------------------------------------------*/ +/* ------------------------------------------------------------------------------------------- */ + +/* + This is the element that acts as the dialog underlay - the modal "mask". Note the high z-index default + set here (and note also the overlay style below has a z-index with a value higher by one). +*/ +.jtk-dialog-underlay { + left: 0; + right: 0; + top: 0; + bottom: 0; + position: fixed; + z-index: 100000; + opacity: 0.8; + background-color: #CCC; + display: none; +} + +/* + This is the element that acts as the parent for dialog content. +*/ +.jtk-dialog-overlay { + position: fixed; + z-index: 100001; + display: none; + background-color: white; + font-family: "Open Sans", sans-serif; + padding: 7px; + box-shadow: 0 0 5px gray; + overflow: hidden; +} + +.jtk-dialog-overlay-x { + max-height:0; + transition: max-height 0.5s ease-in; + -moz-transition: max-height 0.5s ease-in; + -ms-transition: max-height 0.5s ease-in; + -o-transition: max-height 0.5s ease-in; + -webkit-transition: max-height 0.5s ease-in; +} + +.jtk-dialog-overlay-y { + max-width:0; + transition: max-width 0.5s ease-in; + -moz-transition: max-width 0.5s ease-in; + -ms-transition: max-width 0.5s ease-in; + -o-transition: max-width 0.5s ease-in; + -webkit-transition: max-width 0.5s ease-in; +} + +.jtk-dialog-overlay-top { + top:20px; +} + +.jtk-dialog-overlay-bottom { + bottom:20px; +} + +.jtk-dialog-overlay-left { + left:20px; +} + +.jtk-dialog-overlay-right { + right:20px; +} + +.jtk-dialog-overlay-x.jtk-dialog-overlay-visible { + max-height:1000px; +} + +.jtk-dialog-overlay-y.jtk-dialog-overlay-visible { + max-width:1000px; +} + +/* + The element containing buttons in a dialog. +*/ +.jtk-dialog-buttons { + text-align: right; + margin-top: 5px; +} + +/* + An individual button in a dialog. +*/ +.jtk-dialog-button { + border: none; + cursor: pointer; + margin-right: 5px; + min-width: 56px; + background-color: white; + outline: 1px solid #ccc; +} + +/* + Hover style for an individual button in a dialog. +*/ +.jtk-dialog-button:hover { + color: white; + background-color: #234b5e; +} + +/* + The titlebar of a dialog. +*/ +.jtk-dialog-title { + text-align: left; + font-size: 14px; + margin-bottom: 9px; +} + +.jtk-dialog-content { + font-size:12px; + text-align:left; + min-width:250px; + margin: 0 14px; +} + +.jtk-dialog-content ul { + width:100%; + padding-left:0; +} + +.jtk-dialog-content label { + cursor: pointer; + font-weight: inherit; +} + +.jtk-dialog-overlay input, .jtk-dialog-overlay textarea { + background-color: #FFF; + border: 1px solid #CCC; + color: #333; + font-size: 14px; + font-style: normal; + outline: none; + padding: 6px 4px; + margin-right: 6px; +} + +.jtk-dialog-overlay input:focus, .jtk-dialog-overlay textarea:focus { + background-color: #cbeae1; + border: 1px solid #83b8a8; + color: #333; + font-size: 14px; + font-style: normal; + outline: none; +} + +/* -------------------------------------------------------------------------------------------- */ +/* --- DRAWING TOOLS -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------------------------- */ + +/* + Assigned to the element that is drawn around some other element when a drawing operation is taking place. +*/ +.jtk-draw-skeleton { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + outline: 2px solid #84acb3; + opacity: 0.8; +} + +/* + Assigned to every handle (top left, top right, bottom left, bottom right, center) in a draw skeleton. +*/ +.jtk-draw-handle { + position: absolute; + width: 7px; + height: 7px; + background-color: #84acb3; +} + +/* + Assigned to the top left handle in a draw skeleton +*/ +.jtk-draw-handle-tl { + left: 0; + top: 0; + cursor: nw-resize; +} + +/* + Assigned to the top right handle in a draw skeleton +*/ +.jtk-draw-handle-tr { + right: 0; + top: 0; + cursor: ne-resize; +} + +/* + Assigned to the bottom left handle in a draw skeleton +*/ +.jtk-draw-handle-bl { + left: 0; + bottom: 0; + cursor: sw-resize; +} + +/* + Assigned to the bottom right handle in a draw skeleton +*/ +.jtk-draw-handle-br { + bottom: 0; + right: 0; + cursor: se-resize; +} + +/* + Assigned to the center handle in a draw skeleton (the handle by which the element may be dragged). This is + not visible by defaut; enable if you need it. +*/ +.jtk-draw-drag { + display:none; + position: absolute; + left: 50%; + top: 50%; + margin-left: -10px; + margin-top: -10px; + width: 20px; + height: 20px; + background-color: #84acb3; + cursor: move; +} + +/* + This class is added to the document body on drag resize start and removed at the end of resizing. Its purpose + is to switch off text selection on all elements while the user is resizing an element. +*/ +.jtk-draw-select-defeat * { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-demo.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-demo.css new file mode 100644 index 000000000..5d0a49eb3 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsPlumbToolkit-demo.css @@ -0,0 +1,334 @@ +/* ---------------------- page structure ------------------------ */ +#main { + background-color: transparent; + font-family: Arial,sans-serif; + margin-left: auto; + margin-right: auto; + width: 90%; + max-width:1500px; + position: relative; + margin-top:98px; +} + +#main .description { + font-size: 13px; + margin-top: 25px; + padding: 13px; + margin-bottom: 22px; + background-color: #f4f5ef; +} + +#main .description li { + list-style-type: disc !important; +} + +.canvas { + margin-left: 160px; + height:550px; + max-height:700px; + border:1px solid #CCC; + background-color:white; +} + +.canvas-wide { + margin-left:0; +} + +.miniview { + position: absolute; + top: 25px; + right: 25px; + z-index: 100; +} + + +#dataset { + text-align: left; + max-height: 600px; + overflow: auto; +} + +.demo-title { + float:left; + font-size:18px; +} + +.controls { + top: 25px; + color: #FFF; + margin-right: 10px; + position: absolute; + left: 25px; + z-index: 1; +} + +.controls i { + background-color: #449ea6; + border-radius: 4px; + cursor: pointer; + margin-right: 0px; + padding: 4px; +} + +li { + list-style-type: none; +} + +/* ------------------------ node palette -------------------- */ + +.sidebar { + margin:0; + padding:0; + padding-top: 7px; + width:150px; + float:left; + text-align:center; + height: 550px; + padding-right: 10px; + background-color: #84acb3; +} + +.sidebar ul li { + background-color: #234b5e; + border-radius: 11px; + color: #f7ebca; + cursor: move; + margin-bottom: 10px; + margin-left: 6px; + padding: 8px; + width:128px; +} + +.sidebar ul { + width:100%; + padding:0; +} + +.sidebar ul li:hover { + background-color: #577a8b; +} + +.sidebar i { + float:left; +} + +@media (max-width: 600px) { + .sidebar { + float:none; + height: 55px; + width: 100%; + padding-top:0; + } + + .sidebar ul li { + display:inline-block; + margin-top: 7px; + width:67px; + } + .canvas { + margin-left: 0; + margin-top:10px; + height:364px; + } +} + +.btn-icon-margin { + line-height: 18px; + margin-left: 10px; +} + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- jsPlumb setup ---------------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------------------------------------- */ + +._jsPlumb_connector { + z-index:9; +} + +._jsPlumb_endpoint { + z-index:12; + opacity:0.8; + cursor:pointer; +} + +._jsPlumb_overlay { + background-color: white; + color: #434343; + font-weight: 400; + padding: 4px; + z-index:10; + +} + +._jsPlumb_overlay._jsPlumb_hover { + color: #434343; +} + +path { + cursor:pointer; +} + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- Dialogs -----------------------------------------------------------------------------------------*/ +/* ---------------------------------------------------------------------------------------------------- */ + + + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- Drag/drop interactions ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------------------------------------- */ +.drop-hover { + background-color: #629f72 !important; + color: #FFF !important; +} + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- Node styles ------------------------------------------------------------------------------------ */ +/* ---------------------------------------------------------------------------------------------------- */ + +/* -- common --*/ + +.jtk-node { + background-color: #234b5e; + border-radius: 14px; + border:1px solid #CCC; + box-shadow:0 0 5px #CCC; + cursor: pointer; + font-size: 12px; + position: absolute; + z-index: 11; + overflow: hidden; + min-width:80px; + min-height:30px; + width: auto; +} + +.jtk-node .name, li.jsplumb-draggable { + background-color: #234b5e; + color: #f7ebca; + cursor: move; + font-size: 16px; + line-height: 24px; + padding: 6px; + text-align: center; +} + +.jtk-node .ep { + width: 100%; + background-color: orange; + height: 10px; + cursor: pointer; +} + +li.jsplumb-draggable { + min-width:100px; + border-radius:14px; +} + +.jtk-node .name span { + cursor:pointer; +} + +.delete { + padding: 2px; + cursor: pointer; + float: left; + font-size: 10px; + line-height: 20px; +} + +.add, .edit { + cursor: pointer; + float:right; + font-size: 10px; + line-height: 20px; + margin-right:2px; + padding: 2px; +} + +.edit:hover { + color: #ff8000; +} + +.selected-mode { + color:#E4F013; +} + +.connect { + width:10px; + height:10px; + background-color:#f76258; + position:absolute; + bottom:10px; + right:10px; +} + +/* --------------------- / common --------------------------------------- */ + + +/* ----------------------- form ------------------------- */ + +.form-labels-float { + float: left; + font-weight: bold; + text-align: right; + padding-right: 6px; + padding-top: 6px; + font-size: 14px; +} + +.form-labels { + font-weight: bold; + text-align: left; + padding-right: 6px; + font-size: 14px; +} + +.checkbox-id { + margin-top: 6px; + margin-left: 22px; +} + + +.pull-left { float: left; } +.clearfix { clear: both; } + + +.demo-links { + position: fixed; + right: 0; + top: 57px; + font-size: 11px; + background-color: white; + opacity: 0.8; + padding-right: 10px; + padding-left: 5px; + text-transform: uppercase; + z-index:100001; +} + +.demo-links div { + display:inline; + margin-right:7px; + margin-left:7px; +} + +.demo-links i { + padding:4px; +} + +.community { + position: absolute; + top: 38px; + left: 102px; + color: oldlace; + font-size: 13px; + text-transform: lowercase; + letter-spacing: 1px; +} + +.community:after { + content:"Community Edition"; +} + + diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb-doc.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb-doc.css new file mode 100644 index 000000000..bd113af90 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb-doc.css @@ -0,0 +1,781 @@ + +@media (max-width: 600px) { + .col-xs-3 { + width: 100%; + + } + .col-xs-9 { + width: 100%; + } + + .col-xs-3 li { + background-color:#f5f5f5; + } + + .docs-nav:before { + content: "Contents"; + } + + .docs-nav { + cursor:pointer; + margin-bottom: 13px; + font-size:17px; + display:inline-block; + position:relative; + overflow-x:visible !important; + overflow-y:visible !important; + } + + .docs-nav > ul { + cursor: default; + position: absolute; + z-index: 1; + max-height:250px; + visibility: hidden; + transition: visibility 0.5s; + -moz-transition: visibility 0.5s; + -o-transition: visibility 0.5s; + -ms-transition: visibility 0.5s; + -webkit-transition: visibility 0.5s; + width: 100%; + left:0; + top:41px; + overflow: auto; + background-color: inherit; + box-shadow: 0px 2px 2px #ccc; + } + + .docs-nav:focus > ul { + visibility: visible; + } + + .docs-nav li { + padding-top:3px; + padding-bottom:3px; + margin-top:5px; + margin-bottom:5px; + border-bottom: 1px solid #eee; + } + + .docs-nav li:last-of-type { + border-bottom:none; + } + + .markdown-body { + width:100%; + } + + #dataset { + margin-left:0 !important; + height:175px !important; + } +} + +.docs-nav:focus { + outline:none; +} + + +img { + border: 0; +} + +.markdown-body a[id].wiki-toc-anchor { + color: inherit; + text-decoration: none; +} + +.markdown-body>*:first-child { + margin-top: 0!important; +} +.markdown-body>*:last-child { + margin-bottom: 0!important; +} +.markdown-body a.absent { + color: #c00; +} +.markdown-body a.anchor { + display: block; + padding-left: 30px; + margin-left: -30px; + cursor: pointer; + position: absolute; + top: 0; + left: 0; + bottom: 0; +} +.markdown-body h1, +.markdown-body h2, +.markdown-body h3, +.markdown-body h4, +.markdown-body h5, +.markdown-body h6 { + margin: 20px 0 10px; + padding: 0; + font-weight: bold; + -webkit-font-smoothing: antialiased; + cursor: text; + position: relative; +} +.markdown-body h1:hover a.anchor, +.markdown-body h2:hover a.anchor, +.markdown-body h3:hover a.anchor, +.markdown-body h4:hover a.anchor, +.markdown-body h5:hover a.anchor, +.markdown-body h6:hover a.anchor { + background: url(../images/pin-20.png) no-repeat left center; + text-decoration: none; +} +.markdown-body h1 tt, +.markdown-body h1 code, +.markdown-body h2 tt, +.markdown-body h2 code, +.markdown-body h3 tt, +.markdown-body h3 code, +.markdown-body h4 tt, +.markdown-body h4 code, +.markdown-body h5 tt, +.markdown-body h5 code, +.markdown-body h6 tt, +.markdown-body h6 code { + font-size: inherit; +} +.markdown-body h1 { + font-size: 28px; + color: #000; + margin-top: 50px; + margin-bottom: 20px; +} +.markdown-body h2 { + font-size: 24px; + border-bottom: 1px dotted #ccc; + color: #000; + margin-top: 40px; + margin-bottom: 20px; +} +.markdown-body h3 { + font-size: 18px; + margin-top: 30px; + margin-bottom: 15px; +} +.markdown-body h4 { + font-size: 16px; +} +.markdown-body h5 { + font-size: 14px; +} +.markdown-body h6 { + color: #777; + font-size: 14px; +} +.markdown-body p, +.markdown-body blockquote, +.markdown-body ul, +.markdown-body ol, +.markdown-body dl, +.markdown-body li, +.markdown-body table, +.markdown-body pre { + margin: 10px 0; +} +.markdown-body hr { + border: 0 none; + color: #ccc; + height: 1px; + padding: 0; + background-color: #ccc; +} +.markdown-body>h1:first-child, +.markdown-body>h2:first-child, +.markdown-body>h3:first-child, +.markdown-body>h4:first-child, +.markdown-body>h5:first-child, +.markdown-body>h6:first-child { +} +.markdown-body h1+h2{ + margin-top: 30px; +} +.markdown-body h2+h3{ + margin-top: 10px; +} +.markdown-body a:first-child h1, +.markdown-body a:first-child h2, +.markdown-body a:first-child h3, +.markdown-body a:first-child h4, +.markdown-body a:first-child h5, +.markdown-body a:first-child h6 { + margin-top: 0; + padding-top: 0; +} +.markdown-body h1+p, +.markdown-body h2+p, +.markdown-body h3+p, +.markdown-body h4+p, +.markdown-body h5+p, +.markdown-body h6+p { + margin-top: 0; +} +.markdown-body li p.first { + display: inline-block; +} +.markdown-body ul, +.markdown-body ol { + padding-left: 30px; +} +.markdown-body ul li>:first-child, +.markdown-body ol li>:first-child { + margin-top: 0; +} +.markdown-body ul li>:last-child, +.markdown-body ol li>:last-child { + margin-bottom: 0; +} +.markdown-body dl { + padding: 0; +} +.markdown-body dl dt { + font-size: 14px; + font-weight: bold; + font-style: italic; + padding: 0; + margin: 15px 0 5px; +} +.markdown-body dl dt:first-child { + padding: 0; +} +.markdown-body dl dt>:first-child { + margin-top: 0; +} +.markdown-body dl dt>:last-child { + margin-bottom: 0; +} +.markdown-body dl dd { + margin: 0 0 15px; + padding: 0 15px; +} +.markdown-body dl dd>:first-child { + margin-top: 0; +} +.markdown-body dl dd>:last-child { + margin-bottom: 0; +} +.markdown-body blockquote { + border-left: 4px solid #DDD; + padding: 0 15px; + color: #777; +} +.markdown-body blockquote>:first-child { + margin-top: 0; +} +.markdown-body blockquote>:last-child { + margin-bottom: 0; +} +.markdown-body table { + padding: 0; + border-collapse: collapse; + border-spacing: 0; +} +.markdown-body table tr { + border-top: 1px solid #ccc; + background-color: #fff; + margin: 0; + padding: 0; +} +.markdown-body table tr:nth-child(2n) { + background-color: #f8f8f8; +} +.markdown-body table tr th { + font-weight: bold; +} +.markdown-body table tr th, +.markdown-body table tr td { + border: 1px solid #ccc; + text-align: left; + margin: 0; + padding: 6px 13px; +} +.markdown-body table tr th>:first-child, +.markdown-body table tr td>:first-child { + margin-top: 0; +} +.markdown-body table tr th>:last-child, +.markdown-body table tr td>:last-child { + margin-bottom: 0; +} +.markdown-body img { + max-width: 100%; +} +.markdown-body span.frame { + display: block; + overflow: hidden; +} +.markdown-body span.frame>span { + border: 1px solid #ddd; + display: block; + float: left; + overflow: hidden; + margin: 13px 0 0; + padding: 7px; + width: auto; +} +.markdown-body span.frame span img { + display: block; + float: left; +} +.markdown-body span.frame span span { + clear: both; + color: #333; + display: block; + padding: 5px 0 0; +} +.markdown-body span.align-center { + display: block; + overflow: hidden; + clear: both; +} +.markdown-body span.align-center>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: center; +} +.markdown-body span.align-center span img { + margin: 0 auto; + text-align: center; +} +.markdown-body span.align-right { + display: block; + overflow: hidden; + clear: both; +} +.markdown-body span.align-right>span { + display: block; + overflow: hidden; + margin: 13px 0 0; + text-align: right; +} +.markdown-body span.align-right span img { + margin: 0; + text-align: right; +} +.markdown-body span.float-left { + display: block; + margin-right: 13px; + overflow: hidden; + float: left; +} +.markdown-body span.float-left span { + margin: 13px 0 0; +} +.markdown-body span.float-right { + display: block; + margin-left: 13px; + overflow: hidden; + float: right; +} +.markdown-body span.float-right>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: right; +} +.markdown-body code, +.markdown-body tt { + margin: 0 2px; + padding: 0 5px; + white-space: nowrap; + border: 1px solid #ddd; + background-color: #f8f8f8; + border-radius: 3px; +} +.markdown-body pre>tt, +.markdown-body pre>code { + margin: 0; + padding: 0; + white-space: pre; + border: none; + background: transparent; +} +.markdown-body pre { + background-color: #f8f8f8; + border: 1px solid #ccc; + font-size: 11.5px; + line-height: 18px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} +.markdown-body pre pre, +.markdown-body pre code, +.markdown-body pre tt { + background-color: transparent; + border: none; +} +.markdown-body pre pre { + margin: 0; + padding: 0; +} +.toc { + background-color: #F7F7F7; + border: 1px solid #ddd; + padding: 5px 10px; + margin: 0; + border-radius: 3px; +} +.toc-title { + color: #888; + font-size: 14px; + line-height: 1.6; + padding: 2px; + border-bottom: 1px solid #ddd; + margin-bottom: 3px; +} +.toc ul { + padding-left: 10px; + margin: 0; +} +.toc>ul { + margin-left: 10px; + font-size: 17px; +} +.toc ul ul { + font-size: 15px; +} +.toc ul ul ul { + font-size: 14px; +} +.toc ul li{ + margin: 0; +} +#header-content .toc, +#footer-content .toc, +#sidebar-content .toc { + border: none; +} +.highlight { + background: #fff; +} +.highlight .c { + color: #998; + font-style: italic; +} +.highlight .err { + color: #a61717; + background-color: #e3d2d2; +} +.highlight .k { + font-weight: bold; +} +.highlight .o { + font-weight: bold; +} +.highlight .cm { + color: #998; + font-style: italic; +} +.highlight .cp { + color: #999; + font-weight: bold; +} +.highlight .c1 { + color: #998; + font-style: italic; +} +.highlight .cs { + color: #999; + font-weight: bold; + font-style: italic; +} +.highlight .gd { + color: #000; + background-color: #fdd; +} +.highlight .gd .x { + color: #000; + background-color: #faa; +} +.highlight .ge { + font-style: italic; +} +.highlight .gr { + color: #a00; +} +.highlight .gh { + color: #999; +} +.highlight .gi { + color: #000; + background-color: #dfd; +} +.highlight .gi .x { + color: #000; + background-color: #afa; +} +.highlight .go { + color: #888; +} +.highlight .gp { + color: #555; +} +.highlight .gs { + font-weight: bold; +} +.highlight .gu { + color: #800080; + font-weight: bold; +} +.highlight .gt { + color: #a00; +} +.highlight .kc { + font-weight: bold; +} +.highlight .kd { + font-weight: bold; +} +.highlight .kn { + font-weight: bold; +} +.highlight .kp { + font-weight: bold; +} +.highlight .kr { + font-weight: bold; +} +.highlight .kt { + color: #458; + font-weight: bold; +} +.highlight .m { + color: #099; +} +.highlight .s { + color: #d14; +} +.highlight .na { + color: #008080; +} +.highlight .nb { + color: #0086B3; +} +.highlight .nc { + color: #458; + font-weight: bold; +} +.highlight .no { + color: #008080; +} +.highlight .ni { + color: #800080; +} +.highlight .ne { + color: #900; + font-weight: bold; +} +.highlight .nf { + color: #900; + font-weight: bold; +} +.highlight .nn { + color: #555; +} +.highlight .nt { + color: #000080; +} +.highlight .nv { + color: #008080; +} +.highlight .ow { + font-weight: bold; +} +.highlight .w { + color: #bbb; +} +.highlight .mf { + color: #099; +} +.highlight .mh { + color: #099; +} +.highlight .mi { + color: #099; +} +.highlight .mo { + color: #099; +} +.highlight .sb { + color: #d14; +} +.highlight .sc { + color: #d14; +} +.highlight .sd { + color: #d14; +} +.highlight .s2 { + color: #d14; +} +.highlight .se { + color: #d14; +} +.highlight .sh { + color: #d14; +} +.highlight .si { + color: #d14; +} +.highlight .sx { + color: #d14; +} +.highlight .sr { + color: #009926; +} +.highlight .s1 { + color: #d14; +} +.highlight .ss { + color: #990073; +} +.highlight .bp { + color: #999; +} +.highlight .vc { + color: #008080; +} +.highlight .vg { + color: #008080; +} +.highlight .vi { + color: #008080; +} +.highlight .il { + color: #099; +} +.highlight .gc { + color: #999; + background-color: #EAF2F5; +} +.type-csharp .highlight .k { + color: #00F; +} +.type-csharp .highlight .kt { + color: #00F; +} +.type-csharp .highlight .nf { + color: #000; + font-weight: normal; +} +.type-csharp .highlight .nc { + color: #2B91AF; +} +.type-csharp .highlight .nn { + color: #000; +} +.type-csharp .highlight .s { + color: #A31515; +} +.type-csharp .highlight .sc { + color: #A31515; +} + +/* apidoc overrides */ +.yui3-tabview-list/*, #api-tabview */.tabs { + display:none; +} + +.yui3-tab-label { + background: none !important; +} + +.yui3-tab-selected { + background-color:#58775d !important; + border-color: #58775d; + color:white; +} + +.yui3-tab-selected a, .yui3-tab-selected a:visited { + color:white !important; +} + +.yui3-tabview { + font-size:13px; + margin-top: 36px; + margin-bottom: 50px; +} + +.api-class-tabs.yui3-tabview-list { + background-color:#f4f5ef !important; + border:solid #58775d !important; + border-width:0 0 5px !important; +} + +.api-class-tab { + font-size:15px; +} + +#api-filter { + border: 1px solid #CCC; + margin-bottom: 5px; +} + +kbd { + padding: 2px 4px; + font-size: 90%; + color: #fff; + background-color: #aaa; + border-radius: 3px; + -webkit-box-shadow: none; + box-shadow: none; +} + +#docs-main h1 { + font-size:24px; +} + +#docs-main h2 { + font-size:17px; +} + +#docs-main h3 { + font-size:15px; +} + +#docs-main h6 { + font-size: 14px; + font-weight: bold; +} + +#docs-main .params { + margin-top:30px; +} + +#docs-main code { + color:inherit; +} + +#docs-main a { + color: #629f8d; +} + +#docs-main .args { + display:none; +} + +#index h2 { + font-size:18px; +} + +@media (max-width: 600px) { + .yui3-u-1-4, .yui3-u-3-4 { + width:100%; + } + + .yui3-u-1-4 { + max-height:150px; + overflow:auto; + } + + .yui3-u-1-4:focus { + max-height:180px; + } +} diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb.css new file mode 100644 index 000000000..be8d3d707 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/jsplumb.css @@ -0,0 +1,403 @@ +/** DISABLE TEXT SELECTION (SET ON BODY WHEN DRAGGING IS OCCURRING) **/ +._jsPlumb_drag_select * { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/** FB **/ +#like { + position: fixed; + width: 77px; + height: 70px; + border: 0; + right: 11px; + bottom: -40px; +} + +#retweet_button { + position: fixed; + bottom: 30px; + right: -7px; +} + +body { + padding:0; + margin:0; + font-family:'Helvetica Neue', Helvetica, Arial, sans-serif; + background-color: whitesmoke; +} + +#headerWrapper { + width:100%; + background-color:white; + position:fixed; + top:0;left:0; + z-index:100001; + height:44px; + padding:0; + text-align: center; + border-bottom: 1px solid #e5e5e5; + box-shadow: 0px 1px #eee; +} + +#header { + margin-top:0; + + height:44px; + font-size:13px; + margin-left:auto; + margin-right:auto; + + line-height: 44px; + max-width:1000px; + width:80%; +} + +@media screen and (max-width:1000px) { + #header { + width:100%; + } +} + +@media screen and (max-width:800px) { + #header select { + display:none; + } +} + +@media screen and (max-width:700px) { + .library-links { + right:330px; + } +} + +@media screen and (max-width:640px) { + .logo { + display:none; + } + #header { + text-align:center; + overflow:hidden; + } +} + +.explanation i { + float: right; + margin-right: 25px; + margin-top: 13px; + font-size: 25px; + cursor:pointer; +} + +.explanation i:hover { + color:orange; +} + +.words { + text-align: left; + padding:50px; + background-color:white; +} + +.code { + border:1px solid #456; +} + +.logo { + font-size:30px; + color:#1f1f1f; + text-shadow: 1px 1px #ccc; + float:left; + width:154px; + height:44px; + background-position:0px 5px; +} + + #main { + margin-top: 106px; + font-size: 80%; + width: 80%; + margin-left:auto; + margin-right: auto; + height: 600px; + text-align: center; + position: relative; + max-width: 1200px; + max-height: 1000px; +} + +.demo { + position: relative; + width:100%; + background-color:white; + overflow:auto; + margin-top: 53px; + margin-bottom:25px; + height: 600px; +} + +.explanation { + text-align: center; + opacity: 0.8; + filter: alpha(opacity=80); + width: 100%; + z-index: 10000; + overflow: hidden; + font-size:13px; +} + + +.commands { + margin-bottom:10px; +} + +.commands:hover { + z-index:10000; +} + +/* demo elements */ + +a, a:visited { + text-decoration:none; + color:black; + border-radius:0.2em; + -webkit-transition: color 0.15s ease-in; + -moz-transition: color 0.15s ease-in; + -o-transition: color 0.15s ease-in; + transition: color 0.15s ease-in; +} + +a:hover { + color:#7AB02C; +} + +a:active { + color:#FF2300; +} + +.menu, #render, #explanation { + background-color:#fff; +} + +.menu { + float:right; + font-size:12px; +} + +.menu a { + margin-right: 19px; +} + +.otherLibraries { + display:inline; +} + +#render a { + margin-right:10px; +} + +.selected { + color:orange !important; +} + +.cmd { + color:white; + margin-right:25px; +} + +.cmd:hover { + color:#FF2300; + text-decoration: underline; +} +.cmd:active { + color:#FF2300; +} + +.label { + font-size:13px; + padding:8px; + padding:8px; +} + +.component { + border:1px solid #346789; + border-radius:0.5em; + opacity:0.8; + filter:alpha(opacity=80); + background-color:white; + color:black; + padding:0.5em; + font-size:0.8em; +} + +.component:hover { + border:1px solid #123456; + box-shadow: 2px 2px 19px #444; + -o-box-shadow: 2px 2px 19px #444; + -webkit-box-shadow: 2px 2px 19px #444; + -moz-box-shadow: 2px 2px 19px #fff; + opacity:0.9; + filter:alpha(opacity=90); +} + + +.demo-links, .library-links { + position: fixed; + right: 0; + top: 44px; + font-size: 11px; + background-color: white; + opacity: 0.8; + padding-right: 10px; + padding-left: 5px; + text-transform: uppercase; + z-index:100001; +} + +.demo-links div, .library-links a { + display:inline; + margin-right:7px; + margin-left:7px; +} + +.demo-links i, .library-links i { + padding:4px; +} + +.library-links { + right: 515px; + height: 19px; + line-height: 19px; +} + +.current-library { + color:#7AB02C !important; +} + +/** Z-INDEX **/ + +._jsPlumb_connector { z-index:18; } +._jsPlumb_endpoint { z-index:19; } +._jsPlumb_overlay { z-index:20; } + +.aLabel { + background-color:white; + padding:0.4em; + font:12px sans-serif; + color:#444; + z-index:21; + border:1px dotted gray; + opacity:0.8; + filter:alpha(opacity=80); + cursor: pointer; +} +.aLabel._jsPlumb_hover { + background-color:#5C96BC; + color:white; + border:1px solid white; +} + +/* ---------------------- bootstrap dropdowns ------------------------- */ +.clearfix { + *zoom: 1; +} + +.clearfix:before, +.clearfix:after { + display: table; + line-height: 0; + content: ""; +} + +.clearfix:after { + clear: both; +} + +.hide-text { + font: 0/0 a; + color: transparent; + text-shadow: none; + background-color: transparent; + border: 0; +} + +.input-block-level { + display: block; + width: 100%; + min-height: 30px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +/* load test */ + + + #iframe { + width: 98%; + height: 1000px; + position: absolute; + top: 8px; + left: 1%; + border: 0; + } + #render { height:20px;} + #links { + width: 143px; + font-size: 14px; + padding-left: 0px; + position: fixed; + left: 9px; + top: 52px; + z-index: 20; + background-color: white; + } + ul { padding:0; } + li { + list-style-type:none; + } + .current-tests { + color:orange !important; + } + #qunit-tests li.pass, #qunit-tests li.fail { + background-color:transparent; + } + .loadtest #main, #main.test { + max-width: none; + margin-top: 52px; + background-color: white; + + margin-left: 162px; +} + + +.loadtest ._jsPlumb_connection { z-index:3; } +.loadtest .jspLoad { + z-index:4; + position:absolute; + width:70px; + height:70px; + cursor:pointer; +} + +.loadtest #header { + height:11em; + border:2px solid #824563; +} + +.loadtest #setup { + float:left; +} +.loadtest #demo { + margin-top:10em; + position:relative; +} +.loadtest #setup, .loadtest #output { + font-size:12px; +} + + diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/main.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/main.css new file mode 100644 index 000000000..06529ec56 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/css/main.css @@ -0,0 +1,1247 @@ +@font-face { + font-family: 'ico-jsplumb'; + src: url("ico-jsplumb.eot?-oqkwhs"); + src: url("ico-jsplumb.eot?#iefix-oqkwhs") format("embedded-opentype"), url("ico-jsplumb.woff?-oqkwhs") format("woff"), url("ico-jsplumb.ttf?-oqkwhs") format("truetype"), url("ico-jsplumb.svg?-oqkwhs#ico-jsplumb") format("svg"); + font-weight: normal; + font-style: normal +} + +[class^="icon-"], [class*=" icon-"] { + font-family: 'ico-jsplumb'; + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1 +} + +.icon-license:before { + content: "\e604" +} + +.icon-source:before { + content: "\e605" +} + +.icon-support:before { + content: "\e606" +} + +.icon-facebook:before { + content: "\e600" +} + +.icon-twitter:before { + content: "\e601" +} + +.icon-github:before { + content: "\e602" +} + +.icon-linkedin:before { + content: "\e603" +} + +.icon-cross:before { + content: "\ea0f" +} + +.icon-checkmark:before { + content: "\ea10" +} + +*, *:before, *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-rendering: optimizeLegibility +} + +html { + padding: 0; + margin: 0 +} + +body { + background-color: #FFF; + color: #434343; + font-family: "Lato", sans-serif; + font-size: 14px; + font-weight: 400; + height: 100%; + padding: 0 +} + +@media only screen and (max-width: 320px) { + body { + margin-top: 51px + } +} + +.clear-padding { + padding: 0 +} + +.full-width { + width: 100% +} + +.blank-left-padding { + padding: 0 0 0 83px +} + +.full-width-container { + padding: 40px 0; + width: 100% +} + +@media only screen and (max-width: 320px) { + .full-width-container { + padding: 30px 0 + } +} + +.padding-top-page { + padding-top: 92px +} + +@media only screen and (max-width: 320px) { + .padding-top-page { + padding-top: 10px + } +} + +.center-block { + display: table +} + +.pos-relative { + position: relative +} + +@media only screen and (max-width: 320px) { + .mobile-center { + text-align: center + } +} + +.bg-sepia { + background-color: #f4f5ef +} + +.color-white { + color: #FFF !important +} + +.divider-10 { + padding-top: 10px +} + +.divider-20 { + padding-top: 20px +} + +.divider-30 { + padding-top: 30px +} + +.big-title { + color: #58775d; + font-size: 56px; + font-weight: 400; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .big-title { + font-size: 32px; + margin-bottom: 10px + } +} + +.high-title { + color: #696b60; + font-size: 34px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .high-title { + font-size: 32px; + margin-bottom: 10px + } +} + +.prod-title { + color: #696b60; + font-size: 32px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .prod-title { + font-size: 32px; + margin-bottom: 10px + } +} + +.title-white { + color: #FFF; + font-size: 32px; + font-weight: 400; + line-height: 1.2em +} + +@media only screen and (max-width: 320px) { + .title-white { + font-size: 32px; + margin-bottom: 10px + } +} + +.title { + color: #434343; + font-size: 25px; + font-weight: 400; + margin-bottom: 10px +} + +@media only screen and (max-width: 320px) { + .title { + font-size: 18px; + margin-bottom: 6px + } +} + +.big-lead { + color: #FFF; + font-size: 25px; + font-weight: 400; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .big-lead { + font-size: 18px; + margin-bottom: 10px + } +} + +.lead { + color: #434343; + font-size: 18px; + font-weight: 400; + margin-bottom: 0 +} + +@media only screen and (max-width: 320px) { + .lead { + font-size: 14px + } +} + +.apidoc-jsplumb-logo { + display: none +} + +.btn-big-download a { + border-radius: 0; + color: #FFF; + display: inline-block; + font-size: 16px; + font-weight: 400; + margin: 0; + padding: 10px 20px; + text-decoration: none; + background-color: #096070 +} + +.btn-big-download a:hover:not(:disabled), .btn-big-download a:active:not(:disabled), .btn-big-download a:focus:not(:disabled) { + color: #FFF; + cursor: pointer; + background-color: #012930 +} + +.btn-download a { + border-radius: 0; + color: #FFF; + display: inline-block; + font-size: 16px; + font-weight: 400; + margin: 0; + padding: 10px 20px; + text-decoration: none; + background-color: #096070 +} + +.btn-download a:hover:not(:disabled), .btn-download a:active:not(:disabled), .btn-download a:focus:not(:disabled) { + color: #FFF; + cursor: pointer; + background-color: #012930 +} + +.demo-highlight { + background: url("/img/back-green.jpg") repeat-x center +} + +.logo-jsplumb img { + padding-bottom: 16px; + max-width: 100% +} + +@media only screen and (max-width: 320px) { + .logo-jsplumb img { + max-width: 63% + } +} + +@media only screen and (min-width: 769px) and (max-width: 1023px) { + .logo-jsplumb img { + max-width: 63% + } +} + +.browser-window { + position: relative +} + +.browser-window .browser-dropdown-menu { + position: absolute; + top: 10px; + width: 100% +} + +.browser-window table { + width: 100% +} + +.browser-window td.corners { + height: 56px; + width: 53px +} + +.browser-window td.center-top { + background: url("/img/browser-window-top-center.png") repeat-x; + width: 100% +} + +.browser-window td.center { + background-color: #FFF +} + +.browser-window .jsplumb-demo-container { + padding: 10px +} + +.download-container { + text-align: right +} + +@media only screen and (max-width: 320px) { + .download-container { + text-align: center + } +} + +.background-blue { + background: url("/img/back-blue.jpg") repeat-x center +} + +.background-dark-green { + background: url("/img/back-dark-green.jpg") repeat +} + +.btn-drop { + color: #FFF; + font-weight: 700; + padding: 10px 20px 8px 20px; + background-color: #6dadcc; + cursor: pointer; + width: 100% +} + +.btn-drop:hover, .btn-drop:focus, .btn-drop:active, .open .dropdown-toggle.btn-drop { + color: #FFF; + border: none; + background-color: #3491be; + text-decoration: none +} + +.btn-dropmenu { + -webkit-box-shadow: none; + background-color: #6dadcc; + border-radius: 0; + border: none; + box-shadow: none; + color: #FFF; + margin-top: 1px !important; + padding: 10px 0; + width: 100% +} + +.btn-dropmenu > li > a { + color: #FFF; + border: none; + padding: 10px 20px +} + +.btn-dropmenu > li > a:hover { + background-color: #3c9cca; + color: #FFF +} + +.row #main { + height: 400px; + margin-top: 25px +} + +.row #dataset { + display: none +} + +.navbar-top { + background-color: #58775d; + border-color: none; + font-size: 14px; + font-weight: 700 +} + +@media only screen and (max-width: 320px) { + .navbar-top { + background-color: #58775d + } +} + +.navbar-brand { + height: 56px +} + +.nav-wrapper { + margin-top: 10px +} + +.navbar-header a { + border: none +} + +.navbar-nav > li > a { + border: none; + color: #FFF; + padding: 6px 10px; + text-decoration: none +} + +.navbar-nav > li > a.active { + border: none; + color: #cdcc73; + padding: 6px 10px; + text-decoration: none; + cursor: default +} + +.navbar-nav > li:last-child > a { + color: #FFF; + padding: 6px 0 6px 10px; + text-decoration: none +} + +.navbar-nav > li:last-child > a.active { + border: none; + color: #cdcc73; + padding: 6px 10px; + text-decoration: none; + cursor: default +} + +.nav { + float: left +} + +@media only screen and (max-width: 320px) { + .nav { + float: left; + margin-top: 10px + } +} + +@media only screen and (min-width: 321px) and (max-width: 768px) { + .nav { + float: left + } +} + +.nav > li > a:hover, .nav > li > a:focus { + background-color: transparent; + color: #cdcc73; + text-decoration: none +} + +.navbar-toggle .icon-bar { + background-color: #FFF +} + +.social-nav { + color: #FFF; + float: right; + font-size: 22px +} + +.social-nav .link { + cursor: pointer; + border: none; + color: #FFF; + margin-left: 10px; + text-decoration: none +} + +.social-nav .link:hover, .social-nav .link:focus, .social-nav .link:active { + color: #cdcc73; + border: none; + text-decoration: none +} + +.breadcrumbs { + height: 20px; + top: 52px; + position: fixed; + z-index: 1030; + font-size: 11px; + padding-left: 2%; + background-color: aliceblue; + text-transform: uppercase; + width: 100%; + padding-top: 3px +} + +.breadcrumbs a { + color: #629f8d; + text-decoration: none +} + +.breadcrumbs a:hover, .breadcrumbs a:focus { + color: #434343; + text-decoration: underline +} + +.breadcrumbs .crumbs { + float: left +} + +.breadcrumbs .demo-nav { + display: inline-block; + float: right; + margin-right: 2% +} + +@media (max-width: 490px) { + .crumbs { + display: none + } + + .breadcrumbs { + text-align: center + } + + .demo-nav { + float: none !important; + margin-left: auto; + margin-right: auto !important + } +} + +.footer .copyright { + font-size: 12px; + color: #a0b8b7 +} + +.footer .copyright a { + border: none; + color: #FFF; + text-decoration: none +} + +.footer .copyright a:hover { + color: #cdcc73; + text-decoration: none +} + +ul.navbar-footer { + padding: 4px 0 0 10px +} + +@media only screen and (max-width: 320px) { + ul.navbar-footer { + padding: 6px 0 0 0 + } +} + +.navbar-footer > li { + float: left; + font-size: 14px; + list-style-type: none +} + +.navbar-footer > li > a { + border: none; + color: #FFF; + padding: 6px 6px 0 0; + text-decoration: none +} + +.navbar-footer > li > a:hover { + color: #cdcc73; + text-decoration: none +} + +.footer .social-nav { + float: right; + font-size: 22px +} + +@media only screen and (max-width: 320px) { + .footer .social-nav { + float: left; + margin-top: 10px + } +} + +.footer .social-nav .link { + border: none; + color: #a0b8b7; + margin-left: 10px; + text-decoration: none +} + +@media only screen and (max-width: 320px) { + .footer .social-nav .link { + margin-left: 0 + } +} + +.footer .social-nav .link:hover, .footer .social-nav .link:focus, .footer .social-nav .link:active { + color: #cdcc73; + border: none; + text-decoration: none +} + +.clear-footer { + width: 100%; + clear: both +} + +body.ff .clear-footer { + margin-bottom: 95px +} + +body.ff .footer-wrapper { + position: fixed; + width: 100%; + bottom: 0; + left: 0 +} + +#docs { + margin-top: 101px; + margin-bottom: 40px +} + +#docs h2, #docs h3 { + color: #629f8d; + padding-bottom: 3px +} + +#docs pre { + background: #f4f5ef; + border-color: #c5c7b8; + border-radius: 3px; + font-family: courier, sans-serif; + font-size: 12px +} + +#docs a { + color: #629f8d; + text-decoration: none +} + +#docs a:hover, #docs a:focus { + color: #434343; + text-decoration: underline +} + +#docs ul { + padding-left: 10px +} + +#docs table { + border: 1px solid #a0b8b7 +} + +#docs th { + padding: 10px; + background-color: #a0b8b7 +} + +#docs td { + padding: 10px; + border: 1px solid #a0b8b7 +} + +#docs .markdown-body { + font-size: 13px; + line-height: 1.6; + background-color: white +} + +#docs .markdown-body ul { + padding-left: 16px +} + +#docs .markdown-body li { + list-style-type: circle +} + +#docs .docs-nav { + padding-bottom: 10px; + padding-top: 10px; + overflow-x: hidden; + overflow-y: auto; + background-color: #f4f5ef; + border: 1px solid #f4f5ef; + border-radius: 3px +} + +#docs .docs-nav > ul > li > a { + font-weight: bold; + font-size: 13px +} + +#docs .docs-nav > ul > li > ul { + margin-top: 7px +} + +#docs .docs-nav > ul > li { + color: #629f8d; + font-size: 13px; + font-weight: bold +} + +#docs .docs-nav > ul > li > ul a { + font-weight: normal +} + +#docs .docs-nav li { + list-style-type: none; + font-size: 12px; + border-top: 1px dotted #ccc; + padding-top: 6px; + padding-bottom: 5px +} + +.apidoc-jsplumb-logo { + display: none; + left: 50%; + position: absolute; + top: 10px +} + +#api-classes { + margin: 0; + padding: 0; + background-color: #f4f5ef; + font-size: 13px +} + +#api-classes li { + list-style-type: none; + margin: 0; + border-bottom: 1px dotted #ccc; + padding-top: 5px; + padding-bottom: 5px +} + +#api-classes li a { + color: #629f8d +} + +.yui3-tabview-panel { + background-color: #f4f5ef !important; + border: none !important +} + +#api-tabview-panel { + overflow: hidden +} + +#api-filter { + width: 100% +} + +.apidoc-main { + margin-left: 265px !important; + height: auto; + width: auto; + background-color: white; + border: none +} + +.docs-main { + margin-left: 30px +} + +.box.intro { + background-color: #f4f5ef; + padding: 14px; + margin-bottom: 19px; + border-radius: 3px; + font-size: 13px +} + +.apidoc-summary { + width: 150px +} + +.apidoc-detail { + margin-left: 160px +} + +.apidocs { + margin-top: 20px !important; + padding-left: 30px +} + +#api-options { + margin-top: 30px; + padding-left: 30px +} + +.apidoc-intro { + padding-top: 30px !important +} + +#api-list { + margin-bottom: 50px +} + +#api-list h2 { + display: none +} + +.index-item { + width: 30%; + float: left; + display: inline +} + +.index-list { + overflow: hidden +} + +pre.license { + padding: 15px; + word-break: normal; + word-wrap: normal; + white-space: pre-wrap +} + +.license-wrapper, .privacy { + margin-top: 50px; + text-align: left; + width: 75%; + margin-left: auto; + margin-right: auto; + padding: 15px +} + +.privacy { + font-size: 80px +} + +.community-demo .demo { + height: 650px; + position: relative; + overflow: auto; + background-color: white; + border-radius: 3px; + max-width: 1000px; + margin-left: auto; + margin-right: auto; + border: 1px solid #CCC; + margin-top: 73px; + width: 90% +} + +.product-matrix-container { + width: 100%; + font-size: 15px +} + +.product-matrix-container .high-title { + font-size: 28px +} + +.product-matrix-container tr:nth-child(odd) td { + background-color: #FBFBFB; + border-bottom: 1px solid #CFD0C9 +} + +.product-matrix-container tr:nth-child(even) td { + background-color: #E9EBDD; + border-bottom: 1px solid #CFD0C9 +} + +.product-matrix-container td { + border-left: 1px solid #CFD0C9 +} + +.product-matrix-container th { + border-bottom: 1px solid #CFD0C9 +} + +.product-matrix-container th, .product-matrix-container td { + padding: 10px +} + +.product-matrix-container a { + color: #629f8d; + text-decoration: none +} + +.product-matrix-container table { + width: 100%; + border: 1px solid #CFD0C9; + font-size: 90% +} + +.product-matrix-container table table { + border: none +} + +.product-matrix-container table table th, .product-matrix-container table table td, .product-matrix-container table table tr { + border: none +} + +.license-type .icon { + color: #a0b8b7; + font-size: 59px; + margin-left: 15px +} + +.license-type.divider { + border-bottom: 1px solid #CFD0C9; + padding-bottom: 20px; + margin-bottom: 10px +} + +.license-type .divider-color { + border-bottom: 1px solid #CFD0C9; + background-color: #f4f5ef +} + +.license-type .price-table .title { + color: #696b60; + font-size: 34px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 8px +} + +@media only screen and (max-width: 320px) { + .license-type .price-table .title { + font-size: 32px; + margin-bottom: 4px + } +} + +.license-type .price-table .sub-title { + color: #696b60; + font-size: 25px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 8px +} + +@media only screen and (max-width: 320px) { + .license-type .price-table .sub-title { + font-size: 25px; + margin-bottom: 4px + } +} + +.license-type .price-table .total-title { + color: #696b60; + font-size: 22px; + font-weight: 400; + line-height: 1.2em; + text-align: right +} + +@media only screen and (max-width: 320px) { + .license-type .price-table .total-title { + font-size: 22px + } +} + +.license-type .price-table .label { + color: #434343; + display: block; + font-size: 15px; + font-weight: 400; + padding: 0; + text-align: left; + white-space: normal; + margin-bottom: 10px; + line-height: 1.3em +} + +.license-type .price-table .price { + font-size: 15px; + font-weight: 700; + padding-left: 10px; + text-align: right +} + +.license-type .price-table .check-price { + padding-left: 10px; + width: 22px +} + +.license-type .price-table .total-price { + font-size: 18px; + font-weight: 700; + padding-left: 10px; + padding-right: 20px; + text-align: right; + width: 22px +} + +.license-type .btn-buy { + padding: 10px; + text-align: right +} + +.license-type .notes { + color: #8DA3A2; + font-style: italic; + padding-top: 40px; + padding-left: 20px +} + +@media only screen and (max-width: 320px) { + .license-type .notes { + padding-top: 0; + padding-left: 72px + } +} + +@media only screen and (min-width: 321px) and (max-width: 768px) { + .license-type .notes { + padding-top: 0; + padding-left: 72px + } +} + +@media only screen and (min-width: 769px) and (max-width: 1023px) { + .license-type .notes { + padding-top: 0; + padding-left: 72px + } +} + +.license-type button { + background: none; + border: none +} + +.payment-container { + width: 80%; + max-width: 1000px; + margin-right: auto; + margin-left: auto; + margin-top: 50px +} + +.item-packager * { + font-size: 12px +} + +.item-packager table { + margin: auto +} + +.package-form { + margin: auto +} + +.payment-form input:focus { + background-color: #cbeae1 +} + +.payment-form-inner { + overflow: hidden; + -webkit-transition: height 0.5s linear; + -moz-transition: height 0.5s linear; + -ms-transition: height 0.5s linear; + -o-transition: height 0.5s linear; + transition: height 0.5s linear +} + +.jtk-payment-form label { + display: block +} + +.jtk-payment-form label span { + font-size: 12px; + color: cadetblue +} + +.error { + color: red; + font-size: 11px +} + +.txtInv { + width: 450px; + height: 300px +} + +.formMessage { + min-height: 36px; + font-size: 12px +} + +.formMessage.error { + color: red +} + +.formMessage .wait { + width: 36px; + height: 36px; + float: left; + margin-right: 10px; + display: none +} + +.invoice-details table { + border: 1px solid #456; + border-collapse: collapse; + width: 100%; + border: 1px solid #CFD0C9 +} + +.invoice-details table th, .invoice-details table td { + padding: 10px; + text-align: center +} + +.invoice-details table td.item { + text-align: right +} + +.invoice-details td { + border-left: 1px solid #CFD0C9 +} + +.invoice-details tr:nth-child(even) td { + background-color: #E9EBDD; + border-bottom: 1px solid #CFD0C9 +} + +.colTotal { + font-weight: bold; + text-align: right !important +} + +.payment-form input { + font-size: 16px +} + +.payment-form button { + background: none; + border: none +} + +pre { + outline: 1px solid #ccc; + padding: 5px; + margin: 0 +} + +.string { + color: green +} + +.number { + color: darkorange +} + +.boolean { + color: blue +} + +.null { + color: magenta +} + +.key { + color: red +} + +.blog-content .w { + position: absolute; + background-color: white; + box-shadow: 0px 0px 2px black; + text-align: center; + width: 50px; + height: 50px; + border-radius: 3px; + cursor: pointer +} + +.blog-content .demo { + height: 340px; + margin-top: 15px; + margin-bottom: 15px +} + +.blog-content ._jsPlumb_overlay.label { + color: black +} + +.blog-content .highlight { + margin-top: 15px; + margin-bottom: 15px +} + +.blog-content h3 { + margin-top: 25px +} + +.blog-content h4, .blog-content h5, .blog-content h6 { + margin-top: 20px; + font-weight: bold +} + +.blog-content h4 { + font-size: 18px +} + +.contact-form { + width: 80%; + max-width: 700px; + margin-left: auto; + padding-bottom: 25px; + margin-right: auto +} + +.contact-form button { + background: none; + border: none +} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/demo-all.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/demo-all.css new file mode 100644 index 000000000..6d1a0eecc --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/demo-all.css @@ -0,0 +1,679 @@ +/** DISABLE TEXT SELECTION (SET ON BODY WHEN DRAGGING IS OCCURRING) **/ +._jsPlumb_drag_select * { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: -moz-none; + -ms-user-select: none; + user-select: none +} + +/** PAGE STRUCTURE **/ + +.dropdown { + display:inline; +} + +.dropdown-menu>li>a { + width:80%; + text-transform: uppercase; + font-size:12px; +} + +/** FB **/ +#like { + position: fixed; + width: 77px; + height: 70px; + border: 0; + right: 11px; + bottom: -40px; +} + +#retweet_button { + position: fixed; + bottom: 30px; + right: -7px; +} + +body { + padding:0; + margin:0; + font-family:'Helvetica Neue', Helvetica, Arial, sans-serif; + background-color:#eaedef; + +} + +#headerWrapper { + width:100%; + background-color:white; + position:fixed; + top:0;left:0; + z-index:100001; + height:44px; + padding:0; + opacity:0.8; +} + +#header { + margin-top:0; + height:44px; + font-size:13px; + margin-left:auto; + margin-right:auto; + padding-right: 50px; + padding-left: 50px; +} + +.explanation i { + float: right; + margin-right: 25px; + margin-top: 13px; + font-size: 25px; + cursor:pointer; +} + +.explanation i:hover { + color:orange; +} + +.logo { + font-size:30px; + color:#1f1f1f; + text-shadow: 1px 1px #ccc; + float:left; + /*background-image:url(logo-export-35h.png); + background-repeat:no-repeat; */ + width:154px; + height:44px; + background-position:0px 5px; +} + + #main { + margin-top:85px; + font-size: 80%; + width:75%; + margin-left:auto; + margin-right: auto; + height:600px; + text-align: center; + position: relative; + max-width:852px; +} + +.demo { + position: relative; + width:100%; + background-color:white; + height:563px; + overflow:auto; + margin-top:35px; + margin-bottom:25px; +} + +.explanation { + position: absolute; + text-align: center; + background-color: #7AB02C; + opacity: 0.8; + filter: alpha(opacity=80); + color: white; + width: 100%; + height: 54px; + z-index: 10000; + overflow: hidden; + box-shadow: 0px 0px 10px gray; +} + +.explanation.expanded { + height:auto; + min-height:54px; + max-height:100%; +} + +.commands { + margin-bottom:10px; +} + +.commands:hover { + z-index:10000; +} + +/* demo elements */ + +a, a:visited { + text-decoration:none; + /*color:#057D9F; */ + color:black; + border-radius:0.2em; + -webkit-transition: color 0.15s ease-in; + -moz-transition: color 0.15s ease-in; + -o-transition: color 0.15s ease-in; + transition: color 0.15s ease-in; +} + +a:hover { + color:#7AB02C; +} + +a:active { + color:#FF2300; +} + +.menu, #render, #explanation { + background-color:#fff; +} + +.menu { + height: 15px; + float:right; + padding-top:1em; + padding-bottom:0.4em; + background-color: transparent; + margin-right:30px; + font-size:12px; +} + + +.menu a { + margin-right: 19px; +} + +.otherLibraries { + display:inline; +} + +#render a { + margin-right:10px; +} + +.selected { + color:orange !important; +} + +.window, .label { + + text-align:center; + z-index:24; + cursor:pointer; + box-shadow: 2px 2px 19px #aaa; + -o-box-shadow: 2px 2px 19px #aaa; + -webkit-box-shadow: 2px 2px 19px #aaa; + -moz-box-shadow: 2px 2px 19px #aaa; + +} +path, ._jsPlumb_endpoint { cursor:pointer; } + +.cmd { + color:white; + margin-right:25px; +} + +.cmd:hover { + color:#FF2300; + text-decoration: underline; +} +.cmd:active { + color:#FF2300; +} + +.label { + font-size:13px; + padding:8px; + padding:8px; +} + +.component { + border:1px solid #346789; + border-radius:0.5em; + opacity:0.8; + filter:alpha(opacity=80); + background-color:white; + color:black; + padding:0.5em; + font-size:0.8em; +} + +.component:hover { + border:1px solid #123456; + box-shadow: 2px 2px 19px #444; + -o-box-shadow: 2px 2px 19px #444; + -webkit-box-shadow: 2px 2px 19px #444; + -moz-box-shadow: 2px 2px 19px #fff; + opacity:0.9; + filter:alpha(opacity=90); +} + +.window { + background-color:white; + border:1px solid #346789; + box-shadow: 2px 2px 19px #e0e0e0; + -o-box-shadow: 2px 2px 19px #e0e0e0; + -webkit-box-shadow: 2px 2px 19px #e0e0e0; + -moz-box-shadow: 2px 2px 19px #e0e0e0; + -moz-border-radius:0.5em; + border-radius:0.5em; + width:5em; height:5em; + position:absolute; + color:black; + padding:0.5em; + width:80px; + height:80px; + line-height: 80px; + -webkit-transition: -webkit-box-shadow 0.15s ease-in; + -moz-transition: -moz-box-shadow 0.15s ease-in; + -o-transition: -o-box-shadow 0.15s ease-in; + transition: box-shadow 0.15s ease-in; +} + +.window:hover { + border:1px solid #123456; + box-shadow: 2px 2px 19px #444; + -o-box-shadow: 2px 2px 19px #444; + -webkit-box-shadow: 2px 2px 19px #444; + -moz-box-shadow: 2px 2px 19px #fff; + opacity:0.9; + filter:alpha(opacity=90); +} + +.window a { + font-family:helvetica; +} + +.demo-links, .library-links { + position: fixed; + right: 0; + top: 44px; + font-size: 11px; + background-color: white; + opacity: 0.8; + padding-right: 10px; + padding-left: 5px; + text-transform: uppercase; + z-index:100001; +} + +.demo-links div, .library-links a { + display:inline; + margin-right:7px; + margin-left:7px; +} + +.demo-links i, .library-links i { + padding:4px; +} + +.library-links { + right: 454px; + height: 19px; + line-height: 19px; +} + +.current-library { + color:#7AB02C !important; +} + +/** Z-INDEX **/ + +._jsPlumb_connector { z-index:18; } +._jsPlumb_endpoint { z-index:19; } +._jsPlumb_overlay { z-index:20; } +/* +._jsPlumb_connector._jsPlumb_hover { + z-index:21 !important; +} +._jsPlumb_endpoint._jsPlumb_hover { + z-index:22 !important; +} +._jsPlumb_overlay._jsPlumb_hover { + z-index:23 !important; +} +*/ + +.aLabel { + background-color:white; + padding:0.4em; + font:12px sans-serif; + color:#444; + z-index:21; + border:1px dotted gray; + opacity:0.8; + filter:alpha(opacity=80); + cursor: pointer; +} +.aLabel._jsPlumb_hover { + background-color:#5C96BC; + color:white; + border:1px solid white; +} + +/* A TEST +._jsPlumb_element_dragging path { + z-index:21 !important; + stroke:green; +} + +._jsPlumb_endpoint._jsPlumb_element_dragging * { + fill:green; +} + +*/ + +/* ANOTHER TEST +._jsPlumb_endpoint_anchor_foo * { + fill:black; +} + +._jsPlumb_endpoint_anchor_bar * { + fill:red; +} +*/ + +/** +COMPLEMENT SCHEME + +*** Primary Color: + + var. 1 = #5C96BC = rgb(92,150,188) + var. 2 = #57788D = rgb(87,120,141) + var. 3 = #1E567A = rgb(30,86,122) + var. 4 = #89BCDE = rgb(137,188,222) + var. 5 = #9FC5DE = rgb(159,197,222) + +*** Complementary Color: + + var. 1 = #FFC275 = rgb(255,194,117) + var. 2 = #BF9D71 = rgb(191,157,113) + var. 3 = #A66D26 = rgb(166,109,38) + var. 4 = #FFD197 = rgb(255,209,151) + +ANALOGIC SCHEME + +*** Primary Color: + + var. 1 = #5C96BC = rgb(92,150,188) + var. 2 = #57788D = rgb(87,120,141) + var. 3 = #1E567A = rgb(30,86,122) + var. 4 = #89BCDE = rgb(137,188,222) + var. 5 = #9FC5DE = rgb(159,197,222) + +*** Secondary Color A: + + var. 1 = #6A6FC6 = rgb(106,111,198) + var. 2 = #616395 = rgb(97,99,149) + var. 3 = #222781 = rgb(34,39,129) + var. 4 = #9498E3 = rgb(148,152,227) + var. 5 = #A9ACE3 = rgb(169,172,227) + +*** Secondary Color B: + + var. 1 = #5BC793 = rgb(91,199,147) + var. 2 = #589578 = rgb(88,149,120) + var. 3 = #1E8151 = rgb(30,129,81) + var. 4 = #86E3B6 = rgb(134,227,182) + var. 5 = #9FE3C2 = rgb(159,227,194) + + +*/ + + +/* ---------------------- bootstrap dropdowns ------------------------- */ +.clearfix { + *zoom: 1; +} + +.clearfix:before, +.clearfix:after { + display: table; + line-height: 0; + content: ""; +} + +.clearfix:after { + clear: both; +} + +.hide-text { + font: 0/0 a; + color: transparent; + text-shadow: none; + background-color: transparent; + border: 0; +} + +.input-block-level { + display: block; + width: 100%; + min-height: 30px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.dropup, +.dropdown { + position: relative; +} + +.dropdown-toggle { + *margin-bottom: -3px; +} + +.dropdown-toggle:active, +.open .dropdown-toggle { + outline: 0; +} + +.caret { + display: inline-block; + width: 0; + height: 0; + vertical-align: top; + border-top: 4px solid #000000; + border-right: 4px solid transparent; + border-left: 4px solid transparent; + content: ""; +} + +.dropdown .caret { + margin-top: 8px; + margin-left: 2px; +} + +.dropdown-menu { + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + padding: 5px 0; + margin: 2px 0 0; + list-style: none; + background-color: #ffffff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + *border-right-width: 2px; + *border-bottom-width: 2px; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; +} + +.dropdown-menu.pull-right { + right: 0; + left: auto; +} + +.dropdown-menu .divider { + *width: 100%; + height: 1px; + margin: 9px 1px; + *margin: -5px 0 5px; + overflow: hidden; + background-color: #e5e5e5; + border-bottom: 1px solid #ffffff; +} + +.dropdown-menu > li > a { + display: block; + padding: 3px 20px; + clear: both; + font-weight: normal; + line-height: 20px; + color: #333333; + white-space: nowrap; +} + +.dropdown-menu > li > a:hover, +.dropdown-menu > li > a:focus, +.dropdown-submenu:hover > a, +.dropdown-submenu:focus > a { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; + background-image: -moz-linear-gradient(top, #0088cc, #0077b3); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); + background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); + background-image: -o-linear-gradient(top, #0088cc, #0077b3); + background-image: linear-gradient(to bottom, #0088cc, #0077b3); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); +} + +.dropdown-menu > .active > a, +.dropdown-menu > .active > a:hover, +.dropdown-menu > .active > a:focus { + color: #ffffff; + text-decoration: none; + background-color: #0081c2; + background-image: -moz-linear-gradient(top, #0088cc, #0077b3); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); + background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); + background-image: -o-linear-gradient(top, #0088cc, #0077b3); + background-image: linear-gradient(to bottom, #0088cc, #0077b3); + background-repeat: repeat-x; + outline: 0; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); +} + +.dropdown-menu > .disabled > a, +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + color: #999999; +} + +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + text-decoration: none; + cursor: default; + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} + +.open { + *z-index: 1000; +} + +.open > .dropdown-menu { + display: block; +} + +.pull-right > .dropdown-menu { + right: 0; + left: auto; +} + +.dropup .caret, +.navbar-fixed-bottom .dropdown .caret { + border-top: 0; + border-bottom: 4px solid #000000; + content: ""; +} + +.dropup .dropdown-menu, +.navbar-fixed-bottom .dropdown .dropdown-menu { + top: auto; + bottom: 100%; + margin-bottom: 1px; +} + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu > .dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + -webkit-border-radius: 0 6px 6px 6px; + -moz-border-radius: 0 6px 6px 6px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover > .dropdown-menu { + display: block; +} + +.dropup .dropdown-submenu > .dropdown-menu { + top: auto; + bottom: 0; + margin-top: 0; + margin-bottom: -2px; + -webkit-border-radius: 5px 5px 5px 0; + -moz-border-radius: 5px 5px 5px 0; + border-radius: 5px 5px 5px 0; +} + +.dropdown-submenu > a:after { + display: block; + float: right; + width: 0; + height: 0; + margin-top: 5px; + margin-right: -10px; + border-color: transparent; + border-left-color: #cccccc; + border-style: solid; + border-width: 5px 0 5px 5px; + content: " "; +} + +.dropdown-submenu:hover > a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left > .dropdown-menu { + left: -100%; + margin-left: 10px; + -webkit-border-radius: 6px 0 6px 6px; + -moz-border-radius: 6px 0 6px 6px; + border-radius: 6px 0 6px 6px; +} + +.dropdown .dropdown-menu .nav-header { + padding-right: 20px; + padding-left: 20px; +} + +.typeahead { + z-index: 1051; + margin-top: 2px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/cssgrids-min.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/cssgrids-min.css new file mode 100644 index 000000000..e9a991a8a --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/cssgrids-min.css @@ -0,0 +1,2 @@ +/* YUI 3.9.1 (build 5852) Copyright 2013 Yahoo! Inc. http://yuilibrary.com/license/ */ +.yui3-g{letter-spacing:-0.31em;*letter-spacing:normal;*word-spacing:-0.43em;text-rendering:optimizespeed}.opera-only :-o-prefocus,.yui3-g{word-spacing:-0.43em}.yui3-u{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.yui3-u-1,.yui3-u-1-2,.yui3-u-1-3,.yui3-u-2-3,.yui3-u-1-4,.yui3-u-3-4,.yui3-u-1-5,.yui3-u-2-5,.yui3-u-3-5,.yui3-u-4-5,.yui3-u-1-6,.yui3-u-5-6,.yui3-u-1-8,.yui3-u-3-8,.yui3-u-5-8,.yui3-u-7-8,.yui3-u-1-12,.yui3-u-5-12,.yui3-u-7-12,.yui3-u-11-12,.yui3-u-1-24,.yui3-u-5-24,.yui3-u-7-24,.yui3-u-11-24,.yui3-u-13-24,.yui3-u-17-24,.yui3-u-19-24,.yui3-u-23-24{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.yui3-u-1{display:block}.yui3-u-1-2{width:50%}.yui3-u-1-3{width:33.33333%}.yui3-u-2-3{width:66.66666%}.yui3-u-1-4{width:25%}.yui3-u-3-4{width:75%}.yui3-u-1-5{width:20%}.yui3-u-2-5{width:40%}.yui3-u-3-5{width:60%}.yui3-u-4-5{width:80%}.yui3-u-1-6{width:16.656%}.yui3-u-5-6{width:83.33%}.yui3-u-1-8{width:12.5%}.yui3-u-3-8{width:37.5%}.yui3-u-5-8{width:62.5%}.yui3-u-7-8{width:87.5%}.yui3-u-1-12{width:8.3333%}.yui3-u-5-12{width:41.6666%}.yui3-u-7-12{width:58.3333%}.yui3-u-11-12{width:91.6666%}.yui3-u-1-24{width:4.1666%}.yui3-u-5-24{width:20.8333%}.yui3-u-7-24{width:29.1666%}.yui3-u-11-24{width:45.8333%}.yui3-u-13-24{width:54.1666%}.yui3-u-17-24{width:70.8333%}.yui3-u-19-24{width:79.1666%}.yui3-u-23-24{width:95.8333%}#yui3-css-stamp.cssgrids{display:none} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/prettify-min.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/prettify-min.css new file mode 100644 index 000000000..d44b3a228 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/external/prettify-min.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/gollum-template.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/gollum-template.css new file mode 100644 index 000000000..34262f88f --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/gollum-template.css @@ -0,0 +1,749 @@ +/* + Gollum v3 Template +*/ + +/* jsplumb */ + +.markdown-body { + font-size: 12.5px; + line-height: 1.6; + background-color: white; + padding-left: 10px; + margin-left: 265px; + margin-top: 65px; + padding-right: 20px; + margin-right: 10px; +} + +html { background-color: white; } +body { font-family:'Helvetica Neue', Helvetica, Arial, sans-serif !important;background-color:white; } + +a[name]:before { + display:block; + content:" "; + height:50px; + margin-bottom:-18px; + margin-top:-79px; + visibility: hidden; +} + +/* corrections for jsdoc (move these out) */ +#main { + height:auto; + background-color: white; + border:none; + font-size: 85%; + text-align: left; + width: 90%; + max-width: none; +} +nav { + padding-bottom: 10px; + overflow-x: hidden; + overflow-y:auto; + height:100%; + background-color: white; + margin-top: 40px; + position: fixed; + left: 0; + border: none; + float: none; + margin-left: 0; + width:210px; +} + +nav a:visited { + color:#01a3c6; +} + +nav h2 { + display:none; +} + +#main article dd { + border-bottom: 1px solid #ccc; + padding-bottom: 26px; +} + +/* this is the location in source links */ +.details { + display:none; +} + +/* constructors */ +.container-overview { + /*display:none;*/ +} + +.apidoc-main { + margin-left: 255px !important; + height: auto; + width: auto; + background-color: white; + border: none; +} + +.apidoc-summary { + width:150px; +} +.apidoc-detail { + margin-left:160px; +} + +#qunit-tests li, #qunit-testresult { + background-color: white !important; +} + +#qunit-userAgent { + text-shadow:none; +} + +/* / jsplumb */ + +/* added by SP */ + +#headerWrapper { + background-color:#eaedef; +} + +.nav { + width: 240px; + margin-left: 15px; + font-size: 12px; + position: fixed; + height: 88%; + overflow-y: auto; + overflow-x: hidden; + background-color: white; + padding-left: 5px; +} + +.nav ul { + padding-left: 25px; + margin-top:8px; +} + +.nav ul li { + margin-bottom:5px; +} + +html, body { + color: #333; +} + +body { + font: 13.34px helvetica,arial,freesans,clean,sans-serif; + line-height: 1.4; +} + +img { + border: 0; +} + +a, a:visited { + color: #4183C4; + text-decoration: none; + padding:0.3em; +} + +a.absent { + color: #c00; +} + +.markdown-body a[id].wiki-toc-anchor { + color: inherit; + text-decoration: none; +} + +.markdown-body>*:first-child { + margin-top: 0!important; +} +.markdown-body>*:last-child { + margin-bottom: 0!important; +} +.markdown-body a.absent { + color: #c00; +} +.markdown-body a.anchor { + display: block; + padding-left: 30px; + margin-left: -30px; + cursor: pointer; + position: absolute; + top: 0; + left: 0; + bottom: 0; +} +.markdown-body h1, +.markdown-body h2, +.markdown-body h3, +.markdown-body h4, +.markdown-body h5, +.markdown-body h6 { + margin: 20px 0 10px; + padding: 0; + font-weight: bold; + -webkit-font-smoothing: antialiased; + cursor: text; + position: relative; +} +.markdown-body h1:hover a.anchor, +.markdown-body h2:hover a.anchor, +.markdown-body h3:hover a.anchor, +.markdown-body h4:hover a.anchor, +.markdown-body h5:hover a.anchor, +.markdown-body h6:hover a.anchor { + background: url(../images/pin-20.png) no-repeat left center; + text-decoration: none; +} +.markdown-body h1 tt, +.markdown-body h1 code, +.markdown-body h2 tt, +.markdown-body h2 code, +.markdown-body h3 tt, +.markdown-body h3 code, +.markdown-body h4 tt, +.markdown-body h4 code, +.markdown-body h5 tt, +.markdown-body h5 code, +.markdown-body h6 tt, +.markdown-body h6 code { + font-size: inherit; +} +.markdown-body h1 { + font-size: 28px; + color: #000; + margin-top: 50px; + margin-bottom: 20px; +} +.markdown-body h2 { + font-size: 24px; + border-bottom: 1px solid #ccc; + color: #000; + margin-top: 40px; + margin-bottom: 20px; +} +.markdown-body h3 { + font-size: 18px; + margin-top: 30px; + margin-bottom: 15px; +} +.markdown-body h4 { + font-size: 16px; +} +.markdown-body h5 { + font-size: 14px; +} +.markdown-body h6 { + color: #777; + font-size: 14px; +} +.markdown-body p, +.markdown-body blockquote, +.markdown-body ul, +.markdown-body ol, +.markdown-body dl, +.markdown-body li, +.markdown-body table, +.markdown-body pre { + margin: 15px 0; +} +.markdown-body hr { + background: transparent url(../images/dirty-shade.png) repeat-x 0 0; + border: 0 none; + color: #ccc; + height: 4px; + padding: 0; +} +.markdown-body>h1:first-child, +.markdown-body>h2:first-child, +.markdown-body>h3:first-child, +.markdown-body>h4:first-child, +.markdown-body>h5:first-child, +.markdown-body>h6:first-child { +} +.markdown-body h1+h2{ + margin-top: 30px; +} +.markdown-body h2+h3{ + margin-top: 10px; +} +.markdown-body a:first-child h1, +.markdown-body a:first-child h2, +.markdown-body a:first-child h3, +.markdown-body a:first-child h4, +.markdown-body a:first-child h5, +.markdown-body a:first-child h6 { + margin-top: 0; + padding-top: 0; +} +.markdown-body h1+p, +.markdown-body h2+p, +.markdown-body h3+p, +.markdown-body h4+p, +.markdown-body h5+p, +.markdown-body h6+p { + margin-top: 0; +} +.markdown-body li p.first { + display: inline-block; +} +.markdown-body ul, +.markdown-body ol { + padding-left: 30px; +} +.markdown-body ul li>:first-child, +.markdown-body ol li>:first-child { + margin-top: 0; +} +.markdown-body ul li>:last-child, +.markdown-body ol li>:last-child { + margin-bottom: 0; +} +.markdown-body dl { + padding: 0; +} +.markdown-body dl dt { + font-size: 14px; + font-weight: bold; + font-style: italic; + padding: 0; + margin: 15px 0 5px; +} +.markdown-body dl dt:first-child { + padding: 0; +} +.markdown-body dl dt>:first-child { + margin-top: 0; +} +.markdown-body dl dt>:last-child { + margin-bottom: 0; +} +.markdown-body dl dd { + margin: 0 0 15px; + padding: 0 15px; +} +.markdown-body dl dd>:first-child { + margin-top: 0; +} +.markdown-body dl dd>:last-child { + margin-bottom: 0; +} +.markdown-body blockquote { + border-left: 4px solid #DDD; + padding: 0 15px; + color: #777; +} +.markdown-body blockquote>:first-child { + margin-top: 0; +} +.markdown-body blockquote>:last-child { + margin-bottom: 0; +} +.markdown-body table { + padding: 0; + border-collapse: collapse; + border-spacing: 0; +} +.markdown-body table tr { + border-top: 1px solid #ccc; + background-color: #fff; + margin: 0; + padding: 0; +} +.markdown-body table tr:nth-child(2n) { + background-color: #f8f8f8; +} +.markdown-body table tr th { + font-weight: bold; +} +.markdown-body table tr th, +.markdown-body table tr td { + border: 1px solid #ccc; + text-align: left; + margin: 0; + padding: 6px 13px; +} +.markdown-body table tr th>:first-child, +.markdown-body table tr td>:first-child { + margin-top: 0; +} +.markdown-body table tr th>:last-child, +.markdown-body table tr td>:last-child { + margin-bottom: 0; +} +.markdown-body img { + max-width: 100%; +} +.markdown-body span.frame { + display: block; + overflow: hidden; +} +.markdown-body span.frame>span { + border: 1px solid #ddd; + display: block; + float: left; + overflow: hidden; + margin: 13px 0 0; + padding: 7px; + width: auto; +} +.markdown-body span.frame span img { + display: block; + float: left; +} +.markdown-body span.frame span span { + clear: both; + color: #333; + display: block; + padding: 5px 0 0; +} +.markdown-body span.align-center { + display: block; + overflow: hidden; + clear: both; +} +.markdown-body span.align-center>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: center; +} +.markdown-body span.align-center span img { + margin: 0 auto; + text-align: center; +} +.markdown-body span.align-right { + display: block; + overflow: hidden; + clear: both; +} +.markdown-body span.align-right>span { + display: block; + overflow: hidden; + margin: 13px 0 0; + text-align: right; +} +.markdown-body span.align-right span img { + margin: 0; + text-align: right; +} +.markdown-body span.float-left { + display: block; + margin-right: 13px; + overflow: hidden; + float: left; +} +.markdown-body span.float-left span { + margin: 13px 0 0; +} +.markdown-body span.float-right { + display: block; + margin-left: 13px; + overflow: hidden; + float: right; +} +.markdown-body span.float-right>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: right; +} +.markdown-body code, +.markdown-body tt { + margin: 0 2px; + padding: 0 5px; + white-space: nowrap; + border: 1px solid #ddd; + background-color: #f8f8f8; + border-radius: 3px; +} +.markdown-body pre>tt, +.markdown-body pre>code { + margin: 0; + padding: 0; + white-space: pre; + border: none; + background: transparent; +} +.markdown-body pre { + background-color: #f8f8f8; + border: 1px solid #ccc; + font-size: 11.5px; + line-height: 18px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} +.markdown-body pre pre, +.markdown-body pre code, +.markdown-body pre tt { + background-color: transparent; + border: none; +} +.markdown-body pre pre { + margin: 0; + padding: 0; +} +.toc { + background-color: #F7F7F7; + border: 1px solid #ddd; + padding: 5px 10px; + margin: 0; + border-radius: 3px; +} +.toc-title { + color: #888; + font-size: 14px; + line-height: 1.6; + padding: 2px; + border-bottom: 1px solid #ddd; + margin-bottom: 3px; +} +.toc ul { + padding-left: 10px; + margin: 0; +} +.toc>ul { + margin-left: 10px; + font-size: 17px; +} +.toc ul ul { + font-size: 15px; +} +.toc ul ul ul { + font-size: 14px; +} +.toc ul li{ + margin: 0; +} +#header-content .toc, +#footer-content .toc, +#sidebar-content .toc { + border: none; +} +.highlight { + background: #fff; +} +.highlight .c { + color: #998; + font-style: italic; +} +.highlight .err { + color: #a61717; + background-color: #e3d2d2; +} +.highlight .k { + font-weight: bold; +} +.highlight .o { + font-weight: bold; +} +.highlight .cm { + color: #998; + font-style: italic; +} +.highlight .cp { + color: #999; + font-weight: bold; +} +.highlight .c1 { + color: #998; + font-style: italic; +} +.highlight .cs { + color: #999; + font-weight: bold; + font-style: italic; +} +.highlight .gd { + color: #000; + background-color: #fdd; +} +.highlight .gd .x { + color: #000; + background-color: #faa; +} +.highlight .ge { + font-style: italic; +} +.highlight .gr { + color: #a00; +} +.highlight .gh { + color: #999; +} +.highlight .gi { + color: #000; + background-color: #dfd; +} +.highlight .gi .x { + color: #000; + background-color: #afa; +} +.highlight .go { + color: #888; +} +.highlight .gp { + color: #555; +} +.highlight .gs { + font-weight: bold; +} +.highlight .gu { + color: #800080; + font-weight: bold; +} +.highlight .gt { + color: #a00; +} +.highlight .kc { + font-weight: bold; +} +.highlight .kd { + font-weight: bold; +} +.highlight .kn { + font-weight: bold; +} +.highlight .kp { + font-weight: bold; +} +.highlight .kr { + font-weight: bold; +} +.highlight .kt { + color: #458; + font-weight: bold; +} +.highlight .m { + color: #099; +} +.highlight .s { + color: #d14; +} +.highlight .na { + color: #008080; +} +.highlight .nb { + color: #0086B3; +} +.highlight .nc { + color: #458; + font-weight: bold; +} +.highlight .no { + color: #008080; +} +.highlight .ni { + color: #800080; +} +.highlight .ne { + color: #900; + font-weight: bold; +} +.highlight .nf { + color: #900; + font-weight: bold; +} +.highlight .nn { + color: #555; +} +.highlight .nt { + color: #000080; +} +.highlight .nv { + color: #008080; +} +.highlight .ow { + font-weight: bold; +} +.highlight .w { + color: #bbb; +} +.highlight .mf { + color: #099; +} +.highlight .mh { + color: #099; +} +.highlight .mi { + color: #099; +} +.highlight .mo { + color: #099; +} +.highlight .sb { + color: #d14; +} +.highlight .sc { + color: #d14; +} +.highlight .sd { + color: #d14; +} +.highlight .s2 { + color: #d14; +} +.highlight .se { + color: #d14; +} +.highlight .sh { + color: #d14; +} +.highlight .si { + color: #d14; +} +.highlight .sx { + color: #d14; +} +.highlight .sr { + color: #009926; +} +.highlight .s1 { + color: #d14; +} +.highlight .ss { + color: #990073; +} +.highlight .bp { + color: #999; +} +.highlight .vc { + color: #008080; +} +.highlight .vg { + color: #008080; +} +.highlight .vi { + color: #008080; +} +.highlight .il { + color: #099; +} +.highlight .gc { + color: #999; + background-color: #EAF2F5; +} +.type-csharp .highlight .k { + color: #00F; +} +.type-csharp .highlight .kt { + color: #00F; +} +.type-csharp .highlight .nf { + color: #000; + font-weight: normal; +} +.type-csharp .highlight .nc { + color: #2B91AF; +} +.type-csharp .highlight .nn { + color: #000; +} +.type-csharp .highlight .s { + color: #A31515; +} +.type-csharp .highlight .sc { + color: #A31515; +} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.eot b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.eot new file mode 100644 index 0000000000000000000000000000000000000000..a298d34b6af12cfd1ea14da46a74117e45907f34 GIT binary patch literal 5328 zcmbtYU2Gjk6`tAIo!Q;{vwQ!4e0_a?oNFg`li1hJO_Q{Ckdg+GwxKO)t3EVtk|vGn zIBEh)X{FvuAb~)okRU-HfCq&7fJ)&3RVr0o#7iXvMW|0aqzLFkkl+C!KuWIp&dgqW zow_YQqy0H^=FFM1=gj$LcHYS|HjSGzi)}8Py~v4k^w?%T$(pkF$hEOs+Zao;C)i20 z!j^Hbu=5Z|v-{X-c7}bHJ;|2XQ{WWYad4hu7a>bB4K~AevfWzt*4|*!fC<)Tg6+Qd z{#~;{R_z1lXSh$CTwc0x{ZsG10HGS{51d)LcmeMab$YvJo_zZ8f1N-06Vxw*-9LMJ z>6HD({2|6N|3v$qvtX#7i(fI8rQyfVE?>IbVf>G%KY;q&lPf2evagg+q5dV*Ys*WQ zFR%jtChFfuy>WhN`SgR8AN&RNUto+w7gjD_f}JS&B(*bPGyWoT7_+`@{Sut7nK%D4 z>vE6eVui!(&1I3X>!Da(TV;y^HyVe|C%Fbabl_;jJjSKgJhQcAlDTNZ@T~E^ydJLI zTw5b?)Y$bv*ZA5Ws&?T<)K53+2WK3zf!1cYm>j*^_0SvRe+-YawN>jHtgbTVv@`Ab z-u&F2-kp3uFSJ`yrTHlDs&>X&TBc_IlJ>SrmCCT ztxg+~XvMY80aJ6jvt;)C0X{$1nK#4PEIk?qV_~M2OlD=+2s7<$x}D4KC`}(7tu;Bf z_`zp-y%Q5MVGBEzOtlKBN-|kYREwoM$5mRYKsmnSc#hwxR2Nz!cQl%JZIda9t9^8G z`|;_oUpspA9v;?G=~BWPDBrdf_bNfq%z2?yz6dI==QV4iN2g^{;u5XV+C96Il~lTx z9_f~foirD=@ExmjXk?_LEWu3~o6qHoywFT0Qrs%GlgZTb@#F8F6-wCBPE^vVI_4lE zyS55Hud*_qfTwl1jQ=8M%yr1qQ3#Cl;T`ZMjDtSz2|upOqt`Cpp&1cfu`ntV!1X6$ z(rLAKP>^RJj~MD+QEW{BKl-WVNBO$O&4ihvG@~|O-B~?(KA^ggkJ)XpbFUvdeC*ia zL$9CPp!n{fk;#nb5o`*%bb^GUkU37$(Xn%!gzfmY9?RlW7D&HJQk}Ued8qoTTUG6Uk~|J}5s~C`=WLQ-#80 z{-dPD>Mb78zPa&^(XBt#x|=FlG8C!9g~j0jC$iUe9ov@<8K~UA^)jB9_wwUmrk)}% zw6eMv^2~+l%7*u-NZU5vgg4+yXyrWH3d2S^UC)H$IX~|~6Z9!$9ljp{fV>j$5k|Ib zI56s^vWdhoypX1A135GeG@roLL$b~m zfmhvlDq{&cz;VrMPi`b{96=1m83c$>N~1)3CKm&M?mphr(TPLF2Ci+!6+*_?wKdG_ zncW04aqJ_=OVbtqR{DCgip9*rH`6K>yJ&jEVah0JN%GUWO+BS&jZq)h`r*!a_5eT4 zALdUy!XLl!hREFbtH=ya>jbt0rHUnmtpGJr5T*f@bY|)NLULJrxFpqsDCZ&uI-As& zmM}O-xjR(37pgQO5Sm6Rfo#av^^`@f>(POAgaMvo1My69OF?3!4-laN(L%~&@uSPe z!c4e~4ocL>2=fIPN5c_4wLuXy49B6)F5u&qar7_*WdIa22H=AXaRbad0v#aE$SUBT zKGP$aP}eU^rG$$s)OhQfe)U_3{RN>Er2;6LqH z?OTiQ9K6fFf_8K;zA~`4RR|yg!NKqJ0%HjbpbK8>YUvX#m_bWVJPeSbxM?8Ar~7g} z4ESWy6pg2yqzL9ign_g~4H${6*XC>2(E3Qtx+|HWjX?1AbVC#plA;YIT9D=iR2e}V zQNXN`xjxj!939OvjACXPd>;!6Fv()iWB=V3kK#vW85pgz#_Tgq!i;_tY)?gCZEzx< z;@AO4_`-F9nvA@I>wU5j9OdG0x{=FG77N?6xn??5RIWStsZ0placq&0{7+cAh=%ia zW0A&!9=cxE_j9fnD3t)~oU7bIdhonbGW2Qth$2JJ52bX)NLcZ7sf6KpAwOMy391rm z@Ez((Y7>e-rsFoUCMT4h{X!LxB7i^O9g2{Srug5S$%Rs}JhNlRQ;R0CkhcrV+b4JFl=ixv&QecU zrCzPp&1H+&dRqKFY)l0~izgkA-b5YW#6)|<#9Nb))SWzOJ-7XEwL01!tKYY)vAGn{JFb}r8_n(3V}icj#SHdb{39h5cBM{Iy4a&BnMRGWSHc_uOWVr5 zMzDv^BcNCKeq72Pe2WKD)$0Dn&im?PZEkHFs~@{fLpMQ$C9TfEN@Yw~xkf6LSD3g# z#g{*VPN?<;T#Mf(P+7u7b(>_KIJvUCvU2{Gv%k&few#Y5!}{d!5^LaO@HEZ<={#_WUBdem bc#pBC@%*GdNxVBcN!&?})Msl%Y+e2h=t331 literal 0 HcmV?d00001 diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.svg b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.svg new file mode 100644 index 000000000..fbee15942 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.svg @@ -0,0 +1,19 @@ + + + +Generated by IcoMoon + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.ttf b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/ico-jsplumb.ttf new file mode 100644 index 0000000000000000000000000000000000000000..9ed2fe64a52cdd3f01faf6efb61f7c56fa106fb0 GIT binary patch literal 5164 zcmbtYU2Gjk6`r5nncclVd;fpz>+AdDTsyIw*uHjdo20dal(dNShqR=v`p~$En;+G2 z)C82$N_8cWK%hcNkf0C1144a3rSO0%m8ve{B@%)n)F&QV1oR3AV;0o4)t{J+om>?*r#&_#Z#9vUL91r`~&>Fh)IrqLcd zy>jtVhw(q6{Q%l?PpqC;%Dr4UiT0P!uB|LxI?syyn`nO@?Z&yKmE{MkKllsUzrY-a z&aYm$2s=>vEsuVui!(?PZa%YZ*5_)J;a#X&bH@!^K*N9ckunZ*lsDE<|DkT+gY)=zP6UF zls~=j{KJ)+*7CdguPzGq3O}{?SiRnOCGh>B>_b29lVLP>!(s9`dm4>2hZ21Uht8g* zck}Vx+$t{?O2s-a8_u}t1*g2pnJ&!Ors-<8I&Daz7j=^Zrr~sF$?W+9e15JoZ>Muu zdL$E$X0o+pGN&?)Otzg%xATQv<*6ehwI=6+AAGvkJ3g)wj&xGVRI8Y(CX=PaP^o;! zm`*DlYBz9Q-wis|p@r7)?TzN0J5)-cwvSBgJT~>hJ4cS(!!xy1x||Sw9XO8Wel-l6 zc|W6cAj7KX`_0yW3T5LoBK zJK&952YuWXe%zGDs6D(xD6~ zgk7SvqPExWtXVuCP+cs<>=x|oYljZsci-VdubthZ_;lFFX2%K$HicZdVM0^LTsP^O z*tu@PaRbNo9oKUlC8ZL=5fm|{bRI&SYn_t5Qfc4I`9UEF>zS~T$&6;gdZ<#Gv_J(7 zb|k7Rgy2GIkGm?BhZ2MyEJsLJO6^GBabSxvMc#n#59P3SZ1FnQt&U39y zrjbt9vzf7cQ1GD%`ZTf*&yN5=UQ750GYba}j7I5PA~77^Lnb-$e{sNvxeM4l$g>)2 zvVH6kEYbksqFKd}R8~H4plhWSuPmue$M6#ujvdqs|*oZY6IVK`h2u1c*?| zphSBn9|M5yKHf9Yi9^K}u5HH^LdICVIn3;x-3Bvp>?6oaQ;k0>J-ywM{LCZ#@$0Y4?DfCOY=7A#u#l80LPAqL|0=_1Pz0EXs`$P zc;7r`8iFzaik$=SL56rC)*XQk5NCKDa8HlvkWnx^^4y2Gw?{UdB|I&`gZ$uvG~P`vLrC9BX_l`0oDO{440k0P8CYdp8RKL?GDzo!MZ7 z!~~|`wyBmLQNRq^dg5V#48_d=IUYSwn_<8slcs1s<0MTmpFtQ%OVojx$a-VGaSiQ{ z)NO{63C0Kn-z+yoA)zSRP+|mWT|ku;bPxrs8kJvz+L)uGRfbvYDueH1K>;QS_8iXN zYw}Tcl&t`xP1e|RrcIcUkAm&V2&^qm#8Vt6;0Ry1Nl=@Sw{vq&wt^#E9!@v%`H50- zXD;7Nr%KxM`ae|(>A0>V6N>){TNlxA-ZVC8Z0H%!&jmr=^Fyr@V4d}}S4{Vx(^_Q$ zIzFPPj2~o_^5k%)>YGx{WX6hxsmhB`mC*g~&`?sF(EKq&znCfqiJa#pEkEgbxkOM- zz4>Nks!$xu-1uR#sBtLubTRq47zzJr)`I_jFBjMpTVkJQud?5;YaH(^aZg&%85Jc1 z$`-S+?a{HD&fmQq@x3gDXT@@RzGEbefOTjTobhtZmC-h7x6kN+7r7tkYOBG@g|rcRQV>o)qO?t=7%wN;rB7{w@xtlAy&`u1|NOj%{P2 zKVsr;NJyGNz7o&wJUlcs(jKiJ-P71VG&GqODyW87YYOM88s$6c%!7^QPVtzeXZNsz zeGl(QNsUvfn^YdoXj-MwqU=>LhrrSi`Bw?{@OT9D8qbfao&L9YI5{-5zp?vheYDNR zj?wykw;1Rqh!9G24pyt9Qsf({R6%3mhSfm*2s)uUkZ>(tn?Ql_pYm{~;Tvzt4fzIp zg0UU9@)@7wg5|h(4$EW@t@2KbkYdm^V1)Drr3$pT23-TjCLtWnhVEM3*#sIkJPZG0XCm5VCA6%(!VI$! z9k4leg1+83J~*V)(pIOXtxii@otCybEv+#2wrH%?c?Nn{vDdBQca9xn%j`*Zft@j} z2Ag5K*)&=)nKLI=S5{ZgZD(S;TxO@(XOR|5P_S(PJ8YC)WDQ6xV-lKTiCx6~BzTXp Xr*QqGnd0uqjNRl&^KFfYo0oqBE;ctZIadwB5o0BTH2DP>O^9Gv}Mx{lYy93yd?Q;zgD+|C98*QM%{;UDJ$l4{gV(gn7O1#PZ@3 z;GIVO0V-EN{r>Z(7S9v!r>K)GmFU#tPdx_S&q1zI`PaFFKR&&*c#^UFC(*u_iu1Geubd#c-=bcll7D63DH|GNF>e`Yh>M?IN1 z)NM`kj9rc7+WH!smndj7K8=MM=3n4RmWp^%YmqrdG7S$2(3~~iS68F;>+9=AzVSZ0 z8k!nk|HGhDx)%2{jpo4_hisUz1smPljOk7LAH(BpeNDWJQ4ccawsY;-?(Cku-8=Yx zUTU|L&hlYCquV(#zqY!X8>oC{?)irXYFf+h6}~nv*sJ{1-lO$;%o4i24NOYh`kJGoU}Dwa!iUNM|8(+W;ygR{FhWviyC-RiUMOa3spr(&@a48d0vD&$bK29hJ$$!?h;of**Xk+dV#} zQjT;o=}fDXsixEA)L^-C$EeOK9cnjlUEd8l)xo*e(Cv-po!eAKA-4~YZ$CQujdu?p zKEk6~CR<5~o(>#GbH5sf&4M2(9mufi`F^uDe0Wl&6|!s%*N*H?S2NjKc4($j?qs=i zWZ;UNma9%I`$w|c6|+gUSk7% z44yX2W&IaBV^4=X9WQ}(KD-0on03&{J>kaoLEL}7jWZ=HR-h4J7|%o zAdfXPz2ddC3wZOVkssz88n+U5i_(tTnrEiX=J}B7QZX@Z!Op&ZXyM*_7Y@CCc9Y_} z!$vMQTEt@0k}Ee%X<9PZO}l38TsP&of#dp)>p6~+QVHP*S}~<`0YaQ>osqs$S>Mb1 zK`{vHQP_y0ktnQ(Dx*mYR8VI}BD+EeE~NIjt1<;B!P0}}23(Oj+(hJ)!;(eu-;gXE@tub4^?hIT^5@lt7`T%IVE#)~(TmTMpI zi1E#}x2rHqAu7p<3^Q|aqWV7{LG+GFXJ~Tm}M$}>cSOCat2_M0-aNxkWm(HhB zL*Wq`k|X~Y2Yi&ffX)3ltFb2A#~wzkHEpov3_Q&=E%xN%cx&foa)1H9)vzc5y6~lMh@!)}E^j3=Iub=Gx-rO}aO^x;md3@cba~y@AXoCD`gFXLU8G zX0wf4eNVAak!wcF4K!X`<7+)Y_-4mVss{|;)V|L6+C75TleqiS|?>0RS`mc-O2>5-K)vZ7Z%2GA8nkVP^027MMw5 zA3Zxah(Kr>s|2zkUN=G(v2Lsb>j(pU*8$?$;8v2vNFN}=0HQ$1Dft;6LM7<6FUZ_TJ%N zMLRlJUs>3@(Goxeg1z6F14c*~FbRJfYH5lB!=R%lxeSn@bu&PYsRwFf88Bti6x%aS z(ggDnmVvay4X{L`H^Vosq4SZNO;;L%83Y#JY&WbzO3`XVi4mlI0aaGe!75?+JG6p8Ej9)U~O?C8REDB$N0ic zfZB+>ott~I6&&VrA=@Yv#>=Jc`9d?BDQnN`{Y0gt z9|Q%@54BE#b=K2fDcgHaYZV1_eMC}`A4E!daww|$CRL+ov{alNcoC{ny7yh`N@`P@ zKWgX~GnF8f_q?>_r#&y93M!c^R|Y1FrP1j657H%#OR1+z>CY!f_)oJI{P%k~$0pe# z`yzXd{hD3ncxOp^(t^&2C>v0=n2lqPuHAJ1?ruw-WeGehRob&1BVh!rL*vC6t0Y_* zACva@j4ybx`+=@D8*D7$V8QEyeS@$-Iuiq`S@}6m=gSSx;FM@8M!930i#R`t(oK(Jf50$4vYi5|XBquf((47X}B1+avY+b~W}74o+l+3aTOY zn!>%RM)8h3^3y4r6N7{M8$0i-kF>eiHd4R$76aV`5kiU1!D@9xib5lkDQaxouo|czLMK!Q z60XH-6DTnLQy%U#eEo`Cmv6Gi8QXR%pYk~#*p7SmV4LisUEXOCQuLepjF8@-RFO7U zzp2j{;b4}hY3KKw`iwc=S3M^G*?Wt3?V0AtOLPpuJxcW6>b*thFOD+LxkUb=D>d(e zYtFxL zGtj$&vu*{ybL=QvVo$R3?2M^3*c98zcB7V%IdfuVd1d9?Rwjqf1zS3> p1*7Z&Yd~TNM##h>yMX_b;62Ko!t+zc#NF{Qc9J9MOV>@(zX5o735x&# literal 0 HcmV?d00001 diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-defaults.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-defaults.css new file mode 100644 index 000000000..1fb967b39 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-defaults.css @@ -0,0 +1,553 @@ +/* + Default styles for jsPlumb Toolkit + + Copyright 2015 https://jsplumbtoolkit.com +*/ + +/* --------------------------------------------------------------------------------------------- */ +/* --- SURFACE WIDGET -------------------------------------------------------------------------- */ +/* --------------------------------------------------------------------------------------------- */ + +/* + Assigned to every node managed by an instance of the Toolkit. They are required to be positioned absolute, to + enable dragging to work properly. +*/ +.jtk-node { + position: absolute; +} + +/* + This style was created in response to this Chrome bug: + http://stackoverflow.com/questions/13758215/artifacts-when-css-scaled-in-chrome + + Basically it's about how sometimes there can be artefacts left on screen when the user drags an element. It seems + the issue has been fixed in more recent versions of Chrome, but the style is left here in case you come across + the problem. +*/ +.jtk-node.jsplumb-drag { + /*-webkit-backface-visibility: hidden;*/ +} + +/* + Assigned to an element that is the `Container` in a `render` call. + Elements that are acting as Surface widgets should have overflow:hidden set to prevent libs from + scrolling them during drag (we don't want scrollbars; we have an infinite canvas). Position is set to + `relative` as this is the parent for nodes, which are positioned absolute (and for absolute positioning + to work, you need to ensure the parent node has `position:relative`). This style also sets some default + values for the cursor - using a `grab` cursor where supported. +*/ +.jtk-surface { + overflow: hidden !important; + position: relative; + cursor: move; + cursor: -moz-grab; + cursor: -webkit-grab; + + /* + For IE10+. As discussed on this page: + + https://msdn.microsoft.com/en-us/library/ie/jj583807(v=vs.85).aspx + + Microsoft have very helpfully implemented default behaviours for a bunch of touch events and + then consumed the events so you don't have to be bothered by them. They've "done a lot of research" + about this stuff and put together a really great default experience for everyone in the entire world. + */ + touch-action:none; + + /* + Another Chrome issue that appears to have been fixed in later versions + http://stackoverflow.com/questions/15464055/css-transition-effect-makes-image-blurry-moves-image-1px-in-chrome + */ + /* + -webkit-backface-visibility: hidden; + -webkit-transform: translateZ(0) scale(1.0, 1.0); + */ +} + +/* + Assigned to the surface when it is being panned. The default is to change the cursor (in browsers that support + a `grabbing` cursor), and to disable tex selection. +*/ +.jtk-surface-panning { + cursor: -moz-grabbing; + cursor: -webkit-grabbing; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* + The work area in a surface renderer. +*/ +.jtk-surface-canvas { + overflow: visible !important; +} + +/* + For IE10+. Discussed above in the .jtk-surface styles. This one is specific to elements that are configured + to be droppable on a Surface via its `registerDroppableNodes` method. +*/ +.jtk-surface-droppable-node { + touch-action:none; +} + +/* + Assigned to a Surface widget when panning is disabled (and therefore the app is relying on scrollbars when the content overflows). +*/ +.jtk-surface-nopan { + overflow: scroll !important; + cursor:default; +} + +/* +Assigned to tile images in a tiled background +*/ +.jtk-surface-tile { + border:none; + outline:none; + margin:0; + -webkit-transition: opacity .3s ease .15s; + -moz-transition: opacity .3s ease .15s; + -o-transition: opacity .3s ease .15s; + -ms-transition: opacity .3s ease .15s; + transition: opacity .3s ease .15s; +} + +/* + Assigned to the element used for node select with the mouse ("lasso"). +*/ +.jtk-lasso { + border: 2px solid rgb(49, 119, 184); + background-color: WhiteSmoke; + opacity: 0.5; + filter: alpha(opacity=50); + display: none; + z-index: 20000; + position: absolute; +} + +/* + This class is added to the document body on lasso drag start and removed at the end of lasso dragging. Its purpose + is to switch off text selection on all elements while the user is dragging the lasso. +*/ +.jtk-lasso-select-defeat * { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* + Assigned to some element that has been selected (either via lasso or programmatically). +*/ +.jtk-surface-selected-element { + border: 2px dashed #f76258 !important; +} + +/* + Assigned to all pan buttons in a surface widget. +*/ +.jtk-surface-pan { + background-color: Azure; + opacity: 0.4; + filter: alpha(opacity=40); + text-align: center; + cursor: pointer; + z-index: 2; + -webkit-transition: background-color 0.15s ease-in; + -moz-transition: background-color 0.15s ease-in; + -o-transition: background-color 0.15s ease-in; + transition: background-color 0.15s ease-in; +} + +/* + Specific styles for the top and bottom pan buttons. + Top/bottom are 100% width and 20px high by default +*/ +.jtk-surface-pan-top, .jtk-surface-pan-bottom { + width: 100%; + height: 20px; +} + +/* + Hover styles for all pan buttons. + On hover, change color, background color, font weight and opacity. +*/ +.jtk-surface-pan-top:hover, .jtk-surface-pan-bottom:hover, .jtk-surface-pan-left:hover, .jtk-surface-pan-right:hover { + opacity: 0.6; + filter: alpha(opacity=60); + background-color: rgb(49, 119, 184); + color: white; + font-weight: bold; +} + +/* + Specific styles for the left and right pan buttons. + Left/right pan buttons are 100% height and 20px wide +*/ +.jtk-surface-pan-left, .jtk-surface-pan-right { + width: 20px; + height: 100%; + line-height: 40; +} + + +/* + Assigned to a pan button when the user is pressing it. +*/ +.jtk-surface-pan-active, .jtk-surface-pan-active:hover { + background-color: #f76258; +} + +/* --------------------------------------------------------------------------------------------- */ +/* --- MINIVIEW WIDGET ------------------------------------------------------------------------- */ +/* --------------------------------------------------------------------------------------------- */ + +/* + Assigned to an element that is acting as a Miniview. + As with Surface, Miniview elements should have overflow:hidden set to prevent + libs from scrolling them during drag. This style also provides a default width/height for a miniview, + which you may wish to override. +*/ +.jtk-miniview { + overflow: hidden !important; + width: 125px; + height: 125px; + position: relative; + background-color: #B2C9CD; + border: 1px solid #E2E6CD; + border-radius: 4px; + opacity: 0.8; +} + +/* + Assigned to the element that shows the size of the related viewport in a Miniview widget, and which can be dragged to + move the surface. +*/ +.jtk-miniview-panner { + border: 5px dotted WhiteSmoke; + opacity: 0.4; + filter: alpha(opacity=40); + background-color: rgb(79, 111, 126); + cursor: move; + cursor: -moz-grab; + cursor: -webkit-grab; +} + +/* + Assigned to the miniview's panner when it is being dragged. +*/ +.jtk-miniview-panning { + cursor: -moz-grabbing; + cursor: -webkit-grabbing; +} + +/* + Added to all elements displayed in a miniview. +*/ +.jtk-miniview-element { + background-color: rgb(96, 122, 134); + position: absolute; +} + +/* + Assigned to the collapse/expand miniview button +*/ +.jtk-miniview-collapse { + color: whiteSmoke; + position: absolute; + font-size: 18px; + top: -1px; + right: 3px; + cursor: pointer; + font-weight: bold; +} + +/* + The '-' symbol when the miniview is expanded +*/ +.jtk-miniview-collapse:before { + content: "\2012"; +} + +/* + Assigned to the miniview element when it is collapsed. +*/ +.jtk-miniview-collapsed { + background-color: #449ea6; + border-radius: 4px; + height: 22px; + margin-right: 0; + padding: 4px; + width: 21px; +} + +/* + Hide all children of the miniview (except the expand button) when it is collapsed so you don't see anything + poking through under the + icon. +*/ +.jtk-miniview-collapsed .jtk-miniview-element, .jtk-miniview-collapsed .jtk-miniview-panner { + visibility: hidden; +} + +/* + The '+' symbol when the miniview is collapsed. +*/ +.jtk-miniview-collapsed .jtk-miniview-collapse:before { + content: "+"; +} + +/* + Hover state for the collapse/expand icon. +*/ +.jtk-miniview-collapse:hover { + color: #E4F013; +} + +/* ------------------------------------------------------------------------------------------- */ +/* --- DIALOGS --------------------------------------------------------------------------------*/ +/* ------------------------------------------------------------------------------------------- */ + +/* + This is the element that acts as the dialog underlay - the modal "mask". Note the high z-index default + set here (and note also the overlay style below has a z-index with a value higher by one). +*/ +.jtk-dialog-underlay { + left: 0; + right: 0; + top: 0; + bottom: 0; + position: fixed; + z-index: 100000; + opacity: 0.8; + background-color: #CCC; + display: none; +} + +/* + This is the element that acts as the parent for dialog content. +*/ +.jtk-dialog-overlay { + position: fixed; + z-index: 100001; + display: none; + background-color: white; + font-family: "Open Sans", sans-serif; + padding: 7px; + box-shadow: 0 0 5px gray; + overflow: hidden; +} + +.jtk-dialog-overlay-x { + max-height:0; + transition: max-height 0.5s ease-in; + -moz-transition: max-height 0.5s ease-in; + -ms-transition: max-height 0.5s ease-in; + -o-transition: max-height 0.5s ease-in; + -webkit-transition: max-height 0.5s ease-in; +} + +.jtk-dialog-overlay-y { + max-width:0; + transition: max-width 0.5s ease-in; + -moz-transition: max-width 0.5s ease-in; + -ms-transition: max-width 0.5s ease-in; + -o-transition: max-width 0.5s ease-in; + -webkit-transition: max-width 0.5s ease-in; +} + +.jtk-dialog-overlay-top { + top:20px; +} + +.jtk-dialog-overlay-bottom { + bottom:20px; +} + +.jtk-dialog-overlay-left { + left:20px; +} + +.jtk-dialog-overlay-right { + right:20px; +} + +.jtk-dialog-overlay-x.jtk-dialog-overlay-visible { + max-height:1000px; +} + +.jtk-dialog-overlay-y.jtk-dialog-overlay-visible { + max-width:1000px; +} + +/* + The element containing buttons in a dialog. +*/ +.jtk-dialog-buttons { + text-align: right; + margin-top: 5px; +} + +/* + An individual button in a dialog. +*/ +.jtk-dialog-button { + border: none; + cursor: pointer; + margin-right: 5px; + min-width: 56px; + background-color: white; + outline: 1px solid #ccc; +} + +/* + Hover style for an individual button in a dialog. +*/ +.jtk-dialog-button:hover { + color: white; + background-color: #234b5e; +} + +/* + The titlebar of a dialog. +*/ +.jtk-dialog-title { + text-align: left; + font-size: 14px; + margin-bottom: 9px; +} + +.jtk-dialog-content { + font-size:12px; + text-align:left; + min-width:250px; + margin: 0 14px; +} + +.jtk-dialog-content ul { + width:100%; + padding-left:0; +} + +.jtk-dialog-content label { + cursor: pointer; + font-weight: inherit; +} + +.jtk-dialog-overlay input, .jtk-dialog-overlay textarea { + background-color: #FFF; + border: 1px solid #CCC; + color: #333; + font-size: 14px; + font-style: normal; + outline: none; + padding: 6px 4px; + margin-right: 6px; +} + +.jtk-dialog-overlay input:focus, .jtk-dialog-overlay textarea:focus { + background-color: #cbeae1; + border: 1px solid #83b8a8; + color: #333; + font-size: 14px; + font-style: normal; + outline: none; +} + +/* -------------------------------------------------------------------------------------------- */ +/* --- DRAWING TOOLS -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------------------------- */ + +/* + Assigned to the element that is drawn around some other element when a drawing operation is taking place. +*/ +.jtk-draw-skeleton { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + outline: 2px solid #84acb3; + opacity: 0.8; +} + +/* + Assigned to every handle (top left, top right, bottom left, bottom right, center) in a draw skeleton. +*/ +.jtk-draw-handle { + position: absolute; + width: 7px; + height: 7px; + background-color: #84acb3; +} + +/* + Assigned to the top left handle in a draw skeleton +*/ +.jtk-draw-handle-tl { + left: 0; + top: 0; + cursor: nw-resize; +} + +/* + Assigned to the top right handle in a draw skeleton +*/ +.jtk-draw-handle-tr { + right: 0; + top: 0; + cursor: ne-resize; +} + +/* + Assigned to the bottom left handle in a draw skeleton +*/ +.jtk-draw-handle-bl { + left: 0; + bottom: 0; + cursor: sw-resize; +} + +/* + Assigned to the bottom right handle in a draw skeleton +*/ +.jtk-draw-handle-br { + bottom: 0; + right: 0; + cursor: se-resize; +} + +/* + Assigned to the center handle in a draw skeleton (the handle by which the element may be dragged). This is + not visible by defaut; enable if you need it. +*/ +.jtk-draw-drag { + display:none; + position: absolute; + left: 50%; + top: 50%; + margin-left: -10px; + margin-top: -10px; + width: 20px; + height: 20px; + background-color: #84acb3; + cursor: move; +} + +/* + This class is added to the document body on drag resize start and removed at the end of resizing. Its purpose + is to switch off text selection on all elements while the user is resizing an element. +*/ +.jtk-draw-select-defeat * { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-demo.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-demo.css new file mode 100644 index 000000000..5d0a49eb3 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsPlumbToolkit-demo.css @@ -0,0 +1,334 @@ +/* ---------------------- page structure ------------------------ */ +#main { + background-color: transparent; + font-family: Arial,sans-serif; + margin-left: auto; + margin-right: auto; + width: 90%; + max-width:1500px; + position: relative; + margin-top:98px; +} + +#main .description { + font-size: 13px; + margin-top: 25px; + padding: 13px; + margin-bottom: 22px; + background-color: #f4f5ef; +} + +#main .description li { + list-style-type: disc !important; +} + +.canvas { + margin-left: 160px; + height:550px; + max-height:700px; + border:1px solid #CCC; + background-color:white; +} + +.canvas-wide { + margin-left:0; +} + +.miniview { + position: absolute; + top: 25px; + right: 25px; + z-index: 100; +} + + +#dataset { + text-align: left; + max-height: 600px; + overflow: auto; +} + +.demo-title { + float:left; + font-size:18px; +} + +.controls { + top: 25px; + color: #FFF; + margin-right: 10px; + position: absolute; + left: 25px; + z-index: 1; +} + +.controls i { + background-color: #449ea6; + border-radius: 4px; + cursor: pointer; + margin-right: 0px; + padding: 4px; +} + +li { + list-style-type: none; +} + +/* ------------------------ node palette -------------------- */ + +.sidebar { + margin:0; + padding:0; + padding-top: 7px; + width:150px; + float:left; + text-align:center; + height: 550px; + padding-right: 10px; + background-color: #84acb3; +} + +.sidebar ul li { + background-color: #234b5e; + border-radius: 11px; + color: #f7ebca; + cursor: move; + margin-bottom: 10px; + margin-left: 6px; + padding: 8px; + width:128px; +} + +.sidebar ul { + width:100%; + padding:0; +} + +.sidebar ul li:hover { + background-color: #577a8b; +} + +.sidebar i { + float:left; +} + +@media (max-width: 600px) { + .sidebar { + float:none; + height: 55px; + width: 100%; + padding-top:0; + } + + .sidebar ul li { + display:inline-block; + margin-top: 7px; + width:67px; + } + .canvas { + margin-left: 0; + margin-top:10px; + height:364px; + } +} + +.btn-icon-margin { + line-height: 18px; + margin-left: 10px; +} + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- jsPlumb setup ---------------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------------------------------------- */ + +._jsPlumb_connector { + z-index:9; +} + +._jsPlumb_endpoint { + z-index:12; + opacity:0.8; + cursor:pointer; +} + +._jsPlumb_overlay { + background-color: white; + color: #434343; + font-weight: 400; + padding: 4px; + z-index:10; + +} + +._jsPlumb_overlay._jsPlumb_hover { + color: #434343; +} + +path { + cursor:pointer; +} + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- Dialogs -----------------------------------------------------------------------------------------*/ +/* ---------------------------------------------------------------------------------------------------- */ + + + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- Drag/drop interactions ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------------------------------------- */ +.drop-hover { + background-color: #629f72 !important; + color: #FFF !important; +} + +/* ---------------------------------------------------------------------------------------------------- */ +/* --- Node styles ------------------------------------------------------------------------------------ */ +/* ---------------------------------------------------------------------------------------------------- */ + +/* -- common --*/ + +.jtk-node { + background-color: #234b5e; + border-radius: 14px; + border:1px solid #CCC; + box-shadow:0 0 5px #CCC; + cursor: pointer; + font-size: 12px; + position: absolute; + z-index: 11; + overflow: hidden; + min-width:80px; + min-height:30px; + width: auto; +} + +.jtk-node .name, li.jsplumb-draggable { + background-color: #234b5e; + color: #f7ebca; + cursor: move; + font-size: 16px; + line-height: 24px; + padding: 6px; + text-align: center; +} + +.jtk-node .ep { + width: 100%; + background-color: orange; + height: 10px; + cursor: pointer; +} + +li.jsplumb-draggable { + min-width:100px; + border-radius:14px; +} + +.jtk-node .name span { + cursor:pointer; +} + +.delete { + padding: 2px; + cursor: pointer; + float: left; + font-size: 10px; + line-height: 20px; +} + +.add, .edit { + cursor: pointer; + float:right; + font-size: 10px; + line-height: 20px; + margin-right:2px; + padding: 2px; +} + +.edit:hover { + color: #ff8000; +} + +.selected-mode { + color:#E4F013; +} + +.connect { + width:10px; + height:10px; + background-color:#f76258; + position:absolute; + bottom:10px; + right:10px; +} + +/* --------------------- / common --------------------------------------- */ + + +/* ----------------------- form ------------------------- */ + +.form-labels-float { + float: left; + font-weight: bold; + text-align: right; + padding-right: 6px; + padding-top: 6px; + font-size: 14px; +} + +.form-labels { + font-weight: bold; + text-align: left; + padding-right: 6px; + font-size: 14px; +} + +.checkbox-id { + margin-top: 6px; + margin-left: 22px; +} + + +.pull-left { float: left; } +.clearfix { clear: both; } + + +.demo-links { + position: fixed; + right: 0; + top: 57px; + font-size: 11px; + background-color: white; + opacity: 0.8; + padding-right: 10px; + padding-left: 5px; + text-transform: uppercase; + z-index:100001; +} + +.demo-links div { + display:inline; + margin-right:7px; + margin-left:7px; +} + +.demo-links i { + padding:4px; +} + +.community { + position: absolute; + top: 38px; + left: 102px; + color: oldlace; + font-size: 13px; + text-transform: lowercase; + letter-spacing: 1px; +} + +.community:after { + content:"Community Edition"; +} + + diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb-doc.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb-doc.css new file mode 100644 index 000000000..bd113af90 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb-doc.css @@ -0,0 +1,781 @@ + +@media (max-width: 600px) { + .col-xs-3 { + width: 100%; + + } + .col-xs-9 { + width: 100%; + } + + .col-xs-3 li { + background-color:#f5f5f5; + } + + .docs-nav:before { + content: "Contents"; + } + + .docs-nav { + cursor:pointer; + margin-bottom: 13px; + font-size:17px; + display:inline-block; + position:relative; + overflow-x:visible !important; + overflow-y:visible !important; + } + + .docs-nav > ul { + cursor: default; + position: absolute; + z-index: 1; + max-height:250px; + visibility: hidden; + transition: visibility 0.5s; + -moz-transition: visibility 0.5s; + -o-transition: visibility 0.5s; + -ms-transition: visibility 0.5s; + -webkit-transition: visibility 0.5s; + width: 100%; + left:0; + top:41px; + overflow: auto; + background-color: inherit; + box-shadow: 0px 2px 2px #ccc; + } + + .docs-nav:focus > ul { + visibility: visible; + } + + .docs-nav li { + padding-top:3px; + padding-bottom:3px; + margin-top:5px; + margin-bottom:5px; + border-bottom: 1px solid #eee; + } + + .docs-nav li:last-of-type { + border-bottom:none; + } + + .markdown-body { + width:100%; + } + + #dataset { + margin-left:0 !important; + height:175px !important; + } +} + +.docs-nav:focus { + outline:none; +} + + +img { + border: 0; +} + +.markdown-body a[id].wiki-toc-anchor { + color: inherit; + text-decoration: none; +} + +.markdown-body>*:first-child { + margin-top: 0!important; +} +.markdown-body>*:last-child { + margin-bottom: 0!important; +} +.markdown-body a.absent { + color: #c00; +} +.markdown-body a.anchor { + display: block; + padding-left: 30px; + margin-left: -30px; + cursor: pointer; + position: absolute; + top: 0; + left: 0; + bottom: 0; +} +.markdown-body h1, +.markdown-body h2, +.markdown-body h3, +.markdown-body h4, +.markdown-body h5, +.markdown-body h6 { + margin: 20px 0 10px; + padding: 0; + font-weight: bold; + -webkit-font-smoothing: antialiased; + cursor: text; + position: relative; +} +.markdown-body h1:hover a.anchor, +.markdown-body h2:hover a.anchor, +.markdown-body h3:hover a.anchor, +.markdown-body h4:hover a.anchor, +.markdown-body h5:hover a.anchor, +.markdown-body h6:hover a.anchor { + background: url(../images/pin-20.png) no-repeat left center; + text-decoration: none; +} +.markdown-body h1 tt, +.markdown-body h1 code, +.markdown-body h2 tt, +.markdown-body h2 code, +.markdown-body h3 tt, +.markdown-body h3 code, +.markdown-body h4 tt, +.markdown-body h4 code, +.markdown-body h5 tt, +.markdown-body h5 code, +.markdown-body h6 tt, +.markdown-body h6 code { + font-size: inherit; +} +.markdown-body h1 { + font-size: 28px; + color: #000; + margin-top: 50px; + margin-bottom: 20px; +} +.markdown-body h2 { + font-size: 24px; + border-bottom: 1px dotted #ccc; + color: #000; + margin-top: 40px; + margin-bottom: 20px; +} +.markdown-body h3 { + font-size: 18px; + margin-top: 30px; + margin-bottom: 15px; +} +.markdown-body h4 { + font-size: 16px; +} +.markdown-body h5 { + font-size: 14px; +} +.markdown-body h6 { + color: #777; + font-size: 14px; +} +.markdown-body p, +.markdown-body blockquote, +.markdown-body ul, +.markdown-body ol, +.markdown-body dl, +.markdown-body li, +.markdown-body table, +.markdown-body pre { + margin: 10px 0; +} +.markdown-body hr { + border: 0 none; + color: #ccc; + height: 1px; + padding: 0; + background-color: #ccc; +} +.markdown-body>h1:first-child, +.markdown-body>h2:first-child, +.markdown-body>h3:first-child, +.markdown-body>h4:first-child, +.markdown-body>h5:first-child, +.markdown-body>h6:first-child { +} +.markdown-body h1+h2{ + margin-top: 30px; +} +.markdown-body h2+h3{ + margin-top: 10px; +} +.markdown-body a:first-child h1, +.markdown-body a:first-child h2, +.markdown-body a:first-child h3, +.markdown-body a:first-child h4, +.markdown-body a:first-child h5, +.markdown-body a:first-child h6 { + margin-top: 0; + padding-top: 0; +} +.markdown-body h1+p, +.markdown-body h2+p, +.markdown-body h3+p, +.markdown-body h4+p, +.markdown-body h5+p, +.markdown-body h6+p { + margin-top: 0; +} +.markdown-body li p.first { + display: inline-block; +} +.markdown-body ul, +.markdown-body ol { + padding-left: 30px; +} +.markdown-body ul li>:first-child, +.markdown-body ol li>:first-child { + margin-top: 0; +} +.markdown-body ul li>:last-child, +.markdown-body ol li>:last-child { + margin-bottom: 0; +} +.markdown-body dl { + padding: 0; +} +.markdown-body dl dt { + font-size: 14px; + font-weight: bold; + font-style: italic; + padding: 0; + margin: 15px 0 5px; +} +.markdown-body dl dt:first-child { + padding: 0; +} +.markdown-body dl dt>:first-child { + margin-top: 0; +} +.markdown-body dl dt>:last-child { + margin-bottom: 0; +} +.markdown-body dl dd { + margin: 0 0 15px; + padding: 0 15px; +} +.markdown-body dl dd>:first-child { + margin-top: 0; +} +.markdown-body dl dd>:last-child { + margin-bottom: 0; +} +.markdown-body blockquote { + border-left: 4px solid #DDD; + padding: 0 15px; + color: #777; +} +.markdown-body blockquote>:first-child { + margin-top: 0; +} +.markdown-body blockquote>:last-child { + margin-bottom: 0; +} +.markdown-body table { + padding: 0; + border-collapse: collapse; + border-spacing: 0; +} +.markdown-body table tr { + border-top: 1px solid #ccc; + background-color: #fff; + margin: 0; + padding: 0; +} +.markdown-body table tr:nth-child(2n) { + background-color: #f8f8f8; +} +.markdown-body table tr th { + font-weight: bold; +} +.markdown-body table tr th, +.markdown-body table tr td { + border: 1px solid #ccc; + text-align: left; + margin: 0; + padding: 6px 13px; +} +.markdown-body table tr th>:first-child, +.markdown-body table tr td>:first-child { + margin-top: 0; +} +.markdown-body table tr th>:last-child, +.markdown-body table tr td>:last-child { + margin-bottom: 0; +} +.markdown-body img { + max-width: 100%; +} +.markdown-body span.frame { + display: block; + overflow: hidden; +} +.markdown-body span.frame>span { + border: 1px solid #ddd; + display: block; + float: left; + overflow: hidden; + margin: 13px 0 0; + padding: 7px; + width: auto; +} +.markdown-body span.frame span img { + display: block; + float: left; +} +.markdown-body span.frame span span { + clear: both; + color: #333; + display: block; + padding: 5px 0 0; +} +.markdown-body span.align-center { + display: block; + overflow: hidden; + clear: both; +} +.markdown-body span.align-center>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: center; +} +.markdown-body span.align-center span img { + margin: 0 auto; + text-align: center; +} +.markdown-body span.align-right { + display: block; + overflow: hidden; + clear: both; +} +.markdown-body span.align-right>span { + display: block; + overflow: hidden; + margin: 13px 0 0; + text-align: right; +} +.markdown-body span.align-right span img { + margin: 0; + text-align: right; +} +.markdown-body span.float-left { + display: block; + margin-right: 13px; + overflow: hidden; + float: left; +} +.markdown-body span.float-left span { + margin: 13px 0 0; +} +.markdown-body span.float-right { + display: block; + margin-left: 13px; + overflow: hidden; + float: right; +} +.markdown-body span.float-right>span { + display: block; + overflow: hidden; + margin: 13px auto 0; + text-align: right; +} +.markdown-body code, +.markdown-body tt { + margin: 0 2px; + padding: 0 5px; + white-space: nowrap; + border: 1px solid #ddd; + background-color: #f8f8f8; + border-radius: 3px; +} +.markdown-body pre>tt, +.markdown-body pre>code { + margin: 0; + padding: 0; + white-space: pre; + border: none; + background: transparent; +} +.markdown-body pre { + background-color: #f8f8f8; + border: 1px solid #ccc; + font-size: 11.5px; + line-height: 18px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} +.markdown-body pre pre, +.markdown-body pre code, +.markdown-body pre tt { + background-color: transparent; + border: none; +} +.markdown-body pre pre { + margin: 0; + padding: 0; +} +.toc { + background-color: #F7F7F7; + border: 1px solid #ddd; + padding: 5px 10px; + margin: 0; + border-radius: 3px; +} +.toc-title { + color: #888; + font-size: 14px; + line-height: 1.6; + padding: 2px; + border-bottom: 1px solid #ddd; + margin-bottom: 3px; +} +.toc ul { + padding-left: 10px; + margin: 0; +} +.toc>ul { + margin-left: 10px; + font-size: 17px; +} +.toc ul ul { + font-size: 15px; +} +.toc ul ul ul { + font-size: 14px; +} +.toc ul li{ + margin: 0; +} +#header-content .toc, +#footer-content .toc, +#sidebar-content .toc { + border: none; +} +.highlight { + background: #fff; +} +.highlight .c { + color: #998; + font-style: italic; +} +.highlight .err { + color: #a61717; + background-color: #e3d2d2; +} +.highlight .k { + font-weight: bold; +} +.highlight .o { + font-weight: bold; +} +.highlight .cm { + color: #998; + font-style: italic; +} +.highlight .cp { + color: #999; + font-weight: bold; +} +.highlight .c1 { + color: #998; + font-style: italic; +} +.highlight .cs { + color: #999; + font-weight: bold; + font-style: italic; +} +.highlight .gd { + color: #000; + background-color: #fdd; +} +.highlight .gd .x { + color: #000; + background-color: #faa; +} +.highlight .ge { + font-style: italic; +} +.highlight .gr { + color: #a00; +} +.highlight .gh { + color: #999; +} +.highlight .gi { + color: #000; + background-color: #dfd; +} +.highlight .gi .x { + color: #000; + background-color: #afa; +} +.highlight .go { + color: #888; +} +.highlight .gp { + color: #555; +} +.highlight .gs { + font-weight: bold; +} +.highlight .gu { + color: #800080; + font-weight: bold; +} +.highlight .gt { + color: #a00; +} +.highlight .kc { + font-weight: bold; +} +.highlight .kd { + font-weight: bold; +} +.highlight .kn { + font-weight: bold; +} +.highlight .kp { + font-weight: bold; +} +.highlight .kr { + font-weight: bold; +} +.highlight .kt { + color: #458; + font-weight: bold; +} +.highlight .m { + color: #099; +} +.highlight .s { + color: #d14; +} +.highlight .na { + color: #008080; +} +.highlight .nb { + color: #0086B3; +} +.highlight .nc { + color: #458; + font-weight: bold; +} +.highlight .no { + color: #008080; +} +.highlight .ni { + color: #800080; +} +.highlight .ne { + color: #900; + font-weight: bold; +} +.highlight .nf { + color: #900; + font-weight: bold; +} +.highlight .nn { + color: #555; +} +.highlight .nt { + color: #000080; +} +.highlight .nv { + color: #008080; +} +.highlight .ow { + font-weight: bold; +} +.highlight .w { + color: #bbb; +} +.highlight .mf { + color: #099; +} +.highlight .mh { + color: #099; +} +.highlight .mi { + color: #099; +} +.highlight .mo { + color: #099; +} +.highlight .sb { + color: #d14; +} +.highlight .sc { + color: #d14; +} +.highlight .sd { + color: #d14; +} +.highlight .s2 { + color: #d14; +} +.highlight .se { + color: #d14; +} +.highlight .sh { + color: #d14; +} +.highlight .si { + color: #d14; +} +.highlight .sx { + color: #d14; +} +.highlight .sr { + color: #009926; +} +.highlight .s1 { + color: #d14; +} +.highlight .ss { + color: #990073; +} +.highlight .bp { + color: #999; +} +.highlight .vc { + color: #008080; +} +.highlight .vg { + color: #008080; +} +.highlight .vi { + color: #008080; +} +.highlight .il { + color: #099; +} +.highlight .gc { + color: #999; + background-color: #EAF2F5; +} +.type-csharp .highlight .k { + color: #00F; +} +.type-csharp .highlight .kt { + color: #00F; +} +.type-csharp .highlight .nf { + color: #000; + font-weight: normal; +} +.type-csharp .highlight .nc { + color: #2B91AF; +} +.type-csharp .highlight .nn { + color: #000; +} +.type-csharp .highlight .s { + color: #A31515; +} +.type-csharp .highlight .sc { + color: #A31515; +} + +/* apidoc overrides */ +.yui3-tabview-list/*, #api-tabview */.tabs { + display:none; +} + +.yui3-tab-label { + background: none !important; +} + +.yui3-tab-selected { + background-color:#58775d !important; + border-color: #58775d; + color:white; +} + +.yui3-tab-selected a, .yui3-tab-selected a:visited { + color:white !important; +} + +.yui3-tabview { + font-size:13px; + margin-top: 36px; + margin-bottom: 50px; +} + +.api-class-tabs.yui3-tabview-list { + background-color:#f4f5ef !important; + border:solid #58775d !important; + border-width:0 0 5px !important; +} + +.api-class-tab { + font-size:15px; +} + +#api-filter { + border: 1px solid #CCC; + margin-bottom: 5px; +} + +kbd { + padding: 2px 4px; + font-size: 90%; + color: #fff; + background-color: #aaa; + border-radius: 3px; + -webkit-box-shadow: none; + box-shadow: none; +} + +#docs-main h1 { + font-size:24px; +} + +#docs-main h2 { + font-size:17px; +} + +#docs-main h3 { + font-size:15px; +} + +#docs-main h6 { + font-size: 14px; + font-weight: bold; +} + +#docs-main .params { + margin-top:30px; +} + +#docs-main code { + color:inherit; +} + +#docs-main a { + color: #629f8d; +} + +#docs-main .args { + display:none; +} + +#index h2 { + font-size:18px; +} + +@media (max-width: 600px) { + .yui3-u-1-4, .yui3-u-3-4 { + width:100%; + } + + .yui3-u-1-4 { + max-height:150px; + overflow:auto; + } + + .yui3-u-1-4:focus { + max-height:180px; + } +} diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb.css new file mode 100644 index 000000000..be8d3d707 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/jsplumb.css @@ -0,0 +1,403 @@ +/** DISABLE TEXT SELECTION (SET ON BODY WHEN DRAGGING IS OCCURRING) **/ +._jsPlumb_drag_select * { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/** FB **/ +#like { + position: fixed; + width: 77px; + height: 70px; + border: 0; + right: 11px; + bottom: -40px; +} + +#retweet_button { + position: fixed; + bottom: 30px; + right: -7px; +} + +body { + padding:0; + margin:0; + font-family:'Helvetica Neue', Helvetica, Arial, sans-serif; + background-color: whitesmoke; +} + +#headerWrapper { + width:100%; + background-color:white; + position:fixed; + top:0;left:0; + z-index:100001; + height:44px; + padding:0; + text-align: center; + border-bottom: 1px solid #e5e5e5; + box-shadow: 0px 1px #eee; +} + +#header { + margin-top:0; + + height:44px; + font-size:13px; + margin-left:auto; + margin-right:auto; + + line-height: 44px; + max-width:1000px; + width:80%; +} + +@media screen and (max-width:1000px) { + #header { + width:100%; + } +} + +@media screen and (max-width:800px) { + #header select { + display:none; + } +} + +@media screen and (max-width:700px) { + .library-links { + right:330px; + } +} + +@media screen and (max-width:640px) { + .logo { + display:none; + } + #header { + text-align:center; + overflow:hidden; + } +} + +.explanation i { + float: right; + margin-right: 25px; + margin-top: 13px; + font-size: 25px; + cursor:pointer; +} + +.explanation i:hover { + color:orange; +} + +.words { + text-align: left; + padding:50px; + background-color:white; +} + +.code { + border:1px solid #456; +} + +.logo { + font-size:30px; + color:#1f1f1f; + text-shadow: 1px 1px #ccc; + float:left; + width:154px; + height:44px; + background-position:0px 5px; +} + + #main { + margin-top: 106px; + font-size: 80%; + width: 80%; + margin-left:auto; + margin-right: auto; + height: 600px; + text-align: center; + position: relative; + max-width: 1200px; + max-height: 1000px; +} + +.demo { + position: relative; + width:100%; + background-color:white; + overflow:auto; + margin-top: 53px; + margin-bottom:25px; + height: 600px; +} + +.explanation { + text-align: center; + opacity: 0.8; + filter: alpha(opacity=80); + width: 100%; + z-index: 10000; + overflow: hidden; + font-size:13px; +} + + +.commands { + margin-bottom:10px; +} + +.commands:hover { + z-index:10000; +} + +/* demo elements */ + +a, a:visited { + text-decoration:none; + color:black; + border-radius:0.2em; + -webkit-transition: color 0.15s ease-in; + -moz-transition: color 0.15s ease-in; + -o-transition: color 0.15s ease-in; + transition: color 0.15s ease-in; +} + +a:hover { + color:#7AB02C; +} + +a:active { + color:#FF2300; +} + +.menu, #render, #explanation { + background-color:#fff; +} + +.menu { + float:right; + font-size:12px; +} + +.menu a { + margin-right: 19px; +} + +.otherLibraries { + display:inline; +} + +#render a { + margin-right:10px; +} + +.selected { + color:orange !important; +} + +.cmd { + color:white; + margin-right:25px; +} + +.cmd:hover { + color:#FF2300; + text-decoration: underline; +} +.cmd:active { + color:#FF2300; +} + +.label { + font-size:13px; + padding:8px; + padding:8px; +} + +.component { + border:1px solid #346789; + border-radius:0.5em; + opacity:0.8; + filter:alpha(opacity=80); + background-color:white; + color:black; + padding:0.5em; + font-size:0.8em; +} + +.component:hover { + border:1px solid #123456; + box-shadow: 2px 2px 19px #444; + -o-box-shadow: 2px 2px 19px #444; + -webkit-box-shadow: 2px 2px 19px #444; + -moz-box-shadow: 2px 2px 19px #fff; + opacity:0.9; + filter:alpha(opacity=90); +} + + +.demo-links, .library-links { + position: fixed; + right: 0; + top: 44px; + font-size: 11px; + background-color: white; + opacity: 0.8; + padding-right: 10px; + padding-left: 5px; + text-transform: uppercase; + z-index:100001; +} + +.demo-links div, .library-links a { + display:inline; + margin-right:7px; + margin-left:7px; +} + +.demo-links i, .library-links i { + padding:4px; +} + +.library-links { + right: 515px; + height: 19px; + line-height: 19px; +} + +.current-library { + color:#7AB02C !important; +} + +/** Z-INDEX **/ + +._jsPlumb_connector { z-index:18; } +._jsPlumb_endpoint { z-index:19; } +._jsPlumb_overlay { z-index:20; } + +.aLabel { + background-color:white; + padding:0.4em; + font:12px sans-serif; + color:#444; + z-index:21; + border:1px dotted gray; + opacity:0.8; + filter:alpha(opacity=80); + cursor: pointer; +} +.aLabel._jsPlumb_hover { + background-color:#5C96BC; + color:white; + border:1px solid white; +} + +/* ---------------------- bootstrap dropdowns ------------------------- */ +.clearfix { + *zoom: 1; +} + +.clearfix:before, +.clearfix:after { + display: table; + line-height: 0; + content: ""; +} + +.clearfix:after { + clear: both; +} + +.hide-text { + font: 0/0 a; + color: transparent; + text-shadow: none; + background-color: transparent; + border: 0; +} + +.input-block-level { + display: block; + width: 100%; + min-height: 30px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +/* load test */ + + + #iframe { + width: 98%; + height: 1000px; + position: absolute; + top: 8px; + left: 1%; + border: 0; + } + #render { height:20px;} + #links { + width: 143px; + font-size: 14px; + padding-left: 0px; + position: fixed; + left: 9px; + top: 52px; + z-index: 20; + background-color: white; + } + ul { padding:0; } + li { + list-style-type:none; + } + .current-tests { + color:orange !important; + } + #qunit-tests li.pass, #qunit-tests li.fail { + background-color:transparent; + } + .loadtest #main, #main.test { + max-width: none; + margin-top: 52px; + background-color: white; + + margin-left: 162px; +} + + +.loadtest ._jsPlumb_connection { z-index:3; } +.loadtest .jspLoad { + z-index:4; + position:absolute; + width:70px; + height:70px; + cursor:pointer; +} + +.loadtest #header { + height:11em; + border:2px solid #824563; +} + +.loadtest #setup { + float:left; +} +.loadtest #demo { + margin-top:10em; + position:relative; +} +.loadtest #setup, .loadtest #output { + font-size:12px; +} + + diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/main.css b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/main.css new file mode 100644 index 000000000..06529ec56 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/css/main.css @@ -0,0 +1,1247 @@ +@font-face { + font-family: 'ico-jsplumb'; + src: url("ico-jsplumb.eot?-oqkwhs"); + src: url("ico-jsplumb.eot?#iefix-oqkwhs") format("embedded-opentype"), url("ico-jsplumb.woff?-oqkwhs") format("woff"), url("ico-jsplumb.ttf?-oqkwhs") format("truetype"), url("ico-jsplumb.svg?-oqkwhs#ico-jsplumb") format("svg"); + font-weight: normal; + font-style: normal +} + +[class^="icon-"], [class*=" icon-"] { + font-family: 'ico-jsplumb'; + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1 +} + +.icon-license:before { + content: "\e604" +} + +.icon-source:before { + content: "\e605" +} + +.icon-support:before { + content: "\e606" +} + +.icon-facebook:before { + content: "\e600" +} + +.icon-twitter:before { + content: "\e601" +} + +.icon-github:before { + content: "\e602" +} + +.icon-linkedin:before { + content: "\e603" +} + +.icon-cross:before { + content: "\ea0f" +} + +.icon-checkmark:before { + content: "\ea10" +} + +*, *:before, *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-rendering: optimizeLegibility +} + +html { + padding: 0; + margin: 0 +} + +body { + background-color: #FFF; + color: #434343; + font-family: "Lato", sans-serif; + font-size: 14px; + font-weight: 400; + height: 100%; + padding: 0 +} + +@media only screen and (max-width: 320px) { + body { + margin-top: 51px + } +} + +.clear-padding { + padding: 0 +} + +.full-width { + width: 100% +} + +.blank-left-padding { + padding: 0 0 0 83px +} + +.full-width-container { + padding: 40px 0; + width: 100% +} + +@media only screen and (max-width: 320px) { + .full-width-container { + padding: 30px 0 + } +} + +.padding-top-page { + padding-top: 92px +} + +@media only screen and (max-width: 320px) { + .padding-top-page { + padding-top: 10px + } +} + +.center-block { + display: table +} + +.pos-relative { + position: relative +} + +@media only screen and (max-width: 320px) { + .mobile-center { + text-align: center + } +} + +.bg-sepia { + background-color: #f4f5ef +} + +.color-white { + color: #FFF !important +} + +.divider-10 { + padding-top: 10px +} + +.divider-20 { + padding-top: 20px +} + +.divider-30 { + padding-top: 30px +} + +.big-title { + color: #58775d; + font-size: 56px; + font-weight: 400; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .big-title { + font-size: 32px; + margin-bottom: 10px + } +} + +.high-title { + color: #696b60; + font-size: 34px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .high-title { + font-size: 32px; + margin-bottom: 10px + } +} + +.prod-title { + color: #696b60; + font-size: 32px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .prod-title { + font-size: 32px; + margin-bottom: 10px + } +} + +.title-white { + color: #FFF; + font-size: 32px; + font-weight: 400; + line-height: 1.2em +} + +@media only screen and (max-width: 320px) { + .title-white { + font-size: 32px; + margin-bottom: 10px + } +} + +.title { + color: #434343; + font-size: 25px; + font-weight: 400; + margin-bottom: 10px +} + +@media only screen and (max-width: 320px) { + .title { + font-size: 18px; + margin-bottom: 6px + } +} + +.big-lead { + color: #FFF; + font-size: 25px; + font-weight: 400; + margin-bottom: 20px +} + +@media only screen and (max-width: 320px) { + .big-lead { + font-size: 18px; + margin-bottom: 10px + } +} + +.lead { + color: #434343; + font-size: 18px; + font-weight: 400; + margin-bottom: 0 +} + +@media only screen and (max-width: 320px) { + .lead { + font-size: 14px + } +} + +.apidoc-jsplumb-logo { + display: none +} + +.btn-big-download a { + border-radius: 0; + color: #FFF; + display: inline-block; + font-size: 16px; + font-weight: 400; + margin: 0; + padding: 10px 20px; + text-decoration: none; + background-color: #096070 +} + +.btn-big-download a:hover:not(:disabled), .btn-big-download a:active:not(:disabled), .btn-big-download a:focus:not(:disabled) { + color: #FFF; + cursor: pointer; + background-color: #012930 +} + +.btn-download a { + border-radius: 0; + color: #FFF; + display: inline-block; + font-size: 16px; + font-weight: 400; + margin: 0; + padding: 10px 20px; + text-decoration: none; + background-color: #096070 +} + +.btn-download a:hover:not(:disabled), .btn-download a:active:not(:disabled), .btn-download a:focus:not(:disabled) { + color: #FFF; + cursor: pointer; + background-color: #012930 +} + +.demo-highlight { + background: url("/img/back-green.jpg") repeat-x center +} + +.logo-jsplumb img { + padding-bottom: 16px; + max-width: 100% +} + +@media only screen and (max-width: 320px) { + .logo-jsplumb img { + max-width: 63% + } +} + +@media only screen and (min-width: 769px) and (max-width: 1023px) { + .logo-jsplumb img { + max-width: 63% + } +} + +.browser-window { + position: relative +} + +.browser-window .browser-dropdown-menu { + position: absolute; + top: 10px; + width: 100% +} + +.browser-window table { + width: 100% +} + +.browser-window td.corners { + height: 56px; + width: 53px +} + +.browser-window td.center-top { + background: url("/img/browser-window-top-center.png") repeat-x; + width: 100% +} + +.browser-window td.center { + background-color: #FFF +} + +.browser-window .jsplumb-demo-container { + padding: 10px +} + +.download-container { + text-align: right +} + +@media only screen and (max-width: 320px) { + .download-container { + text-align: center + } +} + +.background-blue { + background: url("/img/back-blue.jpg") repeat-x center +} + +.background-dark-green { + background: url("/img/back-dark-green.jpg") repeat +} + +.btn-drop { + color: #FFF; + font-weight: 700; + padding: 10px 20px 8px 20px; + background-color: #6dadcc; + cursor: pointer; + width: 100% +} + +.btn-drop:hover, .btn-drop:focus, .btn-drop:active, .open .dropdown-toggle.btn-drop { + color: #FFF; + border: none; + background-color: #3491be; + text-decoration: none +} + +.btn-dropmenu { + -webkit-box-shadow: none; + background-color: #6dadcc; + border-radius: 0; + border: none; + box-shadow: none; + color: #FFF; + margin-top: 1px !important; + padding: 10px 0; + width: 100% +} + +.btn-dropmenu > li > a { + color: #FFF; + border: none; + padding: 10px 20px +} + +.btn-dropmenu > li > a:hover { + background-color: #3c9cca; + color: #FFF +} + +.row #main { + height: 400px; + margin-top: 25px +} + +.row #dataset { + display: none +} + +.navbar-top { + background-color: #58775d; + border-color: none; + font-size: 14px; + font-weight: 700 +} + +@media only screen and (max-width: 320px) { + .navbar-top { + background-color: #58775d + } +} + +.navbar-brand { + height: 56px +} + +.nav-wrapper { + margin-top: 10px +} + +.navbar-header a { + border: none +} + +.navbar-nav > li > a { + border: none; + color: #FFF; + padding: 6px 10px; + text-decoration: none +} + +.navbar-nav > li > a.active { + border: none; + color: #cdcc73; + padding: 6px 10px; + text-decoration: none; + cursor: default +} + +.navbar-nav > li:last-child > a { + color: #FFF; + padding: 6px 0 6px 10px; + text-decoration: none +} + +.navbar-nav > li:last-child > a.active { + border: none; + color: #cdcc73; + padding: 6px 10px; + text-decoration: none; + cursor: default +} + +.nav { + float: left +} + +@media only screen and (max-width: 320px) { + .nav { + float: left; + margin-top: 10px + } +} + +@media only screen and (min-width: 321px) and (max-width: 768px) { + .nav { + float: left + } +} + +.nav > li > a:hover, .nav > li > a:focus { + background-color: transparent; + color: #cdcc73; + text-decoration: none +} + +.navbar-toggle .icon-bar { + background-color: #FFF +} + +.social-nav { + color: #FFF; + float: right; + font-size: 22px +} + +.social-nav .link { + cursor: pointer; + border: none; + color: #FFF; + margin-left: 10px; + text-decoration: none +} + +.social-nav .link:hover, .social-nav .link:focus, .social-nav .link:active { + color: #cdcc73; + border: none; + text-decoration: none +} + +.breadcrumbs { + height: 20px; + top: 52px; + position: fixed; + z-index: 1030; + font-size: 11px; + padding-left: 2%; + background-color: aliceblue; + text-transform: uppercase; + width: 100%; + padding-top: 3px +} + +.breadcrumbs a { + color: #629f8d; + text-decoration: none +} + +.breadcrumbs a:hover, .breadcrumbs a:focus { + color: #434343; + text-decoration: underline +} + +.breadcrumbs .crumbs { + float: left +} + +.breadcrumbs .demo-nav { + display: inline-block; + float: right; + margin-right: 2% +} + +@media (max-width: 490px) { + .crumbs { + display: none + } + + .breadcrumbs { + text-align: center + } + + .demo-nav { + float: none !important; + margin-left: auto; + margin-right: auto !important + } +} + +.footer .copyright { + font-size: 12px; + color: #a0b8b7 +} + +.footer .copyright a { + border: none; + color: #FFF; + text-decoration: none +} + +.footer .copyright a:hover { + color: #cdcc73; + text-decoration: none +} + +ul.navbar-footer { + padding: 4px 0 0 10px +} + +@media only screen and (max-width: 320px) { + ul.navbar-footer { + padding: 6px 0 0 0 + } +} + +.navbar-footer > li { + float: left; + font-size: 14px; + list-style-type: none +} + +.navbar-footer > li > a { + border: none; + color: #FFF; + padding: 6px 6px 0 0; + text-decoration: none +} + +.navbar-footer > li > a:hover { + color: #cdcc73; + text-decoration: none +} + +.footer .social-nav { + float: right; + font-size: 22px +} + +@media only screen and (max-width: 320px) { + .footer .social-nav { + float: left; + margin-top: 10px + } +} + +.footer .social-nav .link { + border: none; + color: #a0b8b7; + margin-left: 10px; + text-decoration: none +} + +@media only screen and (max-width: 320px) { + .footer .social-nav .link { + margin-left: 0 + } +} + +.footer .social-nav .link:hover, .footer .social-nav .link:focus, .footer .social-nav .link:active { + color: #cdcc73; + border: none; + text-decoration: none +} + +.clear-footer { + width: 100%; + clear: both +} + +body.ff .clear-footer { + margin-bottom: 95px +} + +body.ff .footer-wrapper { + position: fixed; + width: 100%; + bottom: 0; + left: 0 +} + +#docs { + margin-top: 101px; + margin-bottom: 40px +} + +#docs h2, #docs h3 { + color: #629f8d; + padding-bottom: 3px +} + +#docs pre { + background: #f4f5ef; + border-color: #c5c7b8; + border-radius: 3px; + font-family: courier, sans-serif; + font-size: 12px +} + +#docs a { + color: #629f8d; + text-decoration: none +} + +#docs a:hover, #docs a:focus { + color: #434343; + text-decoration: underline +} + +#docs ul { + padding-left: 10px +} + +#docs table { + border: 1px solid #a0b8b7 +} + +#docs th { + padding: 10px; + background-color: #a0b8b7 +} + +#docs td { + padding: 10px; + border: 1px solid #a0b8b7 +} + +#docs .markdown-body { + font-size: 13px; + line-height: 1.6; + background-color: white +} + +#docs .markdown-body ul { + padding-left: 16px +} + +#docs .markdown-body li { + list-style-type: circle +} + +#docs .docs-nav { + padding-bottom: 10px; + padding-top: 10px; + overflow-x: hidden; + overflow-y: auto; + background-color: #f4f5ef; + border: 1px solid #f4f5ef; + border-radius: 3px +} + +#docs .docs-nav > ul > li > a { + font-weight: bold; + font-size: 13px +} + +#docs .docs-nav > ul > li > ul { + margin-top: 7px +} + +#docs .docs-nav > ul > li { + color: #629f8d; + font-size: 13px; + font-weight: bold +} + +#docs .docs-nav > ul > li > ul a { + font-weight: normal +} + +#docs .docs-nav li { + list-style-type: none; + font-size: 12px; + border-top: 1px dotted #ccc; + padding-top: 6px; + padding-bottom: 5px +} + +.apidoc-jsplumb-logo { + display: none; + left: 50%; + position: absolute; + top: 10px +} + +#api-classes { + margin: 0; + padding: 0; + background-color: #f4f5ef; + font-size: 13px +} + +#api-classes li { + list-style-type: none; + margin: 0; + border-bottom: 1px dotted #ccc; + padding-top: 5px; + padding-bottom: 5px +} + +#api-classes li a { + color: #629f8d +} + +.yui3-tabview-panel { + background-color: #f4f5ef !important; + border: none !important +} + +#api-tabview-panel { + overflow: hidden +} + +#api-filter { + width: 100% +} + +.apidoc-main { + margin-left: 265px !important; + height: auto; + width: auto; + background-color: white; + border: none +} + +.docs-main { + margin-left: 30px +} + +.box.intro { + background-color: #f4f5ef; + padding: 14px; + margin-bottom: 19px; + border-radius: 3px; + font-size: 13px +} + +.apidoc-summary { + width: 150px +} + +.apidoc-detail { + margin-left: 160px +} + +.apidocs { + margin-top: 20px !important; + padding-left: 30px +} + +#api-options { + margin-top: 30px; + padding-left: 30px +} + +.apidoc-intro { + padding-top: 30px !important +} + +#api-list { + margin-bottom: 50px +} + +#api-list h2 { + display: none +} + +.index-item { + width: 30%; + float: left; + display: inline +} + +.index-list { + overflow: hidden +} + +pre.license { + padding: 15px; + word-break: normal; + word-wrap: normal; + white-space: pre-wrap +} + +.license-wrapper, .privacy { + margin-top: 50px; + text-align: left; + width: 75%; + margin-left: auto; + margin-right: auto; + padding: 15px +} + +.privacy { + font-size: 80px +} + +.community-demo .demo { + height: 650px; + position: relative; + overflow: auto; + background-color: white; + border-radius: 3px; + max-width: 1000px; + margin-left: auto; + margin-right: auto; + border: 1px solid #CCC; + margin-top: 73px; + width: 90% +} + +.product-matrix-container { + width: 100%; + font-size: 15px +} + +.product-matrix-container .high-title { + font-size: 28px +} + +.product-matrix-container tr:nth-child(odd) td { + background-color: #FBFBFB; + border-bottom: 1px solid #CFD0C9 +} + +.product-matrix-container tr:nth-child(even) td { + background-color: #E9EBDD; + border-bottom: 1px solid #CFD0C9 +} + +.product-matrix-container td { + border-left: 1px solid #CFD0C9 +} + +.product-matrix-container th { + border-bottom: 1px solid #CFD0C9 +} + +.product-matrix-container th, .product-matrix-container td { + padding: 10px +} + +.product-matrix-container a { + color: #629f8d; + text-decoration: none +} + +.product-matrix-container table { + width: 100%; + border: 1px solid #CFD0C9; + font-size: 90% +} + +.product-matrix-container table table { + border: none +} + +.product-matrix-container table table th, .product-matrix-container table table td, .product-matrix-container table table tr { + border: none +} + +.license-type .icon { + color: #a0b8b7; + font-size: 59px; + margin-left: 15px +} + +.license-type.divider { + border-bottom: 1px solid #CFD0C9; + padding-bottom: 20px; + margin-bottom: 10px +} + +.license-type .divider-color { + border-bottom: 1px solid #CFD0C9; + background-color: #f4f5ef +} + +.license-type .price-table .title { + color: #696b60; + font-size: 34px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 8px +} + +@media only screen and (max-width: 320px) { + .license-type .price-table .title { + font-size: 32px; + margin-bottom: 4px + } +} + +.license-type .price-table .sub-title { + color: #696b60; + font-size: 25px; + font-weight: 400; + line-height: 1.2em; + margin-bottom: 8px +} + +@media only screen and (max-width: 320px) { + .license-type .price-table .sub-title { + font-size: 25px; + margin-bottom: 4px + } +} + +.license-type .price-table .total-title { + color: #696b60; + font-size: 22px; + font-weight: 400; + line-height: 1.2em; + text-align: right +} + +@media only screen and (max-width: 320px) { + .license-type .price-table .total-title { + font-size: 22px + } +} + +.license-type .price-table .label { + color: #434343; + display: block; + font-size: 15px; + font-weight: 400; + padding: 0; + text-align: left; + white-space: normal; + margin-bottom: 10px; + line-height: 1.3em +} + +.license-type .price-table .price { + font-size: 15px; + font-weight: 700; + padding-left: 10px; + text-align: right +} + +.license-type .price-table .check-price { + padding-left: 10px; + width: 22px +} + +.license-type .price-table .total-price { + font-size: 18px; + font-weight: 700; + padding-left: 10px; + padding-right: 20px; + text-align: right; + width: 22px +} + +.license-type .btn-buy { + padding: 10px; + text-align: right +} + +.license-type .notes { + color: #8DA3A2; + font-style: italic; + padding-top: 40px; + padding-left: 20px +} + +@media only screen and (max-width: 320px) { + .license-type .notes { + padding-top: 0; + padding-left: 72px + } +} + +@media only screen and (min-width: 321px) and (max-width: 768px) { + .license-type .notes { + padding-top: 0; + padding-left: 72px + } +} + +@media only screen and (min-width: 769px) and (max-width: 1023px) { + .license-type .notes { + padding-top: 0; + padding-left: 72px + } +} + +.license-type button { + background: none; + border: none +} + +.payment-container { + width: 80%; + max-width: 1000px; + margin-right: auto; + margin-left: auto; + margin-top: 50px +} + +.item-packager * { + font-size: 12px +} + +.item-packager table { + margin: auto +} + +.package-form { + margin: auto +} + +.payment-form input:focus { + background-color: #cbeae1 +} + +.payment-form-inner { + overflow: hidden; + -webkit-transition: height 0.5s linear; + -moz-transition: height 0.5s linear; + -ms-transition: height 0.5s linear; + -o-transition: height 0.5s linear; + transition: height 0.5s linear +} + +.jtk-payment-form label { + display: block +} + +.jtk-payment-form label span { + font-size: 12px; + color: cadetblue +} + +.error { + color: red; + font-size: 11px +} + +.txtInv { + width: 450px; + height: 300px +} + +.formMessage { + min-height: 36px; + font-size: 12px +} + +.formMessage.error { + color: red +} + +.formMessage .wait { + width: 36px; + height: 36px; + float: left; + margin-right: 10px; + display: none +} + +.invoice-details table { + border: 1px solid #456; + border-collapse: collapse; + width: 100%; + border: 1px solid #CFD0C9 +} + +.invoice-details table th, .invoice-details table td { + padding: 10px; + text-align: center +} + +.invoice-details table td.item { + text-align: right +} + +.invoice-details td { + border-left: 1px solid #CFD0C9 +} + +.invoice-details tr:nth-child(even) td { + background-color: #E9EBDD; + border-bottom: 1px solid #CFD0C9 +} + +.colTotal { + font-weight: bold; + text-align: right !important +} + +.payment-form input { + font-size: 16px +} + +.payment-form button { + background: none; + border: none +} + +pre { + outline: 1px solid #ccc; + padding: 5px; + margin: 0 +} + +.string { + color: green +} + +.number { + color: darkorange +} + +.boolean { + color: blue +} + +.null { + color: magenta +} + +.key { + color: red +} + +.blog-content .w { + position: absolute; + background-color: white; + box-shadow: 0px 0px 2px black; + text-align: center; + width: 50px; + height: 50px; + border-radius: 3px; + cursor: pointer +} + +.blog-content .demo { + height: 340px; + margin-top: 15px; + margin-bottom: 15px +} + +.blog-content ._jsPlumb_overlay.label { + color: black +} + +.blog-content .highlight { + margin-top: 15px; + margin-bottom: 15px +} + +.blog-content h3 { + margin-top: 25px +} + +.blog-content h4, .blog-content h5, .blog-content h6 { + margin-top: 20px; + font-weight: bold +} + +.blog-content h4 { + font-size: 18px +} + +.contact-form { + width: 80%; + max-width: 700px; + margin-left: auto; + padding-bottom: 25px; + margin-right: auto +} + +.contact-form button { + background: none; + border: none +} \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery-1.9.0-min.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery-1.9.0-min.js new file mode 100644 index 000000000..50d1b22f2 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery-1.9.0-min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.9.0 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license */(function(e,t){"use strict";function n(e){var t=e.length,n=st.type(e);return st.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}function r(e){var t=Tt[e]={};return st.each(e.match(lt)||[],function(e,n){t[n]=!0}),t}function i(e,n,r,i){if(st.acceptData(e)){var o,a,s=st.expando,u="string"==typeof n,l=e.nodeType,c=l?st.cache:e,f=l?e[s]:e[s]&&s;if(f&&c[f]&&(i||c[f].data)||!u||r!==t)return f||(l?e[s]=f=K.pop()||st.guid++:f=s),c[f]||(c[f]={},l||(c[f].toJSON=st.noop)),("object"==typeof n||"function"==typeof n)&&(i?c[f]=st.extend(c[f],n):c[f].data=st.extend(c[f].data,n)),o=c[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[st.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[st.camelCase(n)])):a=o,a}}function o(e,t,n){if(st.acceptData(e)){var r,i,o,a=e.nodeType,u=a?st.cache:e,l=a?e[st.expando]:st.expando;if(u[l]){if(t&&(r=n?u[l]:u[l].data)){st.isArray(t)?t=t.concat(st.map(t,st.camelCase)):t in r?t=[t]:(t=st.camelCase(t),t=t in r?[t]:t.split(" "));for(i=0,o=t.length;o>i;i++)delete r[t[i]];if(!(n?s:st.isEmptyObject)(r))return}(n||(delete u[l].data,s(u[l])))&&(a?st.cleanData([e],!0):st.support.deleteExpando||u!=u.window?delete u[l]:u[l]=null)}}}function a(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(Nt,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:wt.test(r)?st.parseJSON(r):r}catch(o){}st.data(e,n,r)}else r=t}return r}function s(e){var t;for(t in e)if(("data"!==t||!st.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function u(){return!0}function l(){return!1}function c(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function f(e,t,n){if(t=t||0,st.isFunction(t))return st.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return st.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=st.grep(e,function(e){return 1===e.nodeType});if(Wt.test(t))return st.filter(t,r,!n);t=st.filter(t,r)}return st.grep(e,function(e){return st.inArray(e,t)>=0===n})}function p(e){var t=zt.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function d(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function h(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function g(e){var t=nn.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function m(e,t){for(var n,r=0;null!=(n=e[r]);r++)st._data(n,"globalEval",!t||st._data(t[r],"globalEval"))}function y(e,t){if(1===t.nodeType&&st.hasData(e)){var n,r,i,o=st._data(e),a=st._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)st.event.add(t,n,s[n][r])}a.data&&(a.data=st.extend({},a.data))}}function v(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!st.support.noCloneEvent&&t[st.expando]){r=st._data(t);for(i in r.events)st.removeEvent(t,i,r.handle);t.removeAttribute(st.expando)}"script"===n&&t.text!==e.text?(h(t).text=e.text,g(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),st.support.html5Clone&&e.innerHTML&&!st.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Zt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function b(e,n){var r,i,o=0,a=e.getElementsByTagName!==t?e.getElementsByTagName(n||"*"):e.querySelectorAll!==t?e.querySelectorAll(n||"*"):t;if(!a)for(a=[],r=e.childNodes||e;null!=(i=r[o]);o++)!n||st.nodeName(i,n)?a.push(i):st.merge(a,b(i,n));return n===t||n&&st.nodeName(e,n)?st.merge([e],a):a}function x(e){Zt.test(e.type)&&(e.defaultChecked=e.checked)}function T(e,t){if(t in e)return t;for(var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Nn.length;i--;)if(t=Nn[i]+n,t in e)return t;return r}function w(e,t){return e=t||e,"none"===st.css(e,"display")||!st.contains(e.ownerDocument,e)}function N(e,t){for(var n,r=[],i=0,o=e.length;o>i;i++)n=e[i],n.style&&(r[i]=st._data(n,"olddisplay"),t?(r[i]||"none"!==n.style.display||(n.style.display=""),""===n.style.display&&w(n)&&(r[i]=st._data(n,"olddisplay",S(n.nodeName)))):r[i]||w(n)||st._data(n,"olddisplay",st.css(n,"display")));for(i=0;o>i;i++)n=e[i],n.style&&(t&&"none"!==n.style.display&&""!==n.style.display||(n.style.display=t?r[i]||"":"none"));return e}function C(e,t,n){var r=mn.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function k(e,t,n,r,i){for(var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;4>o;o+=2)"margin"===n&&(a+=st.css(e,n+wn[o],!0,i)),r?("content"===n&&(a-=st.css(e,"padding"+wn[o],!0,i)),"margin"!==n&&(a-=st.css(e,"border"+wn[o]+"Width",!0,i))):(a+=st.css(e,"padding"+wn[o],!0,i),"padding"!==n&&(a+=st.css(e,"border"+wn[o]+"Width",!0,i)));return a}function E(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=ln(e),a=st.support.boxSizing&&"border-box"===st.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=un(e,t,o),(0>i||null==i)&&(i=e.style[t]),yn.test(i))return i;r=a&&(st.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+k(e,t,n||(a?"border":"content"),r,o)+"px"}function S(e){var t=V,n=bn[e];return n||(n=A(e,t),"none"!==n&&n||(cn=(cn||st("':""),e._keyEvent=!1,B},_generateMonthYearHeader:function(e,t,n,r,i,s,o,u){var a=this._get(e,"changeMonth"),f=this._get(e,"changeYear"),l=this._get(e,"showMonthAfterYear"),c='
',h="";if(s||!a)h+=''+o[t]+"";else{var p=r&&r.getFullYear()==n,d=i&&i.getFullYear()==n;h+='"}l||(c+=h+(s||!a||!f?" ":""));if(!e.yearshtml){e.yearshtml="";if(s||!f)c+=''+n+"";else{var m=this._get(e,"yearRange").split(":"),g=(new Date).getFullYear(),y=function(e){var t=e.match(/c[+-].*/)?n+parseInt(e.substring(1),10):e.match(/[+-].*/)?g+parseInt(e,10):parseInt(e,10);return isNaN(t)?g:t},b=y(m[0]),w=Math.max(b,y(m[1]||""));b=r?Math.max(b,r.getFullYear()):b,w=i?Math.min(w,i.getFullYear()):w,e.yearshtml+='",c+=e.yearshtml,e.yearshtml=null}}return c+=this._get(e,"yearSuffix"),l&&(c+=(s||!a||!f?" ":"")+h),c+="
",c},_adjustInstDate:function(e,t,n){var r=e.drawYear+(n=="Y"?t:0),i=e.drawMonth+(n=="M"?t:0),s=Math.min(e.selectedDay,this._getDaysInMonth(r,i))+(n=="D"?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(r,i,s)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),(n=="M"||n=="Y")&&this._notifyChange(e)},_restrictMinMax:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max"),i=n&&tr?r:i,i},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return t==null?[1,1]:typeof t=="number"?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return(new Date(e,t,1)).getDay()},_canAdjustMonth:function(e,t,n,r){var i=this._getNumberOfMonths(e),s=this._daylightSavingAdjust(new Date(n,r+(t<0?t:i[0]*i[1]),1));return t<0&&s.setDate(this._getDaysInMonth(s.getFullYear(),s.getMonth())),this._isInRange(e,s)},_isInRange:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max");return(!n||t.getTime()>=n.getTime())&&(!r||t.getTime()<=r.getTime())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t=typeof t!="string"?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,n,r){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var i=t?typeof t=="object"?t:this._daylightSavingAdjust(new Date(r,n,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),i,this._getFormatConfig(e))}}),$.fn.datepicker=function(e){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find(document.body).append($.datepicker.dpDiv),$.datepicker.initialized=!0);var t=Array.prototype.slice.call(arguments,1);return typeof e!="string"||e!="isDisabled"&&e!="getDate"&&e!="widget"?e=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t)):this.each(function(){typeof e=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this].concat(t)):$.datepicker._attachDatepicker(this,e)}):$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.9.2",window["DP_jQuery_"+dpuuid]=$}(jQuery),function(e,t){var n="ui-dialog ui-widget ui-widget-content ui-corner-all ",r={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},i={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};e.widget("ui.dialog",{version:"1.9.2",options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var n=e(this).css(t).offset().top;n<0&&e(this).css("top",t.top-n)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.oldPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.options.title=this.options.title||this.originalTitle;var t=this,r=this.options,i=r.title||" ",s,o,u,a,f;s=(this.uiDialog=e("
")).addClass(n+r.dialogClass).css({display:"none",outline:0,zIndex:r.zIndex}).attr("tabIndex",-1).keydown(function(n){r.closeOnEscape&&!n.isDefaultPrevented()&&n.keyCode&&n.keyCode===e.ui.keyCode.ESCAPE&&(t.close(n),n.preventDefault())}).mousedown(function(e){t.moveToTop(!1,e)}).appendTo("body"),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(s),o=(this.uiDialogTitlebar=e("
")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").bind("mousedown",function(){s.focus()}).prependTo(s),u=e("").addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").click(function(e){e.preventDefault(),t.close(e)}).appendTo(o),(this.uiDialogTitlebarCloseText=e("")).addClass("ui-icon ui-icon-closethick").text(r.closeText).appendTo(u),a=e("").uniqueId().addClass("ui-dialog-title").html(i).prependTo(o),f=(this.uiDialogButtonPane=e("
")).addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),(this.uiButtonSet=e("
")).addClass("ui-dialog-buttonset").appendTo(f),s.attr({role:"dialog","aria-labelledby":a.attr("id")}),o.find("*").add(o).disableSelection(),this._hoverable(u),this._focusable(u),r.draggable&&e.fn.draggable&&this._makeDraggable(),r.resizable&&e.fn.resizable&&this._makeResizable(),this._createButtons(r.buttons),this._isOpen=!1,e.fn.bgiframe&&s.bgiframe(),this._on(s,{keydown:function(t){if(!r.modal||t.keyCode!==e.ui.keyCode.TAB)return;var n=e(":tabbable",s),i=n.filter(":first"),o=n.filter(":last");if(t.target===o[0]&&!t.shiftKey)return i.focus(1),!1;if(t.target===i[0]&&t.shiftKey)return o.focus(1),!1}})},_init:function(){this.options.autoOpen&&this.open()},_destroy:function(){var e,t=this.oldPosition;this.overlay&&this.overlay.destroy(),this.uiDialog.hide(),this.element.removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},close:function(t){var n=this,r,i;if(!this._isOpen)return;if(!1===this._trigger("beforeClose",t))return;return this._isOpen=!1,this.overlay&&this.overlay.destroy(),this.options.hide?this._hide(this.uiDialog,this.options.hide,function(){n._trigger("close",t)}):(this.uiDialog.hide(),this._trigger("close",t)),e.ui.dialog.overlay.resize(),this.options.modal&&(r=0,e(".ui-dialog").each(function(){this!==n.uiDialog[0]&&(i=e(this).css("z-index"),isNaN(i)||(r=Math.max(r,i)))}),e.ui.dialog.maxZ=r),this},isOpen:function(){return this._isOpen},moveToTop:function(t,n){var r=this.options,i;return r.modal&&!t||!r.stack&&!r.modal?this._trigger("focus",n):(r.zIndex>e.ui.dialog.maxZ&&(e.ui.dialog.maxZ=r.zIndex),this.overlay&&(e.ui.dialog.maxZ+=1,e.ui.dialog.overlay.maxZ=e.ui.dialog.maxZ,this.overlay.$el.css("z-index",e.ui.dialog.overlay.maxZ)),i={scrollTop:this.element.scrollTop(),scrollLeft:this.element.scrollLeft()},e.ui.dialog.maxZ+=1,this.uiDialog.css("z-index",e.ui.dialog.maxZ),this.element.attr(i),this._trigger("focus",n),this)},open:function(){if(this._isOpen)return;var t,n=this.options,r=this.uiDialog;return this._size(),this._position(n.position),r.show(n.show),this.overlay=n.modal?new e.ui.dialog.overlay(this):null,this.moveToTop(!0),t=this.element.find(":tabbable"),t.length||(t=this.uiDialogButtonPane.find(":tabbable"),t.length||(t=r)),t.eq(0).focus(),this._isOpen=!0,this._trigger("open"),this},_createButtons:function(t){var n=this,r=!1;this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),typeof t=="object"&&t!==null&&e.each(t,function(){return!(r=!0)}),r?(e.each(t,function(t,r){var i,s;r=e.isFunction(r)?{click:r,text:t}:r,r=e.extend({type:"button"},r),s=r.click,r.click=function(){s.apply(n.element[0],arguments)},i=e("",r).appendTo(n.uiButtonSet),e.fn.button&&i.button()}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog)):this.uiDialog.removeClass("ui-dialog-buttons")},_makeDraggable:function(){function r(e){return{position:e.position,offset:e.offset}}var t=this,n=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(n,i){e(this).addClass("ui-dialog-dragging"),t._trigger("dragStart",n,r(i))},drag:function(e,n){t._trigger("drag",e,r(n))},stop:function(i,s){n.position=[s.position.left-t.document.scrollLeft(),s.position.top-t.document.scrollTop()],e(this).removeClass("ui-dialog-dragging"),t._trigger("dragStop",i,r(s)),e.ui.dialog.overlay.resize()}})},_makeResizable:function(n){function u(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}n=n===t?this.options.resizable:n;var r=this,i=this.options,s=this.uiDialog.css("position"),o=typeof n=="string"?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:i.maxWidth,maxHeight:i.maxHeight,minWidth:i.minWidth,minHeight:this._minHeight(),handles:o,start:function(t,n){e(this).addClass("ui-dialog-resizing"),r._trigger("resizeStart",t,u(n))},resize:function(e,t){r._trigger("resize",e,u(t))},stop:function(t,n){e(this).removeClass("ui-dialog-resizing"),i.height=e(this).height(),i.width=e(this).width(),r._trigger("resizeStop",t,u(n)),e.ui.dialog.overlay.resize()}}).css("position",s).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var e=this.options;return e.height==="auto"?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(t){var n=[],r=[0,0],i;if(t){if(typeof t=="string"||typeof t=="object"&&"0"in t)n=t.split?t.split(" "):[t[0],t[1]],n.length===1&&(n[1]=n[0]),e.each(["left","top"],function(e,t){+n[e]===n[e]&&(r[e]=n[e],n[e]=t)}),t={my:n[0]+(r[0]<0?r[0]:"+"+r[0])+" "+n[1]+(r[1]<0?r[1]:"+"+r[1]),at:n.join(" ")};t=e.extend({},e.ui.dialog.prototype.options.position,t)}else t=e.ui.dialog.prototype.options.position;i=this.uiDialog.is(":visible"),i||this.uiDialog.show(),this.uiDialog.position(t),i||this.uiDialog.hide()},_setOptions:function(t){var n=this,s={},o=!1;e.each(t,function(e,t){n._setOption(e,t),e in r&&(o=!0),e in i&&(s[e]=t)}),o&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",s)},_setOption:function(t,r){var i,s,o=this.uiDialog;switch(t){case"buttons":this._createButtons(r);break;case"closeText":this.uiDialogTitlebarCloseText.text(""+r);break;case"dialogClass":o.removeClass(this.options.dialogClass).addClass(n+r);break;case"disabled":r?o.addClass("ui-dialog-disabled"):o.removeClass("ui-dialog-disabled");break;case"draggable":i=o.is(":data(draggable)"),i&&!r&&o.draggable("destroy"),!i&&r&&this._makeDraggable();break;case"position":this._position(r);break;case"resizable":s=o.is(":data(resizable)"),s&&!r&&o.resizable("destroy"),s&&typeof r=="string"&&o.resizable("option","handles",r),!s&&r!==!1&&this._makeResizable(r);break;case"title":e(".ui-dialog-title",this.uiDialogTitlebar).html(""+(r||" "))}this._super(t,r)},_size:function(){var t,n,r,i=this.options,s=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),i.minWidth>i.width&&(i.width=i.minWidth),t=this.uiDialog.css({height:"auto",width:i.width}).outerHeight(),n=Math.max(0,i.minHeight-t),i.height==="auto"?e.support.minHeight?this.element.css({minHeight:n,height:"auto"}):(this.uiDialog.show(),r=this.element.css("height","auto").height(),s||this.uiDialog.hide(),this.element.height(Math.max(r,n))):this.element.height(Math.max(i.height-t,0)),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),e.extend(e.ui.dialog,{uuid:0,maxZ:0,getTitleId:function(e){var t=e.attr("id");return t||(this.uuid+=1,t=this.uuid),"ui-dialog-title-"+t},overlay:function(t){this.$el=e.ui.dialog.overlay.create(t)}}),e.extend(e.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:e.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(e){return e+".dialog-overlay"}).join(" "),create:function(t){this.instances.length===0&&(setTimeout(function(){e.ui.dialog.overlay.instances.length&&e(document).bind(e.ui.dialog.overlay.events,function(t){if(e(t.target).zIndex()").addClass("ui-widget-overlay");return e(document).bind("keydown.dialog-overlay",function(r){var i=e.ui.dialog.overlay.instances;i.length!==0&&i[i.length-1]===n&&t.options.closeOnEscape&&!r.isDefaultPrevented()&&r.keyCode&&r.keyCode===e.ui.keyCode.ESCAPE&&(t.close(r),r.preventDefault())}),n.appendTo(document.body).css({width:this.width(),height:this.height()}),e.fn.bgiframe&&n.bgiframe(),this.instances.push(n),n},destroy:function(t){var n=e.inArray(t,this.instances),r=0;n!==-1&&this.oldInstances.push(this.instances.splice(n,1)[0]),this.instances.length===0&&e([document,window]).unbind(".dialog-overlay"),t.height(0).width(0).remove(),e.each(this.instances,function(){r=Math.max(r,this.css("z-index"))}),this.maxZ=r},height:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),n=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),t1&&b.splice.apply(b,[1,0].concat(b.splice(w,c+1))),r.dequeue()}}(jQuery),function(e,t){e.effects.effect.clip=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"vertical",a=u==="vertical",f=a?"height":"width",l=a?"top":"left",c={},h,p,d;e.effects.save(r,i),r.show(),h=e.effects.createWrapper(r).css({overflow:"hidden"}),p=r[0].tagName==="IMG"?h:r,d=p[f](),o&&(p.css(f,0),p.css(l,d/2)),c[f]=o?d:0,c[l]=o?0:d/2,p.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o||r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}}(jQuery),function(e,t){e.effects.effect.drop=function(t,n){var r=e(this),i=["position","top","bottom","left","right","opacity","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left"?"pos":"neg",l={opacity:o?1:0},c;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),c=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0)/2,o&&r.css("opacity",0).css(a,f==="pos"?-c:c),l[a]=(o?f==="pos"?"+=":"-=":f==="pos"?"-=":"+=")+c,r.animate(l,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}}(jQuery),function(e,t){e.effects.effect.explode=function(t,n){function y(){c.push(this),c.length===r*i&&b()}function b(){s.css({visibility:"visible"}),e(c).remove(),u||s.hide(),n()}var r=t.pieces?Math.round(Math.sqrt(t.pieces)):3,i=r,s=e(this),o=e.effects.setMode(s,t.mode||"hide"),u=o==="show",a=s.show().css("visibility","hidden").offset(),f=Math.ceil(s.outerWidth()/i),l=Math.ceil(s.outerHeight()/r),c=[],h,p,d,v,m,g;for(h=0;h
").css({position:"absolute",visibility:"visible",left:-p*f,top:-h*l}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:f,height:l,left:d+(u?m*f:0),top:v+(u?g*l:0),opacity:u?0:1}).animate({left:d+(u?0:m*f),top:v+(u?0:g*l),opacity:u?1:0},t.duration||500,t.easing,y)}}}(jQuery),function(e,t){e.effects.effect.fade=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"toggle");r.animate({opacity:i},{queue:!1,duration:t.duration,easing:t.easing,complete:n})}}(jQuery),function(e,t){e.effects.effect.fold=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=s==="hide",a=t.size||15,f=/([0-9]+)%/.exec(a),l=!!t.horizFirst,c=o!==l,h=c?["width","height"]:["height","width"],p=t.duration/2,d,v,m={},g={};e.effects.save(r,i),r.show(),d=e.effects.createWrapper(r).css({overflow:"hidden"}),v=c?[d.width(),d.height()]:[d.height(),d.width()],f&&(a=parseInt(f[1],10)/100*v[u?0:1]),o&&d.css(l?{height:0,width:a}:{height:a,width:0}),m[h[0]]=o?v[0]:a,g[h[1]]=o?v[1]:0,d.animate(m,p,t.easing).animate(g,p,t.easing,function(){u&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()})}}(jQuery),function(e,t){e.effects.effect.highlight=function(t,n){var r=e(this),i=["backgroundImage","backgroundColor","opacity"],s=e.effects.setMode(r,t.mode||"show"),o={backgroundColor:r.css("backgroundColor")};s==="hide"&&(o.opacity=0),e.effects.save(r,i),r.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(o,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),n()}})}}(jQuery),function(e,t){e.effects.effect.pulsate=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"show"),s=i==="show",o=i==="hide",u=s||i==="hide",a=(t.times||5)*2+(u?1:0),f=t.duration/a,l=0,c=r.queue(),h=c.length,p;if(s||!r.is(":visible"))r.css("opacity",0).show(),l=1;for(p=1;p1&&c.splice.apply(c,[1,0].concat(c.splice(h,a+1))),r.dequeue()}}(jQuery),function(e,t){e.effects.effect.puff=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"hide"),s=i==="hide",o=parseInt(t.percent,10)||150,u=o/100,a={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()};e.extend(t,{effect:"scale",queue:!1,fade:!0,mode:i,complete:n,percent:s?o:100,from:s?a:{height:a.height*u,width:a.width*u,outerHeight:a.outerHeight*u,outerWidth:a.outerWidth*u}}),r.effect(t)},e.effects.effect.scale=function(t,n){var r=e(this),i=e.extend(!0,{},t),s=e.effects.setMode(r,t.mode||"effect"),o=parseInt(t.percent,10)||(parseInt(t.percent,10)===0?0:s==="hide"?0:100),u=t.direction||"both",a=t.origin,f={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()},l={y:u!=="horizontal"?o/100:1,x:u!=="vertical"?o/100:1};i.effect="size",i.queue=!1,i.complete=n,s!=="effect"&&(i.origin=a||["middle","center"],i.restore=!0),i.from=t.from||(s==="show"?{height:0,width:0,outerHeight:0,outerWidth:0}:f),i.to={height:f.height*l.y,width:f.width*l.x,outerHeight:f.outerHeight*l.y,outerWidth:f.outerWidth*l.x},i.fade&&(s==="show"&&(i.from.opacity=0,i.to.opacity=1),s==="hide"&&(i.from.opacity=1,i.to.opacity=0)),r.effect(i)},e.effects.effect.size=function(t,n){var r,i,s,o=e(this),u=["position","top","bottom","left","right","width","height","overflow","opacity"],a=["position","top","bottom","left","right","overflow","opacity"],f=["width","height","overflow"],l=["fontSize"],c=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=e.effects.setMode(o,t.mode||"effect"),d=t.restore||p!=="effect",v=t.scale||"both",m=t.origin||["middle","center"],g=o.css("position"),y=d?u:a,b={height:0,width:0,outerHeight:0,outerWidth:0};p==="show"&&o.show(),r={height:o.height(),width:o.width(),outerHeight:o.outerHeight(),outerWidth:o.outerWidth()},t.mode==="toggle"&&p==="show"?(o.from=t.to||b,o.to=t.from||r):(o.from=t.from||(p==="show"?b:r),o.to=t.to||(p==="hide"?b:r)),s={from:{y:o.from.height/r.height,x:o.from.width/r.width},to:{y:o.to.height/r.height,x:o.to.width/r.width}};if(v==="box"||v==="both")s.from.y!==s.to.y&&(y=y.concat(c),o.from=e.effects.setTransition(o,c,s.from.y,o.from),o.to=e.effects.setTransition(o,c,s.to.y,o.to)),s.from.x!==s.to.x&&(y=y.concat(h),o.from=e.effects.setTransition(o,h,s.from.x,o.from),o.to=e.effects.setTransition(o,h,s.to.x,o.to));(v==="content"||v==="both")&&s.from.y!==s.to.y&&(y=y.concat(l).concat(f),o.from=e.effects.setTransition(o,l,s.from.y,o.from),o.to=e.effects.setTransition(o,l,s.to.y,o.to)),e.effects.save(o,y),o.show(),e.effects.createWrapper(o),o.css("overflow","hidden").css(o.from),m&&(i=e.effects.getBaseline(m,r),o.from.top=(r.outerHeight-o.outerHeight())*i.y,o.from.left=(r.outerWidth-o.outerWidth())*i.x,o.to.top=(r.outerHeight-o.to.outerHeight)*i.y,o.to.left=(r.outerWidth-o.to.outerWidth)*i.x),o.css(o.from);if(v==="content"||v==="both")c=c.concat(["marginTop","marginBottom"]).concat(l),h=h.concat(["marginLeft","marginRight"]),f=u.concat(c).concat(h),o.find("*[width]").each(function(){var n=e(this),r={height:n.height(),width:n.width(),outerHeight:n.outerHeight(),outerWidth:n.outerWidth()};d&&e.effects.save(n,f),n.from={height:r.height*s.from.y,width:r.width*s.from.x,outerHeight:r.outerHeight*s.from.y,outerWidth:r.outerWidth*s.from.x},n.to={height:r.height*s.to.y,width:r.width*s.to.x,outerHeight:r.height*s.to.y,outerWidth:r.width*s.to.x},s.from.y!==s.to.y&&(n.from=e.effects.setTransition(n,c,s.from.y,n.from),n.to=e.effects.setTransition(n,c,s.to.y,n.to)),s.from.x!==s.to.x&&(n.from=e.effects.setTransition(n,h,s.from.x,n.from),n.to=e.effects.setTransition(n,h,s.to.x,n.to)),n.css(n.from),n.animate(n.to,t.duration,t.easing,function(){d&&e.effects.restore(n,f)})});o.animate(o.to,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o.to.opacity===0&&o.css("opacity",o.from.opacity),p==="hide"&&o.hide(),e.effects.restore(o,y),d||(g==="static"?o.css({position:"relative",top:o.to.top,left:o.to.left}):e.each(["top","left"],function(e,t){o.css(t,function(t,n){var r=parseInt(n,10),i=e?o.to.left:o.to.top;return n==="auto"?i+"px":r+i+"px"})})),e.effects.removeWrapper(o),n()}})}}(jQuery),function(e,t){e.effects.effect.shake=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"effect"),o=t.direction||"left",u=t.distance||20,a=t.times||3,f=a*2+1,l=Math.round(t.duration/f),c=o==="up"||o==="down"?"top":"left",h=o==="up"||o==="left",p={},d={},v={},m,g=r.queue(),y=g.length;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),p[c]=(h?"-=":"+=")+u,d[c]=(h?"+=":"-=")+u*2,v[c]=(h?"-=":"+=")+u*2,r.animate(p,l,t.easing);for(m=1;m1&&g.splice.apply(g,[1,0].concat(g.splice(y,f+1))),r.dequeue()}}(jQuery),function(e,t){e.effects.effect.slide=function(t,n){var r=e(this),i=["position","top","bottom","left","right","width","height"],s=e.effects.setMode(r,t.mode||"show"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left",l,c={};e.effects.save(r,i),r.show(),l=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(r).css({overflow:"hidden"}),o&&r.css(a,f?isNaN(l)?"-"+l:-l:l),c[a]=(o?f?"+=":"-=":f?"-=":"+=")+l,r.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}}(jQuery),function(e,t){e.effects.effect.transfer=function(t,n){var r=e(this),i=e(t.to),s=i.css("position")==="fixed",o=e("body"),u=s?o.scrollTop():0,a=s?o.scrollLeft():0,f=i.offset(),l={top:f.top-u,left:f.left-a,height:i.innerHeight(),width:i.innerWidth()},c=r.offset(),h=e('
').appendTo(document.body).addClass(t.className).css({top:c.top-u,left:c.left-a,height:r.innerHeight(),width:r.innerWidth(),position:s?"fixed":"absolute"}).animate(l,t.duration,t.easing,function(){h.remove(),n()})}}(jQuery),function(e,t){var n=!1;e.widget("ui.menu",{version:"1.9.2",defaultElement:"
    ",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}).bind("click"+this.eventNamespace,e.proxy(function(e){this.options.disabled&&e.preventDefault()},this)),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item > a":function(e){e.preventDefault()},"click .ui-state-disabled > a":function(e){e.preventDefault()},"click .ui-menu-item:has(a)":function(t){var r=e(t.target).closest(".ui-menu-item");!n&&r.not(".ui-state-disabled").length&&(n=!0,this.select(t),r.has(".ui-menu").length?this.expand(t):this.element.is(":focus")||(this.element.trigger("focus",[!0]),this.active&&this.active.parents(".ui-menu").length===1&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){var n=e(t.currentTarget);n.siblings().children(".ui-state-active").removeClass("ui-state-active"),this.focus(t,n)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var n=this.active||this.element.children(".ui-menu-item").eq(0);t||this.focus(e,n)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){e(t.target).closest(".ui-menu").length||this.collapseAll(t),n=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").andSelf().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var n,r,i,s,o,u=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:u=!1,r=this.previousFilter||"",i=String.fromCharCode(t.keyCode),s=!1,clearTimeout(this.filterTimer),i===r?s=!0:i=r+i,o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())}),n=s&&n.index(this.active.next())!==-1?this.active.nextAll(".ui-menu-item"):n,n.length||(i=String.fromCharCode(t.keyCode),o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())})),n.length?(this.focus(t,n),n.length>1?(this.previousFilter=i,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}u&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(e):this.select(e))},refresh:function(){var t,n=this.options.icons.submenu,r=this.element.find(this.options.menus);r.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),r=t.prev("a"),i=e("").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);r.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",r.attr("id"))}),t=r.add(this.element),t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),t.children(":not(.ui-menu-item)").each(function(){var t=e(this);/[^\-—–\s]/.test(t.text())||t.addClass("ui-widget-content ui-menu-divider")}),t.children(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},focus:function(e,t){var n,r;this.blur(e,e&&e.type==="focus"),this._scrollIntoView(t),this.active=t.first(),r=this.active.children("a").addClass("ui-state-focus"),this.options.role&&this.element.attr("aria-activedescendant",r.attr("id")),this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"),e&&e.type==="keydown"?this._close():this.timer=this._delay(function(){this._close()},this.delay),n=t.children(".ui-menu"),n.length&&/^mouse/.test(e.type)&&this._startOpening(n),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var n,r,i,s,o,u;this._hasScroll()&&(n=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,r=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,i=t.offset().top-this.activeMenu.offset().top-n-r,s=this.activeMenu.scrollTop(),o=this.activeMenu.height(),u=t.height(),i<0?this.activeMenu.scrollTop(s+i):i+u>o&&this.activeMenu.scrollTop(s+i-o+u))},blur:function(e,t){t||clearTimeout(this.timer);if(!this.active)return;this.active.children("a").removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active})},_startOpening:function(e){clearTimeout(this.timer);if(e.attr("aria-hidden")!=="true")return;this.timer=this._delay(function(){this._close(),this._open(e)},this.delay)},_open:function(t){var n=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(n)},collapseAll:function(t,n){clearTimeout(this.timer),this.timer=this._delay(function(){var r=n?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));r.length||(r=this.element),this._close(r),this.blur(t),this.activeMenu=r},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find("a.ui-state-active").removeClass("ui-state-active")},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").children(".ui-menu-item").first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,n){var r;this.active&&(e==="first"||e==="last"?r=this.active[e==="first"?"prevAll":"nextAll"](".ui-menu-item").eq(-1):r=this.active[e+"All"](".ui-menu-item").eq(0));if(!r||!r.length||!this.active)r=this.activeMenu.children(".ui-menu-item")[t]();this.focus(n,r)},nextPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isLastItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r-i<0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item")[this.active?"last":"first"]())},previousPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isFirstItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r+i>0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item").first())},_hasScroll:function(){return this.element.outerHeight()
"),o=s.children()[0];return e("body").append(s),r=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,r===i&&(i=s[0].clientWidth),s.remove(),n=r-i},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width0?"right":"center",vertical:u<0?"top":o>0?"bottom":"middle"};lr(i(o),i(u))?h.important="horizontal":h.important="vertical",t.using.call(this,e,h)}),a.offset(e.extend(C,{using:u}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,i=n.isWindow?n.scrollLeft:n.offset.left,s=n.width,o=e.left-t.collisionPosition.marginLeft,u=i-o,a=o+t.collisionWidth-s-i,f;t.collisionWidth>s?u>0&&a<=0?(f=e.left+u+t.collisionWidth-s-i,e.left+=u-f):a>0&&u<=0?e.left=i:u>a?e.left=i+s-t.collisionWidth:e.left=i:u>0?e.left+=u:a>0?e.left-=a:e.left=r(e.left-o,e.left)},top:function(e,t){var n=t.within,i=n.isWindow?n.scrollTop:n.offset.top,s=t.within.height,o=e.top-t.collisionPosition.marginTop,u=i-o,a=o+t.collisionHeight-s-i,f;t.collisionHeight>s?u>0&&a<=0?(f=e.top+u+t.collisionHeight-s-i,e.top+=u-f):a>0&&u<=0?e.top=i:u>a?e.top=i+s-t.collisionHeight:e.top=i:u>0?e.top+=u:a>0?e.top-=a:e.top=r(e.top-o,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,s=n.width,o=n.isWindow?n.scrollLeft:n.offset.left,u=e.left-t.collisionPosition.marginLeft,a=u-o,f=u+t.collisionWidth-s-o,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-s-r;if(p<0||p0){d=e.left-t.collisionPosition.marginLeft+l+c+h-o;if(d>0||i(d)a&&(v<0||v0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-o,e.top+c+h+p>f&&(d>0||i(d)10&&i<11,t.innerHTML="",n.removeChild(t)}(),e.uiBackCompat!==!1&&function(e){var n=e.fn.position;e.fn.position=function(r){if(!r||!r.offset)return n.call(this,r);var i=r.offset.split(" "),s=r.at.split(" ");return i.length===1&&(i[1]=i[0]),/^\d/.test(i[0])&&(i[0]="+"+i[0]),/^\d/.test(i[1])&&(i[1]="+"+i[1]),s.length===1&&(/left|center|right/.test(s[0])?s[1]="center":(s[1]=s[0],s[0]="center")),n.call(this,e.extend(r,{at:s[0]+i[0]+" "+s[1]+i[1],offset:t}))}}(jQuery)}(jQuery),function(e,t){e.widget("ui.progressbar",{version:"1.9.2",options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=e("
").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(e){return e===t?this._value():(this._setOption("value",e),this)},_setOption:function(e,t){e==="value"&&(this.options.value=t,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),this._super(e,t)},_value:function(){var e=this.options.value;return typeof e!="number"&&(e=0),Math.min(this.options.max,Math.max(this.min,e))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var e=this.value(),t=this._percentage();this.oldValue!==e&&(this.oldValue=e,this._trigger("change")),this.valueDiv.toggle(e>this.min).toggleClass("ui-corner-right",e===this.options.max).width(t.toFixed(0)+"%"),this.element.attr("aria-valuenow",e)}})}(jQuery),function(e,t){var n=5;e.widget("ui.slider",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var t,r,i=this.options,s=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),o="",u=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(i.disabled?" ui-slider-disabled ui-disabled":"")),this.range=e([]),i.range&&(i.range===!0&&(i.values||(i.values=[this._valueMin(),this._valueMin()]),i.values.length&&i.values.length!==2&&(i.values=[i.values[0],i.values[0]])),this.range=e("
").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(i.range==="min"||i.range==="max"?" ui-slider-range-"+i.range:""))),r=i.values&&i.values.length||1;for(t=s.length;tn&&(i=n,s=e(this),o=t)}),c.range===!0&&this.values(1)===c.min&&(o+=1,s=e(this.handles[o])),u=this._start(t,o),u===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,s.addClass("ui-state-active").focus(),a=s.offset(),f=!e(t.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=f?{left:0,top:0}:{left:t.pageX-a.left-s.width()/2,top:t.pageY-a.top-s.height()/2-(parseInt(s.css("borderTopWidth"),10)||0)-(parseInt(s.css("borderBottomWidth"),10)||0)+(parseInt(s.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,r),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},n=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,n),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,n,r,i,s;return this.orientation==="horizontal"?(t=this.elementSize.width,n=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,n=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),r=n/t,r>1&&(r=1),r<0&&(r=0),this.orientation==="vertical"&&(r=1-r),i=this._valueMax()-this._valueMin(),s=this._valueMin()+r*i,this._trimAlignValue(s)},_start:function(e,t){var n={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("start",e,n)},_slide:function(e,t,n){var r,i,s;this.options.values&&this.options.values.length?(r=this.values(t?0:1),this.options.values.length===2&&this.options.range===!0&&(t===0&&n>r||t===1&&n1){this.options.values[t]=this._trimAlignValue(n),this._refreshValue(),this._change(null,t);return}if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();r=this.options.values,i=arguments[0];for(s=0;s=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,n=(e-this._valueMin())%t,r=e-n;return Math.abs(n)*2>=t&&(r+=n>0?t:-t),parseFloat(r.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,n,r,i,s,o=this.options.range,u=this.options,a=this,f=this._animateOff?!1:u.animate,l={};this.options.values&&this.options.values.length?this.handles.each(function(r){n=(a.values(r)-a._valueMin())/(a._valueMax()-a._valueMin())*100,l[a.orientation==="horizontal"?"left":"bottom"]=n+"%",e(this).stop(1,1)[f?"animate":"css"](l,u.animate),a.options.range===!0&&(a.orientation==="horizontal"?(r===0&&a.range.stop(1,1)[f?"animate":"css"]({left:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({width:n-t+"%"},{queue:!1,duration:u.animate})):(r===0&&a.range.stop(1,1)[f?"animate":"css"]({bottom:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({height:n-t+"%"},{queue:!1,duration:u.animate}))),t=n}):(r=this.value(),i=this._valueMin(),s=this._valueMax(),n=s!==i?(r-i)/(s-i)*100:0,l[this.orientation==="horizontal"?"left":"bottom"]=n+"%",this.handle.stop(1,1)[f?"animate":"css"](l,u.animate),o==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[f?"animate":"css"]({width:n+"%"},u.animate),o==="max"&&this.orientation==="horizontal"&&this.range[f?"animate":"css"]({width:100-n+"%"},{queue:!1,duration:u.animate}),o==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[f?"animate":"css"]({height:n+"%"},u.animate),o==="max"&&this.orientation==="vertical"&&this.range[f?"animate":"css"]({height:100-n+"%"},{queue:!1,duration:u.animate}))}})}(jQuery),function(e){function t(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.widget("ui.spinner",{version:"1.9.2",defaultElement:"",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var t={},n=this.element;return e.each(["min","max","step"],function(e,r){var i=n.attr(r);i!==undefined&&i.length&&(t[r]=i)}),t},_events:{keydown:function(e){this._start(e)&&this._keydown(e)&&e.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(e){if(this.cancelBlur){delete this.cancelBlur;return}this._refresh(),this.previous!==this.element.val()&&this._trigger("change",e)},mousewheel:function(e,t){if(!t)return;if(!this.spinning&&!this._start(e))return!1;this._spin((t>0?1:-1)*this.options.step,e),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(e)},100),e.preventDefault()},"mousedown .ui-spinner-button":function(t){function r(){var e=this.element[0]===this.document[0].activeElement;e||(this.element.focus(),this.previous=n,this._delay(function(){this.previous=n}))}var n;n=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),t.preventDefault(),r.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,r.call(this)});if(this._start(t)===!1)return;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){if(!e(t.currentTarget).hasClass("ui-state-active"))return;if(this._start(t)===!1)return!1;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var e=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=e.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(e.height()*.5)&&e.height()>0&&e.height(e.height()),this.options.disabled&&this.disable()},_keydown:function(t){var n=this.options,r=e.ui.keyCode;switch(t.keyCode){case r.UP:return this._repeat(null,1,t),!0;case r.DOWN:return this._repeat(null,-1,t),!0;case r.PAGE_UP:return this._repeat(null,n.page,t),!0;case r.PAGE_DOWN:return this._repeat(null,-n.page,t),!0}return!1},_uiSpinnerHtml:function(){return""},_buttonHtml:function(){return""+""+""+""+""},_start:function(e){return!this.spinning&&this._trigger("start",e)===!1?!1:(this.counter||(this.counter=1),this.spinning=!0,!0)},_repeat:function(e,t,n){e=e||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,t,n)},e),this._spin(t*this.options.step,n)},_spin:function(e,t){var n=this.value()||0;this.counter||(this.counter=1),n=this._adjustValue(n+e*this._increment(this.counter));if(!this.spinning||this._trigger("spin",t,{value:n})!==!1)this._value(n),this.counter++},_increment:function(t){var n=this.options.incremental;return n?e.isFunction(n)?n(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var e=this._precisionOf(this.options.step);return this.options.min!==null&&(e=Math.max(e,this._precisionOf(this.options.min))),e},_precisionOf:function(e){var t=e.toString(),n=t.indexOf(".");return n===-1?0:t.length-n-1},_adjustValue:function(e){var t,n,r=this.options;return t=r.min!==null?r.min:0,n=e-t,n=Math.round(n/r.step)*r.step,e=t+n,e=parseFloat(e.toFixed(this._precision())),r.max!==null&&e>r.max?r.max:r.min!==null&&e1&&e.href.replace(r,"")===location.href.replace(r,"").replace(/\s/g,"%20")}var n=0,r=/#.*$/;e.widget("ui.tabs",{version:"1.9.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var t=this,n=this.options,r=n.active,i=location.hash.substring(1);this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",n.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs();if(r===null){i&&this.tabs.each(function(t,n){if(e(n).attr("aria-controls")===i)return r=t,!1}),r===null&&(r=this.tabs.index(this.tabs.filter(".ui-tabs-active")));if(r===null||r===-1)r=this.tabs.length?0:!1}r!==!1&&(r=this.tabs.index(this.tabs.eq(r)),r===-1&&(r=n.collapsible?!1:0)),n.active=r,!n.collapsible&&n.active===!1&&this.anchors.length&&(n.active=0),e.isArray(n.disabled)&&(n.disabled=e.unique(n.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.options.active!==!1&&this.anchors.length?this.active=this._findActive(this.options.active):this.active=e(),this._refresh(),this.active.length&&this.load(n.active)},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var n=e(this.document[0].activeElement).closest("li"),r=this.tabs.index(n),i=!0;if(this._handlePageNav(t))return;switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:r++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:i=!1,r--;break;case e.ui.keyCode.END:r=this.anchors.length-1;break;case e.ui.keyCode.HOME:r=0;break;case e.ui.keyCode.SPACE:t.preventDefault(),clearTimeout(this.activating),this._activate(r);return;case e.ui.keyCode.ENTER:t.preventDefault(),clearTimeout(this.activating),this._activate(r===this.options.active?!1:r);return;default:return}t.preventDefault(),clearTimeout(this.activating),r=this._focusNextTab(r,i),t.ctrlKey||(n.attr("aria-selected","false"),this.tabs.eq(r).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",r)},this.delay))},_panelKeydown:function(t){if(this._handlePageNav(t))return;t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP)return this._activate(this._focusNextTab(this.options.active-1,!1)),!0;if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN)return this._activate(this._focusNextTab(this.options.active+1,!0)),!0},_findNextTab:function(t,n){function i(){return t>r&&(t=0),t<0&&(t=r),t}var r=this.tabs.length-1;while(e.inArray(i(),this.options.disabled)!==-1)t=n?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,t){if(e==="active"){this._activate(t);return}if(e==="disabled"){this._setupDisabled(t);return}this._super(e,t),e==="collapsible"&&(this.element.toggleClass("ui-tabs-collapsible",t),!t&&this.options.active===!1&&this._activate(0)),e==="event"&&this._setupEvents(t),e==="heightStyle"&&this._setupHeightStyle(t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+i()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,n=this.tablist.children(":has(a[href])");t.disabled=e.map(n.filter(".ui-state-disabled"),function(e){return n.index(e)}),this._processTabs(),t.active===!1||!this.anchors.length?(t.active=!1,this.active=e()):this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(n,r){var i,o,u,a=e(r).uniqueId().attr("id"),f=e(r).closest("li"),l=f.attr("aria-controls");s(r)?(i=r.hash,o=t.element.find(t._sanitizeSelector(i))):(u=t._tabId(f),i="#"+u,o=t.element.find(i),o.length||(o=t._createPanel(u),o.insertAfter(t.panels[n-1]||t.tablist)),o.attr("aria-live","polite")),o.length&&(t.panels=t.panels.add(o)),l&&f.data("ui-tabs-aria-controls",l),f.attr({"aria-controls":i.substring(1),"aria-labelledby":a}),o.attr("aria-labelledby",a)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("
").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var n=0,r;r=this.tabs[n];n++)t===!0||e.inArray(n,t)!==-1?e(r).addClass("ui-state-disabled").attr("aria-disabled","true"):e(r).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var n={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,n),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var n,r,i=this.element.parent();t==="fill"?(e.support.minHeight||(r=i.css("overflow"),i.css("overflow","hidden")),n=i.height(),this.element.siblings(":visible").each(function(){var t=e(this),r=t.css("position");if(r==="absolute"||r==="fixed")return;n-=t.outerHeight(!0)}),r&&i.css("overflow",r),this.element.children().not(this.panels).each(function(){n-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,n-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):t==="auto"&&(n=0,this.panels.each(function(){n=Math.max(n,e(this).height("").height())}).height(n))},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i.closest("li"),o=s[0]===r[0],u=o&&n.collapsible,a=u?e():this._getPanelForTab(s),f=r.length?this._getPanelForTab(r):e(),l={oldTab:r,oldPanel:f,newTab:u?e():s,newPanel:a};t.preventDefault();if(s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||o&&!n.collapsible||this._trigger("beforeActivate",t,l)===!1)return;n.active=u?!1:this.tabs.index(s),this.active=o?e():s,this.xhr&&this.xhr.abort(),!f.length&&!a.length&&e.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,l)},_toggle:function(t,n){function o(){r.running=!1,r._trigger("activate",t,n)}function u(){n.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),i.length&&r.options.show?r._show(i,r.options.show,o):(i.show(),o())}var r=this,i=n.newPanel,s=n.oldPanel;this.running=!0,s.length&&this.options.hide?this._hide(s,this.options.hide,function(){n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),s.hide(),u()),s.attr({"aria-expanded":"false","aria-hidden":"true"}),n.oldTab.attr("aria-selected","false"),i.length&&s.length?n.oldTab.attr("tabIndex",-1):i.length&&this.tabs.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),i.attr({"aria-expanded":"true","aria-hidden":"false"}),n.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var n,r=this._findActive(t);if(r[0]===this.active[0])return;r.length||(r=this.active),n=r.find(".ui-tabs-anchor")[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return typeof e=="string"&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeData("href.tabs").removeData("load.tabs").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),n=t.data("ui-tabs-aria-controls");n?t.attr("aria-controls",n):t.removeAttr("aria-controls")}),this.panels.show(),this.options.heightStyle!=="content"&&this.panels.css("height","")},enable:function(n){var r=this.options.disabled;if(r===!1)return;n===t?r=!1:(n=this._getIndex(n),e.isArray(r)?r=e.map(r,function(e){return e!==n?e:null}):r=e.map(this.tabs,function(e,t){return t!==n?t:null})),this._setupDisabled(r)},disable:function(n){var r=this.options.disabled;if(r===!0)return;if(n===t)r=!0;else{n=this._getIndex(n);if(e.inArray(n,r)!==-1)return;e.isArray(r)?r=e.merge([n],r).sort():r=[n]}this._setupDisabled(r)},load:function(t,n){t=this._getIndex(t);var r=this,i=this.tabs.eq(t),o=i.find(".ui-tabs-anchor"),u=this._getPanelForTab(i),a={tab:i,panel:u};if(s(o[0]))return;this.xhr=e.ajax(this._ajaxSettings(o,n,a)),this.xhr&&this.xhr.statusText!=="canceled"&&(i.addClass("ui-tabs-loading"),u.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){u.html(e),r._trigger("load",n,a)},1)}).complete(function(e,t){setTimeout(function(){t==="abort"&&r.panels.stop(!1,!0),i.removeClass("ui-tabs-loading"),u.removeAttr("aria-busy"),e===r.xhr&&delete r.xhr},1)}))},_ajaxSettings:function(t,n,r){var i=this;return{url:t.attr("href"),beforeSend:function(t,s){return i._trigger("beforeLoad",n,e.extend({jqXHR:t,ajaxSettings:s},r))}}},_getPanelForTab:function(t){var n=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+n))}}),e.uiBackCompat!==!1&&(e.ui.tabs.prototype._ui=function(e,t){return{tab:e,panel:t,index:this.anchors.index(e)}},e.widget("ui.tabs",e.ui.tabs,{url:function(e,t){this.anchors.eq(e).attr("href",t)}}),e.widget("ui.tabs",e.ui.tabs,{options:{ajaxOptions:null,cache:!1},_create:function(){this._super();var t=this;this._on({tabsbeforeload:function(n,r){if(e.data(r.tab[0],"cache.tabs")){n.preventDefault();return}r.jqXHR.success(function(){t.options.cache&&e.data(r.tab[0],"cache.tabs",!0)})}})},_ajaxSettings:function(t,n,r){var i=this.options.ajaxOptions;return e.extend({},i,{error:function(e,t){try{i.error(e,t,r.tab.closest("li").index(),r.tab[0])}catch(n){}}},this._superApply(arguments))},_setOption:function(e,t){e==="cache"&&t===!1&&this.anchors.removeData("cache.tabs"),this._super(e,t)},_destroy:function(){this.anchors.removeData("cache.tabs"),this._super()},url:function(e){this.anchors.eq(e).removeData("cache.tabs"),this._superApply(arguments)}}),e.widget("ui.tabs",e.ui.tabs,{abort:function(){this.xhr&&this.xhr.abort()}}),e.widget("ui.tabs",e.ui.tabs,{options:{spinner:"Loading…"},_create:function(){this._super(),this._on({tabsbeforeload:function(e,t){if(e.target!==this.element[0]||!this.options.spinner)return;var n=t.tab.find("span"),r=n.html();n.html(this.options.spinner),t.jqXHR.complete(function(){n.html(r)})}})}}),e.widget("ui.tabs",e.ui.tabs,{options:{enable:null,disable:null},enable:function(t){var n=this.options,r;if(t&&n.disabled===!0||e.isArray(n.disabled)&&e.inArray(t,n.disabled)!==-1)r=!0;this._superApply(arguments),r&&this._trigger("enable",null,this._ui(this.anchors[t],this.panels[t]))},disable:function(t){var n=this.options,r;if(t&&n.disabled===!1||e.isArray(n.disabled)&&e.inArray(t,n.disabled)===-1)r=!0;this._superApply(arguments),r&&this._trigger("disable",null,this._ui(this.anchors[t],this.panels[t]))}}),e.widget("ui.tabs",e.ui.tabs,{options:{add:null,remove:null,tabTemplate:"
  • #{label}
  • "},add:function(n,r,i){i===t&&(i=this.anchors.length);var s,o,u=this.options,a=e(u.tabTemplate.replace(/#\{href\}/g,n).replace(/#\{label\}/g,r)),f=n.indexOf("#")?this._tabId(a):n.replace("#","");return a.addClass("ui-state-default ui-corner-top").data("ui-tabs-destroy",!0),a.attr("aria-controls",f),s=i>=this.tabs.length,o=this.element.find("#"+f),o.length||(o=this._createPanel(f),s?i>0?o.insertAfter(this.panels.eq(-1)):o.appendTo(this.element):o.insertBefore(this.panels[i])),o.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").hide(),s?a.appendTo(this.tablist):a.insertBefore(this.tabs[i]),u.disabled=e.map(u.disabled,function(e){return e>=i?++e:e}),this.refresh(),this.tabs.length===1&&u.active===!1&&this.option("active",0),this._trigger("add",null,this._ui(this.anchors[i],this.panels[i])),this},remove:function(t){t=this._getIndex(t);var n=this.options,r=this.tabs.eq(t).remove(),i=this._getPanelForTab(r).remove();return r.hasClass("ui-tabs-active")&&this.anchors.length>2&&this._activate(t+(t+1=t?--e:e}),this.refresh(),this._trigger("remove",null,this._ui(r.find("a")[0],i[0])),this}}),e.widget("ui.tabs",e.ui.tabs,{length:function(){return this.anchors.length}}),e.widget("ui.tabs",e.ui.tabs,{options:{idPrefix:"ui-tabs-"},_tabId:function(t){var n=t.is("li")?t.find("a[href]"):t;return n=n[0],e(n).closest("li").attr("aria-controls")||n.title&&n.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF\-]/g,"")||this.options.idPrefix+i()}}),e.widget("ui.tabs",e.ui.tabs,{options:{panelTemplate:"
    "},_createPanel:function(t){return e(this.options.panelTemplate).attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)}}),e.widget("ui.tabs",e.ui.tabs,{_create:function(){var e=this.options;e.active===null&&e.selected!==t&&(e.active=e.selected===-1?!1:e.selected),this._super(),e.selected=e.active,e.selected===!1&&(e.selected=-1)},_setOption:function(e,t){if(e!=="selected")return this._super(e,t);var n=this.options;this._super("active",t===-1?!1:t),n.selected=n.active,n.selected===!1&&(n.selected=-1)},_eventHandler:function(){this._superApply(arguments),this.options.selected=this.options.active,this.options.selected===!1&&(this.options.selected=-1)}}),e.widget("ui.tabs",e.ui.tabs,{options:{show:null,select:null},_create:function(){this._super(),this.options.active!==!1&&this._trigger("show",null,this._ui(this.active.find(".ui-tabs-anchor")[0],this._getPanelForTab(this.active)[0]))},_trigger:function(e,t,n){var r,i,s=this._superApply(arguments);return s?(e==="beforeActivate"?(r=n.newTab.length?n.newTab:n.oldTab,i=n.newPanel.length?n.newPanel:n.oldPanel,s=this._super("select",t,{tab:r.find(".ui-tabs-anchor")[0],panel:i[0],index:r.closest("li").index()})):e==="activate"&&n.newTab.length&&(s=this._super("show",t,{tab:n.newTab.find(".ui-tabs-anchor")[0],panel:n.newPanel[0],index:n.newTab.closest("li").index()})),s):!1}}),e.widget("ui.tabs",e.ui.tabs,{select:function(e){e=this._getIndex(e);if(e===-1){if(!this.options.collapsible||this.options.selected===-1)return;e=this.options.selected}this.anchors.eq(e).trigger(this.options.event+this.eventNamespace)}}),function(){var t=0;e.widget("ui.tabs",e.ui.tabs,{options:{cookie:null},_create:function(){var e=this.options,t;e.active==null&&e.cookie&&(t=parseInt(this._cookie(),10),t===-1&&(t=!1),e.active=t),this._super()},_cookie:function(n){var r=[this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++t)];return arguments.length&&(r.push(n===!1?-1:n),r.push(this.options.cookie)),e.cookie.apply(null,r)},_refresh:function(){this._super(),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_eventHandler:function(){this._superApply(arguments),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_destroy:function(){this._super(),this.options.cookie&&this._cookie(null,this.options.cookie)}})}(),e.widget("ui.tabs",e.ui.tabs,{_trigger:function(t,n,r){var i=e.extend({},r);return t==="load"&&(i.panel=i.panel[0],i.tab=i.tab.find(".ui-tabs-anchor")[0]),this._super(t,n,i)}}),e.widget("ui.tabs",e.ui.tabs,{options:{fx:null},_getFx:function(){var t,n,r=this.options.fx;return r&&(e.isArray(r)?(t=r[0],n=r[1]):t=n=r),r?{show:n,hide:t}:null},_toggle:function(e,t){function o(){n.running=!1,n._trigger("activate",e,t)}function u(){t.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&s.show?r.animate(s.show,s.show.duration,function(){o()}):(r.show(),o())}var n=this,r=t.newPanel,i=t.oldPanel,s=this._getFx();if(!s)return this._super(e,t);n.running=!0,i.length&&s.hide?i.animate(s.hide,s.hide.duration,function(){t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i.hide(),u())}}))}(jQuery),function(e){function n(t,n){var r=(t.attr("aria-describedby")||"").split(/\s+/);r.push(n),t.data("ui-tooltip-id",n).attr("aria-describedby",e.trim(r.join(" ")))}function r(t){var n=t.data("ui-tooltip-id"),r=(t.attr("aria-describedby")||"").split(/\s+/),i=e.inArray(n,r);i!==-1&&r.splice(i,1),t.removeData("ui-tooltip-id"),r=e.trim(r.join(" ")),r?t.attr("aria-describedby",r):t.removeAttr("aria-describedby")}var t=0;e.widget("ui.tooltip",{version:"1.9.2",options:{content:function(){return e(this).attr("title")},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(t,n){var r=this;if(t==="disabled"){this[n?"_disable":"_enable"](),this.options[t]=n;return}this._super(t,n),t==="content"&&e.each(this.tooltips,function(e,t){r._updateContent(t)})},_disable:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0)}),this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var n=this,r=e(t?t.target:this.element).closest(this.options.items);if(!r.length||r.data("ui-tooltip-id"))return;r.attr("title")&&r.data("ui-tooltip-title",r.attr("title")),r.data("ui-tooltip-open",!0),t&&t.type==="mouseover"&&r.parents().each(function(){var t=e(this),r;t.data("ui-tooltip-open")&&(r=e.Event("blur"),r.target=r.currentTarget=this,n.close(r,!0)),t.attr("title")&&(t.uniqueId(),n.parents[this.id]={element:this,title:t.attr("title")},t.attr("title",""))}),this._updateContent(r,t)},_updateContent:function(e,t){var n,r=this.options.content,i=this,s=t?t.type:null;if(typeof r=="string")return this._open(t,e,r);n=r.call(e[0],function(n){if(!e.data("ui-tooltip-open"))return;i._delay(function(){t&&(t.type=s),this._open(t,e,n)})}),n&&this._open(t,e,n)},_open:function(t,r,i){function f(e){a.of=e;if(s.is(":hidden"))return;s.position(a)}var s,o,u,a=e.extend({},this.options.position);if(!i)return;s=this._find(r);if(s.length){s.find(".ui-tooltip-content").html(i);return}r.is("[title]")&&(t&&t.type==="mouseover"?r.attr("title",""):r.removeAttr("title")),s=this._tooltip(r),n(r,s.attr("id")),s.find(".ui-tooltip-content").html(i),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:f}),f(t)):s.position(e.extend({of:r},this.options.position)),s.hide(),this._show(s,this.options.show),this.options.show&&this.options.show.delay&&(u=setInterval(function(){s.is(":visible")&&(f(a.of),clearInterval(u))},e.fx.interval)),this._trigger("open",t,{tooltip:s}),o={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var n=e.Event(t);n.currentTarget=r[0],this.close(n,!0)}},remove:function(){this._removeTooltip(s)}};if(!t||t.type==="mouseover")o.mouseleave="close";if(!t||t.type==="focusin")o.focusout="close";this._on(!0,r,o)},close:function(t){var n=this,i=e(t?t.currentTarget:this.element),s=this._find(i);if(this.closing)return;i.data("ui-tooltip-title")&&i.attr("title",i.data("ui-tooltip-title")),r(i),s.stop(!0),this._hide(s,this.options.hide,function(){n._removeTooltip(e(this))}),i.removeData("ui-tooltip-open"),this._off(i,"mouseleave focusout keyup"),i[0]!==this.element[0]&&this._off(i,"remove"),this._off(this.document,"mousemove"),t&&t.type==="mouseleave"&&e.each(this.parents,function(t,r){e(r.element).attr("title",r.title),delete n.parents[t]}),this.closing=!0,this._trigger("close",t,{tooltip:s}),this.closing=!1},_tooltip:function(n){var r="ui-tooltip-"+t++,i=e("
    ").attr({id:r,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return e("
    ").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),e.fn.bgiframe&&i.bgiframe(),this.tooltips[r]=n,i},_find:function(t){var n=t.data("ui-tooltip-id");return n?e("#"+n):e()},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0),e("#"+n).remove(),r.data("ui-tooltip-title")&&(r.attr("title",r.data("ui-tooltip-title")),r.removeData("ui-tooltip-title"))})}})}(jQuery); \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery.ui.touch-punch-0.2.2.min.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery.ui.touch-punch-0.2.2.min.js new file mode 100644 index 000000000..33d6f97e5 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/external/jquery.ui.touch-punch-0.2.2.min.js @@ -0,0 +1,11 @@ +/* + * jQuery UI Touch Punch 0.2.2 + * + * Copyright 2011, Dave Furfero + * Dual licensed under the MIT or GPL Version 2 licenses. + * + * Depends: + * jquery.ui.widget.js + * jquery.ui.mouse.js + */ +(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery); \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/demo-list.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/demo-list.js new file mode 100644 index 000000000..950ca9164 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/demo-list.js @@ -0,0 +1,67 @@ +// +// this file is just used to automate the process of adding links to the individual demos to their previous/next +// demo. you don't need to concern yourself with what's going on in here. +// +; +(function () { + var list = [ + [ "flowchart", "Flowchart" ], + [ "statemachine", "State Machine" ], + [ "draggableConnectors", "Drag and Drop"], + [ "perimeterAnchors", "Perimeter Anchors"], + [ "chart", "Hierarchical Chart" ], + [ "sourcesAndTargets", "Sources and Targets" ], + [ "dynamicAnchors", "Dynamic Anchors" ], + [ "animation", "Animation" ] + ]; + + jsPlumb.bind("ready", function () { + var current = document.body.getAttribute("data-demo-id"); + + if (current) { + var idx = jsPlumbUtil.findWithFunction(list, function (i) { + return i[0] == current; + }), + prev = idx == 0 ? list.length - 1 : idx - 1, + next = idx == list.length - 1 ? 0 : idx + 1, + _d = function (tag, clazz, parent, html, atts, atStart) { + var d = document.createElement(tag); + d.className = clazz; + if (parent) { + if (atStart && parent.childNodes.length > 0) + parent.insertBefore(d, parent.firstChild); + else + parent.appendChild(d); + } + if (html) d.innerHTML = html; + if (atts) { + for (var i in atts) + d.setAttribute(i, atts[i]); + } + return d; + }; + + // next/previous links + var d = _d("div", "demo-links", document.body), + dp = _d("div", "", d, "" + list[prev][1] + ""), + dc = _d("div", "current-library", d, list[idx][1]), + dn = _d("div", "", d, "" + list[next][1] + ""); + + // make a drop down. + var m = document.querySelectorAll(".menu")[0], + sel = _d("select", "", m, null, null, true); + for (var i = 0; i < list.length; i++) { + var opts = {"data-href": "../" + list[i][0] + "/dom.html"}; + if (list[i][0] == current) + opts["selected"] = true; + _d("option", "", sel, list[i][1], opts, null); + } + jsPlumb.on(sel, "change", function () { + document.location = sel.options[sel.selectedIndex].getAttribute("data-href"); + }); + sel.style.marginRight = "20px"; + + } + + }); +})(); \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6-min.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6-min.js new file mode 100644 index 000000000..0ab4bfd34 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6-min.js @@ -0,0 +1,6 @@ +(function(){"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:a>0?1:-1});var a={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},b=64,c=Math.pow(2,-b-1),d=function(b,c){for(var d=[],e=f(b,c),h=c.length-1,i=2*h-1,j=g(e,i,d,0),k=a.subtract(b,c[0]),m=a.square(k),n=0,o=0;j>o;o++){k=a.subtract(b,l(c,h,d[o],null,null));var p=a.square(k);m>p&&(m=p,n=d[o])}return k=a.subtract(b,c[h]),p=a.square(k),m>p&&(m=p,n=1),{location:n,distance:m}},e=function(a,b){var c=d(a,b);return{point:l(b,b.length-1,c.location,null,null),location:c.location}},f=function(b,c){for(var d=c.length-1,e=2*d-1,f=[],g=[],h=[],i=[],k=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]],l=0;d>=l;l++)f[l]=a.subtract(c[l],b);for(var l=0;d-1>=l;l++)g[l]=a.subtract(c[l+1],c[l]),g[l]=a.scale(g[l],3);for(var m=0;d-1>=m;m++)for(var n=0;d>=n;n++)h[m]||(h[m]=[]),h[m][n]=a.dotProduct(g[m],f[n]);for(l=0;e>=l;l++)i[l]||(i[l]=[]),i[l].y=0,i[l].x=parseFloat(l)/e;for(var o=d,p=d-1,q=0;o+p>=q;q++){var r=Math.max(0,q-p),s=Math.min(q,o);for(l=r;s>=l;l++)j=q-l,i[l+j].y+=h[j][l]*k[j][l]}return i},g=function(a,c,d,e){var f,j,m=[],n=[],o=[],p=[];switch(h(a,c)){case 0:return 0;case 1:if(e>=b)return d[0]=(a[0].x+a[c].x)/2,1;if(i(a,c))return d[0]=k(a,c),1}l(a,c,.5,m,n),f=g(m,c,o,e+1),j=g(n,c,p,e+1);for(var q=0;f>q;q++)d[q]=o[q];for(var q=0;j>q;q++)d[q+f]=p[q];return f+j},h=function(a,b){var c,d,e=0;c=d=Math.sgn(a[0].y);for(var f=1;b>=f;f++)c=Math.sgn(a[f].y),c!=d&&e++,d=c;return e},i=function(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;i=a[0].y-a[b].y,j=a[b].x-a[0].x,k=a[0].x*a[b].y-a[b].x*a[0].y;for(var t=max_distance_below=0,u=1;b>u;u++){var v=i*a[u].x+j*a[u].y+k;v>t?t=v:max_distance_below>v&&(max_distance_below=v)}return n=0,o=1,p=0,q=i,r=j,s=k-t,l=n*r-q*o,m=1/l,e=(o*s-r*p)*m,q=i,r=j,s=k-max_distance_below,l=n*r-q*o,m=1/l,f=(o*s-r*p)*m,g=Math.min(e,f),h=Math.max(e,f),d=h-g,c>d?1:0},k=function(a,b){var c=1,d=0,e=a[b].x-a[0].x,f=a[b].y-a[0].y,g=a[0].x-0,h=a[0].y-0,i=e*d-f*c,j=1/i,k=(e*h-f*g)*j;return 0+c*k},l=function(a,b,c,d,e){for(var f=[[]],g=0;b>=g;g++)f[0][g]=a[g];for(var h=1;b>=h;h++)for(var g=0;b-h>=g;g++)f[h]||(f[h]=[]),f[h][g]||(f[h][g]={}),f[h][g].x=(1-c)*f[h-1][g].x+c*f[h-1][g+1].x,f[h][g].y=(1-c)*f[h-1][g].y+c*f[h-1][g+1].y;if(null!=d)for(g=0;b>=g;g++)d[g]=f[g][0];if(null!=e)for(g=0;b>=g;g++)e[g]=f[b-g][g];return f[b][0]},m={},n=function(a){var b=m[a];if(!b){b=[];var c=function(){return function(b){return Math.pow(b,a)}},d=function(){return function(b){return Math.pow(1-b,a)}},e=function(a){return function(){return a}},f=function(){return function(a){return a}},g=function(){return function(a){return 1-a}},h=function(a){return function(b){for(var c=1,d=0;di;i++){for(var j=[new e(a)],k=0;a-i>k;k++)j.push(new f);for(var k=0;i>k;k++)j.push(new g);b.push(new h(j))}b.push(new d),m[a]=b}return b},o=function(a,b){for(var c=n(a.length-1),d=0,e=0,f=0;f0?1:-1,h=null;ed;)d+=.005*e,f=o(a,d),c+=p(f,b),b=f;return c},t=function(a,b,c){return r(a,b,c).point},u=function(a,b,c){return r(a,b,c).location},v=function(a,b){var c=o(a,b),d=o(a.slice(0,a.length-1),b),e=d.y-c.y,f=d.x-c.x;return 0==e?1/0:Math.atan(e/f)},w=function(a,b,c){var d=r(a,b,c);return d.location>1&&(d.location=1),d.location<0&&(d.location=0),v(a,d.location)},x=function(a,b,c,d){d=null==d?0:d;var e=r(a,b,d),f=v(a,e.location),g=Math.atan(-1/f),h=c/2*Math.sin(g),i=c/2*Math.cos(g);return[{x:e.point.x+i,y:e.point.y+h},{x:e.point.x-i,y:e.point.y-h}]};this.jsBezier={distanceFromCurve:d,gradientAtPoint:v,gradientAtPointAlongCurveFrom:w,nearestPointOnCurve:e,pointOnCurve:o,pointAlongCurveFrom:t,perpendicularToCurveAt:x,locationAlongCurveFrom:u,getLength:s}}).call(this),function(){"use strict";var a=this.Biltong={},b=function(a){return"[object Array]"===Object.prototype.toString.call(a)},c=function(a,c,d){return a=b(a)?a:[a.x,a.y],c=b(c)?c:[c.x,c.y],d(a,c)},d=a.gradient=function(a,b){return c(a,b,function(a,b){return b[0]==a[0]?b[1]>a[1]?1/0:-1/0:b[1]==a[1]?b[0]>a[0]?0:-0:(b[1]-a[1])/(b[0]-a[0])})},e=(a.normal=function(a,b){return-1/d(a,b)},a.lineLength=function(a,b){return c(a,b,function(a,b){return Math.sqrt(Math.pow(b[1]-a[1],2)+Math.pow(b[0]-a[0],2))})},a.quadrant=function(a,b){return c(a,b,function(a,b){return b[0]>a[0]?b[1]>a[1]?2:1:b[0]==a[0]?b[1]>a[1]?2:1:b[1]>a[1]?3:4})}),f=(a.theta=function(a,b){return c(a,b,function(a,b){var c=d(a,b),f=Math.atan(c),g=e(a,b);return(4==g||3==g)&&(f+=Math.PI),0>f&&(f+=2*Math.PI),f})},a.intersects=function(a,b){var c=a.x,d=a.x+a.w,e=a.y,f=a.y+a.h,g=b.x,h=b.x+b.w,i=b.y,j=b.y+b.h;return g>=c&&d>=g&&i>=e&&f>=i||h>=c&&d>=h&&i>=e&&f>=i||g>=c&&d>=g&&j>=e&&f>=j||h>=c&&d>=g&&j>=e&&f>=j||c>=g&&h>=c&&e>=i&&j>=e||d>=g&&h>=d&&e>=i&&j>=e||c>=g&&h>=c&&f>=i&&j>=f||d>=g&&h>=c&&f>=i&&j>=f},a.encloses=function(a,b,c){var d=a.x,e=a.x+a.w,f=a.y,g=a.y+a.h,h=b.x,i=b.x+b.w,j=b.y,k=b.y+b.h,l=function(a,b,d,e){return c?b>=a&&d>=e:b>a&&d>e};return l(d,h,e,i)&&l(f,j,g,k)},[null,[1,-1],[1,1],[-1,1],[-1,-1]]),g=[null,[-1,-1],[-1,1],[1,1],[1,-1]];a.pointOnLine=function(a,b,c){var h=d(a,b),i=e(a,b),j=c>0?f[i]:g[i],k=Math.atan(h),l=Math.abs(c*Math.sin(k))*j[1],m=Math.abs(c*Math.cos(k))*j[0];return{x:a.x+m,y:a.y+l}},a.perpendicularLineTo=function(a,b,c){var e=d(a,b),f=Math.atan(-1/e),g=c/2*Math.sin(f),h=c/2*Math.cos(f);return[{x:b.x+h,y:b.y+g},{x:b.x-h,y:b.y-g}]}}.call(this),function(){"use strict";var a={android:navigator.userAgent.toLowerCase().indexOf("android")>-1},b=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ec&&a[c]!=b;c++);c-1&&9>t,v=function(a,b){if(null==a)return[0,0];var c=A(a),d=z(c,0);return[d[b+"X"],d[b+"Y"]]},w=function(a){return null==a?[0,0]:u?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:v(a,"page")},x=function(a){return v(a,"screen")},y=function(a){return v(a,"client")},z=function(a,b){return a.item?a.item(b):a[b]},A=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},B=function(a){return A(a).length},C=function(a,b,c,d){if(g(a,b,c),d.__tauid=c.__tauid,a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent){var e=b+c.__tauid;a["e"+e]=c,a[e]=function(){a["e"+e]&&a["e"+e](window.event)},a.attachEvent("on"+b,a[e])}},D=function(a,b,d){null!=d&&E(a,function(){var e=c(this);if(h(e,b,d),null!=d.__tauid)if(e.removeEventListener)e.removeEventListener(b,d,!1),q&&s[b]&&e.removeEventListener(s[b],d,!1);else if(this.detachEvent){var f=b+d.__tauid;e[f]&&e.detachEvent("on"+b,e[f]),e[f]=null,e["e"+f]=null}d.__taTouchProxy&&D(a,d.__taTouchProxy[1],d.__taTouchProxy[0])})},E=function(a,b){if(null!=a){a="undefined"!=typeof Window&&"unknown"!=typeof a.top&&a==a.top?[a]:"string"!=typeof a&&null==a.tagName&&null!=a.length?a:"string"==typeof a?document.querySelectorAll(a):[a];for(var c=0;c-1&&9>c,g=function(a){if(f)return[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop];var b=i(a),c=h(b,0);return[c.pageX,c.pageY]},h=function(a,b){return a.item?a.item(b):a[b]},i=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},j={draggable:"katavorio-draggable",droppable:"katavorio-droppable",drag:"katavorio-drag",selected:"katavorio-drag-selected",active:"katavorio-drag-active",hover:"katavorio-drag-hover",noSelect:"katavorio-drag-no-select"},k="katavorio-drag-scope",l=["stop","start","drag","drop","over","out"],m=function(){},n=function(){return!0},o=function(a,b,c){for(var d=0;d1)for(var f=0;f0},g=(this.getMatchingDroppables=function(a){for(var b=[],c={},d=0;d=f.length,i=function(){return e[g[1]]||function(){return e[g[1]]=[],e[g[1]]}()};if(h)g?i()[g[3]]=c:e[a]=c;else if(g){var j=i();e=j[g[3]]||function(){return j[g[3]]={},j[g[3]]}()}else e=e[a]||function(){return e[a]={},e[a]}()}),a}},functionChain:function(a,b,c){for(var d=0;d-1&&a.splice(c,1),-1!=c},remove:function(a,b){var c=k.indexOf(a,b);return c>-1&&a.splice(c,1),-1!=c},addWithFunction:function(a,b,c){-1==k.findWithFunction(a,c)&&a.push(b)},addToList:function(a,b,c,d){var e=a[b];return null==e&&(e=[],a[b]=e),e[d?"unshift":"push"](c),e},extend:function(b,c){var d;for(c=a(c)?c:[c],d=0;d2)for(d=2;dh&&j!==!1;){if(c[d])a[d][h].apply(this,[e,f]);else try{j=a[d][h].apply(this,[e,f])}catch(l){k.log("jsPlumb: fire failed for event "+d+" : "+l)}h++,(null==a||null==a[d])&&(i=!0)}}return this},this.unbind=function(b,c){if(0===arguments.length)a={};else if(1===arguments.length){if("string"==typeof b)delete a[b];else if(b.__jsPlumb){var d;for(var e in b.__jsPlumb)d=b.__jsPlumb[e],k.remove(a[d]||[],b)}}else 2===arguments.length&&k.remove(a[b]||[],c);return this},this.getListener=function(b){return a[b]},this.setSuspendEvents=function(a){b=a},this.isSuspendEvents=function(){return b},this.silently=function(a){this.setSuspendEvents(!0);try{a()}catch(b){jsPlumbUtil.log("Cannot execute silent function "+b)}this.setSuspendEvents(!1)},this.cleanupListeners=function(){for(var b in a)a[b]=null}},k.EventGenerator.prototype={cleanup:function(){this.cleanupListeners()}},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e})}.call(this),function(){"use strict";var a=this,b=a.jsPlumbUtil;b.ieVersion=/MSIE\s([\d.]+)/.test(navigator.userAgent)?new Number(RegExp.$1):-1,b.oldIE=b.ieVersion>-1&&b.ieVersion<9,b.matchesSelector=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ef;f++)d&&d==e[f]||e[f].setHover(b,!0,c)},i=function(a){return null==a?null:a.split(" ")},j=function(a,b,c){for(var d in b)a[d]=c},k=function(a,b,c){if(a.getDefaultType){var e=a.getTypeDescriptor(),f={},g=a.getDefaultType(),h=d.merge({},g);j(f,g,"__default");for(var i=0,k=a._jsPlumb.types.length;k>i;i++){var l=a._jsPlumb.types[i];if("__default"!==l){var m=a._jsPlumb.instance.getType(l,e);null!=m&&(h=d.merge(h,m,["cssClass"]),j(f,m,l))}}b&&(h=d.populate(h,b)),a.applyType(h,c,f),c||a.repaint()}},l=window.jsPlumbUIComponent=function(a){jsPlumbUtil.EventGenerator.apply(this,arguments);var b=this,c=arguments,e=b.idPrefix,f=e+(new Date).getTime();this._jsPlumb={instance:a._jsPlumb,parameters:a.parameters||{},paintStyle:null,hoverPaintStyle:null,paintStyleInUse:null,hover:!1,beforeDetach:a.beforeDetach,beforeDrop:a.beforeDrop,overlayPlacements:[],hoverClass:a.hoverClass||a._jsPlumb.Defaults.HoverClass,types:[],typeCache:{}},this.cacheTypeItem=function(a,b,c){this._jsPlumb.typeCache[c]=this._jsPlumb.typeCache[c]||{},this._jsPlumb.typeCache[c][a]=b},this.getCachedTypeItem=function(a,b){return this._jsPlumb.typeCache[b]?this._jsPlumb.typeCache[b][a]:null},this.getId=function(){return f};var g=a.overlays||[],h={};if(this.defaultOverlayKeys){for(var i=0;if;f++)this.hasType(d[f])||(this._jsPlumb.types.push(d[f]),e=!0);e&&k(this,b,c)}},removeType:function(a,b){var c=i(a),e=!1,f=function(a){var b=d.indexOf(this._jsPlumb.types,a);return-1!=b?(m(this,b),this._jsPlumb.types.splice(b,1),!0):!1}.bind(this);if(null!=c){for(var g=0,h=c.length;h>g;g++)e=f(c[g])||e;e&&k(this,null,b)}},clearTypes:function(a){for(var b=this._jsPlumb.types.length,c=0;b>c;c++)m(this,0),this._jsPlumb.types.splice(0,1);k(this,{},a)},toggleType:function(a,b,c){var d=i(a);if(null!=d){for(var e=0,f=d.length;f>e;e++){var g=jsPlumbUtil.indexOf(this._jsPlumb.types,d[e]);-1!=g?(m(this,g),this._jsPlumb.types.splice(g,1)):this._jsPlumb.types.push(d[e])}k(this,b,c)}},applyType:function(a,b){if(this.setPaintStyle(a.paintStyle,b),this.setHoverPaintStyle(a.hoverPaintStyle,b),a.parameters)for(var c in a.parameters)this.setParameter(c,a.parameters[c]);this._jsPlumb.paintStyleInUse=this.getPaintStyle()},setPaintStyle:function(a,b){this._jsPlumb.paintStyle=a,this._jsPlumb.paintStyleInUse=this._jsPlumb.paintStyle,f(this),b||this.repaint()},getPaintStyle:function(){return this._jsPlumb.paintStyle},setHoverPaintStyle:function(a,b){this._jsPlumb.hoverPaintStyle=a,f(this),b||this.repaint()},getHoverPaintStyle:function(){return this._jsPlumb.hoverPaintStyle},destroy:function(a){(a||null==this.typeId)&&(this.cleanupListeners(),this.clone=null,this._jsPlumb=null)},isHover:function(){return this._jsPlumb.hover},setHover:function(a,b,c){if(this._jsPlumb&&!this._jsPlumb.instance.currentlyDragging&&!this._jsPlumb.instance.isHoverSuspended()){if(this._jsPlumb.hover=a,null!=this.canvas){if(null!=this._jsPlumb.instance.hoverClass){var d=a?"addClass":"removeClass";this._jsPlumb.instance[d](this.canvas,this._jsPlumb.instance.hoverClass)}null!=this._jsPlumb.hoverClass&&this._jsPlumb.instance[d](this.canvas,this._jsPlumb.hoverClass)}null!=this._jsPlumb.hoverPaintStyle&&(this._jsPlumb.paintStyleInUse=a?this._jsPlumb.hoverPaintStyle:this._jsPlumb.paintStyle,this._jsPlumb.instance.isSuspendDrawing()||(c=c||e(),this.repaint({timestamp:c,recalc:!1}))),this.getAttachedElements&&!b&&h(this,a,e(),this)}}});var n=0,o=function(){var a=n+1;return n++,a},p=window.jsPlumbInstance=function(b){this.Defaults={Anchor:"Bottom",Anchors:[null,null],ConnectionsDetachable:!0,ConnectionOverlays:[],Connector:"Bezier",Container:null,DoNotThrowErrors:!1,DragOptions:{},DropOptions:{},Endpoint:"Dot",EndpointOverlays:[],Endpoints:[null,null],EndpointStyle:{fillStyle:"#456"},EndpointStyles:[null,null],EndpointHoverStyle:null,EndpointHoverStyles:[null,null],HoverPaintStyle:null,LabelStyle:{color:"black"},LogEnabled:!1,Overlays:[],MaxConnections:1,PaintStyle:{lineWidth:4,strokeStyle:"#456"},ReattachConnections:!1,RenderMode:"svg",Scope:"jsPlumb_DefaultScope"},b&&q.extend(this.Defaults,b),this.logEnabled=this.Defaults.LogEnabled,this._connectionTypes={},this._endpointTypes={},jsPlumbUtil.EventGenerator.apply(this);var f=this,h=o(),i=f.bind,j={},k=1,m=function(a){if(null==a)return null;if(3==a.nodeType||8==a.nodeType)return{el:a,text:!0};var b=f.getElement(a);return{el:b,id:jsPlumbUtil.isString(a)&&null==b?a:Y(b)}};this.getInstanceIndex=function(){return h},this.setZoom=function(a,b){return jsPlumbUtil.oldIE||(k=a,f.fire("zoom",k),b&&f.repaintEverything()),!jsPlumbUtil.oldIE},this.getZoom=function(){return k};for(var n in this.Defaults)j[n]=this.Defaults[n];var p,r=[];this.unbindContainer=function(){if(null!=p&&r.length>0)for(var a=0;a *",function(c){b(a,c)}),c(a,"._jsPlumb_endpoint, ._jsPlumb_endpoint > *, ._jsPlumb_endpoint svg *",function(c){b(a,c)}),c(a,"._jsPlumb_overlay, ._jsPlumb_overlay *",function(c){b(a,c)})},e=0;e0?arguments[0].selection:[[a,f.getUIPosition(arguments,f.getZoom(),!0)]];for(var c=function(a){K(a[0],a[1]),f.removeClass(a[0],"jsPlumb_dragged"),f.select({source:a[0]}).removeClass(f.elementDraggingClass+" "+f.sourceElementDraggingClass,!0),f.select({target:a[0]}).removeClass(f.elementDraggingClass+" "+f.targetElementDraggingClass,!0),f.getDragManager().dragEnded(a[0])},d=0;de;e++)c.overlays.push(c.sourceEndpoint.connectorOverlays[e])}!c["pointer-events"]&&c.sourceEndpoint&&c.sourceEndpoint.connectorPointerEvents&&(c["pointer-events"]=c.sourceEndpoint.connectorPointerEvents);var h=function(a,b){var c=q.extend({},a);for(var d in b)b[d]&&(c[d]=b[d]);return c},i=function(a,b,d){return f.addEndpoint(a,h(b,{anchor:c.anchors?c.anchors[d]:c.anchor,endpoint:c.endpoints?c.endpoints[d]:c.endpoint,paintStyle:c.endpointStyles?c.endpointStyles[d]:c.endpointStyle,hoverPaintStyle:c.endpointHoverStyles?c.endpointHoverStyles[d]:c.endpointHoverStyle}))},j=function(a,b,d){if(c[a]&&!c[a].endpoint&&!c[a+"Endpoint"]&&!c.newConnection){var e=Y(c[a]),f=d[e];if(f){if(!f.enabled)return!1;var g=null!=f.endpoint&&f.endpoint._jsPlumb?f.endpoint:i(c[a],f.def,b);if(g.isFull())return!1;c[a+"Endpoint"]=g,g._doNotDeleteOnDetach=!1,g._deleteOnDetach=!0,f.uniqueEndpoint&&(f.endpoint?g.finalEndpoint=f.endpoint:(f.endpoint=g,g._deleteOnDetach=!1,g._doNotDeleteOnDetach=!0))}}};return j("source",0,this.sourceEndpointDefinitions)!==!1&&j("target",1,this.targetEndpointDefinitions)!==!1?(c.sourceEndpoint&&c.targetEndpoint&&(N(c.sourceEndpoint,c.targetEndpoint)||(c=null)),c):void 0}.bind(f),P=function(a){var b=f.Defaults.ConnectionType||f.getDefaultConnectionType();a._jsPlumb=f,a.newConnection=P,a.newEndpoint=R,a.endpointsByUUID=w,a.endpointsByElement=v,a.finaliseConnection=Q,a.id="con_"+I();var c=new b(a);return c.isDetachable()&&(c.endpoints[0].initDraggable("_jsPlumbSource"),c.endpoints[1].initDraggable("_jsPlumbTarget")),c},Q=f.finaliseConnection=function(a,b,c,d){if(b=b||{},a.suspendedEndpoint||u.push(a),a.endpoints[0].isTemporarySource=!1,(null==a.suspendedEndpoint||d)&&f.anchorManager.newConnection(a),K(a.source),!b.doNotFireConnectionEvent&&b.fireEvent!==!1){var e={connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]};f.fire("connection",e,c)}},R=function(a,b){var c=f.Defaults.EndpointType||q.Endpoint,d=q.extend({},a);d._jsPlumb=f,d.newConnection=P,d.newEndpoint=R,d.endpointsByUUID=w,d.endpointsByElement=v,d.fireDetachEvent=_,d.elementId=b||Y(d.source);var e=new c(d);return e.id="ep_"+I(),pb(d.elementId,d.source),q.headless||f.getDragManager().endpointAdded(d.source,b),e},S=function(a,b,c){var d=v[a];if(d&&d.length)for(var e=0,f=d.length;f>e;e++){for(var g=0,h=d[e].connections.length;h>g;g++){var i=b(d[e].connections[g]);if(i)return}c&&c(d[e])}},T=function(a,b){return q.each(a,function(a){f.isDragSupported(a)&&(A[f.getAttribute(a,"id")]=b,f.setElementDraggable(a,b))})},U=function(a,b,c){b="block"===b;var d=null;c&&(d=b?function(a){a.setVisible(!0,!0,!0)}:function(a){a.setVisible(!1,!0,!0)});var e=m(a);S(e.id,function(a){if(b&&c){var d=a.sourceId===e.id?1:0;a.endpoints[d].isVisible()&&a.setVisible(!0)}else a.setVisible(b)},d)},V=function(a){return q.each(a,function(a){var b=f.getAttribute(a,"id"),c=null==A[b]?!1:A[b];return c=!c,A[b]=c,f.setDraggable(a,c),c}.bind(this))},W=function(a,b){var c=null;b&&(c=function(a){var b=a.isVisible();a.setVisible(!b)}),S(a,function(a){var b=a.isVisible();a.setVisible(!b)},c)},X=function(a){var b=y[a];return b?{o:b,s:C[a]}:qb({elId:a})},Y=function(a,b,c){if(jsPlumbUtil.isString(a))return a;if(null==a)return null;var d=f.getAttribute(a,"id");return d&&"undefined"!==d||(2==arguments.length&&void 0!==arguments[1]?d=b:(1==arguments.length||3==arguments.length&&!arguments[2])&&(d="jsPlumb_"+h+"_"+I()),c||f.setAttribute(a,"id",d)),d};this.setConnectionBeingDragged=function(a){B=a},this.isConnectionBeingDragged=function(){return B},this.connectorClass="_jsPlumb_connector",this.connectorOutlineClass="_jsPlumb_connector_outline",this.connectedClass="_jsPlumb_connected",this.hoverClass="_jsPlumb_hover",this.endpointClass="_jsPlumb_endpoint",this.endpointConnectedClass="_jsPlumb_endpoint_connected",this.endpointFullClass="_jsPlumb_endpoint_full",this.endpointDropAllowedClass="_jsPlumb_endpoint_drop_allowed",this.endpointDropForbiddenClass="_jsPlumb_endpoint_drop_forbidden",this.overlayClass="_jsPlumb_overlay",this.draggingClass="_jsPlumb_dragging",this.elementDraggingClass="_jsPlumb_element_dragging",this.sourceElementDraggingClass="_jsPlumb_source_element_dragging",this.targetElementDraggingClass="_jsPlumb_target_element_dragging",this.endpointAnchorClassPrefix="_jsPlumb_endpoint_anchor",this.hoverSourceClass="_jsPlumb_source_hover",this.hoverTargetClass="_jsPlumb_target_hover",this.dragSelectClass="_jsPlumb_drag_select",this.Anchors={},this.Connectors={svg:{},vml:{}},this.Endpoints={svg:{},vml:{}},this.Overlays={svg:{},vml:{}},this.ConnectorRenderers={},this.SVG="svg",this.VML="vml",this.addEndpoint=function(a,b,c){c=c||{};var e=q.extend({},c);q.extend(e,b),e.endpoint=e.endpoint||f.Defaults.Endpoint,e.paintStyle=e.paintStyle||f.Defaults.EndpointStyle;for(var g=[],h=d.isArray(a)||null!=a.length&&!d.isString(a)?a:[a],i=0,j=h.length;j>i;i++){e.source=f.getElement(h[i]),nb(e.source);var k=Y(e.source),l=R(e,k),m=pb(k,e.source).info.o;d.addToList(v,k,l),D||l.paint({anchorLoc:l.anchor.compute({xy:[m.left,m.top],wh:C[k],element:l,timestamp:E}),timestamp:E}),g.push(l),l._doNotDeleteOnDetach=!0}return 1==g.length?g[0]:g},this.addEndpoints=function(a,b,c){for(var e=[],g=0,h=b.length;h>g;g++){var i=f.addEndpoint(a,b[g],c);d.isArray(i)?Array.prototype.push.apply(e,i):e.push(i)}return e},this.animate=function(a,b,c){if(!this.animationSupported)return!1;c=c||{};var e=f.getElement(a),g=Y(e),h=q.animEvents.step,i=q.animEvents.complete;c[h]=d.wrap(c[h],function(){f.revalidate(g)}),c[i]=d.wrap(c[i],function(){f.revalidate(g)}),f.doAnimate(e,b,c)},this.checkCondition=function(a){var b=f.getListener(a),c=!0;if(b&&b.length>0){var e=Array.prototype.slice.call(arguments,1);try{for(var g=0,h=b.length;h>g;g++)c=c&&b[g].apply(b[g],e)}catch(i){d.log(f,"cannot check condition ["+a+"]"+i)}}return c},this.connect=function(a,b){var c,d=O(a,b);if(d){if(null==d.source&&null==d.sourceEndpoint)return jsPlumbUtil.log("Cannot establish connection - source does not exist"),void 0;if(null==d.target&&null==d.targetEndpoint)return jsPlumbUtil.log("Cannot establish connection - target does not exist"),void 0;nb(d.source),c=P(d),Q(c,d)}return c};var Z=[{el:"source",elId:"sourceId",epDefs:"sourceEndpointDefinitions"},{el:"target",elId:"targetId",epDefs:"targetEndpointDefinitions"}],$=function(a,b,c,d){var e,f,g,h=Z[c],i=a[h.elId],j=(a[h.el],a.endpoints[c]),k={index:c,originalSourceId:0===c?i:a.sourceId,newSourceId:a.sourceId,originalTargetId:1==c?i:a.targetId,newTargetId:a.targetId,connection:a};if(b.constructor==q.Endpoint)e=b,e.addConnection(a);else if(f=Y(b),g=this[h.epDefs][f],f===a[h.elId])e=null;else if(g){if(!g.enabled)return;e=null!=g.endpoint&&g.endpoint._jsPlumb?g.endpoint:this.addEndpoint(b,g.def),g.uniqueEndpoint&&(g.endpoint=e),e._doNotDeleteOnDetach=!1,e._deleteOnDetach=!0,e.addConnection(a)}else e=a.makeEndpoint(0===c,b,f),e._doNotDeleteOnDetach=!1,e._deleteOnDetach=!0;return null!=e&&(j.detachFromConnection(a),a.endpoints[c]=e,a[h.el]=e.element,a[h.elId]=e.elementId,k[0===c?"newSourceId":"newTargetId"]=e.elementId,ab(k),d||a.repaint()),k}.bind(this);this.setSource=function(a,b,c){var d=$(a,b,0,c);this.anchorManager.sourceChanged(d.originalSourceId,d.newSourceId,a)},this.setTarget=function(a,b,c){var d=$(a,b,1,c);this.anchorManager.updateOtherEndpoint(d.originalSourceId,d.originalTargetId,d.newTargetId,a)},this.deleteEndpoint=function(a,b){var c="string"==typeof a?w[a]:a;return c&&f.deleteObject({endpoint:c,dontUpdateHover:b}),f},this.deleteEveryEndpoint=function(){var a=f.setSuspendDrawing(!0);for(var b in v){var c=v[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)f.deleteEndpoint(c[d],!0)}return v={},x={},w={},y={},z={},f.anchorManager.reset(),f.getDragManager().reset(),a||f.setSuspendDrawing(!1),f};var _=function(a,b,c){var d=f.Defaults.ConnectionType||f.getDefaultConnectionType(),e=a.constructor==d,g=e?{connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]}:a;b&&f.fire("connectionDetached",g,c),f.anchorManager.connectionDetached(g)},ab=f.fireMoveEvent=function(a,b){f.fire("connectionMoved",a,b)};this.unregisterEndpoint=function(a){a._jsPlumb.uuid&&(w[a._jsPlumb.uuid]=null),f.anchorManager.deleteEndpoint(a);for(var b in v){var c=v[b];if(c){for(var d=[],e=0,g=c.length;g>e;e++)c[e]!=a&&d.push(c[e]);v[b]=d}v[b].length<1&&delete v[b]}},this.detach=function(){if(0!==arguments.length){var a=f.Defaults.ConnectionType||f.getDefaultConnectionType(),b=arguments[0].constructor==a,c=2==arguments.length?b?arguments[1]||{}:arguments[0]:arguments[0],d=c.fireEvent!==!1,e=c.forceDetach,g=b?arguments[0]:c.connection;if(g)(e||jsPlumbUtil.functionChain(!0,!1,[[g.endpoints[0],"isDetachAllowed",[g]],[g.endpoints[1],"isDetachAllowed",[g]],[g,"isDetachAllowed",[g]],[f,"checkCondition",["beforeDetach",g]]]))&&g.endpoints[0].detach(g,!1,!0,d);else{var h=q.extend({},c);if(h.uuids)L(h.uuids[0]).detachFrom(L(h.uuids[1]),d);else if(h.sourceEndpoint&&h.targetEndpoint)h.sourceEndpoint.detachFrom(h.targetEndpoint);else{var i=Y(f.getElement(h.source)),j=Y(f.getElement(h.target));S(i,function(a){(a.sourceId==i&&a.targetId==j||a.targetId==i&&a.sourceId==j)&&f.checkCondition("beforeDetach",a)&&a.endpoints[0].detach(a,!1,!0,d)})}}}},this.detachAllConnections=function(a,b){b=b||{},a=f.getElement(a);var c=Y(a),d=v[c];if(d&&d.length)for(var e=0,g=d.length;g>e;e++)d[e].detachAll(b.fireEvent!==!1,b.forceDetach);return f},this.detachEveryConnection=function(a){return a=a||{},f.batch(function(){for(var b in v){var c=v[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)c[d].detachAll(a.fireEvent!==!1,a.forceDetach)}u.length=0}),f},this.deleteObject=function(a){var b={endpoints:{},connections:{},endpointCount:0,connectionCount:0},c=a.fireEvent!==!1,d=a.deleteAttachedObjects!==!1,e=function(c){if(null!=c&&null==b.connections[c.id]&&(a.dontUpdateHover||null==c._jsPlumb||c.setHover(!1),b.connections[c.id]=c,b.connectionCount++,d))for(var e=0;ec;c++)e=m(a[c]),e.el&&M(e.el,!0,b,e.id);else e=m(a),e.el&&M(e.el,!0,b,e.id);return f};var bb=function(a,b,c,d){for(var e=0,f=a.length;f>e;e++)a[e][b].apply(a[e],c);return d(a)},cb=function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d.push([a[e][b].apply(a[e],c),a[e]]);return d},db=function(a,b,c){return function(){return bb(a,b,arguments,c)}},eb=function(a,b){return function(){return cb(a,b,arguments)}},fb=function(a,b){var c=[];if(a)if("string"==typeof a){if("*"===a)return a;c.push(a)}else if(b)c=a;else if(a.length)for(var d=0,e=a.length;e>d;d++)c.push(m(a[d]).id);else c.push(m(a).id);return c},gb=function(a,b,c){return"*"===a?!0:a.length>0?-1!=jsPlumbUtil.indexOf(a,b):!c};this.getConnections=function(a,b){a?a.constructor==String&&(a={scope:a}):a={};for(var c=a.scope||f.getDefaultScope(),d=fb(c,!0),e=fb(a.source),g=fb(a.target),h=!b&&d.length>1?{}:[],i=function(a,c){if(!b&&d.length>1){var e=h[a];null==e&&(e=h[a]=[]),e.push(c)}else h.push(c)},j=0,k=u.length;k>j;j++){var l=u[j];gb(d,l.scope)&&gb(e,l.sourceId)&&gb(g,l.targetId)&&i(l.scope,l)}return h};var hb=function(a,b){return function(c){for(var d=0,e=a.length;e>d;d++)c(a[d]);return b(a)}},ib=function(a){return function(b){return a[b]}},jb=function(a,b){var c,d,e={length:a.length,each:hb(a,b),get:ib(a)},f=["setHover","removeAllOverlays","setLabel","addClass","addOverlay","removeOverlay","removeOverlays","showOverlay","hideOverlay","showOverlays","hideOverlays","setPaintStyle","setHoverPaintStyle","setSuspendEvents","setParameter","setParameters","setVisible","repaint","addType","toggleType","removeType","removeClass","setType","bind","unbind"],g=["getLabel","getOverlay","isHover","getParameter","getParameters","getPaintStyle","getHoverPaintStyle","isVisible","hasType","getType","isSuspendEvents"];for(c=0,d=f.length;d>c;c++)e[f[c]]=db(a,f[c],b);for(c=0,d=g.length;d>c;c++)e[g[c]]=eb(a,g[c]);return e},kb=function(a){var b=jb(a,kb);return q.extend(b,{setDetachable:db(a,"setDetachable",kb),setReattach:db(a,"setReattach",kb),setConnector:db(a,"setConnector",kb),detach:function(){for(var b=0,c=a.length;c>b;b++)f.detach(a[b])},isDetachable:eb(a,"isDetachable"),isReattach:eb(a,"isReattach")})},lb=function(a){var b=jb(a,lb);return q.extend(b,{setEnabled:db(a,"setEnabled",lb),setAnchor:db(a,"setAnchor",lb),isEnabled:eb(a,"isEnabled"),detachAll:function(){for(var b=0,c=a.length;c>b;b++)a[b].detachAll()},remove:function(){for(var b=0,c=a.length;c>b;b++)f.deleteObject({endpoint:a[b]})}})};this.select=function(a){return a=a||{},a.scope=a.scope||"*",kb(a.connections||f.getConnections(a,!0))},this.selectEndpoints=function(a){a=a||{},a.scope=a.scope||"*";var b=!a.element&&!a.source&&!a.target,c=b?"*":fb(a.element),d=b?"*":fb(a.source),e=b?"*":fb(a.target),f=fb(a.scope,!0),g=[];for(var h in v){var i=gb(c,h,!0),j=gb(d,h,!0),k="*"!=d,l=gb(e,h,!0),m="*"!=e;if(i||j||l)a:for(var n=0,o=v[h].length;o>n;n++){var p=v[h][n];if(gb(f,p.scope,!0)){var q=k&&d.length>0&&!p.isSource,r=m&&e.length>0&&!p.isTarget;if(q||r)continue a;g.push(p)}}}return lb(g)},this.getAllConnections=function(){return u},this.getDefaultScope=function(){return F},this.getEndpoint=L,this.getEndpoints=function(a){return v[m(a).id]},this.getDefaultEndpointType=function(){return q.Endpoint},this.getDefaultConnectionType=function(){return q.Connection},this.getId=Y,this.appendElement=J;var mb=!1;this.isHoverSuspended=function(){return mb},this.setHoverSuspended=function(a){mb=a},this.hide=function(a,b){return U(a,"none",b),f},this.idstamp=I,this.connectorsInitialized=!1,this.registerConnectorType=function(a,b){c.push([a,b])};var nb=function(a){if(!p&&a){var b=f.getElement(a);b.offsetParent&&f.setContainer(b.offsetParent)}},ob=function(){f.Defaults.Container&&f.setContainer(f.Defaults.Container)},pb=f.manage=function(a,b){return x[a]||(x[a]={el:b,endpoints:[],connections:[]},x[a].info=qb({elId:a,timestamp:E})),x[a]},qb=this.updateOffset=function(a){var b,c=a.timestamp,d=a.recalc,e=a.offset,g=a.elId;return D&&!c&&(c=E),!d&&c&&c===z[g]?{o:a.offset||y[g],s:C[g]}:(d||!e&&null==y[g]?(b=x[g]?x[g].el:null,null!=b&&(C[g]=f.getSize(b),y[g]=f.getOffset(b),z[g]=c)):(y[g]=e||y[g],null==C[g]&&(b=x[g].el,null!=b&&(C[g]=f.getSize(b))),z[g]=c),y[g]&&!y[g].right&&(y[g].right=y[g].left+C[g][0],y[g].bottom=y[g].top+C[g][1],y[g].width=C[g][0],y[g].height=C[g][1],y[g].centerx=y[g].left+y[g].width/2,y[g].centery=y[g].top+y[g].height/2),{o:y[g],s:C[g]})};this.init=function(){a=q.getRenderModes();var b=function(a,b,c){q.Connectors[a][b]=function(){c.apply(this,arguments),q.ConnectorRenderers[a].apply(this,arguments)},jsPlumbUtil.extend(q.Connectors[a][b],[c,q.ConnectorRenderers[a]])};if(!q.connectorsInitialized){for(var d=0;d=4?[c[2],c[3]]:[0,0],offsets:c.length>=6?[c[4],c[5]]:[0,0],elementId:e,jsPlumbInstance:f,cssClass:7==c.length?c[6]:null};g=new q.Anchor(h),g.clone=function(){return new q.Anchor(h)}}return g.id||(g.id="anchor_"+I()),g},this.makeAnchors=function(a,b,c){for(var e=[],g=0,h=a.length;h>g;g++)"string"==typeof a[g]?e.push(q.Anchors[a[g]]({elementId:b,jsPlumbInstance:c})):d.isArray(a[g])&&e.push(f.makeAnchor(a[g],b,c));return e},this.makeDynamicAnchor=function(a,b){return new q.DynamicAnchor({anchors:a,selector:b,elementId:null,jsPlumbInstance:f})},this.targetEndpointDefinitions={};var rb=function(a,b,c){a.paintStyle=a.paintStyle||c.Defaults.EndpointStyles[b]||c.Defaults.EndpointStyle,a.hoverPaintStyle=a.hoverPaintStyle||c.Defaults.EndpointHoverStyles[b]||c.Defaults.EndpointHoverStyle,a.anchor=a.anchor||c.Defaults.Anchors[b]||c.Defaults.Anchor,a.endpoint=a.endpoint||c.Defaults.Endpoints[b]||c.Defaults.Endpoint};this.sourceEndpointDefinitions={};var sb=function(a,b,c,d,e){for(var f=a.target||a.srcElement,g=!1,h=d.getSelector(b,c),i=0;i0&&b>=c.maxConnections},element:a.el,elementId:a.id,isSource:e,isTarget:g,addClass:function(b){f.addClass(a.el,b)},removeClass:function(b){f.removeClass(a.el,b)},onDrop:function(a){var b=a.endpoints[0];b.anchor.locked=!1},isDropAllowed:function(){return i.isDropAllowed.apply(i,arguments)},isRedrop:function(b){return null!=b.suspendedElement&&null!=b.suspendedEndpoint&&b.suspendedEndpoint.element===a.el},getEndpoint:function(c){var d=a.el[h],e=d.endpoint;if((null==e||null==e._jsPlumb)&&(e=f.addEndpoint(a.el,b),e._mtNew=!0),b.uniqueEndpoint&&(d.endpoint=e),e._doNotDeleteOnDetach=!1,e._deleteOnDetach=!0,c.isDetachable()&&e.initDraggable(),null!=e.anchor.positionFinder){var g=f.getUIPosition(arguments,f.getZoom()),i=f.getOffset(a.el),j=f.getSize(a.el),k=e.anchor.positionFinder(g,i,j,e.anchor.constructorParams);e.anchor.x=k[0],e.anchor.y=k[1]}return e},maybeCleanup:function(a){a._mtNew&&0===a.connections.length?f.deleteObject({endpoint:a}):delete a._mtNew}}),k=q.dragEvents.drop;return c.scope=c.scope||b.scope||f.Defaults.Scope,c[k]=d.wrap(c[k],j,!0),g&&(c[q.dragEvents.over]=function(){return!0}),c.definitionId=h,b.allowLoopback===!1&&(c.canDrop=function(b){var c=b.getDragElement()._jsPlumbRelatedElement;return c!=a.el}),f.initDroppable(a.el,c,"internal"),j};this.makeTarget=function(a,b,c){var d=q.extend({_jsPlumb:this},c);q.extend(d,b),rb(d,1,this);for(var e=(!(d.deleteEndpointsOnDetach===!1),d.maxConnections||-1),f=function(a){var b=m(a),c=b.id,f=q.extend({},d.dropOptions||{});nb(c);var g={def:d,uniqueEndpoint:d.uniqueEndpoint,maxConnections:e,enabled:!0};b.el._jsPlumbTarget=g,this.targetEndpointDefinitions[c]=g,tb(b,d,f,d.isSource===!0,!0,"_jsPlumbTarget")}.bind(this),g=a.length&&a.constructor!=String?a:[a],h=0,i=g.length;i>h;h++)f(g[h]);return this},this.unmakeTarget=function(a,b){var c=m(a);return q.destroyDroppable(c.el),b||delete this.targetEndpointDefinitions[c.id],this},this.makeSource=function(a,b,c){var e=q.extend({_jsPlumb:this},c);q.extend(e,b),rb(e,0,this);for(var g=e.maxConnections||1,h=e.onMaxConnections,i=function(a){var b=a.id,c=this.getElement(a.el);nb(b);var i={def:e,uniqueEndpoint:e.uniqueEndpoint,maxConnections:g,enabled:!0};this.sourceEndpointDefinitions[b]=i,a.el._jsPlumbSource=i;var j=q.dragEvents.stop,l=q.dragEvents.drag,m=q.extend({},e.dragOptions||{}),n=m.drag,o=m.stop,p=null,r=!1;m.scope=m.scope||e.scope,m[l]=d.wrap(m[l],function(){n&&n.apply(this,arguments),r=!1}),m[j]=d.wrap(m[j],function(){if(o&&o.apply(this,arguments),this.currentlyDragging=!1,null!=p._jsPlumb){var a=e.anchor||this.Defaults.Anchor,c=p.anchor,d=p.connections[0],g=this.makeAnchor(a,b,this),h=p.element;if(null!=g.positionFinder){var i=f.getOffset(h),j=this.getSize(h),k={left:i.left+c.x*j[0],top:i.top+c.y*j[1]},l=g.positionFinder(k,i,j,g.constructorParams); +g.x=l[0],g.y=l[1]}p.setAnchor(g,!0),p.repaint(),this.repaint(p.elementId),null!=d&&this.repaint(d.targetId)}}.bind(this));var s=function(d){var i=this.getOriginalEvent(d);if(3!==d.which&&2!==d.button){var j=this.sourceEndpointDefinitions[b];if(j.enabled){if(b=this.getId(this.getElement(a.el)),e.filter){var l=jsPlumbUtil.isString(e.filter)?sb(i,a.el,e.filter,this,e.filterExclude):e.filter(i,a.el);if(l===!1)return}var n=this.select({source:b}).length;if(j.maxConnections>=0&&j.uniqueEndpoint&&n>=j.maxConnections)return h&&h({element:a.el,maxConnections:g},d),!1;var o=q.getPositionOnElement(i,c,k),s={};q.extend(s,e),s.isTemporarySource=!0,s.anchor=[o[0],o[1],0,0],s.dragOptions=m,p=this.addEndpoint(b,s),r=!0,p._doNotDeleteOnDetach=!1,p._deleteOnDetach=!0,j.uniqueEndpoint&&(j.endpoint?p.finalEndpoint=j.endpoint:(j.endpoint=p,p._deleteOnDetach=!1,p._doNotDeleteOnDetach=!0));var t=function(){f.off(p.canvas,"mouseup",t),f.off(a.el,"mouseup",t),r&&(r=!1,f.deleteEndpoint(p))};f.on(p.canvas,"mouseup",t),f.on(a.el,"mouseup",t),f.trigger(p.canvas,"mousedown",d),jsPlumbUtil.consume(d)}}}.bind(this);this.on(a.el,"mousedown",s),i.trigger=s,e.filter&&(jsPlumbUtil.isString(e.filter)||jsPlumbUtil.isFunction(e.filter))&&f.setDragFilter(a.el,e.filter);var t=q.extend({},e.dropOptions||{});tb(a,e,t,!0,e.isTarget===!0,"_jsPlumbSource")}.bind(this),j=a.length&&a.constructor!=String?a:[a],l=0,n=j.length;n>l;l++)i(m(j[l]));return this},this.unmakeSource=function(a,b){var c=m(a),d=this.sourceEndpointDefinitions[c.id].trigger;return d&&f.off(c.el,"mousedown",d),b||delete this.sourceEndpointDefinitions[c.id],this},this.unmakeEverySource=function(){for(var a in this.sourceEndpointDefinitions)f.unmakeSource(a,!0);return this.sourceEndpointDefinitions={},this};var ub=function(a,b){b=jsPlumbUtil.isArray(b)?b:[b];for(var c=Y(a),d=0;dg;g++){var i=m(b[g]);f[i.id]&&(f[i.id].enabled=e?!f[i.id].enabled:c)}else{var j=m(b).id;f[j].enabled=e?!f[j].enabled:c}return this}.bind(this),xb=function(a,b){return d.isString(a)||!a.length?b.apply(this,[a]):a.length?b.apply(this,[a[0]]):void 0}.bind(this);this.toggleSourceEnabled=function(a){return wb("source",a,null,!0),this.isSourceEnabled(a)},this.setSourceEnabled=function(a,b){return wb("source",a,b)},this.isSource=function(a){return xb(a,function(a){return null!=this.sourceEndpointDefinitions[m(a).id]}.bind(this))},this.isSourceEnabled=function(a){return xb(a,function(a){var b=this.sourceEndpointDefinitions[m(a).id];return b&&b.enabled===!0}.bind(this))},this.toggleTargetEnabled=function(a){return wb("target",a,null,!0),this.isTargetEnabled(a)},this.isTarget=function(a){return xb(a,function(a){return null!=this.targetEndpointDefinitions[m(a).id]}.bind(this))},this.isTargetEnabled=function(a){return xb(a,function(a){var b=this.targetEndpointDefinitions[m(a).id];return b&&b.enabled===!0}.bind(this))},this.setTargetEnabled=function(a,b){return wb("target",a,b)},this.ready=function(a){f.bind("ready",a)};var yb=function(a,b){if("object"==typeof a&&a.length)for(var c=0,d=a.length;d>c;c++)b(a[c]);else b(a);return f};this.repaint=function(a,b,c){return yb(a,function(a){K(a,b,c)})},this.revalidate=function(a,b,c){return yb(a,function(a){var d=c?a:f.getId(a);f.updateOffset({elId:d,recalc:!0,timestamp:b}),f.repaint(a)})},this.repaintEverything=function(){var a,b=e();for(a in v)f.updateOffset({elId:a,recalc:!0,timestamp:b});for(a in v)K(a,null,b);return this},this.removeAllEndpoints=function(a,b,c){c=c||[];var d=function(a){var e,g,h=m(a),i=v[h.id];if(i)for(c.push(h),e=0,g=i.length;g>e;e++)f.deleteEndpoint(i[e]);if(delete v[h.id],b&&h.el&&3!=h.el.nodeType&&8!=h.el.nodeType)for(e=0,g=h.el.childNodes.length;g>e;e++)d(h.el.childNodes[e])};return d(a),this};var zb=function(a,b){f.removeAllEndpoints(a.id,!0,b);for(var c=function(a){f.getDragManager().elementRemoved(a.id),f.anchorManager.clearFor(a.id),f.anchorManager.removeFloatingConnection(a.id),delete f.floatingConnections[a.id],delete x[a.id],delete y[a.id],a.el&&(f.removeElement(a.el),a.el._jsPlumb=null)},d=1;d0;)d(e.el.childNodes[0]);b||zb(e,c)}};return f.batch(function(){d(a,!0)},b===!1),f},this.reset=function(){f.silently(function(){f.deleteEveryEndpoint(),f.unbind(),this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={},u.length=0,this.doReset&&this.doReset()}.bind(this))};var Ab=function(a){a.canvas&&a.canvas.parentNode&&a.canvas.parentNode.removeChild(a.canvas),a.cleanup(),a.destroy()};this.clear=function(){f.select().each(Ab),f.selectEndpoints().each(Ab),v={},w={}},this.setDefaultScope=function(a){return F=a,f},this.setDraggable=T,this.setId=function(a,b,c){var d;jsPlumbUtil.isString(a)?d=a:(a=this.getElement(a),d=this.getId(a));var e=this.getConnections({source:d,scope:"*"},!0),f=this.getConnections({target:d,scope:"*"},!0);b=""+b,c?a=this.getElement(b):(a=this.getElement(d),this.setAttribute(a,"id",b)),v[b]=v[d]||[];for(var g=0,h=v[b].length;h>g;g++)v[b][g].setElementId(b),v[b][g].setReferenceElement(a);delete v[d],this.anchorManager.changeId(d,b),this.getDragManager().changeId(d,b),x[b]=x[d],delete x[d];var i=function(c,d,e){for(var f=0,g=c.length;g>f;f++)c[f].endpoints[d].setElementId(b),c[f].endpoints[d].setReferenceElement(a),c[f][e+"Id"]=b,c[f][e]=a};i(e,0,"source"),i(f,1,"target"),this.repaint(b)},this.setDebugLog=function(a){s=a},this.setSuspendDrawing=function(a,b){var c=D;return D=a,E=a?(new Date).getTime():null,b&&this.repaintEverything(),c},this.isSuspendDrawing=function(){return D},this.getSuspendedAt=function(){return E},this.batch=function(a,b){var c=this.isSuspendDrawing();c||this.setSuspendDrawing(!0);try{a()}catch(e){d.log("Function run while suspended failed",e)}c||this.setSuspendDrawing(!1,!b)},this.doWhileSuspended=this.batch,this.getCachedData=X,this.timestamp=e,this.setRenderMode=function(a){if(a!==q.SVG&&a!==q.VML)throw new TypeError("Render mode ["+a+"] not supported");return G=this.trySetRenderMode(a)},this.getRenderMode=function(){return G},this.show=function(a,b){return U(a,"block",b),f},this.toggleVisible=W,this.toggleDraggable=V,this.addListener=this.bind};jsPlumbUtil.extend(p,jsPlumbUtil.EventGenerator,{setAttribute:function(a,b,c){this.setAttribute(a,b,c)},getAttribute:function(a,b){return this.getAttribute(q.getElement(a),b)},convertToFullOverlaySpec:function(a){return jsPlumbUtil.isString(a)&&(a=[a,{}]),a[1].id=a[1].id||jsPlumbUtil.uuid(),a},registerConnectionType:function(a,b){if(this._connectionTypes[a]=q.extend({},b),b.overlays){for(var c={},d=0;d';var b=a.firstChild;null!=b&&null!=b.style?(b.style.behavior="url(#default#VML)",c.vml=b?"object"==typeof b.adj:!0):c.vml=!1,a.parentNode.removeChild(a)}return c.vml},d=function(){var a=-1;if("Microsoft Internet Explorer"==navigator.appName){var b=navigator.userAgent,c=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");null!=c.exec(b)&&(a=parseFloat(RegExp.$1))}return a}(),e=d>-1&&9>d,f=function(a,b){if(null==a)return[0,0];var c=k(a),d=j(c,0);return[d[b+"X"],d[b+"Y"]]},g=function(a){return null==a?[0,0]:e?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:f(a,"page")},h=function(a){return f(a,"screen")},i=function(a){return f(a,"client")},j=function(a,b){return a.item?a.item(b):a[b]},k=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},l=function(a){var b={},c=[],d={},e={},f={};this.register=function(g){var h=a.getId(g),i=a.getOffset(g);b[h]||(b[h]=g,c.push(g),d[h]={});var j=function(b){if(b)for(var c=0;c0){var l=a.getOffset(g);d[h][k]={id:k,offset:{left:l.left-i.left,top:l.top-i.top}},f[k]=h}j(b.childNodes[c])}};j(g)},this.updateOffsets=function(b){if(null!=b){var c=jsPlumb.getElement(b),e=a.getId(c),g=d[e],h=a.getOffset(c);if(g)for(var i in g)if(g.hasOwnProperty(i)){var j=jsPlumb.getElement(i),k=a.getOffset(j);d[e][i]={id:i,offset:{left:k.left-h.left,top:k.top-h.top}},f[i]=e}}},this.endpointAdded=function(c,g){g=g||a.getId(c);var h=document.body,i=c.parentNode;for(e[g]=e[g]?e[g]+1:1;null!=i&&i!=h;){var j=a.getId(i,null,!0);if(j&&b[j]){var k=a.getOffset(i);if(null==d[j][g]){var l=a.getOffset(c);d[j][g]={id:g,offset:{left:l.left-k.left,top:l.top-k.top}},f[g]=j}break}i=i.parentNode}},this.endpointDeleted=function(a){if(e[a.elementId]&&(e[a.elementId]--,e[a.elementId]<=0))for(var b in d)d.hasOwnProperty(b)&&d[b]&&(delete d[b][a.elementId],delete f[a.elementId])},this.changeId=function(a,b){d[b]=d[a],d[a]={},f[b]=f[a],f[a]=null},this.getElementsForDraggable=function(a){return d[a]},this.elementRemoved=function(a){var b=f[a];b&&(delete d[b][a],delete f[a])},this.reset=function(){b={},c=[],d={},e={}},this.dragEnded=function(b){var c=a.getId(b),d=f[c];d&&this.updateOffsets(d)},this.setParent=function(b,c,e,g){var h=f[c];if(h){d[g]||(d[g]={}),d[g][c]=d[h][c],delete d[h][c];var i=a.getOffset(e),j=a.getOffset(b);d[g][c].offset={left:j.left-i.left,top:j.top-i.top},f[c]=g}},this.getDragAncestor=function(b){var c=jsPlumb.getElement(b),d=a.getId(c),e=f[d];return e?jsPlumb.getElement(e):null}},m=function(a){return null==a?null:a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},n=function(a,b){b=m(b),"undefined"!=typeof a.className.baseVal?a.className.baseVal=b:a.className=b},o=function(a){return"undefined"==typeof a.className.baseVal?a.className:a.className.baseVal},p=function(a,b,c){b=null==b?[]:jsPlumbUtil.isArray(b)?b:b.split(/\s+/),c=null==c?[]:jsPlumbUtil.isArray(c)?c:c.split(/\s+/);var d=o(a),e=d.split(/\s+/),f=function(a,b){for(var c=0;c0||b.scrollLeft>0)&&(this.getStyle(a,"position"),d.left-=b.scrollLeft,d.top-=b.scrollTop)}.bind(this);null!=e;)d.left+=e.offsetLeft,d.top+=e.offsetTop,f(e),e=b?e.offsetParent:e.offsetParent==c?null:e.offsetParent;if(null!=c&&!b&&(c.scrollTop>0||c.scrollLeft>0)){var g=null!=a.offsetParent?this.getStyle(a.offsetParent,"position"):"static",h=this.getStyle(a,"position");"absolute"!==h&&"fixed"!==h&&"absolute"!==g&&"fixed"!=g&&(d.left-=c.scrollLeft,d.top-=c.scrollTop)}return d},getPositionOnElement:function(a,b,c){var d="undefined"!=typeof b.getBoundingClientRect?b.getBoundingClientRect():{left:0,top:0,width:0,height:0},e=document.body,f=document.documentElement,g=window.pageYOffset||f.scrollTop||e.scrollTop,h=window.pageXOffset||f.scrollLeft||e.scrollLeft,i=f.clientTop||e.clientTop||0,j=f.clientLeft||e.clientLeft||0,k=0,l=0,m=d.top+g-i+k*c,n=d.left+h-j+l*c,o=jsPlumb.pageLocation(a),p=d.width||b.offsetWidth*c,q=d.height||b.offsetHeight*c,r=(o[0]-n)/p,s=(o[1]-m)/q;return[r,s]},getAbsolutePosition:function(a){var b=function(b){var c=a.style[b];return c?parseFloat(c.substring(0,c.length-2)):void 0};return[b("left"),b("top")]},setAbsolutePosition:function(a,b,c,d){c?this.animate(a,{left:"+="+(b[0]-c[0]),top:"+="+(b[1]-c[1])},d):(a.style.left=b[0]+"px",a.style.top=b[1]+"px")},getSize:function(a){return[a.offsetWidth,a.offsetHeight]},getWidth:function(a){return a.offsetWidth},getHeight:function(a){return a.offsetHeight}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d="__label",e=function(a,c){var e={cssClass:c.cssClass,labelStyle:a.labelStyle,id:d,component:a,_jsPlumb:a._jsPlumb.instance},f=jsPlumb.extend(e,c);return new(b.Overlays[a._jsPlumb.instance.getRenderMode()].Label)(f)},f=function(a,d){var e=null;if(c.isArray(d)){var f=d[0],g=b.extend({component:a,_jsPlumb:a._jsPlumb.instance},d[1]);3==d.length&&b.extend(g,d[2]),e=new(b.Overlays[a._jsPlumb.instance.getRenderMode()][f])(g)}else e=d.constructor==String?new(b.Overlays[a._jsPlumb.instance.getRenderMode()][d])({component:a,_jsPlumb:a._jsPlumb.instance}):d;return e.id=e.id||c.uuid(),a.cacheTypeItem("overlay",e,e.id),a._jsPlumb.overlays[e.id]=e,e};b.OverlayCapableJsPlumbUIComponent=function(a){jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.overlays={},this._jsPlumb.overlayPositions={},a.label&&(this.getDefaultType().overlays[d]=["Label",{label:a.label,location:a.labelLocation||this.defaultLabelLocation||.5,labelStyle:a.labelStyle||this._jsPlumb.instance.Defaults.LabelStyle,id:d}]),this.setListenerComponent=function(a){if(this._jsPlumb)for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].setListenerComponent(a)}},b.OverlayCapableJsPlumbUIComponent.applyType=function(a,b){if(b.overlays){var c,d={};for(c in b.overlays){var e=a._jsPlumb.overlays[b.overlays[c][1].id];if(e)e.updateFrom(b.overlays[c][1]),d[b.overlays[c][1].id]=!0;else{var f=a.getCachedTypeItem("overlay",b.overlays[c][1].id);null!=f?(f.reattach(a._jsPlumb.instance),f.updateFrom(b.overlays[c][1]),a._jsPlumb.overlays[f.id]=f):f=a.addOverlay(b.overlays[c],!0),d[f.id]=!0}}for(c in a._jsPlumb.overlays)null==d[a._jsPlumb.overlays[c].id]&&a.removeOverlay(a._jsPlumb.overlays[c].id)}},c.extend(b.OverlayCapableJsPlumbUIComponent,jsPlumbUIComponent,{setHover:function(a){if(this._jsPlumb&&!this._jsPlumb.instance.isConnectionBeingDragged())for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b][a?"addClass":"removeClass"](this._jsPlumb.instance.hoverClass)},addOverlay:function(a,b){var c=f(this,a);return b||this.repaint(),c},getOverlay:function(a){return this._jsPlumb.overlays[a]},getOverlays:function(){return this._jsPlumb.overlays},hideOverlay:function(a){var b=this.getOverlay(a);b&&b.hide()},hideOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].hide()},showOverlay:function(a){var b=this.getOverlay(a);b&&b.show()},showOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].show()},removeAllOverlays:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup&&this._jsPlumb.overlays[b].cleanup();this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null,a||this.repaint()},removeOverlay:function(a){var b=this._jsPlumb.overlays[a];b&&(b.cleanup&&b.cleanup(),delete this._jsPlumb.overlays[a],this._jsPlumb.overlayPositions&&delete this._jsPlumb.overlayPositions[a])},removeOverlays:function(){for(var a=0,b=arguments.length;b>a;a++)this.removeOverlay(arguments[a])},moveParent:function(a){this.bgCanvas&&(this.bgCanvas.parentNode.removeChild(this.bgCanvas),a.appendChild(this.bgCanvas)),this.canvas.parentNode.removeChild(this.canvas),a.appendChild(this.canvas);for(var b in this._jsPlumb.overlays)if(this._jsPlumb.overlays[b].isAppendedAtTopLevel){var c=this._jsPlumb.overlays[b].getElement();c.parentNode.removeChild(c),a.appendChild(c)}},getLabel:function(){var a=this.getOverlay(d);return null!=a?a.getLabel():null},getLabelOverlay:function(){return this.getOverlay(d)},setLabel:function(a){var b=this.getOverlay(d);if(b)a.constructor==String||a.constructor==Function?b.setLabel(a):(a.label&&b.setLabel(a.label),a.location&&b.setLocation(a.location));else{var c=a.constructor==String||a.constructor==Function?{label:a}:a;b=e(this,c),this._jsPlumb.overlays[d]=b}this._jsPlumb.instance.isSuspendDrawing()||this.repaint()},cleanup:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup(a),this._jsPlumb.overlays[b].destroy(a);a&&(this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null)},setVisible:function(a){this[a?"showOverlays":"hideOverlays"]()},setAbsoluteOverlayPosition:function(a,b){this._jsPlumb.overlayPositions[a.id]=b},getAbsoluteOverlayPosition:function(a){return this._jsPlumb.overlayPositions?this._jsPlumb.overlayPositions[a.id]:null}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a,c){var d=!1;return{drag:function(){if(d)return d=!1,!0;var e=b.getUIPosition(arguments,c.getZoom());a.element&&(jsPlumb.setPosition(a.element,e),c.repaint(a.element,e))},stopDrag:function(){d=!0}}},e=function(a,b){var c=jsPlumb.createElement("div",{position:"absolute"});b.appendElement(c);var d=b.getId(c);b.manage(d,c),a.id=d,a.element=c},f=function(a,c,d,e,f,g,h,i){var j=new b.FloatingAnchor({reference:c,referenceCanvas:e,jsPlumbInstance:g});return h({paintStyle:a,endpoint:d,anchor:j,source:f,scope:i})},g=["connectorStyle","connectorHoverStyle","connectorOverlays","connector","connectionType","connectorClass","connectorHoverClass"],h=function(a,b){var c=0;if(null!=b)for(var d=0;d0)for(var b=0;b0?"add":"remove")+"Class"](j.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](j.endpointFullClass)},this.detachFromConnection=function(a,b,c){b=null==b?i(a,this):b,b>=0&&(this.connections.splice(b,1),this[(this.connections.length>0?"add":"remove")+"Class"](j.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](j.endpointFullClass)),!c&&this._deleteOnDetach&&0===this.connections.length&&j.deleteObject({endpoint:this,fireEvent:!1,deleteAttachedObjects:!1})},this.detach=function(a,b,c,d,e,f,g){var h=null==g?i(a,this):g,k=!1;return d=d!==!1,h>=0&&(c||a._forceDetach||a.isDetachable()&&a.isDetachAllowed(a)&&this.isDetachAllowed(a)&&j.checkCondition("beforeDetach",a,f))&&(j.deleteObject({connection:a,fireEvent:!b&&d,originalEvent:e,deleteAttachedObjects:!1}),k=!0),k},this.detachAll=function(a,b){for(var c=[];this.connections.length>0;){var d=this.detach(this.connections[0],!1,b===!0,a!==!1,null,this,0);d||(c.push(this.connections[0]),this.connections.splice(0,1))}return this.connections=c,this},this.detachFrom=function(a,b,c){for(var d=[],e=0;e0){var l=h(this,a.elementWithPrecedence),m=l.endpoints[0]==this?1:0,n=0===m?l.sourceId:l.targetId,o=j.getCachedData(n),p=o.o,q=o.s;k.txy=[p.left,p.top],k.twh=q,k.tElement=l.endpoints[m]}f=this.anchor.compute(k)}this.endpoint.compute(f,this.anchor.getOrientation(this),this._jsPlumb.paintStyleInUse,g||this.paintStyleInUse),this.endpoint.paint(this._jsPlumb.paintStyleInUse,this.anchor),this.timestamp=b;for(var r in this._jsPlumb.overlays)if(this._jsPlumb.overlays.hasOwnProperty(r)){var s=this._jsPlumb.overlays[r];s.isVisible()&&(this._jsPlumb.overlayPlacements[r]=s.draw(this.endpoint,this._jsPlumb.paintStyleInUse),s.paint(this._jsPlumb.overlayPlacements[r]))}}}},this.getTypeDescriptor=function(){return"endpoint"},this.isVisible=function(){return this._jsPlumb.visible},this.repaint=this.paint;var p=!1;this.initDraggable=function(g){if(!p&&b.isDragSupported(this.element)){var h={id:null,element:null},i=null,n=!1,o=null,q=d(h,j),r=a.dragOptions||{},s={},t=b.dragEvents.start,u=b.dragEvents.stop,v=b.dragEvents.drag,w=function(){i=this.connectorSelector();var b=!0;this.isEnabled()||(b=!1),null!=i||this.isSource||this.isTemporarySource||(b=!1),!this.isSource||!this.isFull()||null!=i&&this.dragAllowedWhenFull||(b=!1),null==i||i.isDetachable(this)||(b=!1);var d=j.checkCondition(null==i?"beforeDrag":"beforeStartDetach",{endpoint:this,source:this.element,sourceId:this.elementId,connection:i});if(d===!1&&(b=!1),b===!1)return j.stopDrag&&j.stopDrag(this.canvas),q.stopDrag(),!1;for(var g=0;g0}.bind(this),j.initDraggable(this.canvas,r,"internal"),this.canvas._jsPlumbRelatedElement=this.element,p=!0}};var q=a.endpoint||this._jsPlumb.instance.Defaults.Endpoint||b.Defaults.Endpoint;this.setEndpoint(q,!0);var r=a.anchor?a.anchor:a.anchors?a.anchors:j.Defaults.Anchor||"Top";this.setAnchor(r,!0);var s=["default",a.type||""].join(" ");this.addType(s,a.data,!0),this.canvas=this.endpoint.canvas,this.canvas._jsPlumb=this,(this.isSource||this.isTarget||this.isTemporarySource)&&this.initDraggable(this.isTarget?"_jsPlumbTarget":"_jsPlumbSource");var t=function(d,e,f,g,h){if((this.isTarget||e)&&b.isDropSupported(this.element)){var i=a.dropOptions||j.Defaults.DropOptions||b.Defaults.DropOptions;i=b.extend({},i),i.scope=i.scope||this.scope;var k=b.dragEvents.drop,l=b.dragEvents.over,m=b.dragEvents.out,n=this,o=j.EndpointDropHandler({getEndpoint:function(){return n},jsPlumb:j,enabled:function(){return null!=g?g.isEnabled():!0},isFull:function(){return g.isFull()},element:this.element,elementId:this.elementId,isSource:this.isSource,isTarget:this.isTarget,addClass:function(a){n.addClass(a)},removeClass:function(a){n.removeClass(a)},isDropAllowed:function(){return n.isDropAllowed.apply(n,arguments)},reference:h,isRedrop:function(a,b){return a.suspendedEndpoint&&b.reference&&a.suspendedEndpoint.id===b.reference.id}});i[k]=c.wrap(i[k],o,!0),i[l]=c.wrap(i[l],function(){var a=b.getDragObject(arguments),c=j.getAttribute(b.getElement(a),"dragId"),d=j.floatingConnections[c];if(null!=d){var e=j.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id==d.suspendedEndpoint.id;if(f){var g=j.checkCondition("checkDropAllowed",{sourceEndpoint:d.endpoints[e],targetEndpoint:this,connection:d});this[(g?"add":"remove")+"Class"](j.endpointDropAllowedClass),this[(g?"remove":"add")+"Class"](j.endpointDropForbiddenClass),d.endpoints[e].anchor.over(this.anchor,this)}}}.bind(this)),i[m]=c.wrap(i[m],function(){var a=b.getDragObject(arguments),c=null==a?null:j.getAttribute(b.getElement(a),"dragId"),d=c?j.floatingConnections[c]:null;if(null!=d){var e=j.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id==d.suspendedEndpoint.id;f&&(this.removeClass(j.endpointDropAllowedClass),this.removeClass(j.endpointDropForbiddenClass),d.endpoints[e].anchor.out())}}.bind(this)),j.initDroppable(d,i,"internal",f)}}.bind(this);return this.anchor.isFloating||t(this.canvas,!0,!(a._transient||this.anchor.isFloating),this,a.reference),this},c.extend(b.Endpoint,b.OverlayCapableJsPlumbUIComponent,{setVisible:function(a,b,c){if(this._jsPlumb.visible=a,this.canvas&&(this.canvas.style.display=a?"block":"none"),this[a?"showOverlays":"hideOverlays"](),!b)for(var d=0;db.dist?1:0});for(var o=k[0].source,p=k[0].target,q=0;qc[0][0],d===!1?-1:1}},r=function(a,b){var c=a[0][0]<0?-Math.PI-a[0][0]:Math.PI-a[0][0],d=b[0][0]<0?-Math.PI-b[0][0]:Math.PI-b[0][0];return c>d?1:a[0][1]>b[0][1]?1:-1},s={top:function(a,b){return a[0]>b[0]?1:-1},right:q(!0),bottom:q(!0),left:r},t=function(a,b){return a.sort(b)},u=function(a,b){var c=m.getCachedData(a),d=c.s,f=c.o,h=function(b,c,d,f,h,i,j){if(f.length>0)for(var k=t(f,s[b]),l="right"===b||"top"===b,m=p(b,c,d,k,h,i,l),n=function(a,b){e[a.id]=[b[0],b[1],b[2],b[3]],g[a.id]=j},o=0;o-1&&(j[d].splice(h,1),b.addToList(j,e,[f,f.endpoints[0],f.endpoints[0].anchor.constructor==c.DynamicAnchor])),f.updateConnectedClass()},this.sourceChanged=function(a,d,e){if(a!==d){b.removeWithFunction(j[a],function(a){return a[0].id===e.id});var f=b.findWithFunction(j[e.targetId],function(a){return a[0].id===e.id});f>-1&&(j[e.targetId][f][0]=e,j[e.targetId][f][1]=e.endpoints[0],j[e.targetId][f][2]=e.endpoints[0].anchor.constructor==c.DynamicAnchor),b.addToList(j,d,[e,e.endpoints[1],e.endpoints[1].anchor.constructor==c.DynamicAnchor]),e.updateConnectedClass()}},this.rehomeEndpoint=function(a,c,e){var f=d[c]||[],g=m.getId(e);if(g!==c){var h=b.indexOf(f,a);if(h>-1){var i=f.splice(h,1)[0];k.add(i,g)}}for(var j=0;j0?this.anchors[0]:null,f=e,g=this,h=function(a,b,c,d,e){var f=d[0]+a.x*e[0],g=d[1]+a.y*e[1],h=d[0]+e[0]/2,i=d[1]+e[1]/2;return Math.sqrt(Math.pow(b-f,2)+Math.pow(c-g,2))+Math.sqrt(Math.pow(h-f,2)+Math.pow(i-g,2))},i=a.selector||function(a,b,c,d,e){for(var f=c[0]+d[0]/2,g=c[1]+d[1]/2,i=-1,j=1/0,k=0;kl&&(i=k+0,j=l)}return e[i]};this.compute=function(a){var b=a.xy,c=a.wh,d=a.txy,h=a.twh;this.timestamp=a.timestamp;var j=g.getUserDefinedLocation();return null!=j?j:this.locked||null==d||null==h?e.compute(a):(a.timestamp=null,e=i(b,c,d,h,this.anchors),this.x=e.x,this.y=e.y,e!=f&&this.fire("anchorChanged",e),f=e,e.compute(a))},this.getCurrentLocation=function(a){return this.getUserDefinedLocation()||(null!=e?e.getCurrentLocation(a):null)},this.getOrientation=function(a){return null!=e?e.getOrientation(a):[0,0]},this.over=function(a,b){null!=e&&e.over(a,b)},this.out=function(){null!=e&&e.out()},this.getCssClass=function(){return e&&e.getCssClass()||""}},b.extend(c.DynamicAnchor,c.Anchor);var e=function(a,b,d,e,f,g){c.Anchors[f]=function(c){var h=c.jsPlumbInstance.makeAnchor([a,b,d,e,0,0],c.elementId,c.jsPlumbInstance);return h.type=f,g&&g(h,c),h}};e(.5,0,0,-1,"TopCenter"),e(.5,1,0,1,"BottomCenter"),e(0,.5,-1,0,"LeftMiddle"),e(1,.5,1,0,"RightMiddle"),e(.5,0,0,-1,"Top"),e(.5,1,0,1,"Bottom"),e(0,.5,-1,0,"Left"),e(1,.5,1,0,"Right"),e(.5,.5,0,0,"Center"),e(1,0,0,-1,"TopRight"),e(1,1,0,1,"BottomRight"),e(0,0,0,-1,"TopLeft"),e(0,1,0,1,"BottomLeft"),c.Defaults.DynamicAnchors=function(a){return a.jsPlumbInstance.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"],a.elementId,a.jsPlumbInstance)},c.Anchors.AutoDefault=function(a){var b=a.jsPlumbInstance.makeDynamicAnchor(c.Defaults.DynamicAnchors(a));return b.type="AutoDefault",b};var f=function(a,b){c.Anchors[a]=function(c){var d=c.jsPlumbInstance.makeAnchor(["Continuous",{faces:b}],c.elementId,c.jsPlumbInstance);return d.type=a,d}};c.Anchors.Continuous=function(a){return a.jsPlumbInstance.continuousAnchorFactory.get(a)},f("ContinuousLeft",["left"]),f("ContinuousTop",["top"]),f("ContinuousBottom",["bottom"]),f("ContinuousRight",["right"]),e(0,0,0,0,"Assign",function(a,b){var c=b.position||"Fixed";a.positionFinder=c.constructor==String?b.jsPlumbInstance.AnchorPositionFinders[c]:c,a.constructorParams=b}),jsPlumbInstance.prototype.AnchorPositionFinders={Fixed:function(a,b,c){return[(a.left-b.left)/c[0],(a.top-b.top)/c[1]]},Grid:function(a,b,c,d){var e=a.left-b.left,f=a.top-b.top,g=c[0]/d.grid[0],h=c[1]/d.grid[1],i=Math.floor(e/g),j=Math.floor(f/h);return[(i*g+g/2)/c[0],(j*h+h/2)/c[1]]}},c.Anchors.Perimeter=function(a){a=a||{};var b=a.anchorCount||60,c=a.shape;if(!c)throw new Error("no shape supplied to Perimeter Anchor type");var d=function(){for(var a=.5,c=2*Math.PI/b,d=0,e=[],f=0;b>f;f++){var g=a+a*Math.sin(d),h=a+a*Math.cos(d);e.push([g,h,0,0]),d+=c}return e},e=function(a){for(var c=b/a.length,d=[],e=function(a,e,f,g,h){c=b*h;for(var i=(f-a)/c,j=(g-e)/c,k=0;c>k;k++)d.push([a+i*k,e+j*k,0,0])},f=0;f0?a:c+a:a*c;return d.pointOnLine({x:g,y:i},{x:h,y:j},e)}return{x:h,y:j}}return{x:g,y:i}},this.gradientAtPoint=function(){return e},this.pointAlongPathFrom=function(a,b,c){var e=this.pointOnPath(a,c),f=0>=b?{x:g,y:i}:{x:h,y:j};return 0>=b&&Math.abs(b)>1&&(b*=-1),d.pointOnLine(e,f,b)};var l=function(a,b,c){return c>=Math.min(a,b)&&c<=Math.max(a,b)},m=function(a,b,c){return Math.abs(c-a)a-b?b:k>c-a?c:a};this.pointOnPath=function(b,c){if(0===b)return{x:this.x1,y:this.y1,theta:this.startAngle};if(1==b)return{x:this.x2,y:this.y2,theta:this.endAngle};c&&(b/=j);var d=e(this,b),f=a.cx+a.r*Math.cos(d),g=a.cy+a.r*Math.sin(d);return{x:l(f),y:l(g),theta:d}},this.gradientAtPoint=function(b,c){var e=this.pointOnPath(b,c),f=d.normal([a.cx,a.cy],[e.x,e.y]);return this.anticlockwise||1/0!=f&&f!=-1/0||(f*=-1),f},this.pointAlongPathFrom=function(b,c,d){var e=this.pointOnPath(b,d),f=2*(c/h)*Math.PI,g=this.anticlockwise?-1:1,i=e.theta+g*f,j=a.cx+this.radius*Math.cos(i),k=a.cy+this.radius*Math.sin(i);return{x:j,y:k}}},Bezier:function(c){this.curve=[{x:c.x1,y:c.y1},{x:c.cp1x,y:c.cp1y},{x:c.cp2x,y:c.cp2y},{x:c.x2,y:c.y2}],b.Segments.AbstractSegment.apply(this,arguments),this.bounds={minX:Math.min(c.x1,c.x2,c.cp1x,c.cp2x),minY:Math.min(c.y1,c.y2,c.cp1y,c.cp2y),maxX:Math.max(c.x1,c.x2,c.cp1x,c.cp2x),maxY:Math.max(c.y1,c.y2,c.cp1y,c.cp2y)},this.type="Bezier";var d=function(b,c,d){return d&&(c=a.jsBezier.locationAlongCurveFrom(b,c>0?0:1,c)),c};this.pointOnPath=function(b,c){return b=d(this.curve,b,c),a.jsBezier.pointOnCurve(this.curve,b)},this.gradientAtPoint=function(b,c){return b=d(this.curve,b,c),a.jsBezier.gradientAtPoint(this.curve,b)},this.pointAlongPathFrom=function(b,c,e){return b=d(this.curve,b,e),a.jsBezier.pointAlongCurveFrom(this.curve,b,c)},this.getLength=function(){return a.jsBezier.getLength(this.curve)},this.getBounds=function(){return this.bounds}}};var e=function(){this.resetBounds=function(){this.bounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}},this.resetBounds()};b.Connectors.AbstractConnector=function(a){e.apply(this,arguments);var f=[],g=0,h=[],i=[],j=a.stub||0,k=c.isArray(j)?j[0]:j,l=c.isArray(j)?j[1]:j,m=a.gap||0,n=c.isArray(m)?m[0]:m,o=c.isArray(m)?m[1]:m,p=null,q=!1,r=null;this.getPath=function(){},this.setPath=function(){},this.findSegmentForPoint=function(a,b){for(var c={d:1/0,s:null,x:null,y:null,l:null},d=0;d0?a/g:(g+a)/g);for(var c=h.length-1,d=1,e=0;e=a){c=e,d=1==a?1:0===a?0:(a-h[e][0])/i[e];break}return{segment:f[c],proportion:d,index:c}},u=function(a,c,d){if(d.x1!=d.x2||d.y1!=d.y2){var e=new b.Segments[c](d);f.push(e),g+=e.getLength(),a.updateBounds(e)}},v=function(){g=f.length=h.length=i.length=0};this.setSegments=function(a){p=[],g=0;for(var b=0;bp?0:1,r=[1,0][q];g=[],h=[],g[q]=a.sourcePos[q]>a.targetPos[q]?-1:1,h[q]=a.sourcePos[q]>a.targetPos[q]?1:-1,g[r]=0,h[r]=0}var s=c?m+n*g[0]:n*g[0],t=e?p+n*g[1]:n*g[1],u=c?o*h[0]:m+o*h[0],v=e?o*h[1]:p+o*h[1],w=g[0]*h[0]+g[1]*h[1],x={sx:s,sy:t,tx:u,ty:v,lw:f,xSpan:Math.abs(u-s),ySpan:Math.abs(v-t),mx:(s+u)/2,my:(t+v)/2,so:g,to:h,x:i,y:j,w:m,h:p,segment:b,startStubX:s+g[0]*k,startStubY:t+g[1]*k,endStubX:u+h[0]*l,endStubY:v+h[1]*l,isXGreaterThanStubTimes2:Math.abs(s-u)>k+l,isYGreaterThanStubTimes2:Math.abs(t-v)>k+l,opposite:-1==w,perpendicular:0===w,orthogonal:1==w,sourceAxis:0===g[0]?"y":"x",points:[i,j,m,p,s,t,u,v]};return x.anchorOrientation=x.opposite?"opposite":x.orthogonal?"orthogonal":"perpendicular",x};return this.getSegments=function(){return f},this.updateBounds=function(a){var b=a.getBounds();this.bounds.minX=Math.min(this.bounds.minX,b.minX),this.bounds.maxX=Math.max(this.bounds.maxX,b.maxX),this.bounds.minY=Math.min(this.bounds.minY,b.minY),this.bounds.maxY=Math.max(this.bounds.maxY,b.maxY)},this.pointOnPath=function(a,b){var c=t(a,b);return c.segment&&c.segment.pointOnPath(c.proportion,!1)||[0,0]},this.gradientAtPoint=function(a,b){var c=t(a,b);return c.segment&&c.segment.gradientAtPoint(c.proportion,!1)||0},this.pointAlongPathFrom=function(a,b,c){var d=t(a,c);return d.segment&&d.segment.pointAlongPathFrom(d.proportion,b,!1)||[0,0]},this.compute=function(a){q||(r=w.call(this,a)),v(),this._compute(r,a),this.x=r.points[0],this.y=r.points[1],this.w=r.points[2],this.h=r.points[3],this.segment=r.segment,s()},{addSegment:u,prepareCompute:w,sourceStub:k,targetStub:l,maxStub:Math.max(k,l),sourceGap:n,targetGap:o,maxGap:Math.max(n,o)}},c.extend(b.Connectors.AbstractConnector,e);var f=b.Connectors.Straight=function(){this.type="Straight";var a=b.Connectors.AbstractConnector.apply(this,arguments);this._compute=function(b){a.addSegment(this,"Straight",{x1:b.sx,y1:b.sy,x2:b.startStubX,y2:b.startStubY}),a.addSegment(this,"Straight",{x1:b.startStubX,y1:b.startStubY,x2:b.endStubX,y2:b.endStubY}),a.addSegment(this,"Straight",{x1:b.endStubX,y1:b.endStubY,x2:b.tx,y2:b.ty})}};c.extend(b.Connectors.Straight,b.Connectors.AbstractConnector),b.registerConnectorType(f,"Straight"),b.Endpoints.AbstractEndpoint=function(a){e.apply(this,arguments);var b=this.compute=function(){var a=this._compute.apply(this,arguments);return this.x=a[0],this.y=a[1],this.w=a[2],this.h=a[3],this.bounds.minX=this.x,this.bounds.minY=this.y,this.bounds.maxX=this.x+this.w,this.bounds.maxY=this.y+this.h,a};return{compute:b,cssClass:a.cssClass}},c.extend(b.Endpoints.AbstractEndpoint,e),b.Endpoints.Dot=function(a){this.type="Dot",b.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},this.radius=a.radius||10,this.defaultOffset=.5*this.radius,this.defaultInnerRadius=this.radius/3,this._compute=function(a,b,c){this.radius=c.radius||this.radius;var d=a[0]-this.radius,e=a[1]-this.radius,f=2*this.radius,g=2*this.radius;if(c.strokeStyle){var h=c.lineWidth||1;d-=h,e-=h,f+=2*h,g+=2*h}return[d,e,f,g,this.radius]}},c.extend(b.Endpoints.Dot,b.Endpoints.AbstractEndpoint),b.Endpoints.Rectangle=function(a){this.type="Rectangle",b.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},this.width=a.width||20,this.height=a.height||20,this._compute=function(a,b,c){var d=c.width||this.width,e=c.height||this.height,f=a[0]-d/2,g=a[1]-e/2;return[f,g,d,e]}},c.extend(b.Endpoints.Rectangle,b.Endpoints.AbstractEndpoint);var g=function(){b.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.displayElements=[]};c.extend(g,b.jsPlumbUIComponent,{getDisplayElements:function(){return this._jsPlumb.displayElements},appendDisplayElement:function(a){this._jsPlumb.displayElements.push(a)}}),b.Endpoints.Image=function(d){this.type="Image",g.apply(this,arguments),b.Endpoints.AbstractEndpoint.apply(this,arguments);var e=d.onload,f=d.src||d.url,h=d.cssClass?" "+d.cssClass:"";this._jsPlumb.img=new Image,this._jsPlumb.ready=!1,this._jsPlumb.initialized=!1,this._jsPlumb.deleted=!1,this._jsPlumb.widthToUse=d.width,this._jsPlumb.heightToUse=d.height,this._jsPlumb.endpoint=d.endpoint,this._jsPlumb.img.onload=function(){null!=this._jsPlumb&&(this._jsPlumb.ready=!0,this._jsPlumb.widthToUse=this._jsPlumb.widthToUse||this._jsPlumb.img.width,this._jsPlumb.heightToUse=this._jsPlumb.heightToUse||this._jsPlumb.img.height,e&&e(this))}.bind(this),this._jsPlumb.endpoint.setImage=function(a,b){var c=a.constructor==String?a:a.src;e=b,this._jsPlumb.img.src=c,null!=this.canvas&&this.canvas.setAttribute("src",this._jsPlumb.img.src)}.bind(this),this._jsPlumb.endpoint.setImage(f,e),this._compute=function(a){return this.anchorPoint=a,this._jsPlumb.ready?[a[0]-this._jsPlumb.widthToUse/2,a[1]-this._jsPlumb.heightToUse/2,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse]:[0,0,0,0]},this.canvas=jsPlumb.createElement("img",{position:"absolute",margin:0,padding:0,outline:0},this._jsPlumb.instance.endpointClass+h),this._jsPlumb.widthToUse&&this.canvas.setAttribute("width",this._jsPlumb.widthToUse),this._jsPlumb.heightToUse&&this.canvas.setAttribute("height",this._jsPlumb.heightToUse),this._jsPlumb.instance.appendElement(this.canvas),this.actuallyPaint=function(){if(!this._jsPlumb.deleted){this._jsPlumb.initialized||(this.canvas.setAttribute("src",this._jsPlumb.img.src),this.appendDisplayElement(this.canvas),this._jsPlumb.initialized=!0);var a=this.anchorPoint[0]-this._jsPlumb.widthToUse/2,b=this.anchorPoint[1]-this._jsPlumb.heightToUse/2;c.sizeElement(this.canvas,a,b,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse)}},this.paint=function(b,c){null!=this._jsPlumb&&(this._jsPlumb.ready?this.actuallyPaint(b,c):a.setTimeout(function(){this.paint(b,c)}.bind(this),200))}},c.extend(b.Endpoints.Image,[g,b.Endpoints.AbstractEndpoint],{cleanup:function(a){a&&(this._jsPlumb.deleted=!0,this.canvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null)}}),b.Endpoints.Blank=function(a){b.Endpoints.AbstractEndpoint.apply(this,arguments),this.type="Blank",g.apply(this,arguments),this._compute=function(a){return[a[0],a[1],10,0]};var d=a.cssClass?" "+a.cssClass:"";this.canvas=jsPlumb.createElement("div",{display:"block",width:"1px",height:"1px",background:"transparent",position:"absolute"},this._jsPlumb.instance.endpointClass+d),this._jsPlumb.instance.appendElement(this.canvas),this.paint=function(){c.sizeElement(this.canvas,this.x,this.y,this.w,this.h)}},c.extend(b.Endpoints.Blank,[b.Endpoints.AbstractEndpoint,g],{cleanup:function(){this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}),b.Endpoints.Triangle=function(a){this.type="Triangle",b.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},a.width=a.width||55,a.height=a.height||55,this.width=a.width,this.height=a.height,this._compute=function(a,b,c){var d=c.width||self.width,e=c.height||self.height,f=a[0]-d/2,g=a[1]-e/2;return[f,g,d,e]}};var h=b.Overlays.AbstractOverlay=function(a){this.visible=!0,this.isAppendedAtTopLevel=!0,this.component=a.component,this.loc=null==a.location?.5:a.location,this.endpointLoc=null==a.endpointLocation?[.5,.5]:a.endpointLocation};h.prototype={cleanup:function(a){a&&(this.component=null,this.canvas=null,this.endpointLoc=null)},reattach:function(){},setVisible:function(a){this.visible=a,this.component.repaint()},isVisible:function(){return this.visible},hide:function(){this.setVisible(!1)},show:function(){this.setVisible(!0)},incrementLocation:function(a){this.loc+=a,this.component.repaint()},setLocation:function(a){this.loc=a,this.component.repaint()},getLocation:function(){return this.loc},updateFrom:function(){}},b.Overlays.Arrow=function(a){this.type="Arrow",h.apply(this,arguments),this.isAppendedAtTopLevel=!1,a=a||{},this.length=a.length||20,this.width=a.width||20,this.id=a.id;var b=(a.direction||1)<0?-1:1,e=a.paintStyle||{lineWidth:1},f=a.foldback||.623;this.computeMaxSize=function(){return 1.5*self.width},this.draw=function(a,g){var h,i,j,k,l;if(a.pointAlongPathFrom){if(c.isString(this.loc)||this.loc>1||this.loc<0){var m=parseInt(this.loc,10),n=this.loc<0?1:0;h=a.pointAlongPathFrom(n,m,!1),i=a.pointAlongPathFrom(n,m-b*this.length/2,!1),j=d.pointOnLine(h,i,this.length)}else if(1==this.loc){if(h=a.pointOnPath(this.loc),i=a.pointAlongPathFrom(this.loc,-this.length),j=d.pointOnLine(h,i,this.length),-1==b){var o=j;j=h,h=o}}else if(0===this.loc){if(j=a.pointOnPath(this.loc),i=a.pointAlongPathFrom(this.loc,this.length),h=d.pointOnLine(j,i,this.length),-1==b){var p=j;j=h,h=p}}else h=a.pointAlongPathFrom(this.loc,b*this.length/2),i=a.pointOnPath(this.loc),j=d.pointOnLine(h,i,this.length);k=d.perpendicularLineTo(h,j,this.width),l=d.pointOnLine(h,j,f*this.length);var q={hxy:h,tail:k,cxy:l},r=e.strokeStyle||g.strokeStyle,s=e.fillStyle||g.strokeStyle,t=e.lineWidth||g.lineWidth;return{component:a,d:q,lineWidth:t,strokeStyle:r,fillStyle:s,minX:Math.min(h.x,k[0].x,k[1].x),maxX:Math.max(h.x,k[0].x,k[1].x),minY:Math.min(h.y,k[0].y,k[1].y),maxY:Math.max(h.y,k[0].y,k[1].y)}}return{component:a,minX:0,maxX:0,minY:0,maxY:0}}},c.extend(b.Overlays.Arrow,h,{updateFrom:function(a){this.length=a.length||this.length,this.width=a.width||this.width,this.direction=null!=a.direction?a.direction:this.direction,this.foldback=a.foldback||this.foldback}}),b.Overlays.PlainArrow=function(a){a=a||{};var c=b.extend(a,{foldback:1});b.Overlays.Arrow.call(this,c),this.type="PlainArrow"},c.extend(b.Overlays.PlainArrow,b.Overlays.Arrow),b.Overlays.Diamond=function(a){a=a||{};var c=a.length||40,d=jsPlumb.extend(a,{length:c/2,foldback:2});b.Overlays.Arrow.call(this,d),this.type="Diamond"},c.extend(b.Overlays.Diamond,b.Overlays.Arrow);var i=function(a,b){return(null==a._jsPlumb.cachedDimensions||b)&&(a._jsPlumb.cachedDimensions=a.getDimensions()),a._jsPlumb.cachedDimensions},j=function(a){b.jsPlumbUIComponent.apply(this,arguments),h.apply(this,arguments);var d=this.fire;this.fire=function(){d.apply(this,arguments),this.component&&this.component.fire.apply(this.component,arguments)},this.detached=!1,this.id=a.id,this._jsPlumb.div=null,this._jsPlumb.initialised=!1,this._jsPlumb.component=a.component,this._jsPlumb.cachedDimensions=null,this._jsPlumb.create=a.create,this._jsPlumb.initiallyInvisible=a.visible===!1,this.getElement=function(){if(null==this._jsPlumb.div){var b=this._jsPlumb.div=jsPlumb.getElement(this._jsPlumb.create(this._jsPlumb.component));b.style.position="absolute",b.className=this._jsPlumb.instance.overlayClass+" "+(this.cssClass?this.cssClass:a.cssClass?a.cssClass:""),this._jsPlumb.instance.appendElement(b),this._jsPlumb.instance.getId(b),this.canvas=b;var c="translate(-50%, -50%)";b.style.webkitTransform=c,b.style.mozTransform=c,b.style.msTransform=c,b.style.oTransform=c,b.style.transform=c,b._jsPlumb=this,a.visible===!1&&(b.style.display="none")}return this._jsPlumb.div},this.draw=function(a,b,d){var e=i(this);if(null!=e&&2==e.length){var f={x:0,y:0};if(d)f={x:d[0],y:d[1]};else if(a.pointOnPath){var g=this.loc,h=!1;(c.isString(this.loc)||this.loc<0||this.loc>1)&&(g=parseInt(this.loc,10),h=!0),f=a.pointOnPath(g,h)}else{var j=this.loc.constructor==Array?this.loc:this.endpointLoc;f={x:j[0]*a.w,y:j[1]*a.h}}var k=f.x-e[0]/2,l=f.y-e[1]/2;return{component:a,d:{minx:k,miny:l,td:e,cxy:f},minX:k,maxX:k+e[0],minY:l,maxY:l+e[1]}}return{minX:0,maxX:0,minY:0,maxY:0}}};c.extend(j,[b.jsPlumbUIComponent,h],{getDimensions:function(){return c.oldIE?b.getSize(this.getElement()):[1,1]},setVisible:function(a){this._jsPlumb.div&&(this._jsPlumb.div.style.display=a?"block":"none",a&&this._jsPlumb.initiallyInvisible&&(i(this,!0),this.component.repaint(),this._jsPlumb.initiallyInvisible=!1))},clearCachedDimensions:function(){this._jsPlumb.cachedDimensions=null},cleanup:function(a){a?null!=this._jsPlumb.div&&(this._jsPlumb.div._jsPlumb=null,this._jsPlumb.instance.removeElement(this._jsPlumb.div)):(this._jsPlumb&&this._jsPlumb.div&&this._jsPlumb.div.parentNode&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div),this.detached=!0)},reattach:function(a){null!=this._jsPlumb.div&&a.getContainer().appendChild(this._jsPlumb.div),this.detached=!1},computeMaxSize:function(){var a=i(this);return Math.max(a[0],a[1])},paint:function(a){this._jsPlumb.initialised||(this.getElement(),a.component.appendDisplayElement(this._jsPlumb.div),this._jsPlumb.initialised=!0,this.detached&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div)),this._jsPlumb.div.style.left=a.component.x+a.d.minx+"px",this._jsPlumb.div.style.top=a.component.y+a.d.miny+"px"}}),b.Overlays.Custom=function(){this.type="Custom",j.apply(this,arguments)},c.extend(b.Overlays.Custom,j),b.Overlays.GuideLines=function(){var a=this;a.length=50,a.lineWidth=5,this.type="GuideLines",h.apply(this,arguments),b.jsPlumbUIComponent.apply(this,arguments),this.draw=function(b){var c=b.pointAlongPathFrom(a.loc,a.length/2),e=b.pointOnPath(a.loc),f=d.pointOnLine(c,e,a.length),g=d.perpendicularLineTo(c,f,40),h=d.perpendicularLineTo(f,c,20);return{connector:b,head:c,tail:f,headLine:h,tailLine:g,minX:Math.min(c.x,f.x,h[0].x,h[1].x),minY:Math.min(c.y,f.y,h[0].y,h[1].y),maxX:Math.max(c.x,f.x,h[0].x,h[1].x),maxY:Math.max(c.y,f.y,h[0].y,h[1].y)}}},b.Overlays.Label=function(a){this.labelStyle=a.labelStyle,this.cssClass=null!=this.labelStyle?this.labelStyle.cssClass:null;var c=b.extend({create:function(){return jsPlumb.createElement("div")}},a);if(b.Overlays.Custom.call(this,c),this.type="Label",this.label=a.label||"",this.labelText=null,this.labelStyle){var d=this.getElement();if(this.labelStyle.font=this.labelStyle.font||"12px sans-serif",d.style.font=this.labelStyle.font,d.style.color=this.labelStyle.color||"black",this.labelStyle.fillStyle&&(d.style.background=this.labelStyle.fillStyle),this.labelStyle.borderWidth>0){var e=this.labelStyle.borderStyle?this.labelStyle.borderStyle:"black";d.style.border=this.labelStyle.borderWidth+"px solid "+e}this.labelStyle.padding&&(d.style.padding=this.labelStyle.padding)}},c.extend(b.Overlays.Label,b.Overlays.Custom,{cleanup:function(a){a&&(this.div=null,this.label=null,this.labelText=null,this.cssClass=null,this.labelStyle=null)},getLabel:function(){return this.label},setLabel:function(a){this.label=a,this.labelText=null,this.clearCachedDimensions(),this.update(),this.component.repaint()},getDimensions:function(){return this.update(),j.prototype.getDimensions.apply(this,arguments)},update:function(){if("function"==typeof this.label){var a=this.label(this);this.getElement().innerHTML=a.replace(/\r\n/g,"
    ")}else null==this.labelText&&(this.labelText=this.label,this.getElement().innerHTML=this.labelText.replace(/\r\n/g,"
    "))},updateFrom:function(a){a.label&&this.setLabel(a.label)}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=function(b){var c=b._mottle;return c||(c=b._mottle=new a.Mottle),c};b.extend(a.jsPlumbInstance.prototype,{getEventManager:function(){return c(this)},on:function(){this.getEventManager().on.apply(this,arguments)},off:function(){this.getEventManager().off.apply(this,arguments)}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a){this.type="Flowchart",a=a||{},a.stub=null==a.stub?30:a.stub;var c,d,e=b.Connectors.AbstractConnector.apply(this,arguments),f=null==a.midpoint?.5:a.midpoint,g=a.alwaysRespectStubs===!0,h=null,i=null,j=null,k=null!=a.cornerRadius?a.cornerRadius:0,l=function(a){return 0>a?-1:0===a?0:1},m=function(a,b,c,d){if(i!=b||j!=c){var e=null==i?d.sx:i,f=null==j?d.sy:j,g=e==b?"v":"h",h=l(b-e),k=l(c-f);i=b,j=c,a.push([e,f,b,c,g,h,k])}},n=function(a){return Math.sqrt(Math.pow(a[0]-a[2],2)+Math.pow(a[1]-a[3],2))},o=function(a){var b=[];return b.push.apply(b,a),b},p=function(a,b,c){for(var d,f=null,g=0;g0&&f[4]!=d[4]){var h=Math.min(k,n(f),n(d));f[2]-=f[5]*h,f[3]-=f[6]*h,d[0]+=d[5]*h,d[1]+=d[6]*h;var i=f[6]==d[5]&&1==d[5]||f[6]==d[5]&&0===d[5]&&f[5]!=d[6]||f[6]==d[5]&&-1==d[5],j=d[1]>f[3]?1:-1,l=d[0]>f[2]?1:-1,m=j==l,p=m&&i||!m&&!i?d[0]:f[2],q=m&&i||!m&&!i?f[3]:d[1];e.addSegment(a,"Straight",{x1:f[0],y1:f[1],x2:f[2],y2:f[3]}),e.addSegment(a,"Arc",{r:h,x1:f[2],y1:f[3],x2:d[0],y2:d[1],cx:p,cy:q,ac:i})}else{var r=f[2]==f[0]?0:f[2]>f[0]?c.lw/2:-(c.lw/2),s=f[3]==f[1]?0:f[3]>f[1]?c.lw/2:-(c.lw/2);e.addSegment(a,"Straight",{x1:f[0]-r,y1:f[1]-s,x2:f[2]+r,y2:f[3]+s})}f=d}null!=d&&e.addSegment(a,"Straight",{x1:d[0],y1:d[1],x2:d[2],y2:d[3]})};this.setSegments=function(a){h=a},this.isEditable=function(){return!0},this.getOriginalSegments=function(){return h||c},this._compute=function(a,b){if(b.clearEdits&&(h=null),null!=h)return p(this,h,a),void 0;c=[],i=null,j=null,d=null;var k=a.startStubX+(a.endStubX-a.startStubX)*f,l=a.startStubY+(a.endStubY-a.startStubY)*f,n={x:[0,1],y:[1,0]},o=function(){return[a.startStubX,a.startStubY,a.endStubX,a.endStubY]},q={perpendicular:o,orthogonal:o,opposite:function(b){var c=a,d="x"==b?0:1,e={x:function(){return 1==c.so[d]&&(c.startStubX>c.endStubX&&c.tx>c.startStubX||c.sx>c.endStubX&&c.tx>c.sx)||-1==c.so[d]&&(c.startStubXc.endStubY&&c.ty>c.startStubY||c.sy>c.endStubY&&c.ty>c.sy)||-1==c.so[d]&&(c.startStubYj[b][0],s=e[b][p][0],t=e[b][p][1],u=d[b][p][q];return c.segment==u[3]||c.segment==u[2]&&r?f[b]:c.segment==u[2]&&s>t?g[b]:c.segment==u[2]&&t>=s||c.segment==u[1]&&!r?i[b]:c.segment==u[0]||c.segment==u[1]&&r?h[b]:void 0},orthogonal:function(b,c,d,e,f){var g=a,h={x:-1==g.so[0]?Math.min(c,e):Math.max(c,e),y:-1==g.so[1]?Math.min(c,e):Math.max(c,e)}[b];return{x:[[h,d],[h,f],[e,f]],y:[[d,h],[f,h],[f,e]]}[b]},opposite:function(c,d,f,g){var h=a,i={x:"y",y:"x"}[c],j={x:"height",y:"width"}[c],m=h["is"+c.toUpperCase()+"GreaterThanStubTimes2"];if(b.sourceEndpoint.elementId==b.targetEndpoint.elementId){var n=f+(1-b.sourceEndpoint.anchor[i])*b.sourceInfo[j]+e.maxStub;return{x:[[d,n],[g,n]],y:[[n,d],[n,g]]}[c]}return!m||1==h.so[t]&&d>g||-1==h.so[t]&&g>d?{x:[[d,l],[g,l]],y:[[k,d],[k,g]]}[c]:1==h.so[t]&&g>d||-1==h.so[t]&&d>g?{x:[[k,h.sy],[k,h.ty]],y:[[h.sx,l],[h.tx,l]]}[c]:void 0}},s=q[a.anchorOrientation](a.sourceAxis),t="x"==a.sourceAxis?0:1,u="x"==a.sourceAxis?1:0,v=s[t],w=s[u],x=s[t+2],y=s[u+2];m(c,s[0],s[1],a);var z=r[a.anchorOrientation](a.sourceAxis,v,w,x,y);if(z)for(var A=0;A=a&&b>=d?1:c>=a&&d>=b?2:a>=c&&d>=b?3:4},e=function(a,b,c,d,e,f,g,h,i){return i>=h?[a,b]:1===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:2===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:3===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:4===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:void 0 +},f=function(a){a=a||{},this.type="StateMachine";var c=b.Connectors.AbstractConnector.apply(this,arguments),f=a.curviness||10,g=a.margin||5,h=a.proximityLimit||80,i=a.orientation&&"clockwise"===a.orientation,j=a.loopbackRadius||25,k=a.showLoopback!==!1;this._compute=function(a,b){var l=Math.abs(b.sourcePos[0]-b.targetPos[0]),m=Math.abs(b.sourcePos[1]-b.targetPos[1]);if(k&&b.sourceEndpoint.elementId===b.targetEndpoint.elementId){var n=b.sourcePos[0],o=b.sourcePos[1]-g,p=n,q=o-j,r=2*j,s=2*j,t=p-j,u=q-j;a.points[0]=t,a.points[1]=u,a.points[2]=r,a.points[3]=s,c.addSegment(this,"Arc",{loopback:!0,x1:n-t+4,y1:o-u,startAngle:0,endAngle:2*Math.PI,r:j,ac:!i,x2:n-t-4,y2:o-u,cx:p-t,cy:q-u})}else{var v=b.sourcePos[0]c?a.insertBefore(b,a.childNodes[c]):a.appendChild(b)};c.svg={node:t,attr:s,pos:u};var z=function(a){var d=a.pointerEventsSpec||"all",e={};b.jsPlumbUIComponent.apply(this,a.originalArgs),this.canvas=null,this.path=null,this.svg=null,this.bgCanvas=null;var f=a.cssClass+" "+(a.originalArgs[0].cssClass||""),g={style:"",width:0,height:0,"pointer-events":d,position:"absolute"};this.svg=t("svg",g),a.useDivWrapper?(this.canvas=jsPlumb.createElement("div",{position:"absolute"}),c.sizeElement(this.canvas,0,0,1,1),this.canvas.className=f):(s(this.svg,{"class":f}),this.canvas=this.svg),a._jsPlumb.appendElement(this.canvas,a.originalArgs[0].parent),a.useDivWrapper&&this.canvas.appendChild(this.svg);var h=[this.canvas];return this.getDisplayElements=function(){return h},this.appendDisplayElement=function(a){h.push(a)},this.paint=function(b,d,f){if(null!=b){var g,h=[this.x,this.y],i=[this.w,this.h];null!=f&&(f.xmin<0&&(h[0]+=f.xmin),f.ymin<0&&(h[1]+=f.ymin),i[0]=f.xmax+(f.xmin<0?-f.xmin:0),i[1]=f.ymax+(f.ymin<0?-f.ymin:0)),a.useDivWrapper?(c.sizeElement(this.canvas,h[0],h[1],i[0],i[1]),h[0]=0,h[1]=0,g=u([0,0])):g=u([h[0],h[1]]),e.paint.apply(this,arguments),s(this.svg,{style:g,width:i[0]||0,height:i[1]||0})}},{renderer:e}};c.extend(z,b.jsPlumbUIComponent,{cleanup:function(a){a||null==this.typeId?(this.canvas&&(this.canvas._jsPlumb=null),this.svg&&(this.svg._jsPlumb=null),this.bgCanvas&&(this.bgCanvas._jsPlumb=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.svg=null,this.canvas=null,this.path=null,this.group=null):(this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.bgCanvas.parentNode.removeChild(this.bgCanvas))},reattach:function(a){var b=a.getContainer();this.canvas&&null==this.canvas.parentNode&&b.appendChild(this.canvas),this.bgCanvas&&null==this.bgCanvas.parentNode&&b.appendChild(this.bgCanvas)},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none")}}),b.ConnectorRenderers.svg=function(a){var d=this,e=z.apply(this,[{cssClass:a._jsPlumb.connectorClass,originalArgs:arguments,pointerEventsSpec:"none",_jsPlumb:a._jsPlumb}]);e.renderer.paint=function(e,f,g){var h=d.getSegments(),i="",j=[0,0];if(g.xmin<0&&(j[0]=-g.xmin),g.ymin<0&&(j[1]=-g.ymin),h.length>0){for(var k=0;kMath.PI?1:0,d=a.anticlockwise?0:1;return"M"+a.x1+" "+a.y1+" A "+a.radius+" "+b.r+" 0 "+c+","+d+" "+a.x2+" "+a.y2}}[a.type]()}}};var A=b.SvgEndpoint=function(a){var d=z.apply(this,[{cssClass:a._jsPlumb.endpointClass,originalArgs:arguments,pointerEventsSpec:"all",useDivWrapper:!0,_jsPlumb:a._jsPlumb}]);d.renderer.paint=function(a){var d=b.extend({},a);d.outlineColor&&(d.strokeWidth=d.outlineWidth,d.strokeStyle=c.convertStyle(d.outlineColor,!0)),null==this.node?(this.node=this.makeNode(d),this.svg.appendChild(this.node)):null!=this.updateNode&&this.updateNode(this.node),x(this.svg,this.node,d,[this.x,this.y,this.w,this.h],this),u(this.node,[this.x,this.y])}.bind(this)};c.extend(A,z),b.Endpoints.svg.Dot=function(){b.Endpoints.Dot.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(){return t("circle",{cx:this.w/2,cy:this.h/2,r:this.radius})},this.updateNode=function(a){s(a,{cx:this.w/2,cy:this.h/2,r:this.radius})}},c.extend(b.Endpoints.svg.Dot,[b.Endpoints.Dot,A]),b.Endpoints.svg.Rectangle=function(){b.Endpoints.Rectangle.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(){return t("rect",{width:this.w,height:this.h})},this.updateNode=function(a){s(a,{width:this.w,height:this.h})}},c.extend(b.Endpoints.svg.Rectangle,[b.Endpoints.Rectangle,A]),b.Endpoints.svg.Image=b.Endpoints.Image,b.Endpoints.svg.Blank=b.Endpoints.Blank,b.Overlays.svg.Label=b.Overlays.Label,b.Overlays.svg.Custom=b.Overlays.Custom;var B=function(a,c){a.apply(this,c),b.jsPlumbUIComponent.apply(this,c),this.isAppendedAtTopLevel=!1,this.path=null,this.paint=function(a,b){if(a.component.svg&&b){null==this.path&&(this.path=t("path",{"pointer-events":"all"}),a.component.svg.appendChild(this.path),this.canvas=a.component.svg);var e=c&&1==c.length?c[0].cssClass||"":"",f=[0,0];b.xmin<0&&(f[0]=-b.xmin),b.ymin<0&&(f[1]=-b.ymin),s(this.path,{d:d(a.d),"class":e,stroke:a.strokeStyle?a.strokeStyle:null,fill:a.fillStyle?a.fillStyle:null,transform:"translate("+f[0]+","+f[1]+")"})}};var d=function(a){return isNaN(a.cxy.x)||isNaN(a.cxy.y)?"":"M"+a.hxy.x+","+a.hxy.y+" L"+a.tail[0].x+","+a.tail[0].y+" L"+a.cxy.x+","+a.cxy.y+" L"+a.tail[1].x+","+a.tail[1].y+" L"+a.hxy.x+","+a.hxy.y};this.transfer=function(a){a.canvas&&this.path&&this.path.parentNode&&(this.path.parentNode.removeChild(this.path),a.canvas.appendChild(this.path))}};c.extend(B,[b.jsPlumbUIComponent,b.Overlays.AbstractOverlay],{cleanup:function(a){null!=this.path&&(a?this._jsPlumb.instance.removeElement(this.path):this.path.parentNode&&this.path.parentNode.removeChild(this.path))},reattach:function(){this.path&&this.canvas&&null==this.path.parentNode&&this.canvas.appendChild(this.path)},setVisible:function(a){null!=this.path&&(this.path.style.display=a?"block":"none")}}),b.Overlays.svg.Arrow=function(){B.apply(this,[b.Overlays.Arrow,arguments])},c.extend(b.Overlays.svg.Arrow,[b.Overlays.Arrow,B]),b.Overlays.svg.PlainArrow=function(){B.apply(this,[b.Overlays.PlainArrow,arguments])},c.extend(b.Overlays.svg.PlainArrow,[b.Overlays.PlainArrow,B]),b.Overlays.svg.Diamond=function(){B.apply(this,[b.Overlays.Diamond,arguments])},c.extend(b.Overlays.svg.Diamond,[b.Overlays.Diamond,B]),b.Overlays.svg.GuideLines=function(){var a,c,d=null,e=this;b.Overlays.GuideLines.apply(this,arguments),this.paint=function(b,g){null==d&&(d=t("path"),b.connector.svg.appendChild(d),e.attachListeners(d,b.connector),e.attachListeners(d,e),a=t("path"),b.connector.svg.appendChild(a),e.attachListeners(a,b.connector),e.attachListeners(a,e),c=t("path"),b.connector.svg.appendChild(c),e.attachListeners(c,b.connector),e.attachListeners(c,e));var h=[0,0];g.xmin<0&&(h[0]=-g.xmin),g.ymin<0&&(h[1]=-g.ymin),s(d,{d:f(b.head,b.tail),stroke:"red",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(a,{d:f(b.tailLine[0],b.tailLine[1]),stroke:"blue",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(c,{d:f(b.headLine[0],b.headLine[1]),stroke:"green",fill:null,transform:"translate("+h[0]+","+h[1]+")"})};var f=function(a,b){return"M "+a.x+","+a.y+" L"+b.x+","+b.y}},c.extend(b.Overlays.svg.GuideLines,b.Overlays.GuideLines)}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d={"stroke-linejoin":"joinstyle",joinstyle:"joinstyle",endcap:"endcap",miterlimit:"miterlimit"},e=null;if(document.createStyleSheet&&document.namespaces){var f=[".jsplumb_vml","jsplumb\\:textbox","jsplumb\\:oval","jsplumb\\:rect","jsplumb\\:stroke","jsplumb\\:shape","jsplumb\\:group"],g="behavior:url(#default#VML);position:absolute;";e=document.createStyleSheet();for(var h=0;h=k&&(window.clearInterval(o),null!=c.complete&&c.complete())},j)},destroyDraggable:function(a,b){f(this,b).destroyDraggable(a)},destroyDroppable:function(a,b){f(this,b).destroyDroppable(a)},initDraggable:function(a,b,c){f(this,c).draggable(a,b)},initDroppable:function(a,b,c){f(this,c).droppable(a,b)},isAlreadyDraggable:function(a){return null!=a._katavorioDrag},isDragSupported:function(){return!0},isDropSupported:function(){return!0},isElementDraggable:function(a){return a=jsPlumb.getElement(a),a._katavorioDrag&&a._katavorioDrag.isEnabled()},getDragObject:function(a){return a[0].drag.getDragElement()},getDragScope:function(a){return a._katavorioDrag&&a._katavorioDrag.scopes.join(" ")||""},getDropEvent:function(a){return a[0].e},getDropScope:function(a){return a._katavorioDrop&&a._katavorioDrop.scopes.join(" ")||""},getUIPosition:function(a){return{left:a[0].pos[0],top:a[0].pos[1]}},setDragFilter:function(a,b,c){a._katavorioDrag&&a._katavorioDrag.setFilter(b,c)},setElementDraggable:function(a,b){a=jsPlumb.getElement(a),a._katavorioDrag&&a._katavorioDrag.setEnabled(b)},setDragScope:function(a,b){a._katavorioDrag&&a._katavorioDrag.k.setDragScope(a,b)},dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop",complete:"complete"},animEvents:{step:"step",complete:"complete"},stopDrag:function(a){a._katavorioDrag&&a._katavorioDrag.abort()},addToDragSelection:function(a){f(this).select(a)},removeFromDragSelection:function(a){f(this).deselect(a)},clearDragSelection:function(){f(this).deselectAll()},getOriginalEvent:function(a){return a},trigger:function(a,b,c){this.getEventManager().trigger(a,b,c)},doReset:function(){for(var a in this)0===a.indexOf("_katavorio_")&&this[a].reset()}});var h=function(a){var b=function(){/complete|loaded|interactive/.test(document.readyState)&&"undefined"!=typeof document.body&&null!=document.body?a():setTimeout(b,9)};b()};h(b.init)}.call(this); \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6.js new file mode 100644 index 000000000..5b5bfeb4c --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/dom.jsPlumb-1.7.6.js @@ -0,0 +1,12729 @@ +/** + * jsBezier-0.7 + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * licensed under the MIT license. + * + * a set of Bezier curve functions that deal with Beziers, used by jsPlumb, and perhaps useful for other people. These functions work with Bezier + * curves of arbitrary degree. + * + * - functions are all in the 'jsBezier' namespace. + * + * - all input points should be in the format {x:.., y:..}. all output points are in this format too. + * + * - all input curves should be in the format [ {x:.., y:..}, {x:.., y:..}, {x:.., y:..}, {x:.., y:..} ] + * + * - 'location' as used as an input here refers to a decimal in the range 0-1 inclusive, which indicates a point some proportion along the length + * of the curve. location as output has the same format and meaning. + * + * + * Function List: + * -------------- + * + * distanceFromCurve(point, curve) + * + * Calculates the distance that the given point lies from the given Bezier. Note that it is computed relative to the center of the Bezier, + * so if you have stroked the curve with a wide pen you may wish to take that into account! The distance returned is relative to the values + * of the curve and the point - it will most likely be pixels. + * + * gradientAtPoint(curve, location) + * + * Calculates the gradient to the curve at the given location, as a decimal between 0 and 1 inclusive. + * + * gradientAtPointAlongCurveFrom (curve, location) + * + * Calculates the gradient at the point on the given curve that is 'distance' units from location. + * + * nearestPointOnCurve(point, curve) + * + * Calculates the nearest point to the given point on the given curve. The return value of this is a JS object literal, containing both the + *point's coordinates and also the 'location' of the point (see above), for example: { point:{x:551,y:150}, location:0.263365 }. + * + * pointOnCurve(curve, location) + * + * Calculates the coordinates of the point on the given Bezier curve at the given location. + * + * pointAlongCurveFrom(curve, location, distance) + * + * Calculates the coordinates of the point on the given curve that is 'distance' units from location. 'distance' should be in the same coordinate + * space as that used to construct the Bezier curve. For an HTML Canvas usage, for example, distance would be a measure of pixels. + * + * locationAlongCurveFrom(curve, location, distance) + * + * Calculates the location on the given curve that is 'distance' units from location. 'distance' should be in the same coordinate + * space as that used to construct the Bezier curve. For an HTML Canvas usage, for example, distance would be a measure of pixels. + * + * perpendicularToCurveAt(curve, location, length, distance) + * + * Calculates the perpendicular to the given curve at the given location. length is the length of the line you wish for (it will be centered + * on the point at 'location'). distance is optional, and allows you to specify a point along the path from the given location as the center of + * the perpendicular returned. The return value of this is an array of two points: [ {x:...,y:...}, {x:...,y:...} ]. + * + * + */ + +(function() { + + var root = this; + + if(typeof Math.sgn == "undefined") { + Math.sgn = function(x) { return x == 0 ? 0 : x > 0 ? 1 :-1; }; + } + + var Vectors = { + subtract : function(v1, v2) { return {x:v1.x - v2.x, y:v1.y - v2.y }; }, + dotProduct : function(v1, v2) { return (v1.x * v2.x) + (v1.y * v2.y); }, + square : function(v) { return Math.sqrt((v.x * v.x) + (v.y * v.y)); }, + scale : function(v, s) { return {x:v.x * s, y:v.y * s }; } + }, + + maxRecursion = 64, + flatnessTolerance = Math.pow(2.0,-maxRecursion-1); + + /** + * Calculates the distance that the point lies from the curve. + * + * @param point a point in the form {x:567, y:3342} + * @param curve a Bezier curve in the form [{x:..., y:...}, {x:..., y:...}, {x:..., y:...}, {x:..., y:...}]. note that this is currently + * hardcoded to assume cubiz beziers, but would be better off supporting any degree. + * @return a JS object literal containing location and distance, for example: {location:0.35, distance:10}. Location is analogous to the location + * argument you pass to the pointOnPath function: it is a ratio of distance travelled along the curve. Distance is the distance in pixels from + * the point to the curve. + */ + var _distanceFromCurve = function(point, curve) { + var candidates = [], + w = _convertToBezier(point, curve), + degree = curve.length - 1, higherDegree = (2 * degree) - 1, + numSolutions = _findRoots(w, higherDegree, candidates, 0), + v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0; + + for (var i = 0; i < numSolutions; i++) { + v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null)); + var newDist = Vectors.square(v); + if (newDist < dist) { + dist = newDist; + t = candidates[i]; + } + } + v = Vectors.subtract(point, curve[degree]); + newDist = Vectors.square(v); + if (newDist < dist) { + dist = newDist; + t = 1.0; + } + return {location:t, distance:dist}; + }; + /** + * finds the nearest point on the curve to the given point. + */ + var _nearestPointOnCurve = function(point, curve) { + var td = _distanceFromCurve(point, curve); + return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location}; + }; + var _convertToBezier = function(point, curve) { + var degree = curve.length - 1, higherDegree = (2 * degree) - 1, + c = [], d = [], cdTable = [], w = [], + z = [ [1.0, 0.6, 0.3, 0.1], [0.4, 0.6, 0.6, 0.4], [0.1, 0.3, 0.6, 1.0] ]; + + for (var i = 0; i <= degree; i++) c[i] = Vectors.subtract(curve[i], point); + for (var i = 0; i <= degree - 1; i++) { + d[i] = Vectors.subtract(curve[i+1], curve[i]); + d[i] = Vectors.scale(d[i], 3.0); + } + for (var row = 0; row <= degree - 1; row++) { + for (var column = 0; column <= degree; column++) { + if (!cdTable[row]) cdTable[row] = []; + cdTable[row][column] = Vectors.dotProduct(d[row], c[column]); + } + } + for (i = 0; i <= higherDegree; i++) { + if (!w[i]) w[i] = []; + w[i].y = 0.0; + w[i].x = parseFloat(i) / higherDegree; + } + var n = degree, m = degree-1; + for (var k = 0; k <= n + m; k++) { + var lb = Math.max(0, k - m), + ub = Math.min(k, n); + for (i = lb; i <= ub; i++) { + j = k - i; + w[i+j].y += cdTable[j][i] * z[j][i]; + } + } + return w; + }; + /** + * counts how many roots there are. + */ + var _findRoots = function(w, degree, t, depth) { + var left = [], right = [], + left_count, right_count, + left_t = [], right_t = []; + + switch (_getCrossingCount(w, degree)) { + case 0 : { + return 0; + } + case 1 : { + if (depth >= maxRecursion) { + t[0] = (w[0].x + w[degree].x) / 2.0; + return 1; + } + if (_isFlatEnough(w, degree)) { + t[0] = _computeXIntercept(w, degree); + return 1; + } + break; + } + } + _bezier(w, degree, 0.5, left, right); + left_count = _findRoots(left, degree, left_t, depth+1); + right_count = _findRoots(right, degree, right_t, depth+1); + for (var i = 0; i < left_count; i++) t[i] = left_t[i]; + for (var i = 0; i < right_count; i++) t[i+left_count] = right_t[i]; + return (left_count+right_count); + }; + var _getCrossingCount = function(curve, degree) { + var n_crossings = 0, sign, old_sign; + sign = old_sign = Math.sgn(curve[0].y); + for (var i = 1; i <= degree; i++) { + sign = Math.sgn(curve[i].y); + if (sign != old_sign) n_crossings++; + old_sign = sign; + } + return n_crossings; + }; + var _isFlatEnough = function(curve, degree) { + var error, + intercept_1, intercept_2, left_intercept, right_intercept, + a, b, c, det, dInv, a1, b1, c1, a2, b2, c2; + a = curve[0].y - curve[degree].y; + b = curve[degree].x - curve[0].x; + c = curve[0].x * curve[degree].y - curve[degree].x * curve[0].y; + + var max_distance_above = max_distance_below = 0.0; + + for (var i = 1; i < degree; i++) { + var value = a * curve[i].x + b * curve[i].y + c; + if (value > max_distance_above) + max_distance_above = value; + else if (value < max_distance_below) + max_distance_below = value; + } + + a1 = 0.0; b1 = 1.0; c1 = 0.0; a2 = a; b2 = b; + c2 = c - max_distance_above; + det = a1 * b2 - a2 * b1; + dInv = 1.0/det; + intercept_1 = (b1 * c2 - b2 * c1) * dInv; + a2 = a; b2 = b; c2 = c - max_distance_below; + det = a1 * b2 - a2 * b1; + dInv = 1.0/det; + intercept_2 = (b1 * c2 - b2 * c1) * dInv; + left_intercept = Math.min(intercept_1, intercept_2); + right_intercept = Math.max(intercept_1, intercept_2); + error = right_intercept - left_intercept; + return (error < flatnessTolerance)? 1 : 0; + }; + var _computeXIntercept = function(curve, degree) { + var XLK = 1.0, YLK = 0.0, + XNM = curve[degree].x - curve[0].x, YNM = curve[degree].y - curve[0].y, + XMK = curve[0].x - 0.0, YMK = curve[0].y - 0.0, + det = XNM*YLK - YNM*XLK, detInv = 1.0/det, + S = (XNM*YMK - YNM*XMK) * detInv; + return 0.0 + XLK * S; + }; + var _bezier = function(curve, degree, t, left, right) { + var temp = [[]]; + for (var j =0; j <= degree; j++) temp[0][j] = curve[j]; + for (var i = 1; i <= degree; i++) { + for (var j =0 ; j <= degree - i; j++) { + if (!temp[i]) temp[i] = []; + if (!temp[i][j]) temp[i][j] = {}; + temp[i][j].x = (1.0 - t) * temp[i-1][j].x + t * temp[i-1][j+1].x; + temp[i][j].y = (1.0 - t) * temp[i-1][j].y + t * temp[i-1][j+1].y; + } + } + if (left != null) + for (j = 0; j <= degree; j++) left[j] = temp[j][0]; + if (right != null) + for (j = 0; j <= degree; j++) right[j] = temp[degree-j][j]; + + return (temp[degree][0]); + }; + + var _curveFunctionCache = {}; + var _getCurveFunctions = function(order) { + var fns = _curveFunctionCache[order]; + if (!fns) { + fns = []; + var f_term = function() { return function(t) { return Math.pow(t, order); }; }, + l_term = function() { return function(t) { return Math.pow((1-t), order); }; }, + c_term = function(c) { return function(t) { return c; }; }, + t_term = function() { return function(t) { return t; }; }, + one_minus_t_term = function() { return function(t) { return 1-t; }; }, + _termFunc = function(terms) { + return function(t) { + var p = 1; + for (var i = 0; i < terms.length; i++) p = p * terms[i](t); + return p; + }; + }; + + fns.push(new f_term()); // first is t to the power of the curve order + for (var i = 1; i < order; i++) { + var terms = [new c_term(order)]; + for (var j = 0 ; j < (order - i); j++) terms.push(new t_term()); + for (var j = 0 ; j < i; j++) terms.push(new one_minus_t_term()); + fns.push(new _termFunc(terms)); + } + fns.push(new l_term()); // last is (1-t) to the power of the curve order + + _curveFunctionCache[order] = fns; + } + + return fns; + }; + + + /** + * calculates a point on the curve, for a Bezier of arbitrary order. + * @param curve an array of control points, eg [{x:10,y:20}, {x:50,y:50}, {x:100,y:100}, {x:120,y:100}]. For a cubic bezier this should have four points. + * @param location a decimal indicating the distance along the curve the point should be located at. this is the distance along the curve as it travels, taking the way it bends into account. should be a number from 0 to 1, inclusive. + */ + var _pointOnPath = function(curve, location) { + var cc = _getCurveFunctions(curve.length - 1), + _x = 0, _y = 0; + for (var i = 0; i < curve.length ; i++) { + _x = _x + (curve[i].x * cc[i](location)); + _y = _y + (curve[i].y * cc[i](location)); + } + + return {x:_x, y:_y}; + }; + + var _dist = function(p1,p2) { + return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); + }; + + var _isPoint = function(curve) { + return curve[0].x == curve[1].x && curve[0].y == curve[1].y; + }; + + /** + * finds the point that is 'distance' along the path from 'location'. this method returns both the x,y location of the point and also + * its 'location' (proportion of travel along the path); the method below - _pointAlongPathFrom - calls this method and just returns the + * point. + */ + var _pointAlongPath = function(curve, location, distance) { + + if (_isPoint(curve)) { + return { + point:curve[0], + location:location + }; + } + + var prev = _pointOnPath(curve, location), + tally = 0, + curLoc = location, + direction = distance > 0 ? 1 : -1, + cur = null; + + while (tally < Math.abs(distance)) { + curLoc += (0.005 * direction); + cur = _pointOnPath(curve, curLoc); + tally += _dist(cur, prev); + prev = cur; + } + return {point:cur, location:curLoc}; + }; + + var _length = function(curve) { + if (_isPoint(curve)) return 0; + + var prev = _pointOnPath(curve, 0), + tally = 0, + curLoc = 0, + direction = 1, + cur = null; + + while (curLoc < 1) { + curLoc += (0.005 * direction); + cur = _pointOnPath(curve, curLoc); + tally += _dist(cur, prev); + prev = cur; + } + return tally; + }; + + /** + * finds the point that is 'distance' along the path from 'location'. + */ + var _pointAlongPathFrom = function(curve, location, distance) { + return _pointAlongPath(curve, location, distance).point; + }; + + /** + * finds the location that is 'distance' along the path from 'location'. + */ + var _locationAlongPathFrom = function(curve, location, distance) { + return _pointAlongPath(curve, location, distance).location; + }; + + /** + * returns the gradient of the curve at the given location, which is a decimal between 0 and 1 inclusive. + * + * thanks // http://bimixual.org/AnimationLibrary/beziertangents.html + */ + var _gradientAtPoint = function(curve, location) { + var p1 = _pointOnPath(curve, location), + p2 = _pointOnPath(curve.slice(0, curve.length - 1), location), + dy = p2.y - p1.y, dx = p2.x - p1.x; + return dy == 0 ? Infinity : Math.atan(dy / dx); + }; + + /** + returns the gradient of the curve at the point which is 'distance' from the given location. + if this point is greater than location 1, the gradient at location 1 is returned. + if this point is less than location 0, the gradient at location 0 is returned. + */ + var _gradientAtPointAlongPathFrom = function(curve, location, distance) { + var p = _pointAlongPath(curve, location, distance); + if (p.location > 1) p.location = 1; + if (p.location < 0) p.location = 0; + return _gradientAtPoint(curve, p.location); + }; + + /** + * calculates a line that is 'length' pixels long, perpendicular to, and centered on, the path at 'distance' pixels from the given location. + * if distance is not supplied, the perpendicular for the given location is computed (ie. we set distance to zero). + */ + var _perpendicularToPathAt = function(curve, location, length, distance) { + distance = distance == null ? 0 : distance; + var p = _pointAlongPath(curve, location, distance), + m = _gradientAtPoint(curve, p.location), + _theta2 = Math.atan(-1 / m), + y = length / 2 * Math.sin(_theta2), + x = length / 2 * Math.cos(_theta2); + return [{x:p.point.x + x, y:p.point.y + y}, {x:p.point.x - x, y:p.point.y - y}]; + }; + + this.jsBezier = { + distanceFromCurve : _distanceFromCurve, + gradientAtPoint : _gradientAtPoint, + gradientAtPointAlongCurveFrom : _gradientAtPointAlongPathFrom, + nearestPointOnCurve : _nearestPointOnCurve, + pointOnCurve : _pointOnPath, + pointAlongCurveFrom : _pointAlongPathFrom, + perpendicularToCurveAt : _perpendicularToPathAt, + locationAlongCurveFrom:_locationAlongPathFrom, + getLength:_length + }; +}).call(this); + +/** + * Biltong v0.2 + * + * Various geometry functions written as part of jsPlumb and perhaps useful for others. + * + * Copyright (c) 2014 Simon Porritt + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +;(function() { + + + "use strict"; + + var Biltong = this.Biltong = {}; + + var _isa = function(a) { return Object.prototype.toString.call(a) === "[object Array]"; }, + _pointHelper = function(p1, p2, fn) { + p1 = _isa(p1) ? p1 : [p1.x, p1.y]; + p2 = _isa(p2) ? p2 : [p2.x, p2.y]; + return fn(p1, p2); + }, + /** + * @name Biltong.gradient + * @function + * @desc Calculates the gradient of a line between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The gradient of a line between the two points. + */ + _gradient = Biltong.gradient = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + if (_p2[0] == _p1[0]) + return _p2[1] > _p1[1] ? Infinity : -Infinity; + else if (_p2[1] == _p1[1]) + return _p2[0] > _p1[0] ? 0 : -0; + else + return (_p2[1] - _p1[1]) / (_p2[0] - _p1[0]); + }); + }, + /** + * @name Biltong.normal + * @function + * @desc Calculates the gradient of a normal to a line between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The gradient of a normal to a line between the two points. + */ + _normal = Biltong.normal = function(p1, p2) { + return -1 / _gradient(p1, p2); + }, + /** + * @name Biltong.lineLength + * @function + * @desc Calculates the length of a line between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The length of a line between the two points. + */ + _lineLength = Biltong.lineLength = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + return Math.sqrt(Math.pow(_p2[1] - _p1[1], 2) + Math.pow(_p2[0] - _p1[0], 2)); + }); + }, + /** + * @name Biltong.quadrant + * @function + * @desc Calculates the quadrant in which the angle between the two points lies. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Integer} The quadrant - 1 for upper right, 2 for lower right, 3 for lower left, 4 for upper left. + */ + _quadrant = Biltong.quadrant = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + if (_p2[0] > _p1[0]) { + return (_p2[1] > _p1[1]) ? 2 : 1; + } + else if (_p2[0] == _p1[0]) { + return _p2[1] > _p1[1] ? 2 : 1; + } + else { + return (_p2[1] > _p1[1]) ? 3 : 4; + } + }); + }, + /** + * @name Biltong.theta + * @function + * @desc Calculates the angle between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The angle between the two points. + */ + _theta = Biltong.theta = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + var m = _gradient(_p1, _p2), + t = Math.atan(m), + s = _quadrant(_p1, _p2); + if ((s == 4 || s== 3)) t += Math.PI; + if (t < 0) t += (2 * Math.PI); + + return t; + }); + }, + /** + * @name Biltong.intersects + * @function + * @desc Calculates whether or not the two rectangles intersect. + * @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @return {Boolean} True if the rectangles intersect, false otherwise. + */ + _intersects = Biltong.intersects = function(r1, r2) { + var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h, + a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h; + + return ( (x1 <= a1 && a1 <= x2) && (y1 <= b1 && b1 <= y2) ) || + ( (x1 <= a2 && a2 <= x2) && (y1 <= b1 && b1 <= y2) ) || + ( (x1 <= a1 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) || + ( (x1 <= a2 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) || + ( (a1 <= x1 && x1 <= a2) && (b1 <= y1 && y1 <= b2) ) || + ( (a1 <= x2 && x2 <= a2) && (b1 <= y1 && y1 <= b2) ) || + ( (a1 <= x1 && x1 <= a2) && (b1 <= y2 && y2 <= b2) ) || + ( (a1 <= x2 && x1 <= a2) && (b1 <= y2 && y2 <= b2) ); + }, + /** + * @name Biltong.encloses + * @function + * @desc Calculates whether or not r2 is completely enclosed by r1. + * @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @param {Boolean} [allowSharedEdges=false] If true, the concept of enclosure allows for one or more edges to be shared by the two rectangles. + * @return {Boolean} True if r1 encloses r2, false otherwise. + */ + _encloses = Biltong.encloses = function(r1, r2, allowSharedEdges) { + var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h, + a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h, + c = function(v1, v2, v3, v4) { return allowSharedEdges ? v1 <= v2 && v3>= v4 : v1 < v2 && v3 > v4; }; + + return c(x1,a1,x2,a2) && c(y1,b1,y2,b2); + }, + _segmentMultipliers = [null, [1, -1], [1, 1], [-1, 1], [-1, -1] ], + _inverseSegmentMultipliers = [null, [-1, -1], [-1, 1], [1, 1], [1, -1] ], + /** + * @name Biltong.pointOnLine + * @function + * @desc Calculates a point on the line from `fromPoint` to `toPoint` that is `distance` units along the length of the line. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Point} Point on the line, in the form `{ x:..., y:... }`. + */ + _pointOnLine = Biltong.pointOnLine = function(fromPoint, toPoint, distance) { + var m = _gradient(fromPoint, toPoint), + s = _quadrant(fromPoint, toPoint), + segmentMultiplier = distance > 0 ? _segmentMultipliers[s] : _inverseSegmentMultipliers[s], + theta = Math.atan(m), + y = Math.abs(distance * Math.sin(theta)) * segmentMultiplier[1], + x = Math.abs(distance * Math.cos(theta)) * segmentMultiplier[0]; + return { x:fromPoint.x + x, y:fromPoint.y + y }; + }, + /** + * @name Biltong.perpendicularLineTo + * @function + * @desc Calculates a line of length `length` that is perpendicular to the line from `fromPoint` to `toPoint` and passes through `toPoint`. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Line} Perpendicular line, in the form `[ { x:..., y:... }, { x:..., y:... } ]`. + */ + _perpendicularLineTo = Biltong.perpendicularLineTo = function(fromPoint, toPoint, length) { + var m = _gradient(fromPoint, toPoint), + theta2 = Math.atan(-1 / m), + y = length / 2 * Math.sin(theta2), + x = length / 2 * Math.cos(theta2); + return [{x:toPoint.x + x, y:toPoint.y + y}, {x:toPoint.x - x, y:toPoint.y - y}]; + }; +}).call(this); +; +(function () { + + "use strict"; + + var Sniff = { + android: navigator.userAgent.toLowerCase().indexOf("android") > -1 + }; + + var matchesSelector = function (el, selector, ctx) { + ctx = ctx || el.parentNode; + var possibles = ctx.querySelectorAll(selector); + for (var i = 0; i < possibles.length; i++) { + if (possibles[i] === el) { + return true; + } + } + return false; + }, + _gel = function (el) { + return typeof el == "string" ? document.getElementById(el) : el; + }, + _t = function (e) { + return e.srcElement || e.target; + }, + _d = function (l, fn) { + for (var i = 0, j = l.length; i < j; i++) { + if (l[i] == fn) break; + } + if (i < l.length) l.splice(i, 1); + }, + guid = 1, + // + // this function generates a guid for every handler, sets it on the handler, then adds + // it to the associated object's map of handlers for the given event. this is what enables us + // to unbind all events of some type, or all events (the second of which can be requested by the user, + // but it also used by Mottle when an element is removed.) + _store = function (obj, event, fn) { + var g = guid++; + obj.__ta = obj.__ta || {}; + obj.__ta[event] = obj.__ta[event] || {}; + // store each handler with a unique guid. + obj.__ta[event][g] = fn; + // set the guid on the handler. + fn.__tauid = g; + return g; + }, + _unstore = function (obj, event, fn) { + obj.__ta && obj.__ta[event] && delete obj.__ta[event][fn.__tauid]; + // a handler might have attached extra functions, so we unbind those too. + if (fn.__taExtra) { + for (var i = 0; i < fn.__taExtra.length; i++) { + _unbind(obj, fn.__taExtra[i][0], fn.__taExtra[i][1]); + } + fn.__taExtra.length = 0; + } + // a handler might have attached an unstore callback + fn.__taUnstore && fn.__taUnstore(); + }, + _curryChildFilter = function (children, obj, fn, evt) { + if (children == null) return fn; + else { + var c = children.split(","), + _fn = function (e) { + _fn.__tauid = fn.__tauid; + var t = _t(e); + for (var i = 0; i < c.length; i++) { + if (matchesSelector(t, c[i], obj)) { + fn.apply(t, arguments); + } + } + }; + registerExtraFunction(fn, evt, _fn); + return _fn; + } + }, + // + // registers an 'extra' function on some event listener function we were given - a function that we + // created and bound to the element as part of our housekeeping, and which we want to unbind and remove + // whenever the given function is unbound. + registerExtraFunction = function (fn, evt, newFn) { + fn.__taExtra = fn.__taExtra || []; + fn.__taExtra.push([evt, newFn]); + }, + DefaultHandler = function (obj, evt, fn, children) { + if (isTouchDevice && touchMap[evt]) { + var tfn = _curryChildFilter(children, obj, fn, touchMap[evt]); + _bind(obj, touchMap[evt], tfn , fn); + } + if (evt === "focus" && obj.getAttribute("tabindex") == null) { + obj.setAttribute("tabindex", "1"); + } + _bind(obj, evt, _curryChildFilter(children, obj, fn, evt), fn); + }, + SmartClickHandler = function (obj, evt, fn, children) { + if (obj.__taSmartClicks == null) { + var down = function (e) { + obj.__tad = _pageLocation(e); + }, + up = function (e) { + obj.__tau = _pageLocation(e); + }, + click = function (e) { + if (obj.__tad && obj.__tau && obj.__tad[0] === obj.__tau[0] && obj.__tad[1] === obj.__tau[1]) { + for (var i = 0; i < obj.__taSmartClicks.length; i++) + obj.__taSmartClicks[i].apply(_t(e), [ e ]); + } + }; + DefaultHandler(obj, "mousedown", down, children); + DefaultHandler(obj, "mouseup", up, children); + DefaultHandler(obj, "click", click, children); + obj.__taSmartClicks = []; + } + + // store in the list of callbacks + obj.__taSmartClicks.push(fn); + // the unstore function removes this function from the object's listener list for this type. + fn.__taUnstore = function () { + _d(obj.__taSmartClicks, fn); + }; + }, + _tapProfiles = { + "tap": {touches: 1, taps: 1}, + "dbltap": {touches: 1, taps: 2}, + "contextmenu": {touches: 2, taps: 1} + }, + TapHandler = function (clickThreshold, dblClickThreshold) { + return function (obj, evt, fn, children) { + // if event is contextmenu, for devices which are mouse only, we want to + // use the default bind. + if (evt == "contextmenu" && isMouseDevice) + DefaultHandler(obj, evt, fn, children); + else { + // the issue here is that this down handler gets registered only for the + // child nodes in the first registration. in fact it should be registered with + // no child selector and then on down we should cycle through the regustered + // functions to see if one of them matches. on mouseup we should execute ALL of + // the functions whose children are either null or match the element. + if (obj.__taTapHandler == null) { + var tt = obj.__taTapHandler = { + tap: [], + dbltap: [], + contextmenu: [], + down: false, + taps: 0, + downSelectors: [] + }; + var down = function (e) { + var target = e.srcElement || e.target; + for (var i = 0; i < tt.downSelectors.length; i++) { + if (tt.downSelectors[i] == null || matchesSelector(target, tt.downSelectors[i], obj)) { + tt.down = true; + setTimeout(clearSingle, clickThreshold); + setTimeout(clearDouble, dblClickThreshold); + break; // we only need one match on mousedown + } + } + }, + up = function (e) { + if (tt.down) { + var target = e.srcElement || e.target; + tt.taps++; + var tc = _touchCount(e); + for (var eventId in _tapProfiles) { + var p = _tapProfiles[eventId]; + if (p.touches === tc && (p.taps === 1 || p.taps === tt.taps)) { + for (var i = 0; i < tt[eventId].length; i++) { + if (tt[eventId][i][1] == null || matchesSelector(target, tt[eventId][i][1], obj)) + tt[eventId][i][0].apply(_t(e), [ e ]); + } + } + } + } + }, + clearSingle = function () { + tt.down = false; + }, + clearDouble = function () { + tt.taps = 0; + }; + + DefaultHandler(obj, "mousedown", down/*, children*/); + DefaultHandler(obj, "mouseup", up/*, children*/); + } + // add this child selector (it can be null, that's fine). + obj.__taTapHandler.downSelectors.push(children); + + obj.__taTapHandler[evt].push([fn, children]); + // the unstore function removes this function from the object's listener list for this type. + fn.__taUnstore = function () { + _d(obj.__taTapHandler[evt], fn); + }; + } + }; + }, + meeHelper = function (type, evt, obj, target) { + for (var i in obj.__tamee[type]) { + obj.__tamee[type][i].apply(target, [ evt ]); + } + }, + MouseEnterExitHandler = function () { + var activeElements = []; + return function (obj, evt, fn, children) { + if (!obj.__tamee) { + // __tamee holds a flag saying whether the mouse is currently "in" the element, and a list of + // both mouseenter and mouseexit functions. + obj.__tamee = { over: false, mouseenter: [], mouseexit: [] }; + // register over and out functions + var over = function (e) { + var t = _t(e); + if ((children == null && (t == obj && !obj.__tamee.over)) || (matchesSelector(t, children, obj) && (t.__tamee == null || !t.__tamee.over))) { + meeHelper("mouseenter", e, obj, t); + t.__tamee = t.__tamee || {}; + t.__tamee.over = true; + activeElements.push(t); + } + }, + out = function (e) { + var t = _t(e); + // is the current target one of the activeElements? and is the + // related target NOT a descendant of it? + for (var i = 0; i < activeElements.length; i++) { + if (t == activeElements[i] && !matchesSelector((e.relatedTarget || e.toElement), "*", t)) { + t.__tamee.over = false; + activeElements.splice(i, 1); + meeHelper("mouseexit", e, obj, t); + } + } + }; + + _bind(obj, "mouseover", _curryChildFilter(children, obj, over, "mouseover"), over); + _bind(obj, "mouseout", _curryChildFilter(children, obj, out, "mouseout"), out); + } + + fn.__taUnstore = function () { + delete obj.__tamee[evt][fn.__tauid]; + }; + + _store(obj, evt, fn); + obj.__tamee[evt][fn.__tauid] = fn; + }; + }, + isTouchDevice = "ontouchstart" in document.documentElement, + isMouseDevice = "onmousedown" in document.documentElement, + touchMap = { "mousedown": "touchstart", "mouseup": "touchend", "mousemove": "touchmove" }, + touchstart = "touchstart", touchend = "touchend", touchmove = "touchmove", + iev = (function () { + var rv = -1; + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent, + re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv; + })(), + isIELT9 = iev > -1 && iev < 9, + _genLoc = function (e, prefix) { + if (e == null) return [ 0, 0 ]; + var ts = _touches(e), t = _getTouch(ts, 0); + return [t[prefix + "X"], t[prefix + "Y"]]; + }, + _pageLocation = function (e) { + if (e == null) return [ 0, 0 ]; + if (isIELT9) { + return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ]; + } + else { + return _genLoc(e, "page"); + } + }, + _screenLocation = function (e) { + return _genLoc(e, "screen"); + }, + _clientLocation = function (e) { + return _genLoc(e, "client"); + }, + _getTouch = function (touches, idx) { + return touches.item ? touches.item(idx) : touches[idx]; + }, + _touches = function (e) { + return e.touches && e.touches.length > 0 ? e.touches : + e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches : + e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches : + [ e ]; + }, + _touchCount = function (e) { + return _touches(e).length; + }, + //http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html + _bind = function (obj, type, fn, originalFn) { + _store(obj, type, fn); + originalFn.__tauid = fn.__tauid; + if (obj.addEventListener) + obj.addEventListener(type, fn, false); + else if (obj.attachEvent) { + var key = type + fn.__tauid; + obj["e" + key] = fn; + // TODO look at replacing with .call(..) + obj[key] = function () { + obj["e" + key] && obj["e" + key](window.event); + }; + obj.attachEvent("on" + type, obj[key]); + } + }, + _unbind = function (obj, type, fn) { + if (fn == null) return; + _each(obj, function () { + var _el = _gel(this); + _unstore(_el, type, fn); + // it has been bound if there is a tauid. otherwise it was not bound and we can ignore it. + if (fn.__tauid != null) { + if (_el.removeEventListener) { + _el.removeEventListener(type, fn, false); + if (isTouchDevice && touchMap[type]) _el.removeEventListener(touchMap[type], fn, false); + } + else if (this.detachEvent) { + var key = type + fn.__tauid; + _el[key] && _el.detachEvent("on" + type, _el[key]); + _el[key] = null; + _el["e" + key] = null; + } + } + + // if a touch event was also registered, deregister now. + if (fn.__taTouchProxy) { + _unbind(obj, fn.__taTouchProxy[1], fn.__taTouchProxy[0]); + } + }); + }, + _devNull = function () { + }, + _each = function (obj, fn) { + if (obj == null) return; + // if a list (or list-like), use it. if a string, get a list + // by running the string through querySelectorAll. else, assume + // it's an Element. + // obj.top is "unknown" in IE8. + obj = (typeof Window !== "undefined" && (typeof obj.top !== "unknown" && obj == obj.top)) ? [ obj ] : + (typeof obj !== "string") && (obj.tagName == null && obj.length != null) ? obj : + typeof obj === "string" ? document.querySelectorAll(obj) + : [ obj ]; + + for (var i = 0; i < obj.length; i++) + fn.apply(obj[i]); + }; + + /** + * Mottle offers support for abstracting out the differences + * between touch and mouse devices, plus "smart click" functionality + * (don't fire click if the mouse has moved between mousedown and mouseup), + * and synthesized click/tap events. + * @class Mottle + * @constructor + * @param {Object} params Constructor params + * @param {Integer} [params.clickThreshold=150] Threshold, in milliseconds beyond which a touchstart followed by a touchend is not considered to be a click. + * @param {Integer} [params.dblClickThreshold=350] Threshold, in milliseconds beyond which two successive tap events are not considered to be a click. + * @param {Boolean} [params.smartClicks=false] If true, won't fire click events if the mouse has moved between mousedown and mouseup. Note that this functionality + * requires that Mottle consume the mousedown event, and so may not be viable in all use cases. + */ + this.Mottle = function (params) { + params = params || {}; + var clickThreshold = params.clickThreshold || 150, + dblClickThreshold = params.dblClickThreshold || 350, + mouseEnterExitHandler = new MouseEnterExitHandler(), + tapHandler = new TapHandler(clickThreshold, dblClickThreshold), + _smartClicks = params.smartClicks, + _doBind = function (obj, evt, fn, children) { + if (fn == null) return; + _each(obj, function () { + var _el = _gel(this); + if (_smartClicks && evt === "click") + SmartClickHandler(_el, evt, fn, children); + else if (evt === "tap" || evt === "dbltap" || evt === "contextmenu") { + tapHandler(_el, evt, fn, children); + } + else if (evt === "mouseenter" || evt == "mouseexit") + mouseEnterExitHandler(_el, evt, fn, children); + else + DefaultHandler(_el, evt, fn, children); + }); + }; + + /** + * Removes an element from the DOM, and deregisters all event handlers for it. You should use this + * to ensure you don't leak memory. + * @method remove + * @param {String|Element} el Element, or id of the element, to remove. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.remove = function (el) { + _each(el, function () { + var _el = _gel(this); + if (_el.__ta) { + for (var evt in _el.__ta) { + for (var h in _el.__ta[evt]) { + _unbind(_el, evt, _el.__ta[evt][h]); + } + } + } + _el.parentNode && _el.parentNode.removeChild(_el); + }); + return this; + }; + + /** + * Register an event handler, optionally as a delegate for some set of descendant elements. Note + * that this method takes either 3 or 4 arguments - if you supply 3 arguments it is assumed you have + * omitted the `children` parameter, and that the event handler should be bound directly to the given element. + * @method on + * @param {Element[]|Element|String} el Either an Element, or a CSS spec for a list of elements, or an array of Elements. + * @param {String} [children] Comma-delimited list of selectors identifying allowed children. + * @param {String} event Event ID. + * @param {Function} fn Event handler function. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.on = function (el, event, children, fn) { + var _el = arguments[0], + _c = arguments.length == 4 ? arguments[2] : null, + _e = arguments[1], + _f = arguments[arguments.length - 1]; + + _doBind(_el, _e, _f, _c); + return this; + }; + + /** + * Cancel delegate event handling for the given function. Note that unlike with 'on' you do not supply + * a list of child selectors here: it removes event delegation from all of the child selectors for which the + * given function was registered (if any). + * @method off + * @param {Element[]|Element|String} el Element - or ID of element - from which to remove event listener. + * @param {String} event Event ID. + * @param {Function} fn Event handler function. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.off = function (el, event, fn) { + _unbind(el, event, fn); + return this; + }; + + /** + * Triggers some event for a given element. + * @method trigger + * @param {Element} el Element for which to trigger the event. + * @param {String} event Event ID. + * @param {Event} originalEvent The original event. Should be optional of course, but currently is not, due + * to the jsPlumb use case that caused this method to be added. + * @param {Object} [payload] Optional object to set as `payload` on the generated event; useful for message passing. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.trigger = function (el, event, originalEvent, payload) { + // MouseEvent undefined in old IE; that's how we know it's a mouse event. A fine Microsoft paradox. + var originalIsMouse = isMouseDevice && (typeof MouseEvent === "undefined" || originalEvent == null || originalEvent.constructor === MouseEvent); + + var eventToBind = (isTouchDevice && !isMouseDevice && touchMap[event]) ? touchMap[event] : event, + bindingAMouseEvent = !(isTouchDevice && !isMouseDevice && touchMap[event]); + + var pl = _pageLocation(originalEvent), sl = _screenLocation(originalEvent), cl = _clientLocation(originalEvent); + _each(el, function () { + var _el = _gel(this), evt; + originalEvent = originalEvent || { + screenX: sl[0], + screenY: sl[1], + clientX: cl[0], + clientY: cl[1] + }; + + var _decorate = function (_evt) { + if (payload) _evt.payload = payload; + }; + + var eventGenerators = { + "TouchEvent": function (evt) { + var touch = document.createTouch(window, _el, 0, pl[0], pl[1], + sl[0], sl[1], + cl[0], cl[1], + 0, 0, 0, 0); + + // https://gist.github.com/sstephenson/448808 + var touches = document.createTouchList(touch); + var targetTouches = document.createTouchList(touch); + var changedTouches = document.createTouchList(touch); + evt.initTouchEvent(eventToBind, true, true, window, null, sl[0], sl[1], + cl[0], cl[1], false, false, false, false, + touches, targetTouches, changedTouches, 1, 0); + }, + "MouseEvents": function (evt) { + evt.initMouseEvent(eventToBind, true, true, window, 0, + sl[0], sl[1], + cl[0], cl[1], + false, false, false, false, 1, _el); + + if (Sniff.android) { + // Android's touch events are not standard. + var t = document.createTouch(window, _el, 0, pl[0], pl[1], + sl[0], sl[1], + cl[0], cl[1], + 0, 0, 0, 0); + + evt.touches = evt.targetTouches = evt.changedTouches = document.createTouchList(t); + } + } + }; + + if (document.createEvent) { + + var ite = !bindingAMouseEvent && !originalIsMouse && (isTouchDevice && touchMap[event] && !Sniff.android), + evtName = ite ? "TouchEvent" : "MouseEvents"; + + evt = document.createEvent(evtName); + eventGenerators[evtName](evt); + _decorate(evt); + _el.dispatchEvent(evt); + } + else if (document.createEventObject) { + evt = document.createEventObject(); + evt.eventType = evt.eventName = eventToBind; + evt.screenX = sl[0]; + evt.screenY = sl[1]; + evt.clientX = cl[0]; + evt.clientY = cl[1]; + _decorate(evt); + _el.fireEvent('on' + eventToBind, evt); + } + }); + return this; + } + }; + + /** + * Static method to assist in 'consuming' an element: uses `stopPropagation` where available, or sets `e.returnValue=false` where it is not. + * @method Mottle.consume + * @param {Event} e Event to consume + * @param {Boolean} [doNotPreventDefault=false] If true, does not call `preventDefault()` on the event. + */ + Mottle.consume = function (e, doNotPreventDefault) { + if (e.stopPropagation) + e.stopPropagation(); + else + e.returnValue = false; + + if (!doNotPreventDefault && e.preventDefault) + e.preventDefault(); + }; + + /** + * Gets the page location corresponding to the given event. For touch events this means get the page location of the first touch. + * @method Mottle.pageLocation + * @param {Event} e Event to get page location for. + * @return {Integer[]} [left, top] for the given event. + */ + Mottle.pageLocation = _pageLocation; + + /** + * Forces touch events to be turned "on". Useful for testing: even if you don't have a touch device, you can still + * trigger a touch event when this is switched on and it will be captured and acted on. + * @method setForceTouchEvents + * @param {Boolean} value If true, force touch events to be on. + */ + Mottle.setForceTouchEvents = function (value) { + isTouchDevice = value; + }; + + /** + * Forces mouse events to be turned "on". Useful for testing: even if you don't have a mouse, you can still + * trigger a mouse event when this is switched on and it will be captured and acted on. + * @method setForceMouseEvents + * @param {Boolean} value If true, force mouse events to be on. + */ + Mottle.setForceMouseEvents = function (value) { + isMouseDevice = value; + }; + +}).call(this); + +/** + drag/drop functionality for use with jsPlumb but with + no knowledge of jsPlumb. supports multiple scopes (separated by whitespace), dragging + multiple elements, constrain to parent, drop filters, drag start filters, custom + css classes. + + a lot of the functionality of this script is expected to be plugged in: + + addClass + removeClass + + addEvent + removeEvent + + getPosition + setPosition + getSize + + indexOf + intersects + + the name came from here: + + http://mrsharpoblunto.github.io/foswig.js/ + + copyright 2015 jsPlumb + */ + +;(function() { + + "use strict"; + + var getOffsetRect = function (elem) { + // (1) + var box = elem.getBoundingClientRect(); + + var body = document.body; + var docElem = document.documentElement; + + // (2) + var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop; + var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft; + + // (3) + var clientTop = docElem.clientTop || body.clientTop || 0; + var clientLeft = docElem.clientLeft || body.clientLeft || 0; + + // (4) + var top = box.top + scrollTop - clientTop; + var left = box.left + scrollLeft - clientLeft; + + return { top: Math.round(top), left: Math.round(left) }; + }; + + var matchesSelector = function(el, selector, ctx) { + ctx = ctx || el.parentNode; + var possibles = ctx.querySelectorAll(selector); + for (var i = 0; i < possibles.length; i++) { + if (possibles[i] === el) + return true; + } + return false; + }; + + var iev = (function() { + var rv = -1; + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent, + re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv; + })(), + DEFAULT_GRID_X = 50, + DEFAULT_GRID_Y = 50, + isIELT9 = iev > -1 && iev < 9, + _pl = function(e) { + if (isIELT9) { + return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ]; + } + else { + var ts = _touches(e), t = _getTouch(ts, 0); + // this is for iPad. may not fly for Android. + return [t.pageX, t.pageY]; + } + }, + _getTouch = function(touches, idx) { return touches.item ? touches.item(idx) : touches[idx]; }, + _touches = function(e) { + return e.touches && e.touches.length > 0 ? e.touches : + e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches : + e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches : + [ e ]; + }, + _classes = { + draggable:"katavorio-draggable", // draggable elements + droppable:"katavorio-droppable", // droppable elements + drag : "katavorio-drag", // elements currently being dragged + selected:"katavorio-drag-selected", // elements in current drag selection + active : "katavorio-drag-active", // droppables that are targets of a currently dragged element + hover : "katavorio-drag-hover", // droppables over which a matching drag element is hovering + noSelect : "katavorio-drag-no-select" // added to the body to provide a hook to suppress text selection + }, + _defaultScope = "katavorio-drag-scope", + _events = [ "stop", "start", "drag", "drop", "over", "out" ], + _devNull = function() {}, + _true = function() { return true; }, + _foreach = function(l, fn, from) { + for (var i = 0; i < l.length; i++) { + if (l[i] != from) + fn(l[i]); + } + }, + _setDroppablesActive = function(dd, val, andHover, drag) { + _foreach(dd, function(e) { + e.setActive(val); + if (val) e.updatePosition(); + if (andHover) e.setHover(drag, val); + }); + }, + _each = function(obj, fn) { + if (obj == null) return; + obj = (typeof obj !== "string") && (obj.tagName == null && obj.length != null) ? obj : [ obj ]; + for (var i = 0; i < obj.length; i++) + fn.apply(obj[i], [ obj[i] ]); + }, + _consume = function(e) { + if (e.stopPropagation) { + e.stopPropagation(); + e.preventDefault(); + } + else { + e.returnValue = false; + } + }, + _defaultInputFilterSelector = "input,textarea,select,button,option", + // + // filters out events on all input elements, like textarea, checkbox, input, select. + _inputFilter = function(e, el, _katavorio) { + var t = e.srcElement || e.target; + return !matchesSelector(t, _katavorio.getInputFilterSelector(), el); + }; + + var Super = function(el, params, css, scope) { + this.params = params || {}; + this.el = el; + this.params.addClass(this.el, this._class); + this.uuid = _uuid(); + var enabled = true; + this.setEnabled = function(e) { enabled = e; }; + this.isEnabled = function() { return enabled; }; + this.toggleEnabled = function() { enabled = !enabled; }; + this.setScope = function(scopes) { + this.scopes = scopes ? scopes.split(/\s+/) : [ scope ]; + }; + this.addScope = function(scopes) { + var m = {}; + _each(this.scopes, function(s) { m[s] = true;}); + _each(scopes ? scopes.split(/\s+/) : [], function(s) { m[s] = true;}); + this.scopes = []; + for (var i in m) this.scopes.push(i); + }; + this.removeScope = function(scopes) { + var m = {}; + _each(this.scopes, function(s) { m[s] = true;}); + _each(scopes ? scopes.split(/\s+/) : [], function(s) { delete m[s];}); + this.scopes = []; + for (var i in m) this.scopes.push(i); + }; + this.toggleScope = function(scopes) { + var m = {}; + _each(this.scopes, function(s) { m[s] = true;}); + _each(scopes ? scopes.split(/\s+/) : [], function(s) { + if (m[s]) delete m[s]; + else m[s] = true; + }); + this.scopes = []; + for (var i in m) this.scopes.push(i); + }; + this.setScope(params.scope); + this.k = params.katavorio; + return params.katavorio; + }; + + var Drag = function(el, params, css, scope) { + this._class = css.draggable; + var k = Super.apply(this, arguments); + this.rightButtonCanDrag = this.params.rightButtonCanDrag; + var downAt = [0,0], posAtDown = null, moving = false, + consumeStartEvent = this.params.consumeStartEvent !== false, + dragEl = this.el, + clone = this.params.clone, + scroll = this.params.scroll, + _multipleDrop = params.multipleDrop !== false; + + var snapThreshold = params.snapThreshold || 5, + _snap = function(pos, x, y, thresholdX, thresholdY) { + thresholdX = thresholdX || snapThreshold; + thresholdY = thresholdY || snapThreshold; + var _dx = Math.floor(pos[0] / x), + _dxl = x * _dx, + _dxt = _dxl + x, + _x = Math.abs(pos[0] - _dxl) <= thresholdX ? _dxl : Math.abs(_dxt - pos[0]) <= thresholdX ? _dxt : pos[0]; + + var _dy = Math.floor(pos[1] / y), + _dyl = y * _dy, + _dyt = _dyl + y, + _y = Math.abs(pos[1] - _dyl) <= thresholdY ? _dyl : Math.abs(_dyt - pos[1]) <= thresholdY ? _dyt : pos[1]; + + return [ _x, _y]; + }; + + this.toGrid = function(pos) { + if (this.params.grid == null) { + return pos; + } + else { + return _snap(pos, this.params.grid[0], this.params.grid[1]); + } + }; + + this.snap = function(x, y) { + if (dragEl == null) return; + x = x || (this.params.grid ? this.params.grid[0] : DEFAULT_GRID_X); + y = y || (this.params.grid ? this.params.grid[1] : DEFAULT_GRID_Y); + var p = this.params.getPosition(dragEl); + this.params.setPosition(dragEl, _snap(p, x, y, x, y)); + }; + + this.constrain = typeof this.params.constrain === "function" ? this.params.constrain : (this.params.constrain || this.params.containment) ? function(pos) { + return [ + Math.max(0, Math.min(constrainRect.w - this.size[0], pos[0])), + Math.max(0, Math.min(constrainRect.h - this.size[1], pos[1])) + ]; + } : function(pos) { return pos; }; + + var _assignId = function(obj) { + if (typeof obj == "function") { + obj._katavorioId = _uuid(); + return obj._katavorioId; + } else { + return obj; + } + }, + // a map of { spec -> [ fn, exclusion ] } entries. + _filters = {}, + _testFilter = function(e) { + for (var key in _filters) { + var f = _filters[key]; + var rv = f[0](e); + if (f[1]) rv = !rv; + if (!rv) return false; + } + return true; + }, + _setFilter = this.setFilter = function(f, _exclude) { + if (f) { + var key = _assignId(f); + _filters[key] = [ + function(e) { + var t = e.srcElement || e.target, m; + if (typeof f === "string") { + m = matchesSelector(t, f, el); + } + else if (typeof f === "function") { + m = f(e, el); + } + return m; + }, + _exclude !== false + ]; + + } + }, + _addFilter = this.addFilter = _setFilter, + _removeFilter = this.removeFilter = function(f) { + var key = typeof f == "function" ? f._katavorioId : f; + delete _filters[key]; + }; + + this.clearAllFilters = function() { + _filters = {}; + }; + + this.canDrag = this.params.canDrag || _true; + + var constrainRect, + matchingDroppables = [], intersectingDroppables = []; + + this.downListener = function(e) { + var isNotRightClick = this.rightButtonCanDrag || (e.which !== 3 && e.button !== 2); + if (isNotRightClick && this.isEnabled() && this.canDrag()) { + var _f = _testFilter(e) && _inputFilter(e, this.el, this.k); + if (_f) { + if (!clone) + dragEl = this.el; + else { + dragEl = this.el.cloneNode(true); + dragEl.setAttribute("id", null); + dragEl.style.position = "absolute"; + // the clone node is added to the body; getOffsetRect gives us a value + // relative to the body. + var b = getOffsetRect(this.el); + dragEl.style.left = b.left + "px"; + dragEl.style.top = b.top + "px"; + document.body.appendChild(dragEl); + } + consumeStartEvent && _consume(e); + downAt = _pl(e); + // + this.params.bind(document, "mousemove", this.moveListener); + this.params.bind(document, "mouseup", this.upListener); + k.markSelection(this); + this.params.addClass(document.body, css.noSelect); + } + else if (this.params.consumeFilteredEvents) { + _consume(e); + } + } + }.bind(this); + + this.moveListener = function(e) { + if (downAt) { + if (!moving) { + var _continue = this.params.events["start"]({el:this.el, pos:posAtDown, e:e, drag:this}); + if (_continue !== false) { + if (!downAt) return; + this.mark(true); + moving = true; + } + } + + // it is possible that the start event caused the drag to be aborted. So we check + // again that we are currently dragging. + if (downAt) { + intersectingDroppables.length = 0; + var pos = _pl(e), dx = pos[0] - downAt[0], dy = pos[1] - downAt[1], + z = this.params.ignoreZoom ? 1 : k.getZoom(); + dx /= z; + dy /= z; + this.moveBy(dx, dy, e); + k.updateSelection(dx, dy, this); + } + } + }.bind(this); + + this.upListener = function(e) { + if (downAt) { + downAt = null; + this.params.unbind(document, "mousemove", this.moveListener); + this.params.unbind(document, "mouseup", this.upListener); + this.params.removeClass(document.body, css.noSelect); + this.unmark(e); + k.unmarkSelection(this, e); + this.stop(e); + k.notifySelectionDragStop(this, e); + moving = false; + if (clone) { + dragEl && dragEl.parentNode && dragEl.parentNode.removeChild(dragEl); + dragEl = null; + } + } + }.bind(this); + + this.getFilters = function() { return _filters; }; + + this.abort = function() { + if (downAt != null) + this.upListener(); + }; + + this.getDragElement = function() { + return dragEl || this.el; + }; + + this.notifyStart = function(e) { + this.params.events["start"]({el:this.el, pos:this.params.getPosition(dragEl), e:e, drag:this}); + }; + + this.stop = function(e, force) { + if (force || moving) { + var positions = [], + sel = k.getSelection(), + dPos = this.params.getPosition(dragEl); + + if (sel.length > 1) { + for (var i = 0; i < sel.length; i++) { + var p = this.params.getPosition(sel[i].el); + positions.push([ sel[i].el, { left: p[0], top: p[1] }, sel[i] ]); + } + } + else { + positions.push([ dragEl, {left:dPos[0], top:dPos[1]}, this ]); + } + + this.params.events["stop"]({ + el: dragEl, pos: dPos, e: e, drag: this, selection:positions + }); + } + }; + + this.mark = function(andNotify) { + posAtDown = this.params.getPosition(dragEl); + this.size = this.params.getSize(dragEl); + matchingDroppables = k.getMatchingDroppables(this); + _setDroppablesActive(matchingDroppables, true, false, this); + this.params.addClass(dragEl, this.params.dragClass || css.drag); + if (this.params.constrain || this.params.containment) { + var cs = this.params.getSize(dragEl.parentNode); + constrainRect = { w:cs[0], h:cs[1] }; + } + if (andNotify) { + k.notifySelectionDragStart(this); + } + }; + this.unmark = function(e) { + _setDroppablesActive(matchingDroppables, false, true, this); + this.params.removeClass(dragEl, this.params.dragClass || css.drag); + matchingDroppables.length = 0; + for (var i = 0; i < intersectingDroppables.length; i++) { + var retVal = intersectingDroppables[i].drop(this, e); + if (retVal === true) break; + } + }; + this.moveBy = function(dx, dy, e) { + intersectingDroppables.length = 0; + var cPos = this.constrain(this.toGrid(([posAtDown[0] + dx, posAtDown[1] + dy])), dragEl), + rect = { x:cPos[0], y:cPos[1], w:this.size[0], h:this.size[1]}; + this.params.setPosition(dragEl, cPos); + for (var i = 0; i < matchingDroppables.length; i++) { + var r2 = { x:matchingDroppables[i].position[0], y:matchingDroppables[i].position[1], w:matchingDroppables[i].size[0], h:matchingDroppables[i].size[1]}; + //if (this.params.intersects(rect, r2) && matchingDroppables[i].canDrop(this) && (_multipleDrop || intersectingDroppables.length == 0)) { + if (this.params.intersects(rect, r2) && matchingDroppables[i].canDrop(this)) { + intersectingDroppables.push(matchingDroppables[i]); + matchingDroppables[i].setHover(this, true, e); + } + else if (matchingDroppables[i].isHover()) { + matchingDroppables[i].setHover(this, false, e); + } + } + this.params.events["drag"]({el:this.el, pos:cPos, e:e, drag:this}); + + /* test to see if the parent needs to be scrolled + if (scroll) { + var pnsl = dragEl.parentNode.scrollLeft, pnst = dragEl.parentNode.scrollTop; + console.log("scroll!", pnsl, pnst); + }*/ + }; + this.destroy = function() { + this.params.unbind(this.el, "mousedown", this.downListener); + this.params.unbind(document, "mousemove", this.moveListener); + this.params.unbind(document, "mouseup", this.upListener); + this.downListener = null; + this.upListener = null; + this.moveListener = null; + //this.params = null; + //this.el = null; + //dragEl = null; + }; + + // init:register mousedown, and perhaps set a filter + this.params.bind(this.el, "mousedown", this.downListener); + + // if handle provded, use that. otherwise, try to set a filter. + // note that a `handle` selector always results in filterExclude being set to false, ie. + // the selector defines the handle element(s). + if (this.params.handle) + _setFilter(this.params.handle, false); + else + _setFilter(this.params.filter, this.params.filterExclude); + }; + + var Drop = function(el, params, css, scope) { + this._class = css.droppable; + this.params = params || {}; + this._activeClass = params.activeClass || css.active; + this._hoverClass = params.hoverClass || css.hover; + Super.apply(this, arguments); + var hover = false; + + this.setActive = function(val) { + this.params[val ? "addClass" : "removeClass"](this.el, this._activeClass); + }; + + this.updatePosition = function() { + this.position = this.params.getPosition(this.el); + this.size = this.params.getSize(this.el); + }; + + this.canDrop = this.params.canDrop || function(drag) { + return true; + }; + + this.isHover = function() { return hover; }; + + this.setHover = function(drag, val, e) { + // if turning off hover but this was not the drag that caused the hover, ignore. + if (val || this.el._katavorioDragHover == null || this.el._katavorioDragHover == drag.el._katavorio) { + this.params[val ? "addClass" : "removeClass"](this.el, this._hoverClass); + //this.el._katavorioDragHover = val ? drag.el._katavorio : null; + this.el._katavorioDragHover = val ? drag.el._katavorio : null; + if (hover !== val) + this.params.events[val ? "over" : "out"]({el:this.el, e:e, drag:drag, drop:this}); + hover = val; + } + }; + + this.drop = function(drag, event) { + return this.params.events["drop"]({ drag:drag, e:event, drop:this }); + }; + + this.destroy = function() { + this._class = null; + this._activeClass = null; + this._hoverClass = null; + //this.params = null; + hover = null; + //this.el = null; + }; + }; + + var _uuid = function() { + return ('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + })); + }; + + var _gel = function(el) { + if (el == null) return null; + el = typeof el === "string" ? document.getElementById(el) : el; + if (el == null) return null; + el._katavorio = el._katavorio || _uuid(); + return el; + }; + + this.Katavorio = function(katavorioParams) { + + var _selection = [], + _selectionMap = {}; + this._dragsByScope = {}; + this._dropsByScope = {}; + var _zoom = 1, + _reg = function(obj, map) { + for(var i = 0; i < obj.scopes.length; i++) { + map[obj.scopes[i]] = map[obj.scopes[i]] || []; + map[obj.scopes[i]].push(obj); + } + }, + _unreg = function(obj, map) { + var c = 0; + for(var i = 0; i < obj.scopes.length; i++) { + if (map[obj.scopes[i]]) { + var idx = katavorioParams.indexOf(map[obj.scopes[i]], obj); + if (idx != -1) { + map[obj.scopes[i]].splice(idx, 1); + c++; + } + } + } + return c > 0 ; + }, + _getMatchingDroppables = this.getMatchingDroppables = function(drag) { + var dd = [], _m = {}; + for (var i = 0; i < drag.scopes.length; i++) { + var _dd = this._dropsByScope[drag.scopes[i]]; + if (_dd) { + for (var j = 0; j < _dd.length; j++) { + //if (_dd[j].canDrop(drag) && !_m[_dd[j].el._katavorio] && _dd[j].el !== drag.el) { + if (_dd[j].canDrop(drag) && !_m[_dd[j].uuid] && _dd[j].el !== drag.el) { + _m[_dd[j].uuid] = true; + dd.push(_dd[j]); + } + } + } + } + return dd; + }, + _prepareParams = function(p) { + p = p || {}; + var _p = { + events:{} + }; + for (var i in katavorioParams) _p[i] = katavorioParams[i]; + for (var i in p) _p[i] = p[i]; + // events + + for (var i = 0; i < _events.length; i++) { + _p.events[_events[i]] = p[_events[i]] || _devNull; + } + _p.katavorio = this; + return _p; + }.bind(this), + _css = {}, + overrideCss = katavorioParams.css || {}, + _scope = katavorioParams.scope || _defaultScope; + + // prepare map of css classes based on defaults frst, then optional overrides + for (var i in _classes) _css[i] = _classes[i]; + for (var i in overrideCss) _css[i] = overrideCss[i]; + + var inputFilterSelector = katavorioParams.inputFilterSelector || _defaultInputFilterSelector; + /** + * Gets the selector identifying which input elements to filter from drag events. + * @method getInputFilterSelector + * @return {String} Current input filter selector. + */ + this.getInputFilterSelector = function() { return inputFilterSelector; }; + + /** + * Sets the selector identifying which input elements to filter from drag events. + * @method setInputFilterSelector + * @param {String} selector Input filter selector to set. + * @return {Katavorio} Current instance; method may be chained. + */ + this.setInputFilterSelector = function(selector) { + inputFilterSelector = selector; + return this; + }; + + this.draggable = function(el, params) { + var o = []; + _each(el, function(_el) { + _el = _gel(_el); + if (_el != null) { + var p = _prepareParams(params); + _el._katavorioDrag = new Drag(_el, p, _css, _scope); + _reg(_el._katavorioDrag, this._dragsByScope); + o.push(_el._katavorioDrag); + katavorioParams.addClass(_el, _css.draggable); + } + }.bind(this)); + return o; + + }; + + this.droppable = function(el, params) { + var o = []; + _each(el, function(_el) { + _el = _gel(_el); + if (_el != null) { + _el._katavorioDrop = new Drop(_el, _prepareParams(params), _css, _scope); + _reg(_el._katavorioDrop, this._dropsByScope); + o.push(_el._katavorioDrop); + katavorioParams.addClass(_el, _css.droppable); + } + }.bind(this)); + return o; + }; + + /** + * @name Katavorio#select + * @function + * @desc Adds an element to the current selection (for multiple node drag) + * @param {Element|String} DOM element - or id of the element - to add. + */ + this.select = function(el) { + _each(el, function() { + var _el = _gel(this); + if (_el && _el._katavorioDrag) { + if (!_selectionMap[_el._katavorio]) { + _selection.push(_el._katavorioDrag); + _selectionMap[_el._katavorio] = [ _el, _selection.length - 1 ]; + katavorioParams.addClass(_el, _css.selected); + } + } + }); + return this; + }; + + /** + * @name Katavorio#deselect + * @function + * @desc Removes an element from the current selection (for multiple node drag) + * @param {Element|String} DOM element - or id of the element - to remove. + */ + this.deselect = function(el) { + _each(el, function() { + var _el = _gel(this); + if (_el && _el._katavorio) { + var e = _selectionMap[_el._katavorio]; + if (e) { + var _s = []; + for (var i = 0; i < _selection.length; i++) + if (_selection[i].el !== _el) _s.push(_selection[i]); + _selection = _s; + delete _selectionMap[_el._katavorio]; + katavorioParams.removeClass(_el, _css.selected); + } + } + }); + return this; + }; + + this.deselectAll = function() { + for (var i in _selectionMap) { + var d = _selectionMap[i]; + katavorioParams.removeClass(d[0], _css.selected); + } + + _selection.length = 0; + _selectionMap = {}; + }; + + this.markSelection = function(drag) { + _foreach(_selection, function(e) { e.mark(); }, drag); + }; + + this.unmarkSelection = function(drag, event) { + _foreach(_selection, function(e) { e.unmark(event); }, drag); + }; + + this.getSelection = function() { return _selection.slice(0); }; + + this.updateSelection = function(dx, dy, drag) { + _foreach(_selection, function(e) { e.moveBy(dx, dy); }, drag); + }; + + this.notifySelectionDragStop = function(drag, evt) { + _foreach(_selection, function(e) { e.stop(evt, true); }, drag); + }; + + this.notifySelectionDragStart = function(drag, evt) { + _foreach(_selection, function(e) { e.notifyStart(evt);}, drag); + }; + + this.setZoom = function(z) { _zoom = z; }; + this.getZoom = function() { return _zoom; }; + + // does the work of changing scopes + var _scopeManip = function(kObj, scopes, map, fn) { + if (kObj != null) { + _unreg(kObj, map); // deregister existing scopes + kObj[fn](scopes); // set scopes + _reg(kObj, map); // register new ones + } + }; + + _each([ "set", "add", "remove", "toggle"], function(v) { + this[v + "Scope"] = function(el, scopes) { + _scopeManip(el._katavorioDrag, scopes, this._dragsByScope, v + "Scope"); + _scopeManip(el._katavorioDrop, scopes, this._dropsByScope, v + "Scope"); + }.bind(this); + this[v + "DragScope"] = function(el, scopes) { + _scopeManip(el._katavorioDrag, scopes, this._dragsByScope, v + "Scope"); + }.bind(this); + this[v + "DropScope"] = function(el, scopes) { + _scopeManip(el._katavorioDrop, scopes, this._dropsByScope, v + "Scope"); + }.bind(this); + }.bind(this)); + + this.snapToGrid = function(x, y) { + for (var s in this._dragsByScope) { + _foreach(this._dragsByScope[s], function(d) { d.snap(x, y); }); + } + }; + + this.getDragsForScope = function(s) { return this._dragsByScope[s]; }; + this.getDropsForScope = function(s) { return this._dropsByScope[s]; }; + + var _destroy = function(el, type, map) { + el = _gel(el); + if (el[type]) { + if (_unreg(el[type], map)) + el[type].destroy(); + el[type] = null; + } + }; + + this.elementRemoved = function(el) { + this.destroyDraggable(el); + this.destroyDroppable(el); + }; + + this.destroyDraggable = function(el) { + _destroy(el, "_katavorioDrag", this._dragsByScope); + }; + + this.destroyDroppable = function(el) { + _destroy(el, "_katavorioDrop", this._dropsByScope); + }; + + this.reset = function() { + this._dragsByScope = {}; + this._dropsByScope = {}; + _selection = []; + _selectionMap = {}; + }; + }; +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains utility functions that run in both browsers and headless. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ + +; +(function () { + + var _isa = function (a) { + return Object.prototype.toString.call(a) === "[object Array]"; + }, + _isnum = function (n) { + return Object.prototype.toString.call(n) === "[object Number]"; + }, + _iss = function (s) { + return typeof s === "string"; + }, + _isb = function (s) { + return typeof s === "boolean"; + }, + _isnull = function (s) { + return s == null; + }, + _iso = function (o) { + return o == null ? false : Object.prototype.toString.call(o) === "[object Object]"; + }, + _isd = function (o) { + return Object.prototype.toString.call(o) === "[object Date]"; + }, + _isf = function (o) { + return Object.prototype.toString.call(o) === "[object Function]"; + }, + _ise = function (o) { + for (var i in o) { + if (o.hasOwnProperty(i)) return false; + } + return true; + }; + + var root = this; + var exports = root.jsPlumbUtil = { + isArray: _isa, + isString: _iss, + isBoolean: _isb, + isNull: _isnull, + isObject: _iso, + isDate: _isd, + isFunction: _isf, + isEmpty: _ise, + isNumber: _isnum, + clone: function (a) { + if (_iss(a)) return "" + a; + else if (_isb(a)) return !!a; + else if (_isd(a)) return new Date(a.getTime()); + else if (_isf(a)) return a; + else if (_isa(a)) { + var b = []; + for (var i = 0; i < a.length; i++) + b.push(this.clone(a[i])); + return b; + } + else if (_iso(a)) { + var c = {}; + for (var j in a) + c[j] = this.clone(a[j]); + return c; + } + else return a; + }, + merge: function (a, b, collations) { + // first change the collations array - if present - into a lookup table, because its faster. + var cMap = {}, ar, i; + collations = collations || []; + for (i = 0; i < collations.length; i++) + cMap[collations[i]] = true; + + var c = this.clone(a); + for (i in b) { + if (c[i] == null) { + c[i] = b[i]; + } + else if (_iss(b[i]) || _isb(b[i])) { + if (!cMap[i]) { + c[i] = b[i]; // if we dont want to collate, just copy it in. + } + else { + ar = []; + // if c's object is also an array we can keep its values. + ar.push.apply(ar, _isa(c[i]) ? c[i] : [ c[i] ]); + ar.push.apply(ar, _isa(b[i]) ? b[i] : [ b[i] ]); + c[i] = ar; + } + } + else { + if (_isa(b[i])) { + ar = []; + // if c's object is also an array we can keep its values. + if (_isa(c[i])) ar.push.apply(ar, c[i]); + ar.push.apply(ar, b[i]); + c[i] = ar; + } + else if (_iso(b[i])) { + // overwite c's value with an object if it is not already one. + if (!_iso(c[i])) + c[i] = {}; + for (var j in b[i]) { + c[i][j] = b[i][j]; + } + } + } + + } + return c; + }, + replace: function (inObj, path, value) { + if (inObj == null) return; + var q = inObj, t = q; + path.replace(/([^\.])+/g, function (term, lc, pos, str) { + var array = term.match(/([^\[0-9]+){1}(\[)([0-9+])/), + last = pos + term.length >= str.length, + _getArray = function () { + return t[array[1]] || (function () { + t[array[1]] = []; + return t[array[1]]; + })(); + }; + + if (last) { + // set term = value on current t, creating term as array if necessary. + if (array) + _getArray()[array[3]] = value; + else + t[term] = value; + } + else { + // set to current t[term], creating t[term] if necessary. + if (array) { + var a = _getArray(); + t = a[array[3]] || (function () { + a[array[3]] = {}; + return a[array[3]]; + })(); + } + else + t = t[term] || (function () { + t[term] = {}; + return t[term]; + })(); + } + }); + + return inObj; + }, + // + // chain a list of functions, supplied by [ object, method name, args ], and return on the first + // one that returns the failValue. if none return the failValue, return the successValue. + // + functionChain: function (successValue, failValue, fns) { + for (var i = 0; i < fns.length; i++) { + var o = fns[i][0][fns[i][1]].apply(fns[i][0], fns[i][2]); + if (o === failValue) { + return o; + } + } + return successValue; + }, + // take the given model and expand out any parameters. + populate: function (model, values) { + // for a string, see if it has parameter matches, and if so, try to make the substitutions. + var getValue = function (fromString) { + var matches = fromString.match(/(\${.*?})/g); + if (matches != null) { + for (var i = 0; i < matches.length; i++) { + var val = values[matches[i].substring(2, matches[i].length - 1)] || ""; + if (val != null) { + fromString = fromString.replace(matches[i], val); + } + } + } + return fromString; + }, + // process one entry. + _one = function (d) { + if (d != null) { + if (_iss(d)) { + return getValue(d); + } + else if (_isa(d)) { + var r = []; + for (var i = 0; i < d.length; i++) + r.push(_one(d[i])); + return r; + } + else if (_iso(d)) { + var s = {}; + for (var j in d) { + s[j] = _one(d[j]); + } + return s; + } + else { + return d; + } + } + }; + + return _one(model); + }, + convertStyle: function (s, ignoreAlpha) { + // TODO: jsPlumb should support a separate 'opacity' style member. + if ("transparent" === s) return s; + var o = s, + pad = function (n) { + return n.length == 1 ? "0" + n : n; + }, + hex = function (k) { + return pad(Number(k).toString(16)); + }, + pattern = /(rgb[a]?\()(.*)(\))/; + if (s.match(pattern)) { + var parts = s.match(pattern)[2].split(","); + o = "#" + hex(parts[0]) + hex(parts[1]) + hex(parts[2]); + if (!ignoreAlpha && parts.length == 4) + o = o + hex(parts[3]); + } + return o; + }, + findWithFunction: function (a, f) { + if (a) + for (var i = 0; i < a.length; i++) if (f(a[i])) return i; + return -1; + }, + indexOf: function (l, v) { + return l.indexOf ? l.indexOf(v) : exports.findWithFunction(l, function (_v) { + return _v == v; + }); + }, + removeWithFunction: function (a, f) { + var idx = exports.findWithFunction(a, f); + if (idx > -1) a.splice(idx, 1); + return idx != -1; + }, + remove: function (l, v) { + var idx = exports.indexOf(l, v); + if (idx > -1) l.splice(idx, 1); + return idx != -1; + }, + // TODO support insert index + addWithFunction: function (list, item, hashFunction) { + if (exports.findWithFunction(list, hashFunction) == -1) list.push(item); + }, + addToList: function (map, key, value, insertAtStart) { + var l = map[key]; + if (l == null) { + l = []; + map[key] = l; + } + l[insertAtStart ? "unshift" : "push"](value); + return l; + }, + // + // extends the given obj (which can be an array) with the given constructor function, prototype functions, and + // class members, any of which may be null. + // + extend: function (child, parent, _protoFn) { + var i; + parent = _isa(parent) ? parent : [ parent ]; + + for (i = 0; i < parent.length; i++) { + for (var j in parent[i].prototype) { + if (parent[i].prototype.hasOwnProperty(j)) { + child.prototype[j] = parent[i].prototype[j]; + } + } + } + + var _makeFn = function (name, protoFn) { + return function () { + for (i = 0; i < parent.length; i++) { + if (parent[i].prototype[name]) + parent[i].prototype[name].apply(this, arguments); + } + return protoFn.apply(this, arguments); + }; + }; + + var _oneSet = function (fns) { + for (var k in fns) { + child.prototype[k] = _makeFn(k, fns[k]); + } + }; + + if (arguments.length > 2) { + for (i = 2; i < arguments.length; i++) + _oneSet(arguments[i]); + } + + return child; + }, + uuid: function () { + return ('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + })); + }, + logEnabled: true, + log: function () { + if (exports.logEnabled && typeof console != "undefined") { + try { + var msg = arguments[arguments.length - 1]; + console.log(msg); + } + catch (e) { + } + } + }, + + /** + * Wraps one function with another, creating a placeholder for the + * wrapped function if it was null. this is used to wrap the various + * drag/drop event functions - to allow jsPlumb to be notified of + * important lifecycle events without imposing itself on the user's + * drag/drop functionality. + * @method jsPlumbUtil.wrap + * @param {Function} wrappedFunction original function to wrap; may be null. + * @param {Function} newFunction function to wrap the original with. + * @param {Object} [returnOnThisValue] Optional. Indicates that the wrappedFunction should + * not be executed if the newFunction returns a value matching 'returnOnThisValue'. + * note that this is a simple comparison and only works for primitives right now. + */ + wrap: function (wrappedFunction, newFunction, returnOnThisValue) { + wrappedFunction = wrappedFunction || function () { + }; + newFunction = newFunction || function () { + }; + return function () { + var r = null; + try { + r = newFunction.apply(this, arguments); + } catch (e) { + exports.log("jsPlumb function failed : " + e); + } + if (returnOnThisValue == null || (r !== returnOnThisValue)) { + try { + r = wrappedFunction.apply(this, arguments); + } catch (e) { + exports.log("wrapped function failed : " + e); + } + } + return r; + }; + } + }; + + exports.EventGenerator = function () { + var _listeners = {}, + eventsSuspended = false, + // this is a list of events that should re-throw any errors that occur during their dispatch. it is current private. + eventsToDieOn = { "ready": true }; + + this.bind = function (event, listener, insertAtStart) { + var _one = function(evt) { + exports.addToList(_listeners, evt, listener, insertAtStart); + listener.__jsPlumb = listener.__jsPlumb || {}; + listener.__jsPlumb[jsPlumbUtil.uuid()] = evt; + }; + + if (typeof event === "string") _one(event); + else if (event.length != null) { + for (var i = 0; i < event.length; i++) { + _one(event[i]); + } + } + + return this; + }; + + this.fire = function (event, value, originalEvent) { + if (!eventsSuspended && _listeners[event]) { + var l = _listeners[event].length, i = 0, _gone = false, ret = null; + if (!this.shouldFireEvent || this.shouldFireEvent(event, value, originalEvent)) { + while (!_gone && i < l && ret !== false) { + // doing it this way rather than catching and then possibly re-throwing means that an error propagated by this + // method will have the whole call stack available in the debugger. + if (eventsToDieOn[event]) + _listeners[event][i].apply(this, [ value, originalEvent]); + else { + try { + ret = _listeners[event][i].apply(this, [ value, originalEvent ]); + } catch (e) { + exports.log("jsPlumb: fire failed for event " + event + " : " + e); + } + } + i++; + if (_listeners == null || _listeners[event] == null) + _gone = true; + } + } + } + return this; + }; + + this.unbind = function (eventOrListener, listener) { + + if (arguments.length === 0) { + _listeners = {}; + } + else if (arguments.length === 1) { + if (typeof eventOrListener === "string") + delete _listeners[eventOrListener]; + else if (eventOrListener.__jsPlumb) { + var evt; + for (var i in eventOrListener.__jsPlumb) { + evt = eventOrListener.__jsPlumb[i]; + exports.remove(_listeners[evt] || [], eventOrListener); + } + } + } + else if (arguments.length === 2) { + exports.remove(_listeners[eventOrListener] || [], listener); + } + + return this; + }; + + this.getListener = function (forEvent) { + return _listeners[forEvent]; + }; + this.setSuspendEvents = function (val) { + eventsSuspended = val; + }; + this.isSuspendEvents = function () { + return eventsSuspended; + }; + this.silently = function(fn) { + this.setSuspendEvents(true); + try { + fn(); + } + catch (e) { + jsPlumbUtil.log("Cannot execute silent function " + e); + } + this.setSuspendEvents(false); + }; + this.cleanupListeners = function () { + for (var i in _listeners) { + _listeners[i] = null; + } + }; + }; + + exports.EventGenerator.prototype = { + cleanup: function () { + this.cleanupListeners(); + } + }; + + // thanks MDC + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fbind + if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () { + }, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; + } + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains utility functions that run in browsers only. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ + ;(function() { + + "use strict"; + + var root = this; + var exports = root.jsPlumbUtil; + + exports.ieVersion = /MSIE\s([\d.]+)/.test(navigator.userAgent) ? (new Number(RegExp.$1)) : -1; + + exports.oldIE = exports.ieVersion > -1 && exports.ieVersion < 9; + + exports.matchesSelector = function(el, selector, ctx) { + ctx = ctx || el.parentNode; + var possibles = ctx.querySelectorAll(selector); + for (var i = 0; i < possibles.length; i++) { + if (possibles[i] === el) + return true; + } + return false; + }; + + exports.consume = function(e, doNotPreventDefault) { + if (e.stopPropagation) + e.stopPropagation(); + else + e.returnValue = false; + + if (!doNotPreventDefault && e.preventDefault) + e.preventDefault(); + }; + + /* + * Function: sizeElement + * Helper to size and position an element. You would typically use + * this when writing your own Connector or Endpoint implementation. + * + * Parameters: + * x - [int] x position for the element origin + * y - [int] y position for the element origin + * w - [int] width of the element + * h - [int] height of the element + * + */ + exports.sizeElement = function(el, x, y, w, h) { + if (el) { + el.style.height = h + "px"; + el.height = h; + el.style.width = w + "px"; + el.width = w; + el.style.left = x + "px"; + el.style.top = y + "px"; + } + }; + + + }).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the core code. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +(function () { + + "use strict"; + + var root = this; + var connectorTypes = [], rendererTypes; + + var _ju = root.jsPlumbUtil, + _getOffset = function (el, _instance, relativeToRoot) { + return _instance.getOffset(el, relativeToRoot); + }, + + /** + * creates a timestamp, using milliseconds since 1970, but as a string. + */ + _timestamp = function () { + return "" + (new Date()).getTime(); + }, + + // helper method to update the hover style whenever it, or paintStyle, changes. + // we use paintStyle as the foundation and merge hoverPaintStyle over the + // top. + _updateHoverStyle = function (component) { + if (component._jsPlumb.paintStyle && component._jsPlumb.hoverPaintStyle) { + var mergedHoverStyle = {}; + jsPlumb.extend(mergedHoverStyle, component._jsPlumb.paintStyle); + jsPlumb.extend(mergedHoverStyle, component._jsPlumb.hoverPaintStyle); + delete component._jsPlumb.hoverPaintStyle; + // we want the fillStyle of paintStyle to override a gradient, if possible. + if (mergedHoverStyle.gradient && component._jsPlumb.paintStyle.fillStyle) + delete mergedHoverStyle.gradient; + component._jsPlumb.hoverPaintStyle = mergedHoverStyle; + } + }, + events = ["tap", "dbltap", "click", "dblclick", "mouseover", "mouseout", "mousemove", "mousedown", "mouseup", "contextmenu" ], + eventFilters = { "mouseout": "mouseleave", "mouseexit": "mouseleave" }, + _updateAttachedElements = function (component, state, timestamp, sourceElement) { + var affectedElements = component.getAttachedElements(); + if (affectedElements) { + for (var i = 0, j = affectedElements.length; i < j; i++) { + if (!sourceElement || sourceElement != affectedElements[i]) + affectedElements[i].setHover(state, true, timestamp); // tell the attached elements not to inform their own attached elements. + } + } + }, + _splitType = function (t) { + return t == null ? null : t.split(" "); + }, + _mapType = function(map, obj, typeId) { + for (var i in obj) + map[i] = typeId; + }, + _applyTypes = function (component, params, doNotRepaint) { + if (component.getDefaultType) { + var td = component.getTypeDescriptor(), map = {}; + var defType = component.getDefaultType(); + var o = _ju.merge({}, defType); + _mapType(map, defType, "__default"); + for (var i = 0, j = component._jsPlumb.types.length; i < j; i++) { + var tid = component._jsPlumb.types[i]; + if (tid !== "__default") { + var _t = component._jsPlumb.instance.getType(tid, td); + if (_t != null) { + o = _ju.merge(o, _t, [ "cssClass" ]); + _mapType(map, _t, tid); + } + } + } + + if (params) { + o = _ju.populate(o, params); + } + + component.applyType(o, doNotRepaint, map); + if (!doNotRepaint) component.repaint(); + } + }, + +// ------------------------------ BEGIN jsPlumbUIComponent -------------------------------------------- + + jsPlumbUIComponent = window.jsPlumbUIComponent = function (params) { + + jsPlumbUtil.EventGenerator.apply(this, arguments); + + var self = this, + a = arguments, + idPrefix = self.idPrefix, + id = idPrefix + (new Date()).getTime(); + + this._jsPlumb = { + instance: params._jsPlumb, + parameters: params.parameters || {}, + paintStyle: null, + hoverPaintStyle: null, + paintStyleInUse: null, + hover: false, + beforeDetach: params.beforeDetach, + beforeDrop: params.beforeDrop, + overlayPlacements: [], + hoverClass: params.hoverClass || params._jsPlumb.Defaults.HoverClass, + types: [], + typeCache:{} + }; + + this.cacheTypeItem = function(key, item, typeId) { + this._jsPlumb.typeCache[typeId] = this._jsPlumb.typeCache[typeId] || {}; + this._jsPlumb.typeCache[typeId][key] = item; + }; + this.getCachedTypeItem = function(key, typeId) { + return this._jsPlumb.typeCache[typeId] ? this._jsPlumb.typeCache[typeId][key] : null; + }; + + this.getId = function () { + return id; + }; + +// ----------------------------- default type -------------------------------------------- + + + var o = params.overlays || [], oo = {}; + if (this.defaultOverlayKeys) { + for (var i = 0; i < this.defaultOverlayKeys.length; i++) + Array.prototype.push.apply(o, this._jsPlumb.instance.Defaults[this.defaultOverlayKeys[i]] || []); + + for (i = 0; i < o.length; i++) { + // if a string, convert to object representation so that we can store the typeid on it. + // also assign an id. + var fo = jsPlumb.convertToFullOverlaySpec(o[i]); + oo[fo[1].id] = fo; + } + } + + var _defaultType = { + overlays:oo, + parameters: params.parameters || {}, + scope: params.scope || this._jsPlumb.instance.getDefaultScope() + }; + this.getDefaultType = function() { + return _defaultType; + }; + this.appendToDefaultType = function(obj) { + for (var i in obj) _defaultType[i] = obj[i]; + }; + +// ----------------------------- end default type -------------------------------------------- + + // all components can generate events + + if (params.events) { + for (i in params.events) + self.bind(i, params.events[i]); + } + + // all components get this clone function. + // TODO issue 116 showed a problem with this - it seems 'a' that is in + // the clone function's scope is shared by all invocations of it, the classic + // JS closure problem. for now, jsPlumb does a version of this inline where + // it used to call clone. but it would be nice to find some time to look + // further at this. + this.clone = function () { + var o = {};//new Object(); + this.constructor.apply(o, a); + return o; + }.bind(this); + + // user can supply a beforeDetach callback, which will be executed before a detach + // is performed; returning false prevents the detach. + this.isDetachAllowed = function (connection) { + var r = true; + if (this._jsPlumb.beforeDetach) { + try { + r = this._jsPlumb.beforeDetach(connection); + } + catch (e) { + _ju.log("jsPlumb: beforeDetach callback failed", e); + } + } + return r; + }; + + // user can supply a beforeDrop callback, which will be executed before a dropped + // connection is confirmed. user can return false to reject connection. + this.isDropAllowed = function (sourceId, targetId, scope, connection, dropEndpoint, source, target) { + var r = this._jsPlumb.instance.checkCondition("beforeDrop", { + sourceId: sourceId, + targetId: targetId, + scope: scope, + connection: connection, + dropEndpoint: dropEndpoint, + source: source, target: target + }); + if (this._jsPlumb.beforeDrop) { + try { + r = this._jsPlumb.beforeDrop({ + sourceId: sourceId, + targetId: targetId, + scope: scope, + connection: connection, + dropEndpoint: dropEndpoint, + source: source, target: target + }); + } + catch (e) { + _ju.log("jsPlumb: beforeDrop callback failed", e); + } + } + return r; + }; + + var boundListeners = [], + bindAListener = function (obj, type, fn) { + boundListeners.push([obj, type, fn]); + obj.bind(type, fn); + }, + domListeners = []; + + // sets the component associated with listener events. for instance, an overlay delegates + // its events back to a connector. but if the connector is swapped on the underlying connection, + // then this component must be changed. This is called by setConnector in the Connection class. + this.setListenerComponent = function (c) { + for (var i = 0; i < domListeners.length; i++) + domListeners[i][3] = c; + }; + + + }; + + var _removeTypeCssHelper = function (component, typeIndex) { + var typeId = component._jsPlumb.types[typeIndex], + type = component._jsPlumb.instance.getType(typeId, component.getTypeDescriptor()); + + if (type != null) { + + if (type.cssClass && component.canvas) + component._jsPlumb.instance.removeClass(component.canvas, type.cssClass); + } + }; + + jsPlumbUtil.extend(jsPlumbUIComponent, jsPlumbUtil.EventGenerator, { + + getParameter: function (name) { + return this._jsPlumb.parameters[name]; + }, + + setParameter: function (name, value) { + this._jsPlumb.parameters[name] = value; + }, + + getParameters: function () { + return this._jsPlumb.parameters; + }, + + setParameters: function (p) { + this._jsPlumb.parameters = p; + }, + + hasClass:function(clazz) { + return jsPlumb.hasClass(this.canvas, clazz); + }, + + addClass: function (clazz) { + jsPlumb.addClass(this.canvas, clazz); + }, + + removeClass: function (clazz) { + jsPlumb.removeClass(this.canvas, clazz); + }, + + updateClasses: function (classesToAdd, classesToRemove) { + jsPlumb.updateClasses(this.canvas, classesToAdd, classesToRemove); + }, + + setType: function (typeId, params, doNotRepaint) { + this.clearTypes(); + this._jsPlumb.types = _splitType(typeId) || []; + _applyTypes(this, params, doNotRepaint); + }, + + getType: function () { + return this._jsPlumb.types; + }, + + reapplyTypes: function (params, doNotRepaint) { + _applyTypes(this, params, doNotRepaint); + }, + + hasType: function (typeId) { + return jsPlumbUtil.indexOf(this._jsPlumb.types, typeId) != -1; + }, + + addType: function (typeId, params, doNotRepaint) { + var t = _splitType(typeId), _cont = false; + if (t != null) { + for (var i = 0, j = t.length; i < j; i++) { + if (!this.hasType(t[i])) { + this._jsPlumb.types.push(t[i]); + _cont = true; + } + } + if (_cont) _applyTypes(this, params, doNotRepaint); + } + }, + + removeType: function (typeId, doNotRepaint) { + var t = _splitType(typeId), _cont = false, _one = function (tt) { + var idx = _ju.indexOf(this._jsPlumb.types, tt); + if (idx != -1) { + // remove css class if necessary + _removeTypeCssHelper(this, idx); + this._jsPlumb.types.splice(idx, 1); + return true; + } + return false; + }.bind(this); + + if (t != null) { + for (var i = 0, j = t.length; i < j; i++) { + _cont = _one(t[i]) || _cont; + } + if (_cont) _applyTypes(this, null, doNotRepaint); + } + }, + clearTypes: function (doNotRepaint) { + var i = this._jsPlumb.types.length; + for (var j = 0; j < i; j++) { + _removeTypeCssHelper(this, 0); + this._jsPlumb.types.splice(0, 1); + } + _applyTypes(this, {}, doNotRepaint); + }, + + toggleType: function (typeId, params, doNotRepaint) { + var t = _splitType(typeId); + if (t != null) { + for (var i = 0, j = t.length; i < j; i++) { + var idx = jsPlumbUtil.indexOf(this._jsPlumb.types, t[i]); + if (idx != -1) { + _removeTypeCssHelper(this, idx); + this._jsPlumb.types.splice(idx, 1); + } + else + this._jsPlumb.types.push(t[i]); + } + + _applyTypes(this, params, doNotRepaint); + } + }, + applyType: function (t, doNotRepaint) { + this.setPaintStyle(t.paintStyle, doNotRepaint); + this.setHoverPaintStyle(t.hoverPaintStyle, doNotRepaint); + if (t.parameters) { + for (var i in t.parameters) + this.setParameter(i, t.parameters[i]); + } + this._jsPlumb.paintStyleInUse = this.getPaintStyle(); + }, + setPaintStyle: function (style, doNotRepaint) { +// this._jsPlumb.paintStyle = jsPlumb.extend({}, style); +// TODO figure out if we want components to clone paintStyle so as not to share it. + this._jsPlumb.paintStyle = style; + this._jsPlumb.paintStyleInUse = this._jsPlumb.paintStyle; + _updateHoverStyle(this); + if (!doNotRepaint) this.repaint(); + }, + getPaintStyle: function () { + return this._jsPlumb.paintStyle; + }, + setHoverPaintStyle: function (style, doNotRepaint) { + //this._jsPlumb.hoverPaintStyle = jsPlumb.extend({}, style); +// TODO figure out if we want components to clone paintStyle so as not to share it. + this._jsPlumb.hoverPaintStyle = style; + _updateHoverStyle(this); + if (!doNotRepaint) this.repaint(); + }, + getHoverPaintStyle: function () { + return this._jsPlumb.hoverPaintStyle; + }, + destroy: function (force) { + if (force || this.typeId == null) { + this.cleanupListeners(); // this is on EventGenerator + this.clone = null; + this._jsPlumb = null; + } + }, + + isHover: function () { + return this._jsPlumb.hover; + }, + + setHover: function (hover, ignoreAttachedElements, timestamp) { + // while dragging, we ignore these events. this keeps the UI from flashing and + // swishing and whatevering. + if (this._jsPlumb && !this._jsPlumb.instance.currentlyDragging && !this._jsPlumb.instance.isHoverSuspended()) { + + this._jsPlumb.hover = hover; + + if (this.canvas != null) { + if (this._jsPlumb.instance.hoverClass != null) { + var method = hover ? "addClass" : "removeClass"; + this._jsPlumb.instance[method](this.canvas, this._jsPlumb.instance.hoverClass); + } + if (this._jsPlumb.hoverClass != null) { + this._jsPlumb.instance[method](this.canvas, this._jsPlumb.hoverClass); + } + } + if (this._jsPlumb.hoverPaintStyle != null) { + this._jsPlumb.paintStyleInUse = hover ? this._jsPlumb.hoverPaintStyle : this._jsPlumb.paintStyle; + if (!this._jsPlumb.instance.isSuspendDrawing()) { + timestamp = timestamp || _timestamp(); + this.repaint({timestamp: timestamp, recalc: false}); + } + } + // get the list of other affected elements, if supported by this component. + // for a connection, its the endpoints. for an endpoint, its the connections! surprise. + if (this.getAttachedElements && !ignoreAttachedElements) + _updateAttachedElements(this, hover, _timestamp(), this); + } + } + }); + +// ------------------------------ END jsPlumbUIComponent -------------------------------------------- + + var _jsPlumbInstanceIndex = 0, + getInstanceIndex = function () { + var i = _jsPlumbInstanceIndex + 1; + _jsPlumbInstanceIndex++; + return i; + }; + + var jsPlumbInstance = window.jsPlumbInstance = function (_defaults) { + + this.Defaults = { + Anchor: "Bottom", + Anchors: [ null, null ], + ConnectionsDetachable: true, + ConnectionOverlays: [ ], + Connector: "Bezier", + Container: null, + DoNotThrowErrors: false, + DragOptions: { }, + DropOptions: { }, + Endpoint: "Dot", + EndpointOverlays: [ ], + Endpoints: [ null, null ], + EndpointStyle: { fillStyle: "#456" }, + EndpointStyles: [ null, null ], + EndpointHoverStyle: null, + EndpointHoverStyles: [ null, null ], + HoverPaintStyle: null, + LabelStyle: { color: "black" }, + LogEnabled: false, + Overlays: [ ], + MaxConnections: 1, + PaintStyle: { lineWidth: 4, strokeStyle: "#456" }, + ReattachConnections: false, + RenderMode: "svg", + Scope: "jsPlumb_DefaultScope" + }; + if (_defaults) jsPlumb.extend(this.Defaults, _defaults); + + this.logEnabled = this.Defaults.LogEnabled; + this._connectionTypes = {}; + this._endpointTypes = {}; + + jsPlumbUtil.EventGenerator.apply(this); + + var _currentInstance = this, + _instanceIndex = getInstanceIndex(), + _bb = _currentInstance.bind, + _initialDefaults = {}, + _zoom = 1, + _info = function (el) { + if (el == null) return null; + else if (el.nodeType == 3 || el.nodeType == 8) { + return { el:el, text:true }; + } + else { + var _el = _currentInstance.getElement(el); + return { el: _el, id: (jsPlumbUtil.isString(el) && _el == null) ? el : _getId(_el) }; + } + }; + + this.getInstanceIndex = function () { + return _instanceIndex; + }; + + this.setZoom = function (z, repaintEverything) { + if (!jsPlumbUtil.oldIE) { + _zoom = z; + _currentInstance.fire("zoom", _zoom); + if (repaintEverything) _currentInstance.repaintEverything(); + } + return !jsPlumbUtil.oldIE; + + }; + this.getZoom = function () { + return _zoom; + }; + + for (var i in this.Defaults) + _initialDefaults[i] = this.Defaults[i]; + + var _container, _containerDelegations = []; + this.unbindContainer = function() { + if (_container != null && _containerDelegations.length > 0) { + for (var i = 0; i < _containerDelegations.length; i++) { + _currentInstance.off(_container, _containerDelegations[i][0], _containerDelegations[i][1]); + } + } + }; + this.setContainer = function (c) { + + this.unbindContainer(); + + // get container as dom element. + c = this.getElement(c); + // move existing connections and endpoints, if any. + this.select().each(function (conn) { + conn.moveParent(c); + }); + this.selectEndpoints().each(function (ep) { + ep.moveParent(c); + }); + + // set container. + _container = c; + _containerDelegations.length = 0; + + var _oneDelegateHandler = function (id, e) { + var t = e.srcElement || e.target, + jp = (t && t.parentNode ? t.parentNode._jsPlumb : null) || (t ? t._jsPlumb : null) || (t && t.parentNode && t.parentNode.parentNode ? t.parentNode.parentNode._jsPlumb : null); + if (jp) { + jp.fire(id, jp, e); + // jsplumb also fires every event coming from components/overlays. That's what the test for `jp.component` is for. + _currentInstance.fire(id, jp.component || jp, e); + } + }; + + var _addOneDelegate = function(eventId, selector, fn) { + _containerDelegations.push([eventId, fn]); + _currentInstance.on(_container, eventId, selector, fn); + }; + + // delegate one event on the container to jsplumb elements. it might be possible to + // abstract this out: each of endpoint, connection and overlay could register themselves with + // jsplumb as "component types" or whatever, and provide a suitable selector. this would be + // done by the renderer (although admittedly from 2.0 onwards we're not supporting vml anymore) + var _oneDelegate = function (id) { + // connections. + //_addOneDelegate(id, "._jsPlumb_connector, ._jsPlumb_connector > *", function (e) { + _addOneDelegate(id, "._jsPlumb_connector > *", function (e) { + _oneDelegateHandler(id, e); + }); + // endpoints. note they can have an enclosing div, or not. + _addOneDelegate(id, "._jsPlumb_endpoint, ._jsPlumb_endpoint > *, ._jsPlumb_endpoint svg *", function (e) { + _oneDelegateHandler(id, e); + }); + // overlays + _addOneDelegate(id, "._jsPlumb_overlay, ._jsPlumb_overlay *", function (e) { + _oneDelegateHandler(id, e); + }); + }; + + for (var i = 0; i < events.length; i++) + _oneDelegate(events[i]); + + }; + this.getContainer = function () { + return _container; + }; + + this.bind = function (event, fn) { + if ("ready" === event && initialized) fn(); + else _bb.apply(_currentInstance, [event, fn]); + }; + + _currentInstance.importDefaults = function (d) { + for (var i in d) { + _currentInstance.Defaults[i] = d[i]; + } + if (d.Container) + _currentInstance.setContainer(d.Container); + + return _currentInstance; + }; + + _currentInstance.restoreDefaults = function () { + _currentInstance.Defaults = jsPlumb.extend({}, _initialDefaults); + return _currentInstance; + }; + + var log = null, + initialized = false, + // TODO remove from window scope + connections = [], + // map of element id -> endpoint lists. an element can have an arbitrary + // number of endpoints on it, and not all of them have to be connected + // to anything. + endpointsByElement = {}, + endpointsByUUID = {}, + managedElements = {}, + offsets = {}, + offsetTimestamps = {}, + draggableStates = {}, + connectionBeingDragged = false, + sizes = [], + _suspendDrawing = false, + _suspendedAt = null, + DEFAULT_SCOPE = this.Defaults.Scope, + renderMode = null, // will be set in init() + _curIdStamp = 1, + _idstamp = function () { + return "" + _curIdStamp++; + }, + + // + // appends an element to some other element, which is calculated as follows: + // + // 1. if Container exists, use that element. + // 2. if the 'parent' parameter exists, use that. + // 3. otherwise just use the root element. + // + // + _appendElement = function (el, parent) { + if (_container) + _container.appendChild(el); + else if (!parent) + this.appendToRoot(el); + else + this.getElement(parent).appendChild(el); + }.bind(this), + + // + // Draws an endpoint and its connections. this is the main entry point into drawing connections as well + // as endpoints, since jsPlumb is endpoint-centric under the hood. + // + // @param element element to draw (of type library specific element object) + // @param ui UI object from current library's event system. optional. + // @param timestamp timestamp for this paint cycle. used to speed things up a little by cutting down the amount of offset calculations we do. + // @param clearEdits defaults to false; indicates that mouse edits for connectors should be cleared + /// + _draw = function (element, ui, timestamp, clearEdits) { + + // TODO is it correct to filter by headless at this top level? how would a headless adapter ever repaint? + // NO. it is not correct. + if (!jsPlumb.headless && !_suspendDrawing) { + var id = _getId(element), + repaintEls = _currentInstance.getDragManager().getElementsForDraggable(id); + + if (timestamp == null) timestamp = _timestamp(); + + // update the offset of everything _before_ we try to draw anything. + var o = _updateOffset({ elId: id, offset: ui, recalc: false, timestamp: timestamp }); + + if (repaintEls) { + for (var i in repaintEls) { + _updateOffset({ + elId: repaintEls[i].id, + offset: { + left: o.o.left + repaintEls[i].offset.left, + top: o.o.top + repaintEls[i].offset.top + }, + recalc: false, + timestamp: timestamp + }); + } + } + + _currentInstance.anchorManager.redraw(id, ui, timestamp, null, clearEdits); + + if (repaintEls) { + for (var j in repaintEls) { + _currentInstance.anchorManager.redraw(repaintEls[j].id, ui, timestamp, repaintEls[j].offset, clearEdits, true); + } + } + } + }, + + // + // gets an Endpoint by uuid. + // + _getEndpoint = function (uuid) { + return endpointsByUUID[uuid]; + }, + + /** + * inits a draggable if it's not already initialised. + * TODO: somehow abstract this to the adapter, because the concept of "draggable" has no + * place on the server. + */ + _initDraggableIfNecessary = function (element, isDraggable, dragOptions, id) { + // move to DragManager? + if (!jsPlumb.headless) { + var _draggable = isDraggable == null ? false : isDraggable; + if (_draggable) { + if (jsPlumb.isDragSupported(element, _currentInstance) && !jsPlumb.isAlreadyDraggable(element, _currentInstance)) { + var options = dragOptions || _currentInstance.Defaults.DragOptions; + options = jsPlumb.extend({}, options); // make a copy. + var dragEvent = jsPlumb.dragEvents.drag, + stopEvent = jsPlumb.dragEvents.stop, + startEvent = jsPlumb.dragEvents.start, + _del = _currentInstance.getElement(element), + _ancestor = _currentInstance.getDragManager().getDragAncestor(_del), + _noOffset = {left: 0, top: 0}, + _ancestorOffset = _noOffset, + _started = false; + + _manage(id, element); + + options[startEvent] = _ju.wrap(options[startEvent], function () { + _ancestorOffset = _ancestor != null ? _currentInstance.getOffset(_ancestor) : _noOffset; + _currentInstance.setHoverSuspended(true); + _currentInstance.select({source: element}).addClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true); + _currentInstance.select({target: element}).addClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true); + _currentInstance.setConnectionBeingDragged(true); + if (options.canDrag) return dragOptions.canDrag(); + }, false); + + options[dragEvent] = _ju.wrap(options[dragEvent], function () { + // TODO: here we could actually use getDragObject, and then compute it ourselves, + // since every adapter does the same thing. but i'm not sure why YUI's getDragObject + // differs from getUIPosition so much + var ui = _currentInstance.getUIPosition(arguments, _currentInstance.getZoom()); + // adjust by ancestor offset if there is one: this is for the case that a draggable + // is contained inside some other element that is not the Container. + ui.left += _ancestorOffset.left; + ui.top += _ancestorOffset.top; + _draw(element, ui, null, true); + if (_started) _currentInstance.addClass(element, "jsPlumb_dragged"); + _started = true; + }); + options[stopEvent] = _ju.wrap(options[stopEvent], function () { + var elements = []; + + // TODO once jquery is no longer supported, remove this, as we will know + // exactly what the method signature is. For now, we need to cater for the + // fact that jquery ui provides two args and katavorio provides only one. + if (arguments.length == 1 && arguments[0].selection && arguments[0].selection.length > 0) { + elements = arguments[0].selection; + } + else { + elements = [ [ element, _currentInstance.getUIPosition(arguments, _currentInstance.getZoom(), true) ] ]; + } + + // this is one element + var _one = function(_e) { + _draw(_e[0], _e[1]); + _currentInstance.removeClass(_e[0], "jsPlumb_dragged"); + _currentInstance.select({source: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true); + _currentInstance.select({target: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true); + _currentInstance.getDragManager().dragEnded(_e[0]); + }; + + for (var i = 0; i < elements.length; i++) + _one(elements[i]); + + // this is common across all + _started = false; + _currentInstance.setHoverSuspended(false); + _currentInstance.setConnectionBeingDragged(false); + }); + var elId = _getId(element); // need ID + draggableStates[elId] = true; + var draggable = draggableStates[elId]; + options.disabled = draggable == null ? false : !draggable; + _currentInstance.initDraggable(element, options); + _currentInstance.getDragManager().register(element); + } + } + } + }, + + _scopeMatch = function (e1, e2) { + var s1 = e1.scope.split(/\s/), s2 = e2.scope.split(/\s/); + for (var i = 0; i < s1.length; i++) + for (var j = 0; j < s2.length; j++) + if (s2[j] == s1[i]) return true; + + return false; + }, + + /* + * prepares a final params object that can be passed to _newConnection, taking into account defaults, events, etc. + */ + _prepareConnectionParams = function (params, referenceParams) { + var _p = jsPlumb.extend({ }, params); + if (referenceParams) jsPlumb.extend(_p, referenceParams); + + // hotwire endpoints passed as source or target to sourceEndpoint/targetEndpoint, respectively. + if (_p.source) { + if (_p.source.endpoint) + _p.sourceEndpoint = _p.source; + else + _p.source = _currentInstance.getElement(_p.source); + } + if (_p.target) { + if (_p.target.endpoint) + _p.targetEndpoint = _p.target; + else + _p.target = _currentInstance.getElement(_p.target); + } + + // test for endpoint uuids to connect + if (params.uuids) { + _p.sourceEndpoint = _getEndpoint(params.uuids[0]); + _p.targetEndpoint = _getEndpoint(params.uuids[1]); + } + + // now ensure that if we do have Endpoints already, they're not full. + // source: + if (_p.sourceEndpoint && _p.sourceEndpoint.isFull()) { + _ju.log(_currentInstance, "could not add connection; source endpoint is full"); + return; + } + + // target: + if (_p.targetEndpoint && _p.targetEndpoint.isFull()) { + _ju.log(_currentInstance, "could not add connection; target endpoint is full"); + return; + } + + // if source endpoint mandates connection type and nothing specified in our params, use it. + if (!_p.type && _p.sourceEndpoint) + _p.type = _p.sourceEndpoint.connectionType; + + // copy in any connectorOverlays that were specified on the source endpoint. + // it doesnt copy target endpoint overlays. i'm not sure if we want it to or not. + if (_p.sourceEndpoint && _p.sourceEndpoint.connectorOverlays) { + _p.overlays = _p.overlays || []; + for (var i = 0, j = _p.sourceEndpoint.connectorOverlays.length; i < j; i++) { + _p.overlays.push(_p.sourceEndpoint.connectorOverlays[i]); + } + } + + // pointer events + if (!_p["pointer-events"] && _p.sourceEndpoint && _p.sourceEndpoint.connectorPointerEvents) + _p["pointer-events"] = _p.sourceEndpoint.connectorPointerEvents; + + var _mergeOverrides = function (def, values) { + var m = jsPlumb.extend({}, def); + for (var i in values) { + if (values[i]) m[i] = values[i]; + } + return m; + }; + + var _addEndpoint = function (el, def, idx) { + return _currentInstance.addEndpoint(el, _mergeOverrides(def, { + anchor: _p.anchors ? _p.anchors[idx] : _p.anchor, + endpoint: _p.endpoints ? _p.endpoints[idx] : _p.endpoint, + paintStyle: _p.endpointStyles ? _p.endpointStyles[idx] : _p.endpointStyle, + hoverPaintStyle: _p.endpointHoverStyles ? _p.endpointHoverStyles[idx] : _p.endpointHoverStyle + })); + }; + + // check for makeSource/makeTarget specs. + + var _oneElementDef = function (type, idx, defs) { + if (_p[type] && !_p[type].endpoint && !_p[type + "Endpoint"] && !_p.newConnection) { + var tid = _getId(_p[type]), tep = defs[tid]; + + if (tep) { + // if not enabled, return. + if (!tep.enabled) return false; + var newEndpoint = tep.endpoint != null && tep.endpoint._jsPlumb ? tep.endpoint : _addEndpoint(_p[type], tep.def, idx); + if (newEndpoint.isFull()) return false; + _p[type + "Endpoint"] = newEndpoint; + newEndpoint._doNotDeleteOnDetach = false; // reset. + newEndpoint._deleteOnDetach = true; + if (tep.uniqueEndpoint) { + if (!tep.endpoint) { + tep.endpoint = newEndpoint; + newEndpoint._deleteOnDetach = false; + newEndpoint._doNotDeleteOnDetach = true; + } + else + newEndpoint.finalEndpoint = tep.endpoint; + } + } + } + }; + + if (_oneElementDef("source", 0, this.sourceEndpointDefinitions) === false) return; + if (_oneElementDef("target", 1, this.targetEndpointDefinitions) === false) return; + + // last, ensure scopes match + if (_p.sourceEndpoint && _p.targetEndpoint) + if (!_scopeMatch(_p.sourceEndpoint, _p.targetEndpoint)) _p = null; + + return _p; + }.bind(_currentInstance), + + _newConnection = function (params) { + var connectionFunc = _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(); + + params._jsPlumb = _currentInstance; + params.newConnection = _newConnection; + params.newEndpoint = _newEndpoint; + params.endpointsByUUID = endpointsByUUID; + params.endpointsByElement = endpointsByElement; + params.finaliseConnection = _finaliseConnection; + params.id = "con_" + _idstamp(); + var con = new connectionFunc(params); + + // if the connection is draggable, then maybe we need to tell the target endpoint to init the + // dragging code. it won't run again if it already configured to be draggable. + if (con.isDetachable()) { + con.endpoints[0].initDraggable("_jsPlumbSource"); + con.endpoints[1].initDraggable("_jsPlumbTarget"); + } + + return con; + }, + + // + // adds the connection to the backing model, fires an event if necessary and then redraws + // + _finaliseConnection = _currentInstance.finaliseConnection = function (jpc, params, originalEvent, doInformAnchorManager) { + params = params || {}; + // add to list of connections (by scope). + if (!jpc.suspendedEndpoint) + connections.push(jpc); + + // turn off isTemporarySource on the source endpoint (only viable on first draw) + jpc.endpoints[0].isTemporarySource = false; + + // always inform the anchor manager + // except that if jpc has a suspended endpoint it's not true to say the + // connection is new; it has just (possibly) moved. the question is whether + // to make that call here or in the anchor manager. i think perhaps here. + if (jpc.suspendedEndpoint == null || doInformAnchorManager) + _currentInstance.anchorManager.newConnection(jpc); + + // force a paint + _draw(jpc.source); + + // fire an event + if (!params.doNotFireConnectionEvent && params.fireEvent !== false) { + + var eventArgs = { + connection: jpc, + source: jpc.source, target: jpc.target, + sourceId: jpc.sourceId, targetId: jpc.targetId, + sourceEndpoint: jpc.endpoints[0], targetEndpoint: jpc.endpoints[1] + }; + + _currentInstance.fire("connection", eventArgs, originalEvent); + } + }, + + /* + factory method to prepare a new endpoint. this should always be used instead of creating Endpoints + manually, since this method attaches event listeners and an id. + */ + _newEndpoint = function (params, id) { + var endpointFunc = _currentInstance.Defaults.EndpointType || jsPlumb.Endpoint; + var _p = jsPlumb.extend({}, params); + _p._jsPlumb = _currentInstance; + _p.newConnection = _newConnection; + _p.newEndpoint = _newEndpoint; + _p.endpointsByUUID = endpointsByUUID; + _p.endpointsByElement = endpointsByElement; + _p.fireDetachEvent = fireDetachEvent; + _p.elementId = id || _getId(_p.source); + var ep = new endpointFunc(_p); + ep.id = "ep_" + _idstamp(); + _manage(_p.elementId, _p.source); + + if (!jsPlumb.headless) + _currentInstance.getDragManager().endpointAdded(_p.source, id); + + return ep; + }, + + /* + * performs the given function operation on all the connections found + * for the given element id; this means we find all the endpoints for + * the given element, and then for each endpoint find the connectors + * connected to it. then we pass each connection in to the given + * function. + */ + _operation = function (elId, func, endpointFunc) { + var endpoints = endpointsByElement[elId]; + if (endpoints && endpoints.length) { + for (var i = 0, ii = endpoints.length; i < ii; i++) { + for (var j = 0, jj = endpoints[i].connections.length; j < jj; j++) { + var retVal = func(endpoints[i].connections[j]); + // if the function passed in returns true, we exit. + // most functions return false. + if (retVal) return; + } + if (endpointFunc) endpointFunc(endpoints[i]); + } + } + }, + + _setDraggable = function (element, draggable) { + return jsPlumb.each(element, function (el) { + if (_currentInstance.isDragSupported(el)) { + draggableStates[_currentInstance.getAttribute(el, "id")] = draggable; + _currentInstance.setElementDraggable(el, draggable); + } + }); + }, + /* + * private method to do the business of hiding/showing. + * + * @param el + * either Id of the element in question or a library specific + * object for the element. + * @param state + * String specifying a value for the css 'display' property + * ('block' or 'none'). + */ + _setVisible = function (el, state, alsoChangeEndpoints) { + state = state === "block"; + var endpointFunc = null; + if (alsoChangeEndpoints) { + if (state) endpointFunc = function (ep) { + ep.setVisible(true, true, true); + }; + else endpointFunc = function (ep) { + ep.setVisible(false, true, true); + }; + } + var info = _info(el); + _operation(info.id, function (jpc) { + if (state && alsoChangeEndpoints) { + // this test is necessary because this functionality is new, and i wanted to maintain backwards compatibility. + // this block will only set a connection to be visible if the other endpoint in the connection is also visible. + var oidx = jpc.sourceId === info.id ? 1 : 0; + if (jpc.endpoints[oidx].isVisible()) jpc.setVisible(true); + } + else // the default behaviour for show, and what always happens for hide, is to just set the visibility without getting clever. + jpc.setVisible(state); + }, endpointFunc); + }, + /* + * toggles the draggable state of the given element(s). + * el is either an id, or an element object, or a list of ids/element objects. + */ + _toggleDraggable = function (el) { + return jsPlumb.each(el, function (el) { + var elId = _currentInstance.getAttribute(el, "id"); + var state = draggableStates[elId] == null ? false : draggableStates[elId]; + state = !state; + draggableStates[elId] = state; + _currentInstance.setDraggable(el, state); + return state; + }.bind(this)); + }, + /** + * private method to do the business of toggling hiding/showing. + */ + _toggleVisible = function (elId, changeEndpoints) { + var endpointFunc = null; + if (changeEndpoints) { + endpointFunc = function (ep) { + var state = ep.isVisible(); + ep.setVisible(!state); + }; + } + _operation(elId, function (jpc) { + var state = jpc.isVisible(); + jpc.setVisible(!state); + }, endpointFunc); + }, + + // TODO comparison performance + _getCachedData = function (elId) { + var o = offsets[elId]; + if (!o) + return _updateOffset({elId: elId}); + else + return {o: o, s: sizes[elId]}; + }, + + /** + * gets an id for the given element, creating and setting one if + * necessary. the id is of the form + * + * jsPlumb__ + * + * where "index in instance" is a monotonically increasing integer that starts at 0, + * for each instance. this method is used not only to assign ids to elements that do not + * have them but also to connections and endpoints. + */ + _getId = function (element, uuid, doNotCreateIfNotFound) { + if (jsPlumbUtil.isString(element)) return element; + if (element == null) return null; + var id = _currentInstance.getAttribute(element, "id"); + if (!id || id === "undefined") { + // check if fixed uuid parameter is given + if (arguments.length == 2 && arguments[1] !== undefined) + id = uuid; + else if (arguments.length == 1 || (arguments.length == 3 && !arguments[2])) + id = "jsPlumb_" + _instanceIndex + "_" + _idstamp(); + + if (!doNotCreateIfNotFound) _currentInstance.setAttribute(element, "id", id); + } + return id; + }; + + this.setConnectionBeingDragged = function (v) { + connectionBeingDragged = v; + }; + this.isConnectionBeingDragged = function () { + return connectionBeingDragged; + }; + + this.connectorClass = "_jsPlumb_connector"; + this.connectorOutlineClass = "_jsPlumb_connector_outline"; + this.connectedClass = "_jsPlumb_connected"; + this.hoverClass = "_jsPlumb_hover"; + this.endpointClass = "_jsPlumb_endpoint"; + this.endpointConnectedClass = "_jsPlumb_endpoint_connected"; + this.endpointFullClass = "_jsPlumb_endpoint_full"; + this.endpointDropAllowedClass = "_jsPlumb_endpoint_drop_allowed"; + this.endpointDropForbiddenClass = "_jsPlumb_endpoint_drop_forbidden"; + this.overlayClass = "_jsPlumb_overlay"; + this.draggingClass = "_jsPlumb_dragging"; + this.elementDraggingClass = "_jsPlumb_element_dragging"; + this.sourceElementDraggingClass = "_jsPlumb_source_element_dragging"; + this.targetElementDraggingClass = "_jsPlumb_target_element_dragging"; + this.endpointAnchorClassPrefix = "_jsPlumb_endpoint_anchor"; + this.hoverSourceClass = "_jsPlumb_source_hover"; + this.hoverTargetClass = "_jsPlumb_target_hover"; + this.dragSelectClass = "_jsPlumb_drag_select"; + + this.Anchors = {}; + this.Connectors = { "svg": {}, "vml": {} }; + this.Endpoints = { "svg": {}, "vml": {} }; + this.Overlays = { "svg": {}, "vml": {} } ; + this.ConnectorRenderers = {}; + this.SVG = "svg"; + this.VML = "vml"; + +// --------------------------- jsPlumbInstance public API --------------------------------------------------------- + + + this.addEndpoint = function (el, params, referenceParams) { + referenceParams = referenceParams || {}; + var p = jsPlumb.extend({}, referenceParams); + jsPlumb.extend(p, params); + p.endpoint = p.endpoint || _currentInstance.Defaults.Endpoint; + p.paintStyle = p.paintStyle || _currentInstance.Defaults.EndpointStyle; + + var results = [], + inputs = (_ju.isArray(el) || (el.length != null && !_ju.isString(el))) ? el : [ el ]; + + for (var i = 0, j = inputs.length; i < j; i++) { + p.source = _currentInstance.getElement(inputs[i]); + _ensureContainer(p.source); + + var id = _getId(p.source), e = _newEndpoint(p, id); + + // SP new. here we have introduced a class-wide element manager, which is responsible + // for getting object dimensions and width/height, and for updating these values only + // when necessary (after a drag, or on a forced refresh call). + var myOffset = _manage(id, p.source).info.o; + _ju.addToList(endpointsByElement, id, e); + + if (!_suspendDrawing) { + e.paint({ + anchorLoc: e.anchor.compute({ xy: [ myOffset.left, myOffset.top ], wh: sizes[id], element: e, timestamp: _suspendedAt }), + timestamp: _suspendedAt + }); + } + + results.push(e); + e._doNotDeleteOnDetach = true; // mark this as being added via addEndpoint. + } + + return results.length == 1 ? results[0] : results; + }; + + this.addEndpoints = function (el, endpoints, referenceParams) { + var results = []; + for (var i = 0, j = endpoints.length; i < j; i++) { + var e = _currentInstance.addEndpoint(el, endpoints[i], referenceParams); + if (_ju.isArray(e)) + Array.prototype.push.apply(results, e); + else results.push(e); + } + return results; + }; + + this.animate = function (el, properties, options) { + if (!this.animationSupported) return false; + + options = options || {}; + var del = _currentInstance.getElement(el), + id = _getId(del), + stepFunction = jsPlumb.animEvents.step, + completeFunction = jsPlumb.animEvents.complete; + + options[stepFunction] = _ju.wrap(options[stepFunction], function () { + _currentInstance.revalidate(id); + }); + + // onComplete repaints, just to make sure everything looks good at the end of the animation. + options[completeFunction] = _ju.wrap(options[completeFunction], function () { + _currentInstance.revalidate(id); + }); + + _currentInstance.doAnimate(del, properties, options); + }; + + /** + * checks for a listener for the given condition, executing it if found, passing in the given value. + * condition listeners would have been attached using "bind" (which is, you could argue, now overloaded, since + * firing click events etc is a bit different to what this does). i thought about adding a "bindCondition" + * or something, but decided against it, for the sake of simplicity. jsPlumb will never fire one of these + * condition events anyway. + */ + this.checkCondition = function (conditionName, args) { + var l = _currentInstance.getListener(conditionName), + r = true; + + if (l && l.length > 0) { + var values = Array.prototype.slice.call(arguments, 1); + try { + for (var i = 0, j = l.length; i < j; i++) { + r = r && l[i].apply(l[i], values); + } + } + catch (e) { + _ju.log(_currentInstance, "cannot check condition [" + conditionName + "]" + e); + } + } + return r; + }; + + this.connect = function (params, referenceParams) { + // prepare a final set of parameters to create connection with + var _p = _prepareConnectionParams(params, referenceParams), jpc; + // TODO probably a nicer return value if the connection was not made. _prepareConnectionParams + // will return null (and log something) if either endpoint was full. what would be nicer is to + // create a dedicated 'error' object. + if (_p) { + if (_p.source == null && _p.sourceEndpoint == null) { + jsPlumbUtil.log("Cannot establish connection - source does not exist"); + return; + } + if (_p.target == null && _p.targetEndpoint == null) { + jsPlumbUtil.log("Cannot establish connection - target does not exist"); + return; + } + _ensureContainer(_p.source); + // create the connection. it is not yet registered + jpc = _newConnection(_p); + // now add it the model, fire an event, and redraw + _finaliseConnection(jpc, _p); + } + return jpc; + }; + + var stTypes = [ + { el: "source", elId: "sourceId", epDefs: "sourceEndpointDefinitions" }, + { el: "target", elId: "targetId", epDefs: "targetEndpointDefinitions" } + ]; + + var _set = function (c, el, idx, doNotRepaint) { + var ep, _st = stTypes[idx], cId = c[_st.elId], cEl = c[_st.el], sid, sep, + oldEndpoint = c.endpoints[idx]; + + var evtParams = { + index: idx, + originalSourceId: idx === 0 ? cId : c.sourceId, + newSourceId: c.sourceId, + originalTargetId: idx == 1 ? cId : c.targetId, + newTargetId: c.targetId, + connection: c + }; + + if (el.constructor == jsPlumb.Endpoint) { // TODO here match the current endpoint class; users can change it { + ep = el; + ep.addConnection(c); + } + else { + sid = _getId(el); + sep = this[_st.epDefs][sid]; + + if (sid === c[_st.elId]) + ep = null; // dont change source/target if the element is already the one given. + else if (sep) { + if (!sep.enabled) return; + ep = sep.endpoint != null && sep.endpoint._jsPlumb ? sep.endpoint : this.addEndpoint(el, sep.def); + if (sep.uniqueEndpoint) sep.endpoint = ep; + ep._doNotDeleteOnDetach = false; + ep._deleteOnDetach = true; + ep.addConnection(c); + } + else { + ep = c.makeEndpoint(idx === 0, el, sid); + ep._doNotDeleteOnDetach = false; + ep._deleteOnDetach = true; + } + } + + if (ep != null) { + oldEndpoint.detachFromConnection(c); + c.endpoints[idx] = ep; + c[_st.el] = ep.element; + c[_st.elId] = ep.elementId; + evtParams[idx === 0 ? "newSourceId" : "newTargetId"] = ep.elementId; + + fireMoveEvent(evtParams); + + if (!doNotRepaint) + c.repaint(); + } + + return evtParams; + + }.bind(this); + + this.setSource = function (connection, el, doNotRepaint) { + var p = _set(connection, el, 0, doNotRepaint); + this.anchorManager.sourceChanged(p.originalSourceId, p.newSourceId, connection); + }; + this.setTarget = function (connection, el, doNotRepaint) { + var p = _set(connection, el, 1, doNotRepaint); + this.anchorManager.updateOtherEndpoint(p.originalSourceId, p.originalTargetId, p.newTargetId, connection); + }; + + this.deleteEndpoint = function (object, dontUpdateHover) { + var endpoint = (typeof object === "string") ? endpointsByUUID[object] : object; + if (endpoint) { + _currentInstance.deleteObject({ endpoint: endpoint, dontUpdateHover: dontUpdateHover }); + } + return _currentInstance; + }; + + this.deleteEveryEndpoint = function () { + var _is = _currentInstance.setSuspendDrawing(true); + for (var id in endpointsByElement) { + var endpoints = endpointsByElement[id]; + if (endpoints && endpoints.length) { + for (var i = 0, j = endpoints.length; i < j; i++) { + _currentInstance.deleteEndpoint(endpoints[i], true); + } + } + } + endpointsByElement = {}; + // SP new + managedElements = {}; + endpointsByUUID = {}; + offsets = {}; + offsetTimestamps = {}; + _currentInstance.anchorManager.reset(); + _currentInstance.getDragManager().reset(); + if (!_is) _currentInstance.setSuspendDrawing(false); + return _currentInstance; + }; + + var fireDetachEvent = function (jpc, doFireEvent, originalEvent) { + // may have been given a connection, or in special cases, an object + var connType = _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(), + argIsConnection = jpc.constructor == connType, + params = argIsConnection ? { + connection: jpc, + source: jpc.source, target: jpc.target, + sourceId: jpc.sourceId, targetId: jpc.targetId, + sourceEndpoint: jpc.endpoints[0], targetEndpoint: jpc.endpoints[1] + } : jpc; + + if (doFireEvent) + _currentInstance.fire("connectionDetached", params, originalEvent); + + _currentInstance.anchorManager.connectionDetached(params); + }; + + var fireMoveEvent = _currentInstance.fireMoveEvent = function (params, evt) { + _currentInstance.fire("connectionMoved", params, evt); + }; + + this.unregisterEndpoint = function (endpoint) { + //if (endpoint._jsPlumb == null) return; + if (endpoint._jsPlumb.uuid) endpointsByUUID[endpoint._jsPlumb.uuid] = null; + _currentInstance.anchorManager.deleteEndpoint(endpoint); + // TODO at least replace this with a removeWithFunction call. + for (var e in endpointsByElement) { + var endpoints = endpointsByElement[e]; + if (endpoints) { + var newEndpoints = []; + for (var i = 0, j = endpoints.length; i < j; i++) + if (endpoints[i] != endpoint) newEndpoints.push(endpoints[i]); + + endpointsByElement[e] = newEndpoints; + } + if (endpointsByElement[e].length < 1) { + delete endpointsByElement[e]; + } + } + }; + + this.detach = function () { + + if (arguments.length === 0) return; + var connType = _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(), + firstArgIsConnection = arguments[0].constructor == connType, + params = arguments.length == 2 ? firstArgIsConnection ? (arguments[1] || {}) : arguments[0] : arguments[0], + fireEvent = (params.fireEvent !== false), + forceDetach = params.forceDetach, + conn = firstArgIsConnection ? arguments[0] : params.connection; + + if (conn) { + if (forceDetach || jsPlumbUtil.functionChain(true, false, [ + [ conn.endpoints[0], "isDetachAllowed", [ conn ] ], + [ conn.endpoints[1], "isDetachAllowed", [ conn ] ], + [ conn, "isDetachAllowed", [ conn ] ], + [ _currentInstance, "checkCondition", [ "beforeDetach", conn ] ] + ])) { + + conn.endpoints[0].detach(conn, false, true, fireEvent); + } + } + else { + var _p = jsPlumb.extend({}, params); // a backwards compatibility hack: source should be thought of as 'params' in this case. + // test for endpoint uuids to detach + if (_p.uuids) { + _getEndpoint(_p.uuids[0]).detachFrom(_getEndpoint(_p.uuids[1]), fireEvent); + } else if (_p.sourceEndpoint && _p.targetEndpoint) { + _p.sourceEndpoint.detachFrom(_p.targetEndpoint); + } else { + var sourceId = _getId(_currentInstance.getElement(_p.source)), + targetId = _getId(_currentInstance.getElement(_p.target)); + _operation(sourceId, function (jpc) { + if ((jpc.sourceId == sourceId && jpc.targetId == targetId) || (jpc.targetId == sourceId && jpc.sourceId == targetId)) { + if (_currentInstance.checkCondition("beforeDetach", jpc)) { + jpc.endpoints[0].detach(jpc, false, true, fireEvent); + } + } + }); + } + } + }; + + this.detachAllConnections = function (el, params) { + params = params || {}; + el = _currentInstance.getElement(el); + var id = _getId(el), + endpoints = endpointsByElement[id]; + if (endpoints && endpoints.length) { + for (var i = 0, j = endpoints.length; i < j; i++) { + endpoints[i].detachAll(params.fireEvent !== false, params.forceDetach); + } + } + return _currentInstance; + }; + + this.detachEveryConnection = function (params) { + params = params || {}; + _currentInstance.batch(function () { + for (var id in endpointsByElement) { + var endpoints = endpointsByElement[id]; + if (endpoints && endpoints.length) { + for (var i = 0, j = endpoints.length; i < j; i++) { + endpoints[i].detachAll(params.fireEvent !== false, params.forceDetach); + } + } + } + connections.length = 0; + }); + return _currentInstance; + }; + + /// not public. but of course its exposed. how to change this. + this.deleteObject = function (params) { + var result = { + endpoints: {}, + connections: {}, + endpointCount: 0, + connectionCount: 0 + }, + fireEvent = params.fireEvent !== false, + deleteAttachedObjects = params.deleteAttachedObjects !== false; + + var unravelConnection = function (connection) { + if (connection != null && result.connections[connection.id] == null) { + if (!params.dontUpdateHover && connection._jsPlumb != null) connection.setHover(false); + result.connections[connection.id] = connection; + result.connectionCount++; + if (deleteAttachedObjects) { + for (var j = 0; j < connection.endpoints.length; j++) { + if (connection.endpoints[j]._deleteOnDetach) + unravelEndpoint(connection.endpoints[j]); + } + } + } + }; + var unravelEndpoint = function (endpoint) { + if (endpoint != null && result.endpoints[endpoint.id] == null) { + if (!params.dontUpdateHover && endpoint._jsPlumb != null) endpoint.setHover(false); + result.endpoints[endpoint.id] = endpoint; + result.endpointCount++; + + if (deleteAttachedObjects) { + for (var i = 0; i < endpoint.connections.length; i++) { + var c = endpoint.connections[i]; + unravelConnection(c); + } + } + } + }; + + if (params.connection) + unravelConnection(params.connection); + else unravelEndpoint(params.endpoint); + + // loop through connections + for (var i in result.connections) { + var c = result.connections[i]; + if (c._jsPlumb) { + jsPlumbUtil.removeWithFunction(connections, function (_c) { + return c.id == _c.id; + }); + fireDetachEvent(c, fireEvent, params.originalEvent); + + c.endpoints[0].detachFromConnection(c); + c.endpoints[1].detachFromConnection(c); + c.cleanup(true); + c.destroy(true); + } + } + + // loop through endpoints + for (var j in result.endpoints) { + var e = result.endpoints[j]; + if (e._jsPlumb) { + _currentInstance.unregisterEndpoint(e); + // FIRE some endpoint deleted event? + e.cleanup(true); + e.destroy(true); + } + } + + return result; + }; + + this.draggable = function (el, options) { + var i, j, info; + // allows for array or jquery selector + if (typeof el == 'object' && el.length) { + for (i = 0, j = el.length; i < j; i++) { + info = _info(el[i]); + if (info.el) _initDraggableIfNecessary(info.el, true, options, info.id); + } + } + else { + //ele = _currentInstance.getElement(el); + info = _info(el); + if (info.el) _initDraggableIfNecessary(info.el, true, options, info.id); + } + return _currentInstance; + }; + + // helpers for select/selectEndpoints + var _setOperation = function (list, func, args, selector) { + for (var i = 0, j = list.length; i < j; i++) { + list[i][func].apply(list[i], args); + } + return selector(list); + }, + _getOperation = function (list, func, args) { + var out = []; + for (var i = 0, j = list.length; i < j; i++) { + out.push([ list[i][func].apply(list[i], args), list[i] ]); + } + return out; + }, + setter = function (list, func, selector) { + return function () { + return _setOperation(list, func, arguments, selector); + }; + }, + getter = function (list, func) { + return function () { + return _getOperation(list, func, arguments); + }; + }, + prepareList = function (input, doNotGetIds) { + var r = []; + if (input) { + if (typeof input == 'string') { + if (input === "*") return input; + r.push(input); + } + else { + if (doNotGetIds) r = input; + else { + if (input.length) { + for (var i = 0, j = input.length; i < j; i++) + r.push(_info(input[i]).id); + } + else + r.push(_info(input).id); + } + } + } + return r; + }, + filterList = function (list, value, missingIsFalse) { + if (list === "*") return true; + return list.length > 0 ? jsPlumbUtil.indexOf(list, value) != -1 : !missingIsFalse; + }; + + // get some connections, specifying source/target/scope + this.getConnections = function (options, flat) { + if (!options) { + options = {}; + } else if (options.constructor == String) { + options = { "scope": options }; + } + var scope = options.scope || _currentInstance.getDefaultScope(), + scopes = prepareList(scope, true), + sources = prepareList(options.source), + targets = prepareList(options.target), + results = (!flat && scopes.length > 1) ? {} : [], + _addOne = function (scope, obj) { + if (!flat && scopes.length > 1) { + var ss = results[scope]; + if (ss == null) { + ss = results[scope] = []; + } + ss.push(obj); + } else results.push(obj); + }; + + for (var j = 0, jj = connections.length; j < jj; j++) { + var c = connections[j]; + if (filterList(scopes, c.scope) && filterList(sources, c.sourceId) && filterList(targets, c.targetId)) + _addOne(c.scope, c); + } + + return results; + }; + + var _curryEach = function (list, executor) { + return function (f) { + for (var i = 0, ii = list.length; i < ii; i++) { + f(list[i]); + } + return executor(list); + }; + }, + _curryGet = function (list) { + return function (idx) { + return list[idx]; + }; + }; + + var _makeCommonSelectHandler = function (list, executor) { + var out = { + length: list.length, + each: _curryEach(list, executor), + get: _curryGet(list) + }, + setters = ["setHover", "removeAllOverlays", "setLabel", "addClass", "addOverlay", "removeOverlay", + "removeOverlays", "showOverlay", "hideOverlay", "showOverlays", "hideOverlays", "setPaintStyle", + "setHoverPaintStyle", "setSuspendEvents", "setParameter", "setParameters", "setVisible", + "repaint", "addType", "toggleType", "removeType", "removeClass", "setType", "bind", "unbind" ], + + getters = ["getLabel", "getOverlay", "isHover", "getParameter", "getParameters", "getPaintStyle", + "getHoverPaintStyle", "isVisible", "hasType", "getType", "isSuspendEvents" ], + i, ii; + + for (i = 0, ii = setters.length; i < ii; i++) + out[setters[i]] = setter(list, setters[i], executor); + + for (i = 0, ii = getters.length; i < ii; i++) + out[getters[i]] = getter(list, getters[i]); + + return out; + }; + + var _makeConnectionSelectHandler = function (list) { + var common = _makeCommonSelectHandler(list, _makeConnectionSelectHandler); + return jsPlumb.extend(common, { + // setters + setDetachable: setter(list, "setDetachable", _makeConnectionSelectHandler), + setReattach: setter(list, "setReattach", _makeConnectionSelectHandler), + setConnector: setter(list, "setConnector", _makeConnectionSelectHandler), + detach: function () { + for (var i = 0, ii = list.length; i < ii; i++) + _currentInstance.detach(list[i]); + }, + // getters + isDetachable: getter(list, "isDetachable"), + isReattach: getter(list, "isReattach") + }); + }; + + var _makeEndpointSelectHandler = function (list) { + var common = _makeCommonSelectHandler(list, _makeEndpointSelectHandler); + return jsPlumb.extend(common, { + setEnabled: setter(list, "setEnabled", _makeEndpointSelectHandler), + setAnchor: setter(list, "setAnchor", _makeEndpointSelectHandler), + isEnabled: getter(list, "isEnabled"), + detachAll: function () { + for (var i = 0, ii = list.length; i < ii; i++) + list[i].detachAll(); + }, + "remove": function () { + for (var i = 0, ii = list.length; i < ii; i++) + _currentInstance.deleteObject({endpoint: list[i]}); + } + }); + }; + + this.select = function (params) { + params = params || {}; + params.scope = params.scope || "*"; + return _makeConnectionSelectHandler(params.connections || _currentInstance.getConnections(params, true)); + }; + + this.selectEndpoints = function (params) { + params = params || {}; + params.scope = params.scope || "*"; + var noElementFilters = !params.element && !params.source && !params.target, + elements = noElementFilters ? "*" : prepareList(params.element), + sources = noElementFilters ? "*" : prepareList(params.source), + targets = noElementFilters ? "*" : prepareList(params.target), + scopes = prepareList(params.scope, true); + + var ep = []; + + for (var el in endpointsByElement) { + var either = filterList(elements, el, true), + source = filterList(sources, el, true), + sourceMatchExact = sources != "*", + target = filterList(targets, el, true), + targetMatchExact = targets != "*"; + + // if they requested 'either' then just match scope. otherwise if they requested 'source' (not as a wildcard) then we have to match only endpoints that have isSource set to to true, and the same thing with isTarget. + if (either || source || target) { + inner: + for (var i = 0, ii = endpointsByElement[el].length; i < ii; i++) { + var _ep = endpointsByElement[el][i]; + if (filterList(scopes, _ep.scope, true)) { + + var noMatchSource = (sourceMatchExact && sources.length > 0 && !_ep.isSource), + noMatchTarget = (targetMatchExact && targets.length > 0 && !_ep.isTarget); + + if (noMatchSource || noMatchTarget) + continue inner; + + ep.push(_ep); + } + } + } + } + + return _makeEndpointSelectHandler(ep); + }; + + // get all connections managed by the instance of jsplumb. + this.getAllConnections = function () { + return connections; + }; + this.getDefaultScope = function () { + return DEFAULT_SCOPE; + }; + // get an endpoint by uuid. + this.getEndpoint = _getEndpoint; + // get endpoints for some element. + this.getEndpoints = function (el) { + return endpointsByElement[_info(el).id]; + }; + // gets the default endpoint type. used when subclassing. see wiki. + this.getDefaultEndpointType = function () { + return jsPlumb.Endpoint; + }; + // gets the default connection type. used when subclassing. see wiki. + this.getDefaultConnectionType = function () { + return jsPlumb.Connection; + }; + /* + * Gets an element's id, creating one if necessary. really only exposed + * for the lib-specific functionality to access; would be better to pass + * the current instance into the lib-specific code (even though this is + * a static call. i just don't want to expose it to the public API). + */ + this.getId = _getId; + + /*this.getOffset = function (id) { + return _updateOffset({elId: id}).o; + };*/ + + this.appendElement = _appendElement; + + var _hoverSuspended = false; + this.isHoverSuspended = function () { + return _hoverSuspended; + }; + this.setHoverSuspended = function (s) { + _hoverSuspended = s; + }; + + // set an element's connections to be hidden + this.hide = function (el, changeEndpoints) { + _setVisible(el, "none", changeEndpoints); + return _currentInstance; + }; + + // exposed for other objects to use to get a unique id. + this.idstamp = _idstamp; + + this.connectorsInitialized = false; + this.registerConnectorType = function (connector, name) { + connectorTypes.push([connector, name]); + }; + + // ensure that, if the current container exists, it is a DOM element and not a selector. + // if it does not exist and `candidate` is supplied, the offset parent of that element will be set as the Container. + // this is used to do a better default behaviour for the case that the user has not set a container: + // addEndpoint, makeSource, makeTarget and connect all call this method with the offsetParent of the + // element in question (for connect it is the source element). So if no container is set, it is inferred + // to be the offsetParent of the first element the user tries to connect. + var _ensureContainer = function (candidate) { + if (!_container && candidate) { + var can = _currentInstance.getElement(candidate); + if (can.offsetParent) _currentInstance.setContainer(can.offsetParent); + } + }; + + var _getContainerFromDefaults = function () { + if (_currentInstance.Defaults.Container) + _currentInstance.setContainer(_currentInstance.Defaults.Container); + }; + + // check if a given element is managed or not. if not, add to our map. if drawing is not suspended then + // we'll also stash its dimensions; otherwise we'll do this in a lazy way through updateOffset. + // TODO make sure we add a test that this tracks a setId call. + var _manage = _currentInstance.manage = function (id, element) { + if (!managedElements[id]) { + managedElements[id] = { + el: element, + endpoints: [], + connections: [] + }; + + managedElements[id].info = _updateOffset({ elId: id, timestamp: _suspendedAt }); + } + + return managedElements[id]; + }; + + /** + * updates the offset and size for a given element, and stores the + * values. if 'offset' is not null we use that (it would have been + * passed in from a drag call) because it's faster; but if it is null, + * or if 'recalc' is true in order to force a recalculation, we get the current values. + */ + var _updateOffset = this.updateOffset = function (params) { + + var timestamp = params.timestamp, recalc = params.recalc, offset = params.offset, elId = params.elId, s; + if (_suspendDrawing && !timestamp) timestamp = _suspendedAt; + if (!recalc) { + if (timestamp && timestamp === offsetTimestamps[elId]) { + return {o: params.offset || offsets[elId], s: sizes[elId]}; + } + } + if (recalc || (!offset && offsets[elId] == null)) { // if forced repaint or no offset available, we recalculate. + + // get the current size and offset, and store them + s = managedElements[elId] ? managedElements[elId].el : null; + if (s != null) { + sizes[elId] = _currentInstance.getSize(s); + offsets[elId] = _currentInstance.getOffset(s); + offsetTimestamps[elId] = timestamp; + } + } else { + offsets[elId] = offset || offsets[elId]; + if (sizes[elId] == null) { + s = managedElements[elId].el; + if (s != null) sizes[elId] = _currentInstance.getSize(s); + } + offsetTimestamps[elId] = timestamp; + } + + if (offsets[elId] && !offsets[elId].right) { + offsets[elId].right = offsets[elId].left + sizes[elId][0]; + offsets[elId].bottom = offsets[elId].top + sizes[elId][1]; + offsets[elId].width = sizes[elId][0]; + offsets[elId].height = sizes[elId][1]; + offsets[elId].centerx = offsets[elId].left + (offsets[elId].width / 2); + offsets[elId].centery = offsets[elId].top + (offsets[elId].height / 2); + } + + return {o: offsets[elId], s: sizes[elId]}; + }; + + /** + * callback from the current library to tell us to prepare ourselves (attach + * mouse listeners etc; can't do that until the library has provided a bind method) + */ + this.init = function () { + rendererTypes = jsPlumb.getRenderModes(); + + var _oneType = function (renderer, name, fn) { + jsPlumb.Connectors[renderer][name] = function () { + fn.apply(this, arguments); + jsPlumb.ConnectorRenderers[renderer].apply(this, arguments); + }; + jsPlumbUtil.extend(jsPlumb.Connectors[renderer][name], [ fn, jsPlumb.ConnectorRenderers[renderer]]); + }; + + if (!jsPlumb.connectorsInitialized) { + for (var i = 0; i < connectorTypes.length; i++) { + for (var j = 0; j < rendererTypes.length; j++) { + _oneType(rendererTypes[j], connectorTypes[i][1], connectorTypes[i][0]); + } + + } + jsPlumb.connectorsInitialized = true; + } + + if (!initialized) { + _getContainerFromDefaults(); + _currentInstance.anchorManager = new jsPlumb.AnchorManager({jsPlumbInstance: _currentInstance}); + _currentInstance.setRenderMode(_currentInstance.Defaults.RenderMode); // calling the method forces the capability logic to be run. + initialized = true; + _currentInstance.fire("ready", _currentInstance); + } + }.bind(this); + + this.log = log; + this.jsPlumbUIComponent = jsPlumbUIComponent; + + /* + * Creates an anchor with the given params. + * + * + * Returns: The newly created Anchor. + * Throws: an error if a named anchor was not found. + */ + this.makeAnchor = function () { + var pp, _a = function (t, p) { + if (jsPlumb.Anchors[t]) return new jsPlumb.Anchors[t](p); + if (!_currentInstance.Defaults.DoNotThrowErrors) + throw { msg: "jsPlumb: unknown anchor type '" + t + "'" }; + }; + if (arguments.length === 0) return null; + var specimen = arguments[0], elementId = arguments[1], jsPlumbInstance = arguments[2], newAnchor = null; + // if it appears to be an anchor already... + if (specimen.compute && specimen.getOrientation) return specimen; //TODO hazy here about whether it should be added or is already added somehow. + // is it the name of an anchor type? + else if (typeof specimen == "string") { + newAnchor = _a(arguments[0], {elementId: elementId, jsPlumbInstance: _currentInstance}); + } + // is it an array? it will be one of: + // an array of [spec, params] - this defines a single anchor, which may be dynamic, but has parameters. + // an array of arrays - this defines some dynamic anchors + // an array of numbers - this defines a single anchor. + else if (_ju.isArray(specimen)) { + if (_ju.isArray(specimen[0]) || _ju.isString(specimen[0])) { + // if [spec, params] format + if (specimen.length == 2 && _ju.isObject(specimen[1])) { + // if first arg is a string, its a named anchor with params + if (_ju.isString(specimen[0])) { + pp = jsPlumb.extend({elementId: elementId, jsPlumbInstance: _currentInstance}, specimen[1]); + newAnchor = _a(specimen[0], pp); + } + // otherwise first arg is array, second is params. we treat as a dynamic anchor, which is fine + // even if the first arg has only one entry. you could argue all anchors should be implicitly dynamic in fact. + else { + pp = jsPlumb.extend({elementId: elementId, jsPlumbInstance: _currentInstance, anchors: specimen[0]}, specimen[1]); + newAnchor = new jsPlumb.DynamicAnchor(pp); + } + } + else + newAnchor = new jsPlumb.DynamicAnchor({anchors: specimen, selector: null, elementId: elementId, jsPlumbInstance: _currentInstance}); + + } + else { + var anchorParams = { + x: specimen[0], y: specimen[1], + orientation: (specimen.length >= 4) ? [ specimen[2], specimen[3] ] : [0, 0], + offsets: (specimen.length >= 6) ? [ specimen[4], specimen[5] ] : [ 0, 0 ], + elementId: elementId, + jsPlumbInstance: _currentInstance, + cssClass: specimen.length == 7 ? specimen[6] : null + }; + newAnchor = new jsPlumb.Anchor(anchorParams); + newAnchor.clone = function () { + return new jsPlumb.Anchor(anchorParams); + }; + } + } + + if (!newAnchor.id) newAnchor.id = "anchor_" + _idstamp(); + return newAnchor; + }; + + /** + * makes a list of anchors from the given list of types or coords, eg + * ["TopCenter", "RightMiddle", "BottomCenter", [0, 1, -1, -1] ] + */ + this.makeAnchors = function (types, elementId, jsPlumbInstance) { + var r = []; + for (var i = 0, ii = types.length; i < ii; i++) { + if (typeof types[i] == "string") + r.push(jsPlumb.Anchors[types[i]]({elementId: elementId, jsPlumbInstance: jsPlumbInstance})); + else if (_ju.isArray(types[i])) + r.push(_currentInstance.makeAnchor(types[i], elementId, jsPlumbInstance)); + } + return r; + }; + + /** + * Makes a dynamic anchor from the given list of anchors (which may be in shorthand notation as strings or dimension arrays, or Anchor + * objects themselves) and the given, optional, anchorSelector function (jsPlumb uses a default if this is not provided; most people will + * not need to provide this - i think). + */ + this.makeDynamicAnchor = function (anchors, anchorSelector) { + return new jsPlumb.DynamicAnchor({anchors: anchors, selector: anchorSelector, elementId: null, jsPlumbInstance: _currentInstance}); + }; + +// --------------------- makeSource/makeTarget ---------------------------------------------- + + this.targetEndpointDefinitions = {}; + var _setEndpointPaintStylesAndAnchor = function (ep, epIndex, _instance) { + ep.paintStyle = ep.paintStyle || + _instance.Defaults.EndpointStyles[epIndex] || + _instance.Defaults.EndpointStyle; + + ep.hoverPaintStyle = ep.hoverPaintStyle || + _instance.Defaults.EndpointHoverStyles[epIndex] || + _instance.Defaults.EndpointHoverStyle; + + ep.anchor = ep.anchor || + _instance.Defaults.Anchors[epIndex] || + _instance.Defaults.Anchor; + + ep.endpoint = ep.endpoint || + _instance.Defaults.Endpoints[epIndex] || + _instance.Defaults.Endpoint; + }; + + // TODO put all the source stuff inside one parent, keyed by id. + this.sourceEndpointDefinitions = {}; + + var selectorFilter = function (evt, _el, selector, _instance, negate) { + var t = evt.target || evt.srcElement, ok = false, + sel = _instance.getSelector(_el, selector); + for (var j = 0; j < sel.length; j++) { + if (sel[j] == t) { + ok = true; + break; + } + } + return negate ? !ok : ok; + }; + + // SP target source refactor + var _makeElementDropHandler = function (elInfo, p, dropOptions, isSource, isTarget, definitionId) { + var proxyComponent = new jsPlumbUIComponent(p); + var _drop = p._jsPlumb.EndpointDropHandler({ + jsPlumb: _currentInstance, + enabled: function () { + return elInfo.el[definitionId].enabled; + }, + isFull: function () { + var targetCount = _currentInstance.select({target: elInfo.id}).length; + var def = elInfo.el[definitionId]; + return def.maxConnections > 0 && targetCount >= def.maxConnections; + }, + element: elInfo.el, + elementId: elInfo.id, + isSource: isSource, + isTarget: isTarget, + addClass: function (clazz) { + _currentInstance.addClass(elInfo.el, clazz); + }, + removeClass: function (clazz) { + _currentInstance.removeClass(elInfo.el, clazz); + }, + onDrop: function (jpc) { + var source = jpc.endpoints[0]; + source.anchor.locked = false; + }, + isDropAllowed: function () { + return proxyComponent.isDropAllowed.apply(proxyComponent, arguments); + }, + isRedrop:function(jpc) { + return (jpc.suspendedElement != null && jpc.suspendedEndpoint != null && jpc.suspendedEndpoint.element === elInfo.el); + }, + getEndpoint: function (jpc) { + + // make a new Endpoint for the target, or get it from the cache if uniqueEndpoint + // is set. if its a redrop the new endpoint will be immediately cleaned up. + var def = elInfo.el[definitionId], + newEndpoint = def.endpoint; + + // if no cached endpoint, or there was one but it has been cleaned up + // (ie. detached), create a new one + if (newEndpoint == null || newEndpoint._jsPlumb == null) { + newEndpoint = _currentInstance.addEndpoint(elInfo.el, p); + newEndpoint._mtNew = true; + } + + if (p.uniqueEndpoint) def.endpoint = newEndpoint; // may of course just store what it just pulled out. that's ok. + // TODO test options to makeTarget to see if we should do this? + newEndpoint._doNotDeleteOnDetach = false; // reset. + newEndpoint._deleteOnDetach = true; + + // if connection is detachable, init the new endpoint to be draggable, to support that happening. + if (jpc.isDetachable()) + newEndpoint.initDraggable(); + + // if the anchor has a 'positionFinder' set, then delegate to that function to find + // out where to locate the anchor. + if (newEndpoint.anchor.positionFinder != null) { + var dropPosition = _currentInstance.getUIPosition(arguments, _currentInstance.getZoom()), + //elPosition = _currentInstance.getOffset(_el), + elPosition = _currentInstance.getOffset(elInfo.el), + //elSize = _currentInstance.getSize(_el), + elSize = _currentInstance.getSize(elInfo.el), + ap = newEndpoint.anchor.positionFinder(dropPosition, elPosition, elSize, newEndpoint.anchor.constructorParams); + newEndpoint.anchor.x = ap[0]; + newEndpoint.anchor.y = ap[1]; + // now figure an orientation for it..kind of hard to know what to do actually. probably the best thing i can do is to + // support specifying an orientation in the anchor's spec. if one is not supplied then i will make the orientation + // be what will cause the most natural link to the source: it will be pointing at the source, but it needs to be + // specified in one axis only, and so how to make that choice? i think i will use whichever axis is the one in which + // the target is furthest away from the source. + } + + return newEndpoint; + }, + maybeCleanup: function (ep) { + if (ep._mtNew && ep.connections.length === 0) { + _currentInstance.deleteObject({endpoint: ep}); + } + else + delete ep._mtNew; + } + }); + + // wrap drop events as needed and initialise droppable + var dropEvent = jsPlumb.dragEvents.drop; + dropOptions.scope = dropOptions.scope || (p.scope || _currentInstance.Defaults.Scope); + dropOptions[dropEvent] = _ju.wrap(dropOptions[dropEvent], _drop, true); + + // if target, return true from the over event. this will cause katavorio to stop setting drops to hover + // if multipleDrop is set to false. + if (isTarget) { + dropOptions[jsPlumb.dragEvents.over] = function () { return true; }; + } + + dropOptions.definitionId = definitionId; + + // vanilla jsplumb only + if (p.allowLoopback === false) { + dropOptions.canDrop = function (_drag) { + var de = _drag.getDragElement()._jsPlumbRelatedElement; + return de != elInfo.el; + }; + } + _currentInstance.initDroppable(elInfo.el, dropOptions, "internal"); + + return _drop; + + }; + + // see API docs + this.makeTarget = function (el, params, referenceParams) { + + // put jsplumb ref into params without altering the params passed in + var p = jsPlumb.extend({_jsPlumb: this}, referenceParams); + jsPlumb.extend(p, params); + + // calculate appropriate paint styles and anchor from the params given + _setEndpointPaintStylesAndAnchor(p, 1, this); + + var deleteEndpointsOnDetach = !(p.deleteEndpointsOnDetach === false), + maxConnections = p.maxConnections || -1, + + _doOne = function (el) { + + // get the element's id and store the endpoint definition for it. jsPlumb.connect calls will look for one of these, + // and use the endpoint definition if found. + // decode the info for this element (id and element) + var elInfo = _info(el), + elid = elInfo.id, + dropOptions = jsPlumb.extend({}, p.dropOptions || {}); + + _ensureContainer(elid); + + // store the definition + var _def = { + def: p, + uniqueEndpoint: p.uniqueEndpoint, + maxConnections: maxConnections, + enabled: true + }; + elInfo.el._jsPlumbTarget = _def; + this.targetEndpointDefinitions[elid] = _def; + _makeElementDropHandler(elInfo, p, dropOptions, p.isSource === true, true, "_jsPlumbTarget"); + + }.bind(this); + + // make an array if only given one element + var inputs = el.length && el.constructor != String ? el : [ el ]; + + // register each one in the list. + for (var i = 0, ii = inputs.length; i < ii; i++) { + _doOne(inputs[i]); + } + + return this; + }; + + // see api docs + this.unmakeTarget = function (el, doNotClearArrays) { + var info = _info(el); + jsPlumb.destroyDroppable(info.el); + if (!doNotClearArrays) { + delete this.targetEndpointDefinitions[info.id]; + } + + return this; + }; + + // see api docs + this.makeSource = function (el, params, referenceParams) { + var p = jsPlumb.extend({_jsPlumb: this}, referenceParams); + jsPlumb.extend(p, params); + _setEndpointPaintStylesAndAnchor(p, 0, this); + var maxConnections = p.maxConnections || 1, + onMaxConnections = p.onMaxConnections, + _doOne = function (elInfo) { + // get the element's id and store the endpoint definition for it. jsPlumb.connect calls will look for one of these, + // and use the endpoint definition if found. + var elid = elInfo.id, + _del = this.getElement(elInfo.el); + + _ensureContainer(elid); + + var _def = { + def: p, + uniqueEndpoint: p.uniqueEndpoint, + maxConnections: maxConnections, + enabled: true + }; + this.sourceEndpointDefinitions[elid] = _def; + elInfo.el._jsPlumbSource = _def; + + var stopEvent = jsPlumb.dragEvents.stop, + dragEvent = jsPlumb.dragEvents.drag, + dragOptions = jsPlumb.extend({ }, p.dragOptions || {}), + existingDrag = dragOptions.drag, + existingStop = dragOptions.stop, + ep = null, + endpointAddedButNoDragYet = false; + + // set scope if its not set in dragOptions but was passed in in params + dragOptions.scope = dragOptions.scope || p.scope; + + dragOptions[dragEvent] = _ju.wrap(dragOptions[dragEvent], function () { + if (existingDrag) existingDrag.apply(this, arguments); + endpointAddedButNoDragYet = false; + }); + + dragOptions[stopEvent] = _ju.wrap(dragOptions[stopEvent], function () { + + if (existingStop) existingStop.apply(this, arguments); + this.currentlyDragging = false; + if (ep._jsPlumb != null) { // if not cleaned up... + + // reset the anchor to the anchor that was initially provided. the one we were using to drag + // the connection was just a placeholder that was located at the place the user pressed the + // mouse button to initiate the drag. + var anchorDef = p.anchor || this.Defaults.Anchor, + oldAnchor = ep.anchor, + oldConnection = ep.connections[0], + newAnchor = this.makeAnchor(anchorDef, elid, this), + _el = ep.element; + + // if the anchor has a 'positionFinder' set, then delegate to that function to find + // out where to locate the anchor. issue 117. + if (newAnchor.positionFinder != null) { + var elPosition = _currentInstance.getOffset(_el), + elSize = this.getSize(_el), + dropPosition = { left: elPosition.left + (oldAnchor.x * elSize[0]), top: elPosition.top + (oldAnchor.y * elSize[1]) }, + ap = newAnchor.positionFinder(dropPosition, elPosition, elSize, newAnchor.constructorParams); + + newAnchor.x = ap[0]; + newAnchor.y = ap[1]; + } + + ep.setAnchor(newAnchor, true); + ep.repaint(); + this.repaint(ep.elementId); + if (oldConnection != null) this.repaint(oldConnection.targetId); + } + }.bind(this)); + + // when the user presses the mouse, add an Endpoint, if we are enabled. + var mouseDownListener = function (e) { + var evt = this.getOriginalEvent(e); + // on right mouse button, abort. + if (e.which === 3 || e.button === 2) return; + + // TODO store def on element. + var def = this.sourceEndpointDefinitions[elid]; + + // if disabled, return. + if (!def.enabled) return; + + elid = this.getId(this.getElement(elInfo.el)); // elid might have changed since this method was called to configure the element. + + // if a filter was given, run it, and return if it says no. + if (p.filter) { + var r = jsPlumbUtil.isString(p.filter) ? selectorFilter(evt, elInfo.el, p.filter, this, p.filterExclude) : p.filter(evt, elInfo.el); + if (r === false) return; + } + + // if maxConnections reached + var sourceCount = this.select({source: elid}).length; + if (def.maxConnections >= 0 && (def.uniqueEndpoint && sourceCount >= def.maxConnections)) { + if (onMaxConnections) { + onMaxConnections({ + element: elInfo.el, + maxConnections: maxConnections + }, e); + } + return false; + } + + // find the position on the element at which the mouse was pressed; this is where the endpoint + // will be located. + var elxy = jsPlumb.getPositionOnElement(evt, _del, _zoom); + + // we need to override the anchor in here, and force 'isSource', but we don't want to mess with + // the params passed in, because after a connection is established we're going to reset the endpoint + // to have the anchor we were given. + var tempEndpointParams = {}; + jsPlumb.extend(tempEndpointParams, p); + tempEndpointParams.isTemporarySource = true; + tempEndpointParams.anchor = [ elxy[0], elxy[1] , 0, 0]; + tempEndpointParams.dragOptions = dragOptions; + + ep = this.addEndpoint(elid, tempEndpointParams); + endpointAddedButNoDragYet = true; + ep._doNotDeleteOnDetach = false; // reset. + ep._deleteOnDetach = true; + + // if unique endpoint and it's already been created, push it onto the endpoint we create. at the end + // of a successful connection we'll switch to that endpoint. + // TODO this is the same code as the programmatic endpoints create on line 1050 ish + if (def.uniqueEndpoint) { + if (!def.endpoint) { + def.endpoint = ep; + ep._deleteOnDetach = false; + ep._doNotDeleteOnDetach = true; + } + else + ep.finalEndpoint = def.endpoint; + } + + var _delTempEndpoint = function () { + // this mouseup event is fired only if no dragging occurred, by jquery and yui, but for mootools + // it is fired even if dragging has occurred, in which case we would blow away a perfectly + // legitimate endpoint, were it not for this check. the flag is set after adding an + // endpoint and cleared in a drag listener we set in the dragOptions above. + _currentInstance.off(ep.canvas, "mouseup", _delTempEndpoint); + _currentInstance.off(elInfo.el, "mouseup", _delTempEndpoint); + if (endpointAddedButNoDragYet) { + endpointAddedButNoDragYet = false; + _currentInstance.deleteEndpoint(ep); + } + }; + + _currentInstance.on(ep.canvas, "mouseup", _delTempEndpoint); + _currentInstance.on(elInfo.el, "mouseup", _delTempEndpoint); + + // and then trigger its mousedown event, which will kick off a drag, which will start dragging + // a new connection from this endpoint. + _currentInstance.trigger(ep.canvas, "mousedown", e); + + jsPlumbUtil.consume(e); + + }.bind(this); + + //this.on(_el, "mousedown", mouseDownListener); + this.on(elInfo.el, "mousedown", mouseDownListener); + _def.trigger = mouseDownListener; + + // if a filter was provided, set it as a dragFilter on the element, + // to prevent the element drag function from kicking in when we want to + // drag a new connection + if (p.filter && (jsPlumbUtil.isString(p.filter) || jsPlumbUtil.isFunction(p.filter))) { + //_currentInstance.setDragFilter(_el, p.filter/*, p.filterExclude*/); + _currentInstance.setDragFilter(elInfo.el, p.filter/*, p.filterExclude*/); + } + + var dropOptions = jsPlumb.extend({}, p.dropOptions || {}); + + _makeElementDropHandler(elInfo, p, dropOptions, true, p.isTarget === true, "_jsPlumbSource"); + + }.bind(this); + + var inputs = el.length && el.constructor != String ? el : [ el ]; + for (var i = 0, ii = inputs.length; i < ii; i++) { + _doOne(_info(inputs[i])); + } + + return this; + }; + + // see api docs + this.unmakeSource = function (el, doNotClearArrays) { + var info = _info(el), + mouseDownListener = this.sourceEndpointDefinitions[info.id].trigger; + + if (mouseDownListener) + _currentInstance.off(info.el, "mousedown", mouseDownListener); + + if (!doNotClearArrays) { + delete this.sourceEndpointDefinitions[info.id]; + } + + return this; + }; + + // see api docs + this.unmakeEverySource = function () { + for (var i in this.sourceEndpointDefinitions) + _currentInstance.unmakeSource(i, true); + + this.sourceEndpointDefinitions = {}; + return this; + }; + + var _getScope = function (el, types) { + types = jsPlumbUtil.isArray(types) ? types : [ types ]; + var id = _getId(el); + for (var i = 0; i < types.length; i++) { + var def = this[types[i]][id]; + if (def) return def.def.scope || this.Defaults.Scope; + } + }.bind(this); + + var _setScope = function (el, scope, types) { + types = jsPlumbUtil.isArray(types) ? types : [ types ]; + var id = _getId(el); + for (var i = 0; i < types.length; i++) { + var def = this[types[i]][id]; + if (def) { + def.def.scope = scope; + if (this.scopeChange != null) this.scopeChange(el, id, endpointsByElement[id], scope, types[i]); + } + } + + }.bind(this); + + this.getScope = function (el, scope) { + return _getScope(el, [ "sourceEndpointDefinitions", "targetEndpointDefinitions" ]); + }; + this.getSourceScope = function (el) { + return _getScope(el, "sourceEndpointDefinitions"); + }; + this.getTargetScope = function (el) { + return _getScope(el, "targetEndpointDefinitions"); + }; + this.setScope = function (el, scope) { + _setScope(el, scope, [ "sourceEndpointDefinitions", "targetEndpointDefinitions" ]); + }; + this.setSourceScope = function (el, scope) { + _setScope(el, scope, "sourceEndpointDefinitions"); + }; + this.setTargetScope = function (el, scope) { + _setScope(el, scope, "targetEndpointDefinitions"); + }; + + // see api docs + this.unmakeEveryTarget = function () { + for (var i in this.targetEndpointDefinitions) + _currentInstance.unmakeTarget(i, true); + + this.targetEndpointDefinitions = {}; + return this; + }; + + // does the work of setting a source enabled or disabled. + var _setEnabled = function (type, el, state, toggle) { + var a = type == "source" ? this.sourceEndpointDefinitions : this.targetEndpointDefinitions; + + if (_ju.isString(el)) a[el].enabled = toggle ? !a[el].enabled : state; + else if (el.length) { + for (var i = 0, ii = el.length; i < ii; i++) { + var info = _info(el[i]); + if (a[info.id]) + a[info.id].enabled = toggle ? !a[info.id].enabled : state; + } + } + // otherwise a DOM element + else { + var id = _info(el).id; + a[id].enabled = toggle ? !a[id].enabled : state; + } + return this; + }.bind(this); + + var _first = function (el, fn) { + if (_ju.isString(el) || !el.length) + return fn.apply(this, [ el ]); + else if (el.length) + return fn.apply(this, [ el[0] ]); + + }.bind(this); + + this.toggleSourceEnabled = function (el) { + _setEnabled("source", el, null, true); + return this.isSourceEnabled(el); + }; + + this.setSourceEnabled = function (el, state) { + return _setEnabled("source", el, state); + }; + this.isSource = function (el) { + return _first(el, function (_el) { + return this.sourceEndpointDefinitions[_info(_el).id] != null; + }.bind(this)); + }; + this.isSourceEnabled = function (el) { + return _first(el, function (_el) { + var sep = this.sourceEndpointDefinitions[_info(_el).id]; + return sep && sep.enabled === true; + }.bind(this)); + }; + + this.toggleTargetEnabled = function (el) { + _setEnabled("target", el, null, true); + return this.isTargetEnabled(el); + }; + + this.isTarget = function (el) { + return _first(el, function (_el) { + return this.targetEndpointDefinitions[_info(_el).id] != null; + }.bind(this)); + }; + this.isTargetEnabled = function (el) { + return _first(el, function (_el) { + var tep = this.targetEndpointDefinitions[_info(_el).id]; + return tep && tep.enabled === true; + }.bind(this)); + }; + this.setTargetEnabled = function (el, state) { + return _setEnabled("target", el, state); + }; + +// --------------------- end makeSource/makeTarget ---------------------------------------------- + + this.ready = function (fn) { + _currentInstance.bind("ready", fn); + }; + + var _elEach = function(el, fn) { + // support both lists... + if (typeof el == 'object' && el.length) + for (var i = 0, ii = el.length; i < ii; i++) { + fn(el[i]); + } + else // ...and single strings or elements. + fn(el); + + return _currentInstance; + }; + + // repaint some element's endpoints and connections + this.repaint = function (el, ui, timestamp) { + return _elEach(el, function(_el) { + _draw(_el, ui, timestamp); + }); + }; + + this.revalidate = function (el, timestamp, isIdAlready) { + return _elEach(el, function(_el) { + var elId = isIdAlready ? _el : _currentInstance.getId(_el); + _currentInstance.updateOffset({ elId: elId, recalc: true, timestamp:timestamp }); + _currentInstance.repaint(_el); + }); + }; + + // repaint every endpoint and connection. + this.repaintEverything = function () { + // TODO this timestamp causes continuous anchors to not repaint properly. + // fix this. do not just take out the timestamp. it runs a lot faster with + // the timestamp included. + var timestamp = _timestamp(), elId; + + for (elId in endpointsByElement) { + _currentInstance.updateOffset({ elId: elId, recalc: true, timestamp: timestamp }); + } + + for (elId in endpointsByElement) { + _draw(elId, null, timestamp); + } + + return this; + }; + + this.removeAllEndpoints = function (el, recurse, affectedElements) { + affectedElements = affectedElements || []; + var _one = function (_el) { + var info = _info(_el), + ebe = endpointsByElement[info.id], + i, ii; + + if (ebe) { + affectedElements.push(info); + for (i = 0, ii = ebe.length; i < ii; i++) + _currentInstance.deleteEndpoint(ebe[i]); + } + delete endpointsByElement[info.id]; + + if (recurse) { + if (info.el && info.el.nodeType != 3 && info.el.nodeType != 8) { + for (i = 0, ii = info.el.childNodes.length; i < ii; i++) { + _one(info.el.childNodes[i]); + } + } + } + + }; + _one(el); + return this; + }; + + var _doRemove = function(info, affectedElements) { + _currentInstance.removeAllEndpoints(info.id, true, affectedElements); + var _one = function(_info) { + _currentInstance.getDragManager().elementRemoved(_info.id); + _currentInstance.anchorManager.clearFor(_info.id); + _currentInstance.anchorManager.removeFloatingConnection(_info.id); + delete _currentInstance.floatingConnections[_info.id]; + delete managedElements[_info.id]; + delete offsets[_info.id]; + if (_info.el) { + _currentInstance.removeElement(_info.el); + _info.el._jsPlumb = null; + } + }; + + // remove all affected child elements + for (var ae = 1; ae < affectedElements.length; ae++) { + _one(affectedElements[ae]); + } + // and always remove the requested one from the dom. + _one(info); + }; + + /** + * Remove the given element, including cleaning up all endpoints registered for it. + * This is exposed in the public API but also used internally by jsPlumb when removing the + * element associated with a connection drag. + */ + this.remove = function (el, doNotRepaint) { + var info = _info(el), affectedElements = []; + if (info.text) { + info.el.parentNode.removeChild(info.el); + } + else if (info.id) { + _currentInstance.batch(function () { + _doRemove(info, affectedElements); + }, doNotRepaint === false); + } + return _currentInstance; + }; + + this.empty = function (el, doNotRepaint) { + var affectedElements = []; + var _one = function(el, dontRemoveFocus) { + var info = _info(el); + if (info.text) { + info.el.parentNode.removeChild(info.el); + } + else if (info.el) { + while(info.el.childNodes.length > 0) { + _one(info.el.childNodes[0]); + } + if (!dontRemoveFocus) _doRemove(info, affectedElements); + } + }; + + _currentInstance.batch(function() { + _one(el, true); + }, doNotRepaint === false); + + return _currentInstance; + }; + + this.reset = function () { + _currentInstance.silently(function() { + _currentInstance.deleteEveryEndpoint(); + _currentInstance.unbind(); + this.targetEndpointDefinitions = {}; + this.sourceEndpointDefinitions = {}; + connections.length = 0; + if (this.doReset) this.doReset(); + }.bind(this)); + }; + + var _clearObject = function (obj) { + if (obj.canvas && obj.canvas.parentNode) + obj.canvas.parentNode.removeChild(obj.canvas); + obj.cleanup(); + obj.destroy(); + }; + + this.clear = function () { + _currentInstance.select().each(_clearObject); + _currentInstance.selectEndpoints().each(_clearObject); + + endpointsByElement = {}; + endpointsByUUID = {}; + }; + + this.setDefaultScope = function (scope) { + DEFAULT_SCOPE = scope; + return _currentInstance; + }; + + // sets whether or not some element should be currently draggable. + this.setDraggable = _setDraggable; + + // sets the id of some element, changing whatever we need to to keep track. + this.setId = function (el, newId, doNotSetAttribute) { + // + var id; + + if (jsPlumbUtil.isString(el)) { + id = el; + } + else { + el = this.getElement(el); + id = this.getId(el); + } + + var sConns = this.getConnections({source: id, scope: '*'}, true), + tConns = this.getConnections({target: id, scope: '*'}, true); + + newId = "" + newId; + + if (!doNotSetAttribute) { + el = this.getElement(id); + this.setAttribute(el, "id", newId); + } + else + el = this.getElement(newId); + + endpointsByElement[newId] = endpointsByElement[id] || []; + for (var i = 0, ii = endpointsByElement[newId].length; i < ii; i++) { + endpointsByElement[newId][i].setElementId(newId); + endpointsByElement[newId][i].setReferenceElement(el); + } + delete endpointsByElement[id]; + + this.anchorManager.changeId(id, newId); + this.getDragManager().changeId(id, newId); + managedElements[newId] = managedElements[id]; + delete managedElements[id]; + + var _conns = function (list, epIdx, type) { + for (var i = 0, ii = list.length; i < ii; i++) { + list[i].endpoints[epIdx].setElementId(newId); + list[i].endpoints[epIdx].setReferenceElement(el); + list[i][type + "Id"] = newId; + list[i][type] = el; + } + }; + _conns(sConns, 0, "source"); + _conns(tConns, 1, "target"); + + this.repaint(newId); + }; + + this.setDebugLog = function (debugLog) { + log = debugLog; + }; + + this.setSuspendDrawing = function (val, repaintAfterwards) { + var curVal = _suspendDrawing; + _suspendDrawing = val; + if (val) _suspendedAt = new Date().getTime(); else _suspendedAt = null; + if (repaintAfterwards) this.repaintEverything(); + return curVal; + }; + + // returns whether or not drawing is currently suspended. + this.isSuspendDrawing = function () { + return _suspendDrawing; + }; + + // return timestamp for when drawing was suspended. + this.getSuspendedAt = function () { + return _suspendedAt; + }; + + this.batch = function (fn, doNotRepaintAfterwards) { + var _wasSuspended = this.isSuspendDrawing(); + if (!_wasSuspended) + this.setSuspendDrawing(true); + try { + fn(); + } + catch (e) { + _ju.log("Function run while suspended failed", e); + } + if (!_wasSuspended) + this.setSuspendDrawing(false, !doNotRepaintAfterwards); + }; + + this.doWhileSuspended = this.batch; + + /* + this.getOffset = function (elId) { + return offsets[elId]; + };*/ + + this.getCachedData = _getCachedData; + this.timestamp = _timestamp; + this.setRenderMode = function (mode) { + if (mode !== jsPlumb.SVG && mode !== jsPlumb.VML) throw new TypeError("Render mode [" + mode + "] not supported"); + renderMode = this.trySetRenderMode(mode); + return renderMode; + }; + this.getRenderMode = function () { + return renderMode; + }; + this.show = function (el, changeEndpoints) { + _setVisible(el, "block", changeEndpoints); + return _currentInstance; + }; + + // TODO: update this method to return the current state. + this.toggleVisible = _toggleVisible; + this.toggleDraggable = _toggleDraggable; + this.addListener = this.bind; + }; + + jsPlumbUtil.extend(jsPlumbInstance, jsPlumbUtil.EventGenerator, { + setAttribute: function (el, a, v) { + this.setAttribute(el, a, v); + }, + getAttribute: function (el, a) { + return this.getAttribute(jsPlumb.getElement(el), a); + }, + convertToFullOverlaySpec: function(spec) { + if (jsPlumbUtil.isString(spec)) { + spec = [ spec, { } ]; + } + spec[1].id = spec[1].id || jsPlumbUtil.uuid(); + return spec; + }, + registerConnectionType: function (id, type) { + this._connectionTypes[id] = jsPlumb.extend({}, type); + if (type.overlays) { + var to = {}; + for (var i = 0; i < type.overlays.length; i++) { + // if a string, convert to object representation so that we can store the typeid on it. + // also assign an id. + var fo = this.convertToFullOverlaySpec(type.overlays[i]); + to[fo[1].id] = fo; + } + this._connectionTypes[id].overlays = to; + } + }, + registerConnectionTypes: function (types) { + for (var i in types) + this.registerConnectionType(i, types[i]); + }, + registerEndpointType: function (id, type) { + this._endpointTypes[id] = jsPlumb.extend({}, type); + }, + registerEndpointTypes: function (types) { + for (var i in types) + this._endpointTypes[i] = jsPlumb.extend({}, types[i]); + }, + getType: function (id, typeDescriptor) { + return typeDescriptor === "connection" ? this._connectionTypes[id] : this._endpointTypes[id]; + }, + setIdChanged: function (oldId, newId) { + this.setId(oldId, newId, true); + }, + // set parent: change the parent for some node and update all the registrations we need to. + setParent: function (el, newParent) { + var _dom = this.getElement(el), + _id = this.getId(_dom), + _pdom = this.getElement(newParent), + _pid = this.getId(_pdom); + + _dom.parentNode.removeChild(_dom); + _pdom.appendChild(_dom); + this.getDragManager().setParent(_dom, _id, _pdom, _pid); + }, + extend: function (o1, o2, names) { + var i; + if (names) { + for (i = 0; i < names.length; i++) + o1[names[i]] = o2[names[i]]; + } + else + for (i in o2) o1[i] = o2[i]; + return o1; + }, + floatingConnections: {}, + getFloatingAnchorIndex: function (jpc) { + return jpc.endpoints[0].isFloating() ? 0 : 1; + } + }); + +// --------------------- static instance + AMD registration ------------------------------------------- + +// create static instance and assign to window if window exists. + var jsPlumb = new jsPlumbInstance(); + // register on window if defined (lets us run on server) + if (typeof window != 'undefined') window.jsPlumb = jsPlumb; + // add 'getInstance' method to static instance + jsPlumb.getInstance = function (_defaults) { + var j = new jsPlumbInstance(_defaults); + j.init(); + return j; + }; + jsPlumb.each = function (spec, fn) { + if (spec == null) return; + if (typeof spec === "string") + fn(jsPlumb.getElement(spec)); + else if (spec.length != null) { + for (var i = 0; i < spec.length; i++) + fn(jsPlumb.getElement(spec[i])); + } + else + fn(spec); // assume it's an element. + }; +// maybe register static instance as an AMD module, and getInstance method too. + if (typeof define === "function") { + define("jsplumb", [], function () { + return jsPlumb; + }); + define("jsplumbinstance", [], function () { + return jsPlumb.getInstance(); + }); + } + // CommonJS + if (typeof exports !== 'undefined') { + exports.jsPlumb = jsPlumb; + } + + +// --------------------- end static instance + AMD registration ------------------------------------------- + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the base functionality for DOM type adapters. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + var root = this, _ju = root.jsPlumbUtil; + + var svgAvailable = !!window.SVGAngle || document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"), + vmlAvailable = function () { + if (vmlAvailable.vml === undefined) { + var a = document.body.appendChild(document.createElement('div')); + a.innerHTML = ''; + var b = a.firstChild; + if (b != null && b.style != null) { + b.style.behavior = "url(#default#VML)"; + vmlAvailable.vml = b ? typeof b.adj == "object" : true; + } + else + vmlAvailable.vml = false; + a.parentNode.removeChild(a); + } + return vmlAvailable.vml; + }, + // TODO: remove this once we remove all library adapter versions and have only vanilla jsplumb: this functionality + // comes from Mottle. + iev = (function () { + var rv = -1; + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent, + re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv; + })(), + isIELT9 = iev > -1 && iev < 9, + _genLoc = function (e, prefix) { + if (e == null) return [ 0, 0 ]; + var ts = _touches(e), t = _getTouch(ts, 0); + return [t[prefix + "X"], t[prefix + "Y"]]; + }, + _pageLocation = function (e) { + if (e == null) return [ 0, 0 ]; + if (isIELT9) { + return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ]; + } + else { + return _genLoc(e, "page"); + } + }, + _screenLocation = function (e) { + return _genLoc(e, "screen"); + }, + _clientLocation = function (e) { + return _genLoc(e, "client"); + }, + _getTouch = function (touches, idx) { + return touches.item ? touches.item(idx) : touches[idx]; + }, + _touches = function (e) { + return e.touches && e.touches.length > 0 ? e.touches : + e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches : + e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches : + [ e ]; + }; + + /** + Manages dragging for some instance of jsPlumb. + + TODO instead of this being accessed directly, it should subscribe to events on the jsPlumb instance: every method + in here is called directly by jsPlumb. But what should happen is that we have unpublished events that this listens + to. The only trick is getting one of these instantiated with every jsPlumb instance: it needs to have a hook somehow. + Basically the general idea is to pull ALL the drag code out (prototype method registrations plus this) into a + dedicated drag script), that does not necessarily need to be included. + + + */ + var DragManager = function (_currentInstance) { + var _draggables = {}, _dlist = [], _delements = {}, _elementsWithEndpoints = {}, + // elementids mapped to the draggable to which they belong. + _draggablesForElements = {}; + + /** + register some element as draggable. right now the drag init stuff is done elsewhere, and it is + possible that will continue to be the case. + */ + this.register = function (el) { + var id = _currentInstance.getId(el), + parentOffset = _currentInstance.getOffset(el); + + if (!_draggables[id]) { + _draggables[id] = el; + _dlist.push(el); + _delements[id] = {}; + } + + // look for child elements that have endpoints and register them against this draggable. + var _oneLevel = function (p) { + if (p) { + for (var i = 0; i < p.childNodes.length; i++) { + if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) { + var cEl = jsPlumb.getElement(p.childNodes[i]), + cid = _currentInstance.getId(p.childNodes[i], null, true); + if (cid && _elementsWithEndpoints[cid] && _elementsWithEndpoints[cid] > 0) { + var cOff = _currentInstance.getOffset(cEl); + _delements[id][cid] = { + id: cid, + offset: { + left: cOff.left - parentOffset.left, + top: cOff.top - parentOffset.top + } + }; + _draggablesForElements[cid] = id; + } + _oneLevel(p.childNodes[i]); + } + } + } + }; + + _oneLevel(el); + }; + + // refresh the offsets for child elements of this element. + this.updateOffsets = function (elId) { + if (elId != null) { + var domEl = jsPlumb.getElement(elId), + id = _currentInstance.getId(domEl), + children = _delements[id], + parentOffset = _currentInstance.getOffset(domEl); + + if (children) { + for (var i in children) { + if (children.hasOwnProperty(i)) { + var cel = jsPlumb.getElement(i), + cOff = _currentInstance.getOffset(cel); + + _delements[id][i] = { + id: i, + offset: { + left: cOff.left - parentOffset.left, + top: cOff.top - parentOffset.top + } + }; + _draggablesForElements[i] = id; + } + } + } + } + }; + + /** + notification that an endpoint was added to the given el. we go up from that el's parent + node, looking for a parent that has been registered as a draggable. if we find one, we add this + el to that parent's list of elements to update on drag (if it is not there already) + */ + this.endpointAdded = function (el, id) { + + id = id || _currentInstance.getId(el); + + var b = document.body, + p = el.parentNode; + + _elementsWithEndpoints[id] = _elementsWithEndpoints[id] ? _elementsWithEndpoints[id] + 1 : 1; + + while (p != null && p != b) { + var pid = _currentInstance.getId(p, null, true); + if (pid && _draggables[pid]) { + var pLoc = _currentInstance.getOffset(p); + + if (_delements[pid][id] == null) { + var cLoc = _currentInstance.getOffset(el); + _delements[pid][id] = { + id: id, + offset: { + left: cLoc.left - pLoc.left, + top: cLoc.top - pLoc.top + } + }; + _draggablesForElements[id] = pid; + } + break; + } + p = p.parentNode; + } + }; + + this.endpointDeleted = function (endpoint) { + if (_elementsWithEndpoints[endpoint.elementId]) { + _elementsWithEndpoints[endpoint.elementId]--; + if (_elementsWithEndpoints[endpoint.elementId] <= 0) { + for (var i in _delements) { + if (_delements.hasOwnProperty(i) && _delements[i]) { + delete _delements[i][endpoint.elementId]; + delete _draggablesForElements[endpoint.elementId]; + } + } + } + } + }; + + this.changeId = function (oldId, newId) { + _delements[newId] = _delements[oldId]; + _delements[oldId] = {}; + _draggablesForElements[newId] = _draggablesForElements[oldId]; + _draggablesForElements[oldId] = null; + }; + + this.getElementsForDraggable = function (id) { + return _delements[id]; + }; + + this.elementRemoved = function (elementId) { + var elId = _draggablesForElements[elementId]; + if (elId) { + delete _delements[elId][elementId]; + delete _draggablesForElements[elementId]; + } + }; + + this.reset = function () { + _draggables = {}; + _dlist = []; + _delements = {}; + _elementsWithEndpoints = {}; + }; + + // + // notification drag ended. We check automatically if need to update some + // ancestor's offsets. + // + this.dragEnded = function (el) { + var id = _currentInstance.getId(el), + ancestor = _draggablesForElements[id]; + + if (ancestor) this.updateOffsets(ancestor); + }; + + this.setParent = function (el, elId, p, pId) { + var current = _draggablesForElements[elId]; + if (current) { + if (!_delements[pId]) + _delements[pId] = {}; + _delements[pId][elId] = _delements[current][elId]; + delete _delements[current][elId]; + var pLoc = _currentInstance.getOffset(p), + cLoc = _currentInstance.getOffset(el); + _delements[pId][elId].offset = { + left: cLoc.left - pLoc.left, + top: cLoc.top - pLoc.top + }; + _draggablesForElements[elId] = pId; + } + }; + + this.getDragAncestor = function (el) { + var de = jsPlumb.getElement(el), + id = _currentInstance.getId(de), + aid = _draggablesForElements[id]; + + if (aid) + return jsPlumb.getElement(aid); + else + return null; + }; + + }; + + var trim = function (str) { + return str == null ? null : (str.replace(/^\s\s*/, '').replace(/\s\s*$/, '')); + }, + _setClassName = function (el, cn) { + cn = trim(cn); + if (typeof el.className.baseVal != "undefined") // SVG + el.className.baseVal = cn; + else + el.className = cn; + }, + _getClassName = function (el) { + return (typeof el.className.baseVal == "undefined") ? el.className : el.className.baseVal; + }, + _classManip = function (el, classesToAdd, classesToRemove) { + classesToAdd = classesToAdd == null ? [] : jsPlumbUtil.isArray(classesToAdd) ? classesToAdd : classesToAdd.split(/\s+/); + classesToRemove = classesToRemove == null ? [] : jsPlumbUtil.isArray(classesToRemove) ? classesToRemove : classesToRemove.split(/\s+/); + + var className = _getClassName(el), + curClasses = className.split(/\s+/); + + var _oneSet = function (add, classes) { + for (var i = 0; i < classes.length; i++) { + if (add) { + if (jsPlumbUtil.indexOf(curClasses, classes[i]) == -1) + curClasses.push(classes[i]); + } + else { + var idx = jsPlumbUtil.indexOf(curClasses, classes[i]); + if (idx != -1) + curClasses.splice(idx, 1); + } + } + }; + + _oneSet(true, classesToAdd); + _oneSet(false, classesToRemove); + + _setClassName(el, curClasses.join(" ")); + }; + + jsPlumb.extend(jsPlumbInstance.prototype, { + + headless: false, + + pageLocation: _pageLocation, + screenLocation: _screenLocation, + clientLocation: _clientLocation, + + getDragManager:function() { + if (this.dragManager == null) + this.dragManager = new DragManager(this); + + return this.dragManager; + }, + + recalculateOffsets:function(elId) { + this.getDragManager().updateOffsets(elId); + }, + + createElement:function(tag, style, clazz, atts) { + return this.createElementNS(null, tag, style, clazz, atts); + }, + + createElementNS:function(ns, tag, style, clazz, atts) { + var e = ns == null ? document.createElement(tag) : document.createElementNS(ns, tag); + var i; + style = style || {}; + for (i in style) + e.style[i] = style[i]; + + if (clazz) + e.className = clazz; + + atts = atts || {}; + for (i in atts) + e.setAttribute(i, "" + atts[i]); + + return e; + }, + + getAttribute: function (el, attName) { + return el.getAttribute != null ? el.getAttribute(attName) : null; + }, + + setAttribute: function (el, a, v) { + if (el.setAttribute != null) el.setAttribute(a, v); + }, + + setAttributes: function (el, atts) { + for (var i in atts) + if (atts.hasOwnProperty(i)) el.setAttribute(i, atts[i]); + }, + + appendToRoot: function (node) { + document.body.appendChild(node); + }, + getRenderModes: function () { + return [ "svg", "vml" ]; + }, + isRenderModeAvailable: function (m) { + return { + "svg": svgAvailable, + "vml": vmlAvailable() + }[m]; + }, + trySetRenderMode: function (mode) { + var renderMode; + + if (mode) { + mode = mode.toLowerCase(); + + var svgAvailable = this.isRenderModeAvailable("svg"), + vmlAvailable = this.isRenderModeAvailable("vml"); + + // now test we actually have the capability to do this. + if (mode === "svg") { + if (svgAvailable) renderMode = "svg"; + else if (vmlAvailable) renderMode = "vml"; + } + else if (vmlAvailable) renderMode = "vml"; + } + + return renderMode; + }, + addClass: function (el, clazz) { + jsPlumb.each(el, function (e) { + _classManip(e, clazz); + }); + }, + hasClass: function (el, clazz) { + el = jsPlumb.getElement(el); + if (el.classList) return el.classList.contains(clazz); + else { + return _getClassName(el).indexOf(clazz) != -1; + } + }, + removeClass: function (el, clazz) { + jsPlumb.each(el, function (e) { + _classManip(e, null, clazz); + }); + }, + updateClasses: function (el, toAdd, toRemove) { + jsPlumb.each(el, function (e) { + _classManip(e, toAdd, toRemove); + }); + }, + setClass: function (el, clazz) { + jsPlumb.each(el, function (e) { + _setClassName(e, clazz); + }); + }, + setPosition: function (el, p) { + el.style.left = p.left + "px"; + el.style.top = p.top + "px"; + }, + getPosition: function (el) { + var _one = function (prop) { + var v = el.style[prop]; + return v ? v.substring(0, v.length - 2) : 0; + }; + return { + left: _one("left"), + top: _one("top") + }; + }, + getStyle:function(el, prop) { + if (typeof window.getComputedStyle !== 'undefined') { + return getComputedStyle(el, null).getPropertyValue(prop); + } else { + return el.currentStyle[prop]; + } + }, + + getSelector: function (ctx, spec) { + var sel = null; + if (arguments.length == 1) { + sel = ctx.nodeType != null ? ctx : document.querySelectorAll(ctx); + } + else + sel = ctx.querySelectorAll(spec); + + return sel; + }, + getOffset:function(el, relativeToRoot) { + el = jsPlumb.getElement(el); + var container = this.getContainer(); + var out = { + left: el.offsetLeft, + top: el.offsetTop + }, + op = (relativeToRoot || (container != null && el.offsetParent != container)) ? el.offsetParent : null, + _maybeAdjustScroll = function(offsetParent) { + if (offsetParent != null && offsetParent !== document.body && (offsetParent.scrollTop > 0 || offsetParent.scrollLeft > 0)) { + var p = this.getStyle(el, "position"); + //if (p !== "fixed") { + out.left -= offsetParent.scrollLeft; + out.top -= offsetParent.scrollTop; + //} + } + }.bind(this); + + while (op != null) { + out.left += op.offsetLeft; + out.top += op.offsetTop; + //if (!relativeToRoot) _maybeAdjustScroll(op); + _maybeAdjustScroll(op); + op = relativeToRoot ? op.offsetParent : + op.offsetParent == container ? null : op.offsetParent; + } + + // if container is scrolled and the element (or its offset parent) is not absolute or fixed, adjust accordingly. + if (container != null && !relativeToRoot && (container.scrollTop > 0 || container.scrollLeft > 0)) { + var pp = el.offsetParent != null ? this.getStyle(el.offsetParent, "position") : "static", + p = this.getStyle(el, "position"); + if (p !== "absolute" && p !== "fixed" && pp !== "absolute" && pp != "fixed") { + out.left -= container.scrollLeft; + out.top -= container.scrollTop; + } + } + return out; + }, + // + // return x+y proportion of the given element's size corresponding to the location of the given event. + // + getPositionOnElement: function (evt, el, zoom) { + var box = typeof el.getBoundingClientRect !== "undefined" ? el.getBoundingClientRect() : { left: 0, top: 0, width: 0, height: 0 }, + body = document.body, + docElem = document.documentElement, + scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop, + scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft, + clientTop = docElem.clientTop || body.clientTop || 0, + clientLeft = docElem.clientLeft || body.clientLeft || 0, + pst = 0, + psl = 0, + top = box.top + scrollTop - clientTop + (pst * zoom), + left = box.left + scrollLeft - clientLeft + (psl * zoom), + cl = jsPlumb.pageLocation(evt), + w = box.width || (el.offsetWidth * zoom), + h = box.height || (el.offsetHeight * zoom), + x = (cl[0] - left) / w, + y = (cl[1] - top) / h; + + return [ x, y ]; + }, + + /** + * Gets the absolute position of some element as read from the left/top properties in its style. + * @method getAbsolutePosition + * @param {Element} el The element to retrieve the absolute coordinates from. **Note** this is a DOM element, not a selector from the underlying library. + * @return {Number[]} [left, top] pixel values. + */ + getAbsolutePosition: function (el) { + var _one = function (s) { + var ss = el.style[s]; + if (ss) return parseFloat(ss.substring(0, ss.length - 2)); + }; + return [ _one("left"), _one("top") ]; + }, + + /** + * Sets the absolute position of some element by setting the left/top properties in its style. + * @method setAbsolutePosition + * @param {Element} el The element to set the absolute coordinates on. **Note** this is a DOM element, not a selector from the underlying library. + * @param {Number[]} xy x and y coordinates + * @param {Number[]} [animateFrom] Optional previous xy to animate from. + * @param {Object} [animateOptions] Options for the animation. + */ + setAbsolutePosition: function (el, xy, animateFrom, animateOptions) { + if (animateFrom) { + this.animate(el, { + left: "+=" + (xy[0] - animateFrom[0]), + top: "+=" + (xy[1] - animateFrom[1]) + }, animateOptions); + } + else { + el.style.left = xy[0] + "px"; + el.style.top = xy[1] + "px"; + } + }, + /** + * gets the size for the element, in an array : [ width, height ]. + */ + getSize: function (el) { + return [ el.offsetWidth, el.offsetHeight ]; + }, + getWidth: function (el) { + return el.offsetWidth; + }, + getHeight: function (el) { + return el.offsetHeight; + } + + }); +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains code for components that support overlays. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +;(function() { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + // ------------------------------ BEGIN OverlayCapablejsPlumbUIComponent -------------------------------------------- + + var _internalLabelOverlayId = "__label", + // this is a shortcut helper method to let people add a label as + // overlay. + _makeLabelOverlay = function (component, params) { + + var _params = { + cssClass: params.cssClass, + labelStyle: component.labelStyle, + id: _internalLabelOverlayId, + component: component, + _jsPlumb: component._jsPlumb.instance // TODO not necessary, since the instance can be accessed through the component. + }, + mergedParams = jsPlumb.extend(_params, params); + + return new _jp.Overlays[component._jsPlumb.instance.getRenderMode()].Label(mergedParams); + }, + _processOverlay = function (component, o) { + var _newOverlay = null; + if (_ju.isArray(o)) { // this is for the shorthand ["Arrow", { width:50 }] syntax + // there's also a three arg version: + // ["Arrow", { width:50 }, {location:0.7}] + // which merges the 3rd arg into the 2nd. + var type = o[0], + // make a copy of the object so as not to mess up anyone else's reference... + p = _jp.extend({component: component, _jsPlumb: component._jsPlumb.instance}, o[1]); + if (o.length == 3) _jp.extend(p, o[2]); + _newOverlay = new _jp.Overlays[component._jsPlumb.instance.getRenderMode()][type](p); + } else if (o.constructor == String) { + _newOverlay = new _jp.Overlays[component._jsPlumb.instance.getRenderMode()][o]({component: component, _jsPlumb: component._jsPlumb.instance}); + } else { + _newOverlay = o; + } + + _newOverlay.id = _newOverlay.id || _ju.uuid(); + component.cacheTypeItem("overlay", _newOverlay, _newOverlay.id); + //component._jsPlumb.overlays.push(_newOverlay); + component._jsPlumb.overlays[_newOverlay.id] = _newOverlay; + + return _newOverlay; + }; + + _jp.OverlayCapableJsPlumbUIComponent = function (params) { + + jsPlumbUIComponent.apply(this, arguments); + this._jsPlumb.overlays = {}; + this._jsPlumb.overlayPositions = {}; + + if (params.label) { + this.getDefaultType().overlays[_internalLabelOverlayId] = ["Label", { + label: params.label, + location: params.labelLocation || this.defaultLabelLocation || 0.5, + labelStyle: params.labelStyle || this._jsPlumb.instance.Defaults.LabelStyle, + id:_internalLabelOverlayId + }]; + } + + this.setListenerComponent = function (c) { + if (this._jsPlumb) { + for (var i in this._jsPlumb.overlays) + this._jsPlumb.overlays[i].setListenerComponent(c); + } + }; + }; + + _jp.OverlayCapableJsPlumbUIComponent.applyType = function (component, t) { + if (t.overlays) { + // loop through the ones in the type. if already present on the component, + // dont remove or re-add. + var keep = {}, i; + + for (i in t.overlays) { + + var existing = component._jsPlumb.overlays[t.overlays[i][1].id]; + if (existing) { + // maybe update from data, if there were parameterised values for instance. + existing.updateFrom(t.overlays[i][1]); + keep[t.overlays[i][1].id] = true; + } + else { + var c = component.getCachedTypeItem("overlay", t.overlays[i][1].id); + if (c != null) { + c.reattach(component._jsPlumb.instance); + // maybe update from data, if there were parameterised values for instance. + c.updateFrom(t.overlays[i][1]); + component._jsPlumb.overlays[c.id] = c; + } + else { + c = component.addOverlay(t.overlays[i], true); + } + keep[c.id] = true; + } + } + + // now loop through the full overlays and remove those that we dont want to keep + for (i in component._jsPlumb.overlays) { + if (keep[component._jsPlumb.overlays[i].id] == null) + component.removeOverlay(component._jsPlumb.overlays[i].id); + } + } + }; + + _ju.extend(_jp.OverlayCapableJsPlumbUIComponent, jsPlumbUIComponent, { + + setHover: function (hover, ignoreAttachedElements) { + if (this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) { + for (var i in this._jsPlumb.overlays) { + this._jsPlumb.overlays[i][hover ? "addClass" : "removeClass"](this._jsPlumb.instance.hoverClass); + } + } + }, + addOverlay: function (overlay, doNotRepaint) { + var o = _processOverlay(this, overlay); + if (!doNotRepaint) this.repaint(); + return o; + }, + getOverlay: function (id) { + return this._jsPlumb.overlays[id]; + }, + getOverlays: function () { + return this._jsPlumb.overlays; + }, + hideOverlay: function (id) { + var o = this.getOverlay(id); + if (o) o.hide(); + }, + hideOverlays: function () { + for (var i in this._jsPlumb.overlays) + this._jsPlumb.overlays[i].hide(); + }, + showOverlay: function (id) { + var o = this.getOverlay(id); + if (o) o.show(); + }, + showOverlays: function () { + for (var i in this._jsPlumb.overlays) + this._jsPlumb.overlays[i].show(); + }, + removeAllOverlays: function (doNotRepaint) { + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays[i].cleanup) this._jsPlumb.overlays[i].cleanup(); + } + + this._jsPlumb.overlays = {}; + this._jsPlumb.overlayPositions = null; + if (!doNotRepaint) + this.repaint(); + }, + removeOverlay: function (overlayId) { + var o = this._jsPlumb.overlays[overlayId]; + if (o) { + if (o.cleanup) o.cleanup(); + delete this._jsPlumb.overlays[overlayId]; + if (this._jsPlumb.overlayPositions) + delete this._jsPlumb.overlayPositions[overlayId]; + } + }, + removeOverlays: function () { + for (var i = 0, j = arguments.length; i < j; i++) + this.removeOverlay(arguments[i]); + }, + moveParent: function (newParent) { + if (this.bgCanvas) { + this.bgCanvas.parentNode.removeChild(this.bgCanvas); + newParent.appendChild(this.bgCanvas); + } + + this.canvas.parentNode.removeChild(this.canvas); + newParent.appendChild(this.canvas); + + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays[i].isAppendedAtTopLevel) { + var el = this._jsPlumb.overlays[i].getElement(); + el.parentNode.removeChild(el); + newParent.appendChild(el); + } + } + }, + getLabel: function () { + var lo = this.getOverlay(_internalLabelOverlayId); + return lo != null ? lo.getLabel() : null; + }, + getLabelOverlay: function () { + return this.getOverlay(_internalLabelOverlayId); + }, + setLabel: function (l) { + var lo = this.getOverlay(_internalLabelOverlayId); + if (!lo) { + var params = l.constructor == String || l.constructor == Function ? { label: l } : l; + lo = _makeLabelOverlay(this, params); + this._jsPlumb.overlays[_internalLabelOverlayId] = lo; + } + else { + if (l.constructor == String || l.constructor == Function) lo.setLabel(l); + else { + if (l.label) lo.setLabel(l.label); + if (l.location) lo.setLocation(l.location); + } + } + + if (!this._jsPlumb.instance.isSuspendDrawing()) + this.repaint(); + }, + cleanup: function (force) { + for (var i in this._jsPlumb.overlays) { + this._jsPlumb.overlays[i].cleanup(force); + this._jsPlumb.overlays[i].destroy(force); + } + if (force) { + this._jsPlumb.overlays = {}; + this._jsPlumb.overlayPositions = null; + } + }, + setVisible: function (v) { + this[v ? "showOverlays" : "hideOverlays"](); + }, + setAbsoluteOverlayPosition: function (overlay, xy) { + this._jsPlumb.overlayPositions[overlay.id] = xy; + }, + getAbsoluteOverlayPosition: function (overlay) { + return this._jsPlumb.overlayPositions ? this._jsPlumb.overlayPositions[overlay.id] : null; + } + }); + +// ------------------------------ END OverlayCapablejsPlumbUIComponent -------------------------------------------- + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for Endpoints. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + // create the drag handler for a connection + var _makeConnectionDragHandler = function (placeholder, _jsPlumb) { + var stopped = false; + return { + drag: function () { + if (stopped) { + stopped = false; + return true; + } + var _ui = _jp.getUIPosition(arguments, _jsPlumb.getZoom()); + + if (placeholder.element) { + jsPlumb.setPosition(placeholder.element, _ui); + _jsPlumb.repaint(placeholder.element, _ui); + } + }, + stopDrag: function () { + stopped = true; + } + }; + }; + + // creates a placeholder div for dragging purposes, adds it, and pre-computes its offset. + var _makeDraggablePlaceholder = function (placeholder, _jsPlumb) { + var n = jsPlumb.createElement("div", { position : "absolute" }); + _jsPlumb.appendElement(n); + var id = _jsPlumb.getId(n); + _jsPlumb.manage(id, n); + // create and assign an id, and initialize the offset. + placeholder.id = id; + placeholder.element = n; + }; + + // create a floating endpoint (for drag connections) + var _makeFloatingEndpoint = function (paintStyle, referenceAnchor, endpoint, referenceCanvas, sourceElement, _jsPlumb, _newEndpoint, scope) { + var floatingAnchor = new _jp.FloatingAnchor({ reference: referenceAnchor, referenceCanvas: referenceCanvas, jsPlumbInstance: _jsPlumb }); + //setting the scope here should not be the way to fix that mootools issue. it should be fixed by not + // adding the floating endpoint as a droppable. that makes more sense anyway! + return _newEndpoint({ paintStyle: paintStyle, endpoint: endpoint, anchor: floatingAnchor, source: sourceElement, scope: scope }); + }; + + var typeParameters = [ "connectorStyle", "connectorHoverStyle", "connectorOverlays", + "connector", "connectionType", "connectorClass", "connectorHoverClass" ]; + + // a helper function that tries to find a connection to the given element, and returns it if so. if elementWithPrecedence is null, + // or no connection to it is found, we return the first connection in our list. + var findConnectionToUseForDynamicAnchor = function (ep, elementWithPrecedence) { + var idx = 0; + if (elementWithPrecedence != null) { + for (var i = 0; i < ep.connections.length; i++) { + if (ep.connections[i].sourceId == elementWithPrecedence || ep.connections[i].targetId == elementWithPrecedence) { + idx = i; + break; + } + } + } + + return ep.connections[idx]; + }; + + var findConnectionIndex = function (conn, ep) { + return _ju.findWithFunction(ep.connections, function (c) { + return c.id == conn.id; + }); + }; + + _jp.Endpoint = function (params) { + var _jsPlumb = params._jsPlumb, + _newConnection = params.newConnection, + _newEndpoint = params.newEndpoint; + + this.idPrefix = "_jsplumb_e_"; + this.defaultLabelLocation = [ 0.5, 0.5 ]; + this.defaultOverlayKeys = ["Overlays", "EndpointOverlays"]; + _jp.OverlayCapableJsPlumbUIComponent.apply(this, arguments); + +// TYPE + + this.appendToDefaultType({ + connectionType:params.connectionType, + maxConnections: params.maxConnections == null ? this._jsPlumb.instance.Defaults.MaxConnections : params.maxConnections, // maximum number of connections this endpoint can be the source of., + paintStyle: params.endpointStyle || params.paintStyle || params.style || this._jsPlumb.instance.Defaults.EndpointStyle || _jp.Defaults.EndpointStyle, + hoverPaintStyle: params.endpointHoverStyle || params.hoverPaintStyle || this._jsPlumb.instance.Defaults.EndpointHoverStyle || _jp.Defaults.EndpointHoverStyle, + connectorStyle: params.connectorStyle, + connectorHoverStyle: params.connectorHoverStyle, + connectorClass: params.connectorClass, + connectorHoverClass: params.connectorHoverClass, + connectorOverlays: params.connectorOverlays, + connector: params.connector, + connectorTooltip: params.connectorTooltip + }); + +// END TYPE + + this._jsPlumb.enabled = !(params.enabled === false); + this._jsPlumb.visible = true; + this.element = _jp.getElement(params.source); + this._jsPlumb.uuid = params.uuid; + this._jsPlumb.floatingEndpoint = null; + var inPlaceCopy = null; + if (this._jsPlumb.uuid) params.endpointsByUUID[this._jsPlumb.uuid] = this; + this.elementId = params.elementId; + + this._jsPlumb.connectionCost = params.connectionCost; + this._jsPlumb.connectionsDirected = params.connectionsDirected; + this._jsPlumb.currentAnchorClass = ""; + this._jsPlumb.events = {}; + + var _updateAnchorClass = function () { + // stash old, get new + var oldAnchorClass = _jsPlumb.endpointAnchorClassPrefix + "_" + this._jsPlumb.currentAnchorClass; + this._jsPlumb.currentAnchorClass = this.anchor.getCssClass(); + var anchorClass = _jsPlumb.endpointAnchorClassPrefix + (this._jsPlumb.currentAnchorClass ? "_" + this._jsPlumb.currentAnchorClass : ""); + + this.removeClass(oldAnchorClass); + this.addClass(anchorClass); + // add and remove at the same time to reduce the number of reflows. + jsPlumb.updateClasses(this.element, anchorClass, oldAnchorClass); + }.bind(this); + + this.prepareAnchor = function(anchorParams) { + var a = this._jsPlumb.instance.makeAnchor(anchorParams, this.elementId, _jsPlumb); + a.bind("anchorChanged", function (currentAnchor) { + this.fire("anchorChanged", {endpoint: this, anchor: currentAnchor}); + _updateAnchorClass(); + }.bind(this)); + return a; + }; + + this.setPreparedAnchor = function(anchor, doNotRepaint) { + this._jsPlumb.instance.continuousAnchorFactory.clear(this.elementId); + this.anchor = anchor; + _updateAnchorClass(); + + if (!doNotRepaint) + this._jsPlumb.instance.repaint(this.elementId); + + return this; + }; + + this.setAnchor = function (anchorParams, doNotRepaint) { + var a = this.prepareAnchor(anchorParams); + this.setPreparedAnchor(a, doNotRepaint); + return this; + }; + + var internalHover = function (state) { + if (this.connections.length > 0) { + for (var i = 0; i < this.connections.length; i++) + this.connections[i].setHover(state, false); + } + else + this.setHover(state); + }.bind(this); + + this.bind("mouseover", function () { + internalHover(true); + }); + this.bind("mouseout", function () { + internalHover(false); + }); + + // ANCHOR MANAGER + if (!params._transient) // in place copies, for example, are transient. they will never need to be retrieved during a paint cycle, because they dont move, and then they are deleted. + this._jsPlumb.instance.anchorManager.add(this, this.elementId); + + this.prepareEndpoint = function(ep, typeId) { + var _e = function (t, p) { + var rm = _jsPlumb.getRenderMode(); + if (_jp.Endpoints[rm][t]) return new _jp.Endpoints[rm][t](p); + if (!_jsPlumb.Defaults.DoNotThrowErrors) + throw { msg: "jsPlumb: unknown endpoint type '" + t + "'" }; + }; + + var endpointArgs = { + _jsPlumb: this._jsPlumb.instance, + cssClass: params.cssClass, + container: params.container, + tooltip: params.tooltip, + connectorTooltip: params.connectorTooltip, + endpoint: this + }; + + var endpoint; + + if (_ju.isString(ep)) + endpoint = _e(ep, endpointArgs); + else if (_ju.isArray(ep)) { + endpointArgs = _ju.merge(ep[1], endpointArgs); + endpoint = _e(ep[0], endpointArgs); + } + else { + endpoint = ep.clone(); + } + + // assign a clone function using a copy of endpointArgs. this is used when a drag starts: the endpoint that was dragged is cloned, + // and the clone is left in its place while the original one goes off on a magical journey. + // the copy is to get around a closure problem, in which endpointArgs ends up getting shared by + // the whole world. + //var argsForClone = jsPlumb.extend({}, endpointArgs); + endpoint.clone = function () { + // TODO this, and the code above, can be refactored to be more dry. + if (_ju.isString(ep)) + return _e(ep, endpointArgs); + else if (_ju.isArray(ep)) { + endpointArgs = _ju.merge(ep[1], endpointArgs); + return _e(ep[0], endpointArgs); + } + }.bind(this); + + endpoint.typeId = typeId; + return endpoint; + }; + + this.setEndpoint = function(ep, doNotRepaint) { + var _ep = this.prepareEndpoint(ep); + this.setPreparedEndpoint(_ep, true); + }; + + this.setPreparedEndpoint = function (ep, doNotRepaint) { + if (this.endpoint != null) { + this.endpoint.cleanup(); + this.endpoint.destroy(); + } + this.endpoint = ep; + this.type = this.endpoint.type; + this.canvas = this.endpoint.canvas; + }; + + _jp.extend(this, params, typeParameters); + + this.isSource = params.isSource || false; + this.isTemporarySource = params.isTemporarySource || false; + this.isTarget = params.isTarget || false; + + this.connections = params.connections || []; + this.connectorPointerEvents = params["connector-pointer-events"]; + + this.scope = params.scope || _jsPlumb.getDefaultScope(); + this.timestamp = null; + this.reattachConnections = params.reattach || _jsPlumb.Defaults.ReattachConnections; + this.connectionsDetachable = _jsPlumb.Defaults.ConnectionsDetachable; + if (params.connectionsDetachable === false || params.detachable === false) + this.connectionsDetachable = false; + this.dragAllowedWhenFull = params.dragAllowedWhenFull !== false; + + if (params.onMaxConnections) + this.bind("maxConnections", params.onMaxConnections); + + // + // add a connection. not part of public API. + // + this.addConnection = function (connection) { + this.connections.push(connection); + this[(this.connections.length > 0 ? "add" : "remove") + "Class"](_jsPlumb.endpointConnectedClass); + this[(this.isFull() ? "add" : "remove") + "Class"](_jsPlumb.endpointFullClass); + }; + + this.detachFromConnection = function (connection, idx, doNotCleanup) { + idx = idx == null ? findConnectionIndex(connection, this) : idx; + if (idx >= 0) { + this.connections.splice(idx, 1); + this[(this.connections.length > 0 ? "add" : "remove") + "Class"](_jsPlumb.endpointConnectedClass); + this[(this.isFull() ? "add" : "remove") + "Class"](_jsPlumb.endpointFullClass); + } + + if (!doNotCleanup && this._deleteOnDetach && this.connections.length === 0) { + _jsPlumb.deleteObject({ + endpoint: this, + fireEvent: false, + deleteAttachedObjects: false + }); + } + }; + + this.detach = function (connection, ignoreTarget, forceDetach, fireEvent, originalEvent, endpointBeingDeleted, connectionIndex) { + + var idx = connectionIndex == null ? findConnectionIndex(connection, this) : connectionIndex, + actuallyDetached = false; + fireEvent = (fireEvent !== false); + + if (idx >= 0) { + + if (forceDetach || connection._forceDetach || (connection.isDetachable() && connection.isDetachAllowed(connection) && this.isDetachAllowed(connection) && _jsPlumb.checkCondition("beforeDetach", connection, endpointBeingDeleted) )) { + + _jsPlumb.deleteObject({ + connection: connection, + fireEvent: (!ignoreTarget && fireEvent), + originalEvent: originalEvent, + deleteAttachedObjects: false/**/ + }); + actuallyDetached = true; + } + } + return actuallyDetached; + }; + + this.detachAll = function (fireEvent, forceDetach) { + var unaffectedConns = []; + while (this.connections.length > 0) { + // TODO this could pass the index in to the detach method to save some time (index will always be zero in this while loop) + var actuallyDetached = this.detach(this.connections[0], false, forceDetach === true, fireEvent !== false, null, this, 0); + if (!actuallyDetached) { + unaffectedConns.push(this.connections[0]); + this.connections.splice(0, 1); + } + } + this.connections = unaffectedConns; + return this; + }; + this.detachFrom = function (targetEndpoint, fireEvent, originalEvent) { + var c = []; + for (var i = 0; i < this.connections.length; i++) { + if (this.connections[i].endpoints[1] == targetEndpoint || this.connections[i].endpoints[0] == targetEndpoint) { + c.push(this.connections[i]); + } + } + for (var j = 0; j < c.length; j++) { + this.detach(c[j], false, true, fireEvent, originalEvent); + } + return this; + }; + + this.getElement = function () { + return this.element; + }; + + this.setElement = function (el) { + var parentId = this._jsPlumb.instance.getId(el), + curId = this.elementId; + // remove the endpoint from the list for the current endpoint's element + _ju.removeWithFunction(params.endpointsByElement[this.elementId], function (e) { + return e.id == this.id; + }.bind(this)); + this.element = jsPlumb.getElement(el); + this.elementId = _jsPlumb.getId(this.element); + _jsPlumb.anchorManager.rehomeEndpoint(this, curId, this.element); + _jsPlumb.dragManager.endpointAdded(this.element); + _ju.addToList(params.endpointsByElement, parentId, this); + return this; + }; + + /** + * private but must be exposed. + */ + this.makeInPlaceCopy = function () { + var loc = this.anchor.getCurrentLocation({element: this}), + o = this.anchor.getOrientation(this), + acc = this.anchor.getCssClass(), + inPlaceAnchor = { + bind: function () { + }, + compute: function () { + return [ loc[0], loc[1] ]; + }, + getCurrentLocation: function () { + return [ loc[0], loc[1] ]; + }, + getOrientation: function () { + return o; + }, + getCssClass: function () { + return acc; + } + }; + + return _newEndpoint({ + dropOptions: params.dropOptions, + anchor: inPlaceAnchor, + source: this.element, + paintStyle: this.getPaintStyle(), + endpoint: params.hideOnDrag ? "Blank" : this.endpoint, + _transient: true, + scope: this.scope, + reference:this + }); + }; + + /** + * returns a connection from the pool; used when dragging starts. just gets the head of the array if it can. + */ + this.connectorSelector = function () { + var candidate = this.connections[0]; + // SP target source refactor + if (/*this.isTarget && */candidate) return candidate; + else { + return (this.connections.length < this._jsPlumb.maxConnections) || this._jsPlumb.maxConnections == -1 ? null : candidate; + } + }; + + this.setStyle = this.setPaintStyle; + + this.paint = function (params) { + params = params || {}; + var timestamp = params.timestamp, recalc = !(params.recalc === false); + if (!timestamp || this.timestamp !== timestamp) { + + var info = _jsPlumb.updateOffset({ elId: this.elementId, timestamp: timestamp }); + + var xy = params.offset ? params.offset.o : info.o; + if (xy != null) { + var ap = params.anchorPoint, connectorPaintStyle = params.connectorPaintStyle; + if (ap == null) { + var wh = params.dimensions || info.s, + anchorParams = { xy: [ xy.left, xy.top ], wh: wh, element: this, timestamp: timestamp }; + if (recalc && this.anchor.isDynamic && this.connections.length > 0) { + var c = findConnectionToUseForDynamicAnchor(this, params.elementWithPrecedence), + oIdx = c.endpoints[0] == this ? 1 : 0, + oId = oIdx === 0 ? c.sourceId : c.targetId, + oInfo = _jsPlumb.getCachedData(oId), + oOffset = oInfo.o, oWH = oInfo.s; + anchorParams.txy = [ oOffset.left, oOffset.top ]; + anchorParams.twh = oWH; + anchorParams.tElement = c.endpoints[oIdx]; + } + ap = this.anchor.compute(anchorParams); + } + + this.endpoint.compute(ap, this.anchor.getOrientation(this), this._jsPlumb.paintStyleInUse, connectorPaintStyle || this.paintStyleInUse); + this.endpoint.paint(this._jsPlumb.paintStyleInUse, this.anchor); + this.timestamp = timestamp; + + // paint overlays + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays.hasOwnProperty(i)) { + var o = this._jsPlumb.overlays[i]; + if (o.isVisible()) { + this._jsPlumb.overlayPlacements[i] = o.draw(this.endpoint, this._jsPlumb.paintStyleInUse); + o.paint(this._jsPlumb.overlayPlacements[i]); + } + } + } + } + } + }; + + this.getTypeDescriptor = function () { + return "endpoint"; + }; + this.isVisible = function () { + return this._jsPlumb.visible; + }; + + this.repaint = this.paint; + + var draggingInitialised = false; + this.initDraggable = function (definitionId) { + + // is this a connection source? we make it draggable and have the + // drag listener maintain a connection with a floating endpoint. + if (!draggingInitialised && _jp.isDragSupported(this.element)) { + var placeholderInfo = { id: null, element: null }, + jpc = null, + existingJpc = false, + existingJpcParams = null, + _dragHandler = _makeConnectionDragHandler(placeholderInfo, _jsPlumb), + dragOptions = params.dragOptions || {}, + defaultOpts = {}, + startEvent = _jp.dragEvents.start, + stopEvent = _jp.dragEvents.stop, + dragEvent = _jp.dragEvents.drag; + + var start = function () { + // drag might have started on an endpoint that is not actually a source, but which has + // one or more connections. + jpc = this.connectorSelector(); + var _continue = true; + // if not enabled, return + if (!this.isEnabled()) _continue = false; + // if no connection and we're not a source - or temporarily a source, as is the case with makeSource - return. + if (jpc == null && !this.isSource && !this.isTemporarySource) _continue = false; + // otherwise if we're full and not allowed to drag, also return false. + if (this.isSource && this.isFull() && !(jpc != null && this.dragAllowedWhenFull)) _continue = false; + // if the connection was setup as not detachable or one of its endpoints + // was setup as connectionsDetachable = false, or Defaults.ConnectionsDetachable + // is set to false... + if (jpc != null && !jpc.isDetachable(this)) _continue = false; + + var beforeDrag = _jsPlumb.checkCondition(jpc == null ? "beforeDrag" : "beforeStartDetach", { + endpoint:this, + source:this.element, + sourceId:this.elementId, + connection:jpc + }); + if (beforeDrag === false) _continue = false; + // else we might have been given some data. we'll pass it in to a new connection as 'data'. + + if (_continue === false) { + // this is for mootools and yui. returning false from this causes jquery to stop drag. + // the events are wrapped in both mootools and yui anyway, but i don't think returning + // false from the start callback would stop a drag. + if (_jsPlumb.stopDrag) _jsPlumb.stopDrag(this.canvas); + _dragHandler.stopDrag(); + return false; + } + + // clear hover for all connections for this endpoint before continuing. + for (var i = 0; i < this.connections.length; i++) + this.connections[i].setHover(false); + + this.addClass("endpointDrag"); + _jsPlumb.setConnectionBeingDragged(true); + + // if we're not full but there was a connection, make it null. we'll create a new one. + if (jpc && !this.isFull() && this.isSource) jpc = null; + + _jsPlumb.updateOffset({ elId: this.elementId }); + inPlaceCopy = this.makeInPlaceCopy(); + inPlaceCopy.addClass(_jsPlumb.draggingClass); + inPlaceCopy.referenceEndpoint = this; + inPlaceCopy.paint(); + + _makeDraggablePlaceholder(placeholderInfo, _jsPlumb); + + // set the offset of this div to be where 'inPlaceCopy' is, to start with. + // TODO merge this code with the code in both Anchor and FloatingAnchor, because it + // does the same stuff. + var ipco = this._jsPlumb.instance.getOffset(inPlaceCopy.canvas), + canvasElement = this.canvas; + + jsPlumb.setPosition(placeholderInfo.element, ipco); + + // when using makeSource and a parent, we first draw the source anchor on the source element, then + // move it to the parent. note that this happens after drawing the placeholder for the + // first time. + if (this.parentAnchor) this.anchor = _jsPlumb.makeAnchor(this.parentAnchor, this.elementId, _jsPlumb); + + // store the id of the dragging div and the source element. the drop function will pick these up. + _jsPlumb.setAttributes(this.canvas, { + "dragId": placeholderInfo.id, + "elId": this.elementId + }); + + this._jsPlumb.floatingEndpoint = _makeFloatingEndpoint(this.getPaintStyle(), this.anchor, this.endpoint, this.canvas, placeholderInfo.element, _jsPlumb, _newEndpoint, this.scope); + // TODO we should not know about DOM here. make the library adapter do this (or the + // dom adapter) + this.canvas.style.visibility = "hidden"; + + if (jpc == null) { + this.anchor.locked = true; + this.setHover(false, false); + // create a connection. one end is this endpoint, the other is a floating endpoint. + jpc = _newConnection({ + sourceEndpoint: this, + targetEndpoint: this._jsPlumb.floatingEndpoint, + source: this.endpointWillMoveTo || this.element, // for makeSource with parent option. ensure source element is represented correctly. + target: placeholderInfo.element, + anchors: [ this.anchor, this._jsPlumb.floatingEndpoint.anchor ], + paintStyle: params.connectorStyle, // this can be null. Connection will use the default. + hoverPaintStyle: params.connectorHoverStyle, + connector: params.connector, // this can also be null. Connection will use the default. + overlays: params.connectorOverlays, + type: this.connectionType, + cssClass: this.connectorClass, + hoverClass: this.connectorHoverClass, + data:beforeDrag + }); + //jpc.pending = true; // mark this connection as not having been established. + jpc.addClass(_jsPlumb.draggingClass); + this._jsPlumb.floatingEndpoint.addClass(_jsPlumb.draggingClass); + // fire an event that informs that a connection is being dragged + _jsPlumb.fire("connectionDrag", jpc); + + } else { + existingJpc = true; + jpc.setHover(false); + // new anchor idx + var anchorIdx = jpc.endpoints[0].id == this.id ? 0 : 1; + this.detachFromConnection(jpc, null, true); // detach from the connection while dragging is occurring. but dont cleanup automatically. + + // store the original scope (issue 57) + var dragScope = _jsPlumb.getDragScope(canvasElement); + _jsPlumb.setAttribute(this.canvas, "originalScope", dragScope); + // now we want to get this endpoint's DROP scope, and set it for now: we can only be dropped on drop zones + // that have our drop scope (issue 57). + var dropScope = _jsPlumb.getDropScope(canvasElement); + _jsPlumb.setDragScope(canvasElement, dropScope); + //*/ + + // fire an event that informs that a connection is being dragged. we do this before + // replacing the original target with the floating element info. + _jsPlumb.fire("connectionDrag", jpc); + + // now we replace ourselves with the temporary div we created above: + if (anchorIdx === 0) { + existingJpcParams = [ jpc.source, jpc.sourceId, canvasElement, dragScope ]; + jpc.source = placeholderInfo.element; + jpc.sourceId = placeholderInfo.id; + } else { + existingJpcParams = [ jpc.target, jpc.targetId, canvasElement, dragScope ]; + jpc.target = placeholderInfo.element; + jpc.targetId = placeholderInfo.id; + } + + // lock the other endpoint; if it is dynamic it will not move while the drag is occurring. + jpc.endpoints[anchorIdx === 0 ? 1 : 0].anchor.locked = true; + // store the original endpoint and assign the new floating endpoint for the drag. + jpc.suspendedEndpoint = jpc.endpoints[anchorIdx]; + + // PROVIDE THE SUSPENDED ELEMENT, BE IT A SOURCE OR TARGET (ISSUE 39) + jpc.suspendedElement = jpc.endpoints[anchorIdx].getElement(); + jpc.suspendedElementId = jpc.endpoints[anchorIdx].elementId; + jpc.suspendedElementType = anchorIdx === 0 ? "source" : "target"; + + jpc.suspendedEndpoint.setHover(false); + this._jsPlumb.floatingEndpoint.referenceEndpoint = jpc.suspendedEndpoint; + jpc.endpoints[anchorIdx] = this._jsPlumb.floatingEndpoint; + + jpc.addClass(_jsPlumb.draggingClass); + this._jsPlumb.floatingEndpoint.addClass(_jsPlumb.draggingClass); + } + + // register it and register connection on it. + _jsPlumb.floatingConnections[placeholderInfo.id] = jpc; + _jsPlumb.anchorManager.addFloatingConnection(placeholderInfo.id, jpc); + // only register for the target endpoint; we will not be dragging the source at any time + // before this connection is either discarded or made into a permanent connection. + _ju.addToList(params.endpointsByElement, placeholderInfo.id, this._jsPlumb.floatingEndpoint); + // tell jsplumb about it + _jsPlumb.currentlyDragging = true; + }.bind(this); + + var stop = function () { + _jsPlumb.setConnectionBeingDragged(false); + // if no endpoints, jpc already cleaned up. + if (jpc && jpc.endpoints != null) { + // get the actual drop event (decode from library args to stop function) + var originalEvent = _jsPlumb.getDropEvent(arguments); + // unlock the other endpoint (if it is dynamic, it would have been locked at drag start) + var idx = _jsPlumb.getFloatingAnchorIndex(jpc); + jpc.endpoints[idx === 0 ? 1 : 0].anchor.locked = false; + // TODO: Dont want to know about css classes inside jsplumb, ideally. + jpc.removeClass(_jsPlumb.draggingClass); + + // if we have the floating endpoint then the connection has not been dropped + // on another endpoint. If it is a new connection we throw it away. If it is an + // existing connection we check to see if we should reattach it, throwing it away + // if not. + if (this._jsPlumb && (jpc.deleteConnectionNow || jpc.endpoints[idx] == this._jsPlumb.floatingEndpoint)) { + // 6a. if the connection was an existing one... + if (existingJpc && jpc.suspendedEndpoint) { + // fix for issue35, thanks Sylvain Gizard: when firing the detach event make sure the + // floating endpoint has been replaced. + if (idx === 0) { + jpc.source = existingJpcParams[0]; + jpc.sourceId = existingJpcParams[1]; + } else { + jpc.target = existingJpcParams[0]; + jpc.targetId = existingJpcParams[1]; + } + + var fe = this._jsPlumb.floatingEndpoint; // store for later removal. + // restore the original scope (issue 57) + _jsPlumb.setDragScope(existingJpcParams[2], existingJpcParams[3]); + jpc.endpoints[idx] = jpc.suspendedEndpoint; + // IF the connection should be reattached, or the other endpoint refuses detach, then + // reset the connection to its original state + if (jpc.isReattach() || jpc._forceReattach || jpc._forceDetach || !jpc.endpoints[idx === 0 ? 1 : 0].detach(jpc, false, false, true, originalEvent, true)) { + jpc.setHover(false); + jpc._forceDetach = null; + jpc._forceReattach = null; + this._jsPlumb.floatingEndpoint.detachFromConnection(jpc); + jpc.suspendedEndpoint.addConnection(jpc); + _jsPlumb.repaint(existingJpcParams[1]); + } + else + _jsPlumb.deleteObject({endpoint: fe}); + } + } + + // remove the element associated with the floating endpoint + // (and its associated floating endpoint and visual artefacts) + _jsPlumb.remove(placeholderInfo.element, false); + // remove the inplace copy + _jsPlumb.deleteObject({endpoint: inPlaceCopy}); + + // makeTargets sets this flag, to tell us we have been replaced and should delete ourself. + if (this.deleteAfterDragStop) { + _jsPlumb.deleteObject({endpoint: this}); + } + else { + if (this._jsPlumb) { + this._jsPlumb.floatingEndpoint = null; + // repaint this endpoint. + // make our canvas visible (TODO: hand off to library; we should not know about DOM) + this.canvas.style.visibility = "visible"; + // unlock our anchor + this.anchor.locked = false; + this.paint({recalc: false}); + } + } + + // although the connection is no longer valid, there are use cases where this is useful. + _jsPlumb.fire("connectionDragStop", jpc, originalEvent); + // tell jsplumb that dragging is finished. + _jsPlumb.currentlyDragging = false; + jpc = null; + } + + }.bind(this); + + dragOptions = _jp.extend(defaultOpts, dragOptions); + dragOptions.scope = this.scope || dragOptions.scope; + dragOptions[startEvent] = _ju.wrap(dragOptions[startEvent], start, false); + // extracted drag handler function so can be used by makeSource + dragOptions[dragEvent] = _ju.wrap(dragOptions[dragEvent], _dragHandler.drag); + dragOptions[stopEvent] = _ju.wrap(dragOptions[stopEvent], stop); + dragOptions.multipleDrop = false; + dragOptions.definitionId = definitionId; + + dragOptions.canDrag = function () { + return this.isSource || this.isTemporarySource || /*(this.isTarget && */this.connections.length > 0/*)*/; + }.bind(this); + + _jsPlumb.initDraggable(this.canvas, dragOptions, "internal"); + + this.canvas._jsPlumbRelatedElement = this.element; + + draggingInitialised = true; + } + }; + + var ep = params.endpoint || this._jsPlumb.instance.Defaults.Endpoint || _jp.Defaults.Endpoint; + this.setEndpoint(ep, true); + var anchorParamsToUse = params.anchor ? params.anchor : params.anchors ? params.anchors : (_jsPlumb.Defaults.Anchor || "Top"); + this.setAnchor(anchorParamsToUse, true); + + // finally, set type if it was provided + var type = [ "default", (params.type || "")].join(" "); + this.addType(type, params.data, true); + this.canvas = this.endpoint.canvas; + this.canvas._jsPlumb = this; + + // if marked as source or target at create time, init the dragging. + if (this.isSource || this.isTarget || this.isTemporarySource) + this.initDraggable(this.isTarget ? "_jsPlumbTarget" : "_jsPlumbSource"); + + // pulled this out into a function so we can reuse it for the inPlaceCopy canvas; you can now drop detached connections + // back onto the endpoint you detached it from. + var _initDropTarget = function (canvas, forceInit, isTransient, endpoint, referenceEndpoint) { + + if ((this.isTarget || forceInit) && _jp.isDropSupported(this.element)) { + var dropOptions = params.dropOptions || _jsPlumb.Defaults.DropOptions || _jp.Defaults.DropOptions; + dropOptions = _jp.extend({}, dropOptions); + dropOptions.scope = dropOptions.scope || this.scope; + var dropEvent = _jp.dragEvents.drop, + overEvent = _jp.dragEvents.over, + outEvent = _jp.dragEvents.out, + _ep = this, + drop = _jsPlumb.EndpointDropHandler({ + getEndpoint: function () { + return _ep; + }, + jsPlumb: _jsPlumb, + enabled: function () { + return endpoint != null ? endpoint.isEnabled() : true; + }, + isFull: function () { + return endpoint.isFull(); + }, + element: this.element, + elementId: this.elementId, + isSource: this.isSource, + isTarget: this.isTarget, + addClass: function (clazz) { + _ep.addClass(clazz); + }, + removeClass: function (clazz) { + _ep.removeClass(clazz); + }, + isDropAllowed: function () { + return _ep.isDropAllowed.apply(_ep, arguments); + }, + reference:referenceEndpoint, + isRedrop:function(jpc, dhParams) { + return jpc.suspendedEndpoint && dhParams.reference && (jpc.suspendedEndpoint.id === dhParams.reference.id); + } + }); + + dropOptions[dropEvent] = _ju.wrap(dropOptions[dropEvent], drop, true); + dropOptions[overEvent] = _ju.wrap(dropOptions[overEvent], function () { + var draggable = _jp.getDragObject(arguments), + id = _jsPlumb.getAttribute(_jp.getElement(draggable), "dragId"), + _jpc = _jsPlumb.floatingConnections[id]; + + if (_jpc != null) { + var idx = _jsPlumb.getFloatingAnchorIndex(_jpc); + // here we should fire the 'over' event if we are a target and this is a new connection, + // or we are the same as the floating endpoint. + var _cont = (this.isTarget && idx !== 0) || (_jpc.suspendedEndpoint && this.referenceEndpoint && this.referenceEndpoint.id == _jpc.suspendedEndpoint.id); + if (_cont) { + var bb = _jsPlumb.checkCondition("checkDropAllowed", { + sourceEndpoint: _jpc.endpoints[idx], + targetEndpoint: this, + connection: _jpc + }); + this[(bb ? "add" : "remove") + "Class"](_jsPlumb.endpointDropAllowedClass); + this[(bb ? "remove" : "add") + "Class"](_jsPlumb.endpointDropForbiddenClass); + _jpc.endpoints[idx].anchor.over(this.anchor, this); + } + } + }.bind(this)); + + dropOptions[outEvent] = _ju.wrap(dropOptions[outEvent], function () { + var draggable = _jp.getDragObject(arguments), + id = draggable == null ? null : _jsPlumb.getAttribute(_jp.getElement(draggable), "dragId"), + _jpc = id ? _jsPlumb.floatingConnections[id] : null; + + if (_jpc != null) { + var idx = _jsPlumb.getFloatingAnchorIndex(_jpc); + var _cont = (this.isTarget && idx !== 0) || (_jpc.suspendedEndpoint && this.referenceEndpoint && this.referenceEndpoint.id == _jpc.suspendedEndpoint.id); + if (_cont) { + this.removeClass(_jsPlumb.endpointDropAllowedClass); + this.removeClass(_jsPlumb.endpointDropForbiddenClass); + _jpc.endpoints[idx].anchor.out(); + } + } + }.bind(this)); + + _jsPlumb.initDroppable(canvas, dropOptions, "internal", isTransient); + } + }.bind(this); + + // Initialise the endpoint's canvas as a drop target. The drop handler will take care of the logic of whether + // something can actually be dropped. + if (!this.anchor.isFloating) + _initDropTarget(this.canvas, true, !(params._transient || this.anchor.isFloating), this, params.reference); + + + return this; + }; + + _ju.extend(_jp.Endpoint, _jp.OverlayCapableJsPlumbUIComponent, { + + setVisible: function (v, doNotChangeConnections, doNotNotifyOtherEndpoint) { + this._jsPlumb.visible = v; + if (this.canvas) this.canvas.style.display = v ? "block" : "none"; + this[v ? "showOverlays" : "hideOverlays"](); + if (!doNotChangeConnections) { + for (var i = 0; i < this.connections.length; i++) { + this.connections[i].setVisible(v); + if (!doNotNotifyOtherEndpoint) { + var oIdx = this === this.connections[i].endpoints[0] ? 1 : 0; + // only change the other endpoint if this is its only connection. + if (this.connections[i].endpoints[oIdx].connections.length == 1) this.connections[i].endpoints[oIdx].setVisible(v, true, true); + } + } + } + }, + getAttachedElements: function () { + return this.connections; + }, + applyType: function (t, doNotRepaint) { + this.setPaintStyle(t.endpointStyle || t.paintStyle, doNotRepaint); + this.setHoverPaintStyle(t.endpointHoverStyle || t.hoverPaintStyle, doNotRepaint); + if (t.maxConnections != null) this._jsPlumb.maxConnections = t.maxConnections; + if (t.scope) this.scope = t.scope; + _jp.extend(this, t, typeParameters); + if (t.cssClass != null && this.canvas) this._jsPlumb.instance.addClass(this.canvas, t.cssClass); + _jp.OverlayCapableJsPlumbUIComponent.applyType(this, t); + }, + isEnabled: function () { + return this._jsPlumb.enabled; + }, + setEnabled: function (e) { + this._jsPlumb.enabled = e; + }, + cleanup: function () { + var anchorClass = this._jsPlumb.instance.endpointAnchorClassPrefix + (this._jsPlumb.currentAnchorClass ? "_" + this._jsPlumb.currentAnchorClass : ""); + jsPlumb.removeClass(this.element, anchorClass); + this.anchor = null; + this.endpoint.cleanup(); + this.endpoint.destroy(); + this.endpoint = null; + // drag/drop + this._jsPlumb.instance.destroyDraggable(this.canvas, "internal"); + this._jsPlumb.instance.destroyDroppable(this.canvas, "internal"); + }, + setHover: function (h) { + if (this.endpoint && this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) + this.endpoint.setHover(h); + }, + isFull: function () { + return this._jsPlumb.maxConnections === 0 ? true : !(this.isFloating() || this._jsPlumb.maxConnections < 0 || this.connections.length < this._jsPlumb.maxConnections); + }, + /** + * private but needs to be exposed. + */ + isFloating: function () { + return this.anchor != null && this.anchor.isFloating; + }, + isConnectedTo: function (endpoint) { + var found = false; + if (endpoint) { + for (var i = 0; i < this.connections.length; i++) { + if (this.connections[i].endpoints[1] == endpoint || this.connections[i].endpoints[0] == endpoint) { + found = true; + break; + } + } + } + return found; + }, + getConnectionCost: function () { + return this._jsPlumb.connectionCost; + }, + setConnectionCost: function (c) { + this._jsPlumb.connectionCost = c; + }, + areConnectionsDirected: function () { + return this._jsPlumb.connectionsDirected; + }, + setConnectionsDirected: function (b) { + this._jsPlumb.connectionsDirected = b; + }, + setElementId: function (_elId) { + this.elementId = _elId; + this.anchor.elementId = _elId; + }, + setReferenceElement: function (_el) { + this.element = _jp.getElement(_el); + }, + setDragAllowedWhenFull: function (allowed) { + this.dragAllowedWhenFull = allowed; + }, + equals: function (endpoint) { + return this.anchor.equals(endpoint.anchor); + }, + getUuid: function () { + return this._jsPlumb.uuid; + }, + computeAnchor: function (params) { + return this.anchor.compute(params); + } + }); + + root.jsPlumbInstance.prototype.EndpointDropHandler = function (dhParams) { + return function (e) { + + var _jsPlumb = dhParams.jsPlumb; + + // remove the classes that are added dynamically. drop is neither forbidden nor allowed now that + // the drop is finishing. + // makeTarget:probably keep these. 'this' would refer to the DOM element though + dhParams.removeClass(_jsPlumb.endpointDropAllowedClass); + dhParams.removeClass(_jsPlumb.endpointDropForbiddenClass); + + var originalEvent = _jsPlumb.getDropEvent(arguments), + draggable = _jsPlumb.getDragObject(arguments), + id = _jsPlumb.getAttribute(draggable, "dragId"), + elId = _jsPlumb.getAttribute(draggable, "elId"), + scope = _jsPlumb.getAttribute(draggable, "originalScope"), + jpc = _jsPlumb.floatingConnections[id]; + + // if no active connection, bail. + if (jpc == null) return; + + // if drag type matches drop type and this is not a new connection (meaning it has a suspendedEndpoint) + // then bail + if (e.drag && e.drop) { + if (e.drag.params.definitionId === e.drop.params.definitionId && jpc.suspendedEndpoint == null) return; + } + + // if suspended endpoint has been cleaned up, bail. + if (jpc.suspendedEndpoint && jpc.suspendedEndpoint._jsPlumb == null) return; + + // get the drop endpoint. for a normal connection this is just the one that would replace the currently + // floating endpoint. for a makeTarget this is a new endpoint that is created on drop. + var _ep = dhParams.getEndpoint(jpc); + + // if this is a drop back where the connection came from, mark it force reattach and + // return; the stop handler will reattach. without firing an event. + //var redrop + //var redrop = jpc.suspendedEndpoint && dhParams.reference && (jpc.suspendedEndpoint.id === dhParams.reference.id); + //var redrop = jpc.suspendedEndpoint && (jpc.suspendedEndpoint.elementId === dhParams.elementId); + //if (redrop) { + if (dhParams.isRedrop(jpc, dhParams)) { + jpc._forceReattach = true; + jpc.setHover(false); + if (dhParams.maybeCleanup) dhParams.maybeCleanup(_ep); + return; + } + + // ensure we dont bother trying to drop sources on non-source eps, and same for target. + var idx = _jsPlumb.getFloatingAnchorIndex(jpc); + if (idx === 0 && !dhParams.isSource) return; + if (idx === 1 && !dhParams.isTarget) return; + + if (dhParams.onDrop) dhParams.onDrop(jpc); + + // restore the original scope if necessary (issue 57) + if (scope) _jsPlumb.setDragScope(draggable, scope); + + // if the target of the drop is full, fire an event (we abort below) + // makeTarget: keep. + if (dhParams.isFull(e)) { + _ep.fire("maxConnections", { + endpoint: this, + connection: jpc, + maxConnections: _ep._jsPlumb.maxConnections + }, originalEvent); + } + + // + // if endpoint enabled, not full, and matches the index of the floating endpoint... + if (!dhParams.isFull() && !(idx === 0 && !dhParams.isSource) && !(idx == 1 && !dhParams.isTarget) && dhParams.enabled()) { + var _doContinue = true; + + // these have to be set before testing for beforeDrop. + if (idx === 0) { + jpc.source = dhParams.element; + jpc.sourceId = dhParams.elementId; + } else { + jpc.target = dhParams.element; + jpc.targetId = dhParams.elementId; + } + + // if this is an existing connection and detach is not allowed we won't continue. The connection's + // endpoints have been reinstated; everything is back to how it was. + if (jpc.suspendedEndpoint && jpc.suspendedEndpoint._jsPlumb && jpc.suspendedEndpoint.id != _ep.id) { + + if (!jpc.isDetachAllowed(jpc) || !jpc.endpoints[idx].isDetachAllowed(jpc) || !jpc.suspendedEndpoint.isDetachAllowed(jpc) || !_jsPlumb.checkCondition("beforeDetach", jpc)) + _doContinue = false; + } + +// ------------ wrap the execution path in a function so we can support asynchronous beforeDrop + + var continueFunction = function (optionalData) { + // remove this jpc from the current endpoint, which is a floating endpoint that we will + // subsequently discard. + jpc.endpoints[idx].detachFromConnection(jpc); + + // if there's a suspended endpoint, detach it from the connection. + if (jpc.suspendedEndpoint) jpc.suspendedEndpoint.detachFromConnection(jpc); + // TODO why? + + jpc.endpoints[idx] = _ep; + _ep.addConnection(jpc); + + // copy our parameters in to the connection: + var params = _ep.getParameters(); + for (var aParam in params) + jpc.setParameter(aParam, params[aParam]); + + if (!jpc.suspendedEndpoint) { + // if not an existing connection and + if (params.draggable) + _jsPlumb.initDraggable(this.element, dragOptions, "internal", _jsPlumb); + } + else { + var suspendedElementId = jpc.suspendedEndpoint.elementId; + _jsPlumb.fireMoveEvent({ + index: idx, + originalSourceId: idx === 0 ? suspendedElementId : jpc.sourceId, + newSourceId: idx === 0 ? _ep.elementId : jpc.sourceId, + originalTargetId: idx == 1 ? suspendedElementId : jpc.targetId, + newTargetId: idx == 1 ? _ep.elementId : jpc.targetId, + originalSourceEndpoint: idx === 0 ? jpc.suspendedEndpoint : jpc.endpoints[0], + newSourceEndpoint: idx === 0 ? _ep : jpc.endpoints[0], + originalTargetEndpoint: idx == 1 ? jpc.suspendedEndpoint : jpc.endpoints[1], + newTargetEndpoint: idx == 1 ? _ep : jpc.endpoints[1], + connection: jpc + }, originalEvent); + } + + if (idx == 1) + _jsPlumb.anchorManager.updateOtherEndpoint(jpc.sourceId, jpc.suspendedElementId, jpc.targetId, jpc); + else + _jsPlumb.anchorManager.sourceChanged(jpc.suspendedEndpoint.elementId, jpc.sourceId, jpc); + + // when makeSource has uniqueEndpoint:true, we want to create connections with new endpoints + // that are subsequently deleted. So makeSource sets `finalEndpoint`, which is the Endpoint to + // which the connection should be attached. The `detachFromConnection` call below results in the + // temporary endpoint being cleaned up. + if (jpc.endpoints[0].finalEndpoint) { + var _toDelete = jpc.endpoints[0]; + _toDelete.detachFromConnection(jpc); + jpc.endpoints[0] = jpc.endpoints[0].finalEndpoint; + jpc.endpoints[0].addConnection(jpc); + } + + // if optionalData was given, merge it onto the connection's data. + if (jsPlumbUtil.isObject(optionalData)) { + jpc.mergeData(optionalData); + } + + // finalise will inform the anchor manager and also add to + // connectionsByScope if necessary. + // TODO if this is not set to true, then dragging a connection's target to a new + // target causes the connection to be forgotten. however if it IS set to true, then + // the opposite happens: dragging by source causes the connection to get forgotten + // about and then if you delete it jsplumb breaks. + _jsPlumb.finaliseConnection(jpc, null, originalEvent/*, true*/); + jpc.setHover(false); + + }.bind(this); + + var dontContinueFunction = function () { + // otherwise just put it back on the endpoint it was on before the drag. + if (jpc.suspendedEndpoint) { + jpc.endpoints[idx] = jpc.suspendedEndpoint; + jpc.setHover(false); + jpc._forceDetach = true; + if (idx === 0) { + jpc.source = jpc.suspendedEndpoint.element; + jpc.sourceId = jpc.suspendedEndpoint.elementId; + } else { + jpc.target = jpc.suspendedEndpoint.element; + jpc.targetId = jpc.suspendedEndpoint.elementId; + } + jpc.suspendedEndpoint.addConnection(jpc); + + _jsPlumb.repaint(jpc.sourceId); + jpc._forceDetach = false; + } + }; + +// -------------------------------------- + // now check beforeDrop. this will be available only on Endpoints that are setup to + // have a beforeDrop condition (although, secretly, under the hood all Endpoints and + // the Connection have them, because they are on jsPlumbUIComponent. shhh!), because + // it only makes sense to have it on a target endpoint. + _doContinue = _doContinue && dhParams.isDropAllowed(jpc.sourceId, jpc.targetId, jpc.scope, jpc, _ep);// && jpc.pending; + + if (_doContinue) { + continueFunction(_doContinue); + return true; + } + else { + dontContinueFunction(); + } + } + + if (dhParams.maybeCleanup) dhParams.maybeCleanup(_ep); + + _jsPlumb.currentlyDragging = false; + }; + }; +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for Connections. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://jsplumb.org + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, + _jp = root.jsPlumb, + _ju = root.jsPlumbUtil; + + + var makeConnector = function (_jsPlumb, renderMode, connectorName, connectorArgs, forComponent) { + if (!_jsPlumb.Defaults.DoNotThrowErrors && jsPlumb.Connectors[renderMode][connectorName] == null) + throw { msg: "jsPlumb: unknown connector type '" + connectorName + "'" }; + + return new _jp.Connectors[renderMode][connectorName](connectorArgs, forComponent); + }, + _makeAnchor = function (anchorParams, elementId, _jsPlumb) { + return (anchorParams) ? _jsPlumb.makeAnchor(anchorParams, elementId, _jsPlumb) : null; + }, + _updateConnectedClass = function (conn, element, _jsPlumb, remove) { + if (element != null) { + element._jsPlumbConnections = element._jsPlumbConnections || {}; + if (remove) + delete element._jsPlumbConnections[conn.id]; + else + element._jsPlumbConnections[conn.id] = true; + + if (_ju.isEmpty(element._jsPlumbConnections)) { + _jsPlumb.removeClass(element, _jsPlumb.connectedClass); + } + else + _jsPlumb.addClass(element, _jsPlumb.connectedClass); + } + }; + + _jp.Connection = function (params) { + var _newEndpoint = params.newEndpoint; + + this.id = params.id; + this.connector = null; + this.idPrefix = "_jsplumb_c_"; + this.defaultLabelLocation = 0.5; + this.defaultOverlayKeys = ["Overlays", "ConnectionOverlays"]; + // if a new connection is the result of moving some existing connection, params.previousConnection + // will have that Connection in it. listeners for the jsPlumbConnection event can look for that + // member and take action if they need to. + this.previousConnection = params.previousConnection; + this.source = _jp.getElement(params.source); + this.target = _jp.getElement(params.target); + // sourceEndpoint and targetEndpoint override source/target, if they are present. but + // source is not overridden if the Endpoint has declared it is not the final target of a connection; + // instead we use the source that the Endpoint declares will be the final source element. + if (params.sourceEndpoint) this.source = params.sourceEndpoint.getElement(); + if (params.targetEndpoint) this.target = params.targetEndpoint.getElement(); + + _jp.OverlayCapableJsPlumbUIComponent.apply(this, arguments); + + this.sourceId = this._jsPlumb.instance.getId(this.source); + this.targetId = this._jsPlumb.instance.getId(this.target); + this.scope = params.scope; // scope may have been passed in to the connect call. if it wasn't, we will pull it from the source endpoint, after having initialised the endpoints. + this.endpoints = []; + this.endpointStyles = []; + + var _jsPlumb = this._jsPlumb.instance; + + _jsPlumb.manage(this.sourceId, this.source); + _jsPlumb.manage(this.targetId, this.target); + + this._jsPlumb.visible = true; + this._jsPlumb.editable = params.editable === true; + this._jsPlumb.params = { + cssClass: params.cssClass, + container: params.container, + "pointer-events": params["pointer-events"], + editorParams: params.editorParams, + overlays: params.overlays + }; + this._jsPlumb.lastPaintedAt = null; + + // listen to mouseover and mouseout events passed from the container delegate. + this.bind("mouseover", function () { + this.setHover(true); + }.bind(this)); + this.bind("mouseout", function () { + this.setHover(false); + }.bind(this)); + +// INITIALISATION CODE + + this.makeEndpoint = function (isSource, el, elId, ep) { + elId = elId || this._jsPlumb.instance.getId(el); + return this.prepareEndpoint(_jsPlumb, _newEndpoint, this, ep, isSource ? 0 : 1, params, el, elId); + }; + + var eS = this.makeEndpoint(true, this.source, this.sourceId, params.sourceEndpoint), + eT = this.makeEndpoint(false, this.target, this.targetId, params.targetEndpoint); + + if (eS) _ju.addToList(params.endpointsByElement, this.sourceId, eS); + if (eT) _ju.addToList(params.endpointsByElement, this.targetId, eT); + // if scope not set, set it to be the scope for the source endpoint. + if (!this.scope) this.scope = this.endpoints[0].scope; + + // if explicitly told to (or not to) delete endpoints on detach, override endpoint's preferences + if (params.deleteEndpointsOnDetach != null) { + this.endpoints[0]._deleteOnDetach = params.deleteEndpointsOnDetach; + this.endpoints[1]._deleteOnDetach = params.deleteEndpointsOnDetach; + } + else { + // otherwise, unless the endpoints say otherwise, mark them for deletion. + if (!this.endpoints[0]._doNotDeleteOnDetach) this.endpoints[0]._deleteOnDetach = true; + if (!this.endpoints[1]._doNotDeleteOnDetach) this.endpoints[1]._deleteOnDetach = true; + } + +// -------------------------- DEFAULT TYPE --------------------------------------------- + + // DETACHABLE + var _detachable = _jsPlumb.Defaults.ConnectionsDetachable; + if (params.detachable === false) _detachable = false; + if (this.endpoints[0].connectionsDetachable === false) _detachable = false; + if (this.endpoints[1].connectionsDetachable === false) _detachable = false; + // REATTACH + var _reattach = params.reattach || this.endpoints[0].reattachConnections || this.endpoints[1].reattachConnections || _jsPlumb.Defaults.ReattachConnections; + + this.appendToDefaultType({ + detachable: _detachable, + rettach: _reattach, + paintStyle:this.endpoints[0].connectorStyle || this.endpoints[1].connectorStyle || params.paintStyle || _jsPlumb.Defaults.PaintStyle || jsPlumb.Defaults.PaintStyle, + hoverPaintStyle:this.endpoints[0].connectorHoverStyle || this.endpoints[1].connectorHoverStyle || params.hoverPaintStyle || _jsPlumb.Defaults.HoverPaintStyle || jsPlumb.Defaults.HoverPaintStyle + }); + + + var _suspendedAt = _jsPlumb.getSuspendedAt(); + if (!_jsPlumb.isSuspendDrawing()) { + // paint the endpoints + var myInfo = _jsPlumb.getCachedData(this.sourceId), + myOffset = myInfo.o, myWH = myInfo.s, + otherInfo = _jsPlumb.getCachedData(this.targetId), + otherOffset = otherInfo.o, + otherWH = otherInfo.s, + initialTimestamp = _suspendedAt || _jsPlumb.timestamp(), + anchorLoc = this.endpoints[0].anchor.compute({ + xy: [ myOffset.left, myOffset.top ], wh: myWH, element: this.endpoints[0], + elementId: this.endpoints[0].elementId, + txy: [ otherOffset.left, otherOffset.top ], twh: otherWH, tElement: this.endpoints[1], + timestamp: initialTimestamp + }); + + this.endpoints[0].paint({ anchorLoc: anchorLoc, timestamp: initialTimestamp }); + + anchorLoc = this.endpoints[1].anchor.compute({ + xy: [ otherOffset.left, otherOffset.top ], wh: otherWH, element: this.endpoints[1], + elementId: this.endpoints[1].elementId, + txy: [ myOffset.left, myOffset.top ], twh: myWH, tElement: this.endpoints[0], + timestamp: initialTimestamp + }); + this.endpoints[1].paint({ anchorLoc: anchorLoc, timestamp: initialTimestamp }); + } + + this.getTypeDescriptor = function () { + return "connection"; + }; + this.getAttachedElements = function () { + return this.endpoints; + }; + + this.isDetachable = function () { + return this._jsPlumb.detachable === true; + }; + this.setDetachable = function (detachable) { + this._jsPlumb.detachable = detachable === true; + }; + this.isReattach = function () { + return this._jsPlumb.reattach === true || this.endpoints[0].reattachConnections === true || this.endpoints[1].reattachConnections === true; + }; + this.setReattach = function (reattach) { + this._jsPlumb.reattach = reattach === true; + }; + +// END INITIALISATION CODE + + +// COST + DIRECTIONALITY + // if cost not supplied, try to inherit from source endpoint + this._jsPlumb.cost = params.cost || this.endpoints[0].getConnectionCost(); + this._jsPlumb.directed = params.directed; + // inherit directed flag if set no source endpoint + if (params.directed == null) this._jsPlumb.directed = this.endpoints[0].areConnectionsDirected(); +// END COST + DIRECTIONALITY + +// PARAMETERS + // merge all the parameters objects into the connection. parameters set + // on the connection take precedence; then source endpoint params, then + // finally target endpoint params. + var _p = jsPlumb.extend({}, this.endpoints[1].getParameters()); + _jp.extend(_p, this.endpoints[0].getParameters()); + _jp.extend(_p, this.getParameters()); + this.setParameters(_p); +// END PARAMETERS + +// PAINTING + + this.setConnector(this.endpoints[0].connector || this.endpoints[1].connector || params.connector || _jsPlumb.Defaults.Connector || _jp.Defaults.Connector, true); + var data = params.data == null || !jsPlumbUtil.isObject(params.data) ? {} : params.data; + this.getData = function() { return data; }; + this.setData = function(d) { data = d || {}; }; + this.mergeData = function(d) { data = jsPlumb.extend(data, d); }; + + // the very last thing we do is apply types, if there are any. + var _types = [ "default", params.type, this.endpoints[0].connectionType, this.endpoints[1].connectionType ].join(" "); + if (/[^\s]/.test(_types)) + this.addType(_types, params.data, true); + + this.updateConnectedClass(); + +// END PAINTING + }; + + _ju.extend(_jp.Connection, _jp.OverlayCapableJsPlumbUIComponent, { + applyType: function (t, doNotRepaint, typeMap) { + + // none of these things result in the creation of objects so can be ignored. + if (t.detachable != null) this.setDetachable(t.detachable); + if (t.reattach != null) this.setReattach(t.reattach); + if (t.scope) this.scope = t.scope; + + if (t.cssClass != null && this.canvas) this._jsPlumb.instance.addClass(this.canvas, t.cssClass); + + var _anchors = null; + // this also results in the creation of objects. + if (t.anchor) { + // note that even if the param was anchor, we store `anchors`. + _anchors = this.getCachedTypeItem("anchors", typeMap.anchor); + if (_anchors == null) { + _anchors = [ this._jsPlumb.instance.makeAnchor(t.anchor), this._jsPlumb.instance.makeAnchor(t.anchor) ]; + this.cacheTypeItem("anchors", _anchors, typeMap.anchor); + } + } + else if (t.anchors) { + _anchors = this.getCachedTypeItem("anchors", typeMap.anchors); + if (_anchors == null) { + _anchors = [ + this._jsPlumb.instance.makeAnchor(t.anchors[0]), + this._jsPlumb.instance.makeAnchor(t.anchors[1]) + ]; + this.cacheTypeItem("anchors", _anchors, typeMap.anchors); + } + } + if (_anchors != null) { + this.endpoints[0].anchor = _anchors[0]; + this.endpoints[1].anchor = _anchors[1]; + } + + _jp.OverlayCapableJsPlumbUIComponent.applyType(this, t); + }, + addClass: function (c, informEndpoints) { + if (informEndpoints) { + this.endpoints[0].addClass(c); + this.endpoints[1].addClass(c); + if (this.suspendedEndpoint) this.suspendedEndpoint.addClass(c); + } + if (this.connector) { + this.connector.addClass(c); + } + }, + removeClass: function (c, informEndpoints) { + if (informEndpoints) { + this.endpoints[0].removeClass(c); + this.endpoints[1].removeClass(c); + if (this.suspendedEndpoint) this.suspendedEndpoint.removeClass(c); + } + if (this.connector) { + this.connector.removeClass(c); + } + }, + isVisible: function () { + return this._jsPlumb.visible; + }, + setVisible: function (v) { + this._jsPlumb.visible = v; + if (this.connector) + this.connector.setVisible(v); + this.repaint(); + }, + cleanup: function () { + this.updateConnectedClass(true); + this.endpoints = null; + this.source = null; + this.target = null; + if (this.connector != null) { + this.connector.cleanup(true); + this.connector.destroy(true); + } + this.connector = null; + }, + updateConnectedClass:function(remove) { + _updateConnectedClass(this, this.source, this._jsPlumb.instance, remove); + _updateConnectedClass(this, this.target, this._jsPlumb.instance, remove); + }, + setHover: function (state) { + if (this.connector && this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) { + this.connector.setHover(state); + root.jsPlumb[state ? "addClass" : "removeClass"](this.source, this._jsPlumb.instance.hoverSourceClass); + root.jsPlumb[state ? "addClass" : "removeClass"](this.target, this._jsPlumb.instance.hoverTargetClass); + } + }, + getUuids:function() { + return [ this.endpoints[0].getUuid(), this.endpoints[1].getUuid() ]; + }, + getCost: function () { + return this._jsPlumb.cost; + }, + setCost: function (c) { + this._jsPlumb.cost = c; + }, + isDirected: function () { + return this._jsPlumb.directed === true; + }, + getConnector: function () { + return this.connector; + }, + prepareConnector:function(connectorSpec, typeId) { + var connectorArgs = { + _jsPlumb: this._jsPlumb.instance, + cssClass: this._jsPlumb.params.cssClass, + container: this._jsPlumb.params.container, + "pointer-events": this._jsPlumb.params["pointer-events"] + }, + renderMode = this._jsPlumb.instance.getRenderMode(), + connector; + + if (_ju.isString(connectorSpec)) + connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec, connectorArgs, this); // lets you use a string as shorthand. + else if (_ju.isArray(connectorSpec)) { + if (connectorSpec.length == 1) + connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec[0], connectorArgs, this); + else + connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec[0], _ju.merge(connectorSpec[1], connectorArgs), this); + } + if (typeId != null) connector.typeId = typeId; + return connector; + }, + setPreparedConnector: function(connector, doNotRepaint, doNotChangeListenerComponent, typeId) { + + var previous; + // the connector will not be cleaned up if it was set as part of a type, because `typeId` will be set on it + // and we havent passed in `true` for "force" here. + if (this.connector != null) { + previous = this.connector; + this.connector.cleanup(); + this.connector.destroy(); + } + + this.connector = connector; + if (typeId) { + this.cacheTypeItem("connector", connector, typeId); + } + + this.canvas = this.connector.canvas; + this.bgCanvas = this.connector.bgCanvas; + + // new: instead of binding listeners per connector, we now just have one delegate on the container. + // so for that handler we set the connection as the '_jsPlumb' member of the canvas element, and + // bgCanvas, if it exists, which it does right now in the VML renderer, so it won't from v 2.0.0 onwards. + if (this.canvas) this.canvas._jsPlumb = this; + if (this.bgCanvas) this.bgCanvas._jsPlumb = this; + + if (previous != null) { + var o = this.getOverlays(); + for (var i = 0; i < o.length; i++) { + if (o[i].transfer) o[i].transfer(this.connector); + } + } + + if (!doNotChangeListenerComponent) this.setListenerComponent(this.connector); + if (!doNotRepaint) this.repaint(); + }, + setConnector: function (connectorSpec, doNotRepaint, doNotChangeListenerComponent, typeId) { + var connector = this.prepareConnector(connectorSpec, typeId); + this.setPreparedConnector(connector, doNotRepaint, doNotChangeListenerComponent, typeId); + }, + paint: function (params) { + + if (!this._jsPlumb.instance.isSuspendDrawing() && this._jsPlumb.visible) { + params = params || {}; + var timestamp = params.timestamp, + // if the moving object is not the source we must transpose the two references. + swap = false, + tId = swap ? this.sourceId : this.targetId, sId = swap ? this.targetId : this.sourceId, + tIdx = swap ? 0 : 1, sIdx = swap ? 1 : 0; + + if (timestamp == null || timestamp != this._jsPlumb.lastPaintedAt) { + var sourceInfo = this._jsPlumb.instance.updateOffset({elId:sId}).o, + targetInfo = this._jsPlumb.instance.updateOffset({elId:tId}).o, + sE = this.endpoints[sIdx], tE = this.endpoints[tIdx]; + + var sAnchorP = sE.anchor.getCurrentLocation({xy: [sourceInfo.left, sourceInfo.top], wh: [sourceInfo.width, sourceInfo.height], element: sE, timestamp: timestamp}), + tAnchorP = tE.anchor.getCurrentLocation({xy: [targetInfo.left, targetInfo.top], wh: [targetInfo.width, targetInfo.height], element: tE, timestamp: timestamp}); + + this.connector.resetBounds(); + + this.connector.compute({ + sourcePos: sAnchorP, + targetPos: tAnchorP, + sourceEndpoint: this.endpoints[sIdx], + targetEndpoint: this.endpoints[tIdx], + lineWidth: this._jsPlumb.paintStyleInUse.lineWidth, + sourceInfo: sourceInfo, + targetInfo: targetInfo + }); + + var overlayExtents = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity }; + + // compute overlays. we do this first so we can get their placements, and adjust the + // container if needs be (if an overlay would be clipped) + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays.hasOwnProperty(i)) { + var o = this._jsPlumb.overlays[i]; + if (o.isVisible()) { + this._jsPlumb.overlayPlacements[i] = o.draw(this.connector, this._jsPlumb.paintStyleInUse, this.getAbsoluteOverlayPosition(o)); + overlayExtents.minX = Math.min(overlayExtents.minX, this._jsPlumb.overlayPlacements[i].minX); + overlayExtents.maxX = Math.max(overlayExtents.maxX, this._jsPlumb.overlayPlacements[i].maxX); + overlayExtents.minY = Math.min(overlayExtents.minY, this._jsPlumb.overlayPlacements[i].minY); + overlayExtents.maxY = Math.max(overlayExtents.maxY, this._jsPlumb.overlayPlacements[i].maxY); + } + } + } + + var lineWidth = parseFloat(this._jsPlumb.paintStyleInUse.lineWidth || 1) / 2, + outlineWidth = parseFloat(this._jsPlumb.paintStyleInUse.lineWidth || 0), + extents = { + xmin: Math.min(this.connector.bounds.minX - (lineWidth + outlineWidth), overlayExtents.minX), + ymin: Math.min(this.connector.bounds.minY - (lineWidth + outlineWidth), overlayExtents.minY), + xmax: Math.max(this.connector.bounds.maxX + (lineWidth + outlineWidth), overlayExtents.maxX), + ymax: Math.max(this.connector.bounds.maxY + (lineWidth + outlineWidth), overlayExtents.maxY) + }; + // paint the connector. + this.connector.paint(this._jsPlumb.paintStyleInUse, null, extents); + // and then the overlays + for (var j in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays.hasOwnProperty(j)) { + var p = this._jsPlumb.overlays[j]; + if (p.isVisible()) { + p.paint(this._jsPlumb.overlayPlacements[j], extents); + } + } + } + } + this._jsPlumb.lastPaintedAt = timestamp; + } + }, + repaint: function (params) { + params = params || {}; + this.paint({ elId: this.sourceId, recalc: !(params.recalc === false), timestamp: params.timestamp}); + }, + prepareEndpoint: function (_jsPlumb, _newEndpoint, conn, existing, index, params, element, elementId) { + var e; + if (existing) { + conn.endpoints[index] = existing; + existing.addConnection(conn); + } else { + if (!params.endpoints) params.endpoints = [ null, null ]; + var ep = params.endpoints[index] || params.endpoint || _jsPlumb.Defaults.Endpoints[index] || jsPlumb.Defaults.Endpoints[index] || _jsPlumb.Defaults.Endpoint || jsPlumb.Defaults.Endpoint; + if (!params.endpointStyles) params.endpointStyles = [ null, null ]; + if (!params.endpointHoverStyles) params.endpointHoverStyles = [ null, null ]; + var es = params.endpointStyles[index] || params.endpointStyle || _jsPlumb.Defaults.EndpointStyles[index] || jsPlumb.Defaults.EndpointStyles[index] || _jsPlumb.Defaults.EndpointStyle || jsPlumb.Defaults.EndpointStyle; + // Endpoints derive their fillStyle from the connector's strokeStyle, if no fillStyle was specified. + if (es.fillStyle == null && params.paintStyle != null) + es.fillStyle = params.paintStyle.strokeStyle; + + if (es.outlineColor == null && params.paintStyle != null) + es.outlineColor = params.paintStyle.outlineColor; + if (es.outlineWidth == null && params.paintStyle != null) + es.outlineWidth = params.paintStyle.outlineWidth; + + var ehs = params.endpointHoverStyles[index] || params.endpointHoverStyle || _jsPlumb.Defaults.EndpointHoverStyles[index] || jsPlumb.Defaults.EndpointHoverStyles[index] || _jsPlumb.Defaults.EndpointHoverStyle || jsPlumb.Defaults.EndpointHoverStyle; + // endpoint hover fill style is derived from connector's hover stroke style + if (params.hoverPaintStyle != null) { + if (ehs == null) ehs = {}; + if (ehs.fillStyle == null) { + ehs.fillStyle = params.hoverPaintStyle.strokeStyle; + } + } + var a = params.anchors ? params.anchors[index] : + params.anchor ? params.anchor : + _makeAnchor(_jsPlumb.Defaults.Anchors[index], elementId, _jsPlumb) || + _makeAnchor(_jp.Defaults.Anchors[index], elementId, _jsPlumb) || + _makeAnchor(_jsPlumb.Defaults.Anchor, elementId, _jsPlumb) || + _makeAnchor(_jp.Defaults.Anchor, elementId, _jsPlumb), + u = params.uuids ? params.uuids[index] : null; + + e = _newEndpoint({ + paintStyle: es, hoverPaintStyle: ehs, endpoint: ep, connections: [ conn ], + uuid: u, anchor: a, source: element, scope: params.scope, + reattach: params.reattach || _jsPlumb.Defaults.ReattachConnections, + detachable: params.detachable || _jsPlumb.Defaults.ConnectionsDetachable + }); + conn.endpoints[index] = e; + + if (params.drawEndpoints === false) e.setVisible(false, true, true); + + } + return e; + } + + }); // END Connection class +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for creating and manipulating anchors. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + + var root = this, + _ju = root.jsPlumbUtil, + _jp = root.jsPlumb; + + // + // manages anchors for all elements. + // + _jp.AnchorManager = function (params) { + var _amEndpoints = {}, + continuousAnchorLocations = {}, + userDefinedContinuousAnchorLocations = {}, + continuousAnchorOrientations = {}, + Orientation = { HORIZONTAL: "horizontal", VERTICAL: "vertical", DIAGONAL: "diagonal", IDENTITY: "identity" }, + axes = ["left", "top", "right", "bottom"], + connectionsByElementId = {}, + self = this, + anchorLists = {}, + jsPlumbInstance = params.jsPlumbInstance, + floatingConnections = {}, + calculateOrientation = function (sourceId, targetId, sd, td, sourceAnchor, targetAnchor) { + + if (sourceId === targetId) return { + orientation: Orientation.IDENTITY, + a: ["top", "top"] + }; + + var theta = Math.atan2((td.centery - sd.centery), (td.centerx - sd.centerx)), + theta2 = Math.atan2((sd.centery - td.centery), (sd.centerx - td.centerx)); + +// -------------------------------------------------------------------------------------- + + // improved face calculation. get midpoints of each face for source and target, then put in an array with all combinations of + // source/target faces. sort this array by distance between midpoints. the entry at index 0 is our preferred option. we can + // go through the array one by one until we find an entry in which each requested face is supported. + var candidates = [], midpoints = { }; + (function (types, dim) { + for (var i = 0; i < types.length; i++) { + midpoints[types[i]] = { + "left": [ dim[i].left, dim[i].centery ], + "right": [ dim[i].right, dim[i].centery ], + "top": [ dim[i].centerx, dim[i].top ], + "bottom": [ dim[i].centerx , dim[i].bottom] + }; + } + })([ "source", "target" ], [ sd, td ]); + + for (var sf = 0; sf < axes.length; sf++) { + for (var tf = 0; tf < axes.length; tf++) { + if (sf != tf) { + candidates.push({ + source: axes[sf], + target: axes[tf], + dist: Biltong.lineLength(midpoints.source[axes[sf]], midpoints.target[axes[tf]]) + }); + } + } + } + + candidates.sort(function (a, b) { + return a.dist < b.dist ? -1 : a.dist > b.dist ? 1 : 0; + }); + + // now go through this list and try to get an entry that satisfies both (there will be one, unless one of the anchors + // declares no available faces) + var sourceEdge = candidates[0].source, targetEdge = candidates[0].target; + for (var i = 0; i < candidates.length; i++) { + + if (!sourceAnchor.isContinuous || sourceAnchor.isEdgeSupported(candidates[i].source)) + sourceEdge = candidates[i].source; + else + sourceEdge = null; + + if (!targetAnchor.isContinuous || targetAnchor.isEdgeSupported(candidates[i].target)) + targetEdge = candidates[i].target; + else { + targetEdge = null; + } + + if (sourceEdge != null && targetEdge != null) break; + } + +// -------------------------------------------------------------------------------------- + + return { + a: [ sourceEdge, targetEdge ], + theta: theta, + theta2: theta2 + }; + }, + // used by placeAnchors function + placeAnchorsOnLine = function (desc, elementDimensions, elementPosition, connections, horizontal, otherMultiplier, reverse) { + var a = [], step = elementDimensions[horizontal ? 0 : 1] / (connections.length + 1); + + for (var i = 0; i < connections.length; i++) { + var val = (i + 1) * step, other = otherMultiplier * elementDimensions[horizontal ? 1 : 0]; + if (reverse) + val = elementDimensions[horizontal ? 0 : 1] - val; + + var dx = (horizontal ? val : other), x = elementPosition[0] + dx, xp = dx / elementDimensions[0], + dy = (horizontal ? other : val), y = elementPosition[1] + dy, yp = dy / elementDimensions[1]; + + a.push([ x, y, xp, yp, connections[i][1], connections[i][2] ]); + } + + return a; + }, + // used by edgeSortFunctions + currySort = function (reverseAngles) { + return function (a, b) { + var r = true; + if (reverseAngles) { + r = a[0][0] < b[0][0]; + } + else { + r = a[0][0] > b[0][0]; + } + return r === false ? -1 : 1; + }; + }, + // used by edgeSortFunctions + leftSort = function (a, b) { + // first get adjusted values + var p1 = a[0][0] < 0 ? -Math.PI - a[0][0] : Math.PI - a[0][0], + p2 = b[0][0] < 0 ? -Math.PI - b[0][0] : Math.PI - b[0][0]; + if (p1 > p2) return 1; + else return a[0][1] > b[0][1] ? 1 : -1; + }, + // used by placeAnchors + edgeSortFunctions = { + "top": function (a, b) { + return a[0] > b[0] ? 1 : -1; + }, + "right": currySort(true), + "bottom": currySort(true), + "left": leftSort + }, + // used by placeAnchors + _sortHelper = function (_array, _fn) { + return _array.sort(_fn); + }, + // used by AnchorManager.redraw + placeAnchors = function (elementId, _anchorLists) { + var cd = jsPlumbInstance.getCachedData(elementId), sS = cd.s, sO = cd.o, + placeSomeAnchors = function (desc, elementDimensions, elementPosition, unsortedConnections, isHorizontal, otherMultiplier, orientation) { + if (unsortedConnections.length > 0) { + var sc = _sortHelper(unsortedConnections, edgeSortFunctions[desc]), // puts them in order based on the target element's pos on screen + reverse = desc === "right" || desc === "top", + anchors = placeAnchorsOnLine(desc, elementDimensions, + elementPosition, sc, + isHorizontal, otherMultiplier, reverse); + + // takes a computed anchor position and adjusts it for parent offset and scroll, then stores it. + var _setAnchorLocation = function (endpoint, anchorPos) { + continuousAnchorLocations[endpoint.id] = [ anchorPos[0], anchorPos[1], anchorPos[2], anchorPos[3] ]; + continuousAnchorOrientations[endpoint.id] = orientation; + }; + + for (var i = 0; i < anchors.length; i++) { + var c = anchors[i][4], weAreSource = c.endpoints[0].elementId === elementId, weAreTarget = c.endpoints[1].elementId === elementId; + if (weAreSource) + _setAnchorLocation(c.endpoints[0], anchors[i]); + else if (weAreTarget) + _setAnchorLocation(c.endpoints[1], anchors[i]); + } + } + }; + + placeSomeAnchors("bottom", sS, [sO.left, sO.top], _anchorLists.bottom, true, 1, [0, 1]); + placeSomeAnchors("top", sS, [sO.left, sO.top], _anchorLists.top, true, 0, [0, -1]); + placeSomeAnchors("left", sS, [sO.left, sO.top], _anchorLists.left, false, 0, [-1, 0]); + placeSomeAnchors("right", sS, [sO.left, sO.top], _anchorLists.right, false, 1, [1, 0]); + }; + + this.reset = function () { + _amEndpoints = {}; + connectionsByElementId = {}; + anchorLists = {}; + }; + this.addFloatingConnection = function (key, conn) { + floatingConnections[key] = conn; + }; + this.removeFloatingConnection = function (key) { + delete floatingConnections[key]; + }; + this.newConnection = function (conn) { + var sourceId = conn.sourceId, targetId = conn.targetId, + ep = conn.endpoints, + doRegisterTarget = true, + registerConnection = function (otherIndex, otherEndpoint, otherAnchor, elId, c) { + if ((sourceId == targetId) && otherAnchor.isContinuous) { + // remove the target endpoint's canvas. we dont need it. + conn._jsPlumb.instance.removeElement(ep[1].canvas); + doRegisterTarget = false; + } + _ju.addToList(connectionsByElementId, elId, [c, otherEndpoint, otherAnchor.constructor == _jp.DynamicAnchor]); + }; + + registerConnection(0, ep[0], ep[0].anchor, targetId, conn); + if (doRegisterTarget) + registerConnection(1, ep[1], ep[1].anchor, sourceId, conn); + }; + var removeEndpointFromAnchorLists = function (endpoint) { + (function (list, eId) { + if (list) { // transient anchors dont get entries in this list. + var f = function (e) { + return e[4] == eId; + }; + _ju.removeWithFunction(list.top, f); + _ju.removeWithFunction(list.left, f); + _ju.removeWithFunction(list.bottom, f); + _ju.removeWithFunction(list.right, f); + } + })(anchorLists[endpoint.elementId], endpoint.id); + }; + this.connectionDetached = function (connInfo) { + var connection = connInfo.connection || connInfo, + sourceId = connInfo.sourceId, + targetId = connInfo.targetId, + ep = connection.endpoints, + removeConnection = function (otherIndex, otherEndpoint, otherAnchor, elId, c) { + if (otherAnchor != null && otherAnchor.constructor == _jp.FloatingAnchor) { + // no-op + } + else { + _ju.removeWithFunction(connectionsByElementId[elId], function (_c) { + return _c[0].id == c.id; + }); + } + }; + + removeConnection(1, ep[1], ep[1].anchor, sourceId, connection); + removeConnection(0, ep[0], ep[0].anchor, targetId, connection); + + // remove from anchorLists + removeEndpointFromAnchorLists(connection.endpoints[0]); + removeEndpointFromAnchorLists(connection.endpoints[1]); + + self.redraw(connection.sourceId); + self.redraw(connection.targetId); + }; + this.add = function (endpoint, elementId) { + _ju.addToList(_amEndpoints, elementId, endpoint); + }; + this.changeId = function (oldId, newId) { + connectionsByElementId[newId] = connectionsByElementId[oldId]; + _amEndpoints[newId] = _amEndpoints[oldId]; + delete connectionsByElementId[oldId]; + delete _amEndpoints[oldId]; + }; + this.getConnectionsFor = function (elementId) { + return connectionsByElementId[elementId] || []; + }; + this.getEndpointsFor = function (elementId) { + return _amEndpoints[elementId] || []; + }; + this.deleteEndpoint = function (endpoint) { + _ju.removeWithFunction(_amEndpoints[endpoint.elementId], function (e) { + return e.id == endpoint.id; + }); + removeEndpointFromAnchorLists(endpoint); + }; + this.clearFor = function (elementId) { + delete _amEndpoints[elementId]; + _amEndpoints[elementId] = []; + }; + // updates the given anchor list by either updating an existing anchor's info, or adding it. this function + // also removes the anchor from its previous list, if the edge it is on has changed. + // all connections found along the way (those that are connected to one of the faces this function + // operates on) are added to the connsToPaint list, as are their endpoints. in this way we know to repaint + // them wthout having to calculate anything else about them. + var _updateAnchorList = function (lists, theta, order, conn, aBoolean, otherElId, idx, reverse, edgeId, elId, connsToPaint, endpointsToPaint) { + // first try to find the exact match, but keep track of the first index of a matching element id along the way.s + var exactIdx = -1, + firstMatchingElIdx = -1, + endpoint = conn.endpoints[idx], + endpointId = endpoint.id, + oIdx = [1, 0][idx], + values = [ + [ theta, order ], + conn, + aBoolean, + otherElId, + endpointId + ], + listToAddTo = lists[edgeId], + listToRemoveFrom = endpoint._continuousAnchorEdge ? lists[endpoint._continuousAnchorEdge] : null, + i, + candidate; + + if (listToRemoveFrom) { + var rIdx = _ju.findWithFunction(listToRemoveFrom, function (e) { + return e[4] == endpointId; + }); + if (rIdx != -1) { + listToRemoveFrom.splice(rIdx, 1); + // get all connections from this list + for (i = 0; i < listToRemoveFrom.length; i++) { + candidate = listToRemoveFrom[i][1]; + _ju.addWithFunction(connsToPaint, candidate, function (c) { + return c.id == candidate.id; + }); + _ju.addWithFunction(endpointsToPaint, listToRemoveFrom[i][1].endpoints[idx], function (e) { + return e.id == candidate.endpoints[idx].id; + }); + _ju.addWithFunction(endpointsToPaint, listToRemoveFrom[i][1].endpoints[oIdx], function (e) { + return e.id == candidate.endpoints[oIdx].id; + }); + } + } + } + + for (i = 0; i < listToAddTo.length; i++) { + candidate = listToAddTo[i][1]; + if (params.idx == 1 && listToAddTo[i][3] === otherElId && firstMatchingElIdx == -1) + firstMatchingElIdx = i; + _ju.addWithFunction(connsToPaint, candidate, function (c) { + return c.id == candidate.id; + }); + _ju.addWithFunction(endpointsToPaint, listToAddTo[i][1].endpoints[idx], function (e) { + return e.id == candidate.endpoints[idx].id; + }); + _ju.addWithFunction(endpointsToPaint, listToAddTo[i][1].endpoints[oIdx], function (e) { + return e.id == candidate.endpoints[oIdx].id; + }); + } + if (exactIdx != -1) { + listToAddTo[exactIdx] = values; + } + else { + var insertIdx = reverse ? firstMatchingElIdx != -1 ? firstMatchingElIdx : 0 : listToAddTo.length; // of course we will get this from having looked through the array shortly. + listToAddTo.splice(insertIdx, 0, values); + } + + // store this for next time. + endpoint._continuousAnchorEdge = edgeId; + }; + + // + // find the entry in an endpoint's list for this connection and update its target endpoint + // with the current target in the connection. + // + // + this.updateOtherEndpoint = function (elId, oldTargetId, newTargetId, connection) { + var sIndex = _ju.findWithFunction(connectionsByElementId[elId], function (i) { + return i[0].id === connection.id; + }), + tIndex = _ju.findWithFunction(connectionsByElementId[oldTargetId], function (i) { + return i[0].id === connection.id; + }); + + // update or add data for source + if (sIndex != -1) { + connectionsByElementId[elId][sIndex][0] = connection; + connectionsByElementId[elId][sIndex][1] = connection.endpoints[1]; + connectionsByElementId[elId][sIndex][2] = connection.endpoints[1].anchor.constructor == _jp.DynamicAnchor; + } + + // remove entry for previous target (if there) + if (tIndex > -1) { + connectionsByElementId[oldTargetId].splice(tIndex, 1); + // add entry for new target + _ju.addToList(connectionsByElementId, newTargetId, [connection, connection.endpoints[0], connection.endpoints[0].anchor.constructor == _jp.DynamicAnchor]); + } + + connection.updateConnectedClass(); + }; + + // + // notification that the connection given has changed source from the originalId to the newId. + // This involves: + // 1. removing the connection from the list of connections stored for the originalId + // 2. updating the source information for the target of the connection + // 3. re-registering the connection in connectionsByElementId with the newId + // + this.sourceChanged = function (originalId, newId, connection) { + if (originalId !== newId) { + // remove the entry that points from the old source to the target + _ju.removeWithFunction(connectionsByElementId[originalId], function (info) { + return info[0].id === connection.id; + }); + // find entry for target and update it + var tIdx = _ju.findWithFunction(connectionsByElementId[connection.targetId], function (i) { + return i[0].id === connection.id; + }); + if (tIdx > -1) { + connectionsByElementId[connection.targetId][tIdx][0] = connection; + connectionsByElementId[connection.targetId][tIdx][1] = connection.endpoints[0]; + connectionsByElementId[connection.targetId][tIdx][2] = connection.endpoints[0].anchor.constructor == _jp.DynamicAnchor; + } + // add entry for new source + _ju.addToList(connectionsByElementId, newId, [connection, connection.endpoints[1], connection.endpoints[1].anchor.constructor == _jp.DynamicAnchor]); + + connection.updateConnectedClass(); + } + }; + + // + // moves the given endpoint from `currentId` to `element`. + // This involves: + // + // 1. changing the key in _amEndpoints under which the endpoint is stored + // 2. changing the source or target values in all of the endpoint's connections + // 3. changing the array in connectionsByElementId in which the endpoint's connections + // are stored (done by either sourceChanged or updateOtherEndpoint) + // + this.rehomeEndpoint = function (ep, currentId, element) { + var eps = _amEndpoints[currentId] || [], + elementId = jsPlumbInstance.getId(element); + + if (elementId !== currentId) { + var idx = _ju.indexOf(eps, ep); + if (idx > -1) { + var _ep = eps.splice(idx, 1)[0]; + self.add(_ep, elementId); + } + } + + for (var i = 0; i < ep.connections.length; i++) { + if (ep.connections[i].sourceId == currentId) { + ep.connections[i].sourceId = ep.elementId; + ep.connections[i].source = ep.element; + self.sourceChanged(currentId, ep.elementId, ep.connections[i]); + } + else if (ep.connections[i].targetId == currentId) { + ep.connections[i].targetId = ep.elementId; + ep.connections[i].target = ep.element; + self.updateOtherEndpoint(ep.connections[i].sourceId, currentId, ep.elementId, ep.connections[i]); + } + } + }; + + this.redraw = function (elementId, ui, timestamp, offsetToUI, clearEdits, doNotRecalcEndpoint) { + + if (!jsPlumbInstance.isSuspendDrawing()) { + // get all the endpoints for this element + var ep = _amEndpoints[elementId] || [], + endpointConnections = connectionsByElementId[elementId] || [], + connectionsToPaint = [], + endpointsToPaint = [], + anchorsToUpdate = []; + + timestamp = timestamp || jsPlumbInstance.timestamp(); + // offsetToUI are values that would have been calculated in the dragManager when registering + // an endpoint for an element that had a parent (somewhere in the hierarchy) that had been + // registered as draggable. + offsetToUI = offsetToUI || {left: 0, top: 0}; + if (ui) { + ui = { + left: ui.left + offsetToUI.left, + top: ui.top + offsetToUI.top + }; + } + + // valid for one paint cycle. + var myOffset = jsPlumbInstance.updateOffset({ elId: elementId, offset: ui, recalc: false, timestamp: timestamp }), + orientationCache = {}; + + // actually, first we should compute the orientation of this element to all other elements to which + // this element is connected with a continuous anchor (whether both ends of the connection have + // a continuous anchor or just one) + + for (var i = 0; i < endpointConnections.length; i++) { + var conn = endpointConnections[i][0], + sourceId = conn.sourceId, + targetId = conn.targetId, + sourceContinuous = conn.endpoints[0].anchor.isContinuous, + targetContinuous = conn.endpoints[1].anchor.isContinuous; + + if (sourceContinuous || targetContinuous) { + var oKey = sourceId + "_" + targetId, + o = orientationCache[oKey], + oIdx = conn.sourceId == elementId ? 1 : 0; + + if (sourceContinuous && !anchorLists[sourceId]) anchorLists[sourceId] = { top: [], right: [], bottom: [], left: [] }; + if (targetContinuous && !anchorLists[targetId]) anchorLists[targetId] = { top: [], right: [], bottom: [], left: [] }; + + if (elementId != targetId) jsPlumbInstance.updateOffset({ elId: targetId, timestamp: timestamp }); + if (elementId != sourceId) jsPlumbInstance.updateOffset({ elId: sourceId, timestamp: timestamp }); + + var td = jsPlumbInstance.getCachedData(targetId), + sd = jsPlumbInstance.getCachedData(sourceId); + + if (targetId == sourceId && (sourceContinuous || targetContinuous)) { + // here we may want to improve this by somehow determining the face we'd like + // to put the connector on. ideally, when drawing, the face should be calculated + // by determining which face is closest to the point at which the mouse button + // was released. for now, we're putting it on the top face. + _updateAnchorList( + anchorLists[sourceId], + -Math.PI / 2, + 0, + conn, + false, + targetId, + 0, false, "top", sourceId, connectionsToPaint, endpointsToPaint); + } + else { + if (!o) { + o = calculateOrientation(sourceId, targetId, sd.o, td.o, conn.endpoints[0].anchor, conn.endpoints[1].anchor); + orientationCache[oKey] = o; + // this would be a performance enhancement, but the computed angles need to be clamped to + //the (-PI/2 -> PI/2) range in order for the sorting to work properly. + /* orientationCache[oKey2] = { + orientation:o.orientation, + a:[o.a[1], o.a[0]], + theta:o.theta + Math.PI, + theta2:o.theta2 + Math.PI + };*/ + } + if (sourceContinuous) _updateAnchorList(anchorLists[sourceId], o.theta, 0, conn, false, targetId, 0, false, o.a[0], sourceId, connectionsToPaint, endpointsToPaint); + if (targetContinuous) _updateAnchorList(anchorLists[targetId], o.theta2, -1, conn, true, sourceId, 1, true, o.a[1], targetId, connectionsToPaint, endpointsToPaint); + } + + if (sourceContinuous) _ju.addWithFunction(anchorsToUpdate, sourceId, function (a) { + return a === sourceId; + }); + if (targetContinuous) _ju.addWithFunction(anchorsToUpdate, targetId, function (a) { + return a === targetId; + }); + _ju.addWithFunction(connectionsToPaint, conn, function (c) { + return c.id == conn.id; + }); + if ((sourceContinuous && oIdx === 0) || (targetContinuous && oIdx === 1)) + _ju.addWithFunction(endpointsToPaint, conn.endpoints[oIdx], function (e) { + return e.id == conn.endpoints[oIdx].id; + }); + } + } + + // place Endpoints whose anchors are continuous but have no Connections + for (i = 0; i < ep.length; i++) { + if (ep[i].connections.length === 0 && ep[i].anchor.isContinuous) { + if (!anchorLists[elementId]) anchorLists[elementId] = { top: [], right: [], bottom: [], left: [] }; + _updateAnchorList(anchorLists[elementId], -Math.PI / 2, 0, {endpoints: [ep[i], ep[i]], paint: function () { + }}, false, elementId, 0, false, ep[i].anchor.getDefaultFace(), elementId, connectionsToPaint, endpointsToPaint); + _ju.addWithFunction(anchorsToUpdate, elementId, function (a) { + return a === elementId; + }); + } + } + + + // now place all the continuous anchors we need to; + for (i = 0; i < anchorsToUpdate.length; i++) { + placeAnchors(anchorsToUpdate[i], anchorLists[anchorsToUpdate[i]]); + } + + // now that continuous anchors have been placed, paint all the endpoints for this element + // TODO performance: add the endpoint ids to a temp array, and then when iterating in the next + // loop, check that we didn't just paint that endpoint. we can probably shave off a few more milliseconds this way. + for (i = 0; i < ep.length; i++) { + ep[i].paint({ timestamp: timestamp, offset: myOffset, dimensions: myOffset.s, recalc: doNotRecalcEndpoint !== true }); + } + + // ... and any other endpoints we came across as a result of the continuous anchors. + for (i = 0; i < endpointsToPaint.length; i++) { + var cd = jsPlumbInstance.getCachedData(endpointsToPaint[i].elementId); + endpointsToPaint[i].paint({ timestamp: timestamp, offset: cd, dimensions: cd.s }); + } + + // paint all the standard and "dynamic connections", which are connections whose other anchor is + // static and therefore does need to be recomputed; we make sure that happens only one time. + + // TODO we could have compiled a list of these in the first pass through connections; might save some time. + for (i = 0; i < endpointConnections.length; i++) { + var otherEndpoint = endpointConnections[i][1]; + if (otherEndpoint.anchor.constructor == _jp.DynamicAnchor) { + otherEndpoint.paint({ elementWithPrecedence: elementId, timestamp: timestamp }); + _ju.addWithFunction(connectionsToPaint, endpointConnections[i][0], function (c) { + return c.id == endpointConnections[i][0].id; + }); + // all the connections for the other endpoint now need to be repainted + for (var k = 0; k < otherEndpoint.connections.length; k++) { + if (otherEndpoint.connections[k] !== endpointConnections[i][0]) + _ju.addWithFunction(connectionsToPaint, otherEndpoint.connections[k], function (c) { + return c.id == otherEndpoint.connections[k].id; + }); + } + } else if (otherEndpoint.anchor.constructor == _jp.Anchor) { + _ju.addWithFunction(connectionsToPaint, endpointConnections[i][0], function (c) { + return c.id == endpointConnections[i][0].id; + }); + } + } + + // paint current floating connection for this element, if there is one. + var fc = floatingConnections[elementId]; + if (fc) + fc.paint({timestamp: timestamp, recalc: false, elId: elementId}); + + // paint all the connections + for (i = 0; i < connectionsToPaint.length; i++) { + connectionsToPaint[i].paint({elId: elementId, timestamp: timestamp, recalc: false, clearEdits: clearEdits}); + } + } + }; + + var ContinuousAnchor = function (anchorParams) { + _ju.EventGenerator.apply(this); + this.type = "Continuous"; + this.isDynamic = true; + this.isContinuous = true; + var faces = anchorParams.faces || ["top", "right", "bottom", "left"], + clockwise = !(anchorParams.clockwise === false), + availableFaces = { }, + opposites = { "top": "bottom", "right": "left", "left": "right", "bottom": "top" }, + clockwiseOptions = { "top": "right", "right": "bottom", "left": "top", "bottom": "left" }, + antiClockwiseOptions = { "top": "left", "right": "top", "left": "bottom", "bottom": "right" }, + secondBest = clockwise ? clockwiseOptions : antiClockwiseOptions, + lastChoice = clockwise ? antiClockwiseOptions : clockwiseOptions, + cssClass = anchorParams.cssClass || ""; + + for (var i = 0; i < faces.length; i++) { + availableFaces[faces[i]] = true; + } + + this.getDefaultFace = function () { + return faces.length === 0 ? "top" : faces[0]; + }; + + // if the given edge is supported, returns it. otherwise looks for a substitute that _is_ + // supported. if none supported we also return the request edge. + this.verifyEdge = function (edge) { + if (availableFaces[edge]) return edge; + else if (availableFaces[opposites[edge]]) return opposites[edge]; + else if (availableFaces[secondBest[edge]]) return secondBest[edge]; + else if (availableFaces[lastChoice[edge]]) return lastChoice[edge]; + return edge; // we have to give them something. + }; + + this.isEdgeSupported = function (edge) { + return availableFaces[edge] === true; + }; + + this.compute = function (params) { + return userDefinedContinuousAnchorLocations[params.element.id] || continuousAnchorLocations[params.element.id] || [0, 0]; + }; + this.getCurrentLocation = function (params) { + return userDefinedContinuousAnchorLocations[params.element.id] || continuousAnchorLocations[params.element.id] || [0, 0]; + }; + this.getOrientation = function (endpoint) { + return continuousAnchorOrientations[endpoint.id] || [0, 0]; + }; + this.clearUserDefinedLocation = function () { + delete userDefinedContinuousAnchorLocations[anchorParams.elementId]; + }; + this.setUserDefinedLocation = function (loc) { + userDefinedContinuousAnchorLocations[anchorParams.elementId] = loc; + }; + this.getCssClass = function () { + return cssClass; + }; + }; + + // continuous anchors + jsPlumbInstance.continuousAnchorFactory = { + get: function (params) { + return new ContinuousAnchor(params); + }, + clear: function (elementId) { + delete userDefinedContinuousAnchorLocations[elementId]; + delete continuousAnchorLocations[elementId]; + } + }; + }; + + /** + * Anchors model a position on some element at which an Endpoint may be located. They began as a first class citizen of jsPlumb, ie. a user + * was required to create these themselves, but over time this has been replaced by the concept of referring to them either by name (eg. "TopMiddle"), + * or by an array describing their coordinates (eg. [ 0, 0.5, 0, -1 ], which is the same as "TopMiddle"). jsPlumb now handles all of the + * creation of Anchors without user intervention. + */ + _jp.Anchor = function (params) { + this.x = params.x || 0; + this.y = params.y || 0; + this.elementId = params.elementId; + this.cssClass = params.cssClass || ""; + this.userDefinedLocation = null; + this.orientation = params.orientation || [ 0, 0 ]; + this.lastReturnValue = null; + this.offsets = params.offsets || [ 0, 0 ]; + this.timestamp = null; + + _ju.EventGenerator.apply(this); + + this.compute = function (params) { + + var xy = params.xy, wh = params.wh, timestamp = params.timestamp; + + if (params.clearUserDefinedLocation) + this.userDefinedLocation = null; + + if (timestamp && timestamp === self.timestamp) + return this.lastReturnValue; + + if (this.userDefinedLocation != null) { + this.lastReturnValue = this.userDefinedLocation; + } + else { + this.lastReturnValue = [ xy[0] + (this.x * wh[0]) + this.offsets[0], xy[1] + (this.y * wh[1]) + this.offsets[1] ]; + } + + this.timestamp = timestamp; + return this.lastReturnValue; + }; + + this.getCurrentLocation = function (params) { + return (this.lastReturnValue == null || (params.timestamp != null && this.timestamp != params.timestamp)) ? this.compute(params) : this.lastReturnValue; + }; + }; + _ju.extend(_jp.Anchor, _ju.EventGenerator, { + equals: function (anchor) { + if (!anchor) return false; + var ao = anchor.getOrientation(), + o = this.getOrientation(); + return this.x == anchor.x && this.y == anchor.y && this.offsets[0] == anchor.offsets[0] && this.offsets[1] == anchor.offsets[1] && o[0] == ao[0] && o[1] == ao[1]; + }, + getUserDefinedLocation: function () { + return this.userDefinedLocation; + }, + setUserDefinedLocation: function (l) { + this.userDefinedLocation = l; + }, + clearUserDefinedLocation: function () { + this.userDefinedLocation = null; + }, + getOrientation: function () { + return this.orientation; + }, + getCssClass: function () { + return this.cssClass; + } + }); + + /** + * An Anchor that floats. its orientation is computed dynamically from + * its position relative to the anchor it is floating relative to. It is used when creating + * a connection through drag and drop. + * + * TODO FloatingAnchor could totally be refactored to extend Anchor just slightly. + */ + _jp.FloatingAnchor = function (params) { + + _jp.Anchor.apply(this, arguments); + + // this is the anchor that this floating anchor is referenced to for + // purposes of calculating the orientation. + var ref = params.reference, + // the canvas this refers to. + refCanvas = params.referenceCanvas, + size = _jp.getSize(refCanvas), + // these are used to store the current relative position of our + // anchor wrt the reference anchor. they only indicate + // direction, so have a value of 1 or -1 (or, very rarely, 0). these + // values are written by the compute method, and read + // by the getOrientation method. + xDir = 0, yDir = 0, + // temporary member used to store an orientation when the floating + // anchor is hovering over another anchor. + orientation = null, + _lastResult = null; + + // clear from parent. we want floating anchor orientation to always be computed. + this.orientation = null; + + // set these to 0 each; they are used by certain types of connectors in the loopback case, + // when the connector is trying to clear the element it is on. but for floating anchor it's not + // very important. + this.x = 0; + this.y = 0; + + this.isFloating = true; + + this.compute = function (params) { + var xy = params.xy, + result = [ xy[0] + (size[0] / 2), xy[1] + (size[1] / 2) ]; // return origin of the element. we may wish to improve this so that any object can be the drag proxy. + _lastResult = result; + return result; + }; + + this.getOrientation = function (_endpoint) { + if (orientation) return orientation; + else { + var o = ref.getOrientation(_endpoint); + // here we take into account the orientation of the other + // anchor: if it declares zero for some direction, we declare zero too. this might not be the most awesome. perhaps we can come + // up with a better way. it's just so that the line we draw looks like it makes sense. maybe this wont make sense. + return [ Math.abs(o[0]) * xDir * -1, + Math.abs(o[1]) * yDir * -1 ]; + } + }; + + /** + * notification the endpoint associated with this anchor is hovering + * over another anchor; we want to assume that anchor's orientation + * for the duration of the hover. + */ + this.over = function (anchor, endpoint) { + orientation = anchor.getOrientation(endpoint); + }; + + /** + * notification the endpoint associated with this anchor is no + * longer hovering over another anchor; we should resume calculating + * orientation as we normally do. + */ + this.out = function () { + orientation = null; + }; + + this.getCurrentLocation = function (params) { + return _lastResult == null ? this.compute(params) : _lastResult; + }; + }; + _ju.extend(_jp.FloatingAnchor, _jp.Anchor); + + var _convertAnchor = function (anchor, jsPlumbInstance, elementId) { + return anchor.constructor == _jp.Anchor ? anchor : jsPlumbInstance.makeAnchor(anchor, elementId, jsPlumbInstance); + }; + + /* + * A DynamicAnchor is an Anchor that contains a list of other Anchors, which it cycles + * through at compute time to find the one that is located closest to + * the center of the target element, and returns that Anchor's compute + * method result. this causes endpoints to follow each other with + * respect to the orientation of their target elements, which is a useful + * feature for some applications. + * + */ + _jp.DynamicAnchor = function (params) { + _jp.Anchor.apply(this, arguments); + + this.isDynamic = true; + this.anchors = []; + this.elementId = params.elementId; + this.jsPlumbInstance = params.jsPlumbInstance; + + for (var i = 0; i < params.anchors.length; i++) + this.anchors[i] = _convertAnchor(params.anchors[i], this.jsPlumbInstance, this.elementId); + + this.getAnchors = function () { + return this.anchors; + }; + this.locked = false; + var _curAnchor = this.anchors.length > 0 ? this.anchors[0] : null, + _lastAnchor = _curAnchor, + self = this, + + // helper method to calculate the distance between the centers of the two elements. + _distance = function (anchor, cx, cy, xy, wh) { + var ax = xy[0] + (anchor.x * wh[0]), ay = xy[1] + (anchor.y * wh[1]), + acx = xy[0] + (wh[0] / 2), acy = xy[1] + (wh[1] / 2); + return (Math.sqrt(Math.pow(cx - ax, 2) + Math.pow(cy - ay, 2)) + + Math.sqrt(Math.pow(acx - ax, 2) + Math.pow(acy - ay, 2))); + }, + // default method uses distance between element centers. you can provide your own method in the dynamic anchor + // constructor (and also to jsPlumb.makeDynamicAnchor). the arguments to it are four arrays: + // xy - xy loc of the anchor's element + // wh - anchor's element's dimensions + // txy - xy loc of the element of the other anchor in the connection + // twh - dimensions of the element of the other anchor in the connection. + // anchors - the list of selectable anchors + _anchorSelector = params.selector || function (xy, wh, txy, twh, anchors) { + var cx = txy[0] + (twh[0] / 2), cy = txy[1] + (twh[1] / 2); + var minIdx = -1, minDist = Infinity; + for (var i = 0; i < anchors.length; i++) { + var d = _distance(anchors[i], cx, cy, xy, wh); + if (d < minDist) { + minIdx = i + 0; + minDist = d; + } + } + return anchors[minIdx]; + }; + + this.compute = function (params) { + var xy = params.xy, wh = params.wh, txy = params.txy, twh = params.twh; + + this.timestamp = params.timestamp; + + var udl = self.getUserDefinedLocation(); + if (udl != null) { + return udl; + } + + // if anchor is locked or an opposite element was not given, we + // maintain our state. anchor will be locked + // if it is the source of a drag and drop. + if (this.locked || txy == null || twh == null) + return _curAnchor.compute(params); + else + params.timestamp = null; // otherwise clear this, i think. we want the anchor to compute. + + _curAnchor = _anchorSelector(xy, wh, txy, twh, this.anchors); + this.x = _curAnchor.x; + this.y = _curAnchor.y; + + if (_curAnchor != _lastAnchor) + this.fire("anchorChanged", _curAnchor); + + _lastAnchor = _curAnchor; + + return _curAnchor.compute(params); + }; + + this.getCurrentLocation = function (params) { + return this.getUserDefinedLocation() || (_curAnchor != null ? _curAnchor.getCurrentLocation(params) : null); + }; + + this.getOrientation = function (_endpoint) { + return _curAnchor != null ? _curAnchor.getOrientation(_endpoint) : [ 0, 0 ]; + }; + this.over = function (anchor, endpoint) { + if (_curAnchor != null) _curAnchor.over(anchor, endpoint); + }; + this.out = function () { + if (_curAnchor != null) _curAnchor.out(); + }; + + this.getCssClass = function () { + return (_curAnchor && _curAnchor.getCssClass()) || ""; + }; + }; + _ju.extend(_jp.DynamicAnchor, _jp.Anchor); + +// -------- basic anchors ------------------ + var _curryAnchor = function (x, y, ox, oy, type, fnInit) { + _jp.Anchors[type] = function (params) { + var a = params.jsPlumbInstance.makeAnchor([ x, y, ox, oy, 0, 0 ], params.elementId, params.jsPlumbInstance); + a.type = type; + if (fnInit) fnInit(a, params); + return a; + }; + }; + + _curryAnchor(0.5, 0, 0, -1, "TopCenter"); + _curryAnchor(0.5, 1, 0, 1, "BottomCenter"); + _curryAnchor(0, 0.5, -1, 0, "LeftMiddle"); + _curryAnchor(1, 0.5, 1, 0, "RightMiddle"); + + _curryAnchor(0.5, 0, 0, -1, "Top"); + _curryAnchor(0.5, 1, 0, 1, "Bottom"); + _curryAnchor(0, 0.5, -1, 0, "Left"); + _curryAnchor(1, 0.5, 1, 0, "Right"); + _curryAnchor(0.5, 0.5, 0, 0, "Center"); + _curryAnchor(1, 0, 0, -1, "TopRight"); + _curryAnchor(1, 1, 0, 1, "BottomRight"); + _curryAnchor(0, 0, 0, -1, "TopLeft"); + _curryAnchor(0, 1, 0, 1, "BottomLeft"); + +// ------- dynamic anchors ------------------- + + // default dynamic anchors chooses from Top, Right, Bottom, Left + _jp.Defaults.DynamicAnchors = function (params) { + return params.jsPlumbInstance.makeAnchors(["TopCenter", "RightMiddle", "BottomCenter", "LeftMiddle"], params.elementId, params.jsPlumbInstance); + }; + + // default dynamic anchors bound to name 'AutoDefault' + _jp.Anchors.AutoDefault = function (params) { + var a = params.jsPlumbInstance.makeDynamicAnchor(_jp.Defaults.DynamicAnchors(params)); + a.type = "AutoDefault"; + return a; + }; + +// ------- continuous anchors ------------------- + + var _curryContinuousAnchor = function (type, faces) { + _jp.Anchors[type] = function (params) { + var a = params.jsPlumbInstance.makeAnchor(["Continuous", { faces: faces }], params.elementId, params.jsPlumbInstance); + a.type = type; + return a; + }; + }; + + _jp.Anchors.Continuous = function (params) { + return params.jsPlumbInstance.continuousAnchorFactory.get(params); + }; + + _curryContinuousAnchor("ContinuousLeft", ["left"]); + _curryContinuousAnchor("ContinuousTop", ["top"]); + _curryContinuousAnchor("ContinuousBottom", ["bottom"]); + _curryContinuousAnchor("ContinuousRight", ["right"]); + +// ------- position assign anchors ------------------- + + // this anchor type lets you assign the position at connection time. + _curryAnchor(0, 0, 0, 0, "Assign", function (anchor, params) { + // find what to use as the "position finder". the user may have supplied a String which represents + // the id of a position finder in jsPlumb.AnchorPositionFinders, or the user may have supplied the + // position finder as a function. we find out what to use and then set it on the anchor. + var pf = params.position || "Fixed"; + anchor.positionFinder = pf.constructor == String ? params.jsPlumbInstance.AnchorPositionFinders[pf] : pf; + // always set the constructor params; the position finder might need them later (the Grid one does, + // for example) + anchor.constructorParams = params; + }); + + // these are the default anchor positions finders, which are used by the makeTarget function. supplying + // a position finder argument to that function allows you to specify where the resulting anchor will + // be located + jsPlumbInstance.prototype.AnchorPositionFinders = { + "Fixed": function (dp, ep, es) { + return [ (dp.left - ep.left) / es[0], (dp.top - ep.top) / es[1] ]; + }, + "Grid": function (dp, ep, es, params) { + var dx = dp.left - ep.left, dy = dp.top - ep.top, + gx = es[0] / (params.grid[0]), gy = es[1] / (params.grid[1]), + mx = Math.floor(dx / gx), my = Math.floor(dy / gy); + return [ ((mx * gx) + (gx / 2)) / es[0], ((my * gy) + (gy / 2)) / es[1] ]; + } + }; + +// ------- perimeter anchors ------------------- + + _jp.Anchors.Perimeter = function (params) { + params = params || {}; + var anchorCount = params.anchorCount || 60, + shape = params.shape; + + if (!shape) throw new Error("no shape supplied to Perimeter Anchor type"); + + var _circle = function () { + var r = 0.5, step = Math.PI * 2 / anchorCount, current = 0, a = []; + for (var i = 0; i < anchorCount; i++) { + var x = r + (r * Math.sin(current)), + y = r + (r * Math.cos(current)); + a.push([ x, y, 0, 0 ]); + current += step; + } + return a; + }, + _path = function (segments) { + var anchorsPerFace = anchorCount / segments.length, a = [], + _computeFace = function (x1, y1, x2, y2, fractionalLength) { + anchorsPerFace = anchorCount * fractionalLength; + var dx = (x2 - x1) / anchorsPerFace, dy = (y2 - y1) / anchorsPerFace; + for (var i = 0; i < anchorsPerFace; i++) { + a.push([ + x1 + (dx * i), + y1 + (dy * i), + 0, + 0 + ]); + } + }; + + for (var i = 0; i < segments.length; i++) + _computeFace.apply(null, segments[i]); + + return a; + }, + _shape = function (faces) { + var s = []; + for (var i = 0; i < faces.length; i++) { + s.push([faces[i][0], faces[i][1], faces[i][2], faces[i][3], 1 / faces.length]); + } + return _path(s); + }, + _rectangle = function () { + return _shape([ + [ 0, 0, 1, 0 ], + [ 1, 0, 1, 1 ], + [ 1, 1, 0, 1 ], + [ 0, 1, 0, 0 ] + ]); + }; + + var _shapes = { + "Circle": _circle, + "Ellipse": _circle, + "Diamond": function () { + return _shape([ + [ 0.5, 0, 1, 0.5 ], + [ 1, 0.5, 0.5, 1 ], + [ 0.5, 1, 0, 0.5 ], + [ 0, 0.5, 0.5, 0 ] + ]); + }, + "Rectangle": _rectangle, + "Square": _rectangle, + "Triangle": function () { + return _shape([ + [ 0.5, 0, 1, 1 ], + [ 1, 1, 0, 1 ], + [ 0, 1, 0.5, 0] + ]); + }, + "Path": function (params) { + var points = params.points, p = [], tl = 0; + for (var i = 0; i < points.length - 1; i++) { + var l = Math.sqrt(Math.pow(points[i][2] - points[i][0]) + Math.pow(points[i][3] - points[i][1])); + tl += l; + p.push([points[i][0], points[i][1], points[i + 1][0], points[i + 1][1], l]); + } + for (var j = 0; j < p.length; j++) { + p[j][4] = p[j][4] / tl; + } + return _path(p); + } + }, + _rotate = function (points, amountInDegrees) { + var o = [], theta = amountInDegrees / 180 * Math.PI; + for (var i = 0; i < points.length; i++) { + var _x = points[i][0] - 0.5, + _y = points[i][1] - 0.5; + + o.push([ + 0.5 + ((_x * Math.cos(theta)) - (_y * Math.sin(theta))), + 0.5 + ((_x * Math.sin(theta)) + (_y * Math.cos(theta))), + points[i][2], + points[i][3] + ]); + } + return o; + }; + + if (!_shapes[shape]) throw new Error("Shape [" + shape + "] is unknown by Perimeter Anchor type"); + + var da = _shapes[shape](params); + if (params.rotation) da = _rotate(da, params.rotation); + var a = params.jsPlumbInstance.makeDynamicAnchor(da); + a.type = "Perimeter"; + return a; + }; +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the default Connectors, Endpoint and Overlay definitions. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil, _jg = root.Biltong; + + _jp.Segments = { + + /* + * Class: AbstractSegment + * A Connector is made up of 1..N Segments, each of which has a Type, such as 'Straight', 'Arc', + * 'Bezier'. This is new from 1.4.2, and gives us a lot more flexibility when drawing connections: things such + * as rounded corners for flowchart connectors, for example, or a straight line stub for Bezier connections, are + * much easier to do now. + * + * A Segment is responsible for providing coordinates for painting it, and also must be able to report its length. + * + */ + AbstractSegment: function (params) { + this.params = params; + + /** + * Function: findClosestPointOnPath + * Finds the closest point on this segment to the given [x, y], + * returning both the x and y of the point plus its distance from + * the supplied point, and its location along the length of the + * path inscribed by the segment. This implementation returns + * Infinity for distance and null values for everything else; + * subclasses are expected to override. + */ + this.findClosestPointOnPath = function (x, y) { + return { + d: Infinity, + x: null, + y: null, + l: null + }; + }; + + this.getBounds = function () { + return { + minX: Math.min(params.x1, params.x2), + minY: Math.min(params.y1, params.y2), + maxX: Math.max(params.x1, params.x2), + maxY: Math.max(params.y1, params.y2) + }; + }; + }, + Straight: function (params) { + var _super = _jp.Segments.AbstractSegment.apply(this, arguments), + length, m, m2, x1, x2, y1, y2, + _recalc = function () { + length = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)); + m = _jg.gradient({x: x1, y: y1}, {x: x2, y: y2}); + m2 = -1 / m; + }; + + this.type = "Straight"; + + this.getLength = function () { + return length; + }; + this.getGradient = function () { + return m; + }; + + this.getCoordinates = function () { + return { x1: x1, y1: y1, x2: x2, y2: y2 }; + }; + this.setCoordinates = function (coords) { + x1 = coords.x1; + y1 = coords.y1; + x2 = coords.x2; + y2 = coords.y2; + _recalc(); + }; + this.setCoordinates({x1: params.x1, y1: params.y1, x2: params.x2, y2: params.y2}); + + this.getBounds = function () { + return { + minX: Math.min(x1, x2), + minY: Math.min(y1, y2), + maxX: Math.max(x1, x2), + maxY: Math.max(y1, y2) + }; + }; + + /** + * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from + * 0 to 1 inclusive. for the straight line segment this is simple maths. + */ + this.pointOnPath = function (location, absolute) { + if (location === 0 && !absolute) + return { x: x1, y: y1 }; + else if (location == 1 && !absolute) + return { x: x2, y: y2 }; + else { + var l = absolute ? location > 0 ? location : length + location : location * length; + return _jg.pointOnLine({x: x1, y: y1}, {x: x2, y: y2}, l); + } + }; + + /** + * returns the gradient of the segment at the given point - which for us is constant. + */ + this.gradientAtPoint = function (_) { + return m; + }; + + /** + * returns the point on the segment's path that is 'distance' along the length of the path from 'location', where + * 'location' is a decimal from 0 to 1 inclusive, and 'distance' is a number of pixels. + * this hands off to jsPlumbUtil to do the maths, supplying two points and the distance. + */ + this.pointAlongPathFrom = function (location, distance, absolute) { + var p = this.pointOnPath(location, absolute), + farAwayPoint = distance <= 0 ? {x: x1, y: y1} : {x: x2, y: y2 }; + + /* + location == 1 ? { + x:x1 + ((x2 - x1) * 10), + y:y1 + ((y1 - y2) * 10) + } : + */ + + if (distance <= 0 && Math.abs(distance) > 1) distance *= -1; + + return _jg.pointOnLine(p, farAwayPoint, distance); + }; + + // is c between a and b? + var within = function (a, b, c) { + return c >= Math.min(a, b) && c <= Math.max(a, b); + }; + // find which of a and b is closest to c + var closest = function (a, b, c) { + return Math.abs(c - a) < Math.abs(c - b) ? a : b; + }; + + /** + Function: findClosestPointOnPath + Finds the closest point on this segment to [x,y]. See + notes on this method in AbstractSegment. + */ + this.findClosestPointOnPath = function (x, y) { + var out = { + d: Infinity, + x: null, + y: null, + l: null, + x1: x1, + x2: x2, + y1: y1, + y2: y2 + }; + + if (m === 0) { + out.y = y1; + out.x = within(x1, x2, x) ? x : closest(x1, x2, x); + } + else if (m == Infinity || m == -Infinity) { + out.x = x1; + out.y = within(y1, y2, y) ? y : closest(y1, y2, y); + } + else { + // closest point lies on normal from given point to this line. + var b = y1 - (m * x1), + b2 = y - (m2 * x), + // y1 = m.x1 + b and y1 = m2.x1 + b2 + // so m.x1 + b = m2.x1 + b2 + // x1(m - m2) = b2 - b + // x1 = (b2 - b) / (m - m2) + _x1 = (b2 - b) / (m - m2), + _y1 = (m * _x1) + b; + + out.x = within(x1, x2, _x1) ? _x1 : closest(x1, x2, _x1);//_x1; + out.y = within(y1, y2, _y1) ? _y1 : closest(y1, y2, _y1);//_y1; + } + + var fractionInSegment = _jg.lineLength([ out.x, out.y ], [ x1, y1 ]); + out.d = _jg.lineLength([x, y], [out.x, out.y]); + out.l = fractionInSegment / length; + return out; + }; + }, + + /* + Arc Segment. You need to supply: + + r - radius + cx - center x for the arc + cy - center y for the arc + ac - whether the arc is anticlockwise or not. default is clockwise. + + and then either: + + startAngle - startAngle for the arc. + endAngle - endAngle for the arc. + + or: + + x1 - x for start point + y1 - y for start point + x2 - x for end point + y2 - y for end point + + */ + Arc: function (params) { + var _super = _jp.Segments.AbstractSegment.apply(this, arguments), + _calcAngle = function (_x, _y) { + return _jg.theta([params.cx, params.cy], [_x, _y]); + }, + _calcAngleForLocation = function (segment, location) { + if (segment.anticlockwise) { + var sa = segment.startAngle < segment.endAngle ? segment.startAngle + TWO_PI : segment.startAngle, + s = Math.abs(sa - segment.endAngle); + return sa - (s * location); + } + else { + var ea = segment.endAngle < segment.startAngle ? segment.endAngle + TWO_PI : segment.endAngle, + ss = Math.abs(ea - segment.startAngle); + + return segment.startAngle + (ss * location); + } + }, + TWO_PI = 2 * Math.PI; + + this.radius = params.r; + this.anticlockwise = params.ac; + this.type = "Arc"; + + if (params.startAngle && params.endAngle) { + this.startAngle = params.startAngle; + this.endAngle = params.endAngle; + this.x1 = params.cx + (this.radius * Math.cos(params.startAngle)); + this.y1 = params.cy + (this.radius * Math.sin(params.startAngle)); + this.x2 = params.cx + (this.radius * Math.cos(params.endAngle)); + this.y2 = params.cy + (this.radius * Math.sin(params.endAngle)); + } + else { + this.startAngle = _calcAngle(params.x1, params.y1); + this.endAngle = _calcAngle(params.x2, params.y2); + this.x1 = params.x1; + this.y1 = params.y1; + this.x2 = params.x2; + this.y2 = params.y2; + } + + if (this.endAngle < 0) this.endAngle += TWO_PI; + if (this.startAngle < 0) this.startAngle += TWO_PI; + + // segment is used by vml + this.segment = _jg.quadrant([this.x1, this.y1], [this.x2, this.y2]); + + // we now have startAngle and endAngle as positive numbers, meaning the + // absolute difference (|d|) between them is the sweep (s) of this arc, unless the + // arc is 'anticlockwise' in which case 's' is given by 2PI - |d|. + + var ea = this.endAngle < this.startAngle ? this.endAngle + TWO_PI : this.endAngle; + this.sweep = Math.abs(ea - this.startAngle); + if (this.anticlockwise) this.sweep = TWO_PI - this.sweep; + var circumference = 2 * Math.PI * this.radius, + frac = this.sweep / TWO_PI, + length = circumference * frac; + + this.getLength = function () { + return length; + }; + + this.getBounds = function () { + return { + minX: params.cx - params.r, + maxX: params.cx + params.r, + minY: params.cy - params.r, + maxY: params.cy + params.r + }; + }; + + var VERY_SMALL_VALUE = 0.0000000001, + gentleRound = function (n) { + var f = Math.floor(n), r = Math.ceil(n); + if (n - f < VERY_SMALL_VALUE) + return f; + else if (r - n < VERY_SMALL_VALUE) + return r; + return n; + }; + + /** + * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from + * 0 to 1 inclusive. + */ + this.pointOnPath = function (location, absolute) { + + if (location === 0) { + return { x: this.x1, y: this.y1, theta: this.startAngle }; + } + else if (location == 1) { + return { x: this.x2, y: this.y2, theta: this.endAngle }; + } + + if (absolute) { + location = location / length; + } + + var angle = _calcAngleForLocation(this, location), + _x = params.cx + (params.r * Math.cos(angle)), + _y = params.cy + (params.r * Math.sin(angle)); + + return { x: gentleRound(_x), y: gentleRound(_y), theta: angle }; + }; + + /** + * returns the gradient of the segment at the given point. + */ + this.gradientAtPoint = function (location, absolute) { + var p = this.pointOnPath(location, absolute); + var m = _jg.normal([ params.cx, params.cy ], [p.x, p.y ]); + if (!this.anticlockwise && (m == Infinity || m == -Infinity)) m *= -1; + return m; + }; + + this.pointAlongPathFrom = function (location, distance, absolute) { + var p = this.pointOnPath(location, absolute), + arcSpan = distance / circumference * 2 * Math.PI, + dir = this.anticlockwise ? -1 : 1, + startAngle = p.theta + (dir * arcSpan), + startX = params.cx + (this.radius * Math.cos(startAngle)), + startY = params.cy + (this.radius * Math.sin(startAngle)); + + return {x: startX, y: startY}; + }; + }, + + Bezier: function (params) { + this.curve = [ + { x: params.x1, y: params.y1}, + { x: params.cp1x, y: params.cp1y }, + { x: params.cp2x, y: params.cp2y }, + { x: params.x2, y: params.y2 } + ]; + + var _super = _jp.Segments.AbstractSegment.apply(this, arguments); + // although this is not a strictly rigorous determination of bounds + // of a bezier curve, it works for the types of curves that this segment + // type produces. + this.bounds = { + minX: Math.min(params.x1, params.x2, params.cp1x, params.cp2x), + minY: Math.min(params.y1, params.y2, params.cp1y, params.cp2y), + maxX: Math.max(params.x1, params.x2, params.cp1x, params.cp2x), + maxY: Math.max(params.y1, params.y2, params.cp1y, params.cp2y) + }; + + this.type = "Bezier"; + + var _translateLocation = function (_curve, location, absolute) { + if (absolute) + location = root.jsBezier.locationAlongCurveFrom(_curve, location > 0 ? 0 : 1, location); + + return location; + }; + + /** + * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from + * 0 to 1 inclusive. + */ + this.pointOnPath = function (location, absolute) { + location = _translateLocation(this.curve, location, absolute); + return root.jsBezier.pointOnCurve(this.curve, location); + }; + + /** + * returns the gradient of the segment at the given point. + */ + this.gradientAtPoint = function (location, absolute) { + location = _translateLocation(this.curve, location, absolute); + return root.jsBezier.gradientAtPoint(this.curve, location); + }; + + this.pointAlongPathFrom = function (location, distance, absolute) { + location = _translateLocation(this.curve, location, absolute); + return root.jsBezier.pointAlongCurveFrom(this.curve, location, distance); + }; + + this.getLength = function () { + return root.jsBezier.getLength(this.curve); + }; + + this.getBounds = function () { + return this.bounds; + }; + } + }; + + /* + Class: AbstractComponent + Superclass for AbstractConnector and AbstractEndpoint. + */ + var AbstractComponent = function () { + this.resetBounds = function () { + this.bounds = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity }; + }; + this.resetBounds(); + }; + + /* + * Class: AbstractConnector + * Superclass for all Connectors; here is where Segments are managed. This is exposed on jsPlumb just so it + * can be accessed from other files. You should not try to instantiate one of these directly. + * + * When this class is asked for a pointOnPath, or gradient etc, it must first figure out which segment to dispatch + * that request to. This is done by keeping track of the total connector length as segments are added, and also + * their cumulative ratios to the total length. Then when the right segment is found it is a simple case of dispatching + * the request to it (and adjusting 'location' so that it is relative to the beginning of that segment.) + */ + _jp.Connectors.AbstractConnector = function (params) { + + AbstractComponent.apply(this, arguments); + + var segments = [], + totalLength = 0, + segmentProportions = [], + segmentProportionalLengths = [], + stub = params.stub || 0, + sourceStub = _ju.isArray(stub) ? stub[0] : stub, + targetStub = _ju.isArray(stub) ? stub[1] : stub, + gap = params.gap || 0, + sourceGap = _ju.isArray(gap) ? gap[0] : gap, + targetGap = _ju.isArray(gap) ? gap[1] : gap, + userProvidedSegments = null, + edited = false, + paintInfo = null; + + // to be overridden by subclasses. + this.getPath = function () { + }; + this.setPath = function (path) { + }; + + /** + * Function: findSegmentForPoint + * Returns the segment that is closest to the given [x,y], + * null if nothing found. This function returns a JS + * object with: + * + * d - distance from segment + * l - proportional location in segment + * x - x point on the segment + * y - y point on the segment + * s - the segment itself. + */ + this.findSegmentForPoint = function (x, y) { + var out = { d: Infinity, s: null, x: null, y: null, l: null }; + for (var i = 0; i < segments.length; i++) { + var _s = segments[i].findClosestPointOnPath(x, y); + if (_s.d < out.d) { + out.d = _s.d; + out.l = _s.l; + out.x = _s.x; + out.y = _s.y; + out.s = segments[i]; + out.x1 = _s.x1; + out.x2 = _s.x2; + out.y1 = _s.y1; + out.y2 = _s.y2; + out.index = i; + } + } + + return out; + }; + + var _updateSegmentProportions = function () { + var curLoc = 0; + for (var i = 0; i < segments.length; i++) { + var sl = segments[i].getLength(); + segmentProportionalLengths[i] = sl / totalLength; + segmentProportions[i] = [curLoc, (curLoc += (sl / totalLength)) ]; + } + }, + + /** + * returns [segment, proportion of travel in segment, segment index] for the segment + * that contains the point which is 'location' distance along the entire path, where + * 'location' is a decimal between 0 and 1 inclusive. in this connector type, paths + * are made up of a list of segments, each of which contributes some fraction to + * the total length. + * From 1.3.10 this also supports the 'absolute' property, which lets us specify a location + * as the absolute distance in pixels, rather than a proportion of the total path. + */ + _findSegmentForLocation = function (location, absolute) { + if (absolute) { + location = location > 0 ? location / totalLength : (totalLength + location) / totalLength; + } + var idx = segmentProportions.length - 1, inSegmentProportion = 1; + for (var i = 0; i < segmentProportions.length; i++) { + if (segmentProportions[i][1] >= location) { + idx = i; + // todo is this correct for all connector path types? + inSegmentProportion = location == 1 ? 1 : location === 0 ? 0 : (location - segmentProportions[i][0]) / segmentProportionalLengths[i]; + break; + } + } + return { segment: segments[idx], proportion: inSegmentProportion, index: idx }; + }, + _addSegment = function (conn, type, params) { + if (params.x1 == params.x2 && params.y1 == params.y2) return; + var s = new _jp.Segments[type](params); + segments.push(s); + totalLength += s.getLength(); + conn.updateBounds(s); + }, + _clearSegments = function () { + totalLength = segments.length = segmentProportions.length = segmentProportionalLengths.length = 0; + }; + + this.setSegments = function (_segs) { + userProvidedSegments = []; + totalLength = 0; + for (var i = 0; i < _segs.length; i++) { + userProvidedSegments.push(_segs[i]); + totalLength += _segs[i].getLength(); + } + }; + + this.getLength = function() { + return totalLength; + }; + + var _prepareCompute = function (params) { + this.lineWidth = params.lineWidth; + var segment = _jg.quadrant(params.sourcePos, params.targetPos), + swapX = params.targetPos[0] < params.sourcePos[0], + swapY = params.targetPos[1] < params.sourcePos[1], + lw = params.lineWidth || 1, + so = params.sourceEndpoint.anchor.getOrientation(params.sourceEndpoint), + to = params.targetEndpoint.anchor.getOrientation(params.targetEndpoint), + x = swapX ? params.targetPos[0] : params.sourcePos[0], + y = swapY ? params.targetPos[1] : params.sourcePos[1], + w = Math.abs(params.targetPos[0] - params.sourcePos[0]), + h = Math.abs(params.targetPos[1] - params.sourcePos[1]); + + // if either anchor does not have an orientation set, we derive one from their relative + // positions. we fix the axis to be the one in which the two elements are further apart, and + // point each anchor at the other element. this is also used when dragging a new connection. + if (so[0] === 0 && so[1] === 0 || to[0] === 0 && to[1] === 0) { + var index = w > h ? 0 : 1, oIndex = [1, 0][index]; + so = []; + to = []; + so[index] = params.sourcePos[index] > params.targetPos[index] ? -1 : 1; + to[index] = params.sourcePos[index] > params.targetPos[index] ? 1 : -1; + so[oIndex] = 0; + to[oIndex] = 0; + } + + var sx = swapX ? w + (sourceGap * so[0]) : sourceGap * so[0], + sy = swapY ? h + (sourceGap * so[1]) : sourceGap * so[1], + tx = swapX ? targetGap * to[0] : w + (targetGap * to[0]), + ty = swapY ? targetGap * to[1] : h + (targetGap * to[1]), + oProduct = ((so[0] * to[0]) + (so[1] * to[1])); + + var result = { + sx: sx, sy: sy, tx: tx, ty: ty, lw: lw, + xSpan: Math.abs(tx - sx), + ySpan: Math.abs(ty - sy), + mx: (sx + tx) / 2, + my: (sy + ty) / 2, + so: so, to: to, x: x, y: y, w: w, h: h, + segment: segment, + startStubX: sx + (so[0] * sourceStub), + startStubY: sy + (so[1] * sourceStub), + endStubX: tx + (to[0] * targetStub), + endStubY: ty + (to[1] * targetStub), + isXGreaterThanStubTimes2: Math.abs(sx - tx) > (sourceStub + targetStub), + isYGreaterThanStubTimes2: Math.abs(sy - ty) > (sourceStub + targetStub), + opposite: oProduct == -1, + perpendicular: oProduct === 0, + orthogonal: oProduct == 1, + sourceAxis: so[0] === 0 ? "y" : "x", + points: [x, y, w, h, sx, sy, tx, ty ] + }; + result.anchorOrientation = result.opposite ? "opposite" : result.orthogonal ? "orthogonal" : "perpendicular"; + return result; + }; + + this.getSegments = function () { + return segments; + }; + + this.updateBounds = function (segment) { + var segBounds = segment.getBounds(); + this.bounds.minX = Math.min(this.bounds.minX, segBounds.minX); + this.bounds.maxX = Math.max(this.bounds.maxX, segBounds.maxX); + this.bounds.minY = Math.min(this.bounds.minY, segBounds.minY); + this.bounds.maxY = Math.max(this.bounds.maxY, segBounds.maxY); + }; + + var dumpSegmentsToConsole = function () { + console.log("SEGMENTS:"); + for (var i = 0; i < segments.length; i++) { + console.log(segments[i].type, segments[i].getLength(), segmentProportions[i]); + } + }; + + this.pointOnPath = function (location, absolute) { + var seg = _findSegmentForLocation(location, absolute); + return seg.segment && seg.segment.pointOnPath(seg.proportion, false) || [0, 0]; + }; + + this.gradientAtPoint = function (location, absolute) { + var seg = _findSegmentForLocation(location, absolute); + return seg.segment && seg.segment.gradientAtPoint(seg.proportion, false) || 0; + }; + + this.pointAlongPathFrom = function (location, distance, absolute) { + var seg = _findSegmentForLocation(location, absolute); + // TODO what happens if this crosses to the next segment? + return seg.segment && seg.segment.pointAlongPathFrom(seg.proportion, distance, false) || [0, 0]; + }; + + this.compute = function (params) { + if (!edited) + paintInfo = _prepareCompute.call(this, params); + + _clearSegments(); + this._compute(paintInfo, params); + this.x = paintInfo.points[0]; + this.y = paintInfo.points[1]; + this.w = paintInfo.points[2]; + this.h = paintInfo.points[3]; + this.segment = paintInfo.segment; + _updateSegmentProportions(); + }; + + return { + addSegment: _addSegment, + prepareCompute: _prepareCompute, + sourceStub: sourceStub, + targetStub: targetStub, + maxStub: Math.max(sourceStub, targetStub), + sourceGap: sourceGap, + targetGap: targetGap, + maxGap: Math.max(sourceGap, targetGap) + }; + }; + _ju.extend(_jp.Connectors.AbstractConnector, AbstractComponent); + + /** + * Class: Connectors.Straight + * The Straight connector draws a simple straight line between the two anchor points. It does not have any constructor parameters. + */ + var Straight = _jp.Connectors.Straight = function () { + this.type = "Straight"; + var _super = _jp.Connectors.AbstractConnector.apply(this, arguments); + + this._compute = function (paintInfo, _) { + _super.addSegment(this, "Straight", {x1: paintInfo.sx, y1: paintInfo.sy, x2: paintInfo.startStubX, y2: paintInfo.startStubY}); + _super.addSegment(this, "Straight", {x1: paintInfo.startStubX, y1: paintInfo.startStubY, x2: paintInfo.endStubX, y2: paintInfo.endStubY}); + _super.addSegment(this, "Straight", {x1: paintInfo.endStubX, y1: paintInfo.endStubY, x2: paintInfo.tx, y2: paintInfo.ty}); + }; + }; + _ju.extend(_jp.Connectors.Straight, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(Straight, "Straight"); + + + // ********************************* END OF CONNECTOR TYPES ******************************************************************* + + // ********************************* ENDPOINT TYPES ******************************************************************* + + _jp.Endpoints.AbstractEndpoint = function (params) { + AbstractComponent.apply(this, arguments); + var compute = this.compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + var out = this._compute.apply(this, arguments); + this.x = out[0]; + this.y = out[1]; + this.w = out[2]; + this.h = out[3]; + this.bounds.minX = this.x; + this.bounds.minY = this.y; + this.bounds.maxX = this.x + this.w; + this.bounds.maxY = this.y + this.h; + return out; + }; + return { + compute: compute, + cssClass: params.cssClass + }; + }; + _ju.extend(_jp.Endpoints.AbstractEndpoint, AbstractComponent); + + /** + * Class: Endpoints.Dot + * A round endpoint, with default radius 10 pixels. + */ + + /** + * Function: Constructor + * + * Parameters: + * + * radius - radius of the endpoint. defaults to 10 pixels. + */ + _jp.Endpoints.Dot = function (params) { + this.type = "Dot"; + var _super = _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + params = params || {}; + this.radius = params.radius || 10; + this.defaultOffset = 0.5 * this.radius; + this.defaultInnerRadius = this.radius / 3; + + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + this.radius = endpointStyle.radius || this.radius; + var x = anchorPoint[0] - this.radius, + y = anchorPoint[1] - this.radius, + w = this.radius * 2, + h = this.radius * 2; + + if (endpointStyle.strokeStyle) { + var lw = endpointStyle.lineWidth || 1; + x -= lw; + y -= lw; + w += (lw * 2); + h += (lw * 2); + } + return [ x, y, w, h, this.radius ]; + }; + }; + _ju.extend(_jp.Endpoints.Dot, _jp.Endpoints.AbstractEndpoint); + + _jp.Endpoints.Rectangle = function (params) { + this.type = "Rectangle"; + var _super = _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + params = params || {}; + this.width = params.width || 20; + this.height = params.height || 20; + + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + var width = endpointStyle.width || this.width, + height = endpointStyle.height || this.height, + x = anchorPoint[0] - (width / 2), + y = anchorPoint[1] - (height / 2); + + return [ x, y, width, height]; + }; + }; + _ju.extend(_jp.Endpoints.Rectangle, _jp.Endpoints.AbstractEndpoint); + + var DOMElementEndpoint = function (params) { + _jp.jsPlumbUIComponent.apply(this, arguments); + this._jsPlumb.displayElements = []; + }; + _ju.extend(DOMElementEndpoint, _jp.jsPlumbUIComponent, { + getDisplayElements: function () { + return this._jsPlumb.displayElements; + }, + appendDisplayElement: function (el) { + this._jsPlumb.displayElements.push(el); + } + }); + + /** + * Class: Endpoints.Image + * Draws an image as the Endpoint. + */ + /** + * Function: Constructor + * + * Parameters: + * + * src - location of the image to use. + + TODO: multiple references to self. not sure quite how to get rid of them entirely. perhaps self = null in the cleanup + function will suffice + + TODO this class still might leak memory. + + */ + _jp.Endpoints.Image = function (params) { + + this.type = "Image"; + DOMElementEndpoint.apply(this, arguments); + _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + + var _onload = params.onload, + src = params.src || params.url, + clazz = params.cssClass ? " " + params.cssClass : ""; + + this._jsPlumb.img = new Image(); + this._jsPlumb.ready = false; + this._jsPlumb.initialized = false; + this._jsPlumb.deleted = false; + this._jsPlumb.widthToUse = params.width; + this._jsPlumb.heightToUse = params.height; + this._jsPlumb.endpoint = params.endpoint; + + this._jsPlumb.img.onload = function () { + if (this._jsPlumb != null) { + this._jsPlumb.ready = true; + this._jsPlumb.widthToUse = this._jsPlumb.widthToUse || this._jsPlumb.img.width; + this._jsPlumb.heightToUse = this._jsPlumb.heightToUse || this._jsPlumb.img.height; + if (_onload) { + _onload(this); + } + } + }.bind(this); + + /* + Function: setImage + Sets the Image to use in this Endpoint. + + Parameters: + img - may be a URL or an Image object + onload - optional; a callback to execute once the image has loaded. + */ + this._jsPlumb.endpoint.setImage = function (_img, onload) { + var s = _img.constructor == String ? _img : _img.src; + _onload = onload; + this._jsPlumb.img.src = s; + + if (this.canvas != null) + this.canvas.setAttribute("src", this._jsPlumb.img.src); + }.bind(this); + + this._jsPlumb.endpoint.setImage(src, _onload); + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + this.anchorPoint = anchorPoint; + if (this._jsPlumb.ready) return [anchorPoint[0] - this._jsPlumb.widthToUse / 2, anchorPoint[1] - this._jsPlumb.heightToUse / 2, + this._jsPlumb.widthToUse, this._jsPlumb.heightToUse]; + else return [0, 0, 0, 0]; + }; + + this.canvas = jsPlumb.createElement("img", { + position:"absolute", + margin:0, + padding:0, + outline:0 + }, this._jsPlumb.instance.endpointClass + clazz); + + if (this._jsPlumb.widthToUse) this.canvas.setAttribute("width", this._jsPlumb.widthToUse); + if (this._jsPlumb.heightToUse) this.canvas.setAttribute("height", this._jsPlumb.heightToUse); + this._jsPlumb.instance.appendElement(this.canvas); + + this.actuallyPaint = function (d, style, anchor) { + if (!this._jsPlumb.deleted) { + if (!this._jsPlumb.initialized) { + this.canvas.setAttribute("src", this._jsPlumb.img.src); + this.appendDisplayElement(this.canvas); + this._jsPlumb.initialized = true; + } + var x = this.anchorPoint[0] - (this._jsPlumb.widthToUse / 2), + y = this.anchorPoint[1] - (this._jsPlumb.heightToUse / 2); + _ju.sizeElement(this.canvas, x, y, this._jsPlumb.widthToUse, this._jsPlumb.heightToUse); + } + }; + + this.paint = function (style, anchor) { + if (this._jsPlumb != null) { // may have been deleted + if (this._jsPlumb.ready) { + this.actuallyPaint(style, anchor); + } + else { + root.setTimeout(function () { + this.paint(style, anchor); + }.bind(this), 200); + } + } + }; + }; + _ju.extend(_jp.Endpoints.Image, [ DOMElementEndpoint, _jp.Endpoints.AbstractEndpoint ], { + cleanup: function (force) { + if (force) { + this._jsPlumb.deleted = true; + if (this.canvas) this.canvas.parentNode.removeChild(this.canvas); + this.canvas = null; + } + } + }); + + /* + * Class: Endpoints.Blank + * An Endpoint that paints nothing (visible) on the screen. Supports cssClass and hoverClass parameters like all Endpoints. + */ + _jp.Endpoints.Blank = function (params) { + var _super = _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + this.type = "Blank"; + DOMElementEndpoint.apply(this, arguments); + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + return [anchorPoint[0], anchorPoint[1], 10, 0]; + }; + + var clazz = params.cssClass ? " " + params.cssClass : ""; + + this.canvas = jsPlumb.createElement("div", { + display: "block", + width: "1px", + height: "1px", + background: "transparent", + position: "absolute" + }, this._jsPlumb.instance.endpointClass + clazz); + + this._jsPlumb.instance.appendElement(this.canvas); + + this.paint = function (style, anchor) { + _ju.sizeElement(this.canvas, this.x, this.y, this.w, this.h); + }; + }; + _ju.extend(_jp.Endpoints.Blank, [_jp.Endpoints.AbstractEndpoint, DOMElementEndpoint], { + cleanup: function () { + if (this.canvas && this.canvas.parentNode) { + this.canvas.parentNode.removeChild(this.canvas); + } + } + }); + + /* + * Class: Endpoints.Triangle + * A triangular Endpoint. + */ + /* + * Function: Constructor + * + * Parameters: + * + * width - width of the triangle's base. defaults to 55 pixels. + * height - height of the triangle from base to apex. defaults to 55 pixels. + */ + _jp.Endpoints.Triangle = function (params) { + this.type = "Triangle"; + _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + params = params || { }; + params.width = params.width || 55; + params.height = params.height || 55; + this.width = params.width; + this.height = params.height; + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + var width = endpointStyle.width || self.width, + height = endpointStyle.height || self.height, + x = anchorPoint[0] - (width / 2), + y = anchorPoint[1] - (height / 2); + return [ x, y, width, height ]; + }; + }; +// ********************************* END OF ENDPOINT TYPES ******************************************************************* + + +// ********************************* OVERLAY DEFINITIONS *********************************************************************** + + var AbstractOverlay = _jp.Overlays.AbstractOverlay = function (params) { + this.visible = true; + this.isAppendedAtTopLevel = true; + this.component = params.component; + this.loc = params.location == null ? 0.5 : params.location; + this.endpointLoc = params.endpointLocation == null ? [ 0.5, 0.5] : params.endpointLocation; + }; + AbstractOverlay.prototype = { + cleanup: function (force) { + if (force) { + this.component = null; + this.canvas = null; + this.endpointLoc = null; + } + }, + reattach:function(instance) { + + }, + setVisible: function (val) { + this.visible = val; + this.component.repaint(); + }, + isVisible: function () { + return this.visible; + }, + hide: function () { + this.setVisible(false); + }, + show: function () { + this.setVisible(true); + }, + incrementLocation: function (amount) { + this.loc += amount; + this.component.repaint(); + }, + setLocation: function (l) { + this.loc = l; + this.component.repaint(); + }, + getLocation: function () { + return this.loc; + }, + updateFrom:function() { } + }; + + + /* + * Class: Overlays.Arrow + * + * An arrow overlay, defined by four points: the head, the two sides of the tail, and a 'foldback' point at some distance along the length + * of the arrow that lines from each tail point converge into. The foldback point is defined using a decimal that indicates some fraction + * of the length of the arrow and has a default value of 0.623. A foldback point value of 1 would mean that the arrow had a straight line + * across the tail. + */ + /* + * Function: Constructor + * + * Parameters: + * + * length - distance in pixels from head to tail baseline. default 20. + * width - width in pixels of the tail baseline. default 20. + * fillStyle - style to use when filling the arrow. defaults to "black". + * strokeStyle - style to use when stroking the arrow. defaults to null, which means the arrow is not stroked. + * lineWidth - line width to use when stroking the arrow. defaults to 1, but only used if strokeStyle is not null. + * foldback - distance (as a decimal from 0 to 1 inclusive) along the length of the arrow marking the point the tail points should fold back to. defaults to 0.623. + * location - distance (as a decimal from 0 to 1 inclusive) marking where the arrow should sit on the connector. defaults to 0.5. + * direction - indicates the direction the arrow points in. valid values are -1 and 1; 1 is default. + */ + _jp.Overlays.Arrow = function (params) { + this.type = "Arrow"; + AbstractOverlay.apply(this, arguments); + this.isAppendedAtTopLevel = false; + params = params || {}; + + this.length = params.length || 20; + this.width = params.width || 20; + this.id = params.id; + var direction = (params.direction || 1) < 0 ? -1 : 1, + paintStyle = params.paintStyle || { lineWidth: 1 }, + // how far along the arrow the lines folding back in come to. default is 62.3%. + foldback = params.foldback || 0.623; + + this.computeMaxSize = function () { + return self.width * 1.5; + }; + + this.draw = function (component, currentConnectionPaintStyle) { + + var hxy, mid, txy, tail, cxy; + if (component.pointAlongPathFrom) { + + if (_ju.isString(this.loc) || this.loc > 1 || this.loc < 0) { + var l = parseInt(this.loc, 10), + fromLoc = this.loc < 0 ? 1 : 0; + hxy = component.pointAlongPathFrom(fromLoc, l, false); + mid = component.pointAlongPathFrom(fromLoc, l - (direction * this.length / 2), false); + txy = _jg.pointOnLine(hxy, mid, this.length); + } + else if (this.loc == 1) { + hxy = component.pointOnPath(this.loc); + mid = component.pointAlongPathFrom(this.loc, -(this.length)); + txy = _jg.pointOnLine(hxy, mid, this.length); + + if (direction == -1) { + var _ = txy; + txy = hxy; + hxy = _; + } + } + else if (this.loc === 0) { + txy = component.pointOnPath(this.loc); + mid = component.pointAlongPathFrom(this.loc, this.length); + hxy = _jg.pointOnLine(txy, mid, this.length); + if (direction == -1) { + var __ = txy; + txy = hxy; + hxy = __; + } + } + else { + hxy = component.pointAlongPathFrom(this.loc, direction * this.length / 2); + mid = component.pointOnPath(this.loc); + txy = _jg.pointOnLine(hxy, mid, this.length); + } + + tail = _jg.perpendicularLineTo(hxy, txy, this.width); + cxy = _jg.pointOnLine(hxy, txy, foldback * this.length); + + var d = { hxy: hxy, tail: tail, cxy: cxy }, + strokeStyle = paintStyle.strokeStyle || currentConnectionPaintStyle.strokeStyle, + fillStyle = paintStyle.fillStyle || currentConnectionPaintStyle.strokeStyle, + lineWidth = paintStyle.lineWidth || currentConnectionPaintStyle.lineWidth; + + return { + component: component, + d: d, + lineWidth: lineWidth, + strokeStyle: strokeStyle, + fillStyle: fillStyle, + minX: Math.min(hxy.x, tail[0].x, tail[1].x), + maxX: Math.max(hxy.x, tail[0].x, tail[1].x), + minY: Math.min(hxy.y, tail[0].y, tail[1].y), + maxY: Math.max(hxy.y, tail[0].y, tail[1].y) + }; + } + else return {component: component, minX: 0, maxX: 0, minY: 0, maxY: 0}; + }; + }; + _ju.extend(_jp.Overlays.Arrow, AbstractOverlay, { + updateFrom:function(d) { + this.length = d.length || this.length; + this.width = d.width|| this.width; + this.direction = d.direction != null ? d.direction : this.direction; + this.foldback = d.foldback|| this.foldback; + } + }); + + /* + * Class: Overlays.PlainArrow + * + * A basic arrow. This is in fact just one instance of the more generic case in which the tail folds back on itself to some + * point along the length of the arrow: in this case, that foldback point is the full length of the arrow. so it just does + * a 'call' to Arrow with foldback set appropriately. + */ + /* + * Function: Constructor + * See for allowed parameters for this overlay. + */ + _jp.Overlays.PlainArrow = function (params) { + params = params || {}; + var p = _jp.extend(params, {foldback: 1}); + _jp.Overlays.Arrow.call(this, p); + this.type = "PlainArrow"; + }; + _ju.extend(_jp.Overlays.PlainArrow, _jp.Overlays.Arrow); + + /* + * Class: Overlays.Diamond + * + * A diamond. Like PlainArrow, this is a concrete case of the more generic case of the tail points converging on some point...it just + * happens that in this case, that point is greater than the length of the the arrow. + * + * this could probably do with some help with positioning...due to the way it reuses the Arrow paint code, what Arrow thinks is the + * center is actually 1/4 of the way along for this guy. but we don't have any knowledge of pixels at this point, so we're kind of + * stuck when it comes to helping out the Arrow class. possibly we could pass in a 'transpose' parameter or something. the value + * would be -l/4 in this case - move along one quarter of the total length. + */ + /* + * Function: Constructor + * See for allowed parameters for this overlay. + */ + _jp.Overlays.Diamond = function (params) { + params = params || {}; + var l = params.length || 40, + p = jsPlumb.extend(params, {length: l / 2, foldback: 2}); + _jp.Overlays.Arrow.call(this, p); + this.type = "Diamond"; + }; + _ju.extend(_jp.Overlays.Diamond, _jp.Overlays.Arrow); + + var _getDimensions = function (component, forceRefresh) { + if (component._jsPlumb.cachedDimensions == null || forceRefresh) + component._jsPlumb.cachedDimensions = component.getDimensions(); + return component._jsPlumb.cachedDimensions; + }; + + // abstract superclass for overlays that add an element to the DOM. + var AbstractDOMOverlay = function (params) { + _jp.jsPlumbUIComponent.apply(this, arguments); + AbstractOverlay.apply(this, arguments); + + // hand off fired events to associated component. + var _f = this.fire; + this.fire = function () { + _f.apply(this, arguments); + if (this.component) this.component.fire.apply(this.component, arguments); + }; + + this.detached=false; + this.id = params.id; + this._jsPlumb.div = null; + this._jsPlumb.initialised = false; + this._jsPlumb.component = params.component; + this._jsPlumb.cachedDimensions = null; + this._jsPlumb.create = params.create; + this._jsPlumb.initiallyInvisible = params.visible === false; + + this.getElement = function () { + if (this._jsPlumb.div == null) { + var div = this._jsPlumb.div = jsPlumb.getElement(this._jsPlumb.create(this._jsPlumb.component)); + div.style.position = "absolute"; + div.className = this._jsPlumb.instance.overlayClass + " " + + (this.cssClass ? this.cssClass : + params.cssClass ? params.cssClass : ""); + this._jsPlumb.instance.appendElement(div); + this._jsPlumb.instance.getId(div); + this.canvas = div; + + // in IE the top left corner is what it placed at the desired location. This will not + // be fixed. IE8 is not going to be supported for much longer. + var ts = "translate(-50%, -50%)"; + div.style.webkitTransform = ts; + div.style.mozTransform = ts; + div.style.msTransform = ts; + div.style.oTransform = ts; + div.style.transform = ts; + + // write the related component into the created element + div._jsPlumb = this; + + if (params.visible === false) + div.style.display = "none"; + } + return this._jsPlumb.div; + }; + + this.draw = function (component, currentConnectionPaintStyle, absolutePosition) { + var td = _getDimensions(this); + if (td != null && td.length == 2) { + var cxy = { x: 0, y: 0 }; + + // absolutePosition would have been set by a call to connection.setAbsoluteOverlayPosition. + if (absolutePosition) { + cxy = { x: absolutePosition[0], y: absolutePosition[1] }; + } + else if (component.pointOnPath) { + var loc = this.loc, absolute = false; + if (_ju.isString(this.loc) || this.loc < 0 || this.loc > 1) { + loc = parseInt(this.loc, 10); + absolute = true; + } + cxy = component.pointOnPath(loc, absolute); // a connection + } + else { + var locToUse = this.loc.constructor == Array ? this.loc : this.endpointLoc; + cxy = { x: locToUse[0] * component.w, + y: locToUse[1] * component.h }; + } + + var minx = cxy.x - (td[0] / 2), + miny = cxy.y - (td[1] / 2); + + return { + component: component, + d: { minx: minx, miny: miny, td: td, cxy: cxy }, + minX: minx, + maxX: minx + td[0], + minY: miny, + maxY: miny + td[1] + }; + } + else return {minX: 0, maxX: 0, minY: 0, maxY: 0}; + }; + }; + _ju.extend(AbstractDOMOverlay, [_jp.jsPlumbUIComponent, AbstractOverlay], { + getDimensions: function () { +// still support the old way, for now, for IE8. But from 2.0.0 this whole method will be gone. + return _ju.oldIE ? _jp.getSize(this.getElement()) : [1, 1]; + }, + setVisible: function (state) { + if (this._jsPlumb.div) { + this._jsPlumb.div.style.display = state ? "block" : "none"; + // if initially invisible, dimensions are 0,0 and never get updated + if (state && this._jsPlumb.initiallyInvisible) { + _getDimensions(this, true); + this.component.repaint(); + this._jsPlumb.initiallyInvisible = false; + } + } + }, + /* + * Function: clearCachedDimensions + * Clears the cached dimensions for the label. As a performance enhancement, label dimensions are + * cached from 1.3.12 onwards. The cache is cleared when you change the label text, of course, but + * there are other reasons why the text dimensions might change - if you make a change through CSS, for + * example, you might change the font size. in that case you should explicitly call this method. + */ + clearCachedDimensions: function () { + this._jsPlumb.cachedDimensions = null; + }, + cleanup: function (force) { + if (force) { + if (this._jsPlumb.div != null) { + this._jsPlumb.div._jsPlumb = null; + this._jsPlumb.instance.removeElement(this._jsPlumb.div); + } + } + else { + // if not a forced cleanup, just detach child from parent for now. + if (this._jsPlumb && this._jsPlumb.div && this._jsPlumb.div.parentNode) + this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div); + this.detached = true; + } + + }, + reattach:function(instance) { + if (this._jsPlumb.div != null) instance.getContainer().appendChild(this._jsPlumb.div); + this.detached = false; + }, + computeMaxSize: function () { + var td = _getDimensions(this); + return Math.max(td[0], td[1]); + }, + paint: function (p, containerExtents) { + if (!this._jsPlumb.initialised) { + this.getElement(); + p.component.appendDisplayElement(this._jsPlumb.div); + this._jsPlumb.initialised = true; + if (this.detached) this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div); + } + this._jsPlumb.div.style.left = (p.component.x + p.d.minx) + "px"; + this._jsPlumb.div.style.top = (p.component.y + p.d.miny) + "px"; + } + }); + + /* + * Class: Overlays.Custom + * A Custom overlay. You supply a 'create' function which returns some DOM element, and jsPlumb positions it. + * The 'create' function is passed a Connection or Endpoint. + */ + /* + * Function: Constructor + * + * Parameters: + * create - function for jsPlumb to call that returns a DOM element. + * location - distance (as a decimal from 0 to 1 inclusive) marking where the label should sit on the connector. defaults to 0.5. + * id - optional id to use for later retrieval of this overlay. + * + */ + _jp.Overlays.Custom = function (params) { + this.type = "Custom"; + AbstractDOMOverlay.apply(this, arguments); + }; + _ju.extend(_jp.Overlays.Custom, AbstractDOMOverlay); + + _jp.Overlays.GuideLines = function () { + var self = this; + self.length = 50; + self.lineWidth = 5; + this.type = "GuideLines"; + AbstractOverlay.apply(this, arguments); + _jp.jsPlumbUIComponent.apply(this, arguments); + this.draw = function (connector, currentConnectionPaintStyle) { + + var head = connector.pointAlongPathFrom(self.loc, self.length / 2), + mid = connector.pointOnPath(self.loc), + tail = _jg.pointOnLine(head, mid, self.length), + tailLine = _jg.perpendicularLineTo(head, tail, 40), + headLine = _jg.perpendicularLineTo(tail, head, 20); + + return { + connector: connector, + head: head, + tail: tail, + headLine: headLine, + tailLine: tailLine, + minX: Math.min(head.x, tail.x, headLine[0].x, headLine[1].x), + minY: Math.min(head.y, tail.y, headLine[0].y, headLine[1].y), + maxX: Math.max(head.x, tail.x, headLine[0].x, headLine[1].x), + maxY: Math.max(head.y, tail.y, headLine[0].y, headLine[1].y) + }; + }; + + // this.cleanup = function() { }; // nothing to clean up for GuideLines + }; + + /* + * Class: Overlays.Label + + */ + /* + * Function: Constructor + * + * Parameters: + * cssClass - optional css class string to append to css class. This string is appended "as-is", so you can of course have multiple classes + * defined. This parameter is preferred to using labelStyle, borderWidth and borderStyle. + * label - the label to paint. May be a string or a function that returns a string. Nothing will be painted if your label is null or your + * label function returns null. empty strings _will_ be painted. + * location - distance (as a decimal from 0 to 1 inclusive) marking where the label should sit on the connector. defaults to 0.5. + * id - optional id to use for later retrieval of this overlay. + * + * + */ + _jp.Overlays.Label = function (params) { + this.labelStyle = params.labelStyle; + + var labelWidth = null, labelHeight = null, labelText = null, labelPadding = null; + this.cssClass = this.labelStyle != null ? this.labelStyle.cssClass : null; + var p = _jp.extend({ + create: function () { + return jsPlumb.createElement("div"); + }}, params); + _jp.Overlays.Custom.call(this, p); + this.type = "Label"; + this.label = params.label || ""; + this.labelText = null; + if (this.labelStyle) { + var el = this.getElement(); + this.labelStyle.font = this.labelStyle.font || "12px sans-serif"; + el.style.font = this.labelStyle.font; + el.style.color = this.labelStyle.color || "black"; + if (this.labelStyle.fillStyle) el.style.background = this.labelStyle.fillStyle; + if (this.labelStyle.borderWidth > 0) { + var dStyle = this.labelStyle.borderStyle ? this.labelStyle.borderStyle : "black"; + el.style.border = this.labelStyle.borderWidth + "px solid " + dStyle; + } + if (this.labelStyle.padding) el.style.padding = this.labelStyle.padding; + } + + }; + _ju.extend(_jp.Overlays.Label, _jp.Overlays.Custom, { + cleanup: function (force) { + if (force) { + this.div = null; + this.label = null; + this.labelText = null; + this.cssClass = null; + this.labelStyle = null; + } + }, + getLabel: function () { + return this.label; + }, + /* + * Function: setLabel + * sets the label's, um, label. you would think i'd call this function + * 'setText', but you can pass either a Function or a String to this, so + * it makes more sense as 'setLabel'. This uses innerHTML on the label div, so keep + * that in mind if you need escaped HTML. + */ + setLabel: function (l) { + this.label = l; + this.labelText = null; + this.clearCachedDimensions(); + this.update(); + this.component.repaint(); + }, + getDimensions: function () { + this.update(); + return AbstractDOMOverlay.prototype.getDimensions.apply(this, arguments); + }, + update: function () { + if (typeof this.label == "function") { + var lt = this.label(this); + this.getElement().innerHTML = lt.replace(/\r\n/g, "
    "); + } + else { + if (this.labelText == null) { + this.labelText = this.label; + this.getElement().innerHTML = this.labelText.replace(/\r\n/g, "
    "); + } + } + }, + updateFrom:function(d) { + if(d.label) this.setLabel(d.label); + } + }); + + // ********************************* END OF OVERLAY DEFINITIONS *********************************************************************** + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the base class for library adapters. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +;(function() { + "use strict"; + var root = this, + _jp = root.jsPlumb; + + var _getEventManager = function(instance) { + var e = instance._mottle; + if (!e) { + e = instance._mottle = new root.Mottle(); + } + return e; + }; + + _jp.extend(root.jsPlumbInstance.prototype, { + getEventManager:function() { + return _getEventManager(this); + }, + // EVENTS + // e.originalEvent is for jQuery; in Vanilla jsPlumb we get the native event. + + on : function(el, event, callback) { + // TODO: here we would like to map the tap event if we know its + // an internal bind to a click. we have to know its internal because only + // then can we be sure that the UP event wont be consumed (tap is a synthesized + // event from a mousedown followed by a mouseup). + //event = { "click":"tap", "dblclick":"dbltap"}[event] || event; + this.getEventManager().on.apply(this, arguments); + }, + off : function(el, event, callback) { + this.getEventManager().off.apply(this, arguments); + } + }); + + +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the 'flowchart' connectors, consisting of vertical and horizontal line segments. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var Flowchart = function (params) { + this.type = "Flowchart"; + params = params || {}; + params.stub = params.stub == null ? 30 : params.stub; + var segments, + _super = _jp.Connectors.AbstractConnector.apply(this, arguments), + midpoint = params.midpoint == null ? 0.5 : params.midpoint, + alwaysRespectStubs = params.alwaysRespectStubs === true, + userSuppliedSegments = null, + lastx = null, lasty = null, lastOrientation, + cornerRadius = params.cornerRadius != null ? params.cornerRadius : 0, + sgn = function (n) { + return n < 0 ? -1 : n === 0 ? 0 : 1; + }, + /** + * helper method to add a segment. + */ + addSegment = function (segments, x, y, paintInfo) { + if (lastx == x && lasty == y) return; + var lx = lastx == null ? paintInfo.sx : lastx, + ly = lasty == null ? paintInfo.sy : lasty, + o = lx == x ? "v" : "h", + sgnx = sgn(x - lx), + sgny = sgn(y - ly); + + lastx = x; + lasty = y; + segments.push([lx, ly, x, y, o, sgnx, sgny]); + }, + segLength = function (s) { + return Math.sqrt(Math.pow(s[0] - s[2], 2) + Math.pow(s[1] - s[3], 2)); + }, + _cloneArray = function (a) { + var _a = []; + _a.push.apply(_a, a); + return _a; + }, + writeSegments = function (conn, segments, paintInfo) { + var current = null, next; + for (var i = 0; i < segments.length - 1; i++) { + + current = current || _cloneArray(segments[i]); + next = _cloneArray(segments[i + 1]); + if (cornerRadius > 0 && current[4] != next[4]) { + var radiusToUse = Math.min(cornerRadius, segLength(current), segLength(next)); + // right angle. adjust current segment's end point, and next segment's start point. + current[2] -= current[5] * radiusToUse; + current[3] -= current[6] * radiusToUse; + next[0] += next[5] * radiusToUse; + next[1] += next[6] * radiusToUse; + var ac = (current[6] == next[5] && next[5] == 1) || + ((current[6] == next[5] && next[5] === 0) && current[5] != next[6]) || + (current[6] == next[5] && next[5] == -1), + sgny = next[1] > current[3] ? 1 : -1, + sgnx = next[0] > current[2] ? 1 : -1, + sgnEqual = sgny == sgnx, + cx = (sgnEqual && ac || (!sgnEqual && !ac)) ? next[0] : current[2], + cy = (sgnEqual && ac || (!sgnEqual && !ac)) ? current[3] : next[1]; + + _super.addSegment(conn, "Straight", { + x1: current[0], y1: current[1], x2: current[2], y2: current[3] + }); + + _super.addSegment(conn, "Arc", { + r: radiusToUse, + x1: current[2], + y1: current[3], + x2: next[0], + y2: next[1], + cx: cx, + cy: cy, + ac: ac + }); + } + else { + // dx + dy are used to adjust for line width. + var dx = (current[2] == current[0]) ? 0 : (current[2] > current[0]) ? (paintInfo.lw / 2) : -(paintInfo.lw / 2), + dy = (current[3] == current[1]) ? 0 : (current[3] > current[1]) ? (paintInfo.lw / 2) : -(paintInfo.lw / 2); + _super.addSegment(conn, "Straight", { + x1: current[0] - dx, y1: current[1] - dy, x2: current[2] + dx, y2: current[3] + dy + }); + } + current = next; + } + if (next != null) { + // last segment + _super.addSegment(conn, "Straight", { + x1: next[0], y1: next[1], x2: next[2], y2: next[3] + }); + } + }; + + this.setSegments = function (s) { + userSuppliedSegments = s; + }; + + this.isEditable = function () { + return true; + }; + + /* + Function: getOriginalSegments + Gets the segments before the addition of rounded corners. This is used by the flowchart + connector editor, since it only wants to concern itself with the original segments. + */ + this.getOriginalSegments = function () { + return userSuppliedSegments || segments; + }; + + this._compute = function (paintInfo, params) { + + if (params.clearEdits) + userSuppliedSegments = null; + + if (userSuppliedSegments != null) { + writeSegments(this, userSuppliedSegments, paintInfo); + return; + } + + segments = []; + lastx = null; + lasty = null; + lastOrientation = null; + + var midx = paintInfo.startStubX + ((paintInfo.endStubX - paintInfo.startStubX) * midpoint), + midy = paintInfo.startStubY + ((paintInfo.endStubY - paintInfo.startStubY) * midpoint); + + var orientations = { x: [ 0, 1 ], y: [ 1, 0 ] }, + commonStubCalculator = function () { + return [ paintInfo.startStubX, paintInfo.startStubY, paintInfo.endStubX, paintInfo.endStubY ]; + }, + stubCalculators = { + perpendicular: commonStubCalculator, + orthogonal: commonStubCalculator, + opposite: function (axis) { + var pi = paintInfo, + idx = axis == "x" ? 0 : 1, + areInProximity = { + "x": function () { + return ( (pi.so[idx] == 1 && ( + ( (pi.startStubX > pi.endStubX) && (pi.tx > pi.startStubX) ) || + ( (pi.sx > pi.endStubX) && (pi.tx > pi.sx))))) || + + ( (pi.so[idx] == -1 && ( + ( (pi.startStubX < pi.endStubX) && (pi.tx < pi.startStubX) ) || + ( (pi.sx < pi.endStubX) && (pi.tx < pi.sx))))); + }, + "y": function () { + return ( (pi.so[idx] == 1 && ( + ( (pi.startStubY > pi.endStubY) && (pi.ty > pi.startStubY) ) || + ( (pi.sy > pi.endStubY) && (pi.ty > pi.sy))))) || + + ( (pi.so[idx] == -1 && ( + ( (pi.startStubY < pi.endStubY) && (pi.ty < pi.startStubY) ) || + ( (pi.sy < pi.endStubY) && (pi.ty < pi.sy))))); + } + }; + + if (!alwaysRespectStubs && areInProximity[axis]()) { + return { + "x": [(paintInfo.sx + paintInfo.tx) / 2, paintInfo.startStubY, (paintInfo.sx + paintInfo.tx) / 2, paintInfo.endStubY], + "y": [paintInfo.startStubX, (paintInfo.sy + paintInfo.ty) / 2, paintInfo.endStubX, (paintInfo.sy + paintInfo.ty) / 2] + }[axis]; + } + else { + return [ paintInfo.startStubX, paintInfo.startStubY, paintInfo.endStubX, paintInfo.endStubY ]; + } + } + }, + lineCalculators = { + perpendicular: function (axis) { + var pi = paintInfo, + sis = { + x: [ + [ [ 1, 2, 3, 4 ], null, [ 2, 1, 4, 3 ] ], + null, + [ [ 4, 3, 2, 1 ], null, [ 3, 4, 1, 2 ] ] + ], + y: [ + [ [ 3, 2, 1, 4 ], null, [ 2, 3, 4, 1 ] ], + null, + [ [ 4, 1, 2, 3 ], null, [ 1, 4, 3, 2 ] ] + ] + }, + stubs = { + x: [ [ pi.startStubX, pi.endStubX ], null, [ pi.endStubX, pi.startStubX ] ], + y: [ [ pi.startStubY, pi.endStubY ], null, [ pi.endStubY, pi.startStubY ] ] + }, + midLines = { + x: [ [ midx, pi.startStubY ], [ midx, pi.endStubY ] ], + y: [ [ pi.startStubX, midy ], [ pi.endStubX, midy ] ] + }, + linesToEnd = { + x: [ [ pi.endStubX, pi.startStubY ] ], + y: [ [ pi.startStubX, pi.endStubY ] ] + }, + startToEnd = { + x: [ [ pi.startStubX, pi.endStubY ], [ pi.endStubX, pi.endStubY ] ], + y: [ [ pi.endStubX, pi.startStubY ], [ pi.endStubX, pi.endStubY ] ] + }, + startToMidToEnd = { + x: [ [ pi.startStubX, midy ], [ pi.endStubX, midy ], [ pi.endStubX, pi.endStubY ] ], + y: [ [ midx, pi.startStubY ], [ midx, pi.endStubY ], [ pi.endStubX, pi.endStubY ] ] + }, + otherStubs = { + x: [ pi.startStubY, pi.endStubY ], + y: [ pi.startStubX, pi.endStubX ] + }, + soIdx = orientations[axis][0], toIdx = orientations[axis][1], + _so = pi.so[soIdx] + 1, + _to = pi.to[toIdx] + 1, + otherFlipped = (pi.to[toIdx] == -1 && (otherStubs[axis][1] < otherStubs[axis][0])) || (pi.to[toIdx] == 1 && (otherStubs[axis][1] > otherStubs[axis][0])), + stub1 = stubs[axis][_so][0], + stub2 = stubs[axis][_so][1], + segmentIndexes = sis[axis][_so][_to]; + + if (pi.segment == segmentIndexes[3] || (pi.segment == segmentIndexes[2] && otherFlipped)) { + return midLines[axis]; + } + else if (pi.segment == segmentIndexes[2] && stub2 < stub1) { + return linesToEnd[axis]; + } + else if ((pi.segment == segmentIndexes[2] && stub2 >= stub1) || (pi.segment == segmentIndexes[1] && !otherFlipped)) { + return startToMidToEnd[axis]; + } + else if (pi.segment == segmentIndexes[0] || (pi.segment == segmentIndexes[1] && otherFlipped)) { + return startToEnd[axis]; + } + }, + orthogonal: function (axis, startStub, otherStartStub, endStub, otherEndStub) { + var pi = paintInfo, + extent = { + "x": pi.so[0] == -1 ? Math.min(startStub, endStub) : Math.max(startStub, endStub), + "y": pi.so[1] == -1 ? Math.min(startStub, endStub) : Math.max(startStub, endStub) + }[axis]; + + return { + "x": [ + [ extent, otherStartStub ], + [ extent, otherEndStub ], + [ endStub, otherEndStub ] + ], + "y": [ + [ otherStartStub, extent ], + [ otherEndStub, extent ], + [ otherEndStub, endStub ] + ] + }[axis]; + }, + opposite: function (axis, ss, oss, es) { + var pi = paintInfo, + otherAxis = {"x": "y", "y": "x"}[axis], + dim = {"x": "height", "y": "width"}[axis], + comparator = pi["is" + axis.toUpperCase() + "GreaterThanStubTimes2"]; + + if (params.sourceEndpoint.elementId == params.targetEndpoint.elementId) { + var _val = oss + ((1 - params.sourceEndpoint.anchor[otherAxis]) * params.sourceInfo[dim]) + _super.maxStub; + return { + "x": [ + [ ss, _val ], + [ es, _val ] + ], + "y": [ + [ _val, ss ], + [ _val, es ] + ] + }[axis]; + + } + else if (!comparator || (pi.so[idx] == 1 && ss > es) || (pi.so[idx] == -1 && ss < es)) { + return { + "x": [ + [ ss, midy ], + [ es, midy ] + ], + "y": [ + [ midx, ss ], + [ midx, es ] + ] + }[axis]; + } + else if ((pi.so[idx] == 1 && ss < es) || (pi.so[idx] == -1 && ss > es)) { + return { + "x": [ + [ midx, pi.sy ], + [ midx, pi.ty ] + ], + "y": [ + [ pi.sx, midy ], + [ pi.tx, midy ] + ] + }[axis]; + } + } + }; + + var stubs = stubCalculators[paintInfo.anchorOrientation](paintInfo.sourceAxis), + idx = paintInfo.sourceAxis == "x" ? 0 : 1, + oidx = paintInfo.sourceAxis == "x" ? 1 : 0, + ss = stubs[idx], + oss = stubs[oidx], + es = stubs[idx + 2], + oes = stubs[oidx + 2]; + + // add the start stub segment. + addSegment(segments, stubs[0], stubs[1], paintInfo); + + // compute the rest of the line + var p = lineCalculators[paintInfo.anchorOrientation](paintInfo.sourceAxis, ss, oss, es, oes); + if (p) { + for (var i = 0; i < p.length; i++) { + addSegment(segments, p[i][0], p[i][1], paintInfo); + } + } + + // line to end stub + addSegment(segments, stubs[2], stubs[3], paintInfo); + + // end stub to end + addSegment(segments, paintInfo.tx, paintInfo.ty, paintInfo); + + writeSegments(this, segments, paintInfo); + }; + + this.getPath = function () { + var _last = null, _lastAxis = null, s = [], segs = userSuppliedSegments || segments; + for (var i = 0; i < segs.length; i++) { + var seg = segs[i], axis = seg[4], axisIndex = (axis == "v" ? 3 : 2); + if (_last != null && _lastAxis === axis) { + _last[axisIndex] = seg[axisIndex]; + } + else { + if (seg[0] != seg[2] || seg[1] != seg[3]) { + s.push({ + start: [ seg[0], seg[1] ], + end: [ seg[2], seg[3] ] + }); + _last = seg; + _lastAxis = seg[4]; + } + } + } + return s; + }; + + this.setPath = function (path) { + userSuppliedSegments = []; + for (var i = 0; i < path.length; i++) { + var lx = path[i].start[0], + ly = path[i].start[1], + x = path[i].end[0], + y = path[i].end[1], + o = lx == x ? "v" : "h", + sgnx = sgn(x - lx), + sgny = sgn(y - ly); + + userSuppliedSegments.push([lx, ly, x, y, o, sgnx, sgny]); + } + }; + }; + + _ju.extend(Flowchart, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(Flowchart, "Flowchart"); +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the state machine connectors. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var _segment = function (x1, y1, x2, y2) { + if (x1 <= x2 && y2 <= y1) return 1; + else if (x1 <= x2 && y1 <= y2) return 2; + else if (x2 <= x1 && y2 >= y1) return 3; + return 4; + }, + + // the control point we will use depends on the faces to which each end of the connection is assigned, specifically whether or not the + // two faces are parallel or perpendicular. if they are parallel then the control point lies on the midpoint of the axis in which they + // are parellel and varies only in the other axis; this variation is proportional to the distance that the anchor points lie from the + // center of that face. if the two faces are perpendicular then the control point is at some distance from both the midpoints; the amount and + // direction are dependent on the orientation of the two elements. 'seg', passed in to this method, tells you which segment the target element + // lies in with respect to the source: 1 is top right, 2 is bottom right, 3 is bottom left, 4 is top left. + // + // sourcePos and targetPos are arrays of info about where on the source and target each anchor is located. their contents are: + // + // 0 - absolute x + // 1 - absolute y + // 2 - proportional x in element (0 is left edge, 1 is right edge) + // 3 - proportional y in element (0 is top edge, 1 is bottom edge) + // + _findControlPoint = function (midx, midy, segment, sourceEdge, targetEdge, dx, dy, distance, proximityLimit) { + // TODO (maybe) + // - if anchor pos is 0.5, make the control point take into account the relative position of the elements. + if (distance <= proximityLimit) return [midx, midy]; + + if (segment === 1) { + if (sourceEdge[3] <= 0 && targetEdge[3] >= 1) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] >= 1 && targetEdge[2] <= 0) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + (-1 * dx) , midy + (-1 * dy) ]; + } + else if (segment === 2) { + if (sourceEdge[3] >= 1 && targetEdge[3] <= 0) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] >= 1 && targetEdge[2] <= 0) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + dx, midy + (-1 * dy) ]; + } + else if (segment === 3) { + if (sourceEdge[3] >= 1 && targetEdge[3] <= 0) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] <= 0 && targetEdge[2] >= 1) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + (-1 * dx) , midy + (-1 * dy) ]; + } + else if (segment === 4) { + if (sourceEdge[3] <= 0 && targetEdge[3] >= 1) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] <= 0 && targetEdge[2] >= 1) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + dx , midy + (-1 * dy) ]; + } + + }; + + var StateMachine = function (params) { + params = params || {}; + this.type = "StateMachine"; + + var _super = _jp.Connectors.AbstractConnector.apply(this, arguments), + curviness = params.curviness || 10, + margin = params.margin || 5, + proximityLimit = params.proximityLimit || 80, + clockwise = params.orientation && params.orientation === "clockwise", + loopbackRadius = params.loopbackRadius || 25, + showLoopback = params.showLoopback !== false; + + this._compute = function (paintInfo, params) { + var w = Math.abs(params.sourcePos[0] - params.targetPos[0]), + h = Math.abs(params.sourcePos[1] - params.targetPos[1]); + + if (!showLoopback || (params.sourceEndpoint.elementId !== params.targetEndpoint.elementId)) { + var _sx = params.sourcePos[0] < params.targetPos[0] ? 0 : w, + _sy = params.sourcePos[1] < params.targetPos[1] ? 0 : h, + _tx = params.sourcePos[0] < params.targetPos[0] ? w : 0, + _ty = params.sourcePos[1] < params.targetPos[1] ? h : 0; + + // now adjust for the margin + if (params.sourcePos[2] === 0) _sx -= margin; + if (params.sourcePos[2] === 1) _sx += margin; + if (params.sourcePos[3] === 0) _sy -= margin; + if (params.sourcePos[3] === 1) _sy += margin; + if (params.targetPos[2] === 0) _tx -= margin; + if (params.targetPos[2] === 1) _tx += margin; + if (params.targetPos[3] === 0) _ty -= margin; + if (params.targetPos[3] === 1) _ty += margin; + + // + // these connectors are quadratic bezier curves, having a single control point. if both anchors + // are located at 0.5 on their respective faces, the control point is set to the midpoint and you + // get a straight line. this is also the case if the two anchors are within 'proximityLimit', since + // it seems to make good aesthetic sense to do that. outside of that, the control point is positioned + // at 'curviness' pixels away along the normal to the straight line connecting the two anchors. + // + // there may be two improvements to this. firstly, we might actually support the notion of avoiding nodes + // in the UI, or at least making a good effort at doing so. if a connection would pass underneath some node, + // for example, we might increase the distance the control point is away from the midpoint in a bid to + // steer it around that node. this will work within limits, but i think those limits would also be the likely + // limits for, once again, aesthetic good sense in the layout of a chart using these connectors. + // + // the second possible change is actually two possible changes: firstly, it is possible we should gradually + // decrease the 'curviness' as the distance between the anchors decreases; start tailing it off to 0 at some + // point (which should be configurable). secondly, we might slightly increase the 'curviness' for connectors + // with respect to how far their anchor is from the center of its respective face. this could either look cool, + // or stupid, and may indeed work only in a way that is so subtle as to have been a waste of time. + // + + var _midx = (_sx + _tx) / 2, + _midy = (_sy + _ty) / 2, + segment = _segment(_sx, _sy, _tx, _ty), + distance = Math.sqrt(Math.pow(_tx - _sx, 2) + Math.pow(_ty - _sy, 2)), + // calculate the control point. this code will be where we'll put in a rudimentary element avoidance scheme; it + // will work by extending the control point to force the curve to be, um, curvier. + _controlPoint = _findControlPoint(_midx, + _midy, + segment, + params.sourcePos, + params.targetPos, + curviness, curviness, + distance, + proximityLimit); + + _super.addSegment(this, "Bezier", { + x1: _tx, y1: _ty, x2: _sx, y2: _sy, + cp1x: _controlPoint[0], cp1y: _controlPoint[1], + cp2x: _controlPoint[0], cp2y: _controlPoint[1] + }); + } + else { + // a loopback connector. draw an arc from one anchor to the other. + var x1 = params.sourcePos[0], y1 = params.sourcePos[1] - margin, + cx = x1, cy = y1 - loopbackRadius, + // canvas sizing stuff, to ensure the whole painted area is visible. + _w = 2 * loopbackRadius, + _h = 2 * loopbackRadius, + _x = cx - loopbackRadius, + _y = cy - loopbackRadius; + + paintInfo.points[0] = _x; + paintInfo.points[1] = _y; + paintInfo.points[2] = _w; + paintInfo.points[3] = _h; + + // ADD AN ARC SEGMENT. + _super.addSegment(this, "Arc", { + loopback: true, + x1: (x1 - _x) + 4, + y1: y1 - _y, + startAngle: 0, + endAngle: 2 * Math.PI, + r: loopbackRadius, + ac: !clockwise, + x2: (x1 - _x) - 4, + y2: y1 - _y, + cx: cx - _x, + cy: cy - _y + }); + } + }; + }; + _ju.extend(StateMachine, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(StateMachine, "StateMachine"); +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for the Bezier connector type. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var Bezier = function (params) { + params = params || {}; + + var _super = _jp.Connectors.AbstractConnector.apply(this, arguments), + majorAnchor = params.curviness || 150, + minorAnchor = 10; + + this.type = "Bezier"; + this.getCurviness = function () { + return majorAnchor; + }; + + this._findControlPoint = function (point, sourceAnchorPosition, targetAnchorPosition, sourceEndpoint, targetEndpoint, soo, too) { + // determine if the two anchors are perpendicular to each other in their orientation. we swap the control + // points around if so (code could be tightened up) + var perpendicular = soo[0] != too[0] || soo[1] == too[1], + p = []; + + if (!perpendicular) { + if (soo[0] === 0) // X + p.push(sourceAnchorPosition[0] < targetAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor); + else p.push(point[0] - (majorAnchor * soo[0])); + + if (soo[1] === 0) // Y + p.push(sourceAnchorPosition[1] < targetAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor); + else p.push(point[1] + (majorAnchor * too[1])); + } + else { + if (too[0] === 0) // X + p.push(targetAnchorPosition[0] < sourceAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor); + else p.push(point[0] + (majorAnchor * too[0])); + + if (too[1] === 0) // Y + p.push(targetAnchorPosition[1] < sourceAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor); + else p.push(point[1] + (majorAnchor * soo[1])); + } + + return p; + }; + + this._compute = function (paintInfo, p) { + var sp = p.sourcePos, + tp = p.targetPos, + _w = Math.abs(sp[0] - tp[0]), + _h = Math.abs(sp[1] - tp[1]), + _sx = sp[0] < tp[0] ? _w : 0, + _sy = sp[1] < tp[1] ? _h : 0, + _tx = sp[0] < tp[0] ? 0 : _w, + _ty = sp[1] < tp[1] ? 0 : _h, + _CP = this._findControlPoint([_sx, _sy], sp, tp, p.sourceEndpoint, p.targetEndpoint, paintInfo.so, paintInfo.to), + _CP2 = this._findControlPoint([_tx, _ty], tp, sp, p.targetEndpoint, p.sourceEndpoint, paintInfo.to, paintInfo.so); + + _super.addSegment(this, "Bezier", { + x1: _sx, y1: _sy, x2: _tx, y2: _ty, + cp1x: _CP[0], cp1y: _CP[1], cp2x: _CP2[0], cp2y: _CP2[1] + }); + }; + }; + + _ju.extend(Bezier, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(Bezier, "Bezier"); + +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the SVG renderers. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + +// ************************** SVG utility methods ******************************************** + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var svgAttributeMap = { + "joinstyle": "stroke-linejoin", + "stroke-linejoin": "stroke-linejoin", + "stroke-dashoffset": "stroke-dashoffset", + "stroke-linecap": "stroke-linecap" + }, + STROKE_DASHARRAY = "stroke-dasharray", + DASHSTYLE = "dashstyle", + LINEAR_GRADIENT = "linearGradient", + RADIAL_GRADIENT = "radialGradient", + DEFS = "defs", + FILL = "fill", + STOP = "stop", + STROKE = "stroke", + STROKE_WIDTH = "stroke-width", + STYLE = "style", + NONE = "none", + JSPLUMB_GRADIENT = "jsplumb_gradient_", + LINE_WIDTH = "lineWidth", + ns = { + svg: "http://www.w3.org/2000/svg", + xhtml: "http://www.w3.org/1999/xhtml" + }, + _attr = function (node, attributes) { + for (var i in attributes) + node.setAttribute(i, "" + attributes[i]); + }, + _node = function (name, attributes) { + attributes = attributes || {}; + attributes.version = "1.1"; + attributes.xmlns = ns.xhtml; + return jsPlumb.createElementNS(ns.svg, name, null, null, attributes); + }, + _pos = function (d) { + return "position:absolute;left:" + d[0] + "px;top:" + d[1] + "px"; + }, + _clearGradient = function (parent) { + var els = parent.querySelectorAll(" defs linearGradient radialGradient"); + for (var i = 0; i < els.length; i++) + els[i].parentNode.removeChild(els[i]); + }, + _updateGradient = function (parent, node, style, dimensions, uiComponent) { + var id = JSPLUMB_GRADIENT + uiComponent._jsPlumb.instance.idstamp(); + // first clear out any existing gradient + _clearGradient(parent); + // this checks for an 'offset' property in the gradient, and in the absence of it, assumes + // we want a linear gradient. if it's there, we create a radial gradient. + // it is possible that a more explicit means of defining the gradient type would be + // better. relying on 'offset' means that we can never have a radial gradient that uses + // some default offset, for instance. + // issue 244 suggested the 'gradientUnits' attribute; without this, straight/flowchart connectors with gradients would + // not show gradients when the line was perfectly horizontal or vertical. + var g; + if (!style.gradient.offset) + g = _node(LINEAR_GRADIENT, {id: id, gradientUnits: "userSpaceOnUse"}); + else + g = _node(RADIAL_GRADIENT, { id: id }); + + var defs = _node(DEFS); + parent.appendChild(defs); + defs.appendChild(g); + + // the svg radial gradient seems to treat stops in the reverse + // order to how canvas does it. so we want to keep all the maths the same, but + // iterate the actual style declarations in reverse order, if the x indexes are not in order. + for (var i = 0; i < style.gradient.stops.length; i++) { + var styleToUse = uiComponent.segment == 1 || uiComponent.segment == 2 ? i : style.gradient.stops.length - 1 - i, + stopColor = _ju.convertStyle(style.gradient.stops[styleToUse][1], true), + s = _node(STOP, {"offset": Math.floor(style.gradient.stops[i][0] * 100) + "%", "stop-color": stopColor}); + + g.appendChild(s); + } + var applyGradientTo = style.strokeStyle ? STROKE : FILL; + node.setAttribute(applyGradientTo, "url(#" + id + ")"); + }, + _applyStyles = function (parent, node, style, dimensions, uiComponent) { + + node.setAttribute(FILL, style.fillStyle ? _ju.convertStyle(style.fillStyle, true) : NONE); + node.setAttribute(STROKE, style.strokeStyle ? _ju.convertStyle(style.strokeStyle, true) : NONE); + + if (style.gradient) { + _updateGradient(parent, node, style, dimensions, uiComponent); + } + else { + // make sure we clear any existing gradient + _clearGradient(parent); + node.setAttribute(STYLE, ""); + } + + if (style.lineWidth) { + node.setAttribute(STROKE_WIDTH, style.lineWidth); + } + + // in SVG there is a stroke-dasharray attribute we can set, and its syntax looks like + // the syntax in VML but is actually kind of nasty: values are given in the pixel + // coordinate space, whereas in VML they are multiples of the width of the stroked + // line, which makes a lot more sense. for that reason, jsPlumb is supporting both + // the native svg 'stroke-dasharray' attribute, and also the 'dashstyle' concept from + // VML, which will be the preferred method. the code below this converts a dashstyle + // attribute given in terms of stroke width into a pixel representation, by using the + // stroke's lineWidth. + if (style[DASHSTYLE] && style[LINE_WIDTH] && !style[STROKE_DASHARRAY]) { + var sep = style[DASHSTYLE].indexOf(",") == -1 ? " " : ",", + parts = style[DASHSTYLE].split(sep), + styleToUse = ""; + parts.forEach(function (p) { + styleToUse += (Math.floor(p * style.lineWidth) + sep); + }); + node.setAttribute(STROKE_DASHARRAY, styleToUse); + } + else if (style[STROKE_DASHARRAY]) { + node.setAttribute(STROKE_DASHARRAY, style[STROKE_DASHARRAY]); + } + + // extra attributes such as join type, dash offset. + for (var i in svgAttributeMap) { + if (style[i]) { + node.setAttribute(svgAttributeMap[i], style[i]); + } + } + }, + _appendAtIndex = function (svg, path, idx) { + if (svg.childNodes.length > idx) { + svg.insertBefore(path, svg.childNodes[idx]); + } + else svg.appendChild(path); + }; + + /** + utility methods for other objects to use. + */ + _ju.svg = { + node: _node, + attr: _attr, + pos: _pos + }; + + // ************************** / SVG utility methods ******************************************** + + /* + * Base class for SVG components. + */ + var SvgComponent = function (params) { + var pointerEventsSpec = params.pointerEventsSpec || "all", renderer = {}; + + _jp.jsPlumbUIComponent.apply(this, params.originalArgs); + this.canvas = null; + this.path = null; + this.svg = null; + this.bgCanvas = null; + + var clazz = params.cssClass + " " + (params.originalArgs[0].cssClass || ""), + svgParams = { + "style": "", + "width": 0, + "height": 0, + "pointer-events": pointerEventsSpec, + "position": "absolute" + }; + + this.svg = _node("svg", svgParams); + + if (params.useDivWrapper) { + this.canvas = jsPlumb.createElement("div", { position : "absolute" }); + _ju.sizeElement(this.canvas, 0, 0, 1, 1); + this.canvas.className = clazz; + } + else { + _attr(this.svg, { "class": clazz }); + this.canvas = this.svg; + } + + params._jsPlumb.appendElement(this.canvas, params.originalArgs[0].parent); + if (params.useDivWrapper) this.canvas.appendChild(this.svg); + + var displayElements = [ this.canvas ]; + this.getDisplayElements = function () { + return displayElements; + }; + + this.appendDisplayElement = function (el) { + displayElements.push(el); + }; + + this.paint = function (style, anchor, extents) { + if (style != null) { + + var xy = [ this.x, this.y ], wh = [ this.w, this.h ], p; + if (extents != null) { + if (extents.xmin < 0) xy[0] += extents.xmin; + if (extents.ymin < 0) xy[1] += extents.ymin; + wh[0] = extents.xmax + ((extents.xmin < 0) ? -extents.xmin : 0); + wh[1] = extents.ymax + ((extents.ymin < 0) ? -extents.ymin : 0); + } + + if (params.useDivWrapper) { + _ju.sizeElement(this.canvas, xy[0], xy[1], wh[0], wh[1]); + xy[0] = 0; + xy[1] = 0; + p = _pos([ 0, 0 ]); + } + else + p = _pos([ xy[0], xy[1] ]); + + renderer.paint.apply(this, arguments); + + _attr(this.svg, { + "style": p, + "width": wh[0] || 0, + "height": wh[1] || 0 + }); + } + }; + + return { + renderer: renderer + }; + }; + + _ju.extend(SvgComponent, _jp.jsPlumbUIComponent, { + cleanup: function (force) { + if (force || this.typeId == null) { + if (this.canvas) this.canvas._jsPlumb = null; + if (this.svg) this.svg._jsPlumb = null; + if (this.bgCanvas) this.bgCanvas._jsPlumb = null; + + if (this.canvas && this.canvas.parentNode) + this.canvas.parentNode.removeChild(this.canvas); + if (this.bgCanvas && this.bgCanvas.parentNode) + this.canvas.parentNode.removeChild(this.canvas); + + this.svg = null; + this.canvas = null; + this.path = null; + this.group = null; + } + else { + // if not a forced cleanup, just detach from DOM for now. + if (this.canvas && this.canvas.parentNode) this.canvas.parentNode.removeChild(this.canvas); + if (this.bgCanvas && this.bgCanvas.parentNode) this.bgCanvas.parentNode.removeChild(this.bgCanvas); + } + }, + reattach:function(instance) { + var c = instance.getContainer(); + if (this.canvas && this.canvas.parentNode == null) c.appendChild(this.canvas); + if (this.bgCanvas && this.bgCanvas.parentNode == null) c.appendChild(this.bgCanvas); + }, + setVisible: function (v) { + if (this.canvas) { + this.canvas.style.display = v ? "block" : "none"; + } + } + }); + + /* + * Base class for SVG connectors. + */ + _jp.ConnectorRenderers.svg = function (params) { + var self = this, + _super = SvgComponent.apply(this, [ + { + cssClass: params._jsPlumb.connectorClass, + originalArgs: arguments, + pointerEventsSpec: "none", + _jsPlumb: params._jsPlumb + } + ]); + + _super.renderer.paint = function (style, anchor, extents) { + + var segments = self.getSegments(), p = "", offset = [0, 0]; + if (extents.xmin < 0) offset[0] = -extents.xmin; + if (extents.ymin < 0) offset[1] = -extents.ymin; + + if (segments.length > 0) { + + // create path from segments. + for (var i = 0; i < segments.length; i++) { + p += _jp.Segments.svg.SegmentRenderer.getPath(segments[i]); + p += " "; + } + + var a = { + d: p, + transform: "translate(" + offset[0] + "," + offset[1] + ")", + "pointer-events": params["pointer-events"] || "visibleStroke" + }, + outlineStyle = null, + d = [self.x, self.y, self.w, self.h]; + + // outline style. actually means drawing an svg object underneath the main one. + if (style.outlineColor) { + var outlineWidth = style.outlineWidth || 1, + outlineStrokeWidth = style.lineWidth + (2 * outlineWidth); + outlineStyle = _jp.extend({}, style); + delete outlineStyle.gradient; + outlineStyle.strokeStyle = _ju.convertStyle(style.outlineColor); + outlineStyle.lineWidth = outlineStrokeWidth; + + if (self.bgPath == null) { + self.bgPath = _node("path", a); + _jp.addClass(self.bgPath, _jp.connectorOutlineClass); + _appendAtIndex(self.svg, self.bgPath, 0); + } + else { + _attr(self.bgPath, a); + } + + _applyStyles(self.svg, self.bgPath, outlineStyle, d, self); + } + + if (self.path == null) { + self.path = _node("path", a); + _appendAtIndex(self.svg, self.path, style.outlineColor ? 1 : 0); + } + else { + _attr(self.path, a); + } + + _applyStyles(self.svg, self.path, style, d, self); + } + }; + }; + _ju.extend(_jp.ConnectorRenderers.svg, SvgComponent); + +// ******************************* svg segment renderer ***************************************************** + + _jp.Segments.svg = { + SegmentRenderer: { + getPath: function (segment) { + return ({ + "Straight": function () { + var d = segment.getCoordinates(); + return "M " + d.x1 + " " + d.y1 + " L " + d.x2 + " " + d.y2; + }, + "Bezier": function () { + var d = segment.params; + return "M " + d.x1 + " " + d.y1 + + " C " + d.cp1x + " " + d.cp1y + " " + d.cp2x + " " + d.cp2y + " " + d.x2 + " " + d.y2; + }, + "Arc": function () { + var d = segment.params, + laf = segment.sweep > Math.PI ? 1 : 0, + sf = segment.anticlockwise ? 0 : 1; + + return "M" + segment.x1 + " " + segment.y1 + " A " + segment.radius + " " + d.r + " 0 " + laf + "," + sf + " " + segment.x2 + " " + segment.y2; + } + })[segment.type](); + } + } + }; + +// ******************************* /svg segments ***************************************************** + + /* + * Base class for SVG endpoints. + */ + var SvgEndpoint = _jp.SvgEndpoint = function (params) { + var _super = SvgComponent.apply(this, [ + { + cssClass: params._jsPlumb.endpointClass, + originalArgs: arguments, + pointerEventsSpec: "all", + useDivWrapper: true, + _jsPlumb: params._jsPlumb + } + ]); + + _super.renderer.paint = function (style) { + var s = _jp.extend({}, style); + if (s.outlineColor) { + s.strokeWidth = s.outlineWidth; + s.strokeStyle = _ju.convertStyle(s.outlineColor, true); + } + + if (this.node == null) { + this.node = this.makeNode(s); + this.svg.appendChild(this.node); + } + else if (this.updateNode != null) { + this.updateNode(this.node); + } + _applyStyles(this.svg, this.node, s, [ this.x, this.y, this.w, this.h ], this); + _pos(this.node, [ this.x, this.y ]); + }.bind(this); + + }; + _ju.extend(SvgEndpoint, SvgComponent); + + /* + * SVG Dot Endpoint + */ + _jp.Endpoints.svg.Dot = function () { + _jp.Endpoints.Dot.apply(this, arguments); + SvgEndpoint.apply(this, arguments); + this.makeNode = function (style) { + return _node("circle", { + "cx": this.w / 2, + "cy": this.h / 2, + "r": this.radius + }); + }; + this.updateNode = function (node) { + _attr(node, { + "cx": this.w / 2, + "cy": this.h / 2, + "r": this.radius + }); + }; + }; + _ju.extend(_jp.Endpoints.svg.Dot, [_jp.Endpoints.Dot, SvgEndpoint]); + + /* + * SVG Rectangle Endpoint + */ + _jp.Endpoints.svg.Rectangle = function () { + _jp.Endpoints.Rectangle.apply(this, arguments); + SvgEndpoint.apply(this, arguments); + this.makeNode = function (style) { + return _node("rect", { + "width": this.w, + "height": this.h + }); + }; + this.updateNode = function (node) { + _attr(node, { + "width": this.w, + "height": this.h + }); + }; + }; + _ju.extend(_jp.Endpoints.svg.Rectangle, [_jp.Endpoints.Rectangle, SvgEndpoint]); + + /* + * SVG Image Endpoint is the default image endpoint. + */ + _jp.Endpoints.svg.Image = _jp.Endpoints.Image; + /* + * Blank endpoint in svg renderer is the default Blank endpoint. + */ + _jp.Endpoints.svg.Blank = _jp.Endpoints.Blank; + /* + * Label overlay in svg renderer is the default Label overlay. + */ + _jp.Overlays.svg.Label = _jp.Overlays.Label; + /* + * Custom overlay in svg renderer is the default Custom overlay. + */ + _jp.Overlays.svg.Custom = _jp.Overlays.Custom; + + var AbstractSvgArrowOverlay = function (superclass, originalArgs) { + superclass.apply(this, originalArgs); + _jp.jsPlumbUIComponent.apply(this, originalArgs); + this.isAppendedAtTopLevel = false; + var self = this; + this.path = null; + this.paint = function (params, containerExtents) { + // only draws on connections, not endpoints. + if (params.component.svg && containerExtents) { + if (this.path == null) { + this.path = _node("path", { + "pointer-events": "all" + }); + params.component.svg.appendChild(this.path); + + this.canvas = params.component.svg; // for the sake of completeness; this behaves the same as other overlays + } + var clazz = originalArgs && (originalArgs.length == 1) ? (originalArgs[0].cssClass || "") : "", + offset = [0, 0]; + + if (containerExtents.xmin < 0) offset[0] = -containerExtents.xmin; + if (containerExtents.ymin < 0) offset[1] = -containerExtents.ymin; + + _attr(this.path, { + "d": makePath(params.d), + "class": clazz, + stroke: params.strokeStyle ? params.strokeStyle : null, + fill: params.fillStyle ? params.fillStyle : null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + } + }; + var makePath = function (d) { + return (isNaN(d.cxy.x) || isNaN(d.cxy.y)) ? "" : "M" + d.hxy.x + "," + d.hxy.y + + " L" + d.tail[0].x + "," + d.tail[0].y + + " L" + d.cxy.x + "," + d.cxy.y + + " L" + d.tail[1].x + "," + d.tail[1].y + + " L" + d.hxy.x + "," + d.hxy.y; + }; + this.transfer = function(target) { + if (target.canvas && this.path && this.path.parentNode) { + this.path.parentNode.removeChild(this.path); + target.canvas.appendChild(this.path); + } + }; + }; + _ju.extend(AbstractSvgArrowOverlay, [_jp.jsPlumbUIComponent, _jp.Overlays.AbstractOverlay], { + cleanup: function (force) { + if (this.path != null) { + if (force) + this._jsPlumb.instance.removeElement(this.path); + else + if (this.path.parentNode) + this.path.parentNode.removeChild(this.path); + } + }, + reattach:function(instance) { + if (this.path && this.canvas && this.path.parentNode == null) + this.canvas.appendChild(this.path); + }, + setVisible: function (v) { + if (this.path != null) (this.path.style.display = (v ? "block" : "none")); + } + }); + + _jp.Overlays.svg.Arrow = function () { + AbstractSvgArrowOverlay.apply(this, [_jp.Overlays.Arrow, arguments]); + }; + _ju.extend(_jp.Overlays.svg.Arrow, [ _jp.Overlays.Arrow, AbstractSvgArrowOverlay ]); + + _jp.Overlays.svg.PlainArrow = function () { + AbstractSvgArrowOverlay.apply(this, [_jp.Overlays.PlainArrow, arguments]); + }; + _ju.extend(_jp.Overlays.svg.PlainArrow, [ _jp.Overlays.PlainArrow, AbstractSvgArrowOverlay ]); + + _jp.Overlays.svg.Diamond = function () { + AbstractSvgArrowOverlay.apply(this, [_jp.Overlays.Diamond, arguments]); + }; + _ju.extend(_jp.Overlays.svg.Diamond, [ _jp.Overlays.Diamond, AbstractSvgArrowOverlay ]); + + // a test + _jp.Overlays.svg.GuideLines = function () { + var path = null, self = this, p1_1, p1_2; + _jp.Overlays.GuideLines.apply(this, arguments); + this.paint = function (params, containerExtents) { + if (path == null) { + path = _node("path"); + params.connector.svg.appendChild(path); + self.attachListeners(path, params.connector); + self.attachListeners(path, self); + + p1_1 = _node("path"); + params.connector.svg.appendChild(p1_1); + self.attachListeners(p1_1, params.connector); + self.attachListeners(p1_1, self); + + p1_2 = _node("path"); + params.connector.svg.appendChild(p1_2); + self.attachListeners(p1_2, params.connector); + self.attachListeners(p1_2, self); + } + + var offset = [0, 0]; + if (containerExtents.xmin < 0) offset[0] = -containerExtents.xmin; + if (containerExtents.ymin < 0) offset[1] = -containerExtents.ymin; + + _attr(path, { + "d": makePath(params.head, params.tail), + stroke: "red", + fill: null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + + _attr(p1_1, { + "d": makePath(params.tailLine[0], params.tailLine[1]), + stroke: "blue", + fill: null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + + _attr(p1_2, { + "d": makePath(params.headLine[0], params.headLine[1]), + stroke: "green", + fill: null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + }; + + var makePath = function (d1, d2) { + return "M " + d1.x + "," + d1.y + + " L" + d2.x + "," + d2.y; + }; + }; + _ju.extend(_jp.Overlays.svg.GuideLines, _jp.Overlays.GuideLines); +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the VML renderers. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ + +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + // http://ajaxian.com/archives/the-vml-changes-in-ie-8 + // http://www.nczonline.net/blog/2010/01/19/internet-explorer-8-document-and-browser-modes/ + // http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/ + + var vmlAttributeMap = { + "stroke-linejoin": "joinstyle", + "joinstyle": "joinstyle", + "endcap": "endcap", + "miterlimit": "miterlimit" + }, + jsPlumbStylesheet = null; + + if (document.createStyleSheet && document.namespaces) { + + var ruleClasses = [ + ".jsplumb_vml", "jsplumb\\:textbox", "jsplumb\\:oval", "jsplumb\\:rect", + "jsplumb\\:stroke", "jsplumb\\:shape", "jsplumb\\:group" + ], + rule = "behavior:url(#default#VML);position:absolute;"; + + jsPlumbStylesheet = document.createStyleSheet(); + + for (var i = 0; i < ruleClasses.length; i++) + jsPlumbStylesheet.addRule(ruleClasses[i], rule); + + // in this page it is also mentioned that IE requires the extra arg to the namespace + // http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/ + // but someone commented saying they didn't need it, and it seems jsPlumb doesnt need it either. + // var iev = document.documentMode; + //if (!iev || iev < 8) + document.namespaces.add("jsplumb", "urn:schemas-microsoft-com:vml"); + //else + // document.namespaces.add("jsplumb", "urn:schemas-microsoft-com:vml", "#default#VML"); + } + + _jp.vml = {}; + + var scale = 1000, + + _atts = function (o, atts) { + for (var i in atts) { + // IE8 fix: setattribute does not work after an element has been added to the dom! + // http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/ + //o.setAttribute(i, atts[i]); + + /*There is an additional problem when accessing VML elements by using get/setAttribute. The simple solution is following: + + if (document.documentMode==8) { + ele.opacity=1; + } else { + ele.setAttribute(‘opacity’,1); + } + */ + + o[i] = atts[i]; + } + }, + _node = function (name, d, atts, parent, _jsPlumb, deferToJsPlumbContainer) { + atts = atts || {}; + var o = document.createElement("jsplumb:" + name); + if (deferToJsPlumbContainer) + _jsPlumb.appendElement(o, parent); + else + // TODO is this failing? that would be because parent is not a plain DOM element. + // IF SO, uncomment the line below this one and remove this one. + parent.appendChild(o); + //jsPlumb.getElement(parent).appendChild(o); + + o.className = (atts["class"] ? atts["class"] + " " : "") + "jsplumb_vml"; + _pos(o, d); + _atts(o, atts); + return o; + }, + _pos = function (o, d, zIndex) { + o.style.left = d[0] + "px"; + o.style.top = d[1] + "px"; + o.style.width = d[2] + "px"; + o.style.height = d[3] + "px"; + o.style.position = "absolute"; + if (zIndex) + o.style.zIndex = zIndex; + }, + _conv = _jp.vml.convertValue = function (v) { + return Math.floor(v * scale); + }, + // tests if the given style is "transparent" and then sets the appropriate opacity node to 0 if so, + // or 1 if not. TODO in the future, support variable opacity. + _maybeSetOpacity = function (styleToWrite, styleToCheck, type, component) { + if ("transparent" === styleToCheck) + component.setOpacity(type, "0.0"); + else + component.setOpacity(type, "1.0"); + }, + _applyStyles = function (node, style, component, _jsPlumb) { + var styleToWrite = {}; + if (style.strokeStyle) { + styleToWrite.stroked = "true"; + var strokeColor = _ju.convertStyle(style.strokeStyle, true); + styleToWrite.strokecolor = strokeColor; + _maybeSetOpacity(styleToWrite, strokeColor, "stroke", component); + styleToWrite.strokeweight = style.lineWidth + "px"; + } + else styleToWrite.stroked = "false"; + + if (style.fillStyle) { + styleToWrite.filled = "true"; + var fillColor = _ju.convertStyle(style.fillStyle, true); + styleToWrite.fillcolor = fillColor; + _maybeSetOpacity(styleToWrite, fillColor, "fill", component); + } + else styleToWrite.filled = "false"; + + if (style.dashstyle) { + if (component.strokeNode == null) { + component.strokeNode = _node("stroke", [0, 0, 0, 0], { dashstyle: style.dashstyle }, node, _jsPlumb); + } + else + component.strokeNode.dashstyle = style.dashstyle; + } + else if (style["stroke-dasharray"] && style.lineWidth) { + var sep = style["stroke-dasharray"].indexOf(",") == -1 ? " " : ",", + parts = style["stroke-dasharray"].split(sep), + styleToUse = ""; + for (var i = 0; i < parts.length; i++) { + styleToUse += (Math.floor(parts[i] / style.lineWidth) + sep); + } + if (component.strokeNode == null) { + component.strokeNode = _node("stroke", [0, 0, 0, 0], { dashstyle: styleToUse }, node, _jsPlumb); + } + else + component.strokeNode.dashstyle = styleToUse; + } + + _atts(node, styleToWrite); + }, + /* + * Base class for Vml endpoints and connectors. Extends jsPlumbUIComponent. + */ + VmlComponent = function () { + var self = this, renderer = {}; + _jp.jsPlumbUIComponent.apply(this, arguments); + + this.opacityNodes = { + "stroke": null, + "fill": null + }; + this.initOpacityNodes = function (vml) { + self.opacityNodes.stroke = _node("stroke", [0, 0, 1, 1], {opacity: "0.0"}, vml, self._jsPlumb.instance); + self.opacityNodes.fill = _node("fill", [0, 0, 1, 1], {opacity: "0.0"}, vml, self._jsPlumb.instance); + }; + this.setOpacity = function (type, value) { + var node = self.opacityNodes[type]; + if (node) node.opacity = "" + value; + }; + var displayElements = [ ]; + this.getDisplayElements = function () { + return displayElements; + }; + + this.appendDisplayElement = function (el, doNotAppendToCanvas) { + if (!doNotAppendToCanvas) self.canvas.parentNode.appendChild(el); + displayElements.push(el); + }; + }; + _ju.extend(VmlComponent, _jp.jsPlumbUIComponent, { + cleanup: function () { + if (this.bgCanvas) this.bgCanvas.parentNode.removeChild(this.bgCanvas); + if (this.canvas) this.canvas.parentNode.removeChild(this.canvas); + } + }); + + /* + * Base class for Vml connectors. extends VmlComponent. + */ + var VmlConnector = _jp.ConnectorRenderers.vml = function (params, component) { + this.strokeNode = null; + this.canvas = null; + VmlComponent.apply(this, arguments); + var clazz = this._jsPlumb.instance.connectorClass + (params.cssClass ? (" " + params.cssClass) : ""); + this.paint = function (style) { + if (style !== null) { + + // we need to be at least 1 pixel in each direction, because otherwise coordsize gets set to + // 0 and overlays cannot paint. + this.w = Math.max(this.w, 1); + this.h = Math.max(this.h, 1); + + var segments = this.getSegments(), p = { "path": "" }, + d = [this.x, this.y, this.w, this.h]; + + // create path from segments. + for (var i = 0; i < segments.length; i++) { + p.path += _jp.Segments.vml.SegmentRenderer.getPath(segments[i]); + p.path += " "; + } + + //* + if (style.outlineColor) { + var outlineWidth = style.outlineWidth || 1, + outlineStrokeWidth = style.lineWidth + (2 * outlineWidth), + outlineStyle = { + strokeStyle: _ju.convertStyle(style.outlineColor), + lineWidth: outlineStrokeWidth + }; + for (var aa in vmlAttributeMap) outlineStyle[aa] = style[aa]; + + if (this.bgCanvas == null) { + p["class"] = clazz; + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + this.bgCanvas = _node("shape", d, p, params.parent, this._jsPlumb.instance, true); + _pos(this.bgCanvas, d); + this.appendDisplayElement(this.bgCanvas, true); + this.initOpacityNodes(this.bgCanvas, ["stroke"]); + this.bgCanvas._jsPlumb = component; + } + else { + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + _pos(this.bgCanvas, d); + _atts(this.bgCanvas, p); + } + + _applyStyles(this.bgCanvas, outlineStyle, this); + } + //*/ + + if (this.canvas == null) { + p["class"] = clazz; + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + this.canvas = _node("shape", d, p, params.parent, this._jsPlumb.instance, true); + this.appendDisplayElement(this.canvas, true); + this.initOpacityNodes(this.canvas, ["stroke"]); + this.canvas._jsPlumb = component; + } + else { + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + _pos(this.canvas, d); + _atts(this.canvas, p); + } + + _applyStyles(this.canvas, style, this, this._jsPlumb.instance); + } + }; + + }; + _ju.extend(VmlConnector, VmlComponent, { + setVisible: function (v) { + if (this.canvas) { + this.canvas.style.display = v ? "block" : "none"; + } + if (this.bgCanvas) { + this.bgCanvas.style.display = v ? "block" : "none"; + } + } + }); + + /* + * + * Base class for Vml Endpoints. extends VmlComponent. + * + */ + var VmlEndpoint = _jp.VmlEndpoint = function (params) { + VmlComponent.apply(this, arguments); + this._jsPlumb.vml = null;//, opacityStrokeNode = null, opacityFillNode = null; + this.canvas = document.createElement("div"); + this.canvas.style.position = "absolute"; + this._jsPlumb.clazz = this._jsPlumb.instance.endpointClass + (params.cssClass ? (" " + params.cssClass) : ""); + + // TODO vml endpoint adds class to VML at constructor time. but the addClass method adds VML + // to the enclosing DIV. what to do? seems like it would be better to just target the div. + // HOWEVER...vml connection has no containing div. why not? it feels like it should. + + params._jsPlumb.appendElement(this.canvas, params.parent); + + this.paint = function (style, anchor) { + var p = { }, vml = this._jsPlumb.vml; + + _ju.sizeElement(this.canvas, this.x, this.y, this.w, this.h); + if (this._jsPlumb.vml == null) { + p["class"] = this._jsPlumb.clazz; + vml = this._jsPlumb.vml = this.getVml([0, 0, this.w, this.h], p, anchor, this.canvas, this._jsPlumb.instance); + + this.appendDisplayElement(vml, true); + this.appendDisplayElement(this.canvas, true); + + this.initOpacityNodes(vml, ["fill"]); + } + else { + _pos(vml, [0, 0, this.w, this.h]); + _atts(vml, p); + } + + _applyStyles(vml, style, this); + }; + }; + _ju.extend(VmlEndpoint, VmlComponent); + +// ******************************* vml segments ***************************************************** + + _jp.Segments.vml = { + SegmentRenderer: { + getPath: function (segment) { + return ({ + "Straight": function (segment) { + var d = segment.params; + return "m" + _conv(d.x1) + "," + _conv(d.y1) + " l" + _conv(d.x2) + "," + _conv(d.y2) + " e"; + }, + "Bezier": function (segment) { + var d = segment.params; + return "m" + _conv(d.x1) + "," + _conv(d.y1) + + " c" + _conv(d.cp1x) + "," + _conv(d.cp1y) + "," + _conv(d.cp2x) + "," + _conv(d.cp2y) + "," + _conv(d.x2) + "," + _conv(d.y2) + " e"; + }, + "Arc": function (segment) { + var d = segment.params, + xmin = Math.min(d.x1, d.x2), + xmax = Math.max(d.x1, d.x2), + ymin = Math.min(d.y1, d.y2), + ymax = Math.max(d.y1, d.y2), + sf = segment.anticlockwise ? 1 : 0, + pathType = (segment.anticlockwise ? "at " : "wa "), + makePosString = function () { + if (d.loopback) + return "0,0," + _conv(2 * d.r) + "," + _conv(2 * d.r); + + var xy = [ + null, + [ function () { + return [xmin, ymin ]; + }, function () { + return [xmin - d.r, ymin - d.r ]; + }], + [ function () { + return [xmin - d.r, ymin ]; + }, function () { + return [xmin, ymin - d.r ]; + }], + [ function () { + return [xmin - d.r, ymin - d.r ]; + }, function () { + return [xmin, ymin ]; + }], + [ function () { + return [xmin, ymin - d.r ]; + }, function () { + return [xmin - d.r, ymin ]; + }] + ][segment.segment][sf](); + + return _conv(xy[0]) + "," + _conv(xy[1]) + "," + _conv(xy[0] + (2 * d.r)) + "," + _conv(xy[1] + (2 * d.r)); + }; + + return pathType + " " + makePosString() + "," + _conv(d.x1) + "," + _conv(d.y1) + "," + _conv(d.x2) + "," + _conv(d.y2) + " e"; + } + + })[segment.type](segment); + } + } + }; + +// ******************************* /vml segments ***************************************************** + +// ******************************* vml endpoints ***************************************************** + + _jp.Endpoints.vml.Dot = function () { + _jp.Endpoints.Dot.apply(this, arguments); + VmlEndpoint.apply(this, arguments); + this.getVml = function (d, atts, anchor, parent, _jsPlumb) { + return _node("oval", d, atts, parent, _jsPlumb); + }; + }; + _ju.extend(_jp.Endpoints.vml.Dot, VmlEndpoint); + + _jp.Endpoints.vml.Rectangle = function () { + _jp.Endpoints.Rectangle.apply(this, arguments); + VmlEndpoint.apply(this, arguments); + this.getVml = function (d, atts, anchor, parent, _jsPlumb) { + return _node("rect", d, atts, parent, _jsPlumb); + }; + }; + _ju.extend(_jp.Endpoints.vml.Rectangle, VmlEndpoint); + + /* + * VML Image Endpoint is the same as the default image endpoint. + */ + _jp.Endpoints.vml.Image = _jp.Endpoints.Image; + + /** + * placeholder for Blank endpoint in vml renderer. + */ + _jp.Endpoints.vml.Blank = _jp.Endpoints.Blank; + +// ******************************* /vml endpoints ***************************************************** + +// ******************************* vml overlays ***************************************************** + + /** + * VML Label renderer. uses the default label renderer (which adds an element to the DOM) + */ + _jp.Overlays.vml.Label = _jp.Overlays.Label; + + /** + * VML Custom renderer. uses the default Custom renderer (which adds an element to the DOM) + */ + _jp.Overlays.vml.Custom = _jp.Overlays.Custom; + + /** + * Abstract VML arrow superclass + */ + var AbstractVmlArrowOverlay = function (superclass, originalArgs) { + superclass.apply(this, originalArgs); + VmlComponent.apply(this, originalArgs); + var self = this, path = null; + this.canvas = null; + this.isAppendedAtTopLevel = true; + var getPath = function (d) { + return "m " + _conv(d.hxy.x) + "," + _conv(d.hxy.y) + + " l " + _conv(d.tail[0].x) + "," + _conv(d.tail[0].y) + + " " + _conv(d.cxy.x) + "," + _conv(d.cxy.y) + + " " + _conv(d.tail[1].x) + "," + _conv(d.tail[1].y) + + " x e"; + }; + this.paint = function (params, containerExtents) { + // only draws for connectors, not endpoints. + if (params.component.canvas && containerExtents) { + var p = {}, d = params.d, connector = params.component; + if (params.strokeStyle) { + p.stroked = "true"; + p.strokecolor = _ju.convertStyle(params.strokeStyle, true); + } + if (params.lineWidth) p.strokeweight = params.lineWidth + "px"; + if (params.fillStyle) { + p.filled = "true"; + p.fillcolor = params.fillStyle; + } + + var xmin = Math.min(d.hxy.x, d.tail[0].x, d.tail[1].x, d.cxy.x), + ymin = Math.min(d.hxy.y, d.tail[0].y, d.tail[1].y, d.cxy.y), + xmax = Math.max(d.hxy.x, d.tail[0].x, d.tail[1].x, d.cxy.x), + ymax = Math.max(d.hxy.y, d.tail[0].y, d.tail[1].y, d.cxy.y), + w = Math.abs(xmax - xmin), + h = Math.abs(ymax - ymin), + dim = [xmin, ymin, w, h]; + + // for VML, we create overlays using shapes that have the same dimensions and + // coordsize as their connector - overlays calculate themselves relative to the + // connector (it's how it's been done since the original canvas implementation, because + // for canvas that makes sense). + p.path = getPath(d); + p.coordsize = (connector.w * scale) + "," + (connector.h * scale); + + dim[0] = connector.x; + dim[1] = connector.y; + dim[2] = connector.w; + dim[3] = connector.h; + + if (self.canvas == null) { + var overlayClass = connector._jsPlumb.overlayClass || ""; + var clazz = originalArgs && (originalArgs.length == 1) ? (originalArgs[0].cssClass || "") : ""; + p["class"] = clazz + " " + overlayClass; + self.canvas = _node("shape", dim, p, connector.canvas.parentNode, connector._jsPlumb.instance, true); + connector.appendDisplayElement(self.canvas, true); + } + else { + _pos(self.canvas, dim); + _atts(self.canvas, p); + } + } + }; + this.cleanup = function () { + if (this.canvas != null) this._jsPlumb.instance.removeElement(this.canvas); + }; + }; + _ju.extend(AbstractVmlArrowOverlay, [VmlComponent, _jp.Overlays.AbstractOverlay], { + setVisible: function (state) { + this.canvas.style.display = state ? "block" : "none"; + } + }); + + _jp.Overlays.vml.Arrow = function () { + AbstractVmlArrowOverlay.apply(this, [_jp.Overlays.Arrow, arguments]); + }; + _ju.extend(_jp.Overlays.vml.Arrow, [ _jp.Overlays.Arrow, AbstractVmlArrowOverlay ]); + + _jp.Overlays.vml.PlainArrow = function () { + AbstractVmlArrowOverlay.apply(this, [_jp.Overlays.PlainArrow, arguments]); + }; + _ju.extend(_jp.Overlays.vml.PlainArrow, [ _jp.Overlays.PlainArrow, AbstractVmlArrowOverlay ]); + + _jp.Overlays.vml.Diamond = function () { + AbstractVmlArrowOverlay.apply(this, [_jp.Overlays.Diamond, arguments]); + }; + _ju.extend(_jp.Overlays.vml.Diamond, [ _jp.Overlays.Diamond, AbstractVmlArrowOverlay ]); + +// ******************************* /vml overlays ***************************************************** + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the 'vanilla' adapter - having no external dependencies other than bundled libs. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil, + _jk = root.Katavorio, _jg = root.Biltong; + + var _getDragManager = function (instance, category) { + + category = category || "main"; + var key = "_katavorio_" + category; + var k = instance[key], + e = instance.getEventManager(); + + if (!k) { + k = new _jk({ + bind: e.on, + unbind: e.off, + getSize: jsPlumb.getSize, + getPosition: function (el) { + var o = instance.getOffset(el); + return [o.left, o.top]; + }, + setPosition: function (el, xy) { + el.style.left = xy[0] + "px"; + el.style.top = xy[1] + "px"; + }, + addClass: jsPlumb.addClass, + removeClass: jsPlumb.removeClass, + intersects: _jg.intersects, + indexOf: _ju.indexOf, + css: { + noSelect: instance.dragSelectClass, + droppable: "jsplumb-droppable", + draggable: "jsplumb-draggable", + drag: "jsplumb-drag", + selected: "jsplumb-drag-selected", + active: "jsplumb-drag-active", + hover: "jsplumb-drag-hover" + } + }); + instance[key] = k; + instance.bind("zoom", k.setZoom); + } + return k; + }; + + var _animProps = function (o, p) { + var _one = function (pName) { + if (p[pName]) { + if (_ju.isString(p[pName])) { + var m = p[pName].match(/-=/) ? -1 : 1, + v = p[pName].substring(2); + return o[pName] + (m * v); + } + else return p[pName]; + } + else + return o[pName]; + }; + return [ _one("left"), _one("top") ]; + }; + + _jp.extend(root.jsPlumbInstance.prototype, { + + animationSupported:true, + + scopeChange: function (el, elId, endpoints, scope, types) { + + }, + + getElement: function (el) { + if (el == null) return null; + // here we pluck the first entry if el was a list of entries. + // this is not my favourite thing to do, but previous versions of + // jsplumb supported jquery selectors, and it is possible a selector + // will be passed in here. + el = typeof el === "string" ? el : el.length != null && el.enctype == null ? el[0] : el; + return typeof el === "string" ? document.getElementById(el) : el; + }, + removeElement: function (element) { + _getDragManager(this).elementRemoved(element); + this.getEventManager().remove(element); + }, + // + // this adapter supports a rudimentary animation function. no easing is supported. only + // left/top properties are supported. property delta args are expected to be in the form + // + // +=x.xxxx + // + // or + // + // -=x.xxxx + // + doAnimate: function (el, properties, options) { + options = options || {}; + var o = this.getOffset(el), + ap = _animProps(o, properties), + ldist = ap[0] - o.left, + tdist = ap[1] - o.top, + d = options.duration || 250, + step = 15, steps = d / step, + linc = (step / d) * ldist, + tinc = (step / d) * tdist, + idx = 0, + int = setInterval(function () { + jsPlumb.setPosition(el, { + left: o.left + (linc * (idx + 1)), + top: o.top + (tinc * (idx + 1)) + }); + if (options.step != null) options.step(); + idx++; + if (idx >= steps) { + window.clearInterval(int); + if (options.complete != null) options.complete(); + } + }, step); + }, + // DRAG/DROP + destroyDraggable: function (el, category) { + _getDragManager(this, category).destroyDraggable(el); + }, + destroyDroppable: function (el, category) { + _getDragManager(this, category).destroyDroppable(el); + }, + initDraggable: function (el, options, category) { + _getDragManager(this, category).draggable(el, options); + }, + initDroppable: function (el, options, category) { + _getDragManager(this, category).droppable(el, options); + }, + isAlreadyDraggable: function (el) { + return el._katavorioDrag != null; + }, + isDragSupported: function (el, options) { + return true; + }, + isDropSupported: function (el, options) { + return true; + }, + isElementDraggable: function (el) { + el = jsPlumb.getElement(el); + return el._katavorioDrag && el._katavorioDrag.isEnabled(); + }, + getDragObject: function (eventArgs) { + return eventArgs[0].drag.getDragElement(); + }, + getDragScope: function (el) { + return el._katavorioDrag && el._katavorioDrag.scopes.join(" ") || ""; + }, + getDropEvent: function (args) { + return args[0].e; + }, + getDropScope: function (el) { + return el._katavorioDrop && el._katavorioDrop.scopes.join(" ") || ""; + }, + getUIPosition: function (eventArgs, zoom) { + return { + left: eventArgs[0].pos[0], + top: eventArgs[0].pos[1] + }; + }, + setDragFilter: function (el, filter, _exclude) { + if (el._katavorioDrag) { + el._katavorioDrag.setFilter(filter, _exclude); + } + }, + setElementDraggable: function (el, draggable) { + el = jsPlumb.getElement(el); + if (el._katavorioDrag) + el._katavorioDrag.setEnabled(draggable); + }, + setDragScope: function (el, scope) { + if (el._katavorioDrag) + el._katavorioDrag.k.setDragScope(el, scope); + }, + dragEvents: { + 'start': 'start', 'stop': 'stop', 'drag': 'drag', 'step': 'step', + 'over': 'over', 'out': 'out', 'drop': 'drop', 'complete': 'complete' + }, + animEvents: { + 'step': "step", 'complete': 'complete' + }, + stopDrag: function (el) { + if (el._katavorioDrag) + el._katavorioDrag.abort(); + }, +// MULTIPLE ELEMENT DRAG + // these methods are unique to this adapter, because katavorio + // supports dragging multiple elements. + addToDragSelection: function (spec) { + _getDragManager(this).select(spec); + }, + removeFromDragSelection: function (spec) { + _getDragManager(this).deselect(spec); + }, + clearDragSelection: function () { + _getDragManager(this).deselectAll(); + }, + getOriginalEvent: function (e) { + return e; + }, + // each adapter needs to use its own trigger method, because it triggers a drag. Mottle's trigger method + // works perfectly well but does not cause a drag to start with jQuery. Presumably this is due to some + // intricacy in the way in which jQuery UI's draggable method registers events. + trigger: function (el, event, originalEvent) { + this.getEventManager().trigger(el, event, originalEvent); + }, + doReset:function() { + // look for katavorio instances and reset each one if found. + for (var key in this) { + if (key.indexOf("_katavorio_") === 0) { + this[key].reset(); + } + } + } + }); + + var ready = function (f) { + var _do = function () { + if (/complete|loaded|interactive/.test(document.readyState) && typeof(document.body) != "undefined" && document.body != null) + f(); + else + setTimeout(_do, 9); + }; + + _do(); + }; + ready(_jp.init); + +}).call(this); diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/jquery.jsPlumb-1.7.6-min.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/jquery.jsPlumb-1.7.6-min.js new file mode 100644 index 000000000..3007893c6 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/dist/js/jquery.jsPlumb-1.7.6-min.js @@ -0,0 +1,6 @@ +(function(){"undefined"==typeof Math.sgn&&(Math.sgn=function(a){return 0==a?0:a>0?1:-1});var a={subtract:function(a,b){return{x:a.x-b.x,y:a.y-b.y}},dotProduct:function(a,b){return a.x*b.x+a.y*b.y},square:function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},scale:function(a,b){return{x:a.x*b,y:a.y*b}}},b=64,c=Math.pow(2,-b-1),d=function(b,c){for(var d=[],e=f(b,c),h=c.length-1,i=2*h-1,j=g(e,i,d,0),k=a.subtract(b,c[0]),m=a.square(k),n=0,o=0;j>o;o++){k=a.subtract(b,l(c,h,d[o],null,null));var p=a.square(k);m>p&&(m=p,n=d[o])}return k=a.subtract(b,c[h]),p=a.square(k),m>p&&(m=p,n=1),{location:n,distance:m}},e=function(a,b){var c=d(a,b);return{point:l(b,b.length-1,c.location,null,null),location:c.location}},f=function(b,c){for(var d=c.length-1,e=2*d-1,f=[],g=[],h=[],i=[],k=[[1,.6,.3,.1],[.4,.6,.6,.4],[.1,.3,.6,1]],l=0;d>=l;l++)f[l]=a.subtract(c[l],b);for(var l=0;d-1>=l;l++)g[l]=a.subtract(c[l+1],c[l]),g[l]=a.scale(g[l],3);for(var m=0;d-1>=m;m++)for(var n=0;d>=n;n++)h[m]||(h[m]=[]),h[m][n]=a.dotProduct(g[m],f[n]);for(l=0;e>=l;l++)i[l]||(i[l]=[]),i[l].y=0,i[l].x=parseFloat(l)/e;for(var o=d,p=d-1,q=0;o+p>=q;q++){var r=Math.max(0,q-p),s=Math.min(q,o);for(l=r;s>=l;l++)j=q-l,i[l+j].y+=h[j][l]*k[j][l]}return i},g=function(a,c,d,e){var f,j,m=[],n=[],o=[],p=[];switch(h(a,c)){case 0:return 0;case 1:if(e>=b)return d[0]=(a[0].x+a[c].x)/2,1;if(i(a,c))return d[0]=k(a,c),1}l(a,c,.5,m,n),f=g(m,c,o,e+1),j=g(n,c,p,e+1);for(var q=0;f>q;q++)d[q]=o[q];for(var q=0;j>q;q++)d[q+f]=p[q];return f+j},h=function(a,b){var c,d,e=0;c=d=Math.sgn(a[0].y);for(var f=1;b>=f;f++)c=Math.sgn(a[f].y),c!=d&&e++,d=c;return e},i=function(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;i=a[0].y-a[b].y,j=a[b].x-a[0].x,k=a[0].x*a[b].y-a[b].x*a[0].y;for(var t=max_distance_below=0,u=1;b>u;u++){var v=i*a[u].x+j*a[u].y+k;v>t?t=v:max_distance_below>v&&(max_distance_below=v)}return n=0,o=1,p=0,q=i,r=j,s=k-t,l=n*r-q*o,m=1/l,e=(o*s-r*p)*m,q=i,r=j,s=k-max_distance_below,l=n*r-q*o,m=1/l,f=(o*s-r*p)*m,g=Math.min(e,f),h=Math.max(e,f),d=h-g,c>d?1:0},k=function(a,b){var c=1,d=0,e=a[b].x-a[0].x,f=a[b].y-a[0].y,g=a[0].x-0,h=a[0].y-0,i=e*d-f*c,j=1/i,k=(e*h-f*g)*j;return 0+c*k},l=function(a,b,c,d,e){for(var f=[[]],g=0;b>=g;g++)f[0][g]=a[g];for(var h=1;b>=h;h++)for(var g=0;b-h>=g;g++)f[h]||(f[h]=[]),f[h][g]||(f[h][g]={}),f[h][g].x=(1-c)*f[h-1][g].x+c*f[h-1][g+1].x,f[h][g].y=(1-c)*f[h-1][g].y+c*f[h-1][g+1].y;if(null!=d)for(g=0;b>=g;g++)d[g]=f[g][0];if(null!=e)for(g=0;b>=g;g++)e[g]=f[b-g][g];return f[b][0]},m={},n=function(a){var b=m[a];if(!b){b=[];var c=function(){return function(b){return Math.pow(b,a)}},d=function(){return function(b){return Math.pow(1-b,a)}},e=function(a){return function(){return a}},f=function(){return function(a){return a}},g=function(){return function(a){return 1-a}},h=function(a){return function(b){for(var c=1,d=0;di;i++){for(var j=[new e(a)],k=0;a-i>k;k++)j.push(new f);for(var k=0;i>k;k++)j.push(new g);b.push(new h(j))}b.push(new d),m[a]=b}return b},o=function(a,b){for(var c=n(a.length-1),d=0,e=0,f=0;f0?1:-1,h=null;ed;)d+=.005*e,f=o(a,d),c+=p(f,b),b=f;return c},t=function(a,b,c){return r(a,b,c).point},u=function(a,b,c){return r(a,b,c).location},v=function(a,b){var c=o(a,b),d=o(a.slice(0,a.length-1),b),e=d.y-c.y,f=d.x-c.x;return 0==e?1/0:Math.atan(e/f)},w=function(a,b,c){var d=r(a,b,c);return d.location>1&&(d.location=1),d.location<0&&(d.location=0),v(a,d.location)},x=function(a,b,c,d){d=null==d?0:d;var e=r(a,b,d),f=v(a,e.location),g=Math.atan(-1/f),h=c/2*Math.sin(g),i=c/2*Math.cos(g);return[{x:e.point.x+i,y:e.point.y+h},{x:e.point.x-i,y:e.point.y-h}]};this.jsBezier={distanceFromCurve:d,gradientAtPoint:v,gradientAtPointAlongCurveFrom:w,nearestPointOnCurve:e,pointOnCurve:o,pointAlongCurveFrom:t,perpendicularToCurveAt:x,locationAlongCurveFrom:u,getLength:s}}).call(this),function(){"use strict";var a=this.Biltong={},b=function(a){return"[object Array]"===Object.prototype.toString.call(a)},c=function(a,c,d){return a=b(a)?a:[a.x,a.y],c=b(c)?c:[c.x,c.y],d(a,c)},d=a.gradient=function(a,b){return c(a,b,function(a,b){return b[0]==a[0]?b[1]>a[1]?1/0:-1/0:b[1]==a[1]?b[0]>a[0]?0:-0:(b[1]-a[1])/(b[0]-a[0])})},e=(a.normal=function(a,b){return-1/d(a,b)},a.lineLength=function(a,b){return c(a,b,function(a,b){return Math.sqrt(Math.pow(b[1]-a[1],2)+Math.pow(b[0]-a[0],2))})},a.quadrant=function(a,b){return c(a,b,function(a,b){return b[0]>a[0]?b[1]>a[1]?2:1:b[0]==a[0]?b[1]>a[1]?2:1:b[1]>a[1]?3:4})}),f=(a.theta=function(a,b){return c(a,b,function(a,b){var c=d(a,b),f=Math.atan(c),g=e(a,b);return(4==g||3==g)&&(f+=Math.PI),0>f&&(f+=2*Math.PI),f})},a.intersects=function(a,b){var c=a.x,d=a.x+a.w,e=a.y,f=a.y+a.h,g=b.x,h=b.x+b.w,i=b.y,j=b.y+b.h;return g>=c&&d>=g&&i>=e&&f>=i||h>=c&&d>=h&&i>=e&&f>=i||g>=c&&d>=g&&j>=e&&f>=j||h>=c&&d>=g&&j>=e&&f>=j||c>=g&&h>=c&&e>=i&&j>=e||d>=g&&h>=d&&e>=i&&j>=e||c>=g&&h>=c&&f>=i&&j>=f||d>=g&&h>=c&&f>=i&&j>=f},a.encloses=function(a,b,c){var d=a.x,e=a.x+a.w,f=a.y,g=a.y+a.h,h=b.x,i=b.x+b.w,j=b.y,k=b.y+b.h,l=function(a,b,d,e){return c?b>=a&&d>=e:b>a&&d>e};return l(d,h,e,i)&&l(f,j,g,k)},[null,[1,-1],[1,1],[-1,1],[-1,-1]]),g=[null,[-1,-1],[-1,1],[1,1],[1,-1]];a.pointOnLine=function(a,b,c){var h=d(a,b),i=e(a,b),j=c>0?f[i]:g[i],k=Math.atan(h),l=Math.abs(c*Math.sin(k))*j[1],m=Math.abs(c*Math.cos(k))*j[0];return{x:a.x+m,y:a.y+l}},a.perpendicularLineTo=function(a,b,c){var e=d(a,b),f=Math.atan(-1/e),g=c/2*Math.sin(f),h=c/2*Math.cos(f);return[{x:b.x+h,y:b.y+g},{x:b.x-h,y:b.y-g}]}}.call(this),function(){"use strict";var a={android:navigator.userAgent.toLowerCase().indexOf("android")>-1},b=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ec&&a[c]!=b;c++);c-1&&9>t,v=function(a,b){if(null==a)return[0,0];var c=A(a),d=z(c,0);return[d[b+"X"],d[b+"Y"]]},w=function(a){return null==a?[0,0]:u?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:v(a,"page")},x=function(a){return v(a,"screen")},y=function(a){return v(a,"client")},z=function(a,b){return a.item?a.item(b):a[b]},A=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},B=function(a){return A(a).length},C=function(a,b,c,d){if(g(a,b,c),d.__tauid=c.__tauid,a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent){var e=b+c.__tauid;a["e"+e]=c,a[e]=function(){a["e"+e]&&a["e"+e](window.event)},a.attachEvent("on"+b,a[e])}},D=function(a,b,d){null!=d&&E(a,function(){var e=c(this);if(h(e,b,d),null!=d.__tauid)if(e.removeEventListener)e.removeEventListener(b,d,!1),q&&s[b]&&e.removeEventListener(s[b],d,!1);else if(this.detachEvent){var f=b+d.__tauid;e[f]&&e.detachEvent("on"+b,e[f]),e[f]=null,e["e"+f]=null}d.__taTouchProxy&&D(a,d.__taTouchProxy[1],d.__taTouchProxy[0])})},E=function(a,b){if(null!=a){a="undefined"!=typeof Window&&"unknown"!=typeof a.top&&a==a.top?[a]:"string"!=typeof a&&null==a.tagName&&null!=a.length?a:"string"==typeof a?document.querySelectorAll(a):[a];for(var c=0;c=f.length,i=function(){return e[g[1]]||function(){return e[g[1]]=[],e[g[1]]}()};if(h)g?i()[g[3]]=c:e[a]=c;else if(g){var j=i();e=j[g[3]]||function(){return j[g[3]]={},j[g[3]]}()}else e=e[a]||function(){return e[a]={},e[a]}()}),a}},functionChain:function(a,b,c){for(var d=0;d-1&&a.splice(c,1),-1!=c},remove:function(a,b){var c=k.indexOf(a,b);return c>-1&&a.splice(c,1),-1!=c},addWithFunction:function(a,b,c){-1==k.findWithFunction(a,c)&&a.push(b)},addToList:function(a,b,c,d){var e=a[b];return null==e&&(e=[],a[b]=e),e[d?"unshift":"push"](c),e},extend:function(b,c){var d;for(c=a(c)?c:[c],d=0;d2)for(d=2;dh&&j!==!1;){if(c[d])a[d][h].apply(this,[e,f]);else try{j=a[d][h].apply(this,[e,f])}catch(l){k.log("jsPlumb: fire failed for event "+d+" : "+l)}h++,(null==a||null==a[d])&&(i=!0)}}return this},this.unbind=function(b,c){if(0===arguments.length)a={};else if(1===arguments.length){if("string"==typeof b)delete a[b];else if(b.__jsPlumb){var d;for(var e in b.__jsPlumb)d=b.__jsPlumb[e],k.remove(a[d]||[],b)}}else 2===arguments.length&&k.remove(a[b]||[],c);return this},this.getListener=function(b){return a[b]},this.setSuspendEvents=function(a){b=a},this.isSuspendEvents=function(){return b},this.silently=function(a){this.setSuspendEvents(!0);try{a()}catch(b){jsPlumbUtil.log("Cannot execute silent function "+b)}this.setSuspendEvents(!1)},this.cleanupListeners=function(){for(var b in a)a[b]=null}},k.EventGenerator.prototype={cleanup:function(){this.cleanupListeners()}},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e})}.call(this),function(){"use strict";var a=this,b=a.jsPlumbUtil;b.ieVersion=/MSIE\s([\d.]+)/.test(navigator.userAgent)?new Number(RegExp.$1):-1,b.oldIE=b.ieVersion>-1&&b.ieVersion<9,b.matchesSelector=function(a,b,c){c=c||a.parentNode;for(var d=c.querySelectorAll(b),e=0;ef;f++)d&&d==e[f]||e[f].setHover(b,!0,c)},i=function(a){return null==a?null:a.split(" ")},j=function(a,b,c){for(var d in b)a[d]=c},k=function(a,b,c){if(a.getDefaultType){var e=a.getTypeDescriptor(),f={},g=a.getDefaultType(),h=d.merge({},g);j(f,g,"__default");for(var i=0,k=a._jsPlumb.types.length;k>i;i++){var l=a._jsPlumb.types[i];if("__default"!==l){var m=a._jsPlumb.instance.getType(l,e);null!=m&&(h=d.merge(h,m,["cssClass"]),j(f,m,l))}}b&&(h=d.populate(h,b)),a.applyType(h,c,f),c||a.repaint()}},l=window.jsPlumbUIComponent=function(a){jsPlumbUtil.EventGenerator.apply(this,arguments);var b=this,c=arguments,e=b.idPrefix,f=e+(new Date).getTime();this._jsPlumb={instance:a._jsPlumb,parameters:a.parameters||{},paintStyle:null,hoverPaintStyle:null,paintStyleInUse:null,hover:!1,beforeDetach:a.beforeDetach,beforeDrop:a.beforeDrop,overlayPlacements:[],hoverClass:a.hoverClass||a._jsPlumb.Defaults.HoverClass,types:[],typeCache:{}},this.cacheTypeItem=function(a,b,c){this._jsPlumb.typeCache[c]=this._jsPlumb.typeCache[c]||{},this._jsPlumb.typeCache[c][a]=b},this.getCachedTypeItem=function(a,b){return this._jsPlumb.typeCache[b]?this._jsPlumb.typeCache[b][a]:null},this.getId=function(){return f};var g=a.overlays||[],h={};if(this.defaultOverlayKeys){for(var i=0;if;f++)this.hasType(d[f])||(this._jsPlumb.types.push(d[f]),e=!0);e&&k(this,b,c)}},removeType:function(a,b){var c=i(a),e=!1,f=function(a){var b=d.indexOf(this._jsPlumb.types,a);return-1!=b?(m(this,b),this._jsPlumb.types.splice(b,1),!0):!1}.bind(this);if(null!=c){for(var g=0,h=c.length;h>g;g++)e=f(c[g])||e;e&&k(this,null,b)}},clearTypes:function(a){for(var b=this._jsPlumb.types.length,c=0;b>c;c++)m(this,0),this._jsPlumb.types.splice(0,1);k(this,{},a)},toggleType:function(a,b,c){var d=i(a);if(null!=d){for(var e=0,f=d.length;f>e;e++){var g=jsPlumbUtil.indexOf(this._jsPlumb.types,d[e]);-1!=g?(m(this,g),this._jsPlumb.types.splice(g,1)):this._jsPlumb.types.push(d[e])}k(this,b,c)}},applyType:function(a,b){if(this.setPaintStyle(a.paintStyle,b),this.setHoverPaintStyle(a.hoverPaintStyle,b),a.parameters)for(var c in a.parameters)this.setParameter(c,a.parameters[c]);this._jsPlumb.paintStyleInUse=this.getPaintStyle()},setPaintStyle:function(a,b){this._jsPlumb.paintStyle=a,this._jsPlumb.paintStyleInUse=this._jsPlumb.paintStyle,f(this),b||this.repaint()},getPaintStyle:function(){return this._jsPlumb.paintStyle},setHoverPaintStyle:function(a,b){this._jsPlumb.hoverPaintStyle=a,f(this),b||this.repaint()},getHoverPaintStyle:function(){return this._jsPlumb.hoverPaintStyle},destroy:function(a){(a||null==this.typeId)&&(this.cleanupListeners(),this.clone=null,this._jsPlumb=null)},isHover:function(){return this._jsPlumb.hover},setHover:function(a,b,c){if(this._jsPlumb&&!this._jsPlumb.instance.currentlyDragging&&!this._jsPlumb.instance.isHoverSuspended()){if(this._jsPlumb.hover=a,null!=this.canvas){if(null!=this._jsPlumb.instance.hoverClass){var d=a?"addClass":"removeClass";this._jsPlumb.instance[d](this.canvas,this._jsPlumb.instance.hoverClass)}null!=this._jsPlumb.hoverClass&&this._jsPlumb.instance[d](this.canvas,this._jsPlumb.hoverClass)}null!=this._jsPlumb.hoverPaintStyle&&(this._jsPlumb.paintStyleInUse=a?this._jsPlumb.hoverPaintStyle:this._jsPlumb.paintStyle,this._jsPlumb.instance.isSuspendDrawing()||(c=c||e(),this.repaint({timestamp:c,recalc:!1}))),this.getAttachedElements&&!b&&h(this,a,e(),this)}}});var n=0,o=function(){var a=n+1;return n++,a},p=window.jsPlumbInstance=function(b){this.Defaults={Anchor:"Bottom",Anchors:[null,null],ConnectionsDetachable:!0,ConnectionOverlays:[],Connector:"Bezier",Container:null,DoNotThrowErrors:!1,DragOptions:{},DropOptions:{},Endpoint:"Dot",EndpointOverlays:[],Endpoints:[null,null],EndpointStyle:{fillStyle:"#456"},EndpointStyles:[null,null],EndpointHoverStyle:null,EndpointHoverStyles:[null,null],HoverPaintStyle:null,LabelStyle:{color:"black"},LogEnabled:!1,Overlays:[],MaxConnections:1,PaintStyle:{lineWidth:4,strokeStyle:"#456"},ReattachConnections:!1,RenderMode:"svg",Scope:"jsPlumb_DefaultScope"},b&&q.extend(this.Defaults,b),this.logEnabled=this.Defaults.LogEnabled,this._connectionTypes={},this._endpointTypes={},jsPlumbUtil.EventGenerator.apply(this);var f=this,h=o(),i=f.bind,j={},k=1,m=function(a){if(null==a)return null;if(3==a.nodeType||8==a.nodeType)return{el:a,text:!0};var b=f.getElement(a);return{el:b,id:jsPlumbUtil.isString(a)&&null==b?a:Y(b)}};this.getInstanceIndex=function(){return h},this.setZoom=function(a,b){return jsPlumbUtil.oldIE||(k=a,f.fire("zoom",k),b&&f.repaintEverything()),!jsPlumbUtil.oldIE},this.getZoom=function(){return k};for(var n in this.Defaults)j[n]=this.Defaults[n];var p,r=[];this.unbindContainer=function(){if(null!=p&&r.length>0)for(var a=0;a *",function(c){b(a,c)}),c(a,"._jsPlumb_endpoint, ._jsPlumb_endpoint > *, ._jsPlumb_endpoint svg *",function(c){b(a,c)}),c(a,"._jsPlumb_overlay, ._jsPlumb_overlay *",function(c){b(a,c)})},e=0;e0?arguments[0].selection:[[a,f.getUIPosition(arguments,f.getZoom(),!0)]];for(var c=function(a){K(a[0],a[1]),f.removeClass(a[0],"jsPlumb_dragged"),f.select({source:a[0]}).removeClass(f.elementDraggingClass+" "+f.sourceElementDraggingClass,!0),f.select({target:a[0]}).removeClass(f.elementDraggingClass+" "+f.targetElementDraggingClass,!0),f.getDragManager().dragEnded(a[0])},d=0;de;e++)c.overlays.push(c.sourceEndpoint.connectorOverlays[e])}!c["pointer-events"]&&c.sourceEndpoint&&c.sourceEndpoint.connectorPointerEvents&&(c["pointer-events"]=c.sourceEndpoint.connectorPointerEvents);var h=function(a,b){var c=q.extend({},a);for(var d in b)b[d]&&(c[d]=b[d]);return c},i=function(a,b,d){return f.addEndpoint(a,h(b,{anchor:c.anchors?c.anchors[d]:c.anchor,endpoint:c.endpoints?c.endpoints[d]:c.endpoint,paintStyle:c.endpointStyles?c.endpointStyles[d]:c.endpointStyle,hoverPaintStyle:c.endpointHoverStyles?c.endpointHoverStyles[d]:c.endpointHoverStyle}))},j=function(a,b,d){if(c[a]&&!c[a].endpoint&&!c[a+"Endpoint"]&&!c.newConnection){var e=Y(c[a]),f=d[e];if(f){if(!f.enabled)return!1;var g=null!=f.endpoint&&f.endpoint._jsPlumb?f.endpoint:i(c[a],f.def,b);if(g.isFull())return!1;c[a+"Endpoint"]=g,g._doNotDeleteOnDetach=!1,g._deleteOnDetach=!0,f.uniqueEndpoint&&(f.endpoint?g.finalEndpoint=f.endpoint:(f.endpoint=g,g._deleteOnDetach=!1,g._doNotDeleteOnDetach=!0))}}};return j("source",0,this.sourceEndpointDefinitions)!==!1&&j("target",1,this.targetEndpointDefinitions)!==!1?(c.sourceEndpoint&&c.targetEndpoint&&(N(c.sourceEndpoint,c.targetEndpoint)||(c=null)),c):void 0 +}.bind(f),P=function(a){var b=f.Defaults.ConnectionType||f.getDefaultConnectionType();a._jsPlumb=f,a.newConnection=P,a.newEndpoint=R,a.endpointsByUUID=w,a.endpointsByElement=v,a.finaliseConnection=Q,a.id="con_"+I();var c=new b(a);return c.isDetachable()&&(c.endpoints[0].initDraggable(),c.endpoints[1].initDraggable()),c},Q=f.finaliseConnection=function(a,b,c,d){if(b=b||{},a.suspendedEndpoint||u.push(a),a.endpoints[0].isTemporarySource=!1,(null==a.suspendedEndpoint||d)&&f.anchorManager.newConnection(a),K(a.source),!b.doNotFireConnectionEvent&&b.fireEvent!==!1){var e={connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]};f.fire("connection",e,c)}},R=function(a,b){var c=f.Defaults.EndpointType||q.Endpoint,d=q.extend({},a);d._jsPlumb=f,d.newConnection=P,d.newEndpoint=R,d.endpointsByUUID=w,d.endpointsByElement=v,d.fireDetachEvent=_,d.elementId=b||Y(d.source);var e=new c(d);return e.id="ep_"+I(),pb(d.elementId,d.source),q.headless||f.getDragManager().endpointAdded(d.source,b),e},S=function(a,b,c){var d=v[a];if(d&&d.length)for(var e=0,f=d.length;f>e;e++){for(var g=0,h=d[e].connections.length;h>g;g++){var i=b(d[e].connections[g]);if(i)return}c&&c(d[e])}},T=function(a,b){return q.each(a,function(a){f.isDragSupported(a)&&(A[f.getAttribute(a,"id")]=b,f.setElementDraggable(a,b))})},U=function(a,b,c){b="block"===b;var d=null;c&&(d=b?function(a){a.setVisible(!0,!0,!0)}:function(a){a.setVisible(!1,!0,!0)});var e=m(a);S(e.id,function(a){if(b&&c){var d=a.sourceId===e.id?1:0;a.endpoints[d].isVisible()&&a.setVisible(!0)}else a.setVisible(b)},d)},V=function(a){return q.each(a,function(a){var b=f.getAttribute(a,"id"),c=null==A[b]?!1:A[b];return c=!c,A[b]=c,f.setDraggable(a,c),c}.bind(this))},W=function(a,b){var c=null;b&&(c=function(a){var b=a.isVisible();a.setVisible(!b)}),S(a,function(a){var b=a.isVisible();a.setVisible(!b)},c)},X=function(a){var b=y[a];return b?{o:b,s:C[a]}:qb({elId:a})},Y=function(a,b,c){if(jsPlumbUtil.isString(a))return a;if(null==a)return null;var d=f.getAttribute(a,"id");return d&&"undefined"!==d||(2==arguments.length&&void 0!==arguments[1]?d=b:(1==arguments.length||3==arguments.length&&!arguments[2])&&(d="jsPlumb_"+h+"_"+I()),c||f.setAttribute(a,"id",d)),d};this.setConnectionBeingDragged=function(a){B=a},this.isConnectionBeingDragged=function(){return B},this.connectorClass="_jsPlumb_connector",this.connectorOutlineClass="_jsPlumb_connector_outline",this.connectedClass="_jsPlumb_connected",this.hoverClass="_jsPlumb_hover",this.endpointClass="_jsPlumb_endpoint",this.endpointConnectedClass="_jsPlumb_endpoint_connected",this.endpointFullClass="_jsPlumb_endpoint_full",this.endpointDropAllowedClass="_jsPlumb_endpoint_drop_allowed",this.endpointDropForbiddenClass="_jsPlumb_endpoint_drop_forbidden",this.overlayClass="_jsPlumb_overlay",this.draggingClass="_jsPlumb_dragging",this.elementDraggingClass="_jsPlumb_element_dragging",this.sourceElementDraggingClass="_jsPlumb_source_element_dragging",this.targetElementDraggingClass="_jsPlumb_target_element_dragging",this.endpointAnchorClassPrefix="_jsPlumb_endpoint_anchor",this.hoverSourceClass="_jsPlumb_source_hover",this.hoverTargetClass="_jsPlumb_target_hover",this.dragSelectClass="_jsPlumb_drag_select",this.Anchors={},this.Connectors={svg:{},vml:{}},this.Endpoints={svg:{},vml:{}},this.Overlays={svg:{},vml:{}},this.ConnectorRenderers={},this.SVG="svg",this.VML="vml",this.addEndpoint=function(a,b,c){c=c||{};var e=q.extend({},c);q.extend(e,b),e.endpoint=e.endpoint||f.Defaults.Endpoint,e.paintStyle=e.paintStyle||f.Defaults.EndpointStyle;for(var g=[],h=d.isArray(a)||null!=a.length&&!d.isString(a)?a:[a],i=0,j=h.length;j>i;i++){e.source=f.getElement(h[i]),nb(e.source);var k=Y(e.source),l=R(e,k),m=pb(k,e.source).info.o;d.addToList(v,k,l),D||l.paint({anchorLoc:l.anchor.compute({xy:[m.left,m.top],wh:C[k],element:l,timestamp:E}),timestamp:E}),g.push(l),l._doNotDeleteOnDetach=!0}return 1==g.length?g[0]:g},this.addEndpoints=function(a,b,c){for(var e=[],g=0,h=b.length;h>g;g++){var i=f.addEndpoint(a,b[g],c);d.isArray(i)?Array.prototype.push.apply(e,i):e.push(i)}return e},this.animate=function(a,b,c){if(!this.animationSupported)return!1;c=c||{};var e=f.getElement(a),g=Y(e),h=q.animEvents.step,i=q.animEvents.complete;c[h]=d.wrap(c[h],function(){f.revalidate(g)}),c[i]=d.wrap(c[i],function(){f.revalidate(g)}),f.doAnimate(e,b,c)},this.checkCondition=function(a){var b=f.getListener(a),c=!0;if(b&&b.length>0){var e=Array.prototype.slice.call(arguments,1);try{for(var g=0,h=b.length;h>g;g++)c=c&&b[g].apply(b[g],e)}catch(i){d.log(f,"cannot check condition ["+a+"]"+i)}}return c},this.connect=function(a,b){var c,d=O(a,b);if(d){if(null==d.source&&null==d.sourceEndpoint)return jsPlumbUtil.log("Cannot establish connection - source does not exist"),void 0;if(null==d.target&&null==d.targetEndpoint)return jsPlumbUtil.log("Cannot establish connection - target does not exist"),void 0;nb(d.source),c=P(d),Q(c,d)}return c};var Z=[{el:"source",elId:"sourceId",epDefs:"sourceEndpointDefinitions"},{el:"target",elId:"targetId",epDefs:"targetEndpointDefinitions"}],$=function(a,b,c,d){var e,f,g,h=Z[c],i=a[h.elId],j=(a[h.el],a.endpoints[c]),k={index:c,originalSourceId:0===c?i:a.sourceId,newSourceId:a.sourceId,originalTargetId:1==c?i:a.targetId,newTargetId:a.targetId,connection:a};if(b.constructor==q.Endpoint)e=b,e.addConnection(a);else if(f=Y(b),g=this[h.epDefs][f],f===a[h.elId])e=null;else if(g){if(!g.enabled)return;e=null!=g.endpoint&&g.endpoint._jsPlumb?g.endpoint:this.addEndpoint(b,g.def),g.uniqueEndpoint&&(g.endpoint=e),e._doNotDeleteOnDetach=!1,e._deleteOnDetach=!0,e.addConnection(a)}else e=a.makeEndpoint(0===c,b,f),e._doNotDeleteOnDetach=!1,e._deleteOnDetach=!0;return null!=e&&(j.detachFromConnection(a),a.endpoints[c]=e,a[h.el]=e.element,a[h.elId]=e.elementId,k[0===c?"newSourceId":"newTargetId"]=e.elementId,ab(k),d||a.repaint()),k}.bind(this);this.setSource=function(a,b,c){var d=$(a,b,0,c);this.anchorManager.sourceChanged(d.originalSourceId,d.newSourceId,a)},this.setTarget=function(a,b,c){var d=$(a,b,1,c);this.anchorManager.updateOtherEndpoint(d.originalSourceId,d.originalTargetId,d.newTargetId,a)},this.deleteEndpoint=function(a,b){var c="string"==typeof a?w[a]:a;return c&&f.deleteObject({endpoint:c,dontUpdateHover:b}),f},this.deleteEveryEndpoint=function(){var a=f.setSuspendDrawing(!0);for(var b in v){var c=v[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)f.deleteEndpoint(c[d],!0)}return v={},x={},w={},f.anchorManager.reset(),f.getDragManager().reset(),a||f.setSuspendDrawing(!1),f};var _=function(a,b,c){var d=f.Defaults.ConnectionType||f.getDefaultConnectionType(),e=a.constructor==d,g=e?{connection:a,source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]}:a;b&&f.fire("connectionDetached",g,c),f.anchorManager.connectionDetached(g)},ab=f.fireMoveEvent=function(a,b){f.fire("connectionMoved",a,b)};this.unregisterEndpoint=function(a){a._jsPlumb.uuid&&(w[a._jsPlumb.uuid]=null),f.anchorManager.deleteEndpoint(a);for(var b in v){var c=v[b];if(c){for(var d=[],e=0,g=c.length;g>e;e++)c[e]!=a&&d.push(c[e]);v[b]=d}v[b].length<1&&delete v[b]}},this.detach=function(){if(0!==arguments.length){var a=f.Defaults.ConnectionType||f.getDefaultConnectionType(),b=arguments[0].constructor==a,c=2==arguments.length?b?arguments[1]||{}:arguments[0]:arguments[0],d=c.fireEvent!==!1,e=c.forceDetach,g=b?arguments[0]:c.connection;if(g)(e||jsPlumbUtil.functionChain(!0,!1,[[g.endpoints[0],"isDetachAllowed",[g]],[g.endpoints[1],"isDetachAllowed",[g]],[g,"isDetachAllowed",[g]],[f,"checkCondition",["beforeDetach",g]]]))&&g.endpoints[0].detach(g,!1,!0,d);else{var h=q.extend({},c);if(h.uuids)L(h.uuids[0]).detachFrom(L(h.uuids[1]),d);else if(h.sourceEndpoint&&h.targetEndpoint)h.sourceEndpoint.detachFrom(h.targetEndpoint);else{var i=Y(f.getElement(h.source)),j=Y(f.getElement(h.target));S(i,function(a){(a.sourceId==i&&a.targetId==j||a.targetId==i&&a.sourceId==j)&&f.checkCondition("beforeDetach",a)&&a.endpoints[0].detach(a,!1,!0,d)})}}}},this.detachAllConnections=function(a,b){b=b||{},a=f.getElement(a);var c=Y(a),d=v[c];if(d&&d.length)for(var e=0,g=d.length;g>e;e++)d[e].detachAll(b.fireEvent!==!1,b.forceDetach);return f},this.detachEveryConnection=function(a){return a=a||{},f.batch(function(){for(var b in v){var c=v[b];if(c&&c.length)for(var d=0,e=c.length;e>d;d++)c[d].detachAll(a.fireEvent!==!1,a.forceDetach)}u.length=0}),f},this.deleteObject=function(a){var b={endpoints:{},connections:{},endpointCount:0,connectionCount:0},c=a.fireEvent!==!1,d=a.deleteAttachedObjects!==!1,e=function(c){if(null!=c&&null==b.connections[c.id]&&(a.dontUpdateHover||null==c._jsPlumb||c.setHover(!1),b.connections[c.id]=c,b.connectionCount++,d))for(var e=0;ec;c++)e=m(a[c]),e.el&&M(e.el,!0,b,e.id);else e=m(a),e.el&&M(e.el,!0,b,e.id);return f};var bb=function(a,b,c,d){for(var e=0,f=a.length;f>e;e++)a[e][b].apply(a[e],c);return d(a)},cb=function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d.push([a[e][b].apply(a[e],c),a[e]]);return d},db=function(a,b,c){return function(){return bb(a,b,arguments,c)}},eb=function(a,b){return function(){return cb(a,b,arguments)}},fb=function(a,b){var c=[];if(a)if("string"==typeof a){if("*"===a)return a;c.push(a)}else if(b)c=a;else if(a.length)for(var d=0,e=a.length;e>d;d++)c.push(m(a[d]).id);else c.push(m(a).id);return c},gb=function(a,b,c){return"*"===a?!0:a.length>0?-1!=jsPlumbUtil.indexOf(a,b):!c};this.getConnections=function(a,b){a?a.constructor==String&&(a={scope:a}):a={};for(var c=a.scope||f.getDefaultScope(),d=fb(c,!0),e=fb(a.source),g=fb(a.target),h=!b&&d.length>1?{}:[],i=function(a,c){if(!b&&d.length>1){var e=h[a];null==e&&(e=h[a]=[]),e.push(c)}else h.push(c)},j=0,k=u.length;k>j;j++){var l=u[j];gb(d,l.scope)&&gb(e,l.sourceId)&&gb(g,l.targetId)&&i(l.scope,l)}return h};var hb=function(a,b){return function(c){for(var d=0,e=a.length;e>d;d++)c(a[d]);return b(a)}},ib=function(a){return function(b){return a[b]}},jb=function(a,b){var c,d,e={length:a.length,each:hb(a,b),get:ib(a)},f=["setHover","removeAllOverlays","setLabel","addClass","addOverlay","removeOverlay","removeOverlays","showOverlay","hideOverlay","showOverlays","hideOverlays","setPaintStyle","setHoverPaintStyle","setSuspendEvents","setParameter","setParameters","setVisible","repaint","addType","toggleType","removeType","removeClass","setType","bind","unbind"],g=["getLabel","getOverlay","isHover","getParameter","getParameters","getPaintStyle","getHoverPaintStyle","isVisible","hasType","getType","isSuspendEvents"];for(c=0,d=f.length;d>c;c++)e[f[c]]=db(a,f[c],b);for(c=0,d=g.length;d>c;c++)e[g[c]]=eb(a,g[c]);return e},kb=function(a){var b=jb(a,kb);return q.extend(b,{setDetachable:db(a,"setDetachable",kb),setReattach:db(a,"setReattach",kb),setConnector:db(a,"setConnector",kb),detach:function(){for(var b=0,c=a.length;c>b;b++)f.detach(a[b])},isDetachable:eb(a,"isDetachable"),isReattach:eb(a,"isReattach")})},lb=function(a){var b=jb(a,lb);return q.extend(b,{setEnabled:db(a,"setEnabled",lb),setAnchor:db(a,"setAnchor",lb),isEnabled:eb(a,"isEnabled"),detachAll:function(){for(var b=0,c=a.length;c>b;b++)a[b].detachAll()},remove:function(){for(var b=0,c=a.length;c>b;b++)f.deleteObject({endpoint:a[b]})}})};this.select=function(a){return a=a||{},a.scope=a.scope||"*",kb(a.connections||f.getConnections(a,!0))},this.selectEndpoints=function(a){a=a||{},a.scope=a.scope||"*";var b=!a.element&&!a.source&&!a.target,c=b?"*":fb(a.element),d=b?"*":fb(a.source),e=b?"*":fb(a.target),f=fb(a.scope,!0),g=[];for(var h in v){var i=gb(c,h,!0),j=gb(d,h,!0),k="*"!=d,l=gb(e,h,!0),m="*"!=e;if(i||j||l)a:for(var n=0,o=v[h].length;o>n;n++){var p=v[h][n];if(gb(f,p.scope,!0)){var q=k&&d.length>0&&!p.isSource,r=m&&e.length>0&&!p.isTarget;if(q||r)continue a;g.push(p)}}}return lb(g)},this.getAllConnections=function(){return u},this.getDefaultScope=function(){return F},this.getEndpoint=L,this.getEndpoints=function(a){return v[m(a).id]},this.getDefaultEndpointType=function(){return q.Endpoint},this.getDefaultConnectionType=function(){return q.Connection},this.getId=Y,this.appendElement=J;var mb=!1;this.isHoverSuspended=function(){return mb},this.setHoverSuspended=function(a){mb=a},this.hide=function(a,b){return U(a,"none",b),f},this.idstamp=I,this.connectorsInitialized=!1,this.registerConnectorType=function(a,b){c.push([a,b])};var nb=function(a){if(!p&&a){var b=f.getElement(a);b.offsetParent&&f.setContainer(b.offsetParent)}},ob=function(){f.Defaults.Container&&f.setContainer(f.Defaults.Container)},pb=f.manage=function(a,b){return x[a]||(x[a]={el:b,endpoints:[],connections:[]},x[a].info=qb({elId:a,timestamp:E})),x[a]},qb=this.updateOffset=function(a){var b,c=a.timestamp,d=a.recalc,e=a.offset,g=a.elId;return D&&!c&&(c=E),!d&&c&&c===z[g]?{o:a.offset||y[g],s:C[g]}:(d||!e&&null==y[g]?(b=x[g]?x[g].el:null,null!=b&&(C[g]=f.getSize(b),y[g]=f.getOffset(b),z[g]=c)):(y[g]=e||y[g],null==C[g]&&(b=x[g].el,null!=b&&(C[g]=f.getSize(b))),z[g]=c),y[g]&&!y[g].right&&(y[g].right=y[g].left+C[g][0],y[g].bottom=y[g].top+C[g][1],y[g].width=C[g][0],y[g].height=C[g][1],y[g].centerx=y[g].left+y[g].width/2,y[g].centery=y[g].top+y[g].height/2),{o:y[g],s:C[g]})};this.init=function(){a=q.getRenderModes();var b=function(a,b,c){q.Connectors[a][b]=function(){c.apply(this,arguments),q.ConnectorRenderers[a].apply(this,arguments)},jsPlumbUtil.extend(q.Connectors[a][b],[c,q.ConnectorRenderers[a]])};if(!q.connectorsInitialized){for(var d=0;d=4?[c[2],c[3]]:[0,0],offsets:c.length>=6?[c[4],c[5]]:[0,0],elementId:e,jsPlumbInstance:f,cssClass:7==c.length?c[6]:null};g=new q.Anchor(h),g.clone=function(){return new q.Anchor(h)}}return g.id||(g.id="anchor_"+I()),g},this.makeAnchors=function(a,b,c){for(var e=[],g=0,h=a.length;h>g;g++)"string"==typeof a[g]?e.push(q.Anchors[a[g]]({elementId:b,jsPlumbInstance:c})):d.isArray(a[g])&&e.push(f.makeAnchor(a[g],b,c));return e},this.makeDynamicAnchor=function(a,b){return new q.DynamicAnchor({anchors:a,selector:b,elementId:null,jsPlumbInstance:f})},this.targetEndpointDefinitions={};var rb=function(a,b,c){a.paintStyle=a.paintStyle||c.Defaults.EndpointStyles[b]||c.Defaults.EndpointStyle,a.hoverPaintStyle=a.hoverPaintStyle||c.Defaults.EndpointHoverStyles[b]||c.Defaults.EndpointHoverStyle,a.anchor=a.anchor||c.Defaults.Anchors[b]||c.Defaults.Anchor,a.endpoint=a.endpoint||c.Defaults.Endpoints[b]||c.Defaults.Endpoint};this.sourceEndpointDefinitions={};var sb=function(a,b,c,d,e){for(var f=a.target||a.srcElement,g=!1,h=d.getSelector(b,c),i=0;i0&&b>=c.maxConnections},element:a.el,elementId:a.id,isSource:e,isTarget:g,addClass:function(b){f.addClass(a.el,b)},removeClass:function(b){f.removeClass(a.el,b)},onDrop:function(a){var b=a.endpoints[0];b.anchor.locked=!1},isDropAllowed:function(){return i.isDropAllowed.apply(i,arguments)},isRedrop:function(b){return null!=b.suspendedElement&&null!=b.suspendedEndpoint&&b.suspendedEndpoint.element===a.el},getEndpoint:function(c){var d=a.el[h],e=d.endpoint;if((null==e||null==e._jsPlumb)&&(e=f.addEndpoint(a.el,b),e._mtNew=!0),b.uniqueEndpoint&&(d.endpoint=e),e._doNotDeleteOnDetach=!1,e._deleteOnDetach=!0,c.isDetachable()&&e.initDraggable(),null!=e.anchor.positionFinder){var g=f.getUIPosition(arguments,f.getZoom()),i=f.getOffset(a.el),j=f.getSize(a.el),k=e.anchor.positionFinder(g,i,j,e.anchor.constructorParams);e.anchor.x=k[0],e.anchor.y=k[1]}return e},maybeCleanup:function(a){a._mtNew&&0===a.connections.length?f.deleteObject({endpoint:a}):delete a._mtNew}}),k=q.dragEvents.drop;return c.scope=c.scope||b.scope||f.Defaults.Scope,c[k]=d.wrap(c[k],j,!0),g&&(c[q.dragEvents.over]=function(){return!0}),b.allowLoopback===!1&&(c.canDrop=function(b){var c=b.getDragElement()._jsPlumbRelatedElement;return c!=a.el}),f.initDroppable(a.el,c,"internal"),j};this.makeTarget=function(a,b,c){var d=q.extend({_jsPlumb:this},c);q.extend(d,b),rb(d,1,this);for(var e=(!(d.deleteEndpointsOnDetach===!1),d.maxConnections||-1),f=function(a){var b=m(a),c=b.id,f=q.extend({},d.dropOptions||{});nb(c);var g={def:d,uniqueEndpoint:d.uniqueEndpoint,maxConnections:e,enabled:!0};b.el._jsPlumbTarget=g,this.targetEndpointDefinitions[c]=g,tb(b,d,f,d.isSource===!0,!0,"_jsPlumbTarget")}.bind(this),g=a.length&&a.constructor!=String?a:[a],h=0,i=g.length;i>h;h++)f(g[h]);return this},this.unmakeTarget=function(a,b){var c=m(a);return q.destroyDroppable(c.el),b||delete this.targetEndpointDefinitions[c.id],this},this.makeSource=function(a,b,c){var e=q.extend({_jsPlumb:this},c);q.extend(e,b),rb(e,0,this);for(var g=e.maxConnections||1,h=e.onMaxConnections,i=function(a){var b=a.id,c=this.getElement(a.el);nb(b);var i={def:e,uniqueEndpoint:e.uniqueEndpoint,maxConnections:g,enabled:!0};this.sourceEndpointDefinitions[b]=i,a.el._jsPlumbSource=i;var j=q.dragEvents.stop,l=q.dragEvents.drag,m=q.extend({},e.dragOptions||{}),n=m.drag,o=m.stop,p=null,r=!1;m.scope=m.scope||e.scope,m[l]=d.wrap(m[l],function(){n&&n.apply(this,arguments),r=!1}),m[j]=d.wrap(m[j],function(){if(o&&o.apply(this,arguments),this.currentlyDragging=!1,null!=p._jsPlumb){var a=e.anchor||this.Defaults.Anchor,c=p.anchor,d=p.connections[0],g=this.makeAnchor(a,b,this),h=p.element;if(null!=g.positionFinder){var i=f.getOffset(h),j=this.getSize(h),k={left:i.left+c.x*j[0],top:i.top+c.y*j[1]},l=g.positionFinder(k,i,j,g.constructorParams);g.x=l[0],g.y=l[1]}p.setAnchor(g,!0),p.repaint(),this.repaint(p.elementId),null!=d&&this.repaint(d.targetId)}}.bind(this));var s=function(d){var i=this.getOriginalEvent(d);if(3!==d.which&&2!==d.button){var j=this.sourceEndpointDefinitions[b];if(j.enabled){if(b=this.getId(this.getElement(a.el)),e.filter){var l=jsPlumbUtil.isString(e.filter)?sb(i,a.el,e.filter,this,e.filterExclude):e.filter(i,a.el);if(l===!1)return}var n=this.select({source:b}).length;if(j.maxConnections>=0&&j.uniqueEndpoint&&n>=j.maxConnections)return h&&h({element:a.el,maxConnections:g},d),!1;var o=q.getPositionOnElement(i,c,k),s={};q.extend(s,e),s.isTemporarySource=!0,s.anchor=[o[0],o[1],0,0],s.dragOptions=m,p=this.addEndpoint(b,s),r=!0,p._doNotDeleteOnDetach=!1,p._deleteOnDetach=!0,j.uniqueEndpoint&&(j.endpoint?p.finalEndpoint=j.endpoint:(j.endpoint=p,p._deleteOnDetach=!1,p._doNotDeleteOnDetach=!0));var t=function(){f.off(p.canvas,"mouseup",t),f.off(a.el,"mouseup",t),r&&(r=!1,f.deleteEndpoint(p))};f.on(p.canvas,"mouseup",t),f.on(a.el,"mouseup",t),f.trigger(p.canvas,"mousedown",d),jsPlumbUtil.consume(d)}}}.bind(this);this.on(a.el,"mousedown",s),i.trigger=s,e.filter&&(jsPlumbUtil.isString(e.filter)||jsPlumbUtil.isFunction(e.filter))&&f.setDragFilter(a.el,e.filter);var t=q.extend({},e.dropOptions||{});tb(a,e,t,!0,e.isTarget===!0,"_jsPlumbSource")}.bind(this),j=a.length&&a.constructor!=String?a:[a],l=0,n=j.length;n>l;l++)i(m(j[l]));return this},this.unmakeSource=function(a,b){var c=m(a),d=this.sourceEndpointDefinitions[c.id].trigger;return d&&f.off(c.el,"mousedown",d),b||delete this.sourceEndpointDefinitions[c.id],this},this.unmakeEverySource=function(){for(var a in this.sourceEndpointDefinitions)f.unmakeSource(a,!0);return this.sourceEndpointDefinitions={},this};var ub=function(a,b){b=jsPlumbUtil.isArray(b)?b:[b];for(var c=Y(a),d=0;dg;g++){var i=m(b[g]);f[i.id]&&(f[i.id].enabled=e?!f[i.id].enabled:c)}else{var j=m(b).id;f[j].enabled=e?!f[j].enabled:c}return this}.bind(this),xb=function(a,b){return d.isString(a)||!a.length?b.apply(this,[a]):a.length?b.apply(this,[a[0]]):void 0}.bind(this);this.toggleSourceEnabled=function(a){return wb("source",a,null,!0),this.isSourceEnabled(a)},this.setSourceEnabled=function(a,b){return wb("source",a,b)},this.isSource=function(a){return xb(a,function(a){return null!=this.sourceEndpointDefinitions[m(a).id]}.bind(this))},this.isSourceEnabled=function(a){return xb(a,function(a){var b=this.sourceEndpointDefinitions[m(a).id];return b&&b.enabled===!0}.bind(this))},this.toggleTargetEnabled=function(a){return wb("target",a,null,!0),this.isTargetEnabled(a)},this.isTarget=function(a){return xb(a,function(a){return null!=this.targetEndpointDefinitions[m(a).id]}.bind(this))},this.isTargetEnabled=function(a){return xb(a,function(a){var b=this.targetEndpointDefinitions[m(a).id];return b&&b.enabled===!0}.bind(this))},this.setTargetEnabled=function(a,b){return wb("target",a,b)},this.ready=function(a){f.bind("ready",a)};var yb=function(a,b){if("object"==typeof a&&a.length)for(var c=0,d=a.length;d>c;c++)b(a[c]);else b(a);return f};this.repaint=function(a,b,c){return yb(a,function(a){K(a,b,c)})},this.revalidate=function(a,b,c){return yb(a,function(a){var d=c?a:f.getId(a);f.updateOffset({elId:d,recalc:!0,timestamp:b}),f.repaint(a)})},this.repaintEverything=function(){var a,b=e();for(a in v)f.updateOffset({elId:a,recalc:!0,timestamp:b});for(a in v)K(a,null,b);return this},this.removeAllEndpoints=function(a,b,c){c=c||[];var d=function(a){var e,g,h=m(a),i=v[h.id];if(i)for(c.push(h),e=0,g=i.length;g>e;e++)f.deleteEndpoint(i[e]);if(delete v[h.id],b&&h.el&&3!=h.el.nodeType&&8!=h.el.nodeType)for(e=0,g=h.el.childNodes.length;g>e;e++)d(h.el.childNodes[e])};return d(a),this};var zb=function(a,b){f.removeAllEndpoints(a.id,!0,b);for(var c=function(a){f.getDragManager().elementRemoved(a.id),f.anchorManager.clearFor(a.id),f.anchorManager.removeFloatingConnection(a.id),delete f.floatingConnections[a.id],delete x[a.id],delete y[a.id],a.el&&(f.removeElement(a.el),a.el._jsPlumb=null)},d=1;d0;)d(e.el.childNodes[0]);b||zb(e,c)}};return f.batch(function(){d(a,!0)},b===!1),f},this.reset=function(){f.silently(function(){f.deleteEveryEndpoint(),f.unbind(),this.targetEndpointDefinitions={},this.sourceEndpointDefinitions={},u.length=0,this.doReset&&this.doReset()}.bind(this))};var Ab=function(a){a.canvas&&a.canvas.parentNode&&a.canvas.parentNode.removeChild(a.canvas),a.cleanup(),a.destroy()};this.clear=function(){f.select().each(Ab),f.selectEndpoints().each(Ab),v={},w={}},this.setDefaultScope=function(a){return F=a,f},this.setDraggable=T,this.setId=function(a,b,c){var d;jsPlumbUtil.isString(a)?d=a:(a=this.getElement(a),d=this.getId(a));var e=this.getConnections({source:d,scope:"*"},!0),f=this.getConnections({target:d,scope:"*"},!0);b=""+b,c?a=this.getElement(b):(a=this.getElement(d),this.setAttribute(a,"id",b)),v[b]=v[d]||[];for(var g=0,h=v[b].length;h>g;g++)v[b][g].setElementId(b),v[b][g].setReferenceElement(a);delete v[d],this.anchorManager.changeId(d,b),this.getDragManager().changeId(d,b),x[b]=x[d],delete x[d];var i=function(c,d,e){for(var f=0,g=c.length;g>f;f++)c[f].endpoints[d].setElementId(b),c[f].endpoints[d].setReferenceElement(a),c[f][e+"Id"]=b,c[f][e]=a};i(e,0,"source"),i(f,1,"target"),this.repaint(b)},this.setDebugLog=function(a){s=a},this.setSuspendDrawing=function(a,b){var c=D;return D=a,E=a?(new Date).getTime():null,b&&this.repaintEverything(),c},this.isSuspendDrawing=function(){return D},this.getSuspendedAt=function(){return E},this.batch=function(a,b){var c=this.isSuspendDrawing();c||this.setSuspendDrawing(!0);try{a()}catch(e){d.log("Function run while suspended failed",e)}c||this.setSuspendDrawing(!1,!b)},this.doWhileSuspended=this.batch,this.getCachedData=X,this.timestamp=e,this.setRenderMode=function(a){if(a!==q.SVG&&a!==q.VML)throw new TypeError("Render mode ["+a+"] not supported");return G=this.trySetRenderMode(a)},this.getRenderMode=function(){return G},this.show=function(a,b){return U(a,"block",b),f},this.toggleVisible=W,this.toggleDraggable=V,this.addListener=this.bind};jsPlumbUtil.extend(p,jsPlumbUtil.EventGenerator,{setAttribute:function(a,b,c){this.setAttribute(a,b,c)},getAttribute:function(a,b){return this.getAttribute(q.getElement(a),b)},convertToFullOverlaySpec:function(a){return jsPlumbUtil.isString(a)&&(a=[a,{}]),a[1].id=a[1].id||jsPlumbUtil.uuid(),a},registerConnectionType:function(a,b){if(this._connectionTypes[a]=q.extend({},b),b.overlays){for(var c={},d=0;d';var b=a.firstChild;null!=b&&null!=b.style?(b.style.behavior="url(#default#VML)",c.vml=b?"object"==typeof b.adj:!0):c.vml=!1,a.parentNode.removeChild(a)}return c.vml},d=function(){var a=-1;if("Microsoft Internet Explorer"==navigator.appName){var b=navigator.userAgent,c=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");null!=c.exec(b)&&(a=parseFloat(RegExp.$1))}return a}(),e=d>-1&&9>d,f=function(a,b){if(null==a)return[0,0];var c=k(a),d=j(c,0);return[d[b+"X"],d[b+"Y"]]},g=function(a){return null==a?[0,0]:e?[a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop]:f(a,"page")},h=function(a){return f(a,"screen")},i=function(a){return f(a,"client")},j=function(a,b){return a.item?a.item(b):a[b]},k=function(a){return a.touches&&a.touches.length>0?a.touches:a.changedTouches&&a.changedTouches.length>0?a.changedTouches:a.targetTouches&&a.targetTouches.length>0?a.targetTouches:[a]},l=function(a){var b={},c=[],d={},e={},f={};this.register=function(g){var h=a.getId(g),i=a.getOffset(g);b[h]||(b[h]=g,c.push(g),d[h]={});var j=function(b){if(b)for(var c=0;c0){var l=a.getOffset(g);d[h][k]={id:k,offset:{left:l.left-i.left,top:l.top-i.top}},f[k]=h}j(b.childNodes[c])}};j(g)},this.updateOffsets=function(b){if(null!=b){var c=jsPlumb.getElement(b),e=a.getId(c),g=d[e],h=a.getOffset(c);if(g)for(var i in g)if(g.hasOwnProperty(i)){var j=jsPlumb.getElement(i),k=a.getOffset(j);d[e][i]={id:i,offset:{left:k.left-h.left,top:k.top-h.top}},f[i]=e}}},this.endpointAdded=function(c,g){g=g||a.getId(c);var h=document.body,i=c.parentNode;for(e[g]=e[g]?e[g]+1:1;null!=i&&i!=h;){var j=a.getId(i,null,!0);if(j&&b[j]){var k=a.getOffset(i);if(null==d[j][g]){var l=a.getOffset(c);d[j][g]={id:g,offset:{left:l.left-k.left,top:l.top-k.top}},f[g]=j}break}i=i.parentNode}},this.endpointDeleted=function(a){if(e[a.elementId]&&(e[a.elementId]--,e[a.elementId]<=0))for(var b in d)d.hasOwnProperty(b)&&d[b]&&(delete d[b][a.elementId],delete f[a.elementId])},this.changeId=function(a,b){d[b]=d[a],d[a]={},f[b]=f[a],f[a]=null},this.getElementsForDraggable=function(a){return d[a]},this.elementRemoved=function(a){var b=f[a];b&&(delete d[b][a],delete f[a])},this.reset=function(){b={},c=[],d={},e={}},this.dragEnded=function(b){var c=a.getId(b),d=f[c];d&&this.updateOffsets(d)},this.setParent=function(b,c,e,g){var h=f[c];if(h){d[g]||(d[g]={}),d[g][c]=d[h][c],delete d[h][c];var i=a.getOffset(e),j=a.getOffset(b);d[g][c].offset={left:j.left-i.left,top:j.top-i.top},f[c]=g}},this.getDragAncestor=function(b){var c=jsPlumb.getElement(b),d=a.getId(c),e=f[d];return e?jsPlumb.getElement(e):null}},m=function(a){return null==a?null:a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},n=function(a,b){b=m(b),"undefined"!=typeof a.className.baseVal?a.className.baseVal=b:a.className=b},o=function(a){return"undefined"==typeof a.className.baseVal?a.className:a.className.baseVal +},p=function(a,b,c){b=null==b?[]:jsPlumbUtil.isArray(b)?b:b.split(/\s+/),c=null==c?[]:jsPlumbUtil.isArray(c)?c:c.split(/\s+/);var d=o(a),e=d.split(/\s+/),f=function(a,b){for(var c=0;c0||b.scrollLeft>0)&&(this.getStyle(a,"position"),d.left-=b.scrollLeft,d.top-=b.scrollTop)}.bind(this);null!=e;)d.left+=e.offsetLeft,d.top+=e.offsetTop,f(e),e=b?e.offsetParent:e.offsetParent==c?null:e.offsetParent;if(null!=c&&!b&&(c.scrollTop>0||c.scrollLeft>0)){var g=null!=a.offsetParent?this.getStyle(a.offsetParent,"position"):"static",h=this.getStyle(a,"position");"absolute"!==h&&"fixed"!==h&&"absolute"!==g&&"fixed"!=g&&(d.left-=c.scrollLeft,d.top-=c.scrollTop)}return d},getPositionOnElement:function(a,b,c){var d="undefined"!=typeof b.getBoundingClientRect?b.getBoundingClientRect():{left:0,top:0,width:0,height:0},e=document.body,f=document.documentElement,g=window.pageYOffset||f.scrollTop||e.scrollTop,h=window.pageXOffset||f.scrollLeft||e.scrollLeft,i=f.clientTop||e.clientTop||0,j=f.clientLeft||e.clientLeft||0,k=0,l=0,m=d.top+g-i+k*c,n=d.left+h-j+l*c,o=jsPlumb.pageLocation(a),p=d.width||b.offsetWidth*c,q=d.height||b.offsetHeight*c,r=(o[0]-n)/p,s=(o[1]-m)/q;return[r,s]},getAbsolutePosition:function(a){var b=function(b){var c=a.style[b];return c?parseFloat(c.substring(0,c.length-2)):void 0};return[b("left"),b("top")]},setAbsolutePosition:function(a,b,c,d){c?this.animate(a,{left:"+="+(b[0]-c[0]),top:"+="+(b[1]-c[1])},d):(a.style.left=b[0]+"px",a.style.top=b[1]+"px")},getSize:function(a){return[a.offsetWidth,a.offsetHeight]},getWidth:function(a){return a.offsetWidth},getHeight:function(a){return a.offsetHeight}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d="__label",e=function(a,c){var e={cssClass:c.cssClass,labelStyle:a.labelStyle,id:d,component:a,_jsPlumb:a._jsPlumb.instance},f=jsPlumb.extend(e,c);return new(b.Overlays[a._jsPlumb.instance.getRenderMode()].Label)(f)},f=function(a,d){var e=null;if(c.isArray(d)){var f=d[0],g=b.extend({component:a,_jsPlumb:a._jsPlumb.instance},d[1]);3==d.length&&b.extend(g,d[2]),e=new(b.Overlays[a._jsPlumb.instance.getRenderMode()][f])(g)}else e=d.constructor==String?new(b.Overlays[a._jsPlumb.instance.getRenderMode()][d])({component:a,_jsPlumb:a._jsPlumb.instance}):d;return e.id=e.id||c.uuid(),a.cacheTypeItem("overlay",e,e.id),a._jsPlumb.overlays[e.id]=e,e};b.OverlayCapableJsPlumbUIComponent=function(a){jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.overlays={},this._jsPlumb.overlayPositions={},a.label&&(this.getDefaultType().overlays[d]=["Label",{label:a.label,location:a.labelLocation||this.defaultLabelLocation||.5,labelStyle:a.labelStyle||this._jsPlumb.instance.Defaults.LabelStyle,id:d}]),this.setListenerComponent=function(a){if(this._jsPlumb)for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].setListenerComponent(a)}},b.OverlayCapableJsPlumbUIComponent.applyType=function(a,b){if(b.overlays){var c,d={};for(c in b.overlays){var e=a._jsPlumb.overlays[b.overlays[c][1].id];if(e)e.updateFrom(b.overlays[c][1]),d[b.overlays[c][1].id]=!0;else{var f=a.getCachedTypeItem("overlay",b.overlays[c][1].id);null!=f?(f.reattach(a._jsPlumb.instance),f.updateFrom(b.overlays[c][1]),a._jsPlumb.overlays[f.id]=f):f=a.addOverlay(b.overlays[c],!0),d[f.id]=!0}}for(c in a._jsPlumb.overlays)null==d[a._jsPlumb.overlays[c].id]&&a.removeOverlay(a._jsPlumb.overlays[c].id)}},c.extend(b.OverlayCapableJsPlumbUIComponent,jsPlumbUIComponent,{setHover:function(a){if(this._jsPlumb&&!this._jsPlumb.instance.isConnectionBeingDragged())for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b][a?"addClass":"removeClass"](this._jsPlumb.instance.hoverClass)},addOverlay:function(a,b){var c=f(this,a);return b||this.repaint(),c},getOverlay:function(a){return this._jsPlumb.overlays[a]},getOverlays:function(){return this._jsPlumb.overlays},hideOverlay:function(a){var b=this.getOverlay(a);b&&b.hide()},hideOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].hide()},showOverlay:function(a){var b=this.getOverlay(a);b&&b.show()},showOverlays:function(){for(var a in this._jsPlumb.overlays)this._jsPlumb.overlays[a].show()},removeAllOverlays:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup&&this._jsPlumb.overlays[b].cleanup();this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null,a||this.repaint()},removeOverlay:function(a){var b=this._jsPlumb.overlays[a];b&&(b.cleanup&&b.cleanup(),delete this._jsPlumb.overlays[a],this._jsPlumb.overlayPositions&&delete this._jsPlumb.overlayPositions[a])},removeOverlays:function(){for(var a=0,b=arguments.length;b>a;a++)this.removeOverlay(arguments[a])},moveParent:function(a){this.bgCanvas&&(this.bgCanvas.parentNode.removeChild(this.bgCanvas),a.appendChild(this.bgCanvas)),this.canvas.parentNode.removeChild(this.canvas),a.appendChild(this.canvas);for(var b in this._jsPlumb.overlays)if(this._jsPlumb.overlays[b].isAppendedAtTopLevel){var c=this._jsPlumb.overlays[b].getElement();c.parentNode.removeChild(c),a.appendChild(c)}},getLabel:function(){var a=this.getOverlay(d);return null!=a?a.getLabel():null},getLabelOverlay:function(){return this.getOverlay(d)},setLabel:function(a){var b=this.getOverlay(d);if(b)a.constructor==String||a.constructor==Function?b.setLabel(a):(a.label&&b.setLabel(a.label),a.location&&b.setLocation(a.location));else{var c=a.constructor==String||a.constructor==Function?{label:a}:a;b=e(this,c),this._jsPlumb.overlays[d]=b}this._jsPlumb.instance.isSuspendDrawing()||this.repaint()},cleanup:function(a){for(var b in this._jsPlumb.overlays)this._jsPlumb.overlays[b].cleanup(a),this._jsPlumb.overlays[b].destroy(a);a&&(this._jsPlumb.overlays={},this._jsPlumb.overlayPositions=null)},setVisible:function(a){this[a?"showOverlays":"hideOverlays"]()},setAbsoluteOverlayPosition:function(a,b){this._jsPlumb.overlayPositions[a.id]=b},getAbsoluteOverlayPosition:function(a){return this._jsPlumb.overlayPositions?this._jsPlumb.overlayPositions[a.id]:null}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a,c){var d=!1;return{drag:function(){if(d)return d=!1,!0;var e=b.getUIPosition(arguments,c.getZoom());a.element&&(jsPlumb.setPosition(a.element,e),c.repaint(a.element,e))},stopDrag:function(){d=!0}}},e=function(a,b){var c=jsPlumb.createElement("div",{position:"absolute"});b.appendElement(c);var d=b.getId(c);b.manage(d,c),a.id=d,a.element=c},f=function(a,c,d,e,f,g,h,i){var j=new b.FloatingAnchor({reference:c,referenceCanvas:e,jsPlumbInstance:g});return h({paintStyle:a,endpoint:d,anchor:j,source:f,scope:i})},g=["connectorStyle","connectorHoverStyle","connectorOverlays","connector","connectionType","connectorClass","connectorHoverClass"],h=function(a,b){var c=0;if(null!=b)for(var d=0;d0)for(var b=0;b0?"add":"remove")+"Class"](j.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](j.endpointFullClass)},this.detachFromConnection=function(a,b,c){b=null==b?i(a,this):b,b>=0&&(this.connections.splice(b,1),this[(this.connections.length>0?"add":"remove")+"Class"](j.endpointConnectedClass),this[(this.isFull()?"add":"remove")+"Class"](j.endpointFullClass)),!c&&this._deleteOnDetach&&0===this.connections.length&&j.deleteObject({endpoint:this,fireEvent:!1,deleteAttachedObjects:!1})},this.detach=function(a,b,c,d,e,f,g){var h=null==g?i(a,this):g,k=!1;return d=d!==!1,h>=0&&(c||a._forceDetach||a.isDetachable()&&a.isDetachAllowed(a)&&this.isDetachAllowed(a)&&j.checkCondition("beforeDetach",a,f))&&(j.deleteObject({connection:a,fireEvent:!b&&d,originalEvent:e,deleteAttachedObjects:!1}),k=!0),k},this.detachAll=function(a,b){for(var c=[];this.connections.length>0;){var d=this.detach(this.connections[0],!1,b===!0,a!==!1,null,this,0);d||(c.push(this.connections[0]),this.connections.splice(0,1))}return this.connections=c,this},this.detachFrom=function(a,b,c){for(var d=[],e=0;e0){var l=h(this,a.elementWithPrecedence),m=l.endpoints[0]==this?1:0,n=0===m?l.sourceId:l.targetId,o=j.getCachedData(n),p=o.o,q=o.s;k.txy=[p.left,p.top],k.twh=q,k.tElement=l.endpoints[m]}f=this.anchor.compute(k)}this.endpoint.compute(f,this.anchor.getOrientation(this),this._jsPlumb.paintStyleInUse,g||this.paintStyleInUse),this.endpoint.paint(this._jsPlumb.paintStyleInUse,this.anchor),this.timestamp=b;for(var r in this._jsPlumb.overlays)if(this._jsPlumb.overlays.hasOwnProperty(r)){var s=this._jsPlumb.overlays[r];s.isVisible()&&(this._jsPlumb.overlayPlacements[r]=s.draw(this.endpoint,this._jsPlumb.paintStyleInUse),s.paint(this._jsPlumb.overlayPlacements[r]))}}}},this.getTypeDescriptor=function(){return"endpoint"},this.isVisible=function(){return this._jsPlumb.visible},this.repaint=this.paint;var p=!1;this.initDraggable=function(){if(!p&&b.isDragSupported(this.element)){var g={id:null,element:null},h=null,i=!1,n=null,o=d(g,j),q=a.dragOptions||{},r={},s=b.dragEvents.start,t=b.dragEvents.stop,u=b.dragEvents.drag,v=function(){h=this.connectorSelector();var b=!0;this.isEnabled()||(b=!1),null!=h||this.isSource||this.isTemporarySource||(b=!1),!this.isSource||!this.isFull()||null!=h&&this.dragAllowedWhenFull||(b=!1),null==h||h.isDetachable(this)||(b=!1);var d=j.checkCondition(null==h?"beforeDrag":"beforeStartDetach",{endpoint:this,source:this.element,sourceId:this.elementId,connection:h});if(d===!1&&(b=!1),b===!1)return j.stopDrag&&j.stopDrag(this.canvas),o.stopDrag(),!1;for(var p=0;p0}.bind(this),j.initDraggable(this.canvas,q,"internal"),this.canvas._jsPlumbRelatedElement=this.element,p=!0}};var q=a.endpoint||this._jsPlumb.instance.Defaults.Endpoint||b.Defaults.Endpoint;this.setEndpoint(q,!0);var r=a.anchor?a.anchor:a.anchors?a.anchors:j.Defaults.Anchor||"Top";this.setAnchor(r,!0);var s=["default",a.type||""].join(" ");this.addType(s,a.data,!0),this.canvas=this.endpoint.canvas,this.canvas._jsPlumb=this,(this.isSource||this.isTarget||this.isTemporarySource)&&this.initDraggable();var t=function(d,e,f,g,h){if((this.isTarget||e)&&b.isDropSupported(this.element)){var i=a.dropOptions||j.Defaults.DropOptions||b.Defaults.DropOptions;i=b.extend({},i),i.scope=i.scope||this.scope;var k=b.dragEvents.drop,l=b.dragEvents.over,m=b.dragEvents.out,n=this,o=j.EndpointDropHandler({getEndpoint:function(){return n},jsPlumb:j,enabled:function(){return null!=g?g.isEnabled():!0},isFull:function(){return g.isFull()},element:this.element,elementId:this.elementId,isSource:this.isSource,isTarget:this.isTarget,addClass:function(a){n.addClass(a)},removeClass:function(a){n.removeClass(a)},isDropAllowed:function(){return n.isDropAllowed.apply(n,arguments)},reference:h,isRedrop:function(a,b){return a.suspendedEndpoint&&b.reference&&a.suspendedEndpoint.id===b.reference.id}});i[k]=c.wrap(i[k],o,!0),i[l]=c.wrap(i[l],function(){var a=b.getDragObject(arguments),c=j.getAttribute(b.getElement(a),"dragId"),d=j.floatingConnections[c];if(null!=d){var e=j.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id==d.suspendedEndpoint.id;if(f){var g=j.checkCondition("checkDropAllowed",{sourceEndpoint:d.endpoints[e],targetEndpoint:this,connection:d});this[(g?"add":"remove")+"Class"](j.endpointDropAllowedClass),this[(g?"remove":"add")+"Class"](j.endpointDropForbiddenClass),d.endpoints[e].anchor.over(this.anchor,this)}}}.bind(this)),i[m]=c.wrap(i[m],function(){var a=b.getDragObject(arguments),c=null==a?null:j.getAttribute(b.getElement(a),"dragId"),d=c?j.floatingConnections[c]:null;if(null!=d){var e=j.getFloatingAnchorIndex(d),f=this.isTarget&&0!==e||d.suspendedEndpoint&&this.referenceEndpoint&&this.referenceEndpoint.id==d.suspendedEndpoint.id;f&&(this.removeClass(j.endpointDropAllowedClass),this.removeClass(j.endpointDropForbiddenClass),d.endpoints[e].anchor.out())}}.bind(this)),j.initDroppable(d,i,"internal",f)}}.bind(this);return this.anchor.isFloating||t(this.canvas,!0,!(a._transient||this.anchor.isFloating),this,a.reference),this},c.extend(b.Endpoint,b.OverlayCapableJsPlumbUIComponent,{setVisible:function(a,b,c){if(this._jsPlumb.visible=a,this.canvas&&(this.canvas.style.display=a?"block":"none"),this[a?"showOverlays":"hideOverlays"](),!b)for(var d=0;db.dist?1:0});for(var o=k[0].source,p=k[0].target,q=0;qc[0][0],d===!1?-1:1}},r=function(a,b){var c=a[0][0]<0?-Math.PI-a[0][0]:Math.PI-a[0][0],d=b[0][0]<0?-Math.PI-b[0][0]:Math.PI-b[0][0];return c>d?1:a[0][1]>b[0][1]?1:-1},s={top:function(a,b){return a[0]>b[0]?1:-1},right:q(!0),bottom:q(!0),left:r},t=function(a,b){return a.sort(b)},u=function(a,b){var c=m.getCachedData(a),d=c.s,f=c.o,h=function(b,c,d,f,h,i,j){if(f.length>0)for(var k=t(f,s[b]),l="right"===b||"top"===b,m=p(b,c,d,k,h,i,l),n=function(a,b){e[a.id]=[b[0],b[1],b[2],b[3]],g[a.id]=j},o=0;o-1&&(j[d].splice(h,1),b.addToList(j,e,[f,f.endpoints[0],f.endpoints[0].anchor.constructor==c.DynamicAnchor])),f.updateConnectedClass()},this.sourceChanged=function(a,d,e){if(a!==d){b.removeWithFunction(j[a],function(a){return a[0].id===e.id});var f=b.findWithFunction(j[e.targetId],function(a){return a[0].id===e.id});f>-1&&(j[e.targetId][f][0]=e,j[e.targetId][f][1]=e.endpoints[0],j[e.targetId][f][2]=e.endpoints[0].anchor.constructor==c.DynamicAnchor),b.addToList(j,d,[e,e.endpoints[1],e.endpoints[1].anchor.constructor==c.DynamicAnchor]),e.updateConnectedClass()}},this.rehomeEndpoint=function(a,c,e){var f=d[c]||[],g=m.getId(e);if(g!==c){var h=b.indexOf(f,a);if(h>-1){var i=f.splice(h,1)[0];k.add(i,g)}}for(var j=0;j0?this.anchors[0]:null,f=e,g=this,h=function(a,b,c,d,e){var f=d[0]+a.x*e[0],g=d[1]+a.y*e[1],h=d[0]+e[0]/2,i=d[1]+e[1]/2;return Math.sqrt(Math.pow(b-f,2)+Math.pow(c-g,2))+Math.sqrt(Math.pow(h-f,2)+Math.pow(i-g,2))},i=a.selector||function(a,b,c,d,e){for(var f=c[0]+d[0]/2,g=c[1]+d[1]/2,i=-1,j=1/0,k=0;kl&&(i=k+0,j=l)}return e[i]};this.compute=function(a){var b=a.xy,c=a.wh,d=a.txy,h=a.twh;this.timestamp=a.timestamp;var j=g.getUserDefinedLocation();return null!=j?j:this.locked||null==d||null==h?e.compute(a):(a.timestamp=null,e=i(b,c,d,h,this.anchors),this.x=e.x,this.y=e.y,e!=f&&this.fire("anchorChanged",e),f=e,e.compute(a))},this.getCurrentLocation=function(a){return this.getUserDefinedLocation()||(null!=e?e.getCurrentLocation(a):null)},this.getOrientation=function(a){return null!=e?e.getOrientation(a):[0,0]},this.over=function(a,b){null!=e&&e.over(a,b)},this.out=function(){null!=e&&e.out()},this.getCssClass=function(){return e&&e.getCssClass()||""}},b.extend(c.DynamicAnchor,c.Anchor);var e=function(a,b,d,e,f,g){c.Anchors[f]=function(c){var h=c.jsPlumbInstance.makeAnchor([a,b,d,e,0,0],c.elementId,c.jsPlumbInstance);return h.type=f,g&&g(h,c),h}};e(.5,0,0,-1,"TopCenter"),e(.5,1,0,1,"BottomCenter"),e(0,.5,-1,0,"LeftMiddle"),e(1,.5,1,0,"RightMiddle"),e(.5,0,0,-1,"Top"),e(.5,1,0,1,"Bottom"),e(0,.5,-1,0,"Left"),e(1,.5,1,0,"Right"),e(.5,.5,0,0,"Center"),e(1,0,0,-1,"TopRight"),e(1,1,0,1,"BottomRight"),e(0,0,0,-1,"TopLeft"),e(0,1,0,1,"BottomLeft"),c.Defaults.DynamicAnchors=function(a){return a.jsPlumbInstance.makeAnchors(["TopCenter","RightMiddle","BottomCenter","LeftMiddle"],a.elementId,a.jsPlumbInstance)},c.Anchors.AutoDefault=function(a){var b=a.jsPlumbInstance.makeDynamicAnchor(c.Defaults.DynamicAnchors(a));return b.type="AutoDefault",b};var f=function(a,b){c.Anchors[a]=function(c){var d=c.jsPlumbInstance.makeAnchor(["Continuous",{faces:b}],c.elementId,c.jsPlumbInstance);return d.type=a,d}};c.Anchors.Continuous=function(a){return a.jsPlumbInstance.continuousAnchorFactory.get(a)},f("ContinuousLeft",["left"]),f("ContinuousTop",["top"]),f("ContinuousBottom",["bottom"]),f("ContinuousRight",["right"]),e(0,0,0,0,"Assign",function(a,b){var c=b.position||"Fixed";a.positionFinder=c.constructor==String?b.jsPlumbInstance.AnchorPositionFinders[c]:c,a.constructorParams=b}),jsPlumbInstance.prototype.AnchorPositionFinders={Fixed:function(a,b,c){return[(a.left-b.left)/c[0],(a.top-b.top)/c[1]]},Grid:function(a,b,c,d){var e=a.left-b.left,f=a.top-b.top,g=c[0]/d.grid[0],h=c[1]/d.grid[1],i=Math.floor(e/g),j=Math.floor(f/h);return[(i*g+g/2)/c[0],(j*h+h/2)/c[1]]}},c.Anchors.Perimeter=function(a){a=a||{};var b=a.anchorCount||60,c=a.shape;if(!c)throw new Error("no shape supplied to Perimeter Anchor type");var d=function(){for(var a=.5,c=2*Math.PI/b,d=0,e=[],f=0;b>f;f++){var g=a+a*Math.sin(d),h=a+a*Math.cos(d);e.push([g,h,0,0]),d+=c}return e},e=function(a){for(var c=b/a.length,d=[],e=function(a,e,f,g,h){c=b*h;for(var i=(f-a)/c,j=(g-e)/c,k=0;c>k;k++)d.push([a+i*k,e+j*k,0,0])},f=0;f0?a:c+a:a*c;return d.pointOnLine({x:g,y:i},{x:h,y:j},e)}return{x:h,y:j}}return{x:g,y:i}},this.gradientAtPoint=function(){return e},this.pointAlongPathFrom=function(a,b,c){var e=this.pointOnPath(a,c),f=0>=b?{x:g,y:i}:{x:h,y:j};return 0>=b&&Math.abs(b)>1&&(b*=-1),d.pointOnLine(e,f,b)};var l=function(a,b,c){return c>=Math.min(a,b)&&c<=Math.max(a,b)},m=function(a,b,c){return Math.abs(c-a)a-b?b:k>c-a?c:a};this.pointOnPath=function(b,c){if(0===b)return{x:this.x1,y:this.y1,theta:this.startAngle};if(1==b)return{x:this.x2,y:this.y2,theta:this.endAngle};c&&(b/=j);var d=e(this,b),f=a.cx+a.r*Math.cos(d),g=a.cy+a.r*Math.sin(d);return{x:l(f),y:l(g),theta:d}},this.gradientAtPoint=function(b,c){var e=this.pointOnPath(b,c),f=d.normal([a.cx,a.cy],[e.x,e.y]);return this.anticlockwise||1/0!=f&&f!=-1/0||(f*=-1),f},this.pointAlongPathFrom=function(b,c,d){var e=this.pointOnPath(b,d),f=2*(c/h)*Math.PI,g=this.anticlockwise?-1:1,i=e.theta+g*f,j=a.cx+this.radius*Math.cos(i),k=a.cy+this.radius*Math.sin(i);return{x:j,y:k}}},Bezier:function(c){this.curve=[{x:c.x1,y:c.y1},{x:c.cp1x,y:c.cp1y},{x:c.cp2x,y:c.cp2y},{x:c.x2,y:c.y2}],b.Segments.AbstractSegment.apply(this,arguments),this.bounds={minX:Math.min(c.x1,c.x2,c.cp1x,c.cp2x),minY:Math.min(c.y1,c.y2,c.cp1y,c.cp2y),maxX:Math.max(c.x1,c.x2,c.cp1x,c.cp2x),maxY:Math.max(c.y1,c.y2,c.cp1y,c.cp2y)},this.type="Bezier";var d=function(b,c,d){return d&&(c=a.jsBezier.locationAlongCurveFrom(b,c>0?0:1,c)),c};this.pointOnPath=function(b,c){return b=d(this.curve,b,c),a.jsBezier.pointOnCurve(this.curve,b)},this.gradientAtPoint=function(b,c){return b=d(this.curve,b,c),a.jsBezier.gradientAtPoint(this.curve,b)},this.pointAlongPathFrom=function(b,c,e){return b=d(this.curve,b,e),a.jsBezier.pointAlongCurveFrom(this.curve,b,c)},this.getLength=function(){return a.jsBezier.getLength(this.curve)},this.getBounds=function(){return this.bounds}}};var e=function(){this.resetBounds=function(){this.bounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}},this.resetBounds()};b.Connectors.AbstractConnector=function(a){e.apply(this,arguments);var f=[],g=0,h=[],i=[],j=a.stub||0,k=c.isArray(j)?j[0]:j,l=c.isArray(j)?j[1]:j,m=a.gap||0,n=c.isArray(m)?m[0]:m,o=c.isArray(m)?m[1]:m,p=null,q=!1,r=null;this.getPath=function(){},this.setPath=function(){},this.findSegmentForPoint=function(a,b){for(var c={d:1/0,s:null,x:null,y:null,l:null},d=0;d0?a/g:(g+a)/g);for(var c=h.length-1,d=1,e=0;e=a){c=e,d=1==a?1:0===a?0:(a-h[e][0])/i[e];break}return{segment:f[c],proportion:d,index:c}},u=function(a,c,d){if(d.x1!=d.x2||d.y1!=d.y2){var e=new b.Segments[c](d);f.push(e),g+=e.getLength(),a.updateBounds(e)}},v=function(){g=f.length=h.length=i.length=0};this.setSegments=function(a){p=[],g=0;for(var b=0;bp?0:1,r=[1,0][q];g=[],h=[],g[q]=a.sourcePos[q]>a.targetPos[q]?-1:1,h[q]=a.sourcePos[q]>a.targetPos[q]?1:-1,g[r]=0,h[r]=0}var s=c?m+n*g[0]:n*g[0],t=e?p+n*g[1]:n*g[1],u=c?o*h[0]:m+o*h[0],v=e?o*h[1]:p+o*h[1],w=g[0]*h[0]+g[1]*h[1],x={sx:s,sy:t,tx:u,ty:v,lw:f,xSpan:Math.abs(u-s),ySpan:Math.abs(v-t),mx:(s+u)/2,my:(t+v)/2,so:g,to:h,x:i,y:j,w:m,h:p,segment:b,startStubX:s+g[0]*k,startStubY:t+g[1]*k,endStubX:u+h[0]*l,endStubY:v+h[1]*l,isXGreaterThanStubTimes2:Math.abs(s-u)>k+l,isYGreaterThanStubTimes2:Math.abs(t-v)>k+l,opposite:-1==w,perpendicular:0===w,orthogonal:1==w,sourceAxis:0===g[0]?"y":"x",points:[i,j,m,p,s,t,u,v]};return x.anchorOrientation=x.opposite?"opposite":x.orthogonal?"orthogonal":"perpendicular",x +};return this.getSegments=function(){return f},this.updateBounds=function(a){var b=a.getBounds();this.bounds.minX=Math.min(this.bounds.minX,b.minX),this.bounds.maxX=Math.max(this.bounds.maxX,b.maxX),this.bounds.minY=Math.min(this.bounds.minY,b.minY),this.bounds.maxY=Math.max(this.bounds.maxY,b.maxY)},this.pointOnPath=function(a,b){var c=t(a,b);return c.segment&&c.segment.pointOnPath(c.proportion,!1)||[0,0]},this.gradientAtPoint=function(a,b){var c=t(a,b);return c.segment&&c.segment.gradientAtPoint(c.proportion,!1)||0},this.pointAlongPathFrom=function(a,b,c){var d=t(a,c);return d.segment&&d.segment.pointAlongPathFrom(d.proportion,b,!1)||[0,0]},this.compute=function(a){q||(r=w.call(this,a)),v(),this._compute(r,a),this.x=r.points[0],this.y=r.points[1],this.w=r.points[2],this.h=r.points[3],this.segment=r.segment,s()},{addSegment:u,prepareCompute:w,sourceStub:k,targetStub:l,maxStub:Math.max(k,l),sourceGap:n,targetGap:o,maxGap:Math.max(n,o)}},c.extend(b.Connectors.AbstractConnector,e);var f=b.Connectors.Straight=function(){this.type="Straight";var a=b.Connectors.AbstractConnector.apply(this,arguments);this._compute=function(b){a.addSegment(this,"Straight",{x1:b.sx,y1:b.sy,x2:b.startStubX,y2:b.startStubY}),a.addSegment(this,"Straight",{x1:b.startStubX,y1:b.startStubY,x2:b.endStubX,y2:b.endStubY}),a.addSegment(this,"Straight",{x1:b.endStubX,y1:b.endStubY,x2:b.tx,y2:b.ty})}};c.extend(b.Connectors.Straight,b.Connectors.AbstractConnector),b.registerConnectorType(f,"Straight"),b.Endpoints.AbstractEndpoint=function(a){e.apply(this,arguments);var b=this.compute=function(){var a=this._compute.apply(this,arguments);return this.x=a[0],this.y=a[1],this.w=a[2],this.h=a[3],this.bounds.minX=this.x,this.bounds.minY=this.y,this.bounds.maxX=this.x+this.w,this.bounds.maxY=this.y+this.h,a};return{compute:b,cssClass:a.cssClass}},c.extend(b.Endpoints.AbstractEndpoint,e),b.Endpoints.Dot=function(a){this.type="Dot",b.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},this.radius=a.radius||10,this.defaultOffset=.5*this.radius,this.defaultInnerRadius=this.radius/3,this._compute=function(a,b,c){this.radius=c.radius||this.radius;var d=a[0]-this.radius,e=a[1]-this.radius,f=2*this.radius,g=2*this.radius;if(c.strokeStyle){var h=c.lineWidth||1;d-=h,e-=h,f+=2*h,g+=2*h}return[d,e,f,g,this.radius]}},c.extend(b.Endpoints.Dot,b.Endpoints.AbstractEndpoint),b.Endpoints.Rectangle=function(a){this.type="Rectangle",b.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},this.width=a.width||20,this.height=a.height||20,this._compute=function(a,b,c){var d=c.width||this.width,e=c.height||this.height,f=a[0]-d/2,g=a[1]-e/2;return[f,g,d,e]}},c.extend(b.Endpoints.Rectangle,b.Endpoints.AbstractEndpoint);var g=function(){b.jsPlumbUIComponent.apply(this,arguments),this._jsPlumb.displayElements=[]};c.extend(g,b.jsPlumbUIComponent,{getDisplayElements:function(){return this._jsPlumb.displayElements},appendDisplayElement:function(a){this._jsPlumb.displayElements.push(a)}}),b.Endpoints.Image=function(d){this.type="Image",g.apply(this,arguments),b.Endpoints.AbstractEndpoint.apply(this,arguments);var e=d.onload,f=d.src||d.url,h=d.cssClass?" "+d.cssClass:"";this._jsPlumb.img=new Image,this._jsPlumb.ready=!1,this._jsPlumb.initialized=!1,this._jsPlumb.deleted=!1,this._jsPlumb.widthToUse=d.width,this._jsPlumb.heightToUse=d.height,this._jsPlumb.endpoint=d.endpoint,this._jsPlumb.img.onload=function(){null!=this._jsPlumb&&(this._jsPlumb.ready=!0,this._jsPlumb.widthToUse=this._jsPlumb.widthToUse||this._jsPlumb.img.width,this._jsPlumb.heightToUse=this._jsPlumb.heightToUse||this._jsPlumb.img.height,e&&e(this))}.bind(this),this._jsPlumb.endpoint.setImage=function(a,b){var c=a.constructor==String?a:a.src;e=b,this._jsPlumb.img.src=c,null!=this.canvas&&this.canvas.setAttribute("src",this._jsPlumb.img.src)}.bind(this),this._jsPlumb.endpoint.setImage(f,e),this._compute=function(a){return this.anchorPoint=a,this._jsPlumb.ready?[a[0]-this._jsPlumb.widthToUse/2,a[1]-this._jsPlumb.heightToUse/2,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse]:[0,0,0,0]},this.canvas=jsPlumb.createElement("img",{position:"absolute",margin:0,padding:0,outline:0},this._jsPlumb.instance.endpointClass+h),this._jsPlumb.widthToUse&&this.canvas.setAttribute("width",this._jsPlumb.widthToUse),this._jsPlumb.heightToUse&&this.canvas.setAttribute("height",this._jsPlumb.heightToUse),this._jsPlumb.instance.appendElement(this.canvas),this.actuallyPaint=function(){if(!this._jsPlumb.deleted){this._jsPlumb.initialized||(this.canvas.setAttribute("src",this._jsPlumb.img.src),this.appendDisplayElement(this.canvas),this._jsPlumb.initialized=!0);var a=this.anchorPoint[0]-this._jsPlumb.widthToUse/2,b=this.anchorPoint[1]-this._jsPlumb.heightToUse/2;c.sizeElement(this.canvas,a,b,this._jsPlumb.widthToUse,this._jsPlumb.heightToUse)}},this.paint=function(b,c){null!=this._jsPlumb&&(this._jsPlumb.ready?this.actuallyPaint(b,c):a.setTimeout(function(){this.paint(b,c)}.bind(this),200))}},c.extend(b.Endpoints.Image,[g,b.Endpoints.AbstractEndpoint],{cleanup:function(a){a&&(this._jsPlumb.deleted=!0,this.canvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null)}}),b.Endpoints.Blank=function(a){b.Endpoints.AbstractEndpoint.apply(this,arguments),this.type="Blank",g.apply(this,arguments),this._compute=function(a){return[a[0],a[1],10,0]};var d=a.cssClass?" "+a.cssClass:"";this.canvas=jsPlumb.createElement("div",{display:"block",width:"1px",height:"1px",background:"transparent",position:"absolute"},this._jsPlumb.instance.endpointClass+d),this._jsPlumb.instance.appendElement(this.canvas),this.paint=function(){c.sizeElement(this.canvas,this.x,this.y,this.w,this.h)}},c.extend(b.Endpoints.Blank,[b.Endpoints.AbstractEndpoint,g],{cleanup:function(){this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}),b.Endpoints.Triangle=function(a){this.type="Triangle",b.Endpoints.AbstractEndpoint.apply(this,arguments),a=a||{},a.width=a.width||55,a.height=a.height||55,this.width=a.width,this.height=a.height,this._compute=function(a,b,c){var d=c.width||self.width,e=c.height||self.height,f=a[0]-d/2,g=a[1]-e/2;return[f,g,d,e]}};var h=b.Overlays.AbstractOverlay=function(a){this.visible=!0,this.isAppendedAtTopLevel=!0,this.component=a.component,this.loc=null==a.location?.5:a.location,this.endpointLoc=null==a.endpointLocation?[.5,.5]:a.endpointLocation};h.prototype={cleanup:function(a){a&&(this.component=null,this.canvas=null,this.endpointLoc=null)},reattach:function(){},setVisible:function(a){this.visible=a,this.component.repaint()},isVisible:function(){return this.visible},hide:function(){this.setVisible(!1)},show:function(){this.setVisible(!0)},incrementLocation:function(a){this.loc+=a,this.component.repaint()},setLocation:function(a){this.loc=a,this.component.repaint()},getLocation:function(){return this.loc},updateFrom:function(){}},b.Overlays.Arrow=function(a){this.type="Arrow",h.apply(this,arguments),this.isAppendedAtTopLevel=!1,a=a||{},this.length=a.length||20,this.width=a.width||20,this.id=a.id;var b=(a.direction||1)<0?-1:1,e=a.paintStyle||{lineWidth:1},f=a.foldback||.623;this.computeMaxSize=function(){return 1.5*self.width},this.draw=function(a,g){var h,i,j,k,l;if(a.pointAlongPathFrom){if(c.isString(this.loc)||this.loc>1||this.loc<0){var m=parseInt(this.loc,10),n=this.loc<0?1:0;h=a.pointAlongPathFrom(n,m,!1),i=a.pointAlongPathFrom(n,m-b*this.length/2,!1),j=d.pointOnLine(h,i,this.length)}else if(1==this.loc){if(h=a.pointOnPath(this.loc),i=a.pointAlongPathFrom(this.loc,-this.length),j=d.pointOnLine(h,i,this.length),-1==b){var o=j;j=h,h=o}}else if(0===this.loc){if(j=a.pointOnPath(this.loc),i=a.pointAlongPathFrom(this.loc,this.length),h=d.pointOnLine(j,i,this.length),-1==b){var p=j;j=h,h=p}}else h=a.pointAlongPathFrom(this.loc,b*this.length/2),i=a.pointOnPath(this.loc),j=d.pointOnLine(h,i,this.length);k=d.perpendicularLineTo(h,j,this.width),l=d.pointOnLine(h,j,f*this.length);var q={hxy:h,tail:k,cxy:l},r=e.strokeStyle||g.strokeStyle,s=e.fillStyle||g.strokeStyle,t=e.lineWidth||g.lineWidth;return{component:a,d:q,lineWidth:t,strokeStyle:r,fillStyle:s,minX:Math.min(h.x,k[0].x,k[1].x),maxX:Math.max(h.x,k[0].x,k[1].x),minY:Math.min(h.y,k[0].y,k[1].y),maxY:Math.max(h.y,k[0].y,k[1].y)}}return{component:a,minX:0,maxX:0,minY:0,maxY:0}}},c.extend(b.Overlays.Arrow,h,{updateFrom:function(a){this.length=a.length||this.length,this.width=a.width||this.width,this.direction=null!=a.direction?a.direction:this.direction,this.foldback=a.foldback||this.foldback}}),b.Overlays.PlainArrow=function(a){a=a||{};var c=b.extend(a,{foldback:1});b.Overlays.Arrow.call(this,c),this.type="PlainArrow"},c.extend(b.Overlays.PlainArrow,b.Overlays.Arrow),b.Overlays.Diamond=function(a){a=a||{};var c=a.length||40,d=jsPlumb.extend(a,{length:c/2,foldback:2});b.Overlays.Arrow.call(this,d),this.type="Diamond"},c.extend(b.Overlays.Diamond,b.Overlays.Arrow);var i=function(a,b){return(null==a._jsPlumb.cachedDimensions||b)&&(a._jsPlumb.cachedDimensions=a.getDimensions()),a._jsPlumb.cachedDimensions},j=function(a){b.jsPlumbUIComponent.apply(this,arguments),h.apply(this,arguments);var d=this.fire;this.fire=function(){d.apply(this,arguments),this.component&&this.component.fire.apply(this.component,arguments)},this.detached=!1,this.id=a.id,this._jsPlumb.div=null,this._jsPlumb.initialised=!1,this._jsPlumb.component=a.component,this._jsPlumb.cachedDimensions=null,this._jsPlumb.create=a.create,this._jsPlumb.initiallyInvisible=a.visible===!1,this.getElement=function(){if(null==this._jsPlumb.div){var b=this._jsPlumb.div=jsPlumb.getElement(this._jsPlumb.create(this._jsPlumb.component));b.style.position="absolute",b.className=this._jsPlumb.instance.overlayClass+" "+(this.cssClass?this.cssClass:a.cssClass?a.cssClass:""),this._jsPlumb.instance.appendElement(b),this._jsPlumb.instance.getId(b),this.canvas=b;var c="translate(-50%, -50%)";b.style.webkitTransform=c,b.style.mozTransform=c,b.style.msTransform=c,b.style.oTransform=c,b.style.transform=c,b._jsPlumb=this,a.visible===!1&&(b.style.display="none")}return this._jsPlumb.div},this.draw=function(a,b,d){var e=i(this);if(null!=e&&2==e.length){var f={x:0,y:0};if(d)f={x:d[0],y:d[1]};else if(a.pointOnPath){var g=this.loc,h=!1;(c.isString(this.loc)||this.loc<0||this.loc>1)&&(g=parseInt(this.loc,10),h=!0),f=a.pointOnPath(g,h)}else{var j=this.loc.constructor==Array?this.loc:this.endpointLoc;f={x:j[0]*a.w,y:j[1]*a.h}}var k=f.x-e[0]/2,l=f.y-e[1]/2;return{component:a,d:{minx:k,miny:l,td:e,cxy:f},minX:k,maxX:k+e[0],minY:l,maxY:l+e[1]}}return{minX:0,maxX:0,minY:0,maxY:0}}};c.extend(j,[b.jsPlumbUIComponent,h],{getDimensions:function(){return c.oldIE?b.getSize(this.getElement()):[1,1]},setVisible:function(a){this._jsPlumb.div&&(this._jsPlumb.div.style.display=a?"block":"none",a&&this._jsPlumb.initiallyInvisible&&(i(this,!0),this.component.repaint(),this._jsPlumb.initiallyInvisible=!1))},clearCachedDimensions:function(){this._jsPlumb.cachedDimensions=null},cleanup:function(a){a?null!=this._jsPlumb.div&&(this._jsPlumb.div._jsPlumb=null,this._jsPlumb.instance.removeElement(this._jsPlumb.div)):(this._jsPlumb&&this._jsPlumb.div&&this._jsPlumb.div.parentNode&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div),this.detached=!0)},reattach:function(a){null!=this._jsPlumb.div&&a.getContainer().appendChild(this._jsPlumb.div),this.detached=!1},computeMaxSize:function(){var a=i(this);return Math.max(a[0],a[1])},paint:function(a){this._jsPlumb.initialised||(this.getElement(),a.component.appendDisplayElement(this._jsPlumb.div),this._jsPlumb.initialised=!0,this.detached&&this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div)),this._jsPlumb.div.style.left=a.component.x+a.d.minx+"px",this._jsPlumb.div.style.top=a.component.y+a.d.miny+"px"}}),b.Overlays.Custom=function(){this.type="Custom",j.apply(this,arguments)},c.extend(b.Overlays.Custom,j),b.Overlays.GuideLines=function(){var a=this;a.length=50,a.lineWidth=5,this.type="GuideLines",h.apply(this,arguments),b.jsPlumbUIComponent.apply(this,arguments),this.draw=function(b){var c=b.pointAlongPathFrom(a.loc,a.length/2),e=b.pointOnPath(a.loc),f=d.pointOnLine(c,e,a.length),g=d.perpendicularLineTo(c,f,40),h=d.perpendicularLineTo(f,c,20);return{connector:b,head:c,tail:f,headLine:h,tailLine:g,minX:Math.min(c.x,f.x,h[0].x,h[1].x),minY:Math.min(c.y,f.y,h[0].y,h[1].y),maxX:Math.max(c.x,f.x,h[0].x,h[1].x),maxY:Math.max(c.y,f.y,h[0].y,h[1].y)}}},b.Overlays.Label=function(a){this.labelStyle=a.labelStyle,this.cssClass=null!=this.labelStyle?this.labelStyle.cssClass:null;var c=b.extend({create:function(){return jsPlumb.createElement("div")}},a);if(b.Overlays.Custom.call(this,c),this.type="Label",this.label=a.label||"",this.labelText=null,this.labelStyle){var d=this.getElement();if(this.labelStyle.font=this.labelStyle.font||"12px sans-serif",d.style.font=this.labelStyle.font,d.style.color=this.labelStyle.color||"black",this.labelStyle.fillStyle&&(d.style.background=this.labelStyle.fillStyle),this.labelStyle.borderWidth>0){var e=this.labelStyle.borderStyle?this.labelStyle.borderStyle:"black";d.style.border=this.labelStyle.borderWidth+"px solid "+e}this.labelStyle.padding&&(d.style.padding=this.labelStyle.padding)}},c.extend(b.Overlays.Label,b.Overlays.Custom,{cleanup:function(a){a&&(this.div=null,this.label=null,this.labelText=null,this.cssClass=null,this.labelStyle=null)},getLabel:function(){return this.label},setLabel:function(a){this.label=a,this.labelText=null,this.clearCachedDimensions(),this.update(),this.component.repaint()},getDimensions:function(){return this.update(),j.prototype.getDimensions.apply(this,arguments)},update:function(){if("function"==typeof this.label){var a=this.label(this);this.getElement().innerHTML=a.replace(/\r\n/g,"
    ")}else null==this.labelText&&(this.labelText=this.label,this.getElement().innerHTML=this.labelText.replace(/\r\n/g,"
    "))},updateFrom:function(a){a.label&&this.setLabel(a.label)}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=function(b){var c=b._mottle;return c||(c=b._mottle=new a.Mottle),c};b.extend(a.jsPlumbInstance.prototype,{getEventManager:function(){return c(this)},on:function(){this.getEventManager().on.apply(this,arguments)},off:function(){this.getEventManager().off.apply(this,arguments)}})}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d=function(a){this.type="Flowchart",a=a||{},a.stub=null==a.stub?30:a.stub;var c,d,e=b.Connectors.AbstractConnector.apply(this,arguments),f=null==a.midpoint?.5:a.midpoint,g=a.alwaysRespectStubs===!0,h=null,i=null,j=null,k=null!=a.cornerRadius?a.cornerRadius:0,l=function(a){return 0>a?-1:0===a?0:1},m=function(a,b,c,d){if(i!=b||j!=c){var e=null==i?d.sx:i,f=null==j?d.sy:j,g=e==b?"v":"h",h=l(b-e),k=l(c-f);i=b,j=c,a.push([e,f,b,c,g,h,k])}},n=function(a){return Math.sqrt(Math.pow(a[0]-a[2],2)+Math.pow(a[1]-a[3],2))},o=function(a){var b=[];return b.push.apply(b,a),b},p=function(a,b,c){for(var d,f=null,g=0;g0&&f[4]!=d[4]){var h=Math.min(k,n(f),n(d));f[2]-=f[5]*h,f[3]-=f[6]*h,d[0]+=d[5]*h,d[1]+=d[6]*h;var i=f[6]==d[5]&&1==d[5]||f[6]==d[5]&&0===d[5]&&f[5]!=d[6]||f[6]==d[5]&&-1==d[5],j=d[1]>f[3]?1:-1,l=d[0]>f[2]?1:-1,m=j==l,p=m&&i||!m&&!i?d[0]:f[2],q=m&&i||!m&&!i?f[3]:d[1];e.addSegment(a,"Straight",{x1:f[0],y1:f[1],x2:f[2],y2:f[3]}),e.addSegment(a,"Arc",{r:h,x1:f[2],y1:f[3],x2:d[0],y2:d[1],cx:p,cy:q,ac:i})}else{var r=f[2]==f[0]?0:f[2]>f[0]?c.lw/2:-(c.lw/2),s=f[3]==f[1]?0:f[3]>f[1]?c.lw/2:-(c.lw/2);e.addSegment(a,"Straight",{x1:f[0]-r,y1:f[1]-s,x2:f[2]+r,y2:f[3]+s})}f=d}null!=d&&e.addSegment(a,"Straight",{x1:d[0],y1:d[1],x2:d[2],y2:d[3]})};this.setSegments=function(a){h=a},this.isEditable=function(){return!0},this.getOriginalSegments=function(){return h||c},this._compute=function(a,b){if(b.clearEdits&&(h=null),null!=h)return p(this,h,a),void 0;c=[],i=null,j=null,d=null;var k=a.startStubX+(a.endStubX-a.startStubX)*f,l=a.startStubY+(a.endStubY-a.startStubY)*f,n={x:[0,1],y:[1,0]},o=function(){return[a.startStubX,a.startStubY,a.endStubX,a.endStubY]},q={perpendicular:o,orthogonal:o,opposite:function(b){var c=a,d="x"==b?0:1,e={x:function(){return 1==c.so[d]&&(c.startStubX>c.endStubX&&c.tx>c.startStubX||c.sx>c.endStubX&&c.tx>c.sx)||-1==c.so[d]&&(c.startStubXc.endStubY&&c.ty>c.startStubY||c.sy>c.endStubY&&c.ty>c.sy)||-1==c.so[d]&&(c.startStubYj[b][0],s=e[b][p][0],t=e[b][p][1],u=d[b][p][q];return c.segment==u[3]||c.segment==u[2]&&r?f[b]:c.segment==u[2]&&s>t?g[b]:c.segment==u[2]&&t>=s||c.segment==u[1]&&!r?i[b]:c.segment==u[0]||c.segment==u[1]&&r?h[b]:void 0},orthogonal:function(b,c,d,e,f){var g=a,h={x:-1==g.so[0]?Math.min(c,e):Math.max(c,e),y:-1==g.so[1]?Math.min(c,e):Math.max(c,e)}[b];return{x:[[h,d],[h,f],[e,f]],y:[[d,h],[f,h],[f,e]]}[b]},opposite:function(c,d,f,g){var h=a,i={x:"y",y:"x"}[c],j={x:"height",y:"width"}[c],m=h["is"+c.toUpperCase()+"GreaterThanStubTimes2"];if(b.sourceEndpoint.elementId==b.targetEndpoint.elementId){var n=f+(1-b.sourceEndpoint.anchor[i])*b.sourceInfo[j]+e.maxStub;return{x:[[d,n],[g,n]],y:[[n,d],[n,g]]}[c]}return!m||1==h.so[t]&&d>g||-1==h.so[t]&&g>d?{x:[[d,l],[g,l]],y:[[k,d],[k,g]]}[c]:1==h.so[t]&&g>d||-1==h.so[t]&&d>g?{x:[[k,h.sy],[k,h.ty]],y:[[h.sx,l],[h.tx,l]]}[c]:void 0}},s=q[a.anchorOrientation](a.sourceAxis),t="x"==a.sourceAxis?0:1,u="x"==a.sourceAxis?1:0,v=s[t],w=s[u],x=s[t+2],y=s[u+2];m(c,s[0],s[1],a);var z=r[a.anchorOrientation](a.sourceAxis,v,w,x,y);if(z)for(var A=0;A=a&&b>=d?1:c>=a&&d>=b?2:a>=c&&d>=b?3:4},e=function(a,b,c,d,e,f,g,h,i){return i>=h?[a,b]:1===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:2===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]>=1&&e[2]<=0?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:3===c?d[3]>=1&&e[3]<=0?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+-1*f,b+-1*g]:4===c?d[3]<=0&&e[3]>=1?[a+(d[2]<.5?-1*f:f),b]:d[2]<=0&&e[2]>=1?[a,b+(d[3]<.5?-1*g:g)]:[a+f,b+-1*g]:void 0},f=function(a){a=a||{},this.type="StateMachine";var c=b.Connectors.AbstractConnector.apply(this,arguments),f=a.curviness||10,g=a.margin||5,h=a.proximityLimit||80,i=a.orientation&&"clockwise"===a.orientation,j=a.loopbackRadius||25,k=a.showLoopback!==!1;this._compute=function(a,b){var l=Math.abs(b.sourcePos[0]-b.targetPos[0]),m=Math.abs(b.sourcePos[1]-b.targetPos[1]);if(k&&b.sourceEndpoint.elementId===b.targetEndpoint.elementId){var n=b.sourcePos[0],o=b.sourcePos[1]-g,p=n,q=o-j,r=2*j,s=2*j,t=p-j,u=q-j;a.points[0]=t,a.points[1]=u,a.points[2]=r,a.points[3]=s,c.addSegment(this,"Arc",{loopback:!0,x1:n-t+4,y1:o-u,startAngle:0,endAngle:2*Math.PI,r:j,ac:!i,x2:n-t-4,y2:o-u,cx:p-t,cy:q-u})}else{var v=b.sourcePos[0]c?a.insertBefore(b,a.childNodes[c]):a.appendChild(b)};c.svg={node:t,attr:s,pos:u};var z=function(a){var d=a.pointerEventsSpec||"all",e={};b.jsPlumbUIComponent.apply(this,a.originalArgs),this.canvas=null,this.path=null,this.svg=null,this.bgCanvas=null;var f=a.cssClass+" "+(a.originalArgs[0].cssClass||""),g={style:"",width:0,height:0,"pointer-events":d,position:"absolute"};this.svg=t("svg",g),a.useDivWrapper?(this.canvas=jsPlumb.createElement("div",{position:"absolute"}),c.sizeElement(this.canvas,0,0,1,1),this.canvas.className=f):(s(this.svg,{"class":f}),this.canvas=this.svg),a._jsPlumb.appendElement(this.canvas,a.originalArgs[0].parent),a.useDivWrapper&&this.canvas.appendChild(this.svg);var h=[this.canvas];return this.getDisplayElements=function(){return h},this.appendDisplayElement=function(a){h.push(a)},this.paint=function(b,d,f){if(null!=b){var g,h=[this.x,this.y],i=[this.w,this.h];null!=f&&(f.xmin<0&&(h[0]+=f.xmin),f.ymin<0&&(h[1]+=f.ymin),i[0]=f.xmax+(f.xmin<0?-f.xmin:0),i[1]=f.ymax+(f.ymin<0?-f.ymin:0)),a.useDivWrapper?(c.sizeElement(this.canvas,h[0],h[1],i[0],i[1]),h[0]=0,h[1]=0,g=u([0,0])):g=u([h[0],h[1]]),e.paint.apply(this,arguments),s(this.svg,{style:g,width:i[0]||0,height:i[1]||0})}},{renderer:e}};c.extend(z,b.jsPlumbUIComponent,{cleanup:function(a){a||null==this.typeId?(this.canvas&&(this.canvas._jsPlumb=null),this.svg&&(this.svg._jsPlumb=null),this.bgCanvas&&(this.bgCanvas._jsPlumb=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.svg=null,this.canvas=null,this.path=null,this.group=null):(this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.bgCanvas&&this.bgCanvas.parentNode&&this.bgCanvas.parentNode.removeChild(this.bgCanvas))},reattach:function(a){var b=a.getContainer();this.canvas&&null==this.canvas.parentNode&&b.appendChild(this.canvas),this.bgCanvas&&null==this.bgCanvas.parentNode&&b.appendChild(this.bgCanvas)},setVisible:function(a){this.canvas&&(this.canvas.style.display=a?"block":"none")}}),b.ConnectorRenderers.svg=function(a){var d=this,e=z.apply(this,[{cssClass:a._jsPlumb.connectorClass,originalArgs:arguments,pointerEventsSpec:"none",_jsPlumb:a._jsPlumb}]);e.renderer.paint=function(e,f,g){var h=d.getSegments(),i="",j=[0,0];if(g.xmin<0&&(j[0]=-g.xmin),g.ymin<0&&(j[1]=-g.ymin),h.length>0){for(var k=0;kMath.PI?1:0,d=a.anticlockwise?0:1;return"M"+a.x1+" "+a.y1+" A "+a.radius+" "+b.r+" 0 "+c+","+d+" "+a.x2+" "+a.y2}}[a.type]()}}};var A=b.SvgEndpoint=function(a){var d=z.apply(this,[{cssClass:a._jsPlumb.endpointClass,originalArgs:arguments,pointerEventsSpec:"all",useDivWrapper:!0,_jsPlumb:a._jsPlumb}]);d.renderer.paint=function(a){var d=b.extend({},a);d.outlineColor&&(d.strokeWidth=d.outlineWidth,d.strokeStyle=c.convertStyle(d.outlineColor,!0)),null==this.node?(this.node=this.makeNode(d),this.svg.appendChild(this.node)):null!=this.updateNode&&this.updateNode(this.node),x(this.svg,this.node,d,[this.x,this.y,this.w,this.h],this),u(this.node,[this.x,this.y])}.bind(this)};c.extend(A,z),b.Endpoints.svg.Dot=function(){b.Endpoints.Dot.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(){return t("circle",{cx:this.w/2,cy:this.h/2,r:this.radius})},this.updateNode=function(a){s(a,{cx:this.w/2,cy:this.h/2,r:this.radius})}},c.extend(b.Endpoints.svg.Dot,[b.Endpoints.Dot,A]),b.Endpoints.svg.Rectangle=function(){b.Endpoints.Rectangle.apply(this,arguments),A.apply(this,arguments),this.makeNode=function(){return t("rect",{width:this.w,height:this.h})},this.updateNode=function(a){s(a,{width:this.w,height:this.h})}},c.extend(b.Endpoints.svg.Rectangle,[b.Endpoints.Rectangle,A]),b.Endpoints.svg.Image=b.Endpoints.Image,b.Endpoints.svg.Blank=b.Endpoints.Blank,b.Overlays.svg.Label=b.Overlays.Label,b.Overlays.svg.Custom=b.Overlays.Custom;var B=function(a,c){a.apply(this,c),b.jsPlumbUIComponent.apply(this,c),this.isAppendedAtTopLevel=!1,this.path=null,this.paint=function(a,b){if(a.component.svg&&b){null==this.path&&(this.path=t("path",{"pointer-events":"all"}),a.component.svg.appendChild(this.path),this.canvas=a.component.svg);var e=c&&1==c.length?c[0].cssClass||"":"",f=[0,0];b.xmin<0&&(f[0]=-b.xmin),b.ymin<0&&(f[1]=-b.ymin),s(this.path,{d:d(a.d),"class":e,stroke:a.strokeStyle?a.strokeStyle:null,fill:a.fillStyle?a.fillStyle:null,transform:"translate("+f[0]+","+f[1]+")"})}};var d=function(a){return isNaN(a.cxy.x)||isNaN(a.cxy.y)?"":"M"+a.hxy.x+","+a.hxy.y+" L"+a.tail[0].x+","+a.tail[0].y+" L"+a.cxy.x+","+a.cxy.y+" L"+a.tail[1].x+","+a.tail[1].y+" L"+a.hxy.x+","+a.hxy.y};this.transfer=function(a){a.canvas&&this.path&&this.path.parentNode&&(this.path.parentNode.removeChild(this.path),a.canvas.appendChild(this.path))}};c.extend(B,[b.jsPlumbUIComponent,b.Overlays.AbstractOverlay],{cleanup:function(a){null!=this.path&&(a?this._jsPlumb.instance.removeElement(this.path):this.path.parentNode&&this.path.parentNode.removeChild(this.path))},reattach:function(){this.path&&this.canvas&&null==this.path.parentNode&&this.canvas.appendChild(this.path)},setVisible:function(a){null!=this.path&&(this.path.style.display=a?"block":"none")}}),b.Overlays.svg.Arrow=function(){B.apply(this,[b.Overlays.Arrow,arguments])},c.extend(b.Overlays.svg.Arrow,[b.Overlays.Arrow,B]),b.Overlays.svg.PlainArrow=function(){B.apply(this,[b.Overlays.PlainArrow,arguments])},c.extend(b.Overlays.svg.PlainArrow,[b.Overlays.PlainArrow,B]),b.Overlays.svg.Diamond=function(){B.apply(this,[b.Overlays.Diamond,arguments])},c.extend(b.Overlays.svg.Diamond,[b.Overlays.Diamond,B]),b.Overlays.svg.GuideLines=function(){var a,c,d=null,e=this;b.Overlays.GuideLines.apply(this,arguments),this.paint=function(b,g){null==d&&(d=t("path"),b.connector.svg.appendChild(d),e.attachListeners(d,b.connector),e.attachListeners(d,e),a=t("path"),b.connector.svg.appendChild(a),e.attachListeners(a,b.connector),e.attachListeners(a,e),c=t("path"),b.connector.svg.appendChild(c),e.attachListeners(c,b.connector),e.attachListeners(c,e));var h=[0,0];g.xmin<0&&(h[0]=-g.xmin),g.ymin<0&&(h[1]=-g.ymin),s(d,{d:f(b.head,b.tail),stroke:"red",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(a,{d:f(b.tailLine[0],b.tailLine[1]),stroke:"blue",fill:null,transform:"translate("+h[0]+","+h[1]+")"}),s(c,{d:f(b.headLine[0],b.headLine[1]),stroke:"green",fill:null,transform:"translate("+h[0]+","+h[1]+")"})};var f=function(a,b){return"M "+a.x+","+a.y+" L"+b.x+","+b.y}},c.extend(b.Overlays.svg.GuideLines,b.Overlays.GuideLines)}.call(this),function(){"use strict";var a=this,b=a.jsPlumb,c=a.jsPlumbUtil,d={"stroke-linejoin":"joinstyle",joinstyle:"joinstyle",endcap:"endcap",miterlimit:"miterlimit"},e=null;if(document.createStyleSheet&&document.namespaces){var f=[".jsplumb_vml","jsplumb\\:textbox","jsplumb\\:oval","jsplumb\\:rect","jsplumb\\:stroke","jsplumb\\:shape","jsplumb\\:group"],g="behavior:url(#default#VML);position:absolute;";e=document.createStyleSheet(); +for(var h=0;h 0 ? 1 :-1; }; + } + + var Vectors = { + subtract : function(v1, v2) { return {x:v1.x - v2.x, y:v1.y - v2.y }; }, + dotProduct : function(v1, v2) { return (v1.x * v2.x) + (v1.y * v2.y); }, + square : function(v) { return Math.sqrt((v.x * v.x) + (v.y * v.y)); }, + scale : function(v, s) { return {x:v.x * s, y:v.y * s }; } + }, + + maxRecursion = 64, + flatnessTolerance = Math.pow(2.0,-maxRecursion-1); + + /** + * Calculates the distance that the point lies from the curve. + * + * @param point a point in the form {x:567, y:3342} + * @param curve a Bezier curve in the form [{x:..., y:...}, {x:..., y:...}, {x:..., y:...}, {x:..., y:...}]. note that this is currently + * hardcoded to assume cubiz beziers, but would be better off supporting any degree. + * @return a JS object literal containing location and distance, for example: {location:0.35, distance:10}. Location is analogous to the location + * argument you pass to the pointOnPath function: it is a ratio of distance travelled along the curve. Distance is the distance in pixels from + * the point to the curve. + */ + var _distanceFromCurve = function(point, curve) { + var candidates = [], + w = _convertToBezier(point, curve), + degree = curve.length - 1, higherDegree = (2 * degree) - 1, + numSolutions = _findRoots(w, higherDegree, candidates, 0), + v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0; + + for (var i = 0; i < numSolutions; i++) { + v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null)); + var newDist = Vectors.square(v); + if (newDist < dist) { + dist = newDist; + t = candidates[i]; + } + } + v = Vectors.subtract(point, curve[degree]); + newDist = Vectors.square(v); + if (newDist < dist) { + dist = newDist; + t = 1.0; + } + return {location:t, distance:dist}; + }; + /** + * finds the nearest point on the curve to the given point. + */ + var _nearestPointOnCurve = function(point, curve) { + var td = _distanceFromCurve(point, curve); + return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location}; + }; + var _convertToBezier = function(point, curve) { + var degree = curve.length - 1, higherDegree = (2 * degree) - 1, + c = [], d = [], cdTable = [], w = [], + z = [ [1.0, 0.6, 0.3, 0.1], [0.4, 0.6, 0.6, 0.4], [0.1, 0.3, 0.6, 1.0] ]; + + for (var i = 0; i <= degree; i++) c[i] = Vectors.subtract(curve[i], point); + for (var i = 0; i <= degree - 1; i++) { + d[i] = Vectors.subtract(curve[i+1], curve[i]); + d[i] = Vectors.scale(d[i], 3.0); + } + for (var row = 0; row <= degree - 1; row++) { + for (var column = 0; column <= degree; column++) { + if (!cdTable[row]) cdTable[row] = []; + cdTable[row][column] = Vectors.dotProduct(d[row], c[column]); + } + } + for (i = 0; i <= higherDegree; i++) { + if (!w[i]) w[i] = []; + w[i].y = 0.0; + w[i].x = parseFloat(i) / higherDegree; + } + var n = degree, m = degree-1; + for (var k = 0; k <= n + m; k++) { + var lb = Math.max(0, k - m), + ub = Math.min(k, n); + for (i = lb; i <= ub; i++) { + j = k - i; + w[i+j].y += cdTable[j][i] * z[j][i]; + } + } + return w; + }; + /** + * counts how many roots there are. + */ + var _findRoots = function(w, degree, t, depth) { + var left = [], right = [], + left_count, right_count, + left_t = [], right_t = []; + + switch (_getCrossingCount(w, degree)) { + case 0 : { + return 0; + } + case 1 : { + if (depth >= maxRecursion) { + t[0] = (w[0].x + w[degree].x) / 2.0; + return 1; + } + if (_isFlatEnough(w, degree)) { + t[0] = _computeXIntercept(w, degree); + return 1; + } + break; + } + } + _bezier(w, degree, 0.5, left, right); + left_count = _findRoots(left, degree, left_t, depth+1); + right_count = _findRoots(right, degree, right_t, depth+1); + for (var i = 0; i < left_count; i++) t[i] = left_t[i]; + for (var i = 0; i < right_count; i++) t[i+left_count] = right_t[i]; + return (left_count+right_count); + }; + var _getCrossingCount = function(curve, degree) { + var n_crossings = 0, sign, old_sign; + sign = old_sign = Math.sgn(curve[0].y); + for (var i = 1; i <= degree; i++) { + sign = Math.sgn(curve[i].y); + if (sign != old_sign) n_crossings++; + old_sign = sign; + } + return n_crossings; + }; + var _isFlatEnough = function(curve, degree) { + var error, + intercept_1, intercept_2, left_intercept, right_intercept, + a, b, c, det, dInv, a1, b1, c1, a2, b2, c2; + a = curve[0].y - curve[degree].y; + b = curve[degree].x - curve[0].x; + c = curve[0].x * curve[degree].y - curve[degree].x * curve[0].y; + + var max_distance_above = max_distance_below = 0.0; + + for (var i = 1; i < degree; i++) { + var value = a * curve[i].x + b * curve[i].y + c; + if (value > max_distance_above) + max_distance_above = value; + else if (value < max_distance_below) + max_distance_below = value; + } + + a1 = 0.0; b1 = 1.0; c1 = 0.0; a2 = a; b2 = b; + c2 = c - max_distance_above; + det = a1 * b2 - a2 * b1; + dInv = 1.0/det; + intercept_1 = (b1 * c2 - b2 * c1) * dInv; + a2 = a; b2 = b; c2 = c - max_distance_below; + det = a1 * b2 - a2 * b1; + dInv = 1.0/det; + intercept_2 = (b1 * c2 - b2 * c1) * dInv; + left_intercept = Math.min(intercept_1, intercept_2); + right_intercept = Math.max(intercept_1, intercept_2); + error = right_intercept - left_intercept; + return (error < flatnessTolerance)? 1 : 0; + }; + var _computeXIntercept = function(curve, degree) { + var XLK = 1.0, YLK = 0.0, + XNM = curve[degree].x - curve[0].x, YNM = curve[degree].y - curve[0].y, + XMK = curve[0].x - 0.0, YMK = curve[0].y - 0.0, + det = XNM*YLK - YNM*XLK, detInv = 1.0/det, + S = (XNM*YMK - YNM*XMK) * detInv; + return 0.0 + XLK * S; + }; + var _bezier = function(curve, degree, t, left, right) { + var temp = [[]]; + for (var j =0; j <= degree; j++) temp[0][j] = curve[j]; + for (var i = 1; i <= degree; i++) { + for (var j =0 ; j <= degree - i; j++) { + if (!temp[i]) temp[i] = []; + if (!temp[i][j]) temp[i][j] = {}; + temp[i][j].x = (1.0 - t) * temp[i-1][j].x + t * temp[i-1][j+1].x; + temp[i][j].y = (1.0 - t) * temp[i-1][j].y + t * temp[i-1][j+1].y; + } + } + if (left != null) + for (j = 0; j <= degree; j++) left[j] = temp[j][0]; + if (right != null) + for (j = 0; j <= degree; j++) right[j] = temp[degree-j][j]; + + return (temp[degree][0]); + }; + + var _curveFunctionCache = {}; + var _getCurveFunctions = function(order) { + var fns = _curveFunctionCache[order]; + if (!fns) { + fns = []; + var f_term = function() { return function(t) { return Math.pow(t, order); }; }, + l_term = function() { return function(t) { return Math.pow((1-t), order); }; }, + c_term = function(c) { return function(t) { return c; }; }, + t_term = function() { return function(t) { return t; }; }, + one_minus_t_term = function() { return function(t) { return 1-t; }; }, + _termFunc = function(terms) { + return function(t) { + var p = 1; + for (var i = 0; i < terms.length; i++) p = p * terms[i](t); + return p; + }; + }; + + fns.push(new f_term()); // first is t to the power of the curve order + for (var i = 1; i < order; i++) { + var terms = [new c_term(order)]; + for (var j = 0 ; j < (order - i); j++) terms.push(new t_term()); + for (var j = 0 ; j < i; j++) terms.push(new one_minus_t_term()); + fns.push(new _termFunc(terms)); + } + fns.push(new l_term()); // last is (1-t) to the power of the curve order + + _curveFunctionCache[order] = fns; + } + + return fns; + }; + + + /** + * calculates a point on the curve, for a Bezier of arbitrary order. + * @param curve an array of control points, eg [{x:10,y:20}, {x:50,y:50}, {x:100,y:100}, {x:120,y:100}]. For a cubic bezier this should have four points. + * @param location a decimal indicating the distance along the curve the point should be located at. this is the distance along the curve as it travels, taking the way it bends into account. should be a number from 0 to 1, inclusive. + */ + var _pointOnPath = function(curve, location) { + var cc = _getCurveFunctions(curve.length - 1), + _x = 0, _y = 0; + for (var i = 0; i < curve.length ; i++) { + _x = _x + (curve[i].x * cc[i](location)); + _y = _y + (curve[i].y * cc[i](location)); + } + + return {x:_x, y:_y}; + }; + + var _dist = function(p1,p2) { + return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); + }; + + var _isPoint = function(curve) { + return curve[0].x == curve[1].x && curve[0].y == curve[1].y; + }; + + /** + * finds the point that is 'distance' along the path from 'location'. this method returns both the x,y location of the point and also + * its 'location' (proportion of travel along the path); the method below - _pointAlongPathFrom - calls this method and just returns the + * point. + */ + var _pointAlongPath = function(curve, location, distance) { + + if (_isPoint(curve)) { + return { + point:curve[0], + location:location + }; + } + + var prev = _pointOnPath(curve, location), + tally = 0, + curLoc = location, + direction = distance > 0 ? 1 : -1, + cur = null; + + while (tally < Math.abs(distance)) { + curLoc += (0.005 * direction); + cur = _pointOnPath(curve, curLoc); + tally += _dist(cur, prev); + prev = cur; + } + return {point:cur, location:curLoc}; + }; + + var _length = function(curve) { + if (_isPoint(curve)) return 0; + + var prev = _pointOnPath(curve, 0), + tally = 0, + curLoc = 0, + direction = 1, + cur = null; + + while (curLoc < 1) { + curLoc += (0.005 * direction); + cur = _pointOnPath(curve, curLoc); + tally += _dist(cur, prev); + prev = cur; + } + return tally; + }; + + /** + * finds the point that is 'distance' along the path from 'location'. + */ + var _pointAlongPathFrom = function(curve, location, distance) { + return _pointAlongPath(curve, location, distance).point; + }; + + /** + * finds the location that is 'distance' along the path from 'location'. + */ + var _locationAlongPathFrom = function(curve, location, distance) { + return _pointAlongPath(curve, location, distance).location; + }; + + /** + * returns the gradient of the curve at the given location, which is a decimal between 0 and 1 inclusive. + * + * thanks // http://bimixual.org/AnimationLibrary/beziertangents.html + */ + var _gradientAtPoint = function(curve, location) { + var p1 = _pointOnPath(curve, location), + p2 = _pointOnPath(curve.slice(0, curve.length - 1), location), + dy = p2.y - p1.y, dx = p2.x - p1.x; + return dy == 0 ? Infinity : Math.atan(dy / dx); + }; + + /** + returns the gradient of the curve at the point which is 'distance' from the given location. + if this point is greater than location 1, the gradient at location 1 is returned. + if this point is less than location 0, the gradient at location 0 is returned. + */ + var _gradientAtPointAlongPathFrom = function(curve, location, distance) { + var p = _pointAlongPath(curve, location, distance); + if (p.location > 1) p.location = 1; + if (p.location < 0) p.location = 0; + return _gradientAtPoint(curve, p.location); + }; + + /** + * calculates a line that is 'length' pixels long, perpendicular to, and centered on, the path at 'distance' pixels from the given location. + * if distance is not supplied, the perpendicular for the given location is computed (ie. we set distance to zero). + */ + var _perpendicularToPathAt = function(curve, location, length, distance) { + distance = distance == null ? 0 : distance; + var p = _pointAlongPath(curve, location, distance), + m = _gradientAtPoint(curve, p.location), + _theta2 = Math.atan(-1 / m), + y = length / 2 * Math.sin(_theta2), + x = length / 2 * Math.cos(_theta2); + return [{x:p.point.x + x, y:p.point.y + y}, {x:p.point.x - x, y:p.point.y - y}]; + }; + + this.jsBezier = { + distanceFromCurve : _distanceFromCurve, + gradientAtPoint : _gradientAtPoint, + gradientAtPointAlongCurveFrom : _gradientAtPointAlongPathFrom, + nearestPointOnCurve : _nearestPointOnCurve, + pointOnCurve : _pointOnPath, + pointAlongCurveFrom : _pointAlongPathFrom, + perpendicularToCurveAt : _perpendicularToPathAt, + locationAlongCurveFrom:_locationAlongPathFrom, + getLength:_length + }; +}).call(this); + +/** + * Biltong v0.2 + * + * Various geometry functions written as part of jsPlumb and perhaps useful for others. + * + * Copyright (c) 2014 Simon Porritt + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +;(function() { + + + "use strict"; + + var Biltong = this.Biltong = {}; + + var _isa = function(a) { return Object.prototype.toString.call(a) === "[object Array]"; }, + _pointHelper = function(p1, p2, fn) { + p1 = _isa(p1) ? p1 : [p1.x, p1.y]; + p2 = _isa(p2) ? p2 : [p2.x, p2.y]; + return fn(p1, p2); + }, + /** + * @name Biltong.gradient + * @function + * @desc Calculates the gradient of a line between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The gradient of a line between the two points. + */ + _gradient = Biltong.gradient = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + if (_p2[0] == _p1[0]) + return _p2[1] > _p1[1] ? Infinity : -Infinity; + else if (_p2[1] == _p1[1]) + return _p2[0] > _p1[0] ? 0 : -0; + else + return (_p2[1] - _p1[1]) / (_p2[0] - _p1[0]); + }); + }, + /** + * @name Biltong.normal + * @function + * @desc Calculates the gradient of a normal to a line between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The gradient of a normal to a line between the two points. + */ + _normal = Biltong.normal = function(p1, p2) { + return -1 / _gradient(p1, p2); + }, + /** + * @name Biltong.lineLength + * @function + * @desc Calculates the length of a line between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The length of a line between the two points. + */ + _lineLength = Biltong.lineLength = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + return Math.sqrt(Math.pow(_p2[1] - _p1[1], 2) + Math.pow(_p2[0] - _p1[0], 2)); + }); + }, + /** + * @name Biltong.quadrant + * @function + * @desc Calculates the quadrant in which the angle between the two points lies. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Integer} The quadrant - 1 for upper right, 2 for lower right, 3 for lower left, 4 for upper left. + */ + _quadrant = Biltong.quadrant = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + if (_p2[0] > _p1[0]) { + return (_p2[1] > _p1[1]) ? 2 : 1; + } + else if (_p2[0] == _p1[0]) { + return _p2[1] > _p1[1] ? 2 : 1; + } + else { + return (_p2[1] > _p1[1]) ? 3 : 4; + } + }); + }, + /** + * @name Biltong.theta + * @function + * @desc Calculates the angle between the two points. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Float} The angle between the two points. + */ + _theta = Biltong.theta = function(p1, p2) { + return _pointHelper(p1, p2, function(_p1, _p2) { + var m = _gradient(_p1, _p2), + t = Math.atan(m), + s = _quadrant(_p1, _p2); + if ((s == 4 || s== 3)) t += Math.PI; + if (t < 0) t += (2 * Math.PI); + + return t; + }); + }, + /** + * @name Biltong.intersects + * @function + * @desc Calculates whether or not the two rectangles intersect. + * @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @return {Boolean} True if the rectangles intersect, false otherwise. + */ + _intersects = Biltong.intersects = function(r1, r2) { + var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h, + a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h; + + return ( (x1 <= a1 && a1 <= x2) && (y1 <= b1 && b1 <= y2) ) || + ( (x1 <= a2 && a2 <= x2) && (y1 <= b1 && b1 <= y2) ) || + ( (x1 <= a1 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) || + ( (x1 <= a2 && a1 <= x2) && (y1 <= b2 && b2 <= y2) ) || + ( (a1 <= x1 && x1 <= a2) && (b1 <= y1 && y1 <= b2) ) || + ( (a1 <= x2 && x2 <= a2) && (b1 <= y1 && y1 <= b2) ) || + ( (a1 <= x1 && x1 <= a2) && (b1 <= y2 && y2 <= b2) ) || + ( (a1 <= x2 && x1 <= a2) && (b1 <= y2 && y2 <= b2) ); + }, + /** + * @name Biltong.encloses + * @function + * @desc Calculates whether or not r2 is completely enclosed by r1. + * @param {Rectangle} r1 First rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @param {Rectangle} r2 Second rectangle, as a js object in the form `{x:.., y:.., w:.., h:..}` + * @param {Boolean} [allowSharedEdges=false] If true, the concept of enclosure allows for one or more edges to be shared by the two rectangles. + * @return {Boolean} True if r1 encloses r2, false otherwise. + */ + _encloses = Biltong.encloses = function(r1, r2, allowSharedEdges) { + var x1 = r1.x, x2 = r1.x + r1.w, y1 = r1.y, y2 = r1.y + r1.h, + a1 = r2.x, a2 = r2.x + r2.w, b1 = r2.y, b2 = r2.y + r2.h, + c = function(v1, v2, v3, v4) { return allowSharedEdges ? v1 <= v2 && v3>= v4 : v1 < v2 && v3 > v4; }; + + return c(x1,a1,x2,a2) && c(y1,b1,y2,b2); + }, + _segmentMultipliers = [null, [1, -1], [1, 1], [-1, 1], [-1, -1] ], + _inverseSegmentMultipliers = [null, [-1, -1], [-1, 1], [1, 1], [1, -1] ], + /** + * @name Biltong.pointOnLine + * @function + * @desc Calculates a point on the line from `fromPoint` to `toPoint` that is `distance` units along the length of the line. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Point} Point on the line, in the form `{ x:..., y:... }`. + */ + _pointOnLine = Biltong.pointOnLine = function(fromPoint, toPoint, distance) { + var m = _gradient(fromPoint, toPoint), + s = _quadrant(fromPoint, toPoint), + segmentMultiplier = distance > 0 ? _segmentMultipliers[s] : _inverseSegmentMultipliers[s], + theta = Math.atan(m), + y = Math.abs(distance * Math.sin(theta)) * segmentMultiplier[1], + x = Math.abs(distance * Math.cos(theta)) * segmentMultiplier[0]; + return { x:fromPoint.x + x, y:fromPoint.y + y }; + }, + /** + * @name Biltong.perpendicularLineTo + * @function + * @desc Calculates a line of length `length` that is perpendicular to the line from `fromPoint` to `toPoint` and passes through `toPoint`. + * @param {Point} p1 First point, either as a 2 entry array or object with `left` and `top` properties. + * @param {Point} p2 Second point, either as a 2 entry array or object with `left` and `top` properties. + * @return {Line} Perpendicular line, in the form `[ { x:..., y:... }, { x:..., y:... } ]`. + */ + _perpendicularLineTo = Biltong.perpendicularLineTo = function(fromPoint, toPoint, length) { + var m = _gradient(fromPoint, toPoint), + theta2 = Math.atan(-1 / m), + y = length / 2 * Math.sin(theta2), + x = length / 2 * Math.cos(theta2); + return [{x:toPoint.x + x, y:toPoint.y + y}, {x:toPoint.x - x, y:toPoint.y - y}]; + }; +}).call(this); +; +(function () { + + "use strict"; + + var Sniff = { + android: navigator.userAgent.toLowerCase().indexOf("android") > -1 + }; + + var matchesSelector = function (el, selector, ctx) { + ctx = ctx || el.parentNode; + var possibles = ctx.querySelectorAll(selector); + for (var i = 0; i < possibles.length; i++) { + if (possibles[i] === el) { + return true; + } + } + return false; + }, + _gel = function (el) { + return typeof el == "string" ? document.getElementById(el) : el; + }, + _t = function (e) { + return e.srcElement || e.target; + }, + _d = function (l, fn) { + for (var i = 0, j = l.length; i < j; i++) { + if (l[i] == fn) break; + } + if (i < l.length) l.splice(i, 1); + }, + guid = 1, + // + // this function generates a guid for every handler, sets it on the handler, then adds + // it to the associated object's map of handlers for the given event. this is what enables us + // to unbind all events of some type, or all events (the second of which can be requested by the user, + // but it also used by Mottle when an element is removed.) + _store = function (obj, event, fn) { + var g = guid++; + obj.__ta = obj.__ta || {}; + obj.__ta[event] = obj.__ta[event] || {}; + // store each handler with a unique guid. + obj.__ta[event][g] = fn; + // set the guid on the handler. + fn.__tauid = g; + return g; + }, + _unstore = function (obj, event, fn) { + obj.__ta && obj.__ta[event] && delete obj.__ta[event][fn.__tauid]; + // a handler might have attached extra functions, so we unbind those too. + if (fn.__taExtra) { + for (var i = 0; i < fn.__taExtra.length; i++) { + _unbind(obj, fn.__taExtra[i][0], fn.__taExtra[i][1]); + } + fn.__taExtra.length = 0; + } + // a handler might have attached an unstore callback + fn.__taUnstore && fn.__taUnstore(); + }, + _curryChildFilter = function (children, obj, fn, evt) { + if (children == null) return fn; + else { + var c = children.split(","), + _fn = function (e) { + _fn.__tauid = fn.__tauid; + var t = _t(e); + for (var i = 0; i < c.length; i++) { + if (matchesSelector(t, c[i], obj)) { + fn.apply(t, arguments); + } + } + }; + registerExtraFunction(fn, evt, _fn); + return _fn; + } + }, + // + // registers an 'extra' function on some event listener function we were given - a function that we + // created and bound to the element as part of our housekeeping, and which we want to unbind and remove + // whenever the given function is unbound. + registerExtraFunction = function (fn, evt, newFn) { + fn.__taExtra = fn.__taExtra || []; + fn.__taExtra.push([evt, newFn]); + }, + DefaultHandler = function (obj, evt, fn, children) { + if (isTouchDevice && touchMap[evt]) { + var tfn = _curryChildFilter(children, obj, fn, touchMap[evt]); + _bind(obj, touchMap[evt], tfn , fn); + } + if (evt === "focus" && obj.getAttribute("tabindex") == null) { + obj.setAttribute("tabindex", "1"); + } + _bind(obj, evt, _curryChildFilter(children, obj, fn, evt), fn); + }, + SmartClickHandler = function (obj, evt, fn, children) { + if (obj.__taSmartClicks == null) { + var down = function (e) { + obj.__tad = _pageLocation(e); + }, + up = function (e) { + obj.__tau = _pageLocation(e); + }, + click = function (e) { + if (obj.__tad && obj.__tau && obj.__tad[0] === obj.__tau[0] && obj.__tad[1] === obj.__tau[1]) { + for (var i = 0; i < obj.__taSmartClicks.length; i++) + obj.__taSmartClicks[i].apply(_t(e), [ e ]); + } + }; + DefaultHandler(obj, "mousedown", down, children); + DefaultHandler(obj, "mouseup", up, children); + DefaultHandler(obj, "click", click, children); + obj.__taSmartClicks = []; + } + + // store in the list of callbacks + obj.__taSmartClicks.push(fn); + // the unstore function removes this function from the object's listener list for this type. + fn.__taUnstore = function () { + _d(obj.__taSmartClicks, fn); + }; + }, + _tapProfiles = { + "tap": {touches: 1, taps: 1}, + "dbltap": {touches: 1, taps: 2}, + "contextmenu": {touches: 2, taps: 1} + }, + TapHandler = function (clickThreshold, dblClickThreshold) { + return function (obj, evt, fn, children) { + // if event is contextmenu, for devices which are mouse only, we want to + // use the default bind. + if (evt == "contextmenu" && isMouseDevice) + DefaultHandler(obj, evt, fn, children); + else { + // the issue here is that this down handler gets registered only for the + // child nodes in the first registration. in fact it should be registered with + // no child selector and then on down we should cycle through the regustered + // functions to see if one of them matches. on mouseup we should execute ALL of + // the functions whose children are either null or match the element. + if (obj.__taTapHandler == null) { + var tt = obj.__taTapHandler = { + tap: [], + dbltap: [], + contextmenu: [], + down: false, + taps: 0, + downSelectors: [] + }; + var down = function (e) { + var target = e.srcElement || e.target; + for (var i = 0; i < tt.downSelectors.length; i++) { + if (tt.downSelectors[i] == null || matchesSelector(target, tt.downSelectors[i], obj)) { + tt.down = true; + setTimeout(clearSingle, clickThreshold); + setTimeout(clearDouble, dblClickThreshold); + break; // we only need one match on mousedown + } + } + }, + up = function (e) { + if (tt.down) { + var target = e.srcElement || e.target; + tt.taps++; + var tc = _touchCount(e); + for (var eventId in _tapProfiles) { + var p = _tapProfiles[eventId]; + if (p.touches === tc && (p.taps === 1 || p.taps === tt.taps)) { + for (var i = 0; i < tt[eventId].length; i++) { + if (tt[eventId][i][1] == null || matchesSelector(target, tt[eventId][i][1], obj)) + tt[eventId][i][0].apply(_t(e), [ e ]); + } + } + } + } + }, + clearSingle = function () { + tt.down = false; + }, + clearDouble = function () { + tt.taps = 0; + }; + + DefaultHandler(obj, "mousedown", down/*, children*/); + DefaultHandler(obj, "mouseup", up/*, children*/); + } + // add this child selector (it can be null, that's fine). + obj.__taTapHandler.downSelectors.push(children); + + obj.__taTapHandler[evt].push([fn, children]); + // the unstore function removes this function from the object's listener list for this type. + fn.__taUnstore = function () { + _d(obj.__taTapHandler[evt], fn); + }; + } + }; + }, + meeHelper = function (type, evt, obj, target) { + for (var i in obj.__tamee[type]) { + obj.__tamee[type][i].apply(target, [ evt ]); + } + }, + MouseEnterExitHandler = function () { + var activeElements = []; + return function (obj, evt, fn, children) { + if (!obj.__tamee) { + // __tamee holds a flag saying whether the mouse is currently "in" the element, and a list of + // both mouseenter and mouseexit functions. + obj.__tamee = { over: false, mouseenter: [], mouseexit: [] }; + // register over and out functions + var over = function (e) { + var t = _t(e); + if ((children == null && (t == obj && !obj.__tamee.over)) || (matchesSelector(t, children, obj) && (t.__tamee == null || !t.__tamee.over))) { + meeHelper("mouseenter", e, obj, t); + t.__tamee = t.__tamee || {}; + t.__tamee.over = true; + activeElements.push(t); + } + }, + out = function (e) { + var t = _t(e); + // is the current target one of the activeElements? and is the + // related target NOT a descendant of it? + for (var i = 0; i < activeElements.length; i++) { + if (t == activeElements[i] && !matchesSelector((e.relatedTarget || e.toElement), "*", t)) { + t.__tamee.over = false; + activeElements.splice(i, 1); + meeHelper("mouseexit", e, obj, t); + } + } + }; + + _bind(obj, "mouseover", _curryChildFilter(children, obj, over, "mouseover"), over); + _bind(obj, "mouseout", _curryChildFilter(children, obj, out, "mouseout"), out); + } + + fn.__taUnstore = function () { + delete obj.__tamee[evt][fn.__tauid]; + }; + + _store(obj, evt, fn); + obj.__tamee[evt][fn.__tauid] = fn; + }; + }, + isTouchDevice = "ontouchstart" in document.documentElement, + isMouseDevice = "onmousedown" in document.documentElement, + touchMap = { "mousedown": "touchstart", "mouseup": "touchend", "mousemove": "touchmove" }, + touchstart = "touchstart", touchend = "touchend", touchmove = "touchmove", + iev = (function () { + var rv = -1; + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent, + re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv; + })(), + isIELT9 = iev > -1 && iev < 9, + _genLoc = function (e, prefix) { + if (e == null) return [ 0, 0 ]; + var ts = _touches(e), t = _getTouch(ts, 0); + return [t[prefix + "X"], t[prefix + "Y"]]; + }, + _pageLocation = function (e) { + if (e == null) return [ 0, 0 ]; + if (isIELT9) { + return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ]; + } + else { + return _genLoc(e, "page"); + } + }, + _screenLocation = function (e) { + return _genLoc(e, "screen"); + }, + _clientLocation = function (e) { + return _genLoc(e, "client"); + }, + _getTouch = function (touches, idx) { + return touches.item ? touches.item(idx) : touches[idx]; + }, + _touches = function (e) { + return e.touches && e.touches.length > 0 ? e.touches : + e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches : + e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches : + [ e ]; + }, + _touchCount = function (e) { + return _touches(e).length; + }, + //http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html + _bind = function (obj, type, fn, originalFn) { + _store(obj, type, fn); + originalFn.__tauid = fn.__tauid; + if (obj.addEventListener) + obj.addEventListener(type, fn, false); + else if (obj.attachEvent) { + var key = type + fn.__tauid; + obj["e" + key] = fn; + // TODO look at replacing with .call(..) + obj[key] = function () { + obj["e" + key] && obj["e" + key](window.event); + }; + obj.attachEvent("on" + type, obj[key]); + } + }, + _unbind = function (obj, type, fn) { + if (fn == null) return; + _each(obj, function () { + var _el = _gel(this); + _unstore(_el, type, fn); + // it has been bound if there is a tauid. otherwise it was not bound and we can ignore it. + if (fn.__tauid != null) { + if (_el.removeEventListener) { + _el.removeEventListener(type, fn, false); + if (isTouchDevice && touchMap[type]) _el.removeEventListener(touchMap[type], fn, false); + } + else if (this.detachEvent) { + var key = type + fn.__tauid; + _el[key] && _el.detachEvent("on" + type, _el[key]); + _el[key] = null; + _el["e" + key] = null; + } + } + + // if a touch event was also registered, deregister now. + if (fn.__taTouchProxy) { + _unbind(obj, fn.__taTouchProxy[1], fn.__taTouchProxy[0]); + } + }); + }, + _devNull = function () { + }, + _each = function (obj, fn) { + if (obj == null) return; + // if a list (or list-like), use it. if a string, get a list + // by running the string through querySelectorAll. else, assume + // it's an Element. + // obj.top is "unknown" in IE8. + obj = (typeof Window !== "undefined" && (typeof obj.top !== "unknown" && obj == obj.top)) ? [ obj ] : + (typeof obj !== "string") && (obj.tagName == null && obj.length != null) ? obj : + typeof obj === "string" ? document.querySelectorAll(obj) + : [ obj ]; + + for (var i = 0; i < obj.length; i++) + fn.apply(obj[i]); + }; + + /** + * Mottle offers support for abstracting out the differences + * between touch and mouse devices, plus "smart click" functionality + * (don't fire click if the mouse has moved between mousedown and mouseup), + * and synthesized click/tap events. + * @class Mottle + * @constructor + * @param {Object} params Constructor params + * @param {Integer} [params.clickThreshold=150] Threshold, in milliseconds beyond which a touchstart followed by a touchend is not considered to be a click. + * @param {Integer} [params.dblClickThreshold=350] Threshold, in milliseconds beyond which two successive tap events are not considered to be a click. + * @param {Boolean} [params.smartClicks=false] If true, won't fire click events if the mouse has moved between mousedown and mouseup. Note that this functionality + * requires that Mottle consume the mousedown event, and so may not be viable in all use cases. + */ + this.Mottle = function (params) { + params = params || {}; + var clickThreshold = params.clickThreshold || 150, + dblClickThreshold = params.dblClickThreshold || 350, + mouseEnterExitHandler = new MouseEnterExitHandler(), + tapHandler = new TapHandler(clickThreshold, dblClickThreshold), + _smartClicks = params.smartClicks, + _doBind = function (obj, evt, fn, children) { + if (fn == null) return; + _each(obj, function () { + var _el = _gel(this); + if (_smartClicks && evt === "click") + SmartClickHandler(_el, evt, fn, children); + else if (evt === "tap" || evt === "dbltap" || evt === "contextmenu") { + tapHandler(_el, evt, fn, children); + } + else if (evt === "mouseenter" || evt == "mouseexit") + mouseEnterExitHandler(_el, evt, fn, children); + else + DefaultHandler(_el, evt, fn, children); + }); + }; + + /** + * Removes an element from the DOM, and deregisters all event handlers for it. You should use this + * to ensure you don't leak memory. + * @method remove + * @param {String|Element} el Element, or id of the element, to remove. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.remove = function (el) { + _each(el, function () { + var _el = _gel(this); + if (_el.__ta) { + for (var evt in _el.__ta) { + for (var h in _el.__ta[evt]) { + _unbind(_el, evt, _el.__ta[evt][h]); + } + } + } + _el.parentNode && _el.parentNode.removeChild(_el); + }); + return this; + }; + + /** + * Register an event handler, optionally as a delegate for some set of descendant elements. Note + * that this method takes either 3 or 4 arguments - if you supply 3 arguments it is assumed you have + * omitted the `children` parameter, and that the event handler should be bound directly to the given element. + * @method on + * @param {Element[]|Element|String} el Either an Element, or a CSS spec for a list of elements, or an array of Elements. + * @param {String} [children] Comma-delimited list of selectors identifying allowed children. + * @param {String} event Event ID. + * @param {Function} fn Event handler function. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.on = function (el, event, children, fn) { + var _el = arguments[0], + _c = arguments.length == 4 ? arguments[2] : null, + _e = arguments[1], + _f = arguments[arguments.length - 1]; + + _doBind(_el, _e, _f, _c); + return this; + }; + + /** + * Cancel delegate event handling for the given function. Note that unlike with 'on' you do not supply + * a list of child selectors here: it removes event delegation from all of the child selectors for which the + * given function was registered (if any). + * @method off + * @param {Element[]|Element|String} el Element - or ID of element - from which to remove event listener. + * @param {String} event Event ID. + * @param {Function} fn Event handler function. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.off = function (el, event, fn) { + _unbind(el, event, fn); + return this; + }; + + /** + * Triggers some event for a given element. + * @method trigger + * @param {Element} el Element for which to trigger the event. + * @param {String} event Event ID. + * @param {Event} originalEvent The original event. Should be optional of course, but currently is not, due + * to the jsPlumb use case that caused this method to be added. + * @param {Object} [payload] Optional object to set as `payload` on the generated event; useful for message passing. + * @return {Mottle} The current Mottle instance; you can chain this method. + */ + this.trigger = function (el, event, originalEvent, payload) { + // MouseEvent undefined in old IE; that's how we know it's a mouse event. A fine Microsoft paradox. + var originalIsMouse = isMouseDevice && (typeof MouseEvent === "undefined" || originalEvent == null || originalEvent.constructor === MouseEvent); + + var eventToBind = (isTouchDevice && !isMouseDevice && touchMap[event]) ? touchMap[event] : event, + bindingAMouseEvent = !(isTouchDevice && !isMouseDevice && touchMap[event]); + + var pl = _pageLocation(originalEvent), sl = _screenLocation(originalEvent), cl = _clientLocation(originalEvent); + _each(el, function () { + var _el = _gel(this), evt; + originalEvent = originalEvent || { + screenX: sl[0], + screenY: sl[1], + clientX: cl[0], + clientY: cl[1] + }; + + var _decorate = function (_evt) { + if (payload) _evt.payload = payload; + }; + + var eventGenerators = { + "TouchEvent": function (evt) { + var touch = document.createTouch(window, _el, 0, pl[0], pl[1], + sl[0], sl[1], + cl[0], cl[1], + 0, 0, 0, 0); + + // https://gist.github.com/sstephenson/448808 + var touches = document.createTouchList(touch); + var targetTouches = document.createTouchList(touch); + var changedTouches = document.createTouchList(touch); + evt.initTouchEvent(eventToBind, true, true, window, null, sl[0], sl[1], + cl[0], cl[1], false, false, false, false, + touches, targetTouches, changedTouches, 1, 0); + }, + "MouseEvents": function (evt) { + evt.initMouseEvent(eventToBind, true, true, window, 0, + sl[0], sl[1], + cl[0], cl[1], + false, false, false, false, 1, _el); + + if (Sniff.android) { + // Android's touch events are not standard. + var t = document.createTouch(window, _el, 0, pl[0], pl[1], + sl[0], sl[1], + cl[0], cl[1], + 0, 0, 0, 0); + + evt.touches = evt.targetTouches = evt.changedTouches = document.createTouchList(t); + } + } + }; + + if (document.createEvent) { + + var ite = !bindingAMouseEvent && !originalIsMouse && (isTouchDevice && touchMap[event] && !Sniff.android), + evtName = ite ? "TouchEvent" : "MouseEvents"; + + evt = document.createEvent(evtName); + eventGenerators[evtName](evt); + _decorate(evt); + _el.dispatchEvent(evt); + } + else if (document.createEventObject) { + evt = document.createEventObject(); + evt.eventType = evt.eventName = eventToBind; + evt.screenX = sl[0]; + evt.screenY = sl[1]; + evt.clientX = cl[0]; + evt.clientY = cl[1]; + _decorate(evt); + _el.fireEvent('on' + eventToBind, evt); + } + }); + return this; + } + }; + + /** + * Static method to assist in 'consuming' an element: uses `stopPropagation` where available, or sets `e.returnValue=false` where it is not. + * @method Mottle.consume + * @param {Event} e Event to consume + * @param {Boolean} [doNotPreventDefault=false] If true, does not call `preventDefault()` on the event. + */ + Mottle.consume = function (e, doNotPreventDefault) { + if (e.stopPropagation) + e.stopPropagation(); + else + e.returnValue = false; + + if (!doNotPreventDefault && e.preventDefault) + e.preventDefault(); + }; + + /** + * Gets the page location corresponding to the given event. For touch events this means get the page location of the first touch. + * @method Mottle.pageLocation + * @param {Event} e Event to get page location for. + * @return {Integer[]} [left, top] for the given event. + */ + Mottle.pageLocation = _pageLocation; + + /** + * Forces touch events to be turned "on". Useful for testing: even if you don't have a touch device, you can still + * trigger a touch event when this is switched on and it will be captured and acted on. + * @method setForceTouchEvents + * @param {Boolean} value If true, force touch events to be on. + */ + Mottle.setForceTouchEvents = function (value) { + isTouchDevice = value; + }; + + /** + * Forces mouse events to be turned "on". Useful for testing: even if you don't have a mouse, you can still + * trigger a mouse event when this is switched on and it will be captured and acted on. + * @method setForceMouseEvents + * @param {Boolean} value If true, force mouse events to be on. + */ + Mottle.setForceMouseEvents = function (value) { + isMouseDevice = value; + }; + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains utility functions that run in both browsers and headless. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ + +; +(function () { + + var _isa = function (a) { + return Object.prototype.toString.call(a) === "[object Array]"; + }, + _isnum = function (n) { + return Object.prototype.toString.call(n) === "[object Number]"; + }, + _iss = function (s) { + return typeof s === "string"; + }, + _isb = function (s) { + return typeof s === "boolean"; + }, + _isnull = function (s) { + return s == null; + }, + _iso = function (o) { + return o == null ? false : Object.prototype.toString.call(o) === "[object Object]"; + }, + _isd = function (o) { + return Object.prototype.toString.call(o) === "[object Date]"; + }, + _isf = function (o) { + return Object.prototype.toString.call(o) === "[object Function]"; + }, + _ise = function (o) { + for (var i in o) { + if (o.hasOwnProperty(i)) return false; + } + return true; + }; + + var root = this; + var exports = root.jsPlumbUtil = { + isArray: _isa, + isString: _iss, + isBoolean: _isb, + isNull: _isnull, + isObject: _iso, + isDate: _isd, + isFunction: _isf, + isEmpty: _ise, + isNumber: _isnum, + clone: function (a) { + if (_iss(a)) return "" + a; + else if (_isb(a)) return !!a; + else if (_isd(a)) return new Date(a.getTime()); + else if (_isf(a)) return a; + else if (_isa(a)) { + var b = []; + for (var i = 0; i < a.length; i++) + b.push(this.clone(a[i])); + return b; + } + else if (_iso(a)) { + var c = {}; + for (var j in a) + c[j] = this.clone(a[j]); + return c; + } + else return a; + }, + merge: function (a, b, collations) { + // first change the collations array - if present - into a lookup table, because its faster. + var cMap = {}, ar, i; + collations = collations || []; + for (i = 0; i < collations.length; i++) + cMap[collations[i]] = true; + + var c = this.clone(a); + for (i in b) { + if (c[i] == null) { + c[i] = b[i]; + } + else if (_iss(b[i]) || _isb(b[i])) { + if (!cMap[i]) { + c[i] = b[i]; // if we dont want to collate, just copy it in. + } + else { + ar = []; + // if c's object is also an array we can keep its values. + ar.push.apply(ar, _isa(c[i]) ? c[i] : [ c[i] ]); + ar.push.apply(ar, _isa(b[i]) ? b[i] : [ b[i] ]); + c[i] = ar; + } + } + else { + if (_isa(b[i])) { + ar = []; + // if c's object is also an array we can keep its values. + if (_isa(c[i])) ar.push.apply(ar, c[i]); + ar.push.apply(ar, b[i]); + c[i] = ar; + } + else if (_iso(b[i])) { + // overwite c's value with an object if it is not already one. + if (!_iso(c[i])) + c[i] = {}; + for (var j in b[i]) { + c[i][j] = b[i][j]; + } + } + } + + } + return c; + }, + replace: function (inObj, path, value) { + if (inObj == null) return; + var q = inObj, t = q; + path.replace(/([^\.])+/g, function (term, lc, pos, str) { + var array = term.match(/([^\[0-9]+){1}(\[)([0-9+])/), + last = pos + term.length >= str.length, + _getArray = function () { + return t[array[1]] || (function () { + t[array[1]] = []; + return t[array[1]]; + })(); + }; + + if (last) { + // set term = value on current t, creating term as array if necessary. + if (array) + _getArray()[array[3]] = value; + else + t[term] = value; + } + else { + // set to current t[term], creating t[term] if necessary. + if (array) { + var a = _getArray(); + t = a[array[3]] || (function () { + a[array[3]] = {}; + return a[array[3]]; + })(); + } + else + t = t[term] || (function () { + t[term] = {}; + return t[term]; + })(); + } + }); + + return inObj; + }, + // + // chain a list of functions, supplied by [ object, method name, args ], and return on the first + // one that returns the failValue. if none return the failValue, return the successValue. + // + functionChain: function (successValue, failValue, fns) { + for (var i = 0; i < fns.length; i++) { + var o = fns[i][0][fns[i][1]].apply(fns[i][0], fns[i][2]); + if (o === failValue) { + return o; + } + } + return successValue; + }, + // take the given model and expand out any parameters. + populate: function (model, values) { + // for a string, see if it has parameter matches, and if so, try to make the substitutions. + var getValue = function (fromString) { + var matches = fromString.match(/(\${.*?})/g); + if (matches != null) { + for (var i = 0; i < matches.length; i++) { + var val = values[matches[i].substring(2, matches[i].length - 1)] || ""; + if (val != null) { + fromString = fromString.replace(matches[i], val); + } + } + } + return fromString; + }, + // process one entry. + _one = function (d) { + if (d != null) { + if (_iss(d)) { + return getValue(d); + } + else if (_isa(d)) { + var r = []; + for (var i = 0; i < d.length; i++) + r.push(_one(d[i])); + return r; + } + else if (_iso(d)) { + var s = {}; + for (var j in d) { + s[j] = _one(d[j]); + } + return s; + } + else { + return d; + } + } + }; + + return _one(model); + }, + convertStyle: function (s, ignoreAlpha) { + // TODO: jsPlumb should support a separate 'opacity' style member. + if ("transparent" === s) return s; + var o = s, + pad = function (n) { + return n.length == 1 ? "0" + n : n; + }, + hex = function (k) { + return pad(Number(k).toString(16)); + }, + pattern = /(rgb[a]?\()(.*)(\))/; + if (s.match(pattern)) { + var parts = s.match(pattern)[2].split(","); + o = "#" + hex(parts[0]) + hex(parts[1]) + hex(parts[2]); + if (!ignoreAlpha && parts.length == 4) + o = o + hex(parts[3]); + } + return o; + }, + findWithFunction: function (a, f) { + if (a) + for (var i = 0; i < a.length; i++) if (f(a[i])) return i; + return -1; + }, + indexOf: function (l, v) { + return l.indexOf ? l.indexOf(v) : exports.findWithFunction(l, function (_v) { + return _v == v; + }); + }, + removeWithFunction: function (a, f) { + var idx = exports.findWithFunction(a, f); + if (idx > -1) a.splice(idx, 1); + return idx != -1; + }, + remove: function (l, v) { + var idx = exports.indexOf(l, v); + if (idx > -1) l.splice(idx, 1); + return idx != -1; + }, + // TODO support insert index + addWithFunction: function (list, item, hashFunction) { + if (exports.findWithFunction(list, hashFunction) == -1) list.push(item); + }, + addToList: function (map, key, value, insertAtStart) { + var l = map[key]; + if (l == null) { + l = []; + map[key] = l; + } + l[insertAtStart ? "unshift" : "push"](value); + return l; + }, + // + // extends the given obj (which can be an array) with the given constructor function, prototype functions, and + // class members, any of which may be null. + // + extend: function (child, parent, _protoFn) { + var i; + parent = _isa(parent) ? parent : [ parent ]; + + for (i = 0; i < parent.length; i++) { + for (var j in parent[i].prototype) { + if (parent[i].prototype.hasOwnProperty(j)) { + child.prototype[j] = parent[i].prototype[j]; + } + } + } + + var _makeFn = function (name, protoFn) { + return function () { + for (i = 0; i < parent.length; i++) { + if (parent[i].prototype[name]) + parent[i].prototype[name].apply(this, arguments); + } + return protoFn.apply(this, arguments); + }; + }; + + var _oneSet = function (fns) { + for (var k in fns) { + child.prototype[k] = _makeFn(k, fns[k]); + } + }; + + if (arguments.length > 2) { + for (i = 2; i < arguments.length; i++) + _oneSet(arguments[i]); + } + + return child; + }, + uuid: function () { + return ('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + })); + }, + logEnabled: true, + log: function () { + if (exports.logEnabled && typeof console != "undefined") { + try { + var msg = arguments[arguments.length - 1]; + console.log(msg); + } + catch (e) { + } + } + }, + + /** + * Wraps one function with another, creating a placeholder for the + * wrapped function if it was null. this is used to wrap the various + * drag/drop event functions - to allow jsPlumb to be notified of + * important lifecycle events without imposing itself on the user's + * drag/drop functionality. + * @method jsPlumbUtil.wrap + * @param {Function} wrappedFunction original function to wrap; may be null. + * @param {Function} newFunction function to wrap the original with. + * @param {Object} [returnOnThisValue] Optional. Indicates that the wrappedFunction should + * not be executed if the newFunction returns a value matching 'returnOnThisValue'. + * note that this is a simple comparison and only works for primitives right now. + */ + wrap: function (wrappedFunction, newFunction, returnOnThisValue) { + wrappedFunction = wrappedFunction || function () { + }; + newFunction = newFunction || function () { + }; + return function () { + var r = null; + try { + r = newFunction.apply(this, arguments); + } catch (e) { + exports.log("jsPlumb function failed : " + e); + } + if (returnOnThisValue == null || (r !== returnOnThisValue)) { + try { + r = wrappedFunction.apply(this, arguments); + } catch (e) { + exports.log("wrapped function failed : " + e); + } + } + return r; + }; + } + }; + + exports.EventGenerator = function () { + var _listeners = {}, + eventsSuspended = false, + // this is a list of events that should re-throw any errors that occur during their dispatch. it is current private. + eventsToDieOn = { "ready": true }; + + this.bind = function (event, listener, insertAtStart) { + var _one = function(evt) { + exports.addToList(_listeners, evt, listener, insertAtStart); + listener.__jsPlumb = listener.__jsPlumb || {}; + listener.__jsPlumb[jsPlumbUtil.uuid()] = evt; + }; + + if (typeof event === "string") _one(event); + else if (event.length != null) { + for (var i = 0; i < event.length; i++) { + _one(event[i]); + } + } + + return this; + }; + + this.fire = function (event, value, originalEvent) { + if (!eventsSuspended && _listeners[event]) { + var l = _listeners[event].length, i = 0, _gone = false, ret = null; + if (!this.shouldFireEvent || this.shouldFireEvent(event, value, originalEvent)) { + while (!_gone && i < l && ret !== false) { + // doing it this way rather than catching and then possibly re-throwing means that an error propagated by this + // method will have the whole call stack available in the debugger. + if (eventsToDieOn[event]) + _listeners[event][i].apply(this, [ value, originalEvent]); + else { + try { + ret = _listeners[event][i].apply(this, [ value, originalEvent ]); + } catch (e) { + exports.log("jsPlumb: fire failed for event " + event + " : " + e); + } + } + i++; + if (_listeners == null || _listeners[event] == null) + _gone = true; + } + } + } + return this; + }; + + this.unbind = function (eventOrListener, listener) { + + if (arguments.length === 0) { + _listeners = {}; + } + else if (arguments.length === 1) { + if (typeof eventOrListener === "string") + delete _listeners[eventOrListener]; + else if (eventOrListener.__jsPlumb) { + var evt; + for (var i in eventOrListener.__jsPlumb) { + evt = eventOrListener.__jsPlumb[i]; + exports.remove(_listeners[evt] || [], eventOrListener); + } + } + } + else if (arguments.length === 2) { + exports.remove(_listeners[eventOrListener] || [], listener); + } + + return this; + }; + + this.getListener = function (forEvent) { + return _listeners[forEvent]; + }; + this.setSuspendEvents = function (val) { + eventsSuspended = val; + }; + this.isSuspendEvents = function () { + return eventsSuspended; + }; + this.silently = function(fn) { + this.setSuspendEvents(true); + try { + fn(); + } + catch (e) { + jsPlumbUtil.log("Cannot execute silent function " + e); + } + this.setSuspendEvents(false); + }; + this.cleanupListeners = function () { + for (var i in _listeners) { + _listeners[i] = null; + } + }; + }; + + exports.EventGenerator.prototype = { + cleanup: function () { + this.cleanupListeners(); + } + }; + + // thanks MDC + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fbind + if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () { + }, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; + } + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains utility functions that run in browsers only. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ + ;(function() { + + "use strict"; + + var root = this; + var exports = root.jsPlumbUtil; + + exports.ieVersion = /MSIE\s([\d.]+)/.test(navigator.userAgent) ? (new Number(RegExp.$1)) : -1; + + exports.oldIE = exports.ieVersion > -1 && exports.ieVersion < 9; + + exports.matchesSelector = function(el, selector, ctx) { + ctx = ctx || el.parentNode; + var possibles = ctx.querySelectorAll(selector); + for (var i = 0; i < possibles.length; i++) { + if (possibles[i] === el) + return true; + } + return false; + }; + + exports.consume = function(e, doNotPreventDefault) { + if (e.stopPropagation) + e.stopPropagation(); + else + e.returnValue = false; + + if (!doNotPreventDefault && e.preventDefault) + e.preventDefault(); + }; + + /* + * Function: sizeElement + * Helper to size and position an element. You would typically use + * this when writing your own Connector or Endpoint implementation. + * + * Parameters: + * x - [int] x position for the element origin + * y - [int] y position for the element origin + * w - [int] width of the element + * h - [int] height of the element + * + */ + exports.sizeElement = function(el, x, y, w, h) { + if (el) { + el.style.height = h + "px"; + el.height = h; + el.style.width = w + "px"; + el.width = w; + el.style.left = x + "px"; + el.style.top = y + "px"; + } + }; + + + }).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the core code. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +(function () { + + "use strict"; + + var root = this; + var connectorTypes = [], rendererTypes; + + var _ju = root.jsPlumbUtil, + _getOffset = function (el, _instance, relativeToRoot) { + return _instance.getOffset(el, relativeToRoot); + }, + + /** + * creates a timestamp, using milliseconds since 1970, but as a string. + */ + _timestamp = function () { + return "" + (new Date()).getTime(); + }, + + // helper method to update the hover style whenever it, or paintStyle, changes. + // we use paintStyle as the foundation and merge hoverPaintStyle over the + // top. + _updateHoverStyle = function (component) { + if (component._jsPlumb.paintStyle && component._jsPlumb.hoverPaintStyle) { + var mergedHoverStyle = {}; + jsPlumb.extend(mergedHoverStyle, component._jsPlumb.paintStyle); + jsPlumb.extend(mergedHoverStyle, component._jsPlumb.hoverPaintStyle); + delete component._jsPlumb.hoverPaintStyle; + // we want the fillStyle of paintStyle to override a gradient, if possible. + if (mergedHoverStyle.gradient && component._jsPlumb.paintStyle.fillStyle) + delete mergedHoverStyle.gradient; + component._jsPlumb.hoverPaintStyle = mergedHoverStyle; + } + }, + events = ["tap", "dbltap", "click", "dblclick", "mouseover", "mouseout", "mousemove", "mousedown", "mouseup", "contextmenu" ], + eventFilters = { "mouseout": "mouseleave", "mouseexit": "mouseleave" }, + _updateAttachedElements = function (component, state, timestamp, sourceElement) { + var affectedElements = component.getAttachedElements(); + if (affectedElements) { + for (var i = 0, j = affectedElements.length; i < j; i++) { + if (!sourceElement || sourceElement != affectedElements[i]) + affectedElements[i].setHover(state, true, timestamp); // tell the attached elements not to inform their own attached elements. + } + } + }, + _splitType = function (t) { + return t == null ? null : t.split(" "); + }, + _mapType = function(map, obj, typeId) { + for (var i in obj) + map[i] = typeId; + }, + _applyTypes = function (component, params, doNotRepaint) { + if (component.getDefaultType) { + var td = component.getTypeDescriptor(), map = {}; + var defType = component.getDefaultType(); + var o = _ju.merge({}, defType); + _mapType(map, defType, "__default"); + for (var i = 0, j = component._jsPlumb.types.length; i < j; i++) { + var tid = component._jsPlumb.types[i]; + if (tid !== "__default") { + var _t = component._jsPlumb.instance.getType(tid, td); + if (_t != null) { + o = _ju.merge(o, _t, [ "cssClass" ]); + _mapType(map, _t, tid); + } + } + } + + if (params) { + o = _ju.populate(o, params); + } + + component.applyType(o, doNotRepaint, map); + if (!doNotRepaint) component.repaint(); + } + }, + +// ------------------------------ BEGIN jsPlumbUIComponent -------------------------------------------- + + jsPlumbUIComponent = window.jsPlumbUIComponent = function (params) { + + jsPlumbUtil.EventGenerator.apply(this, arguments); + + var self = this, + a = arguments, + idPrefix = self.idPrefix, + id = idPrefix + (new Date()).getTime(); + + this._jsPlumb = { + instance: params._jsPlumb, + parameters: params.parameters || {}, + paintStyle: null, + hoverPaintStyle: null, + paintStyleInUse: null, + hover: false, + beforeDetach: params.beforeDetach, + beforeDrop: params.beforeDrop, + overlayPlacements: [], + hoverClass: params.hoverClass || params._jsPlumb.Defaults.HoverClass, + types: [], + typeCache:{} + }; + + this.cacheTypeItem = function(key, item, typeId) { + this._jsPlumb.typeCache[typeId] = this._jsPlumb.typeCache[typeId] || {}; + this._jsPlumb.typeCache[typeId][key] = item; + }; + this.getCachedTypeItem = function(key, typeId) { + return this._jsPlumb.typeCache[typeId] ? this._jsPlumb.typeCache[typeId][key] : null; + }; + + this.getId = function () { + return id; + }; + +// ----------------------------- default type -------------------------------------------- + + + var o = params.overlays || [], oo = {}; + if (this.defaultOverlayKeys) { + for (var i = 0; i < this.defaultOverlayKeys.length; i++) + Array.prototype.push.apply(o, this._jsPlumb.instance.Defaults[this.defaultOverlayKeys[i]] || []); + + for (i = 0; i < o.length; i++) { + // if a string, convert to object representation so that we can store the typeid on it. + // also assign an id. + var fo = jsPlumb.convertToFullOverlaySpec(o[i]); + oo[fo[1].id] = fo; + } + } + + var _defaultType = { + overlays:oo, + parameters: params.parameters || {}, + scope: params.scope || this._jsPlumb.instance.getDefaultScope() + }; + this.getDefaultType = function() { + return _defaultType; + }; + this.appendToDefaultType = function(obj) { + for (var i in obj) _defaultType[i] = obj[i]; + }; + +// ----------------------------- end default type -------------------------------------------- + + // all components can generate events + + if (params.events) { + for (i in params.events) + self.bind(i, params.events[i]); + } + + // all components get this clone function. + // TODO issue 116 showed a problem with this - it seems 'a' that is in + // the clone function's scope is shared by all invocations of it, the classic + // JS closure problem. for now, jsPlumb does a version of this inline where + // it used to call clone. but it would be nice to find some time to look + // further at this. + this.clone = function () { + var o = {};//new Object(); + this.constructor.apply(o, a); + return o; + }.bind(this); + + // user can supply a beforeDetach callback, which will be executed before a detach + // is performed; returning false prevents the detach. + this.isDetachAllowed = function (connection) { + var r = true; + if (this._jsPlumb.beforeDetach) { + try { + r = this._jsPlumb.beforeDetach(connection); + } + catch (e) { + _ju.log("jsPlumb: beforeDetach callback failed", e); + } + } + return r; + }; + + // user can supply a beforeDrop callback, which will be executed before a dropped + // connection is confirmed. user can return false to reject connection. + this.isDropAllowed = function (sourceId, targetId, scope, connection, dropEndpoint, source, target) { + var r = this._jsPlumb.instance.checkCondition("beforeDrop", { + sourceId: sourceId, + targetId: targetId, + scope: scope, + connection: connection, + dropEndpoint: dropEndpoint, + source: source, target: target + }); + if (this._jsPlumb.beforeDrop) { + try { + r = this._jsPlumb.beforeDrop({ + sourceId: sourceId, + targetId: targetId, + scope: scope, + connection: connection, + dropEndpoint: dropEndpoint, + source: source, target: target + }); + } + catch (e) { + _ju.log("jsPlumb: beforeDrop callback failed", e); + } + } + return r; + }; + + var boundListeners = [], + bindAListener = function (obj, type, fn) { + boundListeners.push([obj, type, fn]); + obj.bind(type, fn); + }, + domListeners = []; + + // sets the component associated with listener events. for instance, an overlay delegates + // its events back to a connector. but if the connector is swapped on the underlying connection, + // then this component must be changed. This is called by setConnector in the Connection class. + this.setListenerComponent = function (c) { + for (var i = 0; i < domListeners.length; i++) + domListeners[i][3] = c; + }; + + + }; + + var _removeTypeCssHelper = function (component, typeIndex) { + var typeId = component._jsPlumb.types[typeIndex], + type = component._jsPlumb.instance.getType(typeId, component.getTypeDescriptor()); + + if (type != null) { + + if (type.cssClass && component.canvas) + component._jsPlumb.instance.removeClass(component.canvas, type.cssClass); + } + }; + + jsPlumbUtil.extend(jsPlumbUIComponent, jsPlumbUtil.EventGenerator, { + + getParameter: function (name) { + return this._jsPlumb.parameters[name]; + }, + + setParameter: function (name, value) { + this._jsPlumb.parameters[name] = value; + }, + + getParameters: function () { + return this._jsPlumb.parameters; + }, + + setParameters: function (p) { + this._jsPlumb.parameters = p; + }, + + hasClass:function(clazz) { + return jsPlumb.hasClass(this.canvas, clazz); + }, + + addClass: function (clazz) { + jsPlumb.addClass(this.canvas, clazz); + }, + + removeClass: function (clazz) { + jsPlumb.removeClass(this.canvas, clazz); + }, + + updateClasses: function (classesToAdd, classesToRemove) { + jsPlumb.updateClasses(this.canvas, classesToAdd, classesToRemove); + }, + + setType: function (typeId, params, doNotRepaint) { + this.clearTypes(); + this._jsPlumb.types = _splitType(typeId) || []; + _applyTypes(this, params, doNotRepaint); + }, + + getType: function () { + return this._jsPlumb.types; + }, + + reapplyTypes: function (params, doNotRepaint) { + _applyTypes(this, params, doNotRepaint); + }, + + hasType: function (typeId) { + return jsPlumbUtil.indexOf(this._jsPlumb.types, typeId) != -1; + }, + + addType: function (typeId, params, doNotRepaint) { + var t = _splitType(typeId), _cont = false; + if (t != null) { + for (var i = 0, j = t.length; i < j; i++) { + if (!this.hasType(t[i])) { + this._jsPlumb.types.push(t[i]); + _cont = true; + } + } + if (_cont) _applyTypes(this, params, doNotRepaint); + } + }, + + removeType: function (typeId, doNotRepaint) { + var t = _splitType(typeId), _cont = false, _one = function (tt) { + var idx = _ju.indexOf(this._jsPlumb.types, tt); + if (idx != -1) { + // remove css class if necessary + _removeTypeCssHelper(this, idx); + this._jsPlumb.types.splice(idx, 1); + return true; + } + return false; + }.bind(this); + + if (t != null) { + for (var i = 0, j = t.length; i < j; i++) { + _cont = _one(t[i]) || _cont; + } + if (_cont) _applyTypes(this, null, doNotRepaint); + } + }, + clearTypes: function (doNotRepaint) { + var i = this._jsPlumb.types.length; + for (var j = 0; j < i; j++) { + _removeTypeCssHelper(this, 0); + this._jsPlumb.types.splice(0, 1); + } + _applyTypes(this, {}, doNotRepaint); + }, + + toggleType: function (typeId, params, doNotRepaint) { + var t = _splitType(typeId); + if (t != null) { + for (var i = 0, j = t.length; i < j; i++) { + var idx = jsPlumbUtil.indexOf(this._jsPlumb.types, t[i]); + if (idx != -1) { + _removeTypeCssHelper(this, idx); + this._jsPlumb.types.splice(idx, 1); + } + else + this._jsPlumb.types.push(t[i]); + } + + _applyTypes(this, params, doNotRepaint); + } + }, + applyType: function (t, doNotRepaint) { + this.setPaintStyle(t.paintStyle, doNotRepaint); + this.setHoverPaintStyle(t.hoverPaintStyle, doNotRepaint); + if (t.parameters) { + for (var i in t.parameters) + this.setParameter(i, t.parameters[i]); + } + this._jsPlumb.paintStyleInUse = this.getPaintStyle(); + }, + setPaintStyle: function (style, doNotRepaint) { +// this._jsPlumb.paintStyle = jsPlumb.extend({}, style); +// TODO figure out if we want components to clone paintStyle so as not to share it. + this._jsPlumb.paintStyle = style; + this._jsPlumb.paintStyleInUse = this._jsPlumb.paintStyle; + _updateHoverStyle(this); + if (!doNotRepaint) this.repaint(); + }, + getPaintStyle: function () { + return this._jsPlumb.paintStyle; + }, + setHoverPaintStyle: function (style, doNotRepaint) { + //this._jsPlumb.hoverPaintStyle = jsPlumb.extend({}, style); +// TODO figure out if we want components to clone paintStyle so as not to share it. + this._jsPlumb.hoverPaintStyle = style; + _updateHoverStyle(this); + if (!doNotRepaint) this.repaint(); + }, + getHoverPaintStyle: function () { + return this._jsPlumb.hoverPaintStyle; + }, + destroy: function (force) { + if (force || this.typeId == null) { + this.cleanupListeners(); // this is on EventGenerator + this.clone = null; + this._jsPlumb = null; + } + }, + + isHover: function () { + return this._jsPlumb.hover; + }, + + setHover: function (hover, ignoreAttachedElements, timestamp) { + // while dragging, we ignore these events. this keeps the UI from flashing and + // swishing and whatevering. + if (this._jsPlumb && !this._jsPlumb.instance.currentlyDragging && !this._jsPlumb.instance.isHoverSuspended()) { + + this._jsPlumb.hover = hover; + + if (this.canvas != null) { + if (this._jsPlumb.instance.hoverClass != null) { + var method = hover ? "addClass" : "removeClass"; + this._jsPlumb.instance[method](this.canvas, this._jsPlumb.instance.hoverClass); + } + if (this._jsPlumb.hoverClass != null) { + this._jsPlumb.instance[method](this.canvas, this._jsPlumb.hoverClass); + } + } + if (this._jsPlumb.hoverPaintStyle != null) { + this._jsPlumb.paintStyleInUse = hover ? this._jsPlumb.hoverPaintStyle : this._jsPlumb.paintStyle; + if (!this._jsPlumb.instance.isSuspendDrawing()) { + timestamp = timestamp || _timestamp(); + this.repaint({timestamp: timestamp, recalc: false}); + } + } + // get the list of other affected elements, if supported by this component. + // for a connection, its the endpoints. for an endpoint, its the connections! surprise. + if (this.getAttachedElements && !ignoreAttachedElements) + _updateAttachedElements(this, hover, _timestamp(), this); + } + } + }); + +// ------------------------------ END jsPlumbUIComponent -------------------------------------------- + + var _jsPlumbInstanceIndex = 0, + getInstanceIndex = function () { + var i = _jsPlumbInstanceIndex + 1; + _jsPlumbInstanceIndex++; + return i; + }; + + var jsPlumbInstance = window.jsPlumbInstance = function (_defaults) { + + this.Defaults = { + Anchor: "Bottom", + Anchors: [ null, null ], + ConnectionsDetachable: true, + ConnectionOverlays: [ ], + Connector: "Bezier", + Container: null, + DoNotThrowErrors: false, + DragOptions: { }, + DropOptions: { }, + Endpoint: "Dot", + EndpointOverlays: [ ], + Endpoints: [ null, null ], + EndpointStyle: { fillStyle: "#456" }, + EndpointStyles: [ null, null ], + EndpointHoverStyle: null, + EndpointHoverStyles: [ null, null ], + HoverPaintStyle: null, + LabelStyle: { color: "black" }, + LogEnabled: false, + Overlays: [ ], + MaxConnections: 1, + PaintStyle: { lineWidth: 4, strokeStyle: "#456" }, + ReattachConnections: false, + RenderMode: "svg", + Scope: "jsPlumb_DefaultScope" + }; + if (_defaults) jsPlumb.extend(this.Defaults, _defaults); + + this.logEnabled = this.Defaults.LogEnabled; + this._connectionTypes = {}; + this._endpointTypes = {}; + + jsPlumbUtil.EventGenerator.apply(this); + + var _currentInstance = this, + _instanceIndex = getInstanceIndex(), + _bb = _currentInstance.bind, + _initialDefaults = {}, + _zoom = 1, + _info = function (el) { + if (el == null) return null; + else if (el.nodeType == 3 || el.nodeType == 8) { + return { el:el, text:true }; + } + else { + var _el = _currentInstance.getElement(el); + return { el: _el, id: (jsPlumbUtil.isString(el) && _el == null) ? el : _getId(_el) }; + } + }; + + this.getInstanceIndex = function () { + return _instanceIndex; + }; + + this.setZoom = function (z, repaintEverything) { + if (!jsPlumbUtil.oldIE) { + _zoom = z; + _currentInstance.fire("zoom", _zoom); + if (repaintEverything) _currentInstance.repaintEverything(); + } + return !jsPlumbUtil.oldIE; + + }; + this.getZoom = function () { + return _zoom; + }; + + for (var i in this.Defaults) + _initialDefaults[i] = this.Defaults[i]; + + var _container, _containerDelegations = []; + this.unbindContainer = function() { + if (_container != null && _containerDelegations.length > 0) { + for (var i = 0; i < _containerDelegations.length; i++) { + _currentInstance.off(_container, _containerDelegations[i][0], _containerDelegations[i][1]); + } + } + }; + this.setContainer = function (c) { + + this.unbindContainer(); + + // get container as dom element. + c = this.getElement(c); + // move existing connections and endpoints, if any. + this.select().each(function (conn) { + conn.moveParent(c); + }); + this.selectEndpoints().each(function (ep) { + ep.moveParent(c); + }); + + // set container. + _container = c; + _containerDelegations.length = 0; + + var _oneDelegateHandler = function (id, e) { + var t = e.srcElement || e.target, + jp = (t && t.parentNode ? t.parentNode._jsPlumb : null) || (t ? t._jsPlumb : null) || (t && t.parentNode && t.parentNode.parentNode ? t.parentNode.parentNode._jsPlumb : null); + if (jp) { + jp.fire(id, jp, e); + // jsplumb also fires every event coming from components/overlays. That's what the test for `jp.component` is for. + _currentInstance.fire(id, jp.component || jp, e); + } + }; + + var _addOneDelegate = function(eventId, selector, fn) { + _containerDelegations.push([eventId, fn]); + _currentInstance.on(_container, eventId, selector, fn); + }; + + // delegate one event on the container to jsplumb elements. it might be possible to + // abstract this out: each of endpoint, connection and overlay could register themselves with + // jsplumb as "component types" or whatever, and provide a suitable selector. this would be + // done by the renderer (although admittedly from 2.0 onwards we're not supporting vml anymore) + var _oneDelegate = function (id) { + // connections. + //_addOneDelegate(id, "._jsPlumb_connector, ._jsPlumb_connector > *", function (e) { + _addOneDelegate(id, "._jsPlumb_connector > *", function (e) { + _oneDelegateHandler(id, e); + }); + // endpoints. note they can have an enclosing div, or not. + _addOneDelegate(id, "._jsPlumb_endpoint, ._jsPlumb_endpoint > *, ._jsPlumb_endpoint svg *", function (e) { + _oneDelegateHandler(id, e); + }); + // overlays + _addOneDelegate(id, "._jsPlumb_overlay, ._jsPlumb_overlay *", function (e) { + _oneDelegateHandler(id, e); + }); + }; + + for (var i = 0; i < events.length; i++) + _oneDelegate(events[i]); + + }; + this.getContainer = function () { + return _container; + }; + + this.bind = function (event, fn) { + if ("ready" === event && initialized) fn(); + else _bb.apply(_currentInstance, [event, fn]); + }; + + _currentInstance.importDefaults = function (d) { + for (var i in d) { + _currentInstance.Defaults[i] = d[i]; + } + if (d.Container) + _currentInstance.setContainer(d.Container); + + return _currentInstance; + }; + + _currentInstance.restoreDefaults = function () { + _currentInstance.Defaults = jsPlumb.extend({}, _initialDefaults); + return _currentInstance; + }; + + var log = null, + initialized = false, + // TODO remove from window scope + connections = [], + // map of element id -> endpoint lists. an element can have an arbitrary + // number of endpoints on it, and not all of them have to be connected + // to anything. + endpointsByElement = {}, + endpointsByUUID = {}, + managedElements = {}, + offsets = {}, + offsetTimestamps = {}, + draggableStates = {}, + connectionBeingDragged = false, + sizes = [], + _suspendDrawing = false, + _suspendedAt = null, + DEFAULT_SCOPE = this.Defaults.Scope, + renderMode = null, // will be set in init() + _curIdStamp = 1, + _idstamp = function () { + return "" + _curIdStamp++; + }, + + // + // appends an element to some other element, which is calculated as follows: + // + // 1. if Container exists, use that element. + // 2. if the 'parent' parameter exists, use that. + // 3. otherwise just use the root element. + // + // + _appendElement = function (el, parent) { + if (_container) + _container.appendChild(el); + else if (!parent) + this.appendToRoot(el); + else + this.getElement(parent).appendChild(el); + }.bind(this), + + // + // Draws an endpoint and its connections. this is the main entry point into drawing connections as well + // as endpoints, since jsPlumb is endpoint-centric under the hood. + // + // @param element element to draw (of type library specific element object) + // @param ui UI object from current library's event system. optional. + // @param timestamp timestamp for this paint cycle. used to speed things up a little by cutting down the amount of offset calculations we do. + // @param clearEdits defaults to false; indicates that mouse edits for connectors should be cleared + /// + _draw = function (element, ui, timestamp, clearEdits) { + + // TODO is it correct to filter by headless at this top level? how would a headless adapter ever repaint? + // NO. it is not correct. + if (!jsPlumb.headless && !_suspendDrawing) { + var id = _getId(element), + repaintEls = _currentInstance.getDragManager().getElementsForDraggable(id); + + if (timestamp == null) timestamp = _timestamp(); + + // update the offset of everything _before_ we try to draw anything. + var o = _updateOffset({ elId: id, offset: ui, recalc: false, timestamp: timestamp }); + + if (repaintEls) { + for (var i in repaintEls) { + _updateOffset({ + elId: repaintEls[i].id, + offset: { + left: o.o.left + repaintEls[i].offset.left, + top: o.o.top + repaintEls[i].offset.top + }, + recalc: false, + timestamp: timestamp + }); + } + } + + _currentInstance.anchorManager.redraw(id, ui, timestamp, null, clearEdits); + + if (repaintEls) { + for (var j in repaintEls) { + _currentInstance.anchorManager.redraw(repaintEls[j].id, ui, timestamp, repaintEls[j].offset, clearEdits, true); + } + } + } + }, + + // + // gets an Endpoint by uuid. + // + _getEndpoint = function (uuid) { + return endpointsByUUID[uuid]; + }, + + /** + * inits a draggable if it's not already initialised. + * TODO: somehow abstract this to the adapter, because the concept of "draggable" has no + * place on the server. + */ + _initDraggableIfNecessary = function (element, isDraggable, dragOptions, id) { + // move to DragManager? + if (!jsPlumb.headless) { + var _draggable = isDraggable == null ? false : isDraggable; + if (_draggable) { + if (jsPlumb.isDragSupported(element, _currentInstance) && !jsPlumb.isAlreadyDraggable(element, _currentInstance)) { + var options = dragOptions || _currentInstance.Defaults.DragOptions; + options = jsPlumb.extend({}, options); // make a copy. + var dragEvent = jsPlumb.dragEvents.drag, + stopEvent = jsPlumb.dragEvents.stop, + startEvent = jsPlumb.dragEvents.start, + _del = _currentInstance.getElement(element), + _ancestor = _currentInstance.getDragManager().getDragAncestor(_del), + _noOffset = {left: 0, top: 0}, + _ancestorOffset = _noOffset, + _started = false; + + _manage(id, element); + + options[startEvent] = _ju.wrap(options[startEvent], function () { + _ancestorOffset = _ancestor != null ? _currentInstance.getOffset(_ancestor) : _noOffset; + _currentInstance.setHoverSuspended(true); + _currentInstance.select({source: element}).addClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true); + _currentInstance.select({target: element}).addClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true); + _currentInstance.setConnectionBeingDragged(true); + if (options.canDrag) return dragOptions.canDrag(); + }, false); + + options[dragEvent] = _ju.wrap(options[dragEvent], function () { + // TODO: here we could actually use getDragObject, and then compute it ourselves, + // since every adapter does the same thing. but i'm not sure why YUI's getDragObject + // differs from getUIPosition so much + var ui = _currentInstance.getUIPosition(arguments, _currentInstance.getZoom()); + // adjust by ancestor offset if there is one: this is for the case that a draggable + // is contained inside some other element that is not the Container. + ui.left += _ancestorOffset.left; + ui.top += _ancestorOffset.top; + _draw(element, ui, null, true); + if (_started) _currentInstance.addClass(element, "jsPlumb_dragged"); + _started = true; + }); + options[stopEvent] = _ju.wrap(options[stopEvent], function () { + var elements = []; + + // TODO once jquery is no longer supported, remove this, as we will know + // exactly what the method signature is. For now, we need to cater for the + // fact that jquery ui provides two args and katavorio provides only one. + if (arguments.length == 1 && arguments[0].selection && arguments[0].selection.length > 0) { + elements = arguments[0].selection; + } + else { + elements = [ [ element, _currentInstance.getUIPosition(arguments, _currentInstance.getZoom(), true) ] ]; + } + + // this is one element + var _one = function(_e) { + _draw(_e[0], _e[1]); + _currentInstance.removeClass(_e[0], "jsPlumb_dragged"); + _currentInstance.select({source: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true); + _currentInstance.select({target: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true); + _currentInstance.getDragManager().dragEnded(_e[0]); + }; + + for (var i = 0; i < elements.length; i++) + _one(elements[i]); + + // this is common across all + _started = false; + _currentInstance.setHoverSuspended(false); + _currentInstance.setConnectionBeingDragged(false); + }); + var elId = _getId(element); // need ID + draggableStates[elId] = true; + var draggable = draggableStates[elId]; + options.disabled = draggable == null ? false : !draggable; + _currentInstance.initDraggable(element, options); + _currentInstance.getDragManager().register(element); + } + } + } + }, + + _scopeMatch = function (e1, e2) { + var s1 = e1.scope.split(/\s/), s2 = e2.scope.split(/\s/); + for (var i = 0; i < s1.length; i++) + for (var j = 0; j < s2.length; j++) + if (s2[j] == s1[i]) return true; + + return false; + }, + + /* + * prepares a final params object that can be passed to _newConnection, taking into account defaults, events, etc. + */ + _prepareConnectionParams = function (params, referenceParams) { + var _p = jsPlumb.extend({ }, params); + if (referenceParams) jsPlumb.extend(_p, referenceParams); + + // hotwire endpoints passed as source or target to sourceEndpoint/targetEndpoint, respectively. + if (_p.source) { + if (_p.source.endpoint) + _p.sourceEndpoint = _p.source; + else + _p.source = _currentInstance.getElement(_p.source); + } + if (_p.target) { + if (_p.target.endpoint) + _p.targetEndpoint = _p.target; + else + _p.target = _currentInstance.getElement(_p.target); + } + + // test for endpoint uuids to connect + if (params.uuids) { + _p.sourceEndpoint = _getEndpoint(params.uuids[0]); + _p.targetEndpoint = _getEndpoint(params.uuids[1]); + } + + // now ensure that if we do have Endpoints already, they're not full. + // source: + if (_p.sourceEndpoint && _p.sourceEndpoint.isFull()) { + _ju.log(_currentInstance, "could not add connection; source endpoint is full"); + return; + } + + // target: + if (_p.targetEndpoint && _p.targetEndpoint.isFull()) { + _ju.log(_currentInstance, "could not add connection; target endpoint is full"); + return; + } + + // if source endpoint mandates connection type and nothing specified in our params, use it. + if (!_p.type && _p.sourceEndpoint) + _p.type = _p.sourceEndpoint.connectionType; + + // copy in any connectorOverlays that were specified on the source endpoint. + // it doesnt copy target endpoint overlays. i'm not sure if we want it to or not. + if (_p.sourceEndpoint && _p.sourceEndpoint.connectorOverlays) { + _p.overlays = _p.overlays || []; + for (var i = 0, j = _p.sourceEndpoint.connectorOverlays.length; i < j; i++) { + _p.overlays.push(_p.sourceEndpoint.connectorOverlays[i]); + } + } + + // pointer events + if (!_p["pointer-events"] && _p.sourceEndpoint && _p.sourceEndpoint.connectorPointerEvents) + _p["pointer-events"] = _p.sourceEndpoint.connectorPointerEvents; + + var _mergeOverrides = function (def, values) { + var m = jsPlumb.extend({}, def); + for (var i in values) { + if (values[i]) m[i] = values[i]; + } + return m; + }; + + var _addEndpoint = function (el, def, idx) { + return _currentInstance.addEndpoint(el, _mergeOverrides(def, { + anchor: _p.anchors ? _p.anchors[idx] : _p.anchor, + endpoint: _p.endpoints ? _p.endpoints[idx] : _p.endpoint, + paintStyle: _p.endpointStyles ? _p.endpointStyles[idx] : _p.endpointStyle, + hoverPaintStyle: _p.endpointHoverStyles ? _p.endpointHoverStyles[idx] : _p.endpointHoverStyle + })); + }; + + // check for makeSource/makeTarget specs. + + var _oneElementDef = function (type, idx, defs) { + if (_p[type] && !_p[type].endpoint && !_p[type + "Endpoint"] && !_p.newConnection) { + var tid = _getId(_p[type]), tep = defs[tid]; + + if (tep) { + // if not enabled, return. + if (!tep.enabled) return false; + var newEndpoint = tep.endpoint != null && tep.endpoint._jsPlumb ? tep.endpoint : _addEndpoint(_p[type], tep.def, idx); + if (newEndpoint.isFull()) return false; + _p[type + "Endpoint"] = newEndpoint; + newEndpoint._doNotDeleteOnDetach = false; // reset. + newEndpoint._deleteOnDetach = true; + if (tep.uniqueEndpoint) { + if (!tep.endpoint) { + tep.endpoint = newEndpoint; + newEndpoint._deleteOnDetach = false; + newEndpoint._doNotDeleteOnDetach = true; + } + else + newEndpoint.finalEndpoint = tep.endpoint; + } + } + } + }; + + if (_oneElementDef("source", 0, this.sourceEndpointDefinitions) === false) return; + if (_oneElementDef("target", 1, this.targetEndpointDefinitions) === false) return; + + // last, ensure scopes match + if (_p.sourceEndpoint && _p.targetEndpoint) + if (!_scopeMatch(_p.sourceEndpoint, _p.targetEndpoint)) _p = null; + + return _p; + }.bind(_currentInstance), + + _newConnection = function (params) { + var connectionFunc = _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(); + + params._jsPlumb = _currentInstance; + params.newConnection = _newConnection; + params.newEndpoint = _newEndpoint; + params.endpointsByUUID = endpointsByUUID; + params.endpointsByElement = endpointsByElement; + params.finaliseConnection = _finaliseConnection; + params.id = "con_" + _idstamp(); + var con = new connectionFunc(params); + + // if the connection is draggable, then maybe we need to tell the target endpoint to init the + // dragging code. it won't run again if it already configured to be draggable. + if (con.isDetachable()) { + con.endpoints[0].initDraggable(); + con.endpoints[1].initDraggable(); + } + + return con; + }, + + // + // adds the connection to the backing model, fires an event if necessary and then redraws + // + _finaliseConnection = _currentInstance.finaliseConnection = function (jpc, params, originalEvent, doInformAnchorManager) { + params = params || {}; + // add to list of connections (by scope). + if (!jpc.suspendedEndpoint) + connections.push(jpc); + + // turn off isTemporarySource on the source endpoint (only viable on first draw) + jpc.endpoints[0].isTemporarySource = false; + + // always inform the anchor manager + // except that if jpc has a suspended endpoint it's not true to say the + // connection is new; it has just (possibly) moved. the question is whether + // to make that call here or in the anchor manager. i think perhaps here. + if (jpc.suspendedEndpoint == null || doInformAnchorManager) + _currentInstance.anchorManager.newConnection(jpc); + + // force a paint + _draw(jpc.source); + + // fire an event + if (!params.doNotFireConnectionEvent && params.fireEvent !== false) { + + var eventArgs = { + connection: jpc, + source: jpc.source, target: jpc.target, + sourceId: jpc.sourceId, targetId: jpc.targetId, + sourceEndpoint: jpc.endpoints[0], targetEndpoint: jpc.endpoints[1] + }; + + _currentInstance.fire("connection", eventArgs, originalEvent); + } + }, + + /* + factory method to prepare a new endpoint. this should always be used instead of creating Endpoints + manually, since this method attaches event listeners and an id. + */ + _newEndpoint = function (params, id) { + var endpointFunc = _currentInstance.Defaults.EndpointType || jsPlumb.Endpoint; + var _p = jsPlumb.extend({}, params); + _p._jsPlumb = _currentInstance; + _p.newConnection = _newConnection; + _p.newEndpoint = _newEndpoint; + _p.endpointsByUUID = endpointsByUUID; + _p.endpointsByElement = endpointsByElement; + _p.fireDetachEvent = fireDetachEvent; + _p.elementId = id || _getId(_p.source); + var ep = new endpointFunc(_p); + ep.id = "ep_" + _idstamp(); + _manage(_p.elementId, _p.source); + + if (!jsPlumb.headless) + _currentInstance.getDragManager().endpointAdded(_p.source, id); + + return ep; + }, + + /* + * performs the given function operation on all the connections found + * for the given element id; this means we find all the endpoints for + * the given element, and then for each endpoint find the connectors + * connected to it. then we pass each connection in to the given + * function. + */ + _operation = function (elId, func, endpointFunc) { + var endpoints = endpointsByElement[elId]; + if (endpoints && endpoints.length) { + for (var i = 0, ii = endpoints.length; i < ii; i++) { + for (var j = 0, jj = endpoints[i].connections.length; j < jj; j++) { + var retVal = func(endpoints[i].connections[j]); + // if the function passed in returns true, we exit. + // most functions return false. + if (retVal) return; + } + if (endpointFunc) endpointFunc(endpoints[i]); + } + } + }, + + _setDraggable = function (element, draggable) { + return jsPlumb.each(element, function (el) { + if (_currentInstance.isDragSupported(el)) { + draggableStates[_currentInstance.getAttribute(el, "id")] = draggable; + _currentInstance.setElementDraggable(el, draggable); + } + }); + }, + /* + * private method to do the business of hiding/showing. + * + * @param el + * either Id of the element in question or a library specific + * object for the element. + * @param state + * String specifying a value for the css 'display' property + * ('block' or 'none'). + */ + _setVisible = function (el, state, alsoChangeEndpoints) { + state = state === "block"; + var endpointFunc = null; + if (alsoChangeEndpoints) { + if (state) endpointFunc = function (ep) { + ep.setVisible(true, true, true); + }; + else endpointFunc = function (ep) { + ep.setVisible(false, true, true); + }; + } + var info = _info(el); + _operation(info.id, function (jpc) { + if (state && alsoChangeEndpoints) { + // this test is necessary because this functionality is new, and i wanted to maintain backwards compatibility. + // this block will only set a connection to be visible if the other endpoint in the connection is also visible. + var oidx = jpc.sourceId === info.id ? 1 : 0; + if (jpc.endpoints[oidx].isVisible()) jpc.setVisible(true); + } + else // the default behaviour for show, and what always happens for hide, is to just set the visibility without getting clever. + jpc.setVisible(state); + }, endpointFunc); + }, + /* + * toggles the draggable state of the given element(s). + * el is either an id, or an element object, or a list of ids/element objects. + */ + _toggleDraggable = function (el) { + return jsPlumb.each(el, function (el) { + var elId = _currentInstance.getAttribute(el, "id"); + var state = draggableStates[elId] == null ? false : draggableStates[elId]; + state = !state; + draggableStates[elId] = state; + _currentInstance.setDraggable(el, state); + return state; + }.bind(this)); + }, + /** + * private method to do the business of toggling hiding/showing. + */ + _toggleVisible = function (elId, changeEndpoints) { + var endpointFunc = null; + if (changeEndpoints) { + endpointFunc = function (ep) { + var state = ep.isVisible(); + ep.setVisible(!state); + }; + } + _operation(elId, function (jpc) { + var state = jpc.isVisible(); + jpc.setVisible(!state); + }, endpointFunc); + }, + + // TODO comparison performance + _getCachedData = function (elId) { + var o = offsets[elId]; + if (!o) + return _updateOffset({elId: elId}); + else + return {o: o, s: sizes[elId]}; + }, + + /** + * gets an id for the given element, creating and setting one if + * necessary. the id is of the form + * + * jsPlumb__ + * + * where "index in instance" is a monotonically increasing integer that starts at 0, + * for each instance. this method is used not only to assign ids to elements that do not + * have them but also to connections and endpoints. + */ + _getId = function (element, uuid, doNotCreateIfNotFound) { + if (jsPlumbUtil.isString(element)) return element; + if (element == null) return null; + var id = _currentInstance.getAttribute(element, "id"); + if (!id || id === "undefined") { + // check if fixed uuid parameter is given + if (arguments.length == 2 && arguments[1] !== undefined) + id = uuid; + else if (arguments.length == 1 || (arguments.length == 3 && !arguments[2])) + id = "jsPlumb_" + _instanceIndex + "_" + _idstamp(); + + if (!doNotCreateIfNotFound) _currentInstance.setAttribute(element, "id", id); + } + return id; + }; + + this.setConnectionBeingDragged = function (v) { + connectionBeingDragged = v; + }; + this.isConnectionBeingDragged = function () { + return connectionBeingDragged; + }; + + this.connectorClass = "_jsPlumb_connector"; + this.connectorOutlineClass = "_jsPlumb_connector_outline"; + this.connectedClass = "_jsPlumb_connected"; + this.hoverClass = "_jsPlumb_hover"; + this.endpointClass = "_jsPlumb_endpoint"; + this.endpointConnectedClass = "_jsPlumb_endpoint_connected"; + this.endpointFullClass = "_jsPlumb_endpoint_full"; + this.endpointDropAllowedClass = "_jsPlumb_endpoint_drop_allowed"; + this.endpointDropForbiddenClass = "_jsPlumb_endpoint_drop_forbidden"; + this.overlayClass = "_jsPlumb_overlay"; + this.draggingClass = "_jsPlumb_dragging"; + this.elementDraggingClass = "_jsPlumb_element_dragging"; + this.sourceElementDraggingClass = "_jsPlumb_source_element_dragging"; + this.targetElementDraggingClass = "_jsPlumb_target_element_dragging"; + this.endpointAnchorClassPrefix = "_jsPlumb_endpoint_anchor"; + this.hoverSourceClass = "_jsPlumb_source_hover"; + this.hoverTargetClass = "_jsPlumb_target_hover"; + this.dragSelectClass = "_jsPlumb_drag_select"; + + this.Anchors = {}; + this.Connectors = { "svg": {}, "vml": {} }; + this.Endpoints = { "svg": {}, "vml": {} }; + this.Overlays = { "svg": {}, "vml": {} } ; + this.ConnectorRenderers = {}; + this.SVG = "svg"; + this.VML = "vml"; + +// --------------------------- jsPlumbInstance public API --------------------------------------------------------- + + + this.addEndpoint = function (el, params, referenceParams) { + referenceParams = referenceParams || {}; + var p = jsPlumb.extend({}, referenceParams); + jsPlumb.extend(p, params); + p.endpoint = p.endpoint || _currentInstance.Defaults.Endpoint; + p.paintStyle = p.paintStyle || _currentInstance.Defaults.EndpointStyle; + + var results = [], + inputs = (_ju.isArray(el) || (el.length != null && !_ju.isString(el))) ? el : [ el ]; + + for (var i = 0, j = inputs.length; i < j; i++) { + p.source = _currentInstance.getElement(inputs[i]); + _ensureContainer(p.source); + + var id = _getId(p.source), e = _newEndpoint(p, id); + + // SP new. here we have introduced a class-wide element manager, which is responsible + // for getting object dimensions and width/height, and for updating these values only + // when necessary (after a drag, or on a forced refresh call). + var myOffset = _manage(id, p.source).info.o; + _ju.addToList(endpointsByElement, id, e); + + if (!_suspendDrawing) { + e.paint({ + anchorLoc: e.anchor.compute({ xy: [ myOffset.left, myOffset.top ], wh: sizes[id], element: e, timestamp: _suspendedAt }), + timestamp: _suspendedAt + }); + } + + results.push(e); + e._doNotDeleteOnDetach = true; // mark this as being added via addEndpoint. + } + + return results.length == 1 ? results[0] : results; + }; + + this.addEndpoints = function (el, endpoints, referenceParams) { + var results = []; + for (var i = 0, j = endpoints.length; i < j; i++) { + var e = _currentInstance.addEndpoint(el, endpoints[i], referenceParams); + if (_ju.isArray(e)) + Array.prototype.push.apply(results, e); + else results.push(e); + } + return results; + }; + + this.animate = function (el, properties, options) { + if (!this.animationSupported) return false; + + options = options || {}; + var del = _currentInstance.getElement(el), + id = _getId(del), + stepFunction = jsPlumb.animEvents.step, + completeFunction = jsPlumb.animEvents.complete; + + options[stepFunction] = _ju.wrap(options[stepFunction], function () { + _currentInstance.revalidate(id); + }); + + // onComplete repaints, just to make sure everything looks good at the end of the animation. + options[completeFunction] = _ju.wrap(options[completeFunction], function () { + _currentInstance.revalidate(id); + }); + + _currentInstance.doAnimate(del, properties, options); + }; + + /** + * checks for a listener for the given condition, executing it if found, passing in the given value. + * condition listeners would have been attached using "bind" (which is, you could argue, now overloaded, since + * firing click events etc is a bit different to what this does). i thought about adding a "bindCondition" + * or something, but decided against it, for the sake of simplicity. jsPlumb will never fire one of these + * condition events anyway. + */ + this.checkCondition = function (conditionName, args) { + var l = _currentInstance.getListener(conditionName), + r = true; + + if (l && l.length > 0) { + var values = Array.prototype.slice.call(arguments, 1); + try { + for (var i = 0, j = l.length; i < j; i++) { + r = r && l[i].apply(l[i], values); + } + } + catch (e) { + _ju.log(_currentInstance, "cannot check condition [" + conditionName + "]" + e); + } + } + return r; + }; + + this.connect = function (params, referenceParams) { + // prepare a final set of parameters to create connection with + var _p = _prepareConnectionParams(params, referenceParams), jpc; + // TODO probably a nicer return value if the connection was not made. _prepareConnectionParams + // will return null (and log something) if either endpoint was full. what would be nicer is to + // create a dedicated 'error' object. + if (_p) { + if (_p.source == null && _p.sourceEndpoint == null) { + jsPlumbUtil.log("Cannot establish connection - source does not exist"); + return; + } + if (_p.target == null && _p.targetEndpoint == null) { + jsPlumbUtil.log("Cannot establish connection - target does not exist"); + return; + } + _ensureContainer(_p.source); + // create the connection. it is not yet registered + jpc = _newConnection(_p); + // now add it the model, fire an event, and redraw + _finaliseConnection(jpc, _p); + } + return jpc; + }; + + var stTypes = [ + { el: "source", elId: "sourceId", epDefs: "sourceEndpointDefinitions" }, + { el: "target", elId: "targetId", epDefs: "targetEndpointDefinitions" } + ]; + + var _set = function (c, el, idx, doNotRepaint) { + var ep, _st = stTypes[idx], cId = c[_st.elId], cEl = c[_st.el], sid, sep, + oldEndpoint = c.endpoints[idx]; + + var evtParams = { + index: idx, + originalSourceId: idx === 0 ? cId : c.sourceId, + newSourceId: c.sourceId, + originalTargetId: idx == 1 ? cId : c.targetId, + newTargetId: c.targetId, + connection: c + }; + + if (el.constructor == jsPlumb.Endpoint) { // TODO here match the current endpoint class; users can change it { + ep = el; + ep.addConnection(c); + } + else { + sid = _getId(el); + sep = this[_st.epDefs][sid]; + + if (sid === c[_st.elId]) + ep = null; // dont change source/target if the element is already the one given. + else if (sep) { + if (!sep.enabled) return; + ep = sep.endpoint != null && sep.endpoint._jsPlumb ? sep.endpoint : this.addEndpoint(el, sep.def); + if (sep.uniqueEndpoint) sep.endpoint = ep; + ep._doNotDeleteOnDetach = false; + ep._deleteOnDetach = true; + ep.addConnection(c); + } + else { + ep = c.makeEndpoint(idx === 0, el, sid); + ep._doNotDeleteOnDetach = false; + ep._deleteOnDetach = true; + } + } + + if (ep != null) { + oldEndpoint.detachFromConnection(c); + c.endpoints[idx] = ep; + c[_st.el] = ep.element; + c[_st.elId] = ep.elementId; + evtParams[idx === 0 ? "newSourceId" : "newTargetId"] = ep.elementId; + + fireMoveEvent(evtParams); + + if (!doNotRepaint) + c.repaint(); + } + + return evtParams; + + }.bind(this); + + this.setSource = function (connection, el, doNotRepaint) { + var p = _set(connection, el, 0, doNotRepaint); + this.anchorManager.sourceChanged(p.originalSourceId, p.newSourceId, connection); + }; + this.setTarget = function (connection, el, doNotRepaint) { + var p = _set(connection, el, 1, doNotRepaint); + this.anchorManager.updateOtherEndpoint(p.originalSourceId, p.originalTargetId, p.newTargetId, connection); + }; + + this.deleteEndpoint = function (object, dontUpdateHover) { + var endpoint = (typeof object === "string") ? endpointsByUUID[object] : object; + if (endpoint) { + _currentInstance.deleteObject({ endpoint: endpoint, dontUpdateHover: dontUpdateHover }); + } + return _currentInstance; + }; + + this.deleteEveryEndpoint = function () { + var _is = _currentInstance.setSuspendDrawing(true); + for (var id in endpointsByElement) { + var endpoints = endpointsByElement[id]; + if (endpoints && endpoints.length) { + for (var i = 0, j = endpoints.length; i < j; i++) { + _currentInstance.deleteEndpoint(endpoints[i], true); + } + } + } + endpointsByElement = {}; + // SP new + managedElements = {}; + endpointsByUUID = {}; + _currentInstance.anchorManager.reset(); + _currentInstance.getDragManager().reset(); + if (!_is) _currentInstance.setSuspendDrawing(false); + return _currentInstance; + }; + + var fireDetachEvent = function (jpc, doFireEvent, originalEvent) { + // may have been given a connection, or in special cases, an object + var connType = _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(), + argIsConnection = jpc.constructor == connType, + params = argIsConnection ? { + connection: jpc, + source: jpc.source, target: jpc.target, + sourceId: jpc.sourceId, targetId: jpc.targetId, + sourceEndpoint: jpc.endpoints[0], targetEndpoint: jpc.endpoints[1] + } : jpc; + + if (doFireEvent) + _currentInstance.fire("connectionDetached", params, originalEvent); + + _currentInstance.anchorManager.connectionDetached(params); + }; + + var fireMoveEvent = _currentInstance.fireMoveEvent = function (params, evt) { + _currentInstance.fire("connectionMoved", params, evt); + }; + + this.unregisterEndpoint = function (endpoint) { + //if (endpoint._jsPlumb == null) return; + if (endpoint._jsPlumb.uuid) endpointsByUUID[endpoint._jsPlumb.uuid] = null; + _currentInstance.anchorManager.deleteEndpoint(endpoint); + // TODO at least replace this with a removeWithFunction call. + for (var e in endpointsByElement) { + var endpoints = endpointsByElement[e]; + if (endpoints) { + var newEndpoints = []; + for (var i = 0, j = endpoints.length; i < j; i++) + if (endpoints[i] != endpoint) newEndpoints.push(endpoints[i]); + + endpointsByElement[e] = newEndpoints; + } + if (endpointsByElement[e].length < 1) { + delete endpointsByElement[e]; + } + } + }; + + this.detach = function () { + + if (arguments.length === 0) return; + var connType = _currentInstance.Defaults.ConnectionType || _currentInstance.getDefaultConnectionType(), + firstArgIsConnection = arguments[0].constructor == connType, + params = arguments.length == 2 ? firstArgIsConnection ? (arguments[1] || {}) : arguments[0] : arguments[0], + fireEvent = (params.fireEvent !== false), + forceDetach = params.forceDetach, + conn = firstArgIsConnection ? arguments[0] : params.connection; + + if (conn) { + if (forceDetach || jsPlumbUtil.functionChain(true, false, [ + [ conn.endpoints[0], "isDetachAllowed", [ conn ] ], + [ conn.endpoints[1], "isDetachAllowed", [ conn ] ], + [ conn, "isDetachAllowed", [ conn ] ], + [ _currentInstance, "checkCondition", [ "beforeDetach", conn ] ] + ])) { + + conn.endpoints[0].detach(conn, false, true, fireEvent); + } + } + else { + var _p = jsPlumb.extend({}, params); // a backwards compatibility hack: source should be thought of as 'params' in this case. + // test for endpoint uuids to detach + if (_p.uuids) { + _getEndpoint(_p.uuids[0]).detachFrom(_getEndpoint(_p.uuids[1]), fireEvent); + } else if (_p.sourceEndpoint && _p.targetEndpoint) { + _p.sourceEndpoint.detachFrom(_p.targetEndpoint); + } else { + var sourceId = _getId(_currentInstance.getElement(_p.source)), + targetId = _getId(_currentInstance.getElement(_p.target)); + _operation(sourceId, function (jpc) { + if ((jpc.sourceId == sourceId && jpc.targetId == targetId) || (jpc.targetId == sourceId && jpc.sourceId == targetId)) { + if (_currentInstance.checkCondition("beforeDetach", jpc)) { + jpc.endpoints[0].detach(jpc, false, true, fireEvent); + } + } + }); + } + } + }; + + this.detachAllConnections = function (el, params) { + params = params || {}; + el = _currentInstance.getElement(el); + var id = _getId(el), + endpoints = endpointsByElement[id]; + if (endpoints && endpoints.length) { + for (var i = 0, j = endpoints.length; i < j; i++) { + endpoints[i].detachAll(params.fireEvent !== false, params.forceDetach); + } + } + return _currentInstance; + }; + + this.detachEveryConnection = function (params) { + params = params || {}; + _currentInstance.batch(function () { + for (var id in endpointsByElement) { + var endpoints = endpointsByElement[id]; + if (endpoints && endpoints.length) { + for (var i = 0, j = endpoints.length; i < j; i++) { + endpoints[i].detachAll(params.fireEvent !== false, params.forceDetach); + } + } + } + connections.length = 0; + }); + return _currentInstance; + }; + + /// not public. but of course its exposed. how to change this. + this.deleteObject = function (params) { + var result = { + endpoints: {}, + connections: {}, + endpointCount: 0, + connectionCount: 0 + }, + fireEvent = params.fireEvent !== false, + deleteAttachedObjects = params.deleteAttachedObjects !== false; + + var unravelConnection = function (connection) { + if (connection != null && result.connections[connection.id] == null) { + if (!params.dontUpdateHover && connection._jsPlumb != null) connection.setHover(false); + result.connections[connection.id] = connection; + result.connectionCount++; + if (deleteAttachedObjects) { + for (var j = 0; j < connection.endpoints.length; j++) { + if (connection.endpoints[j]._deleteOnDetach) + unravelEndpoint(connection.endpoints[j]); + } + } + } + }; + var unravelEndpoint = function (endpoint) { + if (endpoint != null && result.endpoints[endpoint.id] == null) { + if (!params.dontUpdateHover && endpoint._jsPlumb != null) endpoint.setHover(false); + result.endpoints[endpoint.id] = endpoint; + result.endpointCount++; + + if (deleteAttachedObjects) { + for (var i = 0; i < endpoint.connections.length; i++) { + var c = endpoint.connections[i]; + unravelConnection(c); + } + } + } + }; + + if (params.connection) + unravelConnection(params.connection); + else unravelEndpoint(params.endpoint); + + // loop through connections + for (var i in result.connections) { + var c = result.connections[i]; + if (c._jsPlumb) { + jsPlumbUtil.removeWithFunction(connections, function (_c) { + return c.id == _c.id; + }); + fireDetachEvent(c, fireEvent, params.originalEvent); + + c.endpoints[0].detachFromConnection(c); + c.endpoints[1].detachFromConnection(c); + c.cleanup(true); + c.destroy(true); + } + } + + // loop through endpoints + for (var j in result.endpoints) { + var e = result.endpoints[j]; + if (e._jsPlumb) { + _currentInstance.unregisterEndpoint(e); + // FIRE some endpoint deleted event? + e.cleanup(true); + e.destroy(true); + } + } + + return result; + }; + + this.draggable = function (el, options) { + var i, j, info; + // allows for array or jquery selector + if (typeof el == 'object' && el.length) { + for (i = 0, j = el.length; i < j; i++) { + info = _info(el[i]); + if (info.el) _initDraggableIfNecessary(info.el, true, options, info.id); + } + } + else { + //ele = _currentInstance.getElement(el); + info = _info(el); + if (info.el) _initDraggableIfNecessary(info.el, true, options, info.id); + } + return _currentInstance; + }; + + // helpers for select/selectEndpoints + var _setOperation = function (list, func, args, selector) { + for (var i = 0, j = list.length; i < j; i++) { + list[i][func].apply(list[i], args); + } + return selector(list); + }, + _getOperation = function (list, func, args) { + var out = []; + for (var i = 0, j = list.length; i < j; i++) { + out.push([ list[i][func].apply(list[i], args), list[i] ]); + } + return out; + }, + setter = function (list, func, selector) { + return function () { + return _setOperation(list, func, arguments, selector); + }; + }, + getter = function (list, func) { + return function () { + return _getOperation(list, func, arguments); + }; + }, + prepareList = function (input, doNotGetIds) { + var r = []; + if (input) { + if (typeof input == 'string') { + if (input === "*") return input; + r.push(input); + } + else { + if (doNotGetIds) r = input; + else { + if (input.length) { + for (var i = 0, j = input.length; i < j; i++) + r.push(_info(input[i]).id); + } + else + r.push(_info(input).id); + } + } + } + return r; + }, + filterList = function (list, value, missingIsFalse) { + if (list === "*") return true; + return list.length > 0 ? jsPlumbUtil.indexOf(list, value) != -1 : !missingIsFalse; + }; + + // get some connections, specifying source/target/scope + this.getConnections = function (options, flat) { + if (!options) { + options = {}; + } else if (options.constructor == String) { + options = { "scope": options }; + } + var scope = options.scope || _currentInstance.getDefaultScope(), + scopes = prepareList(scope, true), + sources = prepareList(options.source), + targets = prepareList(options.target), + results = (!flat && scopes.length > 1) ? {} : [], + _addOne = function (scope, obj) { + if (!flat && scopes.length > 1) { + var ss = results[scope]; + if (ss == null) { + ss = results[scope] = []; + } + ss.push(obj); + } else results.push(obj); + }; + + for (var j = 0, jj = connections.length; j < jj; j++) { + var c = connections[j]; + if (filterList(scopes, c.scope) && filterList(sources, c.sourceId) && filterList(targets, c.targetId)) + _addOne(c.scope, c); + } + + return results; + }; + + var _curryEach = function (list, executor) { + return function (f) { + for (var i = 0, ii = list.length; i < ii; i++) { + f(list[i]); + } + return executor(list); + }; + }, + _curryGet = function (list) { + return function (idx) { + return list[idx]; + }; + }; + + var _makeCommonSelectHandler = function (list, executor) { + var out = { + length: list.length, + each: _curryEach(list, executor), + get: _curryGet(list) + }, + setters = ["setHover", "removeAllOverlays", "setLabel", "addClass", "addOverlay", "removeOverlay", + "removeOverlays", "showOverlay", "hideOverlay", "showOverlays", "hideOverlays", "setPaintStyle", + "setHoverPaintStyle", "setSuspendEvents", "setParameter", "setParameters", "setVisible", + "repaint", "addType", "toggleType", "removeType", "removeClass", "setType", "bind", "unbind" ], + + getters = ["getLabel", "getOverlay", "isHover", "getParameter", "getParameters", "getPaintStyle", + "getHoverPaintStyle", "isVisible", "hasType", "getType", "isSuspendEvents" ], + i, ii; + + for (i = 0, ii = setters.length; i < ii; i++) + out[setters[i]] = setter(list, setters[i], executor); + + for (i = 0, ii = getters.length; i < ii; i++) + out[getters[i]] = getter(list, getters[i]); + + return out; + }; + + var _makeConnectionSelectHandler = function (list) { + var common = _makeCommonSelectHandler(list, _makeConnectionSelectHandler); + return jsPlumb.extend(common, { + // setters + setDetachable: setter(list, "setDetachable", _makeConnectionSelectHandler), + setReattach: setter(list, "setReattach", _makeConnectionSelectHandler), + setConnector: setter(list, "setConnector", _makeConnectionSelectHandler), + detach: function () { + for (var i = 0, ii = list.length; i < ii; i++) + _currentInstance.detach(list[i]); + }, + // getters + isDetachable: getter(list, "isDetachable"), + isReattach: getter(list, "isReattach") + }); + }; + + var _makeEndpointSelectHandler = function (list) { + var common = _makeCommonSelectHandler(list, _makeEndpointSelectHandler); + return jsPlumb.extend(common, { + setEnabled: setter(list, "setEnabled", _makeEndpointSelectHandler), + setAnchor: setter(list, "setAnchor", _makeEndpointSelectHandler), + isEnabled: getter(list, "isEnabled"), + detachAll: function () { + for (var i = 0, ii = list.length; i < ii; i++) + list[i].detachAll(); + }, + "remove": function () { + for (var i = 0, ii = list.length; i < ii; i++) + _currentInstance.deleteObject({endpoint: list[i]}); + } + }); + }; + + this.select = function (params) { + params = params || {}; + params.scope = params.scope || "*"; + return _makeConnectionSelectHandler(params.connections || _currentInstance.getConnections(params, true)); + }; + + this.selectEndpoints = function (params) { + params = params || {}; + params.scope = params.scope || "*"; + var noElementFilters = !params.element && !params.source && !params.target, + elements = noElementFilters ? "*" : prepareList(params.element), + sources = noElementFilters ? "*" : prepareList(params.source), + targets = noElementFilters ? "*" : prepareList(params.target), + scopes = prepareList(params.scope, true); + + var ep = []; + + for (var el in endpointsByElement) { + var either = filterList(elements, el, true), + source = filterList(sources, el, true), + sourceMatchExact = sources != "*", + target = filterList(targets, el, true), + targetMatchExact = targets != "*"; + + // if they requested 'either' then just match scope. otherwise if they requested 'source' (not as a wildcard) then we have to match only endpoints that have isSource set to to true, and the same thing with isTarget. + if (either || source || target) { + inner: + for (var i = 0, ii = endpointsByElement[el].length; i < ii; i++) { + var _ep = endpointsByElement[el][i]; + if (filterList(scopes, _ep.scope, true)) { + + var noMatchSource = (sourceMatchExact && sources.length > 0 && !_ep.isSource), + noMatchTarget = (targetMatchExact && targets.length > 0 && !_ep.isTarget); + + if (noMatchSource || noMatchTarget) + continue inner; + + ep.push(_ep); + } + } + } + } + + return _makeEndpointSelectHandler(ep); + }; + + // get all connections managed by the instance of jsplumb. + this.getAllConnections = function () { + return connections; + }; + this.getDefaultScope = function () { + return DEFAULT_SCOPE; + }; + // get an endpoint by uuid. + this.getEndpoint = _getEndpoint; + // get endpoints for some element. + this.getEndpoints = function (el) { + return endpointsByElement[_info(el).id]; + }; + // gets the default endpoint type. used when subclassing. see wiki. + this.getDefaultEndpointType = function () { + return jsPlumb.Endpoint; + }; + // gets the default connection type. used when subclassing. see wiki. + this.getDefaultConnectionType = function () { + return jsPlumb.Connection; + }; + /* + * Gets an element's id, creating one if necessary. really only exposed + * for the lib-specific functionality to access; would be better to pass + * the current instance into the lib-specific code (even though this is + * a static call. i just don't want to expose it to the public API). + */ + this.getId = _getId; + + /*this.getOffset = function (id) { + return _updateOffset({elId: id}).o; + };*/ + + this.appendElement = _appendElement; + + var _hoverSuspended = false; + this.isHoverSuspended = function () { + return _hoverSuspended; + }; + this.setHoverSuspended = function (s) { + _hoverSuspended = s; + }; + + // set an element's connections to be hidden + this.hide = function (el, changeEndpoints) { + _setVisible(el, "none", changeEndpoints); + return _currentInstance; + }; + + // exposed for other objects to use to get a unique id. + this.idstamp = _idstamp; + + this.connectorsInitialized = false; + this.registerConnectorType = function (connector, name) { + connectorTypes.push([connector, name]); + }; + + // ensure that, if the current container exists, it is a DOM element and not a selector. + // if it does not exist and `candidate` is supplied, the offset parent of that element will be set as the Container. + // this is used to do a better default behaviour for the case that the user has not set a container: + // addEndpoint, makeSource, makeTarget and connect all call this method with the offsetParent of the + // element in question (for connect it is the source element). So if no container is set, it is inferred + // to be the offsetParent of the first element the user tries to connect. + var _ensureContainer = function (candidate) { + if (!_container && candidate) { + var can = _currentInstance.getElement(candidate); + if (can.offsetParent) _currentInstance.setContainer(can.offsetParent); + } + }; + + var _getContainerFromDefaults = function () { + if (_currentInstance.Defaults.Container) + _currentInstance.setContainer(_currentInstance.Defaults.Container); + }; + + // check if a given element is managed or not. if not, add to our map. if drawing is not suspended then + // we'll also stash its dimensions; otherwise we'll do this in a lazy way through updateOffset. + // TODO make sure we add a test that this tracks a setId call. + var _manage = _currentInstance.manage = function (id, element) { + if (!managedElements[id]) { + managedElements[id] = { + el: element, + endpoints: [], + connections: [] + }; + + managedElements[id].info = _updateOffset({ elId: id, timestamp: _suspendedAt }); + } + + return managedElements[id]; + }; + + /** + * updates the offset and size for a given element, and stores the + * values. if 'offset' is not null we use that (it would have been + * passed in from a drag call) because it's faster; but if it is null, + * or if 'recalc' is true in order to force a recalculation, we get the current values. + */ + var _updateOffset = this.updateOffset = function (params) { + + var timestamp = params.timestamp, recalc = params.recalc, offset = params.offset, elId = params.elId, s; + if (_suspendDrawing && !timestamp) timestamp = _suspendedAt; + if (!recalc) { + if (timestamp && timestamp === offsetTimestamps[elId]) { + return {o: params.offset || offsets[elId], s: sizes[elId]}; + } + } + if (recalc || (!offset && offsets[elId] == null)) { // if forced repaint or no offset available, we recalculate. + + // get the current size and offset, and store them + s = managedElements[elId] ? managedElements[elId].el : null; + if (s != null) { + sizes[elId] = _currentInstance.getSize(s); + offsets[elId] = _currentInstance.getOffset(s); + offsetTimestamps[elId] = timestamp; + } + } else { + offsets[elId] = offset || offsets[elId]; + if (sizes[elId] == null) { + s = managedElements[elId].el; + if (s != null) sizes[elId] = _currentInstance.getSize(s); + } + offsetTimestamps[elId] = timestamp; + } + + if (offsets[elId] && !offsets[elId].right) { + offsets[elId].right = offsets[elId].left + sizes[elId][0]; + offsets[elId].bottom = offsets[elId].top + sizes[elId][1]; + offsets[elId].width = sizes[elId][0]; + offsets[elId].height = sizes[elId][1]; + offsets[elId].centerx = offsets[elId].left + (offsets[elId].width / 2); + offsets[elId].centery = offsets[elId].top + (offsets[elId].height / 2); + } + + return {o: offsets[elId], s: sizes[elId]}; + }; + + /** + * callback from the current library to tell us to prepare ourselves (attach + * mouse listeners etc; can't do that until the library has provided a bind method) + */ + this.init = function () { + rendererTypes = jsPlumb.getRenderModes(); + + var _oneType = function (renderer, name, fn) { + jsPlumb.Connectors[renderer][name] = function () { + fn.apply(this, arguments); + jsPlumb.ConnectorRenderers[renderer].apply(this, arguments); + }; + jsPlumbUtil.extend(jsPlumb.Connectors[renderer][name], [ fn, jsPlumb.ConnectorRenderers[renderer]]); + }; + + if (!jsPlumb.connectorsInitialized) { + for (var i = 0; i < connectorTypes.length; i++) { + for (var j = 0; j < rendererTypes.length; j++) { + _oneType(rendererTypes[j], connectorTypes[i][1], connectorTypes[i][0]); + } + + } + jsPlumb.connectorsInitialized = true; + } + + if (!initialized) { + _getContainerFromDefaults(); + _currentInstance.anchorManager = new jsPlumb.AnchorManager({jsPlumbInstance: _currentInstance}); + _currentInstance.setRenderMode(_currentInstance.Defaults.RenderMode); // calling the method forces the capability logic to be run. + initialized = true; + _currentInstance.fire("ready", _currentInstance); + } + }.bind(this); + + this.log = log; + this.jsPlumbUIComponent = jsPlumbUIComponent; + + /* + * Creates an anchor with the given params. + * + * + * Returns: The newly created Anchor. + * Throws: an error if a named anchor was not found. + */ + this.makeAnchor = function () { + var pp, _a = function (t, p) { + if (jsPlumb.Anchors[t]) return new jsPlumb.Anchors[t](p); + if (!_currentInstance.Defaults.DoNotThrowErrors) + throw { msg: "jsPlumb: unknown anchor type '" + t + "'" }; + }; + if (arguments.length === 0) return null; + var specimen = arguments[0], elementId = arguments[1], jsPlumbInstance = arguments[2], newAnchor = null; + // if it appears to be an anchor already... + if (specimen.compute && specimen.getOrientation) return specimen; //TODO hazy here about whether it should be added or is already added somehow. + // is it the name of an anchor type? + else if (typeof specimen == "string") { + newAnchor = _a(arguments[0], {elementId: elementId, jsPlumbInstance: _currentInstance}); + } + // is it an array? it will be one of: + // an array of [spec, params] - this defines a single anchor, which may be dynamic, but has parameters. + // an array of arrays - this defines some dynamic anchors + // an array of numbers - this defines a single anchor. + else if (_ju.isArray(specimen)) { + if (_ju.isArray(specimen[0]) || _ju.isString(specimen[0])) { + // if [spec, params] format + if (specimen.length == 2 && _ju.isObject(specimen[1])) { + // if first arg is a string, its a named anchor with params + if (_ju.isString(specimen[0])) { + pp = jsPlumb.extend({elementId: elementId, jsPlumbInstance: _currentInstance}, specimen[1]); + newAnchor = _a(specimen[0], pp); + } + // otherwise first arg is array, second is params. we treat as a dynamic anchor, which is fine + // even if the first arg has only one entry. you could argue all anchors should be implicitly dynamic in fact. + else { + pp = jsPlumb.extend({elementId: elementId, jsPlumbInstance: _currentInstance, anchors: specimen[0]}, specimen[1]); + newAnchor = new jsPlumb.DynamicAnchor(pp); + } + } + else + newAnchor = new jsPlumb.DynamicAnchor({anchors: specimen, selector: null, elementId: elementId, jsPlumbInstance: _currentInstance}); + + } + else { + var anchorParams = { + x: specimen[0], y: specimen[1], + orientation: (specimen.length >= 4) ? [ specimen[2], specimen[3] ] : [0, 0], + offsets: (specimen.length >= 6) ? [ specimen[4], specimen[5] ] : [ 0, 0 ], + elementId: elementId, + jsPlumbInstance: _currentInstance, + cssClass: specimen.length == 7 ? specimen[6] : null + }; + newAnchor = new jsPlumb.Anchor(anchorParams); + newAnchor.clone = function () { + return new jsPlumb.Anchor(anchorParams); + }; + } + } + + if (!newAnchor.id) newAnchor.id = "anchor_" + _idstamp(); + return newAnchor; + }; + + /** + * makes a list of anchors from the given list of types or coords, eg + * ["TopCenter", "RightMiddle", "BottomCenter", [0, 1, -1, -1] ] + */ + this.makeAnchors = function (types, elementId, jsPlumbInstance) { + var r = []; + for (var i = 0, ii = types.length; i < ii; i++) { + if (typeof types[i] == "string") + r.push(jsPlumb.Anchors[types[i]]({elementId: elementId, jsPlumbInstance: jsPlumbInstance})); + else if (_ju.isArray(types[i])) + r.push(_currentInstance.makeAnchor(types[i], elementId, jsPlumbInstance)); + } + return r; + }; + + /** + * Makes a dynamic anchor from the given list of anchors (which may be in shorthand notation as strings or dimension arrays, or Anchor + * objects themselves) and the given, optional, anchorSelector function (jsPlumb uses a default if this is not provided; most people will + * not need to provide this - i think). + */ + this.makeDynamicAnchor = function (anchors, anchorSelector) { + return new jsPlumb.DynamicAnchor({anchors: anchors, selector: anchorSelector, elementId: null, jsPlumbInstance: _currentInstance}); + }; + +// --------------------- makeSource/makeTarget ---------------------------------------------- + + this.targetEndpointDefinitions = {}; + var _setEndpointPaintStylesAndAnchor = function (ep, epIndex, _instance) { + ep.paintStyle = ep.paintStyle || + _instance.Defaults.EndpointStyles[epIndex] || + _instance.Defaults.EndpointStyle; + + ep.hoverPaintStyle = ep.hoverPaintStyle || + _instance.Defaults.EndpointHoverStyles[epIndex] || + _instance.Defaults.EndpointHoverStyle; + + ep.anchor = ep.anchor || + _instance.Defaults.Anchors[epIndex] || + _instance.Defaults.Anchor; + + ep.endpoint = ep.endpoint || + _instance.Defaults.Endpoints[epIndex] || + _instance.Defaults.Endpoint; + }; + + // TODO put all the source stuff inside one parent, keyed by id. + this.sourceEndpointDefinitions = {}; + + var selectorFilter = function (evt, _el, selector, _instance, negate) { + var t = evt.target || evt.srcElement, ok = false, + sel = _instance.getSelector(_el, selector); + for (var j = 0; j < sel.length; j++) { + if (sel[j] == t) { + ok = true; + break; + } + } + return negate ? !ok : ok; + }; + + // SP target source refactor + var _makeElementDropHandler = function (elInfo, p, dropOptions, isSource, isTarget, definitionId) { + var proxyComponent = new jsPlumbUIComponent(p); + var _drop = p._jsPlumb.EndpointDropHandler({ + jsPlumb: _currentInstance, + enabled: function () { + return elInfo.el[definitionId].enabled; + }, + isFull: function () { + var targetCount = _currentInstance.select({target: elInfo.id}).length; + var def = elInfo.el[definitionId]; + return def.maxConnections > 0 && targetCount >= def.maxConnections; + }, + element: elInfo.el, + elementId: elInfo.id, + isSource: isSource, + isTarget: isTarget, + addClass: function (clazz) { + _currentInstance.addClass(elInfo.el, clazz); + }, + removeClass: function (clazz) { + _currentInstance.removeClass(elInfo.el, clazz); + }, + onDrop: function (jpc) { + var source = jpc.endpoints[0]; + source.anchor.locked = false; + }, + isDropAllowed: function () { + return proxyComponent.isDropAllowed.apply(proxyComponent, arguments); + }, + isRedrop:function(jpc) { + return (jpc.suspendedElement != null && jpc.suspendedEndpoint != null && jpc.suspendedEndpoint.element === elInfo.el); + }, + getEndpoint: function (jpc) { + + // make a new Endpoint for the target, or get it from the cache if uniqueEndpoint + // is set. if its a redrop the new endpoint will be immediately cleaned up. + var def = elInfo.el[definitionId], + newEndpoint = def.endpoint; + + // if no cached endpoint, or there was one but it has been cleaned up + // (ie. detached), create a new one + if (newEndpoint == null || newEndpoint._jsPlumb == null) { + newEndpoint = _currentInstance.addEndpoint(elInfo.el, p); + newEndpoint._mtNew = true; + } + + if (p.uniqueEndpoint) def.endpoint = newEndpoint; // may of course just store what it just pulled out. that's ok. + // TODO test options to makeTarget to see if we should do this? + newEndpoint._doNotDeleteOnDetach = false; // reset. + newEndpoint._deleteOnDetach = true; + + // if connection is detachable, init the new endpoint to be draggable, to support that happening. + if (jpc.isDetachable()) + newEndpoint.initDraggable(); + + // if the anchor has a 'positionFinder' set, then delegate to that function to find + // out where to locate the anchor. + if (newEndpoint.anchor.positionFinder != null) { + var dropPosition = _currentInstance.getUIPosition(arguments, _currentInstance.getZoom()), + //elPosition = _currentInstance.getOffset(_el), + elPosition = _currentInstance.getOffset(elInfo.el), + //elSize = _currentInstance.getSize(_el), + elSize = _currentInstance.getSize(elInfo.el), + ap = newEndpoint.anchor.positionFinder(dropPosition, elPosition, elSize, newEndpoint.anchor.constructorParams); + newEndpoint.anchor.x = ap[0]; + newEndpoint.anchor.y = ap[1]; + // now figure an orientation for it..kind of hard to know what to do actually. probably the best thing i can do is to + // support specifying an orientation in the anchor's spec. if one is not supplied then i will make the orientation + // be what will cause the most natural link to the source: it will be pointing at the source, but it needs to be + // specified in one axis only, and so how to make that choice? i think i will use whichever axis is the one in which + // the target is furthest away from the source. + } + + return newEndpoint; + }, + maybeCleanup: function (ep) { + if (ep._mtNew && ep.connections.length === 0) { + _currentInstance.deleteObject({endpoint: ep}); + } + else + delete ep._mtNew; + } + }); + + // wrap drop events as needed and initialise droppable + var dropEvent = jsPlumb.dragEvents.drop; + dropOptions.scope = dropOptions.scope || (p.scope || _currentInstance.Defaults.Scope); + dropOptions[dropEvent] = _ju.wrap(dropOptions[dropEvent], _drop, true); + + // if target, return true from the over event. this will cause katavorio to stop setting drops to hover + // if multipleDrop is set to false. + if (isTarget) { + dropOptions[jsPlumb.dragEvents.over] = function () { return true; }; + } + + // vanilla jsplumb only + if (p.allowLoopback === false) { + dropOptions.canDrop = function (_drag) { + var de = _drag.getDragElement()._jsPlumbRelatedElement; + return de != elInfo.el; + }; + } + _currentInstance.initDroppable(elInfo.el, dropOptions, "internal"); + + return _drop; + + }; + + // see API docs + this.makeTarget = function (el, params, referenceParams) { + + // put jsplumb ref into params without altering the params passed in + var p = jsPlumb.extend({_jsPlumb: this}, referenceParams); + jsPlumb.extend(p, params); + + // calculate appropriate paint styles and anchor from the params given + _setEndpointPaintStylesAndAnchor(p, 1, this); + + var deleteEndpointsOnDetach = !(p.deleteEndpointsOnDetach === false), + maxConnections = p.maxConnections || -1, + + _doOne = function (el) { + + // get the element's id and store the endpoint definition for it. jsPlumb.connect calls will look for one of these, + // and use the endpoint definition if found. + // decode the info for this element (id and element) + var elInfo = _info(el), + elid = elInfo.id, + dropOptions = jsPlumb.extend({}, p.dropOptions || {}); + + _ensureContainer(elid); + + // store the definition + var _def = { + def: p, + uniqueEndpoint: p.uniqueEndpoint, + maxConnections: maxConnections, + enabled: true + }; + elInfo.el._jsPlumbTarget = _def; + this.targetEndpointDefinitions[elid] = _def; + _makeElementDropHandler(elInfo, p, dropOptions, p.isSource === true, true, "_jsPlumbTarget"); + + }.bind(this); + + // make an array if only given one element + var inputs = el.length && el.constructor != String ? el : [ el ]; + + // register each one in the list. + for (var i = 0, ii = inputs.length; i < ii; i++) { + _doOne(inputs[i]); + } + + return this; + }; + + // see api docs + this.unmakeTarget = function (el, doNotClearArrays) { + var info = _info(el); + jsPlumb.destroyDroppable(info.el); + if (!doNotClearArrays) { + delete this.targetEndpointDefinitions[info.id]; + } + + return this; + }; + + // see api docs + this.makeSource = function (el, params, referenceParams) { + var p = jsPlumb.extend({_jsPlumb: this}, referenceParams); + jsPlumb.extend(p, params); + _setEndpointPaintStylesAndAnchor(p, 0, this); + var maxConnections = p.maxConnections || 1, + onMaxConnections = p.onMaxConnections, + _doOne = function (elInfo) { + // get the element's id and store the endpoint definition for it. jsPlumb.connect calls will look for one of these, + // and use the endpoint definition if found. + var elid = elInfo.id, + _del = this.getElement(elInfo.el); + + _ensureContainer(elid); + + var _def = { + def: p, + uniqueEndpoint: p.uniqueEndpoint, + maxConnections: maxConnections, + enabled: true + }; + this.sourceEndpointDefinitions[elid] = _def; + elInfo.el._jsPlumbSource = _def; + + var stopEvent = jsPlumb.dragEvents.stop, + dragEvent = jsPlumb.dragEvents.drag, + dragOptions = jsPlumb.extend({ }, p.dragOptions || {}), + existingDrag = dragOptions.drag, + existingStop = dragOptions.stop, + ep = null, + endpointAddedButNoDragYet = false; + + // set scope if its not set in dragOptions but was passed in in params + dragOptions.scope = dragOptions.scope || p.scope; + + dragOptions[dragEvent] = _ju.wrap(dragOptions[dragEvent], function () { + if (existingDrag) existingDrag.apply(this, arguments); + endpointAddedButNoDragYet = false; + }); + + dragOptions[stopEvent] = _ju.wrap(dragOptions[stopEvent], function () { + + if (existingStop) existingStop.apply(this, arguments); + this.currentlyDragging = false; + if (ep._jsPlumb != null) { // if not cleaned up... + + // reset the anchor to the anchor that was initially provided. the one we were using to drag + // the connection was just a placeholder that was located at the place the user pressed the + // mouse button to initiate the drag. + var anchorDef = p.anchor || this.Defaults.Anchor, + oldAnchor = ep.anchor, + oldConnection = ep.connections[0], + newAnchor = this.makeAnchor(anchorDef, elid, this), + _el = ep.element; + + // if the anchor has a 'positionFinder' set, then delegate to that function to find + // out where to locate the anchor. issue 117. + if (newAnchor.positionFinder != null) { + var elPosition = _currentInstance.getOffset(_el), + elSize = this.getSize(_el), + dropPosition = { left: elPosition.left + (oldAnchor.x * elSize[0]), top: elPosition.top + (oldAnchor.y * elSize[1]) }, + ap = newAnchor.positionFinder(dropPosition, elPosition, elSize, newAnchor.constructorParams); + + newAnchor.x = ap[0]; + newAnchor.y = ap[1]; + } + + ep.setAnchor(newAnchor, true); + ep.repaint(); + this.repaint(ep.elementId); + if (oldConnection != null) this.repaint(oldConnection.targetId); + } + }.bind(this)); + + // when the user presses the mouse, add an Endpoint, if we are enabled. + var mouseDownListener = function (e) { + var evt = this.getOriginalEvent(e); + // on right mouse button, abort. + if (e.which === 3 || e.button === 2) return; + + // TODO store def on element. + var def = this.sourceEndpointDefinitions[elid]; + + // if disabled, return. + if (!def.enabled) return; + + elid = this.getId(this.getElement(elInfo.el)); // elid might have changed since this method was called to configure the element. + + // if a filter was given, run it, and return if it says no. + if (p.filter) { + var r = jsPlumbUtil.isString(p.filter) ? selectorFilter(evt, elInfo.el, p.filter, this, p.filterExclude) : p.filter(evt, elInfo.el); + if (r === false) return; + } + + // if maxConnections reached + var sourceCount = this.select({source: elid}).length; + if (def.maxConnections >= 0 && (def.uniqueEndpoint && sourceCount >= def.maxConnections)) { + if (onMaxConnections) { + onMaxConnections({ + element: elInfo.el, + maxConnections: maxConnections + }, e); + } + return false; + } + + // find the position on the element at which the mouse was pressed; this is where the endpoint + // will be located. + var elxy = jsPlumb.getPositionOnElement(evt, _del, _zoom); + + // we need to override the anchor in here, and force 'isSource', but we don't want to mess with + // the params passed in, because after a connection is established we're going to reset the endpoint + // to have the anchor we were given. + var tempEndpointParams = {}; + jsPlumb.extend(tempEndpointParams, p); + tempEndpointParams.isTemporarySource = true; + tempEndpointParams.anchor = [ elxy[0], elxy[1] , 0, 0]; + tempEndpointParams.dragOptions = dragOptions; + + ep = this.addEndpoint(elid, tempEndpointParams); + endpointAddedButNoDragYet = true; + ep._doNotDeleteOnDetach = false; // reset. + ep._deleteOnDetach = true; + + // if unique endpoint and it's already been created, push it onto the endpoint we create. at the end + // of a successful connection we'll switch to that endpoint. + // TODO this is the same code as the programmatic endpoints create on line 1050 ish + if (def.uniqueEndpoint) { + if (!def.endpoint) { + def.endpoint = ep; + ep._deleteOnDetach = false; + ep._doNotDeleteOnDetach = true; + } + else + ep.finalEndpoint = def.endpoint; + } + + var _delTempEndpoint = function () { + // this mouseup event is fired only if no dragging occurred, by jquery and yui, but for mootools + // it is fired even if dragging has occurred, in which case we would blow away a perfectly + // legitimate endpoint, were it not for this check. the flag is set after adding an + // endpoint and cleared in a drag listener we set in the dragOptions above. + _currentInstance.off(ep.canvas, "mouseup", _delTempEndpoint); + _currentInstance.off(elInfo.el, "mouseup", _delTempEndpoint); + if (endpointAddedButNoDragYet) { + endpointAddedButNoDragYet = false; + _currentInstance.deleteEndpoint(ep); + } + }; + + _currentInstance.on(ep.canvas, "mouseup", _delTempEndpoint); + _currentInstance.on(elInfo.el, "mouseup", _delTempEndpoint); + + // and then trigger its mousedown event, which will kick off a drag, which will start dragging + // a new connection from this endpoint. + _currentInstance.trigger(ep.canvas, "mousedown", e); + + jsPlumbUtil.consume(e); + + }.bind(this); + + //this.on(_el, "mousedown", mouseDownListener); + this.on(elInfo.el, "mousedown", mouseDownListener); + _def.trigger = mouseDownListener; + + // if a filter was provided, set it as a dragFilter on the element, + // to prevent the element drag function from kicking in when we want to + // drag a new connection + if (p.filter && (jsPlumbUtil.isString(p.filter) || jsPlumbUtil.isFunction(p.filter))) { + //_currentInstance.setDragFilter(_el, p.filter/*, p.filterExclude*/); + _currentInstance.setDragFilter(elInfo.el, p.filter/*, p.filterExclude*/); + } + + var dropOptions = jsPlumb.extend({}, p.dropOptions || {}); + + _makeElementDropHandler(elInfo, p, dropOptions, true, p.isTarget === true, "_jsPlumbSource"); + + }.bind(this); + + var inputs = el.length && el.constructor != String ? el : [ el ]; + for (var i = 0, ii = inputs.length; i < ii; i++) { + _doOne(_info(inputs[i])); + } + + return this; + }; + + // see api docs + this.unmakeSource = function (el, doNotClearArrays) { + var info = _info(el), + mouseDownListener = this.sourceEndpointDefinitions[info.id].trigger; + + if (mouseDownListener) + _currentInstance.off(info.el, "mousedown", mouseDownListener); + + if (!doNotClearArrays) { + delete this.sourceEndpointDefinitions[info.id]; + } + + return this; + }; + + // see api docs + this.unmakeEverySource = function () { + for (var i in this.sourceEndpointDefinitions) + _currentInstance.unmakeSource(i, true); + + this.sourceEndpointDefinitions = {}; + return this; + }; + + var _getScope = function (el, types) { + types = jsPlumbUtil.isArray(types) ? types : [ types ]; + var id = _getId(el); + for (var i = 0; i < types.length; i++) { + var def = this[types[i]][id]; + if (def) return def.def.scope || this.Defaults.Scope; + } + }.bind(this); + + var _setScope = function (el, scope, types) { + types = jsPlumbUtil.isArray(types) ? types : [ types ]; + var id = _getId(el); + for (var i = 0; i < types.length; i++) { + var def = this[types[i]][id]; + if (def) { + def.def.scope = scope; + if (this.scopeChange != null) this.scopeChange(el, id, endpointsByElement[id], scope, types[i]); + } + } + + }.bind(this); + + this.getScope = function (el, scope) { + return _getScope(el, [ "sourceEndpointDefinitions", "targetEndpointDefinitions" ]); + }; + this.getSourceScope = function (el) { + return _getScope(el, "sourceEndpointDefinitions"); + }; + this.getTargetScope = function (el) { + return _getScope(el, "targetEndpointDefinitions"); + }; + this.setScope = function (el, scope) { + _setScope(el, scope, [ "sourceEndpointDefinitions", "targetEndpointDefinitions" ]); + }; + this.setSourceScope = function (el, scope) { + _setScope(el, scope, "sourceEndpointDefinitions"); + }; + this.setTargetScope = function (el, scope) { + _setScope(el, scope, "targetEndpointDefinitions"); + }; + + // see api docs + this.unmakeEveryTarget = function () { + for (var i in this.targetEndpointDefinitions) + _currentInstance.unmakeTarget(i, true); + + this.targetEndpointDefinitions = {}; + return this; + }; + + // does the work of setting a source enabled or disabled. + var _setEnabled = function (type, el, state, toggle) { + var a = type == "source" ? this.sourceEndpointDefinitions : this.targetEndpointDefinitions; + + if (_ju.isString(el)) a[el].enabled = toggle ? !a[el].enabled : state; + else if (el.length) { + for (var i = 0, ii = el.length; i < ii; i++) { + var info = _info(el[i]); + if (a[info.id]) + a[info.id].enabled = toggle ? !a[info.id].enabled : state; + } + } + // otherwise a DOM element + else { + var id = _info(el).id; + a[id].enabled = toggle ? !a[id].enabled : state; + } + return this; + }.bind(this); + + var _first = function (el, fn) { + if (_ju.isString(el) || !el.length) + return fn.apply(this, [ el ]); + else if (el.length) + return fn.apply(this, [ el[0] ]); + + }.bind(this); + + this.toggleSourceEnabled = function (el) { + _setEnabled("source", el, null, true); + return this.isSourceEnabled(el); + }; + + this.setSourceEnabled = function (el, state) { + return _setEnabled("source", el, state); + }; + this.isSource = function (el) { + return _first(el, function (_el) { + return this.sourceEndpointDefinitions[_info(_el).id] != null; + }.bind(this)); + }; + this.isSourceEnabled = function (el) { + return _first(el, function (_el) { + var sep = this.sourceEndpointDefinitions[_info(_el).id]; + return sep && sep.enabled === true; + }.bind(this)); + }; + + this.toggleTargetEnabled = function (el) { + _setEnabled("target", el, null, true); + return this.isTargetEnabled(el); + }; + + this.isTarget = function (el) { + return _first(el, function (_el) { + return this.targetEndpointDefinitions[_info(_el).id] != null; + }.bind(this)); + }; + this.isTargetEnabled = function (el) { + return _first(el, function (_el) { + var tep = this.targetEndpointDefinitions[_info(_el).id]; + return tep && tep.enabled === true; + }.bind(this)); + }; + this.setTargetEnabled = function (el, state) { + return _setEnabled("target", el, state); + }; + +// --------------------- end makeSource/makeTarget ---------------------------------------------- + + this.ready = function (fn) { + _currentInstance.bind("ready", fn); + }; + + var _elEach = function(el, fn) { + // support both lists... + if (typeof el == 'object' && el.length) + for (var i = 0, ii = el.length; i < ii; i++) { + fn(el[i]); + } + else // ...and single strings or elements. + fn(el); + + return _currentInstance; + }; + + // repaint some element's endpoints and connections + this.repaint = function (el, ui, timestamp) { + return _elEach(el, function(_el) { + _draw(_el, ui, timestamp); + }); + }; + + this.revalidate = function (el, timestamp, isIdAlready) { + return _elEach(el, function(_el) { + var elId = isIdAlready ? _el : _currentInstance.getId(_el); + _currentInstance.updateOffset({ elId: elId, recalc: true, timestamp:timestamp }); + _currentInstance.repaint(_el); + }); + }; + + // repaint every endpoint and connection. + this.repaintEverything = function () { + // TODO this timestamp causes continuous anchors to not repaint properly. + // fix this. do not just take out the timestamp. it runs a lot faster with + // the timestamp included. + var timestamp = _timestamp(), elId; + + for (elId in endpointsByElement) { + _currentInstance.updateOffset({ elId: elId, recalc: true, timestamp: timestamp }); + } + + for (elId in endpointsByElement) { + _draw(elId, null, timestamp); + } + + return this; + }; + + this.removeAllEndpoints = function (el, recurse, affectedElements) { + affectedElements = affectedElements || []; + var _one = function (_el) { + var info = _info(_el), + ebe = endpointsByElement[info.id], + i, ii; + + if (ebe) { + affectedElements.push(info); + for (i = 0, ii = ebe.length; i < ii; i++) + _currentInstance.deleteEndpoint(ebe[i]); + } + delete endpointsByElement[info.id]; + + if (recurse) { + if (info.el && info.el.nodeType != 3 && info.el.nodeType != 8) { + for (i = 0, ii = info.el.childNodes.length; i < ii; i++) { + _one(info.el.childNodes[i]); + } + } + } + + }; + _one(el); + return this; + }; + + var _doRemove = function(info, affectedElements) { + _currentInstance.removeAllEndpoints(info.id, true, affectedElements); + var _one = function(_info) { + _currentInstance.getDragManager().elementRemoved(_info.id); + _currentInstance.anchorManager.clearFor(_info.id); + _currentInstance.anchorManager.removeFloatingConnection(_info.id); + delete _currentInstance.floatingConnections[_info.id]; + delete managedElements[_info.id]; + delete offsets[_info.id]; + if (_info.el) { + _currentInstance.removeElement(_info.el); + _info.el._jsPlumb = null; + } + }; + + // remove all affected child elements + for (var ae = 1; ae < affectedElements.length; ae++) { + _one(affectedElements[ae]); + } + // and always remove the requested one from the dom. + _one(info); + }; + + /** + * Remove the given element, including cleaning up all endpoints registered for it. + * This is exposed in the public API but also used internally by jsPlumb when removing the + * element associated with a connection drag. + */ + this.remove = function (el, doNotRepaint) { + var info = _info(el), affectedElements = []; + if (info.text) { + info.el.parentNode.removeChild(info.el); + } + else if (info.id) { + _currentInstance.batch(function () { + _doRemove(info, affectedElements); + }, doNotRepaint === false); + } + return _currentInstance; + }; + + this.empty = function (el, doNotRepaint) { + var affectedElements = []; + var _one = function(el, dontRemoveFocus) { + var info = _info(el); + if (info.text) { + info.el.parentNode.removeChild(info.el); + } + else if (info.el) { + while(info.el.childNodes.length > 0) { + _one(info.el.childNodes[0]); + } + if (!dontRemoveFocus) _doRemove(info, affectedElements); + } + }; + + _currentInstance.batch(function() { + _one(el, true); + }, doNotRepaint === false); + + return _currentInstance; + }; + + this.reset = function () { + _currentInstance.silently(function() { + _currentInstance.deleteEveryEndpoint(); + _currentInstance.unbind(); + this.targetEndpointDefinitions = {}; + this.sourceEndpointDefinitions = {}; + connections.length = 0; + if (this.doReset) this.doReset(); + }.bind(this)); + }; + + var _clearObject = function (obj) { + if (obj.canvas && obj.canvas.parentNode) + obj.canvas.parentNode.removeChild(obj.canvas); + obj.cleanup(); + obj.destroy(); + }; + + this.clear = function () { + _currentInstance.select().each(_clearObject); + _currentInstance.selectEndpoints().each(_clearObject); + + endpointsByElement = {}; + endpointsByUUID = {}; + }; + + this.setDefaultScope = function (scope) { + DEFAULT_SCOPE = scope; + return _currentInstance; + }; + + // sets whether or not some element should be currently draggable. + this.setDraggable = _setDraggable; + + // sets the id of some element, changing whatever we need to to keep track. + this.setId = function (el, newId, doNotSetAttribute) { + // + var id; + + if (jsPlumbUtil.isString(el)) { + id = el; + } + else { + el = this.getElement(el); + id = this.getId(el); + } + + var sConns = this.getConnections({source: id, scope: '*'}, true), + tConns = this.getConnections({target: id, scope: '*'}, true); + + newId = "" + newId; + + if (!doNotSetAttribute) { + el = this.getElement(id); + this.setAttribute(el, "id", newId); + } + else + el = this.getElement(newId); + + endpointsByElement[newId] = endpointsByElement[id] || []; + for (var i = 0, ii = endpointsByElement[newId].length; i < ii; i++) { + endpointsByElement[newId][i].setElementId(newId); + endpointsByElement[newId][i].setReferenceElement(el); + } + delete endpointsByElement[id]; + + this.anchorManager.changeId(id, newId); + this.getDragManager().changeId(id, newId); + managedElements[newId] = managedElements[id]; + delete managedElements[id]; + + var _conns = function (list, epIdx, type) { + for (var i = 0, ii = list.length; i < ii; i++) { + list[i].endpoints[epIdx].setElementId(newId); + list[i].endpoints[epIdx].setReferenceElement(el); + list[i][type + "Id"] = newId; + list[i][type] = el; + } + }; + _conns(sConns, 0, "source"); + _conns(tConns, 1, "target"); + + this.repaint(newId); + }; + + this.setDebugLog = function (debugLog) { + log = debugLog; + }; + + this.setSuspendDrawing = function (val, repaintAfterwards) { + var curVal = _suspendDrawing; + _suspendDrawing = val; + if (val) _suspendedAt = new Date().getTime(); else _suspendedAt = null; + if (repaintAfterwards) this.repaintEverything(); + return curVal; + }; + + // returns whether or not drawing is currently suspended. + this.isSuspendDrawing = function () { + return _suspendDrawing; + }; + + // return timestamp for when drawing was suspended. + this.getSuspendedAt = function () { + return _suspendedAt; + }; + + this.batch = function (fn, doNotRepaintAfterwards) { + var _wasSuspended = this.isSuspendDrawing(); + if (!_wasSuspended) + this.setSuspendDrawing(true); + try { + fn(); + } + catch (e) { + _ju.log("Function run while suspended failed", e); + } + if (!_wasSuspended) + this.setSuspendDrawing(false, !doNotRepaintAfterwards); + }; + + this.doWhileSuspended = this.batch; + + /* + this.getOffset = function (elId) { + return offsets[elId]; + };*/ + + this.getCachedData = _getCachedData; + this.timestamp = _timestamp; + this.setRenderMode = function (mode) { + if (mode !== jsPlumb.SVG && mode !== jsPlumb.VML) throw new TypeError("Render mode [" + mode + "] not supported"); + renderMode = this.trySetRenderMode(mode); + return renderMode; + }; + this.getRenderMode = function () { + return renderMode; + }; + this.show = function (el, changeEndpoints) { + _setVisible(el, "block", changeEndpoints); + return _currentInstance; + }; + + // TODO: update this method to return the current state. + this.toggleVisible = _toggleVisible; + this.toggleDraggable = _toggleDraggable; + this.addListener = this.bind; + }; + + jsPlumbUtil.extend(jsPlumbInstance, jsPlumbUtil.EventGenerator, { + setAttribute: function (el, a, v) { + this.setAttribute(el, a, v); + }, + getAttribute: function (el, a) { + return this.getAttribute(jsPlumb.getElement(el), a); + }, + convertToFullOverlaySpec: function(spec) { + if (jsPlumbUtil.isString(spec)) { + spec = [ spec, { } ]; + } + spec[1].id = spec[1].id || jsPlumbUtil.uuid(); + return spec; + }, + registerConnectionType: function (id, type) { + this._connectionTypes[id] = jsPlumb.extend({}, type); + if (type.overlays) { + var to = {}; + for (var i = 0; i < type.overlays.length; i++) { + // if a string, convert to object representation so that we can store the typeid on it. + // also assign an id. + var fo = this.convertToFullOverlaySpec(type.overlays[i]); + to[fo[1].id] = fo; + } + this._connectionTypes[id].overlays = to; + } + }, + registerConnectionTypes: function (types) { + for (var i in types) + this.registerConnectionType(i, types[i]); + }, + registerEndpointType: function (id, type) { + this._endpointTypes[id] = jsPlumb.extend({}, type); + }, + registerEndpointTypes: function (types) { + for (var i in types) + this._endpointTypes[i] = jsPlumb.extend({}, types[i]); + }, + getType: function (id, typeDescriptor) { + return typeDescriptor === "connection" ? this._connectionTypes[id] : this._endpointTypes[id]; + }, + setIdChanged: function (oldId, newId) { + this.setId(oldId, newId, true); + }, + // set parent: change the parent for some node and update all the registrations we need to. + setParent: function (el, newParent) { + var _dom = this.getElement(el), + _id = this.getId(_dom), + _pdom = this.getElement(newParent), + _pid = this.getId(_pdom); + + _dom.parentNode.removeChild(_dom); + _pdom.appendChild(_dom); + this.getDragManager().setParent(_dom, _id, _pdom, _pid); + }, + extend: function (o1, o2, names) { + var i; + if (names) { + for (i = 0; i < names.length; i++) + o1[names[i]] = o2[names[i]]; + } + else + for (i in o2) o1[i] = o2[i]; + return o1; + }, + floatingConnections: {}, + getFloatingAnchorIndex: function (jpc) { + return jpc.endpoints[0].isFloating() ? 0 : 1; + } + }); + +// --------------------- static instance + AMD registration ------------------------------------------- + +// create static instance and assign to window if window exists. + var jsPlumb = new jsPlumbInstance(); + // register on window if defined (lets us run on server) + if (typeof window != 'undefined') window.jsPlumb = jsPlumb; + // add 'getInstance' method to static instance + jsPlumb.getInstance = function (_defaults) { + var j = new jsPlumbInstance(_defaults); + j.init(); + return j; + }; + jsPlumb.each = function (spec, fn) { + if (spec == null) return; + if (typeof spec === "string") + fn(jsPlumb.getElement(spec)); + else if (spec.length != null) { + for (var i = 0; i < spec.length; i++) + fn(jsPlumb.getElement(spec[i])); + } + else + fn(spec); // assume it's an element. + }; +// maybe register static instance as an AMD module, and getInstance method too. + if (typeof define === "function") { + define("jsplumb", [], function () { + return jsPlumb; + }); + define("jsplumbinstance", [], function () { + return jsPlumb.getInstance(); + }); + } + // CommonJS + if (typeof exports !== 'undefined') { + exports.jsPlumb = jsPlumb; + } + + +// --------------------- end static instance + AMD registration ------------------------------------------- + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the base functionality for DOM type adapters. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + var root = this, _ju = root.jsPlumbUtil; + + var svgAvailable = !!window.SVGAngle || document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"), + vmlAvailable = function () { + if (vmlAvailable.vml === undefined) { + var a = document.body.appendChild(document.createElement('div')); + a.innerHTML = ''; + var b = a.firstChild; + if (b != null && b.style != null) { + b.style.behavior = "url(#default#VML)"; + vmlAvailable.vml = b ? typeof b.adj == "object" : true; + } + else + vmlAvailable.vml = false; + a.parentNode.removeChild(a); + } + return vmlAvailable.vml; + }, + // TODO: remove this once we remove all library adapter versions and have only vanilla jsplumb: this functionality + // comes from Mottle. + iev = (function () { + var rv = -1; + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent, + re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv; + })(), + isIELT9 = iev > -1 && iev < 9, + _genLoc = function (e, prefix) { + if (e == null) return [ 0, 0 ]; + var ts = _touches(e), t = _getTouch(ts, 0); + return [t[prefix + "X"], t[prefix + "Y"]]; + }, + _pageLocation = function (e) { + if (e == null) return [ 0, 0 ]; + if (isIELT9) { + return [ e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop ]; + } + else { + return _genLoc(e, "page"); + } + }, + _screenLocation = function (e) { + return _genLoc(e, "screen"); + }, + _clientLocation = function (e) { + return _genLoc(e, "client"); + }, + _getTouch = function (touches, idx) { + return touches.item ? touches.item(idx) : touches[idx]; + }, + _touches = function (e) { + return e.touches && e.touches.length > 0 ? e.touches : + e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches : + e.targetTouches && e.targetTouches.length > 0 ? e.targetTouches : + [ e ]; + }; + + /** + Manages dragging for some instance of jsPlumb. + + TODO instead of this being accessed directly, it should subscribe to events on the jsPlumb instance: every method + in here is called directly by jsPlumb. But what should happen is that we have unpublished events that this listens + to. The only trick is getting one of these instantiated with every jsPlumb instance: it needs to have a hook somehow. + Basically the general idea is to pull ALL the drag code out (prototype method registrations plus this) into a + dedicated drag script), that does not necessarily need to be included. + + + */ + var DragManager = function (_currentInstance) { + var _draggables = {}, _dlist = [], _delements = {}, _elementsWithEndpoints = {}, + // elementids mapped to the draggable to which they belong. + _draggablesForElements = {}; + + /** + register some element as draggable. right now the drag init stuff is done elsewhere, and it is + possible that will continue to be the case. + */ + this.register = function (el) { + var id = _currentInstance.getId(el), + parentOffset = _currentInstance.getOffset(el); + + if (!_draggables[id]) { + _draggables[id] = el; + _dlist.push(el); + _delements[id] = {}; + } + + // look for child elements that have endpoints and register them against this draggable. + var _oneLevel = function (p) { + if (p) { + for (var i = 0; i < p.childNodes.length; i++) { + if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) { + var cEl = jsPlumb.getElement(p.childNodes[i]), + cid = _currentInstance.getId(p.childNodes[i], null, true); + if (cid && _elementsWithEndpoints[cid] && _elementsWithEndpoints[cid] > 0) { + var cOff = _currentInstance.getOffset(cEl); + _delements[id][cid] = { + id: cid, + offset: { + left: cOff.left - parentOffset.left, + top: cOff.top - parentOffset.top + } + }; + _draggablesForElements[cid] = id; + } + _oneLevel(p.childNodes[i]); + } + } + } + }; + + _oneLevel(el); + }; + + // refresh the offsets for child elements of this element. + this.updateOffsets = function (elId) { + if (elId != null) { + var domEl = jsPlumb.getElement(elId), + id = _currentInstance.getId(domEl), + children = _delements[id], + parentOffset = _currentInstance.getOffset(domEl); + + if (children) { + for (var i in children) { + if (children.hasOwnProperty(i)) { + var cel = jsPlumb.getElement(i), + cOff = _currentInstance.getOffset(cel); + + _delements[id][i] = { + id: i, + offset: { + left: cOff.left - parentOffset.left, + top: cOff.top - parentOffset.top + } + }; + _draggablesForElements[i] = id; + } + } + } + } + }; + + /** + notification that an endpoint was added to the given el. we go up from that el's parent + node, looking for a parent that has been registered as a draggable. if we find one, we add this + el to that parent's list of elements to update on drag (if it is not there already) + */ + this.endpointAdded = function (el, id) { + + id = id || _currentInstance.getId(el); + + var b = document.body, + p = el.parentNode; + + _elementsWithEndpoints[id] = _elementsWithEndpoints[id] ? _elementsWithEndpoints[id] + 1 : 1; + + while (p != null && p != b) { + var pid = _currentInstance.getId(p, null, true); + if (pid && _draggables[pid]) { + var pLoc = _currentInstance.getOffset(p); + + if (_delements[pid][id] == null) { + var cLoc = _currentInstance.getOffset(el); + _delements[pid][id] = { + id: id, + offset: { + left: cLoc.left - pLoc.left, + top: cLoc.top - pLoc.top + } + }; + _draggablesForElements[id] = pid; + } + break; + } + p = p.parentNode; + } + }; + + this.endpointDeleted = function (endpoint) { + if (_elementsWithEndpoints[endpoint.elementId]) { + _elementsWithEndpoints[endpoint.elementId]--; + if (_elementsWithEndpoints[endpoint.elementId] <= 0) { + for (var i in _delements) { + if (_delements.hasOwnProperty(i) && _delements[i]) { + delete _delements[i][endpoint.elementId]; + delete _draggablesForElements[endpoint.elementId]; + } + } + } + } + }; + + this.changeId = function (oldId, newId) { + _delements[newId] = _delements[oldId]; + _delements[oldId] = {}; + _draggablesForElements[newId] = _draggablesForElements[oldId]; + _draggablesForElements[oldId] = null; + }; + + this.getElementsForDraggable = function (id) { + return _delements[id]; + }; + + this.elementRemoved = function (elementId) { + var elId = _draggablesForElements[elementId]; + if (elId) { + delete _delements[elId][elementId]; + delete _draggablesForElements[elementId]; + } + }; + + this.reset = function () { + _draggables = {}; + _dlist = []; + _delements = {}; + _elementsWithEndpoints = {}; + }; + + // + // notification drag ended. We check automatically if need to update some + // ancestor's offsets. + // + this.dragEnded = function (el) { + var id = _currentInstance.getId(el), + ancestor = _draggablesForElements[id]; + + if (ancestor) this.updateOffsets(ancestor); + }; + + this.setParent = function (el, elId, p, pId) { + var current = _draggablesForElements[elId]; + if (current) { + if (!_delements[pId]) + _delements[pId] = {}; + _delements[pId][elId] = _delements[current][elId]; + delete _delements[current][elId]; + var pLoc = _currentInstance.getOffset(p), + cLoc = _currentInstance.getOffset(el); + _delements[pId][elId].offset = { + left: cLoc.left - pLoc.left, + top: cLoc.top - pLoc.top + }; + _draggablesForElements[elId] = pId; + } + }; + + this.getDragAncestor = function (el) { + var de = jsPlumb.getElement(el), + id = _currentInstance.getId(de), + aid = _draggablesForElements[id]; + + if (aid) + return jsPlumb.getElement(aid); + else + return null; + }; + + }; + + var trim = function (str) { + return str == null ? null : (str.replace(/^\s\s*/, '').replace(/\s\s*$/, '')); + }, + _setClassName = function (el, cn) { + cn = trim(cn); + if (typeof el.className.baseVal != "undefined") // SVG + el.className.baseVal = cn; + else + el.className = cn; + }, + _getClassName = function (el) { + return (typeof el.className.baseVal == "undefined") ? el.className : el.className.baseVal; + }, + _classManip = function (el, classesToAdd, classesToRemove) { + classesToAdd = classesToAdd == null ? [] : jsPlumbUtil.isArray(classesToAdd) ? classesToAdd : classesToAdd.split(/\s+/); + classesToRemove = classesToRemove == null ? [] : jsPlumbUtil.isArray(classesToRemove) ? classesToRemove : classesToRemove.split(/\s+/); + + var className = _getClassName(el), + curClasses = className.split(/\s+/); + + var _oneSet = function (add, classes) { + for (var i = 0; i < classes.length; i++) { + if (add) { + if (jsPlumbUtil.indexOf(curClasses, classes[i]) == -1) + curClasses.push(classes[i]); + } + else { + var idx = jsPlumbUtil.indexOf(curClasses, classes[i]); + if (idx != -1) + curClasses.splice(idx, 1); + } + } + }; + + _oneSet(true, classesToAdd); + _oneSet(false, classesToRemove); + + _setClassName(el, curClasses.join(" ")); + }; + + jsPlumb.extend(jsPlumbInstance.prototype, { + + headless: false, + + pageLocation: _pageLocation, + screenLocation: _screenLocation, + clientLocation: _clientLocation, + + getDragManager:function() { + if (this.dragManager == null) + this.dragManager = new DragManager(this); + + return this.dragManager; + }, + + recalculateOffsets:function(elId) { + this.getDragManager().updateOffsets(elId); + }, + + createElement:function(tag, style, clazz, atts) { + return this.createElementNS(null, tag, style, clazz, atts); + }, + + createElementNS:function(ns, tag, style, clazz, atts) { + var e = ns == null ? document.createElement(tag) : document.createElementNS(ns, tag); + var i; + style = style || {}; + for (i in style) + e.style[i] = style[i]; + + if (clazz) + e.className = clazz; + + atts = atts || {}; + for (i in atts) + e.setAttribute(i, "" + atts[i]); + + return e; + }, + + getAttribute: function (el, attName) { + return el.getAttribute != null ? el.getAttribute(attName) : null; + }, + + setAttribute: function (el, a, v) { + if (el.setAttribute != null) el.setAttribute(a, v); + }, + + setAttributes: function (el, atts) { + for (var i in atts) + if (atts.hasOwnProperty(i)) el.setAttribute(i, atts[i]); + }, + + appendToRoot: function (node) { + document.body.appendChild(node); + }, + getRenderModes: function () { + return [ "svg", "vml" ]; + }, + isRenderModeAvailable: function (m) { + return { + "svg": svgAvailable, + "vml": vmlAvailable() + }[m]; + }, + trySetRenderMode: function (mode) { + var renderMode; + + if (mode) { + mode = mode.toLowerCase(); + + var svgAvailable = this.isRenderModeAvailable("svg"), + vmlAvailable = this.isRenderModeAvailable("vml"); + + // now test we actually have the capability to do this. + if (mode === "svg") { + if (svgAvailable) renderMode = "svg"; + else if (vmlAvailable) renderMode = "vml"; + } + else if (vmlAvailable) renderMode = "vml"; + } + + return renderMode; + }, + addClass: function (el, clazz) { + jsPlumb.each(el, function (e) { + _classManip(e, clazz); + }); + }, + hasClass: function (el, clazz) { + el = jsPlumb.getElement(el); + if (el.classList) return el.classList.contains(clazz); + else { + return _getClassName(el).indexOf(clazz) != -1; + } + }, + removeClass: function (el, clazz) { + jsPlumb.each(el, function (e) { + _classManip(e, null, clazz); + }); + }, + updateClasses: function (el, toAdd, toRemove) { + jsPlumb.each(el, function (e) { + _classManip(e, toAdd, toRemove); + }); + }, + setClass: function (el, clazz) { + jsPlumb.each(el, function (e) { + _setClassName(e, clazz); + }); + }, + setPosition: function (el, p) { + el.style.left = p.left + "px"; + el.style.top = p.top + "px"; + }, + getPosition: function (el) { + var _one = function (prop) { + var v = el.style[prop]; + return v ? v.substring(0, v.length - 2) : 0; + }; + return { + left: _one("left"), + top: _one("top") + }; + }, + getStyle:function(el, prop) { + if (typeof window.getComputedStyle !== 'undefined') { + return getComputedStyle(el, null).getPropertyValue(prop); + } else { + return el.currentStyle[prop]; + } + }, + + getSelector: function (ctx, spec) { + var sel = null; + if (arguments.length == 1) { + sel = ctx.nodeType != null ? ctx : document.querySelectorAll(ctx); + } + else + sel = ctx.querySelectorAll(spec); + + return sel; + }, + getOffset:function(el, relativeToRoot) { + el = jsPlumb.getElement(el); + var container = this.getContainer(); + var out = { + left: el.offsetLeft, + top: el.offsetTop + }, + op = (relativeToRoot || (container != null && el.offsetParent != container)) ? el.offsetParent : null, + _maybeAdjustScroll = function(offsetParent) { + if (offsetParent != null && offsetParent !== document.body && (offsetParent.scrollTop > 0 || offsetParent.scrollLeft > 0)) { + var p = this.getStyle(el, "position"); + //if (p !== "fixed") { + out.left -= offsetParent.scrollLeft; + out.top -= offsetParent.scrollTop; + //} + } + }.bind(this); + + while (op != null) { + out.left += op.offsetLeft; + out.top += op.offsetTop; + //if (!relativeToRoot) _maybeAdjustScroll(op); + _maybeAdjustScroll(op); + op = relativeToRoot ? op.offsetParent : + op.offsetParent == container ? null : op.offsetParent; + } + + // if container is scrolled and the element (or its offset parent) is not absolute or fixed, adjust accordingly. + if (container != null && !relativeToRoot && (container.scrollTop > 0 || container.scrollLeft > 0)) { + var pp = el.offsetParent != null ? this.getStyle(el.offsetParent, "position") : "static", + p = this.getStyle(el, "position"); + if (p !== "absolute" && p !== "fixed" && pp !== "absolute" && pp != "fixed") { + out.left -= container.scrollLeft; + out.top -= container.scrollTop; + } + } + return out; + }, + // + // return x+y proportion of the given element's size corresponding to the location of the given event. + // + getPositionOnElement: function (evt, el, zoom) { + var box = typeof el.getBoundingClientRect !== "undefined" ? el.getBoundingClientRect() : { left: 0, top: 0, width: 0, height: 0 }, + body = document.body, + docElem = document.documentElement, + scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop, + scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft, + clientTop = docElem.clientTop || body.clientTop || 0, + clientLeft = docElem.clientLeft || body.clientLeft || 0, + pst = 0, + psl = 0, + top = box.top + scrollTop - clientTop + (pst * zoom), + left = box.left + scrollLeft - clientLeft + (psl * zoom), + cl = jsPlumb.pageLocation(evt), + w = box.width || (el.offsetWidth * zoom), + h = box.height || (el.offsetHeight * zoom), + x = (cl[0] - left) / w, + y = (cl[1] - top) / h; + + return [ x, y ]; + }, + + /** + * Gets the absolute position of some element as read from the left/top properties in its style. + * @method getAbsolutePosition + * @param {Element} el The element to retrieve the absolute coordinates from. **Note** this is a DOM element, not a selector from the underlying library. + * @return {Number[]} [left, top] pixel values. + */ + getAbsolutePosition: function (el) { + var _one = function (s) { + var ss = el.style[s]; + if (ss) return parseFloat(ss.substring(0, ss.length - 2)); + }; + return [ _one("left"), _one("top") ]; + }, + + /** + * Sets the absolute position of some element by setting the left/top properties in its style. + * @method setAbsolutePosition + * @param {Element} el The element to set the absolute coordinates on. **Note** this is a DOM element, not a selector from the underlying library. + * @param {Number[]} xy x and y coordinates + * @param {Number[]} [animateFrom] Optional previous xy to animate from. + * @param {Object} [animateOptions] Options for the animation. + */ + setAbsolutePosition: function (el, xy, animateFrom, animateOptions) { + if (animateFrom) { + this.animate(el, { + left: "+=" + (xy[0] - animateFrom[0]), + top: "+=" + (xy[1] - animateFrom[1]) + }, animateOptions); + } + else { + el.style.left = xy[0] + "px"; + el.style.top = xy[1] + "px"; + } + }, + /** + * gets the size for the element, in an array : [ width, height ]. + */ + getSize: function (el) { + return [ el.offsetWidth, el.offsetHeight ]; + }, + getWidth: function (el) { + return el.offsetWidth; + }, + getHeight: function (el) { + return el.offsetHeight; + } + + }); +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains code for components that support overlays. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +;(function() { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + // ------------------------------ BEGIN OverlayCapablejsPlumbUIComponent -------------------------------------------- + + var _internalLabelOverlayId = "__label", + // this is a shortcut helper method to let people add a label as + // overlay. + _makeLabelOverlay = function (component, params) { + + var _params = { + cssClass: params.cssClass, + labelStyle: component.labelStyle, + id: _internalLabelOverlayId, + component: component, + _jsPlumb: component._jsPlumb.instance // TODO not necessary, since the instance can be accessed through the component. + }, + mergedParams = jsPlumb.extend(_params, params); + + return new _jp.Overlays[component._jsPlumb.instance.getRenderMode()].Label(mergedParams); + }, + _processOverlay = function (component, o) { + var _newOverlay = null; + if (_ju.isArray(o)) { // this is for the shorthand ["Arrow", { width:50 }] syntax + // there's also a three arg version: + // ["Arrow", { width:50 }, {location:0.7}] + // which merges the 3rd arg into the 2nd. + var type = o[0], + // make a copy of the object so as not to mess up anyone else's reference... + p = _jp.extend({component: component, _jsPlumb: component._jsPlumb.instance}, o[1]); + if (o.length == 3) _jp.extend(p, o[2]); + _newOverlay = new _jp.Overlays[component._jsPlumb.instance.getRenderMode()][type](p); + } else if (o.constructor == String) { + _newOverlay = new _jp.Overlays[component._jsPlumb.instance.getRenderMode()][o]({component: component, _jsPlumb: component._jsPlumb.instance}); + } else { + _newOverlay = o; + } + + _newOverlay.id = _newOverlay.id || _ju.uuid(); + component.cacheTypeItem("overlay", _newOverlay, _newOverlay.id); + //component._jsPlumb.overlays.push(_newOverlay); + component._jsPlumb.overlays[_newOverlay.id] = _newOverlay; + + return _newOverlay; + }; + + _jp.OverlayCapableJsPlumbUIComponent = function (params) { + + jsPlumbUIComponent.apply(this, arguments); + this._jsPlumb.overlays = {}; + this._jsPlumb.overlayPositions = {}; + + if (params.label) { + this.getDefaultType().overlays[_internalLabelOverlayId] = ["Label", { + label: params.label, + location: params.labelLocation || this.defaultLabelLocation || 0.5, + labelStyle: params.labelStyle || this._jsPlumb.instance.Defaults.LabelStyle, + id:_internalLabelOverlayId + }]; + } + + this.setListenerComponent = function (c) { + if (this._jsPlumb) { + for (var i in this._jsPlumb.overlays) + this._jsPlumb.overlays[i].setListenerComponent(c); + } + }; + }; + + _jp.OverlayCapableJsPlumbUIComponent.applyType = function (component, t) { + if (t.overlays) { + // loop through the ones in the type. if already present on the component, + // dont remove or re-add. + var keep = {}, i; + + for (i in t.overlays) { + + var existing = component._jsPlumb.overlays[t.overlays[i][1].id]; + if (existing) { + // maybe update from data, if there were parameterised values for instance. + existing.updateFrom(t.overlays[i][1]); + keep[t.overlays[i][1].id] = true; + } + else { + var c = component.getCachedTypeItem("overlay", t.overlays[i][1].id); + if (c != null) { + c.reattach(component._jsPlumb.instance); + // maybe update from data, if there were parameterised values for instance. + c.updateFrom(t.overlays[i][1]); + component._jsPlumb.overlays[c.id] = c; + } + else { + c = component.addOverlay(t.overlays[i], true); + } + keep[c.id] = true; + } + } + + // now loop through the full overlays and remove those that we dont want to keep + for (i in component._jsPlumb.overlays) { + if (keep[component._jsPlumb.overlays[i].id] == null) + component.removeOverlay(component._jsPlumb.overlays[i].id); + } + } + }; + + _ju.extend(_jp.OverlayCapableJsPlumbUIComponent, jsPlumbUIComponent, { + + setHover: function (hover, ignoreAttachedElements) { + if (this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) { + for (var i in this._jsPlumb.overlays) { + this._jsPlumb.overlays[i][hover ? "addClass" : "removeClass"](this._jsPlumb.instance.hoverClass); + } + } + }, + addOverlay: function (overlay, doNotRepaint) { + var o = _processOverlay(this, overlay); + if (!doNotRepaint) this.repaint(); + return o; + }, + getOverlay: function (id) { + return this._jsPlumb.overlays[id]; + }, + getOverlays: function () { + return this._jsPlumb.overlays; + }, + hideOverlay: function (id) { + var o = this.getOverlay(id); + if (o) o.hide(); + }, + hideOverlays: function () { + for (var i in this._jsPlumb.overlays) + this._jsPlumb.overlays[i].hide(); + }, + showOverlay: function (id) { + var o = this.getOverlay(id); + if (o) o.show(); + }, + showOverlays: function () { + for (var i in this._jsPlumb.overlays) + this._jsPlumb.overlays[i].show(); + }, + removeAllOverlays: function (doNotRepaint) { + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays[i].cleanup) this._jsPlumb.overlays[i].cleanup(); + } + + this._jsPlumb.overlays = {}; + this._jsPlumb.overlayPositions = null; + if (!doNotRepaint) + this.repaint(); + }, + removeOverlay: function (overlayId) { + var o = this._jsPlumb.overlays[overlayId]; + if (o) { + if (o.cleanup) o.cleanup(); + delete this._jsPlumb.overlays[overlayId]; + if (this._jsPlumb.overlayPositions) + delete this._jsPlumb.overlayPositions[overlayId]; + } + }, + removeOverlays: function () { + for (var i = 0, j = arguments.length; i < j; i++) + this.removeOverlay(arguments[i]); + }, + moveParent: function (newParent) { + if (this.bgCanvas) { + this.bgCanvas.parentNode.removeChild(this.bgCanvas); + newParent.appendChild(this.bgCanvas); + } + + this.canvas.parentNode.removeChild(this.canvas); + newParent.appendChild(this.canvas); + + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays[i].isAppendedAtTopLevel) { + var el = this._jsPlumb.overlays[i].getElement(); + el.parentNode.removeChild(el); + newParent.appendChild(el); + } + } + }, + getLabel: function () { + var lo = this.getOverlay(_internalLabelOverlayId); + return lo != null ? lo.getLabel() : null; + }, + getLabelOverlay: function () { + return this.getOverlay(_internalLabelOverlayId); + }, + setLabel: function (l) { + var lo = this.getOverlay(_internalLabelOverlayId); + if (!lo) { + var params = l.constructor == String || l.constructor == Function ? { label: l } : l; + lo = _makeLabelOverlay(this, params); + this._jsPlumb.overlays[_internalLabelOverlayId] = lo; + } + else { + if (l.constructor == String || l.constructor == Function) lo.setLabel(l); + else { + if (l.label) lo.setLabel(l.label); + if (l.location) lo.setLocation(l.location); + } + } + + if (!this._jsPlumb.instance.isSuspendDrawing()) + this.repaint(); + }, + cleanup: function (force) { + for (var i in this._jsPlumb.overlays) { + this._jsPlumb.overlays[i].cleanup(force); + this._jsPlumb.overlays[i].destroy(force); + } + if (force) { + this._jsPlumb.overlays = {}; + this._jsPlumb.overlayPositions = null; + } + }, + setVisible: function (v) { + this[v ? "showOverlays" : "hideOverlays"](); + }, + setAbsoluteOverlayPosition: function (overlay, xy) { + this._jsPlumb.overlayPositions[overlay.id] = xy; + }, + getAbsoluteOverlayPosition: function (overlay) { + return this._jsPlumb.overlayPositions ? this._jsPlumb.overlayPositions[overlay.id] : null; + } + }); + +// ------------------------------ END OverlayCapablejsPlumbUIComponent -------------------------------------------- + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for Endpoints. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + // create the drag handler for a connection + var _makeConnectionDragHandler = function (placeholder, _jsPlumb) { + var stopped = false; + return { + drag: function () { + if (stopped) { + stopped = false; + return true; + } + var _ui = _jp.getUIPosition(arguments, _jsPlumb.getZoom()); + + if (placeholder.element) { + jsPlumb.setPosition(placeholder.element, _ui); + _jsPlumb.repaint(placeholder.element, _ui); + } + }, + stopDrag: function () { + stopped = true; + } + }; + }; + + // creates a placeholder div for dragging purposes, adds it, and pre-computes its offset. + var _makeDraggablePlaceholder = function (placeholder, _jsPlumb) { + var n = jsPlumb.createElement("div", { position : "absolute" }); + _jsPlumb.appendElement(n); + var id = _jsPlumb.getId(n); + _jsPlumb.manage(id, n); + // create and assign an id, and initialize the offset. + placeholder.id = id; + placeholder.element = n; + }; + + // create a floating endpoint (for drag connections) + var _makeFloatingEndpoint = function (paintStyle, referenceAnchor, endpoint, referenceCanvas, sourceElement, _jsPlumb, _newEndpoint, scope) { + var floatingAnchor = new _jp.FloatingAnchor({ reference: referenceAnchor, referenceCanvas: referenceCanvas, jsPlumbInstance: _jsPlumb }); + //setting the scope here should not be the way to fix that mootools issue. it should be fixed by not + // adding the floating endpoint as a droppable. that makes more sense anyway! + return _newEndpoint({ paintStyle: paintStyle, endpoint: endpoint, anchor: floatingAnchor, source: sourceElement, scope: scope }); + }; + + var typeParameters = [ "connectorStyle", "connectorHoverStyle", "connectorOverlays", + "connector", "connectionType", "connectorClass", "connectorHoverClass" ]; + + // a helper function that tries to find a connection to the given element, and returns it if so. if elementWithPrecedence is null, + // or no connection to it is found, we return the first connection in our list. + var findConnectionToUseForDynamicAnchor = function (ep, elementWithPrecedence) { + var idx = 0; + if (elementWithPrecedence != null) { + for (var i = 0; i < ep.connections.length; i++) { + if (ep.connections[i].sourceId == elementWithPrecedence || ep.connections[i].targetId == elementWithPrecedence) { + idx = i; + break; + } + } + } + + return ep.connections[idx]; + }; + + var findConnectionIndex = function (conn, ep) { + return _ju.findWithFunction(ep.connections, function (c) { + return c.id == conn.id; + }); + }; + + _jp.Endpoint = function (params) { + var _jsPlumb = params._jsPlumb, + _newConnection = params.newConnection, + _newEndpoint = params.newEndpoint; + + this.idPrefix = "_jsplumb_e_"; + this.defaultLabelLocation = [ 0.5, 0.5 ]; + this.defaultOverlayKeys = ["Overlays", "EndpointOverlays"]; + _jp.OverlayCapableJsPlumbUIComponent.apply(this, arguments); + +// TYPE + + this.appendToDefaultType({ + connectionType:params.connectionType, + maxConnections: params.maxConnections == null ? this._jsPlumb.instance.Defaults.MaxConnections : params.maxConnections, // maximum number of connections this endpoint can be the source of., + paintStyle: params.endpointStyle || params.paintStyle || params.style || this._jsPlumb.instance.Defaults.EndpointStyle || _jp.Defaults.EndpointStyle, + hoverPaintStyle: params.endpointHoverStyle || params.hoverPaintStyle || this._jsPlumb.instance.Defaults.EndpointHoverStyle || _jp.Defaults.EndpointHoverStyle, + connectorStyle: params.connectorStyle, + connectorHoverStyle: params.connectorHoverStyle, + connectorClass: params.connectorClass, + connectorHoverClass: params.connectorHoverClass, + connectorOverlays: params.connectorOverlays, + connector: params.connector, + connectorTooltip: params.connectorTooltip + }); + +// END TYPE + + this._jsPlumb.enabled = !(params.enabled === false); + this._jsPlumb.visible = true; + this.element = _jp.getElement(params.source); + this._jsPlumb.uuid = params.uuid; + this._jsPlumb.floatingEndpoint = null; + var inPlaceCopy = null; + if (this._jsPlumb.uuid) params.endpointsByUUID[this._jsPlumb.uuid] = this; + this.elementId = params.elementId; + + this._jsPlumb.connectionCost = params.connectionCost; + this._jsPlumb.connectionsDirected = params.connectionsDirected; + this._jsPlumb.currentAnchorClass = ""; + this._jsPlumb.events = {}; + + var _updateAnchorClass = function () { + // stash old, get new + var oldAnchorClass = _jsPlumb.endpointAnchorClassPrefix + "_" + this._jsPlumb.currentAnchorClass; + this._jsPlumb.currentAnchorClass = this.anchor.getCssClass(); + var anchorClass = _jsPlumb.endpointAnchorClassPrefix + (this._jsPlumb.currentAnchorClass ? "_" + this._jsPlumb.currentAnchorClass : ""); + + this.removeClass(oldAnchorClass); + this.addClass(anchorClass); + // add and remove at the same time to reduce the number of reflows. + jsPlumb.updateClasses(this.element, anchorClass, oldAnchorClass); + }.bind(this); + + this.prepareAnchor = function(anchorParams) { + var a = this._jsPlumb.instance.makeAnchor(anchorParams, this.elementId, _jsPlumb); + a.bind("anchorChanged", function (currentAnchor) { + this.fire("anchorChanged", {endpoint: this, anchor: currentAnchor}); + _updateAnchorClass(); + }.bind(this)); + return a; + }; + + this.setPreparedAnchor = function(anchor, doNotRepaint) { + this._jsPlumb.instance.continuousAnchorFactory.clear(this.elementId); + this.anchor = anchor; + _updateAnchorClass(); + + if (!doNotRepaint) + this._jsPlumb.instance.repaint(this.elementId); + + return this; + }; + + this.setAnchor = function (anchorParams, doNotRepaint) { + var a = this.prepareAnchor(anchorParams); + this.setPreparedAnchor(a, doNotRepaint); + return this; + }; + + var internalHover = function (state) { + if (this.connections.length > 0) { + for (var i = 0; i < this.connections.length; i++) + this.connections[i].setHover(state, false); + } + else + this.setHover(state); + }.bind(this); + + this.bind("mouseover", function () { + internalHover(true); + }); + this.bind("mouseout", function () { + internalHover(false); + }); + + // ANCHOR MANAGER + if (!params._transient) // in place copies, for example, are transient. they will never need to be retrieved during a paint cycle, because they dont move, and then they are deleted. + this._jsPlumb.instance.anchorManager.add(this, this.elementId); + + this.prepareEndpoint = function(ep, typeId) { + var _e = function (t, p) { + var rm = _jsPlumb.getRenderMode(); + if (_jp.Endpoints[rm][t]) return new _jp.Endpoints[rm][t](p); + if (!_jsPlumb.Defaults.DoNotThrowErrors) + throw { msg: "jsPlumb: unknown endpoint type '" + t + "'" }; + }; + + var endpointArgs = { + _jsPlumb: this._jsPlumb.instance, + cssClass: params.cssClass, + container: params.container, + tooltip: params.tooltip, + connectorTooltip: params.connectorTooltip, + endpoint: this + }; + + var endpoint; + + if (_ju.isString(ep)) + endpoint = _e(ep, endpointArgs); + else if (_ju.isArray(ep)) { + endpointArgs = _ju.merge(ep[1], endpointArgs); + endpoint = _e(ep[0], endpointArgs); + } + else { + endpoint = ep.clone(); + } + + // assign a clone function using a copy of endpointArgs. this is used when a drag starts: the endpoint that was dragged is cloned, + // and the clone is left in its place while the original one goes off on a magical journey. + // the copy is to get around a closure problem, in which endpointArgs ends up getting shared by + // the whole world. + //var argsForClone = jsPlumb.extend({}, endpointArgs); + endpoint.clone = function () { + // TODO this, and the code above, can be refactored to be more dry. + if (_ju.isString(ep)) + return _e(ep, endpointArgs); + else if (_ju.isArray(ep)) { + endpointArgs = _ju.merge(ep[1], endpointArgs); + return _e(ep[0], endpointArgs); + } + }.bind(this); + + endpoint.typeId = typeId; + return endpoint; + }; + + this.setEndpoint = function(ep, doNotRepaint) { + var _ep = this.prepareEndpoint(ep); + this.setPreparedEndpoint(_ep, true); + }; + + this.setPreparedEndpoint = function (ep, doNotRepaint) { + if (this.endpoint != null) { + this.endpoint.cleanup(); + this.endpoint.destroy(); + } + this.endpoint = ep; + this.type = this.endpoint.type; + this.canvas = this.endpoint.canvas; + }; + + _jp.extend(this, params, typeParameters); + + this.isSource = params.isSource || false; + this.isTemporarySource = params.isTemporarySource || false; + this.isTarget = params.isTarget || false; + + this.connections = params.connections || []; + this.connectorPointerEvents = params["connector-pointer-events"]; + + this.scope = params.scope || _jsPlumb.getDefaultScope(); + this.timestamp = null; + this.reattachConnections = params.reattach || _jsPlumb.Defaults.ReattachConnections; + this.connectionsDetachable = _jsPlumb.Defaults.ConnectionsDetachable; + if (params.connectionsDetachable === false || params.detachable === false) + this.connectionsDetachable = false; + this.dragAllowedWhenFull = params.dragAllowedWhenFull !== false; + + if (params.onMaxConnections) + this.bind("maxConnections", params.onMaxConnections); + + // + // add a connection. not part of public API. + // + this.addConnection = function (connection) { + this.connections.push(connection); + this[(this.connections.length > 0 ? "add" : "remove") + "Class"](_jsPlumb.endpointConnectedClass); + this[(this.isFull() ? "add" : "remove") + "Class"](_jsPlumb.endpointFullClass); + }; + + this.detachFromConnection = function (connection, idx, doNotCleanup) { + idx = idx == null ? findConnectionIndex(connection, this) : idx; + if (idx >= 0) { + this.connections.splice(idx, 1); + this[(this.connections.length > 0 ? "add" : "remove") + "Class"](_jsPlumb.endpointConnectedClass); + this[(this.isFull() ? "add" : "remove") + "Class"](_jsPlumb.endpointFullClass); + } + + if (!doNotCleanup && this._deleteOnDetach && this.connections.length === 0) { + _jsPlumb.deleteObject({ + endpoint: this, + fireEvent: false, + deleteAttachedObjects: false + }); + } + }; + + this.detach = function (connection, ignoreTarget, forceDetach, fireEvent, originalEvent, endpointBeingDeleted, connectionIndex) { + + var idx = connectionIndex == null ? findConnectionIndex(connection, this) : connectionIndex, + actuallyDetached = false; + fireEvent = (fireEvent !== false); + + if (idx >= 0) { + + if (forceDetach || connection._forceDetach || (connection.isDetachable() && connection.isDetachAllowed(connection) && this.isDetachAllowed(connection) && _jsPlumb.checkCondition("beforeDetach", connection, endpointBeingDeleted) )) { + + _jsPlumb.deleteObject({ + connection: connection, + fireEvent: (!ignoreTarget && fireEvent), + originalEvent: originalEvent, + deleteAttachedObjects: false/**/ + }); + actuallyDetached = true; + } + } + return actuallyDetached; + }; + + this.detachAll = function (fireEvent, forceDetach) { + var unaffectedConns = []; + while (this.connections.length > 0) { + // TODO this could pass the index in to the detach method to save some time (index will always be zero in this while loop) + var actuallyDetached = this.detach(this.connections[0], false, forceDetach === true, fireEvent !== false, null, this, 0); + if (!actuallyDetached) { + unaffectedConns.push(this.connections[0]); + this.connections.splice(0, 1); + } + } + this.connections = unaffectedConns; + return this; + }; + this.detachFrom = function (targetEndpoint, fireEvent, originalEvent) { + var c = []; + for (var i = 0; i < this.connections.length; i++) { + if (this.connections[i].endpoints[1] == targetEndpoint || this.connections[i].endpoints[0] == targetEndpoint) { + c.push(this.connections[i]); + } + } + for (var j = 0; j < c.length; j++) { + this.detach(c[j], false, true, fireEvent, originalEvent); + } + return this; + }; + + this.getElement = function () { + return this.element; + }; + + this.setElement = function (el) { + var parentId = this._jsPlumb.instance.getId(el), + curId = this.elementId; + // remove the endpoint from the list for the current endpoint's element + _ju.removeWithFunction(params.endpointsByElement[this.elementId], function (e) { + return e.id == this.id; + }.bind(this)); + this.element = jsPlumb.getElement(el); + this.elementId = _jsPlumb.getId(this.element); + _jsPlumb.anchorManager.rehomeEndpoint(this, curId, this.element); + _jsPlumb.dragManager.endpointAdded(this.element); + _ju.addToList(params.endpointsByElement, parentId, this); + return this; + }; + + /** + * private but must be exposed. + */ + this.makeInPlaceCopy = function () { + var loc = this.anchor.getCurrentLocation({element: this}), + o = this.anchor.getOrientation(this), + acc = this.anchor.getCssClass(), + inPlaceAnchor = { + bind: function () { + }, + compute: function () { + return [ loc[0], loc[1] ]; + }, + getCurrentLocation: function () { + return [ loc[0], loc[1] ]; + }, + getOrientation: function () { + return o; + }, + getCssClass: function () { + return acc; + } + }; + + return _newEndpoint({ + dropOptions: params.dropOptions, + anchor: inPlaceAnchor, + source: this.element, + paintStyle: this.getPaintStyle(), + endpoint: params.hideOnDrag ? "Blank" : this.endpoint, + _transient: true, + scope: this.scope, + reference:this + }); + }; + + /** + * returns a connection from the pool; used when dragging starts. just gets the head of the array if it can. + */ + this.connectorSelector = function () { + var candidate = this.connections[0]; + // SP target source refactor + if (/*this.isTarget && */candidate) return candidate; + else { + return (this.connections.length < this._jsPlumb.maxConnections) || this._jsPlumb.maxConnections == -1 ? null : candidate; + } + }; + + this.setStyle = this.setPaintStyle; + + this.paint = function (params) { + params = params || {}; + var timestamp = params.timestamp, recalc = !(params.recalc === false); + if (!timestamp || this.timestamp !== timestamp) { + + var info = _jsPlumb.updateOffset({ elId: this.elementId, timestamp: timestamp }); + + var xy = params.offset ? params.offset.o : info.o; + if (xy != null) { + var ap = params.anchorPoint, connectorPaintStyle = params.connectorPaintStyle; + if (ap == null) { + var wh = params.dimensions || info.s, + anchorParams = { xy: [ xy.left, xy.top ], wh: wh, element: this, timestamp: timestamp }; + if (recalc && this.anchor.isDynamic && this.connections.length > 0) { + var c = findConnectionToUseForDynamicAnchor(this, params.elementWithPrecedence), + oIdx = c.endpoints[0] == this ? 1 : 0, + oId = oIdx === 0 ? c.sourceId : c.targetId, + oInfo = _jsPlumb.getCachedData(oId), + oOffset = oInfo.o, oWH = oInfo.s; + anchorParams.txy = [ oOffset.left, oOffset.top ]; + anchorParams.twh = oWH; + anchorParams.tElement = c.endpoints[oIdx]; + } + ap = this.anchor.compute(anchorParams); + } + + this.endpoint.compute(ap, this.anchor.getOrientation(this), this._jsPlumb.paintStyleInUse, connectorPaintStyle || this.paintStyleInUse); + this.endpoint.paint(this._jsPlumb.paintStyleInUse, this.anchor); + this.timestamp = timestamp; + + // paint overlays + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays.hasOwnProperty(i)) { + var o = this._jsPlumb.overlays[i]; + if (o.isVisible()) { + this._jsPlumb.overlayPlacements[i] = o.draw(this.endpoint, this._jsPlumb.paintStyleInUse); + o.paint(this._jsPlumb.overlayPlacements[i]); + } + } + } + } + } + }; + + this.getTypeDescriptor = function () { + return "endpoint"; + }; + this.isVisible = function () { + return this._jsPlumb.visible; + }; + + this.repaint = this.paint; + + var draggingInitialised = false; + this.initDraggable = function () { + + // is this a connection source? we make it draggable and have the + // drag listener maintain a connection with a floating endpoint. + if (!draggingInitialised && _jp.isDragSupported(this.element)) { + var placeholderInfo = { id: null, element: null }, + jpc = null, + existingJpc = false, + existingJpcParams = null, + _dragHandler = _makeConnectionDragHandler(placeholderInfo, _jsPlumb), + dragOptions = params.dragOptions || {}, + defaultOpts = {}, + startEvent = _jp.dragEvents.start, + stopEvent = _jp.dragEvents.stop, + dragEvent = _jp.dragEvents.drag; + + var start = function () { + // drag might have started on an endpoint that is not actually a source, but which has + // one or more connections. + jpc = this.connectorSelector(); + var _continue = true; + // if not enabled, return + if (!this.isEnabled()) _continue = false; + // if no connection and we're not a source - or temporarily a source, as is the case with makeSource - return. + if (jpc == null && !this.isSource && !this.isTemporarySource) _continue = false; + // otherwise if we're full and not allowed to drag, also return false. + if (this.isSource && this.isFull() && !(jpc != null && this.dragAllowedWhenFull)) _continue = false; + // if the connection was setup as not detachable or one of its endpoints + // was setup as connectionsDetachable = false, or Defaults.ConnectionsDetachable + // is set to false... + if (jpc != null && !jpc.isDetachable(this)) _continue = false; + + var beforeDrag = _jsPlumb.checkCondition(jpc == null ? "beforeDrag" : "beforeStartDetach", { + endpoint:this, + source:this.element, + sourceId:this.elementId, + connection:jpc + }); + if (beforeDrag === false) _continue = false; + // else we might have been given some data. we'll pass it in to a new connection as 'data'. + + if (_continue === false) { + // this is for mootools and yui. returning false from this causes jquery to stop drag. + // the events are wrapped in both mootools and yui anyway, but i don't think returning + // false from the start callback would stop a drag. + if (_jsPlumb.stopDrag) _jsPlumb.stopDrag(this.canvas); + _dragHandler.stopDrag(); + return false; + } + + // clear hover for all connections for this endpoint before continuing. + for (var i = 0; i < this.connections.length; i++) + this.connections[i].setHover(false); + + this.addClass("endpointDrag"); + _jsPlumb.setConnectionBeingDragged(true); + + // if we're not full but there was a connection, make it null. we'll create a new one. + if (jpc && !this.isFull() && this.isSource) jpc = null; + + _jsPlumb.updateOffset({ elId: this.elementId }); + inPlaceCopy = this.makeInPlaceCopy(); + inPlaceCopy.addClass(_jsPlumb.draggingClass); + inPlaceCopy.referenceEndpoint = this; + inPlaceCopy.paint(); + + _makeDraggablePlaceholder(placeholderInfo, _jsPlumb); + + // set the offset of this div to be where 'inPlaceCopy' is, to start with. + // TODO merge this code with the code in both Anchor and FloatingAnchor, because it + // does the same stuff. + var ipco = this._jsPlumb.instance.getOffset(inPlaceCopy.canvas), + canvasElement = this.canvas; + + jsPlumb.setPosition(placeholderInfo.element, ipco); + + // when using makeSource and a parent, we first draw the source anchor on the source element, then + // move it to the parent. note that this happens after drawing the placeholder for the + // first time. + if (this.parentAnchor) this.anchor = _jsPlumb.makeAnchor(this.parentAnchor, this.elementId, _jsPlumb); + + // store the id of the dragging div and the source element. the drop function will pick these up. + _jsPlumb.setAttributes(this.canvas, { + "dragId": placeholderInfo.id, + "elId": this.elementId + }); + + this._jsPlumb.floatingEndpoint = _makeFloatingEndpoint(this.getPaintStyle(), this.anchor, this.endpoint, this.canvas, placeholderInfo.element, _jsPlumb, _newEndpoint, this.scope); + // TODO we should not know about DOM here. make the library adapter do this (or the + // dom adapter) + this.canvas.style.visibility = "hidden"; + + if (jpc == null) { + this.anchor.locked = true; + this.setHover(false, false); + // create a connection. one end is this endpoint, the other is a floating endpoint. + jpc = _newConnection({ + sourceEndpoint: this, + targetEndpoint: this._jsPlumb.floatingEndpoint, + source: this.endpointWillMoveTo || this.element, // for makeSource with parent option. ensure source element is represented correctly. + target: placeholderInfo.element, + anchors: [ this.anchor, this._jsPlumb.floatingEndpoint.anchor ], + paintStyle: params.connectorStyle, // this can be null. Connection will use the default. + hoverPaintStyle: params.connectorHoverStyle, + connector: params.connector, // this can also be null. Connection will use the default. + overlays: params.connectorOverlays, + type: this.connectionType, + cssClass: this.connectorClass, + hoverClass: this.connectorHoverClass, + data:beforeDrag + }); + //jpc.pending = true; // mark this connection as not having been established. + jpc.addClass(_jsPlumb.draggingClass); + this._jsPlumb.floatingEndpoint.addClass(_jsPlumb.draggingClass); + // fire an event that informs that a connection is being dragged + _jsPlumb.fire("connectionDrag", jpc); + + } else { + existingJpc = true; + jpc.setHover(false); + // new anchor idx + var anchorIdx = jpc.endpoints[0].id == this.id ? 0 : 1; + this.detachFromConnection(jpc, null, true); // detach from the connection while dragging is occurring. but dont cleanup automatically. + + // store the original scope (issue 57) + var dragScope = _jsPlumb.getDragScope(canvasElement); + _jsPlumb.setAttribute(this.canvas, "originalScope", dragScope); + // now we want to get this endpoint's DROP scope, and set it for now: we can only be dropped on drop zones + // that have our drop scope (issue 57). + var dropScope = _jsPlumb.getDropScope(canvasElement); + _jsPlumb.setDragScope(canvasElement, dropScope); + //*/ + + // fire an event that informs that a connection is being dragged. we do this before + // replacing the original target with the floating element info. + _jsPlumb.fire("connectionDrag", jpc); + + // now we replace ourselves with the temporary div we created above: + if (anchorIdx === 0) { + existingJpcParams = [ jpc.source, jpc.sourceId, canvasElement, dragScope ]; + jpc.source = placeholderInfo.element; + jpc.sourceId = placeholderInfo.id; + } else { + existingJpcParams = [ jpc.target, jpc.targetId, canvasElement, dragScope ]; + jpc.target = placeholderInfo.element; + jpc.targetId = placeholderInfo.id; + } + + // lock the other endpoint; if it is dynamic it will not move while the drag is occurring. + jpc.endpoints[anchorIdx === 0 ? 1 : 0].anchor.locked = true; + // store the original endpoint and assign the new floating endpoint for the drag. + jpc.suspendedEndpoint = jpc.endpoints[anchorIdx]; + + // PROVIDE THE SUSPENDED ELEMENT, BE IT A SOURCE OR TARGET (ISSUE 39) + jpc.suspendedElement = jpc.endpoints[anchorIdx].getElement(); + jpc.suspendedElementId = jpc.endpoints[anchorIdx].elementId; + jpc.suspendedElementType = anchorIdx === 0 ? "source" : "target"; + + jpc.suspendedEndpoint.setHover(false); + this._jsPlumb.floatingEndpoint.referenceEndpoint = jpc.suspendedEndpoint; + jpc.endpoints[anchorIdx] = this._jsPlumb.floatingEndpoint; + + jpc.addClass(_jsPlumb.draggingClass); + this._jsPlumb.floatingEndpoint.addClass(_jsPlumb.draggingClass); + } + + // register it and register connection on it. + _jsPlumb.floatingConnections[placeholderInfo.id] = jpc; + _jsPlumb.anchorManager.addFloatingConnection(placeholderInfo.id, jpc); + // only register for the target endpoint; we will not be dragging the source at any time + // before this connection is either discarded or made into a permanent connection. + _ju.addToList(params.endpointsByElement, placeholderInfo.id, this._jsPlumb.floatingEndpoint); + // tell jsplumb about it + _jsPlumb.currentlyDragging = true; + }.bind(this); + + var stop = function () { + _jsPlumb.setConnectionBeingDragged(false); + // if no endpoints, jpc already cleaned up. + if (jpc && jpc.endpoints != null) { + // get the actual drop event (decode from library args to stop function) + var originalEvent = _jsPlumb.getDropEvent(arguments); + // unlock the other endpoint (if it is dynamic, it would have been locked at drag start) + var idx = _jsPlumb.getFloatingAnchorIndex(jpc); + jpc.endpoints[idx === 0 ? 1 : 0].anchor.locked = false; + // TODO: Dont want to know about css classes inside jsplumb, ideally. + jpc.removeClass(_jsPlumb.draggingClass); + + // if we have the floating endpoint then the connection has not been dropped + // on another endpoint. If it is a new connection we throw it away. If it is an + // existing connection we check to see if we should reattach it, throwing it away + // if not. + if (this._jsPlumb && (jpc.deleteConnectionNow || jpc.endpoints[idx] == this._jsPlumb.floatingEndpoint)) { + // 6a. if the connection was an existing one... + if (existingJpc && jpc.suspendedEndpoint) { + // fix for issue35, thanks Sylvain Gizard: when firing the detach event make sure the + // floating endpoint has been replaced. + if (idx === 0) { + jpc.source = existingJpcParams[0]; + jpc.sourceId = existingJpcParams[1]; + } else { + jpc.target = existingJpcParams[0]; + jpc.targetId = existingJpcParams[1]; + } + + var fe = this._jsPlumb.floatingEndpoint; // store for later removal. + // restore the original scope (issue 57) + _jsPlumb.setDragScope(existingJpcParams[2], existingJpcParams[3]); + jpc.endpoints[idx] = jpc.suspendedEndpoint; + // IF the connection should be reattached, or the other endpoint refuses detach, then + // reset the connection to its original state + if (jpc.isReattach() || jpc._forceReattach || jpc._forceDetach || !jpc.endpoints[idx === 0 ? 1 : 0].detach(jpc, false, false, true, originalEvent, true)) { + jpc.setHover(false); + jpc._forceDetach = null; + jpc._forceReattach = null; + this._jsPlumb.floatingEndpoint.detachFromConnection(jpc); + jpc.suspendedEndpoint.addConnection(jpc); + _jsPlumb.repaint(existingJpcParams[1]); + } + else + _jsPlumb.deleteObject({endpoint: fe}); + } + } + + // remove the element associated with the floating endpoint + // (and its associated floating endpoint and visual artefacts) + _jsPlumb.remove(placeholderInfo.element, false); + // remove the inplace copy + _jsPlumb.deleteObject({endpoint: inPlaceCopy}); + + // makeTargets sets this flag, to tell us we have been replaced and should delete ourself. + if (this.deleteAfterDragStop) { + _jsPlumb.deleteObject({endpoint: this}); + } + else { + if (this._jsPlumb) { + this._jsPlumb.floatingEndpoint = null; + // repaint this endpoint. + // make our canvas visible (TODO: hand off to library; we should not know about DOM) + this.canvas.style.visibility = "visible"; + // unlock our anchor + this.anchor.locked = false; + this.paint({recalc: false}); + } + } + + // although the connection is no longer valid, there are use cases where this is useful. + _jsPlumb.fire("connectionDragStop", jpc, originalEvent); + // tell jsplumb that dragging is finished. + _jsPlumb.currentlyDragging = false; + jpc = null; + } + + }.bind(this); + + dragOptions = _jp.extend(defaultOpts, dragOptions); + dragOptions.scope = this.scope || dragOptions.scope; + dragOptions[startEvent] = _ju.wrap(dragOptions[startEvent], start, false); + // extracted drag handler function so can be used by makeSource + dragOptions[dragEvent] = _ju.wrap(dragOptions[dragEvent], _dragHandler.drag); + dragOptions[stopEvent] = _ju.wrap(dragOptions[stopEvent], stop); + dragOptions.multipleDrop = false; + + dragOptions.canDrag = function () { + return this.isSource || this.isTemporarySource || /*(this.isTarget && */this.connections.length > 0/*)*/; + }.bind(this); + + _jsPlumb.initDraggable(this.canvas, dragOptions, "internal"); + + this.canvas._jsPlumbRelatedElement = this.element; + + draggingInitialised = true; + } + }; + + var ep = params.endpoint || this._jsPlumb.instance.Defaults.Endpoint || _jp.Defaults.Endpoint; + this.setEndpoint(ep, true); + var anchorParamsToUse = params.anchor ? params.anchor : params.anchors ? params.anchors : (_jsPlumb.Defaults.Anchor || "Top"); + this.setAnchor(anchorParamsToUse, true); + + // finally, set type if it was provided + var type = [ "default", (params.type || "")].join(" "); + this.addType(type, params.data, true); + this.canvas = this.endpoint.canvas; + this.canvas._jsPlumb = this; + + // if marked as source or target at create time, init the dragging. + if (this.isSource || this.isTarget || this.isTemporarySource) + this.initDraggable(); + + // pulled this out into a function so we can reuse it for the inPlaceCopy canvas; you can now drop detached connections + // back onto the endpoint you detached it from. + var _initDropTarget = function (canvas, forceInit, isTransient, endpoint, referenceEndpoint) { + + if ((this.isTarget || forceInit) && _jp.isDropSupported(this.element)) { + var dropOptions = params.dropOptions || _jsPlumb.Defaults.DropOptions || _jp.Defaults.DropOptions; + dropOptions = _jp.extend({}, dropOptions); + dropOptions.scope = dropOptions.scope || this.scope; + var dropEvent = _jp.dragEvents.drop, + overEvent = _jp.dragEvents.over, + outEvent = _jp.dragEvents.out, + _ep = this, + drop = _jsPlumb.EndpointDropHandler({ + getEndpoint: function () { + return _ep; + }, + jsPlumb: _jsPlumb, + enabled: function () { + return endpoint != null ? endpoint.isEnabled() : true; + }, + isFull: function () { + return endpoint.isFull(); + }, + element: this.element, + elementId: this.elementId, + isSource: this.isSource, + isTarget: this.isTarget, + addClass: function (clazz) { + _ep.addClass(clazz); + }, + removeClass: function (clazz) { + _ep.removeClass(clazz); + }, + isDropAllowed: function () { + return _ep.isDropAllowed.apply(_ep, arguments); + }, + reference:referenceEndpoint, + isRedrop:function(jpc, dhParams) { + return jpc.suspendedEndpoint && dhParams.reference && (jpc.suspendedEndpoint.id === dhParams.reference.id); + } + }); + + dropOptions[dropEvent] = _ju.wrap(dropOptions[dropEvent], drop, true); + dropOptions[overEvent] = _ju.wrap(dropOptions[overEvent], function () { + var draggable = _jp.getDragObject(arguments), + id = _jsPlumb.getAttribute(_jp.getElement(draggable), "dragId"), + _jpc = _jsPlumb.floatingConnections[id]; + + if (_jpc != null) { + var idx = _jsPlumb.getFloatingAnchorIndex(_jpc); + // here we should fire the 'over' event if we are a target and this is a new connection, + // or we are the same as the floating endpoint. + var _cont = (this.isTarget && idx !== 0) || (_jpc.suspendedEndpoint && this.referenceEndpoint && this.referenceEndpoint.id == _jpc.suspendedEndpoint.id); + if (_cont) { + var bb = _jsPlumb.checkCondition("checkDropAllowed", { + sourceEndpoint: _jpc.endpoints[idx], + targetEndpoint: this, + connection: _jpc + }); + this[(bb ? "add" : "remove") + "Class"](_jsPlumb.endpointDropAllowedClass); + this[(bb ? "remove" : "add") + "Class"](_jsPlumb.endpointDropForbiddenClass); + _jpc.endpoints[idx].anchor.over(this.anchor, this); + } + } + }.bind(this)); + + dropOptions[outEvent] = _ju.wrap(dropOptions[outEvent], function () { + var draggable = _jp.getDragObject(arguments), + id = draggable == null ? null : _jsPlumb.getAttribute(_jp.getElement(draggable), "dragId"), + _jpc = id ? _jsPlumb.floatingConnections[id] : null; + + if (_jpc != null) { + var idx = _jsPlumb.getFloatingAnchorIndex(_jpc); + var _cont = (this.isTarget && idx !== 0) || (_jpc.suspendedEndpoint && this.referenceEndpoint && this.referenceEndpoint.id == _jpc.suspendedEndpoint.id); + if (_cont) { + this.removeClass(_jsPlumb.endpointDropAllowedClass); + this.removeClass(_jsPlumb.endpointDropForbiddenClass); + _jpc.endpoints[idx].anchor.out(); + } + } + }.bind(this)); + + _jsPlumb.initDroppable(canvas, dropOptions, "internal", isTransient); + } + }.bind(this); + + // Initialise the endpoint's canvas as a drop target. The drop handler will take care of the logic of whether + // something can actually be dropped. + if (!this.anchor.isFloating) + _initDropTarget(this.canvas, true, !(params._transient || this.anchor.isFloating), this, params.reference); + + + return this; + }; + + _ju.extend(_jp.Endpoint, _jp.OverlayCapableJsPlumbUIComponent, { + + setVisible: function (v, doNotChangeConnections, doNotNotifyOtherEndpoint) { + this._jsPlumb.visible = v; + if (this.canvas) this.canvas.style.display = v ? "block" : "none"; + this[v ? "showOverlays" : "hideOverlays"](); + if (!doNotChangeConnections) { + for (var i = 0; i < this.connections.length; i++) { + this.connections[i].setVisible(v); + if (!doNotNotifyOtherEndpoint) { + var oIdx = this === this.connections[i].endpoints[0] ? 1 : 0; + // only change the other endpoint if this is its only connection. + if (this.connections[i].endpoints[oIdx].connections.length == 1) this.connections[i].endpoints[oIdx].setVisible(v, true, true); + } + } + } + }, + getAttachedElements: function () { + return this.connections; + }, + applyType: function (t, doNotRepaint) { + this.setPaintStyle(t.endpointStyle || t.paintStyle, doNotRepaint); + this.setHoverPaintStyle(t.endpointHoverStyle || t.hoverPaintStyle, doNotRepaint); + if (t.maxConnections != null) this._jsPlumb.maxConnections = t.maxConnections; + if (t.scope) this.scope = t.scope; + _jp.extend(this, t, typeParameters); + if (t.cssClass != null && this.canvas) this._jsPlumb.instance.addClass(this.canvas, t.cssClass); + _jp.OverlayCapableJsPlumbUIComponent.applyType(this, t); + }, + isEnabled: function () { + return this._jsPlumb.enabled; + }, + setEnabled: function (e) { + this._jsPlumb.enabled = e; + }, + cleanup: function () { + var anchorClass = this._jsPlumb.instance.endpointAnchorClassPrefix + (this._jsPlumb.currentAnchorClass ? "_" + this._jsPlumb.currentAnchorClass : ""); + jsPlumb.removeClass(this.element, anchorClass); + this.anchor = null; + this.endpoint.cleanup(); + this.endpoint.destroy(); + this.endpoint = null; + // drag/drop + this._jsPlumb.instance.destroyDraggable(this.canvas, "internal"); + this._jsPlumb.instance.destroyDroppable(this.canvas, "internal"); + }, + setHover: function (h) { + if (this.endpoint && this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) + this.endpoint.setHover(h); + }, + isFull: function () { + return this._jsPlumb.maxConnections === 0 ? true : !(this.isFloating() || this._jsPlumb.maxConnections < 0 || this.connections.length < this._jsPlumb.maxConnections); + }, + /** + * private but needs to be exposed. + */ + isFloating: function () { + return this.anchor != null && this.anchor.isFloating; + }, + isConnectedTo: function (endpoint) { + var found = false; + if (endpoint) { + for (var i = 0; i < this.connections.length; i++) { + if (this.connections[i].endpoints[1] == endpoint || this.connections[i].endpoints[0] == endpoint) { + found = true; + break; + } + } + } + return found; + }, + getConnectionCost: function () { + return this._jsPlumb.connectionCost; + }, + setConnectionCost: function (c) { + this._jsPlumb.connectionCost = c; + }, + areConnectionsDirected: function () { + return this._jsPlumb.connectionsDirected; + }, + setConnectionsDirected: function (b) { + this._jsPlumb.connectionsDirected = b; + }, + setElementId: function (_elId) { + this.elementId = _elId; + this.anchor.elementId = _elId; + }, + setReferenceElement: function (_el) { + this.element = _jp.getElement(_el); + }, + setDragAllowedWhenFull: function (allowed) { + this.dragAllowedWhenFull = allowed; + }, + equals: function (endpoint) { + return this.anchor.equals(endpoint.anchor); + }, + getUuid: function () { + return this._jsPlumb.uuid; + }, + computeAnchor: function (params) { + return this.anchor.compute(params); + } + }); + + root.jsPlumbInstance.prototype.EndpointDropHandler = function (dhParams) { + return function (e) { + + var _jsPlumb = dhParams.jsPlumb; + + // remove the classes that are added dynamically. drop is neither forbidden nor allowed now that + // the drop is finishing. + // makeTarget:probably keep these. 'this' would refer to the DOM element though + dhParams.removeClass(_jsPlumb.endpointDropAllowedClass); + dhParams.removeClass(_jsPlumb.endpointDropForbiddenClass); + + var originalEvent = _jsPlumb.getDropEvent(arguments), + draggable = _jsPlumb.getDragObject(arguments), + id = _jsPlumb.getAttribute(draggable, "dragId"), + elId = _jsPlumb.getAttribute(draggable, "elId"), + scope = _jsPlumb.getAttribute(draggable, "originalScope"), + jpc = _jsPlumb.floatingConnections[id]; + + // if no active connection, bail. + if (jpc == null) return; + + // if suspended endpoint has been cleaned up, bail. + if (jpc.suspendedEndpoint && jpc.suspendedEndpoint._jsPlumb == null) return; + + // get the drop endpoint. for a normal connection this is just the one that would replace the currently + // floating endpoint. for a makeTarget this is a new endpoint that is created on drop. + var _ep = dhParams.getEndpoint(jpc); + + // if this is a drop back where the connection came from, mark it force reattach and + // return; the stop handler will reattach. without firing an event. + //var redrop + //var redrop = jpc.suspendedEndpoint && dhParams.reference && (jpc.suspendedEndpoint.id === dhParams.reference.id); + //var redrop = jpc.suspendedEndpoint && (jpc.suspendedEndpoint.elementId === dhParams.elementId); + //if (redrop) { + if (dhParams.isRedrop(jpc, dhParams)) { + jpc._forceReattach = true; + jpc.setHover(false); + if (dhParams.maybeCleanup) dhParams.maybeCleanup(_ep); + return; + } + + // ensure we dont bother trying to drop sources on non-source eps, and same for target. + var idx = _jsPlumb.getFloatingAnchorIndex(jpc); + if (idx === 0 && !dhParams.isSource) return; + if (idx === 1 && !dhParams.isTarget) return; + + if (dhParams.onDrop) dhParams.onDrop(jpc); + + // restore the original scope if necessary (issue 57) + if (scope) _jsPlumb.setDragScope(draggable, scope); + + // if the target of the drop is full, fire an event (we abort below) + // makeTarget: keep. + if (dhParams.isFull(e)) { + _ep.fire("maxConnections", { + endpoint: this, + connection: jpc, + maxConnections: _ep._jsPlumb.maxConnections + }, originalEvent); + } + + // + // if endpoint enabled, not full, and matches the index of the floating endpoint... + if (!dhParams.isFull() && !(idx === 0 && !dhParams.isSource) && !(idx == 1 && !dhParams.isTarget) && dhParams.enabled()) { + var _doContinue = true; + + // these have to be set before testing for beforeDrop. + if (idx === 0) { + jpc.source = dhParams.element; + jpc.sourceId = dhParams.elementId; + } else { + jpc.target = dhParams.element; + jpc.targetId = dhParams.elementId; + } + + // if this is an existing connection and detach is not allowed we won't continue. The connection's + // endpoints have been reinstated; everything is back to how it was. + if (jpc.suspendedEndpoint && jpc.suspendedEndpoint._jsPlumb && jpc.suspendedEndpoint.id != _ep.id) { + + if (!jpc.isDetachAllowed(jpc) || !jpc.endpoints[idx].isDetachAllowed(jpc) || !jpc.suspendedEndpoint.isDetachAllowed(jpc) || !_jsPlumb.checkCondition("beforeDetach", jpc)) + _doContinue = false; + } + +// ------------ wrap the execution path in a function so we can support asynchronous beforeDrop + + var continueFunction = function (optionalData) { + // remove this jpc from the current endpoint, which is a floating endpoint that we will + // subsequently discard. + jpc.endpoints[idx].detachFromConnection(jpc); + + // if there's a suspended endpoint, detach it from the connection. + if (jpc.suspendedEndpoint) jpc.suspendedEndpoint.detachFromConnection(jpc); + // TODO why? + + jpc.endpoints[idx] = _ep; + _ep.addConnection(jpc); + + // copy our parameters in to the connection: + var params = _ep.getParameters(); + for (var aParam in params) + jpc.setParameter(aParam, params[aParam]); + + if (!jpc.suspendedEndpoint) { + // if not an existing connection and + if (params.draggable) + _jsPlumb.initDraggable(this.element, dragOptions, "internal", _jsPlumb); + } + else { + var suspendedElementId = jpc.suspendedEndpoint.elementId; + _jsPlumb.fireMoveEvent({ + index: idx, + originalSourceId: idx === 0 ? suspendedElementId : jpc.sourceId, + newSourceId: idx === 0 ? _ep.elementId : jpc.sourceId, + originalTargetId: idx == 1 ? suspendedElementId : jpc.targetId, + newTargetId: idx == 1 ? _ep.elementId : jpc.targetId, + originalSourceEndpoint: idx === 0 ? jpc.suspendedEndpoint : jpc.endpoints[0], + newSourceEndpoint: idx === 0 ? _ep : jpc.endpoints[0], + originalTargetEndpoint: idx == 1 ? jpc.suspendedEndpoint : jpc.endpoints[1], + newTargetEndpoint: idx == 1 ? _ep : jpc.endpoints[1], + connection: jpc + }, originalEvent); + } + + if (idx == 1) + _jsPlumb.anchorManager.updateOtherEndpoint(jpc.sourceId, jpc.suspendedElementId, jpc.targetId, jpc); + else + _jsPlumb.anchorManager.sourceChanged(jpc.suspendedEndpoint.elementId, jpc.sourceId, jpc); + + // when makeSource has uniqueEndpoint:true, we want to create connections with new endpoints + // that are subsequently deleted. So makeSource sets `finalEndpoint`, which is the Endpoint to + // which the connection should be attached. The `detachFromConnection` call below results in the + // temporary endpoint being cleaned up. + if (jpc.endpoints[0].finalEndpoint) { + var _toDelete = jpc.endpoints[0]; + _toDelete.detachFromConnection(jpc); + jpc.endpoints[0] = jpc.endpoints[0].finalEndpoint; + jpc.endpoints[0].addConnection(jpc); + } + + // if optionalData was given, merge it onto the connection's data. + if (jsPlumbUtil.isObject(optionalData)) { + jpc.mergeData(optionalData); + } + + // finalise will inform the anchor manager and also add to + // connectionsByScope if necessary. + // TODO if this is not set to true, then dragging a connection's target to a new + // target causes the connection to be forgotten. however if it IS set to true, then + // the opposite happens: dragging by source causes the connection to get forgotten + // about and then if you delete it jsplumb breaks. + _jsPlumb.finaliseConnection(jpc, null, originalEvent/*, true*/); + jpc.setHover(false); + + }.bind(this); + + var dontContinueFunction = function () { + // otherwise just put it back on the endpoint it was on before the drag. + if (jpc.suspendedEndpoint) { + jpc.endpoints[idx] = jpc.suspendedEndpoint; + jpc.setHover(false); + jpc._forceDetach = true; + if (idx === 0) { + jpc.source = jpc.suspendedEndpoint.element; + jpc.sourceId = jpc.suspendedEndpoint.elementId; + } else { + jpc.target = jpc.suspendedEndpoint.element; + jpc.targetId = jpc.suspendedEndpoint.elementId; + } + jpc.suspendedEndpoint.addConnection(jpc); + + _jsPlumb.repaint(jpc.sourceId); + jpc._forceDetach = false; + } + }; + +// -------------------------------------- + // now check beforeDrop. this will be available only on Endpoints that are setup to + // have a beforeDrop condition (although, secretly, under the hood all Endpoints and + // the Connection have them, because they are on jsPlumbUIComponent. shhh!), because + // it only makes sense to have it on a target endpoint. + _doContinue = _doContinue && dhParams.isDropAllowed(jpc.sourceId, jpc.targetId, jpc.scope, jpc, _ep);// && jpc.pending; + + if (_doContinue) { + continueFunction(_doContinue); + return true; + } + else { + dontContinueFunction(); + } + } + + if (dhParams.maybeCleanup) dhParams.maybeCleanup(_ep); + + _jsPlumb.currentlyDragging = false; + }; + }; +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for Connections. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://jsplumb.org + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, + _jp = root.jsPlumb, + _ju = root.jsPlumbUtil; + + + var makeConnector = function (_jsPlumb, renderMode, connectorName, connectorArgs, forComponent) { + if (!_jsPlumb.Defaults.DoNotThrowErrors && jsPlumb.Connectors[renderMode][connectorName] == null) + throw { msg: "jsPlumb: unknown connector type '" + connectorName + "'" }; + + return new _jp.Connectors[renderMode][connectorName](connectorArgs, forComponent); + }, + _makeAnchor = function (anchorParams, elementId, _jsPlumb) { + return (anchorParams) ? _jsPlumb.makeAnchor(anchorParams, elementId, _jsPlumb) : null; + }, + _updateConnectedClass = function (conn, element, _jsPlumb, remove) { + if (element != null) { + element._jsPlumbConnections = element._jsPlumbConnections || {}; + if (remove) + delete element._jsPlumbConnections[conn.id]; + else + element._jsPlumbConnections[conn.id] = true; + + if (_ju.isEmpty(element._jsPlumbConnections)) { + _jsPlumb.removeClass(element, _jsPlumb.connectedClass); + } + else + _jsPlumb.addClass(element, _jsPlumb.connectedClass); + } + }; + + _jp.Connection = function (params) { + var _newEndpoint = params.newEndpoint; + + this.id = params.id; + this.connector = null; + this.idPrefix = "_jsplumb_c_"; + this.defaultLabelLocation = 0.5; + this.defaultOverlayKeys = ["Overlays", "ConnectionOverlays"]; + // if a new connection is the result of moving some existing connection, params.previousConnection + // will have that Connection in it. listeners for the jsPlumbConnection event can look for that + // member and take action if they need to. + this.previousConnection = params.previousConnection; + this.source = _jp.getElement(params.source); + this.target = _jp.getElement(params.target); + // sourceEndpoint and targetEndpoint override source/target, if they are present. but + // source is not overridden if the Endpoint has declared it is not the final target of a connection; + // instead we use the source that the Endpoint declares will be the final source element. + if (params.sourceEndpoint) this.source = params.sourceEndpoint.getElement(); + if (params.targetEndpoint) this.target = params.targetEndpoint.getElement(); + + _jp.OverlayCapableJsPlumbUIComponent.apply(this, arguments); + + this.sourceId = this._jsPlumb.instance.getId(this.source); + this.targetId = this._jsPlumb.instance.getId(this.target); + this.scope = params.scope; // scope may have been passed in to the connect call. if it wasn't, we will pull it from the source endpoint, after having initialised the endpoints. + this.endpoints = []; + this.endpointStyles = []; + + var _jsPlumb = this._jsPlumb.instance; + + _jsPlumb.manage(this.sourceId, this.source); + _jsPlumb.manage(this.targetId, this.target); + + this._jsPlumb.visible = true; + this._jsPlumb.editable = params.editable === true; + this._jsPlumb.params = { + cssClass: params.cssClass, + container: params.container, + "pointer-events": params["pointer-events"], + editorParams: params.editorParams, + overlays: params.overlays + }; + this._jsPlumb.lastPaintedAt = null; + + // listen to mouseover and mouseout events passed from the container delegate. + this.bind("mouseover", function () { + this.setHover(true); + }.bind(this)); + this.bind("mouseout", function () { + this.setHover(false); + }.bind(this)); + +// INITIALISATION CODE + + this.makeEndpoint = function (isSource, el, elId, ep) { + elId = elId || this._jsPlumb.instance.getId(el); + return this.prepareEndpoint(_jsPlumb, _newEndpoint, this, ep, isSource ? 0 : 1, params, el, elId); + }; + + var eS = this.makeEndpoint(true, this.source, this.sourceId, params.sourceEndpoint), + eT = this.makeEndpoint(false, this.target, this.targetId, params.targetEndpoint); + + if (eS) _ju.addToList(params.endpointsByElement, this.sourceId, eS); + if (eT) _ju.addToList(params.endpointsByElement, this.targetId, eT); + // if scope not set, set it to be the scope for the source endpoint. + if (!this.scope) this.scope = this.endpoints[0].scope; + + // if explicitly told to (or not to) delete endpoints on detach, override endpoint's preferences + if (params.deleteEndpointsOnDetach != null) { + this.endpoints[0]._deleteOnDetach = params.deleteEndpointsOnDetach; + this.endpoints[1]._deleteOnDetach = params.deleteEndpointsOnDetach; + } + else { + // otherwise, unless the endpoints say otherwise, mark them for deletion. + if (!this.endpoints[0]._doNotDeleteOnDetach) this.endpoints[0]._deleteOnDetach = true; + if (!this.endpoints[1]._doNotDeleteOnDetach) this.endpoints[1]._deleteOnDetach = true; + } + +// -------------------------- DEFAULT TYPE --------------------------------------------- + + // DETACHABLE + var _detachable = _jsPlumb.Defaults.ConnectionsDetachable; + if (params.detachable === false) _detachable = false; + if (this.endpoints[0].connectionsDetachable === false) _detachable = false; + if (this.endpoints[1].connectionsDetachable === false) _detachable = false; + // REATTACH + var _reattach = params.reattach || this.endpoints[0].reattachConnections || this.endpoints[1].reattachConnections || _jsPlumb.Defaults.ReattachConnections; + + this.appendToDefaultType({ + detachable: _detachable, + rettach: _reattach, + paintStyle:this.endpoints[0].connectorStyle || this.endpoints[1].connectorStyle || params.paintStyle || _jsPlumb.Defaults.PaintStyle || jsPlumb.Defaults.PaintStyle, + hoverPaintStyle:this.endpoints[0].connectorHoverStyle || this.endpoints[1].connectorHoverStyle || params.hoverPaintStyle || _jsPlumb.Defaults.HoverPaintStyle || jsPlumb.Defaults.HoverPaintStyle + }); + + + var _suspendedAt = _jsPlumb.getSuspendedAt(); + if (!_jsPlumb.isSuspendDrawing()) { + // paint the endpoints + var myInfo = _jsPlumb.getCachedData(this.sourceId), + myOffset = myInfo.o, myWH = myInfo.s, + otherInfo = _jsPlumb.getCachedData(this.targetId), + otherOffset = otherInfo.o, + otherWH = otherInfo.s, + initialTimestamp = _suspendedAt || _jsPlumb.timestamp(), + anchorLoc = this.endpoints[0].anchor.compute({ + xy: [ myOffset.left, myOffset.top ], wh: myWH, element: this.endpoints[0], + elementId: this.endpoints[0].elementId, + txy: [ otherOffset.left, otherOffset.top ], twh: otherWH, tElement: this.endpoints[1], + timestamp: initialTimestamp + }); + + this.endpoints[0].paint({ anchorLoc: anchorLoc, timestamp: initialTimestamp }); + + anchorLoc = this.endpoints[1].anchor.compute({ + xy: [ otherOffset.left, otherOffset.top ], wh: otherWH, element: this.endpoints[1], + elementId: this.endpoints[1].elementId, + txy: [ myOffset.left, myOffset.top ], twh: myWH, tElement: this.endpoints[0], + timestamp: initialTimestamp + }); + this.endpoints[1].paint({ anchorLoc: anchorLoc, timestamp: initialTimestamp }); + } + + this.getTypeDescriptor = function () { + return "connection"; + }; + this.getAttachedElements = function () { + return this.endpoints; + }; + + this.isDetachable = function () { + return this._jsPlumb.detachable === true; + }; + this.setDetachable = function (detachable) { + this._jsPlumb.detachable = detachable === true; + }; + this.isReattach = function () { + return this._jsPlumb.reattach === true || this.endpoints[0].reattachConnections === true || this.endpoints[1].reattachConnections === true; + }; + this.setReattach = function (reattach) { + this._jsPlumb.reattach = reattach === true; + }; + +// END INITIALISATION CODE + + +// COST + DIRECTIONALITY + // if cost not supplied, try to inherit from source endpoint + this._jsPlumb.cost = params.cost || this.endpoints[0].getConnectionCost(); + this._jsPlumb.directed = params.directed; + // inherit directed flag if set no source endpoint + if (params.directed == null) this._jsPlumb.directed = this.endpoints[0].areConnectionsDirected(); +// END COST + DIRECTIONALITY + +// PARAMETERS + // merge all the parameters objects into the connection. parameters set + // on the connection take precedence; then source endpoint params, then + // finally target endpoint params. + var _p = jsPlumb.extend({}, this.endpoints[1].getParameters()); + _jp.extend(_p, this.endpoints[0].getParameters()); + _jp.extend(_p, this.getParameters()); + this.setParameters(_p); +// END PARAMETERS + +// PAINTING + + this.setConnector(this.endpoints[0].connector || this.endpoints[1].connector || params.connector || _jsPlumb.Defaults.Connector || _jp.Defaults.Connector, true); + var data = params.data == null || !jsPlumbUtil.isObject(params.data) ? {} : params.data; + this.getData = function() { return data; }; + this.setData = function(d) { data = d || {}; }; + this.mergeData = function(d) { data = jsPlumb.extend(data, d); }; + + // the very last thing we do is apply types, if there are any. + var _types = [ "default", params.type, this.endpoints[0].connectionType, this.endpoints[1].connectionType ].join(" "); + if (/[^\s]/.test(_types)) + this.addType(_types, params.data, true); + + this.updateConnectedClass(); + +// END PAINTING + }; + + _ju.extend(_jp.Connection, _jp.OverlayCapableJsPlumbUIComponent, { + applyType: function (t, doNotRepaint, typeMap) { + + // none of these things result in the creation of objects so can be ignored. + if (t.detachable != null) this.setDetachable(t.detachable); + if (t.reattach != null) this.setReattach(t.reattach); + if (t.scope) this.scope = t.scope; + + if (t.cssClass != null && this.canvas) this._jsPlumb.instance.addClass(this.canvas, t.cssClass); + + var _anchors = null; + // this also results in the creation of objects. + if (t.anchor) { + // note that even if the param was anchor, we store `anchors`. + _anchors = this.getCachedTypeItem("anchors", typeMap.anchor); + if (_anchors == null) { + _anchors = [ this._jsPlumb.instance.makeAnchor(t.anchor), this._jsPlumb.instance.makeAnchor(t.anchor) ]; + this.cacheTypeItem("anchors", _anchors, typeMap.anchor); + } + } + else if (t.anchors) { + _anchors = this.getCachedTypeItem("anchors", typeMap.anchors); + if (_anchors == null) { + _anchors = [ + this._jsPlumb.instance.makeAnchor(t.anchors[0]), + this._jsPlumb.instance.makeAnchor(t.anchors[1]) + ]; + this.cacheTypeItem("anchors", _anchors, typeMap.anchors); + } + } + if (_anchors != null) { + this.endpoints[0].anchor = _anchors[0]; + this.endpoints[1].anchor = _anchors[1]; + } + + _jp.OverlayCapableJsPlumbUIComponent.applyType(this, t); + }, + addClass: function (c, informEndpoints) { + if (informEndpoints) { + this.endpoints[0].addClass(c); + this.endpoints[1].addClass(c); + if (this.suspendedEndpoint) this.suspendedEndpoint.addClass(c); + } + if (this.connector) { + this.connector.addClass(c); + } + }, + removeClass: function (c, informEndpoints) { + if (informEndpoints) { + this.endpoints[0].removeClass(c); + this.endpoints[1].removeClass(c); + if (this.suspendedEndpoint) this.suspendedEndpoint.removeClass(c); + } + if (this.connector) { + this.connector.removeClass(c); + } + }, + isVisible: function () { + return this._jsPlumb.visible; + }, + setVisible: function (v) { + this._jsPlumb.visible = v; + if (this.connector) + this.connector.setVisible(v); + this.repaint(); + }, + cleanup: function () { + this.updateConnectedClass(true); + this.endpoints = null; + this.source = null; + this.target = null; + if (this.connector != null) { + this.connector.cleanup(true); + this.connector.destroy(true); + } + this.connector = null; + }, + updateConnectedClass:function(remove) { + _updateConnectedClass(this, this.source, this._jsPlumb.instance, remove); + _updateConnectedClass(this, this.target, this._jsPlumb.instance, remove); + }, + setHover: function (state) { + if (this.connector && this._jsPlumb && !this._jsPlumb.instance.isConnectionBeingDragged()) { + this.connector.setHover(state); + root.jsPlumb[state ? "addClass" : "removeClass"](this.source, this._jsPlumb.instance.hoverSourceClass); + root.jsPlumb[state ? "addClass" : "removeClass"](this.target, this._jsPlumb.instance.hoverTargetClass); + } + }, + getUuids:function() { + return [ this.endpoints[0].getUuid(), this.endpoints[1].getUuid() ]; + }, + getCost: function () { + return this._jsPlumb.cost; + }, + setCost: function (c) { + this._jsPlumb.cost = c; + }, + isDirected: function () { + return this._jsPlumb.directed === true; + }, + getConnector: function () { + return this.connector; + }, + prepareConnector:function(connectorSpec, typeId) { + var connectorArgs = { + _jsPlumb: this._jsPlumb.instance, + cssClass: this._jsPlumb.params.cssClass, + container: this._jsPlumb.params.container, + "pointer-events": this._jsPlumb.params["pointer-events"] + }, + renderMode = this._jsPlumb.instance.getRenderMode(), + connector; + + if (_ju.isString(connectorSpec)) + connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec, connectorArgs, this); // lets you use a string as shorthand. + else if (_ju.isArray(connectorSpec)) { + if (connectorSpec.length == 1) + connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec[0], connectorArgs, this); + else + connector = makeConnector(this._jsPlumb.instance, renderMode, connectorSpec[0], _ju.merge(connectorSpec[1], connectorArgs), this); + } + if (typeId != null) connector.typeId = typeId; + return connector; + }, + setPreparedConnector: function(connector, doNotRepaint, doNotChangeListenerComponent, typeId) { + + var previous; + // the connector will not be cleaned up if it was set as part of a type, because `typeId` will be set on it + // and we havent passed in `true` for "force" here. + if (this.connector != null) { + previous = this.connector; + this.connector.cleanup(); + this.connector.destroy(); + } + + this.connector = connector; + if (typeId) { + this.cacheTypeItem("connector", connector, typeId); + } + + this.canvas = this.connector.canvas; + this.bgCanvas = this.connector.bgCanvas; + + // new: instead of binding listeners per connector, we now just have one delegate on the container. + // so for that handler we set the connection as the '_jsPlumb' member of the canvas element, and + // bgCanvas, if it exists, which it does right now in the VML renderer, so it won't from v 2.0.0 onwards. + if (this.canvas) this.canvas._jsPlumb = this; + if (this.bgCanvas) this.bgCanvas._jsPlumb = this; + + if (previous != null) { + var o = this.getOverlays(); + for (var i = 0; i < o.length; i++) { + if (o[i].transfer) o[i].transfer(this.connector); + } + } + + if (!doNotChangeListenerComponent) this.setListenerComponent(this.connector); + if (!doNotRepaint) this.repaint(); + }, + setConnector: function (connectorSpec, doNotRepaint, doNotChangeListenerComponent, typeId) { + var connector = this.prepareConnector(connectorSpec, typeId); + this.setPreparedConnector(connector, doNotRepaint, doNotChangeListenerComponent, typeId); + }, + paint: function (params) { + + if (!this._jsPlumb.instance.isSuspendDrawing() && this._jsPlumb.visible) { + params = params || {}; + var timestamp = params.timestamp, + // if the moving object is not the source we must transpose the two references. + swap = false, + tId = swap ? this.sourceId : this.targetId, sId = swap ? this.targetId : this.sourceId, + tIdx = swap ? 0 : 1, sIdx = swap ? 1 : 0; + + if (timestamp == null || timestamp != this._jsPlumb.lastPaintedAt) { + var sourceInfo = this._jsPlumb.instance.updateOffset({elId:sId}).o, + targetInfo = this._jsPlumb.instance.updateOffset({elId:tId}).o, + sE = this.endpoints[sIdx], tE = this.endpoints[tIdx]; + + var sAnchorP = sE.anchor.getCurrentLocation({xy: [sourceInfo.left, sourceInfo.top], wh: [sourceInfo.width, sourceInfo.height], element: sE, timestamp: timestamp}), + tAnchorP = tE.anchor.getCurrentLocation({xy: [targetInfo.left, targetInfo.top], wh: [targetInfo.width, targetInfo.height], element: tE, timestamp: timestamp}); + + this.connector.resetBounds(); + + this.connector.compute({ + sourcePos: sAnchorP, + targetPos: tAnchorP, + sourceEndpoint: this.endpoints[sIdx], + targetEndpoint: this.endpoints[tIdx], + lineWidth: this._jsPlumb.paintStyleInUse.lineWidth, + sourceInfo: sourceInfo, + targetInfo: targetInfo + }); + + var overlayExtents = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity }; + + // compute overlays. we do this first so we can get their placements, and adjust the + // container if needs be (if an overlay would be clipped) + for (var i in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays.hasOwnProperty(i)) { + var o = this._jsPlumb.overlays[i]; + if (o.isVisible()) { + this._jsPlumb.overlayPlacements[i] = o.draw(this.connector, this._jsPlumb.paintStyleInUse, this.getAbsoluteOverlayPosition(o)); + overlayExtents.minX = Math.min(overlayExtents.minX, this._jsPlumb.overlayPlacements[i].minX); + overlayExtents.maxX = Math.max(overlayExtents.maxX, this._jsPlumb.overlayPlacements[i].maxX); + overlayExtents.minY = Math.min(overlayExtents.minY, this._jsPlumb.overlayPlacements[i].minY); + overlayExtents.maxY = Math.max(overlayExtents.maxY, this._jsPlumb.overlayPlacements[i].maxY); + } + } + } + + var lineWidth = parseFloat(this._jsPlumb.paintStyleInUse.lineWidth || 1) / 2, + outlineWidth = parseFloat(this._jsPlumb.paintStyleInUse.lineWidth || 0), + extents = { + xmin: Math.min(this.connector.bounds.minX - (lineWidth + outlineWidth), overlayExtents.minX), + ymin: Math.min(this.connector.bounds.minY - (lineWidth + outlineWidth), overlayExtents.minY), + xmax: Math.max(this.connector.bounds.maxX + (lineWidth + outlineWidth), overlayExtents.maxX), + ymax: Math.max(this.connector.bounds.maxY + (lineWidth + outlineWidth), overlayExtents.maxY) + }; + // paint the connector. + this.connector.paint(this._jsPlumb.paintStyleInUse, null, extents); + // and then the overlays + for (var j in this._jsPlumb.overlays) { + if (this._jsPlumb.overlays.hasOwnProperty(j)) { + var p = this._jsPlumb.overlays[j]; + if (p.isVisible()) { + p.paint(this._jsPlumb.overlayPlacements[j], extents); + } + } + } + } + this._jsPlumb.lastPaintedAt = timestamp; + } + }, + repaint: function (params) { + params = params || {}; + this.paint({ elId: this.sourceId, recalc: !(params.recalc === false), timestamp: params.timestamp}); + }, + prepareEndpoint: function (_jsPlumb, _newEndpoint, conn, existing, index, params, element, elementId) { + var e; + if (existing) { + conn.endpoints[index] = existing; + existing.addConnection(conn); + } else { + if (!params.endpoints) params.endpoints = [ null, null ]; + var ep = params.endpoints[index] || params.endpoint || _jsPlumb.Defaults.Endpoints[index] || jsPlumb.Defaults.Endpoints[index] || _jsPlumb.Defaults.Endpoint || jsPlumb.Defaults.Endpoint; + if (!params.endpointStyles) params.endpointStyles = [ null, null ]; + if (!params.endpointHoverStyles) params.endpointHoverStyles = [ null, null ]; + var es = params.endpointStyles[index] || params.endpointStyle || _jsPlumb.Defaults.EndpointStyles[index] || jsPlumb.Defaults.EndpointStyles[index] || _jsPlumb.Defaults.EndpointStyle || jsPlumb.Defaults.EndpointStyle; + // Endpoints derive their fillStyle from the connector's strokeStyle, if no fillStyle was specified. + if (es.fillStyle == null && params.paintStyle != null) + es.fillStyle = params.paintStyle.strokeStyle; + + if (es.outlineColor == null && params.paintStyle != null) + es.outlineColor = params.paintStyle.outlineColor; + if (es.outlineWidth == null && params.paintStyle != null) + es.outlineWidth = params.paintStyle.outlineWidth; + + var ehs = params.endpointHoverStyles[index] || params.endpointHoverStyle || _jsPlumb.Defaults.EndpointHoverStyles[index] || jsPlumb.Defaults.EndpointHoverStyles[index] || _jsPlumb.Defaults.EndpointHoverStyle || jsPlumb.Defaults.EndpointHoverStyle; + // endpoint hover fill style is derived from connector's hover stroke style + if (params.hoverPaintStyle != null) { + if (ehs == null) ehs = {}; + if (ehs.fillStyle == null) { + ehs.fillStyle = params.hoverPaintStyle.strokeStyle; + } + } + var a = params.anchors ? params.anchors[index] : + params.anchor ? params.anchor : + _makeAnchor(_jsPlumb.Defaults.Anchors[index], elementId, _jsPlumb) || + _makeAnchor(_jp.Defaults.Anchors[index], elementId, _jsPlumb) || + _makeAnchor(_jsPlumb.Defaults.Anchor, elementId, _jsPlumb) || + _makeAnchor(_jp.Defaults.Anchor, elementId, _jsPlumb), + u = params.uuids ? params.uuids[index] : null; + + e = _newEndpoint({ + paintStyle: es, hoverPaintStyle: ehs, endpoint: ep, connections: [ conn ], + uuid: u, anchor: a, source: element, scope: params.scope, + reattach: params.reattach || _jsPlumb.Defaults.ReattachConnections, + detachable: params.detachable || _jsPlumb.Defaults.ConnectionsDetachable + }); + conn.endpoints[index] = e; + + if (params.drawEndpoints === false) e.setVisible(false, true, true); + + } + return e; + } + + }); // END Connection class +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for creating and manipulating anchors. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + + var root = this, + _ju = root.jsPlumbUtil, + _jp = root.jsPlumb; + + // + // manages anchors for all elements. + // + _jp.AnchorManager = function (params) { + var _amEndpoints = {}, + continuousAnchorLocations = {}, + userDefinedContinuousAnchorLocations = {}, + continuousAnchorOrientations = {}, + Orientation = { HORIZONTAL: "horizontal", VERTICAL: "vertical", DIAGONAL: "diagonal", IDENTITY: "identity" }, + axes = ["left", "top", "right", "bottom"], + connectionsByElementId = {}, + self = this, + anchorLists = {}, + jsPlumbInstance = params.jsPlumbInstance, + floatingConnections = {}, + calculateOrientation = function (sourceId, targetId, sd, td, sourceAnchor, targetAnchor) { + + if (sourceId === targetId) return { + orientation: Orientation.IDENTITY, + a: ["top", "top"] + }; + + var theta = Math.atan2((td.centery - sd.centery), (td.centerx - sd.centerx)), + theta2 = Math.atan2((sd.centery - td.centery), (sd.centerx - td.centerx)); + +// -------------------------------------------------------------------------------------- + + // improved face calculation. get midpoints of each face for source and target, then put in an array with all combinations of + // source/target faces. sort this array by distance between midpoints. the entry at index 0 is our preferred option. we can + // go through the array one by one until we find an entry in which each requested face is supported. + var candidates = [], midpoints = { }; + (function (types, dim) { + for (var i = 0; i < types.length; i++) { + midpoints[types[i]] = { + "left": [ dim[i].left, dim[i].centery ], + "right": [ dim[i].right, dim[i].centery ], + "top": [ dim[i].centerx, dim[i].top ], + "bottom": [ dim[i].centerx , dim[i].bottom] + }; + } + })([ "source", "target" ], [ sd, td ]); + + for (var sf = 0; sf < axes.length; sf++) { + for (var tf = 0; tf < axes.length; tf++) { + if (sf != tf) { + candidates.push({ + source: axes[sf], + target: axes[tf], + dist: Biltong.lineLength(midpoints.source[axes[sf]], midpoints.target[axes[tf]]) + }); + } + } + } + + candidates.sort(function (a, b) { + return a.dist < b.dist ? -1 : a.dist > b.dist ? 1 : 0; + }); + + // now go through this list and try to get an entry that satisfies both (there will be one, unless one of the anchors + // declares no available faces) + var sourceEdge = candidates[0].source, targetEdge = candidates[0].target; + for (var i = 0; i < candidates.length; i++) { + + if (!sourceAnchor.isContinuous || sourceAnchor.isEdgeSupported(candidates[i].source)) + sourceEdge = candidates[i].source; + else + sourceEdge = null; + + if (!targetAnchor.isContinuous || targetAnchor.isEdgeSupported(candidates[i].target)) + targetEdge = candidates[i].target; + else { + targetEdge = null; + } + + if (sourceEdge != null && targetEdge != null) break; + } + +// -------------------------------------------------------------------------------------- + + return { + a: [ sourceEdge, targetEdge ], + theta: theta, + theta2: theta2 + }; + }, + // used by placeAnchors function + placeAnchorsOnLine = function (desc, elementDimensions, elementPosition, connections, horizontal, otherMultiplier, reverse) { + var a = [], step = elementDimensions[horizontal ? 0 : 1] / (connections.length + 1); + + for (var i = 0; i < connections.length; i++) { + var val = (i + 1) * step, other = otherMultiplier * elementDimensions[horizontal ? 1 : 0]; + if (reverse) + val = elementDimensions[horizontal ? 0 : 1] - val; + + var dx = (horizontal ? val : other), x = elementPosition[0] + dx, xp = dx / elementDimensions[0], + dy = (horizontal ? other : val), y = elementPosition[1] + dy, yp = dy / elementDimensions[1]; + + a.push([ x, y, xp, yp, connections[i][1], connections[i][2] ]); + } + + return a; + }, + // used by edgeSortFunctions + currySort = function (reverseAngles) { + return function (a, b) { + var r = true; + if (reverseAngles) { + r = a[0][0] < b[0][0]; + } + else { + r = a[0][0] > b[0][0]; + } + return r === false ? -1 : 1; + }; + }, + // used by edgeSortFunctions + leftSort = function (a, b) { + // first get adjusted values + var p1 = a[0][0] < 0 ? -Math.PI - a[0][0] : Math.PI - a[0][0], + p2 = b[0][0] < 0 ? -Math.PI - b[0][0] : Math.PI - b[0][0]; + if (p1 > p2) return 1; + else return a[0][1] > b[0][1] ? 1 : -1; + }, + // used by placeAnchors + edgeSortFunctions = { + "top": function (a, b) { + return a[0] > b[0] ? 1 : -1; + }, + "right": currySort(true), + "bottom": currySort(true), + "left": leftSort + }, + // used by placeAnchors + _sortHelper = function (_array, _fn) { + return _array.sort(_fn); + }, + // used by AnchorManager.redraw + placeAnchors = function (elementId, _anchorLists) { + var cd = jsPlumbInstance.getCachedData(elementId), sS = cd.s, sO = cd.o, + placeSomeAnchors = function (desc, elementDimensions, elementPosition, unsortedConnections, isHorizontal, otherMultiplier, orientation) { + if (unsortedConnections.length > 0) { + var sc = _sortHelper(unsortedConnections, edgeSortFunctions[desc]), // puts them in order based on the target element's pos on screen + reverse = desc === "right" || desc === "top", + anchors = placeAnchorsOnLine(desc, elementDimensions, + elementPosition, sc, + isHorizontal, otherMultiplier, reverse); + + // takes a computed anchor position and adjusts it for parent offset and scroll, then stores it. + var _setAnchorLocation = function (endpoint, anchorPos) { + continuousAnchorLocations[endpoint.id] = [ anchorPos[0], anchorPos[1], anchorPos[2], anchorPos[3] ]; + continuousAnchorOrientations[endpoint.id] = orientation; + }; + + for (var i = 0; i < anchors.length; i++) { + var c = anchors[i][4], weAreSource = c.endpoints[0].elementId === elementId, weAreTarget = c.endpoints[1].elementId === elementId; + if (weAreSource) + _setAnchorLocation(c.endpoints[0], anchors[i]); + else if (weAreTarget) + _setAnchorLocation(c.endpoints[1], anchors[i]); + } + } + }; + + placeSomeAnchors("bottom", sS, [sO.left, sO.top], _anchorLists.bottom, true, 1, [0, 1]); + placeSomeAnchors("top", sS, [sO.left, sO.top], _anchorLists.top, true, 0, [0, -1]); + placeSomeAnchors("left", sS, [sO.left, sO.top], _anchorLists.left, false, 0, [-1, 0]); + placeSomeAnchors("right", sS, [sO.left, sO.top], _anchorLists.right, false, 1, [1, 0]); + }; + + this.reset = function () { + _amEndpoints = {}; + connectionsByElementId = {}; + anchorLists = {}; + }; + this.addFloatingConnection = function (key, conn) { + floatingConnections[key] = conn; + }; + this.removeFloatingConnection = function (key) { + delete floatingConnections[key]; + }; + this.newConnection = function (conn) { + var sourceId = conn.sourceId, targetId = conn.targetId, + ep = conn.endpoints, + doRegisterTarget = true, + registerConnection = function (otherIndex, otherEndpoint, otherAnchor, elId, c) { + if ((sourceId == targetId) && otherAnchor.isContinuous) { + // remove the target endpoint's canvas. we dont need it. + conn._jsPlumb.instance.removeElement(ep[1].canvas); + doRegisterTarget = false; + } + _ju.addToList(connectionsByElementId, elId, [c, otherEndpoint, otherAnchor.constructor == _jp.DynamicAnchor]); + }; + + registerConnection(0, ep[0], ep[0].anchor, targetId, conn); + if (doRegisterTarget) + registerConnection(1, ep[1], ep[1].anchor, sourceId, conn); + }; + var removeEndpointFromAnchorLists = function (endpoint) { + (function (list, eId) { + if (list) { // transient anchors dont get entries in this list. + var f = function (e) { + return e[4] == eId; + }; + _ju.removeWithFunction(list.top, f); + _ju.removeWithFunction(list.left, f); + _ju.removeWithFunction(list.bottom, f); + _ju.removeWithFunction(list.right, f); + } + })(anchorLists[endpoint.elementId], endpoint.id); + }; + this.connectionDetached = function (connInfo) { + var connection = connInfo.connection || connInfo, + sourceId = connInfo.sourceId, + targetId = connInfo.targetId, + ep = connection.endpoints, + removeConnection = function (otherIndex, otherEndpoint, otherAnchor, elId, c) { + if (otherAnchor != null && otherAnchor.constructor == _jp.FloatingAnchor) { + // no-op + } + else { + _ju.removeWithFunction(connectionsByElementId[elId], function (_c) { + return _c[0].id == c.id; + }); + } + }; + + removeConnection(1, ep[1], ep[1].anchor, sourceId, connection); + removeConnection(0, ep[0], ep[0].anchor, targetId, connection); + + // remove from anchorLists + removeEndpointFromAnchorLists(connection.endpoints[0]); + removeEndpointFromAnchorLists(connection.endpoints[1]); + + self.redraw(connection.sourceId); + self.redraw(connection.targetId); + }; + this.add = function (endpoint, elementId) { + _ju.addToList(_amEndpoints, elementId, endpoint); + }; + this.changeId = function (oldId, newId) { + connectionsByElementId[newId] = connectionsByElementId[oldId]; + _amEndpoints[newId] = _amEndpoints[oldId]; + delete connectionsByElementId[oldId]; + delete _amEndpoints[oldId]; + }; + this.getConnectionsFor = function (elementId) { + return connectionsByElementId[elementId] || []; + }; + this.getEndpointsFor = function (elementId) { + return _amEndpoints[elementId] || []; + }; + this.deleteEndpoint = function (endpoint) { + _ju.removeWithFunction(_amEndpoints[endpoint.elementId], function (e) { + return e.id == endpoint.id; + }); + removeEndpointFromAnchorLists(endpoint); + }; + this.clearFor = function (elementId) { + delete _amEndpoints[elementId]; + _amEndpoints[elementId] = []; + }; + // updates the given anchor list by either updating an existing anchor's info, or adding it. this function + // also removes the anchor from its previous list, if the edge it is on has changed. + // all connections found along the way (those that are connected to one of the faces this function + // operates on) are added to the connsToPaint list, as are their endpoints. in this way we know to repaint + // them wthout having to calculate anything else about them. + var _updateAnchorList = function (lists, theta, order, conn, aBoolean, otherElId, idx, reverse, edgeId, elId, connsToPaint, endpointsToPaint) { + // first try to find the exact match, but keep track of the first index of a matching element id along the way.s + var exactIdx = -1, + firstMatchingElIdx = -1, + endpoint = conn.endpoints[idx], + endpointId = endpoint.id, + oIdx = [1, 0][idx], + values = [ + [ theta, order ], + conn, + aBoolean, + otherElId, + endpointId + ], + listToAddTo = lists[edgeId], + listToRemoveFrom = endpoint._continuousAnchorEdge ? lists[endpoint._continuousAnchorEdge] : null, + i, + candidate; + + if (listToRemoveFrom) { + var rIdx = _ju.findWithFunction(listToRemoveFrom, function (e) { + return e[4] == endpointId; + }); + if (rIdx != -1) { + listToRemoveFrom.splice(rIdx, 1); + // get all connections from this list + for (i = 0; i < listToRemoveFrom.length; i++) { + candidate = listToRemoveFrom[i][1]; + _ju.addWithFunction(connsToPaint, candidate, function (c) { + return c.id == candidate.id; + }); + _ju.addWithFunction(endpointsToPaint, listToRemoveFrom[i][1].endpoints[idx], function (e) { + return e.id == candidate.endpoints[idx].id; + }); + _ju.addWithFunction(endpointsToPaint, listToRemoveFrom[i][1].endpoints[oIdx], function (e) { + return e.id == candidate.endpoints[oIdx].id; + }); + } + } + } + + for (i = 0; i < listToAddTo.length; i++) { + candidate = listToAddTo[i][1]; + if (params.idx == 1 && listToAddTo[i][3] === otherElId && firstMatchingElIdx == -1) + firstMatchingElIdx = i; + _ju.addWithFunction(connsToPaint, candidate, function (c) { + return c.id == candidate.id; + }); + _ju.addWithFunction(endpointsToPaint, listToAddTo[i][1].endpoints[idx], function (e) { + return e.id == candidate.endpoints[idx].id; + }); + _ju.addWithFunction(endpointsToPaint, listToAddTo[i][1].endpoints[oIdx], function (e) { + return e.id == candidate.endpoints[oIdx].id; + }); + } + if (exactIdx != -1) { + listToAddTo[exactIdx] = values; + } + else { + var insertIdx = reverse ? firstMatchingElIdx != -1 ? firstMatchingElIdx : 0 : listToAddTo.length; // of course we will get this from having looked through the array shortly. + listToAddTo.splice(insertIdx, 0, values); + } + + // store this for next time. + endpoint._continuousAnchorEdge = edgeId; + }; + + // + // find the entry in an endpoint's list for this connection and update its target endpoint + // with the current target in the connection. + // + // + this.updateOtherEndpoint = function (elId, oldTargetId, newTargetId, connection) { + var sIndex = _ju.findWithFunction(connectionsByElementId[elId], function (i) { + return i[0].id === connection.id; + }), + tIndex = _ju.findWithFunction(connectionsByElementId[oldTargetId], function (i) { + return i[0].id === connection.id; + }); + + // update or add data for source + if (sIndex != -1) { + connectionsByElementId[elId][sIndex][0] = connection; + connectionsByElementId[elId][sIndex][1] = connection.endpoints[1]; + connectionsByElementId[elId][sIndex][2] = connection.endpoints[1].anchor.constructor == _jp.DynamicAnchor; + } + + // remove entry for previous target (if there) + if (tIndex > -1) { + connectionsByElementId[oldTargetId].splice(tIndex, 1); + // add entry for new target + _ju.addToList(connectionsByElementId, newTargetId, [connection, connection.endpoints[0], connection.endpoints[0].anchor.constructor == _jp.DynamicAnchor]); + } + + connection.updateConnectedClass(); + }; + + // + // notification that the connection given has changed source from the originalId to the newId. + // This involves: + // 1. removing the connection from the list of connections stored for the originalId + // 2. updating the source information for the target of the connection + // 3. re-registering the connection in connectionsByElementId with the newId + // + this.sourceChanged = function (originalId, newId, connection) { + if (originalId !== newId) { + // remove the entry that points from the old source to the target + _ju.removeWithFunction(connectionsByElementId[originalId], function (info) { + return info[0].id === connection.id; + }); + // find entry for target and update it + var tIdx = _ju.findWithFunction(connectionsByElementId[connection.targetId], function (i) { + return i[0].id === connection.id; + }); + if (tIdx > -1) { + connectionsByElementId[connection.targetId][tIdx][0] = connection; + connectionsByElementId[connection.targetId][tIdx][1] = connection.endpoints[0]; + connectionsByElementId[connection.targetId][tIdx][2] = connection.endpoints[0].anchor.constructor == _jp.DynamicAnchor; + } + // add entry for new source + _ju.addToList(connectionsByElementId, newId, [connection, connection.endpoints[1], connection.endpoints[1].anchor.constructor == _jp.DynamicAnchor]); + + connection.updateConnectedClass(); + } + }; + + // + // moves the given endpoint from `currentId` to `element`. + // This involves: + // + // 1. changing the key in _amEndpoints under which the endpoint is stored + // 2. changing the source or target values in all of the endpoint's connections + // 3. changing the array in connectionsByElementId in which the endpoint's connections + // are stored (done by either sourceChanged or updateOtherEndpoint) + // + this.rehomeEndpoint = function (ep, currentId, element) { + var eps = _amEndpoints[currentId] || [], + elementId = jsPlumbInstance.getId(element); + + if (elementId !== currentId) { + var idx = _ju.indexOf(eps, ep); + if (idx > -1) { + var _ep = eps.splice(idx, 1)[0]; + self.add(_ep, elementId); + } + } + + for (var i = 0; i < ep.connections.length; i++) { + if (ep.connections[i].sourceId == currentId) { + ep.connections[i].sourceId = ep.elementId; + ep.connections[i].source = ep.element; + self.sourceChanged(currentId, ep.elementId, ep.connections[i]); + } + else if (ep.connections[i].targetId == currentId) { + ep.connections[i].targetId = ep.elementId; + ep.connections[i].target = ep.element; + self.updateOtherEndpoint(ep.connections[i].sourceId, currentId, ep.elementId, ep.connections[i]); + } + } + }; + + this.redraw = function (elementId, ui, timestamp, offsetToUI, clearEdits, doNotRecalcEndpoint) { + + if (!jsPlumbInstance.isSuspendDrawing()) { + // get all the endpoints for this element + var ep = _amEndpoints[elementId] || [], + endpointConnections = connectionsByElementId[elementId] || [], + connectionsToPaint = [], + endpointsToPaint = [], + anchorsToUpdate = []; + + timestamp = timestamp || jsPlumbInstance.timestamp(); + // offsetToUI are values that would have been calculated in the dragManager when registering + // an endpoint for an element that had a parent (somewhere in the hierarchy) that had been + // registered as draggable. + offsetToUI = offsetToUI || {left: 0, top: 0}; + if (ui) { + ui = { + left: ui.left + offsetToUI.left, + top: ui.top + offsetToUI.top + }; + } + + // valid for one paint cycle. + var myOffset = jsPlumbInstance.updateOffset({ elId: elementId, offset: ui, recalc: false, timestamp: timestamp }), + orientationCache = {}; + + // actually, first we should compute the orientation of this element to all other elements to which + // this element is connected with a continuous anchor (whether both ends of the connection have + // a continuous anchor or just one) + + for (var i = 0; i < endpointConnections.length; i++) { + var conn = endpointConnections[i][0], + sourceId = conn.sourceId, + targetId = conn.targetId, + sourceContinuous = conn.endpoints[0].anchor.isContinuous, + targetContinuous = conn.endpoints[1].anchor.isContinuous; + + if (sourceContinuous || targetContinuous) { + var oKey = sourceId + "_" + targetId, + o = orientationCache[oKey], + oIdx = conn.sourceId == elementId ? 1 : 0; + + if (sourceContinuous && !anchorLists[sourceId]) anchorLists[sourceId] = { top: [], right: [], bottom: [], left: [] }; + if (targetContinuous && !anchorLists[targetId]) anchorLists[targetId] = { top: [], right: [], bottom: [], left: [] }; + + if (elementId != targetId) jsPlumbInstance.updateOffset({ elId: targetId, timestamp: timestamp }); + if (elementId != sourceId) jsPlumbInstance.updateOffset({ elId: sourceId, timestamp: timestamp }); + + var td = jsPlumbInstance.getCachedData(targetId), + sd = jsPlumbInstance.getCachedData(sourceId); + + if (targetId == sourceId && (sourceContinuous || targetContinuous)) { + // here we may want to improve this by somehow determining the face we'd like + // to put the connector on. ideally, when drawing, the face should be calculated + // by determining which face is closest to the point at which the mouse button + // was released. for now, we're putting it on the top face. + _updateAnchorList( + anchorLists[sourceId], + -Math.PI / 2, + 0, + conn, + false, + targetId, + 0, false, "top", sourceId, connectionsToPaint, endpointsToPaint); + } + else { + if (!o) { + o = calculateOrientation(sourceId, targetId, sd.o, td.o, conn.endpoints[0].anchor, conn.endpoints[1].anchor); + orientationCache[oKey] = o; + // this would be a performance enhancement, but the computed angles need to be clamped to + //the (-PI/2 -> PI/2) range in order for the sorting to work properly. + /* orientationCache[oKey2] = { + orientation:o.orientation, + a:[o.a[1], o.a[0]], + theta:o.theta + Math.PI, + theta2:o.theta2 + Math.PI + };*/ + } + if (sourceContinuous) _updateAnchorList(anchorLists[sourceId], o.theta, 0, conn, false, targetId, 0, false, o.a[0], sourceId, connectionsToPaint, endpointsToPaint); + if (targetContinuous) _updateAnchorList(anchorLists[targetId], o.theta2, -1, conn, true, sourceId, 1, true, o.a[1], targetId, connectionsToPaint, endpointsToPaint); + } + + if (sourceContinuous) _ju.addWithFunction(anchorsToUpdate, sourceId, function (a) { + return a === sourceId; + }); + if (targetContinuous) _ju.addWithFunction(anchorsToUpdate, targetId, function (a) { + return a === targetId; + }); + _ju.addWithFunction(connectionsToPaint, conn, function (c) { + return c.id == conn.id; + }); + if ((sourceContinuous && oIdx === 0) || (targetContinuous && oIdx === 1)) + _ju.addWithFunction(endpointsToPaint, conn.endpoints[oIdx], function (e) { + return e.id == conn.endpoints[oIdx].id; + }); + } + } + + // place Endpoints whose anchors are continuous but have no Connections + for (i = 0; i < ep.length; i++) { + if (ep[i].connections.length === 0 && ep[i].anchor.isContinuous) { + if (!anchorLists[elementId]) anchorLists[elementId] = { top: [], right: [], bottom: [], left: [] }; + _updateAnchorList(anchorLists[elementId], -Math.PI / 2, 0, {endpoints: [ep[i], ep[i]], paint: function () { + }}, false, elementId, 0, false, ep[i].anchor.getDefaultFace(), elementId, connectionsToPaint, endpointsToPaint); + _ju.addWithFunction(anchorsToUpdate, elementId, function (a) { + return a === elementId; + }); + } + } + + + // now place all the continuous anchors we need to; + for (i = 0; i < anchorsToUpdate.length; i++) { + placeAnchors(anchorsToUpdate[i], anchorLists[anchorsToUpdate[i]]); + } + + // now that continuous anchors have been placed, paint all the endpoints for this element + // TODO performance: add the endpoint ids to a temp array, and then when iterating in the next + // loop, check that we didn't just paint that endpoint. we can probably shave off a few more milliseconds this way. + for (i = 0; i < ep.length; i++) { + ep[i].paint({ timestamp: timestamp, offset: myOffset, dimensions: myOffset.s, recalc: doNotRecalcEndpoint !== true }); + } + + // ... and any other endpoints we came across as a result of the continuous anchors. + for (i = 0; i < endpointsToPaint.length; i++) { + var cd = jsPlumbInstance.getCachedData(endpointsToPaint[i].elementId); + endpointsToPaint[i].paint({ timestamp: timestamp, offset: cd, dimensions: cd.s }); + } + + // paint all the standard and "dynamic connections", which are connections whose other anchor is + // static and therefore does need to be recomputed; we make sure that happens only one time. + + // TODO we could have compiled a list of these in the first pass through connections; might save some time. + for (i = 0; i < endpointConnections.length; i++) { + var otherEndpoint = endpointConnections[i][1]; + if (otherEndpoint.anchor.constructor == _jp.DynamicAnchor) { + otherEndpoint.paint({ elementWithPrecedence: elementId, timestamp: timestamp }); + _ju.addWithFunction(connectionsToPaint, endpointConnections[i][0], function (c) { + return c.id == endpointConnections[i][0].id; + }); + // all the connections for the other endpoint now need to be repainted + for (var k = 0; k < otherEndpoint.connections.length; k++) { + if (otherEndpoint.connections[k] !== endpointConnections[i][0]) + _ju.addWithFunction(connectionsToPaint, otherEndpoint.connections[k], function (c) { + return c.id == otherEndpoint.connections[k].id; + }); + } + } else if (otherEndpoint.anchor.constructor == _jp.Anchor) { + _ju.addWithFunction(connectionsToPaint, endpointConnections[i][0], function (c) { + return c.id == endpointConnections[i][0].id; + }); + } + } + + // paint current floating connection for this element, if there is one. + var fc = floatingConnections[elementId]; + if (fc) + fc.paint({timestamp: timestamp, recalc: false, elId: elementId}); + + // paint all the connections + for (i = 0; i < connectionsToPaint.length; i++) { + connectionsToPaint[i].paint({elId: elementId, timestamp: timestamp, recalc: false, clearEdits: clearEdits}); + } + } + }; + + var ContinuousAnchor = function (anchorParams) { + _ju.EventGenerator.apply(this); + this.type = "Continuous"; + this.isDynamic = true; + this.isContinuous = true; + var faces = anchorParams.faces || ["top", "right", "bottom", "left"], + clockwise = !(anchorParams.clockwise === false), + availableFaces = { }, + opposites = { "top": "bottom", "right": "left", "left": "right", "bottom": "top" }, + clockwiseOptions = { "top": "right", "right": "bottom", "left": "top", "bottom": "left" }, + antiClockwiseOptions = { "top": "left", "right": "top", "left": "bottom", "bottom": "right" }, + secondBest = clockwise ? clockwiseOptions : antiClockwiseOptions, + lastChoice = clockwise ? antiClockwiseOptions : clockwiseOptions, + cssClass = anchorParams.cssClass || ""; + + for (var i = 0; i < faces.length; i++) { + availableFaces[faces[i]] = true; + } + + this.getDefaultFace = function () { + return faces.length === 0 ? "top" : faces[0]; + }; + + // if the given edge is supported, returns it. otherwise looks for a substitute that _is_ + // supported. if none supported we also return the request edge. + this.verifyEdge = function (edge) { + if (availableFaces[edge]) return edge; + else if (availableFaces[opposites[edge]]) return opposites[edge]; + else if (availableFaces[secondBest[edge]]) return secondBest[edge]; + else if (availableFaces[lastChoice[edge]]) return lastChoice[edge]; + return edge; // we have to give them something. + }; + + this.isEdgeSupported = function (edge) { + return availableFaces[edge] === true; + }; + + this.compute = function (params) { + return userDefinedContinuousAnchorLocations[params.element.id] || continuousAnchorLocations[params.element.id] || [0, 0]; + }; + this.getCurrentLocation = function (params) { + return userDefinedContinuousAnchorLocations[params.element.id] || continuousAnchorLocations[params.element.id] || [0, 0]; + }; + this.getOrientation = function (endpoint) { + return continuousAnchorOrientations[endpoint.id] || [0, 0]; + }; + this.clearUserDefinedLocation = function () { + delete userDefinedContinuousAnchorLocations[anchorParams.elementId]; + }; + this.setUserDefinedLocation = function (loc) { + userDefinedContinuousAnchorLocations[anchorParams.elementId] = loc; + }; + this.getCssClass = function () { + return cssClass; + }; + }; + + // continuous anchors + jsPlumbInstance.continuousAnchorFactory = { + get: function (params) { + return new ContinuousAnchor(params); + }, + clear: function (elementId) { + delete userDefinedContinuousAnchorLocations[elementId]; + delete continuousAnchorLocations[elementId]; + } + }; + }; + + /** + * Anchors model a position on some element at which an Endpoint may be located. They began as a first class citizen of jsPlumb, ie. a user + * was required to create these themselves, but over time this has been replaced by the concept of referring to them either by name (eg. "TopMiddle"), + * or by an array describing their coordinates (eg. [ 0, 0.5, 0, -1 ], which is the same as "TopMiddle"). jsPlumb now handles all of the + * creation of Anchors without user intervention. + */ + _jp.Anchor = function (params) { + this.x = params.x || 0; + this.y = params.y || 0; + this.elementId = params.elementId; + this.cssClass = params.cssClass || ""; + this.userDefinedLocation = null; + this.orientation = params.orientation || [ 0, 0 ]; + this.lastReturnValue = null; + this.offsets = params.offsets || [ 0, 0 ]; + this.timestamp = null; + + _ju.EventGenerator.apply(this); + + this.compute = function (params) { + + var xy = params.xy, wh = params.wh, timestamp = params.timestamp; + + if (params.clearUserDefinedLocation) + this.userDefinedLocation = null; + + if (timestamp && timestamp === self.timestamp) + return this.lastReturnValue; + + if (this.userDefinedLocation != null) { + this.lastReturnValue = this.userDefinedLocation; + } + else { + this.lastReturnValue = [ xy[0] + (this.x * wh[0]) + this.offsets[0], xy[1] + (this.y * wh[1]) + this.offsets[1] ]; + } + + this.timestamp = timestamp; + return this.lastReturnValue; + }; + + this.getCurrentLocation = function (params) { + return (this.lastReturnValue == null || (params.timestamp != null && this.timestamp != params.timestamp)) ? this.compute(params) : this.lastReturnValue; + }; + }; + _ju.extend(_jp.Anchor, _ju.EventGenerator, { + equals: function (anchor) { + if (!anchor) return false; + var ao = anchor.getOrientation(), + o = this.getOrientation(); + return this.x == anchor.x && this.y == anchor.y && this.offsets[0] == anchor.offsets[0] && this.offsets[1] == anchor.offsets[1] && o[0] == ao[0] && o[1] == ao[1]; + }, + getUserDefinedLocation: function () { + return this.userDefinedLocation; + }, + setUserDefinedLocation: function (l) { + this.userDefinedLocation = l; + }, + clearUserDefinedLocation: function () { + this.userDefinedLocation = null; + }, + getOrientation: function () { + return this.orientation; + }, + getCssClass: function () { + return this.cssClass; + } + }); + + /** + * An Anchor that floats. its orientation is computed dynamically from + * its position relative to the anchor it is floating relative to. It is used when creating + * a connection through drag and drop. + * + * TODO FloatingAnchor could totally be refactored to extend Anchor just slightly. + */ + _jp.FloatingAnchor = function (params) { + + _jp.Anchor.apply(this, arguments); + + // this is the anchor that this floating anchor is referenced to for + // purposes of calculating the orientation. + var ref = params.reference, + // the canvas this refers to. + refCanvas = params.referenceCanvas, + size = _jp.getSize(refCanvas), + // these are used to store the current relative position of our + // anchor wrt the reference anchor. they only indicate + // direction, so have a value of 1 or -1 (or, very rarely, 0). these + // values are written by the compute method, and read + // by the getOrientation method. + xDir = 0, yDir = 0, + // temporary member used to store an orientation when the floating + // anchor is hovering over another anchor. + orientation = null, + _lastResult = null; + + // clear from parent. we want floating anchor orientation to always be computed. + this.orientation = null; + + // set these to 0 each; they are used by certain types of connectors in the loopback case, + // when the connector is trying to clear the element it is on. but for floating anchor it's not + // very important. + this.x = 0; + this.y = 0; + + this.isFloating = true; + + this.compute = function (params) { + var xy = params.xy, + result = [ xy[0] + (size[0] / 2), xy[1] + (size[1] / 2) ]; // return origin of the element. we may wish to improve this so that any object can be the drag proxy. + _lastResult = result; + return result; + }; + + this.getOrientation = function (_endpoint) { + if (orientation) return orientation; + else { + var o = ref.getOrientation(_endpoint); + // here we take into account the orientation of the other + // anchor: if it declares zero for some direction, we declare zero too. this might not be the most awesome. perhaps we can come + // up with a better way. it's just so that the line we draw looks like it makes sense. maybe this wont make sense. + return [ Math.abs(o[0]) * xDir * -1, + Math.abs(o[1]) * yDir * -1 ]; + } + }; + + /** + * notification the endpoint associated with this anchor is hovering + * over another anchor; we want to assume that anchor's orientation + * for the duration of the hover. + */ + this.over = function (anchor, endpoint) { + orientation = anchor.getOrientation(endpoint); + }; + + /** + * notification the endpoint associated with this anchor is no + * longer hovering over another anchor; we should resume calculating + * orientation as we normally do. + */ + this.out = function () { + orientation = null; + }; + + this.getCurrentLocation = function (params) { + return _lastResult == null ? this.compute(params) : _lastResult; + }; + }; + _ju.extend(_jp.FloatingAnchor, _jp.Anchor); + + var _convertAnchor = function (anchor, jsPlumbInstance, elementId) { + return anchor.constructor == _jp.Anchor ? anchor : jsPlumbInstance.makeAnchor(anchor, elementId, jsPlumbInstance); + }; + + /* + * A DynamicAnchor is an Anchor that contains a list of other Anchors, which it cycles + * through at compute time to find the one that is located closest to + * the center of the target element, and returns that Anchor's compute + * method result. this causes endpoints to follow each other with + * respect to the orientation of their target elements, which is a useful + * feature for some applications. + * + */ + _jp.DynamicAnchor = function (params) { + _jp.Anchor.apply(this, arguments); + + this.isDynamic = true; + this.anchors = []; + this.elementId = params.elementId; + this.jsPlumbInstance = params.jsPlumbInstance; + + for (var i = 0; i < params.anchors.length; i++) + this.anchors[i] = _convertAnchor(params.anchors[i], this.jsPlumbInstance, this.elementId); + + this.getAnchors = function () { + return this.anchors; + }; + this.locked = false; + var _curAnchor = this.anchors.length > 0 ? this.anchors[0] : null, + _lastAnchor = _curAnchor, + self = this, + + // helper method to calculate the distance between the centers of the two elements. + _distance = function (anchor, cx, cy, xy, wh) { + var ax = xy[0] + (anchor.x * wh[0]), ay = xy[1] + (anchor.y * wh[1]), + acx = xy[0] + (wh[0] / 2), acy = xy[1] + (wh[1] / 2); + return (Math.sqrt(Math.pow(cx - ax, 2) + Math.pow(cy - ay, 2)) + + Math.sqrt(Math.pow(acx - ax, 2) + Math.pow(acy - ay, 2))); + }, + // default method uses distance between element centers. you can provide your own method in the dynamic anchor + // constructor (and also to jsPlumb.makeDynamicAnchor). the arguments to it are four arrays: + // xy - xy loc of the anchor's element + // wh - anchor's element's dimensions + // txy - xy loc of the element of the other anchor in the connection + // twh - dimensions of the element of the other anchor in the connection. + // anchors - the list of selectable anchors + _anchorSelector = params.selector || function (xy, wh, txy, twh, anchors) { + var cx = txy[0] + (twh[0] / 2), cy = txy[1] + (twh[1] / 2); + var minIdx = -1, minDist = Infinity; + for (var i = 0; i < anchors.length; i++) { + var d = _distance(anchors[i], cx, cy, xy, wh); + if (d < minDist) { + minIdx = i + 0; + minDist = d; + } + } + return anchors[minIdx]; + }; + + this.compute = function (params) { + var xy = params.xy, wh = params.wh, txy = params.txy, twh = params.twh; + + this.timestamp = params.timestamp; + + var udl = self.getUserDefinedLocation(); + if (udl != null) { + return udl; + } + + // if anchor is locked or an opposite element was not given, we + // maintain our state. anchor will be locked + // if it is the source of a drag and drop. + if (this.locked || txy == null || twh == null) + return _curAnchor.compute(params); + else + params.timestamp = null; // otherwise clear this, i think. we want the anchor to compute. + + _curAnchor = _anchorSelector(xy, wh, txy, twh, this.anchors); + this.x = _curAnchor.x; + this.y = _curAnchor.y; + + if (_curAnchor != _lastAnchor) + this.fire("anchorChanged", _curAnchor); + + _lastAnchor = _curAnchor; + + return _curAnchor.compute(params); + }; + + this.getCurrentLocation = function (params) { + return this.getUserDefinedLocation() || (_curAnchor != null ? _curAnchor.getCurrentLocation(params) : null); + }; + + this.getOrientation = function (_endpoint) { + return _curAnchor != null ? _curAnchor.getOrientation(_endpoint) : [ 0, 0 ]; + }; + this.over = function (anchor, endpoint) { + if (_curAnchor != null) _curAnchor.over(anchor, endpoint); + }; + this.out = function () { + if (_curAnchor != null) _curAnchor.out(); + }; + + this.getCssClass = function () { + return (_curAnchor && _curAnchor.getCssClass()) || ""; + }; + }; + _ju.extend(_jp.DynamicAnchor, _jp.Anchor); + +// -------- basic anchors ------------------ + var _curryAnchor = function (x, y, ox, oy, type, fnInit) { + _jp.Anchors[type] = function (params) { + var a = params.jsPlumbInstance.makeAnchor([ x, y, ox, oy, 0, 0 ], params.elementId, params.jsPlumbInstance); + a.type = type; + if (fnInit) fnInit(a, params); + return a; + }; + }; + + _curryAnchor(0.5, 0, 0, -1, "TopCenter"); + _curryAnchor(0.5, 1, 0, 1, "BottomCenter"); + _curryAnchor(0, 0.5, -1, 0, "LeftMiddle"); + _curryAnchor(1, 0.5, 1, 0, "RightMiddle"); + + _curryAnchor(0.5, 0, 0, -1, "Top"); + _curryAnchor(0.5, 1, 0, 1, "Bottom"); + _curryAnchor(0, 0.5, -1, 0, "Left"); + _curryAnchor(1, 0.5, 1, 0, "Right"); + _curryAnchor(0.5, 0.5, 0, 0, "Center"); + _curryAnchor(1, 0, 0, -1, "TopRight"); + _curryAnchor(1, 1, 0, 1, "BottomRight"); + _curryAnchor(0, 0, 0, -1, "TopLeft"); + _curryAnchor(0, 1, 0, 1, "BottomLeft"); + +// ------- dynamic anchors ------------------- + + // default dynamic anchors chooses from Top, Right, Bottom, Left + _jp.Defaults.DynamicAnchors = function (params) { + return params.jsPlumbInstance.makeAnchors(["TopCenter", "RightMiddle", "BottomCenter", "LeftMiddle"], params.elementId, params.jsPlumbInstance); + }; + + // default dynamic anchors bound to name 'AutoDefault' + _jp.Anchors.AutoDefault = function (params) { + var a = params.jsPlumbInstance.makeDynamicAnchor(_jp.Defaults.DynamicAnchors(params)); + a.type = "AutoDefault"; + return a; + }; + +// ------- continuous anchors ------------------- + + var _curryContinuousAnchor = function (type, faces) { + _jp.Anchors[type] = function (params) { + var a = params.jsPlumbInstance.makeAnchor(["Continuous", { faces: faces }], params.elementId, params.jsPlumbInstance); + a.type = type; + return a; + }; + }; + + _jp.Anchors.Continuous = function (params) { + return params.jsPlumbInstance.continuousAnchorFactory.get(params); + }; + + _curryContinuousAnchor("ContinuousLeft", ["left"]); + _curryContinuousAnchor("ContinuousTop", ["top"]); + _curryContinuousAnchor("ContinuousBottom", ["bottom"]); + _curryContinuousAnchor("ContinuousRight", ["right"]); + +// ------- position assign anchors ------------------- + + // this anchor type lets you assign the position at connection time. + _curryAnchor(0, 0, 0, 0, "Assign", function (anchor, params) { + // find what to use as the "position finder". the user may have supplied a String which represents + // the id of a position finder in jsPlumb.AnchorPositionFinders, or the user may have supplied the + // position finder as a function. we find out what to use and then set it on the anchor. + var pf = params.position || "Fixed"; + anchor.positionFinder = pf.constructor == String ? params.jsPlumbInstance.AnchorPositionFinders[pf] : pf; + // always set the constructor params; the position finder might need them later (the Grid one does, + // for example) + anchor.constructorParams = params; + }); + + // these are the default anchor positions finders, which are used by the makeTarget function. supplying + // a position finder argument to that function allows you to specify where the resulting anchor will + // be located + jsPlumbInstance.prototype.AnchorPositionFinders = { + "Fixed": function (dp, ep, es) { + return [ (dp.left - ep.left) / es[0], (dp.top - ep.top) / es[1] ]; + }, + "Grid": function (dp, ep, es, params) { + var dx = dp.left - ep.left, dy = dp.top - ep.top, + gx = es[0] / (params.grid[0]), gy = es[1] / (params.grid[1]), + mx = Math.floor(dx / gx), my = Math.floor(dy / gy); + return [ ((mx * gx) + (gx / 2)) / es[0], ((my * gy) + (gy / 2)) / es[1] ]; + } + }; + +// ------- perimeter anchors ------------------- + + _jp.Anchors.Perimeter = function (params) { + params = params || {}; + var anchorCount = params.anchorCount || 60, + shape = params.shape; + + if (!shape) throw new Error("no shape supplied to Perimeter Anchor type"); + + var _circle = function () { + var r = 0.5, step = Math.PI * 2 / anchorCount, current = 0, a = []; + for (var i = 0; i < anchorCount; i++) { + var x = r + (r * Math.sin(current)), + y = r + (r * Math.cos(current)); + a.push([ x, y, 0, 0 ]); + current += step; + } + return a; + }, + _path = function (segments) { + var anchorsPerFace = anchorCount / segments.length, a = [], + _computeFace = function (x1, y1, x2, y2, fractionalLength) { + anchorsPerFace = anchorCount * fractionalLength; + var dx = (x2 - x1) / anchorsPerFace, dy = (y2 - y1) / anchorsPerFace; + for (var i = 0; i < anchorsPerFace; i++) { + a.push([ + x1 + (dx * i), + y1 + (dy * i), + 0, + 0 + ]); + } + }; + + for (var i = 0; i < segments.length; i++) + _computeFace.apply(null, segments[i]); + + return a; + }, + _shape = function (faces) { + var s = []; + for (var i = 0; i < faces.length; i++) { + s.push([faces[i][0], faces[i][1], faces[i][2], faces[i][3], 1 / faces.length]); + } + return _path(s); + }, + _rectangle = function () { + return _shape([ + [ 0, 0, 1, 0 ], + [ 1, 0, 1, 1 ], + [ 1, 1, 0, 1 ], + [ 0, 1, 0, 0 ] + ]); + }; + + var _shapes = { + "Circle": _circle, + "Ellipse": _circle, + "Diamond": function () { + return _shape([ + [ 0.5, 0, 1, 0.5 ], + [ 1, 0.5, 0.5, 1 ], + [ 0.5, 1, 0, 0.5 ], + [ 0, 0.5, 0.5, 0 ] + ]); + }, + "Rectangle": _rectangle, + "Square": _rectangle, + "Triangle": function () { + return _shape([ + [ 0.5, 0, 1, 1 ], + [ 1, 1, 0, 1 ], + [ 0, 1, 0.5, 0] + ]); + }, + "Path": function (params) { + var points = params.points, p = [], tl = 0; + for (var i = 0; i < points.length - 1; i++) { + var l = Math.sqrt(Math.pow(points[i][2] - points[i][0]) + Math.pow(points[i][3] - points[i][1])); + tl += l; + p.push([points[i][0], points[i][1], points[i + 1][0], points[i + 1][1], l]); + } + for (var j = 0; j < p.length; j++) { + p[j][4] = p[j][4] / tl; + } + return _path(p); + } + }, + _rotate = function (points, amountInDegrees) { + var o = [], theta = amountInDegrees / 180 * Math.PI; + for (var i = 0; i < points.length; i++) { + var _x = points[i][0] - 0.5, + _y = points[i][1] - 0.5; + + o.push([ + 0.5 + ((_x * Math.cos(theta)) - (_y * Math.sin(theta))), + 0.5 + ((_x * Math.sin(theta)) + (_y * Math.cos(theta))), + points[i][2], + points[i][3] + ]); + } + return o; + }; + + if (!_shapes[shape]) throw new Error("Shape [" + shape + "] is unknown by Perimeter Anchor type"); + + var da = _shapes[shape](params); + if (params.rotation) da = _rotate(da, params.rotation); + var a = params.jsPlumbInstance.makeDynamicAnchor(da); + a.type = "Perimeter"; + return a; + }; +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the default Connectors, Endpoint and Overlay definitions. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil, _jg = root.Biltong; + + _jp.Segments = { + + /* + * Class: AbstractSegment + * A Connector is made up of 1..N Segments, each of which has a Type, such as 'Straight', 'Arc', + * 'Bezier'. This is new from 1.4.2, and gives us a lot more flexibility when drawing connections: things such + * as rounded corners for flowchart connectors, for example, or a straight line stub for Bezier connections, are + * much easier to do now. + * + * A Segment is responsible for providing coordinates for painting it, and also must be able to report its length. + * + */ + AbstractSegment: function (params) { + this.params = params; + + /** + * Function: findClosestPointOnPath + * Finds the closest point on this segment to the given [x, y], + * returning both the x and y of the point plus its distance from + * the supplied point, and its location along the length of the + * path inscribed by the segment. This implementation returns + * Infinity for distance and null values for everything else; + * subclasses are expected to override. + */ + this.findClosestPointOnPath = function (x, y) { + return { + d: Infinity, + x: null, + y: null, + l: null + }; + }; + + this.getBounds = function () { + return { + minX: Math.min(params.x1, params.x2), + minY: Math.min(params.y1, params.y2), + maxX: Math.max(params.x1, params.x2), + maxY: Math.max(params.y1, params.y2) + }; + }; + }, + Straight: function (params) { + var _super = _jp.Segments.AbstractSegment.apply(this, arguments), + length, m, m2, x1, x2, y1, y2, + _recalc = function () { + length = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)); + m = _jg.gradient({x: x1, y: y1}, {x: x2, y: y2}); + m2 = -1 / m; + }; + + this.type = "Straight"; + + this.getLength = function () { + return length; + }; + this.getGradient = function () { + return m; + }; + + this.getCoordinates = function () { + return { x1: x1, y1: y1, x2: x2, y2: y2 }; + }; + this.setCoordinates = function (coords) { + x1 = coords.x1; + y1 = coords.y1; + x2 = coords.x2; + y2 = coords.y2; + _recalc(); + }; + this.setCoordinates({x1: params.x1, y1: params.y1, x2: params.x2, y2: params.y2}); + + this.getBounds = function () { + return { + minX: Math.min(x1, x2), + minY: Math.min(y1, y2), + maxX: Math.max(x1, x2), + maxY: Math.max(y1, y2) + }; + }; + + /** + * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from + * 0 to 1 inclusive. for the straight line segment this is simple maths. + */ + this.pointOnPath = function (location, absolute) { + if (location === 0 && !absolute) + return { x: x1, y: y1 }; + else if (location == 1 && !absolute) + return { x: x2, y: y2 }; + else { + var l = absolute ? location > 0 ? location : length + location : location * length; + return _jg.pointOnLine({x: x1, y: y1}, {x: x2, y: y2}, l); + } + }; + + /** + * returns the gradient of the segment at the given point - which for us is constant. + */ + this.gradientAtPoint = function (_) { + return m; + }; + + /** + * returns the point on the segment's path that is 'distance' along the length of the path from 'location', where + * 'location' is a decimal from 0 to 1 inclusive, and 'distance' is a number of pixels. + * this hands off to jsPlumbUtil to do the maths, supplying two points and the distance. + */ + this.pointAlongPathFrom = function (location, distance, absolute) { + var p = this.pointOnPath(location, absolute), + farAwayPoint = distance <= 0 ? {x: x1, y: y1} : {x: x2, y: y2 }; + + /* + location == 1 ? { + x:x1 + ((x2 - x1) * 10), + y:y1 + ((y1 - y2) * 10) + } : + */ + + if (distance <= 0 && Math.abs(distance) > 1) distance *= -1; + + return _jg.pointOnLine(p, farAwayPoint, distance); + }; + + // is c between a and b? + var within = function (a, b, c) { + return c >= Math.min(a, b) && c <= Math.max(a, b); + }; + // find which of a and b is closest to c + var closest = function (a, b, c) { + return Math.abs(c - a) < Math.abs(c - b) ? a : b; + }; + + /** + Function: findClosestPointOnPath + Finds the closest point on this segment to [x,y]. See + notes on this method in AbstractSegment. + */ + this.findClosestPointOnPath = function (x, y) { + var out = { + d: Infinity, + x: null, + y: null, + l: null, + x1: x1, + x2: x2, + y1: y1, + y2: y2 + }; + + if (m === 0) { + out.y = y1; + out.x = within(x1, x2, x) ? x : closest(x1, x2, x); + } + else if (m == Infinity || m == -Infinity) { + out.x = x1; + out.y = within(y1, y2, y) ? y : closest(y1, y2, y); + } + else { + // closest point lies on normal from given point to this line. + var b = y1 - (m * x1), + b2 = y - (m2 * x), + // y1 = m.x1 + b and y1 = m2.x1 + b2 + // so m.x1 + b = m2.x1 + b2 + // x1(m - m2) = b2 - b + // x1 = (b2 - b) / (m - m2) + _x1 = (b2 - b) / (m - m2), + _y1 = (m * _x1) + b; + + out.x = within(x1, x2, _x1) ? _x1 : closest(x1, x2, _x1);//_x1; + out.y = within(y1, y2, _y1) ? _y1 : closest(y1, y2, _y1);//_y1; + } + + var fractionInSegment = _jg.lineLength([ out.x, out.y ], [ x1, y1 ]); + out.d = _jg.lineLength([x, y], [out.x, out.y]); + out.l = fractionInSegment / length; + return out; + }; + }, + + /* + Arc Segment. You need to supply: + + r - radius + cx - center x for the arc + cy - center y for the arc + ac - whether the arc is anticlockwise or not. default is clockwise. + + and then either: + + startAngle - startAngle for the arc. + endAngle - endAngle for the arc. + + or: + + x1 - x for start point + y1 - y for start point + x2 - x for end point + y2 - y for end point + + */ + Arc: function (params) { + var _super = _jp.Segments.AbstractSegment.apply(this, arguments), + _calcAngle = function (_x, _y) { + return _jg.theta([params.cx, params.cy], [_x, _y]); + }, + _calcAngleForLocation = function (segment, location) { + if (segment.anticlockwise) { + var sa = segment.startAngle < segment.endAngle ? segment.startAngle + TWO_PI : segment.startAngle, + s = Math.abs(sa - segment.endAngle); + return sa - (s * location); + } + else { + var ea = segment.endAngle < segment.startAngle ? segment.endAngle + TWO_PI : segment.endAngle, + ss = Math.abs(ea - segment.startAngle); + + return segment.startAngle + (ss * location); + } + }, + TWO_PI = 2 * Math.PI; + + this.radius = params.r; + this.anticlockwise = params.ac; + this.type = "Arc"; + + if (params.startAngle && params.endAngle) { + this.startAngle = params.startAngle; + this.endAngle = params.endAngle; + this.x1 = params.cx + (this.radius * Math.cos(params.startAngle)); + this.y1 = params.cy + (this.radius * Math.sin(params.startAngle)); + this.x2 = params.cx + (this.radius * Math.cos(params.endAngle)); + this.y2 = params.cy + (this.radius * Math.sin(params.endAngle)); + } + else { + this.startAngle = _calcAngle(params.x1, params.y1); + this.endAngle = _calcAngle(params.x2, params.y2); + this.x1 = params.x1; + this.y1 = params.y1; + this.x2 = params.x2; + this.y2 = params.y2; + } + + if (this.endAngle < 0) this.endAngle += TWO_PI; + if (this.startAngle < 0) this.startAngle += TWO_PI; + + // segment is used by vml + this.segment = _jg.quadrant([this.x1, this.y1], [this.x2, this.y2]); + + // we now have startAngle and endAngle as positive numbers, meaning the + // absolute difference (|d|) between them is the sweep (s) of this arc, unless the + // arc is 'anticlockwise' in which case 's' is given by 2PI - |d|. + + var ea = this.endAngle < this.startAngle ? this.endAngle + TWO_PI : this.endAngle; + this.sweep = Math.abs(ea - this.startAngle); + if (this.anticlockwise) this.sweep = TWO_PI - this.sweep; + var circumference = 2 * Math.PI * this.radius, + frac = this.sweep / TWO_PI, + length = circumference * frac; + + this.getLength = function () { + return length; + }; + + this.getBounds = function () { + return { + minX: params.cx - params.r, + maxX: params.cx + params.r, + minY: params.cy - params.r, + maxY: params.cy + params.r + }; + }; + + var VERY_SMALL_VALUE = 0.0000000001, + gentleRound = function (n) { + var f = Math.floor(n), r = Math.ceil(n); + if (n - f < VERY_SMALL_VALUE) + return f; + else if (r - n < VERY_SMALL_VALUE) + return r; + return n; + }; + + /** + * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from + * 0 to 1 inclusive. + */ + this.pointOnPath = function (location, absolute) { + + if (location === 0) { + return { x: this.x1, y: this.y1, theta: this.startAngle }; + } + else if (location == 1) { + return { x: this.x2, y: this.y2, theta: this.endAngle }; + } + + if (absolute) { + location = location / length; + } + + var angle = _calcAngleForLocation(this, location), + _x = params.cx + (params.r * Math.cos(angle)), + _y = params.cy + (params.r * Math.sin(angle)); + + return { x: gentleRound(_x), y: gentleRound(_y), theta: angle }; + }; + + /** + * returns the gradient of the segment at the given point. + */ + this.gradientAtPoint = function (location, absolute) { + var p = this.pointOnPath(location, absolute); + var m = _jg.normal([ params.cx, params.cy ], [p.x, p.y ]); + if (!this.anticlockwise && (m == Infinity || m == -Infinity)) m *= -1; + return m; + }; + + this.pointAlongPathFrom = function (location, distance, absolute) { + var p = this.pointOnPath(location, absolute), + arcSpan = distance / circumference * 2 * Math.PI, + dir = this.anticlockwise ? -1 : 1, + startAngle = p.theta + (dir * arcSpan), + startX = params.cx + (this.radius * Math.cos(startAngle)), + startY = params.cy + (this.radius * Math.sin(startAngle)); + + return {x: startX, y: startY}; + }; + }, + + Bezier: function (params) { + this.curve = [ + { x: params.x1, y: params.y1}, + { x: params.cp1x, y: params.cp1y }, + { x: params.cp2x, y: params.cp2y }, + { x: params.x2, y: params.y2 } + ]; + + var _super = _jp.Segments.AbstractSegment.apply(this, arguments); + // although this is not a strictly rigorous determination of bounds + // of a bezier curve, it works for the types of curves that this segment + // type produces. + this.bounds = { + minX: Math.min(params.x1, params.x2, params.cp1x, params.cp2x), + minY: Math.min(params.y1, params.y2, params.cp1y, params.cp2y), + maxX: Math.max(params.x1, params.x2, params.cp1x, params.cp2x), + maxY: Math.max(params.y1, params.y2, params.cp1y, params.cp2y) + }; + + this.type = "Bezier"; + + var _translateLocation = function (_curve, location, absolute) { + if (absolute) + location = root.jsBezier.locationAlongCurveFrom(_curve, location > 0 ? 0 : 1, location); + + return location; + }; + + /** + * returns the point on the segment's path that is 'location' along the length of the path, where 'location' is a decimal from + * 0 to 1 inclusive. + */ + this.pointOnPath = function (location, absolute) { + location = _translateLocation(this.curve, location, absolute); + return root.jsBezier.pointOnCurve(this.curve, location); + }; + + /** + * returns the gradient of the segment at the given point. + */ + this.gradientAtPoint = function (location, absolute) { + location = _translateLocation(this.curve, location, absolute); + return root.jsBezier.gradientAtPoint(this.curve, location); + }; + + this.pointAlongPathFrom = function (location, distance, absolute) { + location = _translateLocation(this.curve, location, absolute); + return root.jsBezier.pointAlongCurveFrom(this.curve, location, distance); + }; + + this.getLength = function () { + return root.jsBezier.getLength(this.curve); + }; + + this.getBounds = function () { + return this.bounds; + }; + } + }; + + /* + Class: AbstractComponent + Superclass for AbstractConnector and AbstractEndpoint. + */ + var AbstractComponent = function () { + this.resetBounds = function () { + this.bounds = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity }; + }; + this.resetBounds(); + }; + + /* + * Class: AbstractConnector + * Superclass for all Connectors; here is where Segments are managed. This is exposed on jsPlumb just so it + * can be accessed from other files. You should not try to instantiate one of these directly. + * + * When this class is asked for a pointOnPath, or gradient etc, it must first figure out which segment to dispatch + * that request to. This is done by keeping track of the total connector length as segments are added, and also + * their cumulative ratios to the total length. Then when the right segment is found it is a simple case of dispatching + * the request to it (and adjusting 'location' so that it is relative to the beginning of that segment.) + */ + _jp.Connectors.AbstractConnector = function (params) { + + AbstractComponent.apply(this, arguments); + + var segments = [], + totalLength = 0, + segmentProportions = [], + segmentProportionalLengths = [], + stub = params.stub || 0, + sourceStub = _ju.isArray(stub) ? stub[0] : stub, + targetStub = _ju.isArray(stub) ? stub[1] : stub, + gap = params.gap || 0, + sourceGap = _ju.isArray(gap) ? gap[0] : gap, + targetGap = _ju.isArray(gap) ? gap[1] : gap, + userProvidedSegments = null, + edited = false, + paintInfo = null; + + // to be overridden by subclasses. + this.getPath = function () { + }; + this.setPath = function (path) { + }; + + /** + * Function: findSegmentForPoint + * Returns the segment that is closest to the given [x,y], + * null if nothing found. This function returns a JS + * object with: + * + * d - distance from segment + * l - proportional location in segment + * x - x point on the segment + * y - y point on the segment + * s - the segment itself. + */ + this.findSegmentForPoint = function (x, y) { + var out = { d: Infinity, s: null, x: null, y: null, l: null }; + for (var i = 0; i < segments.length; i++) { + var _s = segments[i].findClosestPointOnPath(x, y); + if (_s.d < out.d) { + out.d = _s.d; + out.l = _s.l; + out.x = _s.x; + out.y = _s.y; + out.s = segments[i]; + out.x1 = _s.x1; + out.x2 = _s.x2; + out.y1 = _s.y1; + out.y2 = _s.y2; + out.index = i; + } + } + + return out; + }; + + var _updateSegmentProportions = function () { + var curLoc = 0; + for (var i = 0; i < segments.length; i++) { + var sl = segments[i].getLength(); + segmentProportionalLengths[i] = sl / totalLength; + segmentProportions[i] = [curLoc, (curLoc += (sl / totalLength)) ]; + } + }, + + /** + * returns [segment, proportion of travel in segment, segment index] for the segment + * that contains the point which is 'location' distance along the entire path, where + * 'location' is a decimal between 0 and 1 inclusive. in this connector type, paths + * are made up of a list of segments, each of which contributes some fraction to + * the total length. + * From 1.3.10 this also supports the 'absolute' property, which lets us specify a location + * as the absolute distance in pixels, rather than a proportion of the total path. + */ + _findSegmentForLocation = function (location, absolute) { + if (absolute) { + location = location > 0 ? location / totalLength : (totalLength + location) / totalLength; + } + var idx = segmentProportions.length - 1, inSegmentProportion = 1; + for (var i = 0; i < segmentProportions.length; i++) { + if (segmentProportions[i][1] >= location) { + idx = i; + // todo is this correct for all connector path types? + inSegmentProportion = location == 1 ? 1 : location === 0 ? 0 : (location - segmentProportions[i][0]) / segmentProportionalLengths[i]; + break; + } + } + return { segment: segments[idx], proportion: inSegmentProportion, index: idx }; + }, + _addSegment = function (conn, type, params) { + if (params.x1 == params.x2 && params.y1 == params.y2) return; + var s = new _jp.Segments[type](params); + segments.push(s); + totalLength += s.getLength(); + conn.updateBounds(s); + }, + _clearSegments = function () { + totalLength = segments.length = segmentProportions.length = segmentProportionalLengths.length = 0; + }; + + this.setSegments = function (_segs) { + userProvidedSegments = []; + totalLength = 0; + for (var i = 0; i < _segs.length; i++) { + userProvidedSegments.push(_segs[i]); + totalLength += _segs[i].getLength(); + } + }; + + this.getLength = function() { + return totalLength; + }; + + var _prepareCompute = function (params) { + this.lineWidth = params.lineWidth; + var segment = _jg.quadrant(params.sourcePos, params.targetPos), + swapX = params.targetPos[0] < params.sourcePos[0], + swapY = params.targetPos[1] < params.sourcePos[1], + lw = params.lineWidth || 1, + so = params.sourceEndpoint.anchor.getOrientation(params.sourceEndpoint), + to = params.targetEndpoint.anchor.getOrientation(params.targetEndpoint), + x = swapX ? params.targetPos[0] : params.sourcePos[0], + y = swapY ? params.targetPos[1] : params.sourcePos[1], + w = Math.abs(params.targetPos[0] - params.sourcePos[0]), + h = Math.abs(params.targetPos[1] - params.sourcePos[1]); + + // if either anchor does not have an orientation set, we derive one from their relative + // positions. we fix the axis to be the one in which the two elements are further apart, and + // point each anchor at the other element. this is also used when dragging a new connection. + if (so[0] === 0 && so[1] === 0 || to[0] === 0 && to[1] === 0) { + var index = w > h ? 0 : 1, oIndex = [1, 0][index]; + so = []; + to = []; + so[index] = params.sourcePos[index] > params.targetPos[index] ? -1 : 1; + to[index] = params.sourcePos[index] > params.targetPos[index] ? 1 : -1; + so[oIndex] = 0; + to[oIndex] = 0; + } + + var sx = swapX ? w + (sourceGap * so[0]) : sourceGap * so[0], + sy = swapY ? h + (sourceGap * so[1]) : sourceGap * so[1], + tx = swapX ? targetGap * to[0] : w + (targetGap * to[0]), + ty = swapY ? targetGap * to[1] : h + (targetGap * to[1]), + oProduct = ((so[0] * to[0]) + (so[1] * to[1])); + + var result = { + sx: sx, sy: sy, tx: tx, ty: ty, lw: lw, + xSpan: Math.abs(tx - sx), + ySpan: Math.abs(ty - sy), + mx: (sx + tx) / 2, + my: (sy + ty) / 2, + so: so, to: to, x: x, y: y, w: w, h: h, + segment: segment, + startStubX: sx + (so[0] * sourceStub), + startStubY: sy + (so[1] * sourceStub), + endStubX: tx + (to[0] * targetStub), + endStubY: ty + (to[1] * targetStub), + isXGreaterThanStubTimes2: Math.abs(sx - tx) > (sourceStub + targetStub), + isYGreaterThanStubTimes2: Math.abs(sy - ty) > (sourceStub + targetStub), + opposite: oProduct == -1, + perpendicular: oProduct === 0, + orthogonal: oProduct == 1, + sourceAxis: so[0] === 0 ? "y" : "x", + points: [x, y, w, h, sx, sy, tx, ty ] + }; + result.anchorOrientation = result.opposite ? "opposite" : result.orthogonal ? "orthogonal" : "perpendicular"; + return result; + }; + + this.getSegments = function () { + return segments; + }; + + this.updateBounds = function (segment) { + var segBounds = segment.getBounds(); + this.bounds.minX = Math.min(this.bounds.minX, segBounds.minX); + this.bounds.maxX = Math.max(this.bounds.maxX, segBounds.maxX); + this.bounds.minY = Math.min(this.bounds.minY, segBounds.minY); + this.bounds.maxY = Math.max(this.bounds.maxY, segBounds.maxY); + }; + + var dumpSegmentsToConsole = function () { + console.log("SEGMENTS:"); + for (var i = 0; i < segments.length; i++) { + console.log(segments[i].type, segments[i].getLength(), segmentProportions[i]); + } + }; + + this.pointOnPath = function (location, absolute) { + var seg = _findSegmentForLocation(location, absolute); + return seg.segment && seg.segment.pointOnPath(seg.proportion, false) || [0, 0]; + }; + + this.gradientAtPoint = function (location, absolute) { + var seg = _findSegmentForLocation(location, absolute); + return seg.segment && seg.segment.gradientAtPoint(seg.proportion, false) || 0; + }; + + this.pointAlongPathFrom = function (location, distance, absolute) { + var seg = _findSegmentForLocation(location, absolute); + // TODO what happens if this crosses to the next segment? + return seg.segment && seg.segment.pointAlongPathFrom(seg.proportion, distance, false) || [0, 0]; + }; + + this.compute = function (params) { + if (!edited) + paintInfo = _prepareCompute.call(this, params); + + _clearSegments(); + this._compute(paintInfo, params); + this.x = paintInfo.points[0]; + this.y = paintInfo.points[1]; + this.w = paintInfo.points[2]; + this.h = paintInfo.points[3]; + this.segment = paintInfo.segment; + _updateSegmentProportions(); + }; + + return { + addSegment: _addSegment, + prepareCompute: _prepareCompute, + sourceStub: sourceStub, + targetStub: targetStub, + maxStub: Math.max(sourceStub, targetStub), + sourceGap: sourceGap, + targetGap: targetGap, + maxGap: Math.max(sourceGap, targetGap) + }; + }; + _ju.extend(_jp.Connectors.AbstractConnector, AbstractComponent); + + /** + * Class: Connectors.Straight + * The Straight connector draws a simple straight line between the two anchor points. It does not have any constructor parameters. + */ + var Straight = _jp.Connectors.Straight = function () { + this.type = "Straight"; + var _super = _jp.Connectors.AbstractConnector.apply(this, arguments); + + this._compute = function (paintInfo, _) { + _super.addSegment(this, "Straight", {x1: paintInfo.sx, y1: paintInfo.sy, x2: paintInfo.startStubX, y2: paintInfo.startStubY}); + _super.addSegment(this, "Straight", {x1: paintInfo.startStubX, y1: paintInfo.startStubY, x2: paintInfo.endStubX, y2: paintInfo.endStubY}); + _super.addSegment(this, "Straight", {x1: paintInfo.endStubX, y1: paintInfo.endStubY, x2: paintInfo.tx, y2: paintInfo.ty}); + }; + }; + _ju.extend(_jp.Connectors.Straight, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(Straight, "Straight"); + + + // ********************************* END OF CONNECTOR TYPES ******************************************************************* + + // ********************************* ENDPOINT TYPES ******************************************************************* + + _jp.Endpoints.AbstractEndpoint = function (params) { + AbstractComponent.apply(this, arguments); + var compute = this.compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + var out = this._compute.apply(this, arguments); + this.x = out[0]; + this.y = out[1]; + this.w = out[2]; + this.h = out[3]; + this.bounds.minX = this.x; + this.bounds.minY = this.y; + this.bounds.maxX = this.x + this.w; + this.bounds.maxY = this.y + this.h; + return out; + }; + return { + compute: compute, + cssClass: params.cssClass + }; + }; + _ju.extend(_jp.Endpoints.AbstractEndpoint, AbstractComponent); + + /** + * Class: Endpoints.Dot + * A round endpoint, with default radius 10 pixels. + */ + + /** + * Function: Constructor + * + * Parameters: + * + * radius - radius of the endpoint. defaults to 10 pixels. + */ + _jp.Endpoints.Dot = function (params) { + this.type = "Dot"; + var _super = _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + params = params || {}; + this.radius = params.radius || 10; + this.defaultOffset = 0.5 * this.radius; + this.defaultInnerRadius = this.radius / 3; + + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + this.radius = endpointStyle.radius || this.radius; + var x = anchorPoint[0] - this.radius, + y = anchorPoint[1] - this.radius, + w = this.radius * 2, + h = this.radius * 2; + + if (endpointStyle.strokeStyle) { + var lw = endpointStyle.lineWidth || 1; + x -= lw; + y -= lw; + w += (lw * 2); + h += (lw * 2); + } + return [ x, y, w, h, this.radius ]; + }; + }; + _ju.extend(_jp.Endpoints.Dot, _jp.Endpoints.AbstractEndpoint); + + _jp.Endpoints.Rectangle = function (params) { + this.type = "Rectangle"; + var _super = _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + params = params || {}; + this.width = params.width || 20; + this.height = params.height || 20; + + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + var width = endpointStyle.width || this.width, + height = endpointStyle.height || this.height, + x = anchorPoint[0] - (width / 2), + y = anchorPoint[1] - (height / 2); + + return [ x, y, width, height]; + }; + }; + _ju.extend(_jp.Endpoints.Rectangle, _jp.Endpoints.AbstractEndpoint); + + var DOMElementEndpoint = function (params) { + _jp.jsPlumbUIComponent.apply(this, arguments); + this._jsPlumb.displayElements = []; + }; + _ju.extend(DOMElementEndpoint, _jp.jsPlumbUIComponent, { + getDisplayElements: function () { + return this._jsPlumb.displayElements; + }, + appendDisplayElement: function (el) { + this._jsPlumb.displayElements.push(el); + } + }); + + /** + * Class: Endpoints.Image + * Draws an image as the Endpoint. + */ + /** + * Function: Constructor + * + * Parameters: + * + * src - location of the image to use. + + TODO: multiple references to self. not sure quite how to get rid of them entirely. perhaps self = null in the cleanup + function will suffice + + TODO this class still might leak memory. + + */ + _jp.Endpoints.Image = function (params) { + + this.type = "Image"; + DOMElementEndpoint.apply(this, arguments); + _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + + var _onload = params.onload, + src = params.src || params.url, + clazz = params.cssClass ? " " + params.cssClass : ""; + + this._jsPlumb.img = new Image(); + this._jsPlumb.ready = false; + this._jsPlumb.initialized = false; + this._jsPlumb.deleted = false; + this._jsPlumb.widthToUse = params.width; + this._jsPlumb.heightToUse = params.height; + this._jsPlumb.endpoint = params.endpoint; + + this._jsPlumb.img.onload = function () { + if (this._jsPlumb != null) { + this._jsPlumb.ready = true; + this._jsPlumb.widthToUse = this._jsPlumb.widthToUse || this._jsPlumb.img.width; + this._jsPlumb.heightToUse = this._jsPlumb.heightToUse || this._jsPlumb.img.height; + if (_onload) { + _onload(this); + } + } + }.bind(this); + + /* + Function: setImage + Sets the Image to use in this Endpoint. + + Parameters: + img - may be a URL or an Image object + onload - optional; a callback to execute once the image has loaded. + */ + this._jsPlumb.endpoint.setImage = function (_img, onload) { + var s = _img.constructor == String ? _img : _img.src; + _onload = onload; + this._jsPlumb.img.src = s; + + if (this.canvas != null) + this.canvas.setAttribute("src", this._jsPlumb.img.src); + }.bind(this); + + this._jsPlumb.endpoint.setImage(src, _onload); + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + this.anchorPoint = anchorPoint; + if (this._jsPlumb.ready) return [anchorPoint[0] - this._jsPlumb.widthToUse / 2, anchorPoint[1] - this._jsPlumb.heightToUse / 2, + this._jsPlumb.widthToUse, this._jsPlumb.heightToUse]; + else return [0, 0, 0, 0]; + }; + + this.canvas = jsPlumb.createElement("img", { + position:"absolute", + margin:0, + padding:0, + outline:0 + }, this._jsPlumb.instance.endpointClass + clazz); + + if (this._jsPlumb.widthToUse) this.canvas.setAttribute("width", this._jsPlumb.widthToUse); + if (this._jsPlumb.heightToUse) this.canvas.setAttribute("height", this._jsPlumb.heightToUse); + this._jsPlumb.instance.appendElement(this.canvas); + + this.actuallyPaint = function (d, style, anchor) { + if (!this._jsPlumb.deleted) { + if (!this._jsPlumb.initialized) { + this.canvas.setAttribute("src", this._jsPlumb.img.src); + this.appendDisplayElement(this.canvas); + this._jsPlumb.initialized = true; + } + var x = this.anchorPoint[0] - (this._jsPlumb.widthToUse / 2), + y = this.anchorPoint[1] - (this._jsPlumb.heightToUse / 2); + _ju.sizeElement(this.canvas, x, y, this._jsPlumb.widthToUse, this._jsPlumb.heightToUse); + } + }; + + this.paint = function (style, anchor) { + if (this._jsPlumb != null) { // may have been deleted + if (this._jsPlumb.ready) { + this.actuallyPaint(style, anchor); + } + else { + root.setTimeout(function () { + this.paint(style, anchor); + }.bind(this), 200); + } + } + }; + }; + _ju.extend(_jp.Endpoints.Image, [ DOMElementEndpoint, _jp.Endpoints.AbstractEndpoint ], { + cleanup: function (force) { + if (force) { + this._jsPlumb.deleted = true; + if (this.canvas) this.canvas.parentNode.removeChild(this.canvas); + this.canvas = null; + } + } + }); + + /* + * Class: Endpoints.Blank + * An Endpoint that paints nothing (visible) on the screen. Supports cssClass and hoverClass parameters like all Endpoints. + */ + _jp.Endpoints.Blank = function (params) { + var _super = _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + this.type = "Blank"; + DOMElementEndpoint.apply(this, arguments); + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + return [anchorPoint[0], anchorPoint[1], 10, 0]; + }; + + var clazz = params.cssClass ? " " + params.cssClass : ""; + + this.canvas = jsPlumb.createElement("div", { + display: "block", + width: "1px", + height: "1px", + background: "transparent", + position: "absolute" + }, this._jsPlumb.instance.endpointClass + clazz); + + this._jsPlumb.instance.appendElement(this.canvas); + + this.paint = function (style, anchor) { + _ju.sizeElement(this.canvas, this.x, this.y, this.w, this.h); + }; + }; + _ju.extend(_jp.Endpoints.Blank, [_jp.Endpoints.AbstractEndpoint, DOMElementEndpoint], { + cleanup: function () { + if (this.canvas && this.canvas.parentNode) { + this.canvas.parentNode.removeChild(this.canvas); + } + } + }); + + /* + * Class: Endpoints.Triangle + * A triangular Endpoint. + */ + /* + * Function: Constructor + * + * Parameters: + * + * width - width of the triangle's base. defaults to 55 pixels. + * height - height of the triangle from base to apex. defaults to 55 pixels. + */ + _jp.Endpoints.Triangle = function (params) { + this.type = "Triangle"; + _jp.Endpoints.AbstractEndpoint.apply(this, arguments); + params = params || { }; + params.width = params.width || 55; + params.height = params.height || 55; + this.width = params.width; + this.height = params.height; + this._compute = function (anchorPoint, orientation, endpointStyle, connectorPaintStyle) { + var width = endpointStyle.width || self.width, + height = endpointStyle.height || self.height, + x = anchorPoint[0] - (width / 2), + y = anchorPoint[1] - (height / 2); + return [ x, y, width, height ]; + }; + }; +// ********************************* END OF ENDPOINT TYPES ******************************************************************* + + +// ********************************* OVERLAY DEFINITIONS *********************************************************************** + + var AbstractOverlay = _jp.Overlays.AbstractOverlay = function (params) { + this.visible = true; + this.isAppendedAtTopLevel = true; + this.component = params.component; + this.loc = params.location == null ? 0.5 : params.location; + this.endpointLoc = params.endpointLocation == null ? [ 0.5, 0.5] : params.endpointLocation; + }; + AbstractOverlay.prototype = { + cleanup: function (force) { + if (force) { + this.component = null; + this.canvas = null; + this.endpointLoc = null; + } + }, + reattach:function(instance) { + + }, + setVisible: function (val) { + this.visible = val; + this.component.repaint(); + }, + isVisible: function () { + return this.visible; + }, + hide: function () { + this.setVisible(false); + }, + show: function () { + this.setVisible(true); + }, + incrementLocation: function (amount) { + this.loc += amount; + this.component.repaint(); + }, + setLocation: function (l) { + this.loc = l; + this.component.repaint(); + }, + getLocation: function () { + return this.loc; + }, + updateFrom:function() { } + }; + + + /* + * Class: Overlays.Arrow + * + * An arrow overlay, defined by four points: the head, the two sides of the tail, and a 'foldback' point at some distance along the length + * of the arrow that lines from each tail point converge into. The foldback point is defined using a decimal that indicates some fraction + * of the length of the arrow and has a default value of 0.623. A foldback point value of 1 would mean that the arrow had a straight line + * across the tail. + */ + /* + * Function: Constructor + * + * Parameters: + * + * length - distance in pixels from head to tail baseline. default 20. + * width - width in pixels of the tail baseline. default 20. + * fillStyle - style to use when filling the arrow. defaults to "black". + * strokeStyle - style to use when stroking the arrow. defaults to null, which means the arrow is not stroked. + * lineWidth - line width to use when stroking the arrow. defaults to 1, but only used if strokeStyle is not null. + * foldback - distance (as a decimal from 0 to 1 inclusive) along the length of the arrow marking the point the tail points should fold back to. defaults to 0.623. + * location - distance (as a decimal from 0 to 1 inclusive) marking where the arrow should sit on the connector. defaults to 0.5. + * direction - indicates the direction the arrow points in. valid values are -1 and 1; 1 is default. + */ + _jp.Overlays.Arrow = function (params) { + this.type = "Arrow"; + AbstractOverlay.apply(this, arguments); + this.isAppendedAtTopLevel = false; + params = params || {}; + + this.length = params.length || 20; + this.width = params.width || 20; + this.id = params.id; + var direction = (params.direction || 1) < 0 ? -1 : 1, + paintStyle = params.paintStyle || { lineWidth: 1 }, + // how far along the arrow the lines folding back in come to. default is 62.3%. + foldback = params.foldback || 0.623; + + this.computeMaxSize = function () { + return self.width * 1.5; + }; + + this.draw = function (component, currentConnectionPaintStyle) { + + var hxy, mid, txy, tail, cxy; + if (component.pointAlongPathFrom) { + + if (_ju.isString(this.loc) || this.loc > 1 || this.loc < 0) { + var l = parseInt(this.loc, 10), + fromLoc = this.loc < 0 ? 1 : 0; + hxy = component.pointAlongPathFrom(fromLoc, l, false); + mid = component.pointAlongPathFrom(fromLoc, l - (direction * this.length / 2), false); + txy = _jg.pointOnLine(hxy, mid, this.length); + } + else if (this.loc == 1) { + hxy = component.pointOnPath(this.loc); + mid = component.pointAlongPathFrom(this.loc, -(this.length)); + txy = _jg.pointOnLine(hxy, mid, this.length); + + if (direction == -1) { + var _ = txy; + txy = hxy; + hxy = _; + } + } + else if (this.loc === 0) { + txy = component.pointOnPath(this.loc); + mid = component.pointAlongPathFrom(this.loc, this.length); + hxy = _jg.pointOnLine(txy, mid, this.length); + if (direction == -1) { + var __ = txy; + txy = hxy; + hxy = __; + } + } + else { + hxy = component.pointAlongPathFrom(this.loc, direction * this.length / 2); + mid = component.pointOnPath(this.loc); + txy = _jg.pointOnLine(hxy, mid, this.length); + } + + tail = _jg.perpendicularLineTo(hxy, txy, this.width); + cxy = _jg.pointOnLine(hxy, txy, foldback * this.length); + + var d = { hxy: hxy, tail: tail, cxy: cxy }, + strokeStyle = paintStyle.strokeStyle || currentConnectionPaintStyle.strokeStyle, + fillStyle = paintStyle.fillStyle || currentConnectionPaintStyle.strokeStyle, + lineWidth = paintStyle.lineWidth || currentConnectionPaintStyle.lineWidth; + + return { + component: component, + d: d, + lineWidth: lineWidth, + strokeStyle: strokeStyle, + fillStyle: fillStyle, + minX: Math.min(hxy.x, tail[0].x, tail[1].x), + maxX: Math.max(hxy.x, tail[0].x, tail[1].x), + minY: Math.min(hxy.y, tail[0].y, tail[1].y), + maxY: Math.max(hxy.y, tail[0].y, tail[1].y) + }; + } + else return {component: component, minX: 0, maxX: 0, minY: 0, maxY: 0}; + }; + }; + _ju.extend(_jp.Overlays.Arrow, AbstractOverlay, { + updateFrom:function(d) { + this.length = d.length || this.length; + this.width = d.width|| this.width; + this.direction = d.direction != null ? d.direction : this.direction; + this.foldback = d.foldback|| this.foldback; + } + }); + + /* + * Class: Overlays.PlainArrow + * + * A basic arrow. This is in fact just one instance of the more generic case in which the tail folds back on itself to some + * point along the length of the arrow: in this case, that foldback point is the full length of the arrow. so it just does + * a 'call' to Arrow with foldback set appropriately. + */ + /* + * Function: Constructor + * See for allowed parameters for this overlay. + */ + _jp.Overlays.PlainArrow = function (params) { + params = params || {}; + var p = _jp.extend(params, {foldback: 1}); + _jp.Overlays.Arrow.call(this, p); + this.type = "PlainArrow"; + }; + _ju.extend(_jp.Overlays.PlainArrow, _jp.Overlays.Arrow); + + /* + * Class: Overlays.Diamond + * + * A diamond. Like PlainArrow, this is a concrete case of the more generic case of the tail points converging on some point...it just + * happens that in this case, that point is greater than the length of the the arrow. + * + * this could probably do with some help with positioning...due to the way it reuses the Arrow paint code, what Arrow thinks is the + * center is actually 1/4 of the way along for this guy. but we don't have any knowledge of pixels at this point, so we're kind of + * stuck when it comes to helping out the Arrow class. possibly we could pass in a 'transpose' parameter or something. the value + * would be -l/4 in this case - move along one quarter of the total length. + */ + /* + * Function: Constructor + * See for allowed parameters for this overlay. + */ + _jp.Overlays.Diamond = function (params) { + params = params || {}; + var l = params.length || 40, + p = jsPlumb.extend(params, {length: l / 2, foldback: 2}); + _jp.Overlays.Arrow.call(this, p); + this.type = "Diamond"; + }; + _ju.extend(_jp.Overlays.Diamond, _jp.Overlays.Arrow); + + var _getDimensions = function (component, forceRefresh) { + if (component._jsPlumb.cachedDimensions == null || forceRefresh) + component._jsPlumb.cachedDimensions = component.getDimensions(); + return component._jsPlumb.cachedDimensions; + }; + + // abstract superclass for overlays that add an element to the DOM. + var AbstractDOMOverlay = function (params) { + _jp.jsPlumbUIComponent.apply(this, arguments); + AbstractOverlay.apply(this, arguments); + + // hand off fired events to associated component. + var _f = this.fire; + this.fire = function () { + _f.apply(this, arguments); + if (this.component) this.component.fire.apply(this.component, arguments); + }; + + this.detached=false; + this.id = params.id; + this._jsPlumb.div = null; + this._jsPlumb.initialised = false; + this._jsPlumb.component = params.component; + this._jsPlumb.cachedDimensions = null; + this._jsPlumb.create = params.create; + this._jsPlumb.initiallyInvisible = params.visible === false; + + this.getElement = function () { + if (this._jsPlumb.div == null) { + var div = this._jsPlumb.div = jsPlumb.getElement(this._jsPlumb.create(this._jsPlumb.component)); + div.style.position = "absolute"; + div.className = this._jsPlumb.instance.overlayClass + " " + + (this.cssClass ? this.cssClass : + params.cssClass ? params.cssClass : ""); + this._jsPlumb.instance.appendElement(div); + this._jsPlumb.instance.getId(div); + this.canvas = div; + + // in IE the top left corner is what it placed at the desired location. This will not + // be fixed. IE8 is not going to be supported for much longer. + var ts = "translate(-50%, -50%)"; + div.style.webkitTransform = ts; + div.style.mozTransform = ts; + div.style.msTransform = ts; + div.style.oTransform = ts; + div.style.transform = ts; + + // write the related component into the created element + div._jsPlumb = this; + + if (params.visible === false) + div.style.display = "none"; + } + return this._jsPlumb.div; + }; + + this.draw = function (component, currentConnectionPaintStyle, absolutePosition) { + var td = _getDimensions(this); + if (td != null && td.length == 2) { + var cxy = { x: 0, y: 0 }; + + // absolutePosition would have been set by a call to connection.setAbsoluteOverlayPosition. + if (absolutePosition) { + cxy = { x: absolutePosition[0], y: absolutePosition[1] }; + } + else if (component.pointOnPath) { + var loc = this.loc, absolute = false; + if (_ju.isString(this.loc) || this.loc < 0 || this.loc > 1) { + loc = parseInt(this.loc, 10); + absolute = true; + } + cxy = component.pointOnPath(loc, absolute); // a connection + } + else { + var locToUse = this.loc.constructor == Array ? this.loc : this.endpointLoc; + cxy = { x: locToUse[0] * component.w, + y: locToUse[1] * component.h }; + } + + var minx = cxy.x - (td[0] / 2), + miny = cxy.y - (td[1] / 2); + + return { + component: component, + d: { minx: minx, miny: miny, td: td, cxy: cxy }, + minX: minx, + maxX: minx + td[0], + minY: miny, + maxY: miny + td[1] + }; + } + else return {minX: 0, maxX: 0, minY: 0, maxY: 0}; + }; + }; + _ju.extend(AbstractDOMOverlay, [_jp.jsPlumbUIComponent, AbstractOverlay], { + getDimensions: function () { +// still support the old way, for now, for IE8. But from 2.0.0 this whole method will be gone. + return _ju.oldIE ? _jp.getSize(this.getElement()) : [1, 1]; + }, + setVisible: function (state) { + if (this._jsPlumb.div) { + this._jsPlumb.div.style.display = state ? "block" : "none"; + // if initially invisible, dimensions are 0,0 and never get updated + if (state && this._jsPlumb.initiallyInvisible) { + _getDimensions(this, true); + this.component.repaint(); + this._jsPlumb.initiallyInvisible = false; + } + } + }, + /* + * Function: clearCachedDimensions + * Clears the cached dimensions for the label. As a performance enhancement, label dimensions are + * cached from 1.3.12 onwards. The cache is cleared when you change the label text, of course, but + * there are other reasons why the text dimensions might change - if you make a change through CSS, for + * example, you might change the font size. in that case you should explicitly call this method. + */ + clearCachedDimensions: function () { + this._jsPlumb.cachedDimensions = null; + }, + cleanup: function (force) { + if (force) { + if (this._jsPlumb.div != null) { + this._jsPlumb.div._jsPlumb = null; + this._jsPlumb.instance.removeElement(this._jsPlumb.div); + } + } + else { + // if not a forced cleanup, just detach child from parent for now. + if (this._jsPlumb && this._jsPlumb.div && this._jsPlumb.div.parentNode) + this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div); + this.detached = true; + } + + }, + reattach:function(instance) { + if (this._jsPlumb.div != null) instance.getContainer().appendChild(this._jsPlumb.div); + this.detached = false; + }, + computeMaxSize: function () { + var td = _getDimensions(this); + return Math.max(td[0], td[1]); + }, + paint: function (p, containerExtents) { + if (!this._jsPlumb.initialised) { + this.getElement(); + p.component.appendDisplayElement(this._jsPlumb.div); + this._jsPlumb.initialised = true; + if (this.detached) this._jsPlumb.div.parentNode.removeChild(this._jsPlumb.div); + } + this._jsPlumb.div.style.left = (p.component.x + p.d.minx) + "px"; + this._jsPlumb.div.style.top = (p.component.y + p.d.miny) + "px"; + } + }); + + /* + * Class: Overlays.Custom + * A Custom overlay. You supply a 'create' function which returns some DOM element, and jsPlumb positions it. + * The 'create' function is passed a Connection or Endpoint. + */ + /* + * Function: Constructor + * + * Parameters: + * create - function for jsPlumb to call that returns a DOM element. + * location - distance (as a decimal from 0 to 1 inclusive) marking where the label should sit on the connector. defaults to 0.5. + * id - optional id to use for later retrieval of this overlay. + * + */ + _jp.Overlays.Custom = function (params) { + this.type = "Custom"; + AbstractDOMOverlay.apply(this, arguments); + }; + _ju.extend(_jp.Overlays.Custom, AbstractDOMOverlay); + + _jp.Overlays.GuideLines = function () { + var self = this; + self.length = 50; + self.lineWidth = 5; + this.type = "GuideLines"; + AbstractOverlay.apply(this, arguments); + _jp.jsPlumbUIComponent.apply(this, arguments); + this.draw = function (connector, currentConnectionPaintStyle) { + + var head = connector.pointAlongPathFrom(self.loc, self.length / 2), + mid = connector.pointOnPath(self.loc), + tail = _jg.pointOnLine(head, mid, self.length), + tailLine = _jg.perpendicularLineTo(head, tail, 40), + headLine = _jg.perpendicularLineTo(tail, head, 20); + + return { + connector: connector, + head: head, + tail: tail, + headLine: headLine, + tailLine: tailLine, + minX: Math.min(head.x, tail.x, headLine[0].x, headLine[1].x), + minY: Math.min(head.y, tail.y, headLine[0].y, headLine[1].y), + maxX: Math.max(head.x, tail.x, headLine[0].x, headLine[1].x), + maxY: Math.max(head.y, tail.y, headLine[0].y, headLine[1].y) + }; + }; + + // this.cleanup = function() { }; // nothing to clean up for GuideLines + }; + + /* + * Class: Overlays.Label + + */ + /* + * Function: Constructor + * + * Parameters: + * cssClass - optional css class string to append to css class. This string is appended "as-is", so you can of course have multiple classes + * defined. This parameter is preferred to using labelStyle, borderWidth and borderStyle. + * label - the label to paint. May be a string or a function that returns a string. Nothing will be painted if your label is null or your + * label function returns null. empty strings _will_ be painted. + * location - distance (as a decimal from 0 to 1 inclusive) marking where the label should sit on the connector. defaults to 0.5. + * id - optional id to use for later retrieval of this overlay. + * + * + */ + _jp.Overlays.Label = function (params) { + this.labelStyle = params.labelStyle; + + var labelWidth = null, labelHeight = null, labelText = null, labelPadding = null; + this.cssClass = this.labelStyle != null ? this.labelStyle.cssClass : null; + var p = _jp.extend({ + create: function () { + return jsPlumb.createElement("div"); + }}, params); + _jp.Overlays.Custom.call(this, p); + this.type = "Label"; + this.label = params.label || ""; + this.labelText = null; + if (this.labelStyle) { + var el = this.getElement(); + this.labelStyle.font = this.labelStyle.font || "12px sans-serif"; + el.style.font = this.labelStyle.font; + el.style.color = this.labelStyle.color || "black"; + if (this.labelStyle.fillStyle) el.style.background = this.labelStyle.fillStyle; + if (this.labelStyle.borderWidth > 0) { + var dStyle = this.labelStyle.borderStyle ? this.labelStyle.borderStyle : "black"; + el.style.border = this.labelStyle.borderWidth + "px solid " + dStyle; + } + if (this.labelStyle.padding) el.style.padding = this.labelStyle.padding; + } + + }; + _ju.extend(_jp.Overlays.Label, _jp.Overlays.Custom, { + cleanup: function (force) { + if (force) { + this.div = null; + this.label = null; + this.labelText = null; + this.cssClass = null; + this.labelStyle = null; + } + }, + getLabel: function () { + return this.label; + }, + /* + * Function: setLabel + * sets the label's, um, label. you would think i'd call this function + * 'setText', but you can pass either a Function or a String to this, so + * it makes more sense as 'setLabel'. This uses innerHTML on the label div, so keep + * that in mind if you need escaped HTML. + */ + setLabel: function (l) { + this.label = l; + this.labelText = null; + this.clearCachedDimensions(); + this.update(); + this.component.repaint(); + }, + getDimensions: function () { + this.update(); + return AbstractDOMOverlay.prototype.getDimensions.apply(this, arguments); + }, + update: function () { + if (typeof this.label == "function") { + var lt = this.label(this); + this.getElement().innerHTML = lt.replace(/\r\n/g, "
    "); + } + else { + if (this.labelText == null) { + this.labelText = this.label; + this.getElement().innerHTML = this.labelText.replace(/\r\n/g, "
    "); + } + } + }, + updateFrom:function(d) { + if(d.label) this.setLabel(d.label); + } + }); + + // ********************************* END OF OVERLAY DEFINITIONS *********************************************************************** + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the base class for library adapters. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +;(function() { + "use strict"; + var root = this, + _jp = root.jsPlumb; + + var _getEventManager = function(instance) { + var e = instance._mottle; + if (!e) { + e = instance._mottle = new root.Mottle(); + } + return e; + }; + + _jp.extend(root.jsPlumbInstance.prototype, { + getEventManager:function() { + return _getEventManager(this); + }, + // EVENTS + // e.originalEvent is for jQuery; in Vanilla jsPlumb we get the native event. + + on : function(el, event, callback) { + // TODO: here we would like to map the tap event if we know its + // an internal bind to a click. we have to know its internal because only + // then can we be sure that the UP event wont be consumed (tap is a synthesized + // event from a mousedown followed by a mouseup). + //event = { "click":"tap", "dblclick":"dbltap"}[event] || event; + this.getEventManager().on.apply(this, arguments); + }, + off : function(el, event, callback) { + this.getEventManager().off.apply(this, arguments); + } + }); + + +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the 'flowchart' connectors, consisting of vertical and horizontal line segments. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var Flowchart = function (params) { + this.type = "Flowchart"; + params = params || {}; + params.stub = params.stub == null ? 30 : params.stub; + var segments, + _super = _jp.Connectors.AbstractConnector.apply(this, arguments), + midpoint = params.midpoint == null ? 0.5 : params.midpoint, + alwaysRespectStubs = params.alwaysRespectStubs === true, + userSuppliedSegments = null, + lastx = null, lasty = null, lastOrientation, + cornerRadius = params.cornerRadius != null ? params.cornerRadius : 0, + sgn = function (n) { + return n < 0 ? -1 : n === 0 ? 0 : 1; + }, + /** + * helper method to add a segment. + */ + addSegment = function (segments, x, y, paintInfo) { + if (lastx == x && lasty == y) return; + var lx = lastx == null ? paintInfo.sx : lastx, + ly = lasty == null ? paintInfo.sy : lasty, + o = lx == x ? "v" : "h", + sgnx = sgn(x - lx), + sgny = sgn(y - ly); + + lastx = x; + lasty = y; + segments.push([lx, ly, x, y, o, sgnx, sgny]); + }, + segLength = function (s) { + return Math.sqrt(Math.pow(s[0] - s[2], 2) + Math.pow(s[1] - s[3], 2)); + }, + _cloneArray = function (a) { + var _a = []; + _a.push.apply(_a, a); + return _a; + }, + writeSegments = function (conn, segments, paintInfo) { + var current = null, next; + for (var i = 0; i < segments.length - 1; i++) { + + current = current || _cloneArray(segments[i]); + next = _cloneArray(segments[i + 1]); + if (cornerRadius > 0 && current[4] != next[4]) { + var radiusToUse = Math.min(cornerRadius, segLength(current), segLength(next)); + // right angle. adjust current segment's end point, and next segment's start point. + current[2] -= current[5] * radiusToUse; + current[3] -= current[6] * radiusToUse; + next[0] += next[5] * radiusToUse; + next[1] += next[6] * radiusToUse; + var ac = (current[6] == next[5] && next[5] == 1) || + ((current[6] == next[5] && next[5] === 0) && current[5] != next[6]) || + (current[6] == next[5] && next[5] == -1), + sgny = next[1] > current[3] ? 1 : -1, + sgnx = next[0] > current[2] ? 1 : -1, + sgnEqual = sgny == sgnx, + cx = (sgnEqual && ac || (!sgnEqual && !ac)) ? next[0] : current[2], + cy = (sgnEqual && ac || (!sgnEqual && !ac)) ? current[3] : next[1]; + + _super.addSegment(conn, "Straight", { + x1: current[0], y1: current[1], x2: current[2], y2: current[3] + }); + + _super.addSegment(conn, "Arc", { + r: radiusToUse, + x1: current[2], + y1: current[3], + x2: next[0], + y2: next[1], + cx: cx, + cy: cy, + ac: ac + }); + } + else { + // dx + dy are used to adjust for line width. + var dx = (current[2] == current[0]) ? 0 : (current[2] > current[0]) ? (paintInfo.lw / 2) : -(paintInfo.lw / 2), + dy = (current[3] == current[1]) ? 0 : (current[3] > current[1]) ? (paintInfo.lw / 2) : -(paintInfo.lw / 2); + _super.addSegment(conn, "Straight", { + x1: current[0] - dx, y1: current[1] - dy, x2: current[2] + dx, y2: current[3] + dy + }); + } + current = next; + } + if (next != null) { + // last segment + _super.addSegment(conn, "Straight", { + x1: next[0], y1: next[1], x2: next[2], y2: next[3] + }); + } + }; + + this.setSegments = function (s) { + userSuppliedSegments = s; + }; + + this.isEditable = function () { + return true; + }; + + /* + Function: getOriginalSegments + Gets the segments before the addition of rounded corners. This is used by the flowchart + connector editor, since it only wants to concern itself with the original segments. + */ + this.getOriginalSegments = function () { + return userSuppliedSegments || segments; + }; + + this._compute = function (paintInfo, params) { + + if (params.clearEdits) + userSuppliedSegments = null; + + if (userSuppliedSegments != null) { + writeSegments(this, userSuppliedSegments, paintInfo); + return; + } + + segments = []; + lastx = null; + lasty = null; + lastOrientation = null; + + var midx = paintInfo.startStubX + ((paintInfo.endStubX - paintInfo.startStubX) * midpoint), + midy = paintInfo.startStubY + ((paintInfo.endStubY - paintInfo.startStubY) * midpoint); + + var orientations = { x: [ 0, 1 ], y: [ 1, 0 ] }, + commonStubCalculator = function () { + return [ paintInfo.startStubX, paintInfo.startStubY, paintInfo.endStubX, paintInfo.endStubY ]; + }, + stubCalculators = { + perpendicular: commonStubCalculator, + orthogonal: commonStubCalculator, + opposite: function (axis) { + var pi = paintInfo, + idx = axis == "x" ? 0 : 1, + areInProximity = { + "x": function () { + return ( (pi.so[idx] == 1 && ( + ( (pi.startStubX > pi.endStubX) && (pi.tx > pi.startStubX) ) || + ( (pi.sx > pi.endStubX) && (pi.tx > pi.sx))))) || + + ( (pi.so[idx] == -1 && ( + ( (pi.startStubX < pi.endStubX) && (pi.tx < pi.startStubX) ) || + ( (pi.sx < pi.endStubX) && (pi.tx < pi.sx))))); + }, + "y": function () { + return ( (pi.so[idx] == 1 && ( + ( (pi.startStubY > pi.endStubY) && (pi.ty > pi.startStubY) ) || + ( (pi.sy > pi.endStubY) && (pi.ty > pi.sy))))) || + + ( (pi.so[idx] == -1 && ( + ( (pi.startStubY < pi.endStubY) && (pi.ty < pi.startStubY) ) || + ( (pi.sy < pi.endStubY) && (pi.ty < pi.sy))))); + } + }; + + if (!alwaysRespectStubs && areInProximity[axis]()) { + return { + "x": [(paintInfo.sx + paintInfo.tx) / 2, paintInfo.startStubY, (paintInfo.sx + paintInfo.tx) / 2, paintInfo.endStubY], + "y": [paintInfo.startStubX, (paintInfo.sy + paintInfo.ty) / 2, paintInfo.endStubX, (paintInfo.sy + paintInfo.ty) / 2] + }[axis]; + } + else { + return [ paintInfo.startStubX, paintInfo.startStubY, paintInfo.endStubX, paintInfo.endStubY ]; + } + } + }, + lineCalculators = { + perpendicular: function (axis) { + var pi = paintInfo, + sis = { + x: [ + [ [ 1, 2, 3, 4 ], null, [ 2, 1, 4, 3 ] ], + null, + [ [ 4, 3, 2, 1 ], null, [ 3, 4, 1, 2 ] ] + ], + y: [ + [ [ 3, 2, 1, 4 ], null, [ 2, 3, 4, 1 ] ], + null, + [ [ 4, 1, 2, 3 ], null, [ 1, 4, 3, 2 ] ] + ] + }, + stubs = { + x: [ [ pi.startStubX, pi.endStubX ], null, [ pi.endStubX, pi.startStubX ] ], + y: [ [ pi.startStubY, pi.endStubY ], null, [ pi.endStubY, pi.startStubY ] ] + }, + midLines = { + x: [ [ midx, pi.startStubY ], [ midx, pi.endStubY ] ], + y: [ [ pi.startStubX, midy ], [ pi.endStubX, midy ] ] + }, + linesToEnd = { + x: [ [ pi.endStubX, pi.startStubY ] ], + y: [ [ pi.startStubX, pi.endStubY ] ] + }, + startToEnd = { + x: [ [ pi.startStubX, pi.endStubY ], [ pi.endStubX, pi.endStubY ] ], + y: [ [ pi.endStubX, pi.startStubY ], [ pi.endStubX, pi.endStubY ] ] + }, + startToMidToEnd = { + x: [ [ pi.startStubX, midy ], [ pi.endStubX, midy ], [ pi.endStubX, pi.endStubY ] ], + y: [ [ midx, pi.startStubY ], [ midx, pi.endStubY ], [ pi.endStubX, pi.endStubY ] ] + }, + otherStubs = { + x: [ pi.startStubY, pi.endStubY ], + y: [ pi.startStubX, pi.endStubX ] + }, + soIdx = orientations[axis][0], toIdx = orientations[axis][1], + _so = pi.so[soIdx] + 1, + _to = pi.to[toIdx] + 1, + otherFlipped = (pi.to[toIdx] == -1 && (otherStubs[axis][1] < otherStubs[axis][0])) || (pi.to[toIdx] == 1 && (otherStubs[axis][1] > otherStubs[axis][0])), + stub1 = stubs[axis][_so][0], + stub2 = stubs[axis][_so][1], + segmentIndexes = sis[axis][_so][_to]; + + if (pi.segment == segmentIndexes[3] || (pi.segment == segmentIndexes[2] && otherFlipped)) { + return midLines[axis]; + } + else if (pi.segment == segmentIndexes[2] && stub2 < stub1) { + return linesToEnd[axis]; + } + else if ((pi.segment == segmentIndexes[2] && stub2 >= stub1) || (pi.segment == segmentIndexes[1] && !otherFlipped)) { + return startToMidToEnd[axis]; + } + else if (pi.segment == segmentIndexes[0] || (pi.segment == segmentIndexes[1] && otherFlipped)) { + return startToEnd[axis]; + } + }, + orthogonal: function (axis, startStub, otherStartStub, endStub, otherEndStub) { + var pi = paintInfo, + extent = { + "x": pi.so[0] == -1 ? Math.min(startStub, endStub) : Math.max(startStub, endStub), + "y": pi.so[1] == -1 ? Math.min(startStub, endStub) : Math.max(startStub, endStub) + }[axis]; + + return { + "x": [ + [ extent, otherStartStub ], + [ extent, otherEndStub ], + [ endStub, otherEndStub ] + ], + "y": [ + [ otherStartStub, extent ], + [ otherEndStub, extent ], + [ otherEndStub, endStub ] + ] + }[axis]; + }, + opposite: function (axis, ss, oss, es) { + var pi = paintInfo, + otherAxis = {"x": "y", "y": "x"}[axis], + dim = {"x": "height", "y": "width"}[axis], + comparator = pi["is" + axis.toUpperCase() + "GreaterThanStubTimes2"]; + + if (params.sourceEndpoint.elementId == params.targetEndpoint.elementId) { + var _val = oss + ((1 - params.sourceEndpoint.anchor[otherAxis]) * params.sourceInfo[dim]) + _super.maxStub; + return { + "x": [ + [ ss, _val ], + [ es, _val ] + ], + "y": [ + [ _val, ss ], + [ _val, es ] + ] + }[axis]; + + } + else if (!comparator || (pi.so[idx] == 1 && ss > es) || (pi.so[idx] == -1 && ss < es)) { + return { + "x": [ + [ ss, midy ], + [ es, midy ] + ], + "y": [ + [ midx, ss ], + [ midx, es ] + ] + }[axis]; + } + else if ((pi.so[idx] == 1 && ss < es) || (pi.so[idx] == -1 && ss > es)) { + return { + "x": [ + [ midx, pi.sy ], + [ midx, pi.ty ] + ], + "y": [ + [ pi.sx, midy ], + [ pi.tx, midy ] + ] + }[axis]; + } + } + }; + + var stubs = stubCalculators[paintInfo.anchorOrientation](paintInfo.sourceAxis), + idx = paintInfo.sourceAxis == "x" ? 0 : 1, + oidx = paintInfo.sourceAxis == "x" ? 1 : 0, + ss = stubs[idx], + oss = stubs[oidx], + es = stubs[idx + 2], + oes = stubs[oidx + 2]; + + // add the start stub segment. + addSegment(segments, stubs[0], stubs[1], paintInfo); + + // compute the rest of the line + var p = lineCalculators[paintInfo.anchorOrientation](paintInfo.sourceAxis, ss, oss, es, oes); + if (p) { + for (var i = 0; i < p.length; i++) { + addSegment(segments, p[i][0], p[i][1], paintInfo); + } + } + + // line to end stub + addSegment(segments, stubs[2], stubs[3], paintInfo); + + // end stub to end + addSegment(segments, paintInfo.tx, paintInfo.ty, paintInfo); + + writeSegments(this, segments, paintInfo); + }; + + this.getPath = function () { + var _last = null, _lastAxis = null, s = [], segs = userSuppliedSegments || segments; + for (var i = 0; i < segs.length; i++) { + var seg = segs[i], axis = seg[4], axisIndex = (axis == "v" ? 3 : 2); + if (_last != null && _lastAxis === axis) { + _last[axisIndex] = seg[axisIndex]; + } + else { + if (seg[0] != seg[2] || seg[1] != seg[3]) { + s.push({ + start: [ seg[0], seg[1] ], + end: [ seg[2], seg[3] ] + }); + _last = seg; + _lastAxis = seg[4]; + } + } + } + return s; + }; + + this.setPath = function (path) { + userSuppliedSegments = []; + for (var i = 0; i < path.length; i++) { + var lx = path[i].start[0], + ly = path[i].start[1], + x = path[i].end[0], + y = path[i].end[1], + o = lx == x ? "v" : "h", + sgnx = sgn(x - lx), + sgny = sgn(y - ly); + + userSuppliedSegments.push([lx, ly, x, y, o, sgnx, sgny]); + } + }; + }; + + _ju.extend(Flowchart, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(Flowchart, "Flowchart"); +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the state machine connectors. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var _segment = function (x1, y1, x2, y2) { + if (x1 <= x2 && y2 <= y1) return 1; + else if (x1 <= x2 && y1 <= y2) return 2; + else if (x2 <= x1 && y2 >= y1) return 3; + return 4; + }, + + // the control point we will use depends on the faces to which each end of the connection is assigned, specifically whether or not the + // two faces are parallel or perpendicular. if they are parallel then the control point lies on the midpoint of the axis in which they + // are parellel and varies only in the other axis; this variation is proportional to the distance that the anchor points lie from the + // center of that face. if the two faces are perpendicular then the control point is at some distance from both the midpoints; the amount and + // direction are dependent on the orientation of the two elements. 'seg', passed in to this method, tells you which segment the target element + // lies in with respect to the source: 1 is top right, 2 is bottom right, 3 is bottom left, 4 is top left. + // + // sourcePos and targetPos are arrays of info about where on the source and target each anchor is located. their contents are: + // + // 0 - absolute x + // 1 - absolute y + // 2 - proportional x in element (0 is left edge, 1 is right edge) + // 3 - proportional y in element (0 is top edge, 1 is bottom edge) + // + _findControlPoint = function (midx, midy, segment, sourceEdge, targetEdge, dx, dy, distance, proximityLimit) { + // TODO (maybe) + // - if anchor pos is 0.5, make the control point take into account the relative position of the elements. + if (distance <= proximityLimit) return [midx, midy]; + + if (segment === 1) { + if (sourceEdge[3] <= 0 && targetEdge[3] >= 1) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] >= 1 && targetEdge[2] <= 0) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + (-1 * dx) , midy + (-1 * dy) ]; + } + else if (segment === 2) { + if (sourceEdge[3] >= 1 && targetEdge[3] <= 0) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] >= 1 && targetEdge[2] <= 0) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + dx, midy + (-1 * dy) ]; + } + else if (segment === 3) { + if (sourceEdge[3] >= 1 && targetEdge[3] <= 0) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] <= 0 && targetEdge[2] >= 1) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + (-1 * dx) , midy + (-1 * dy) ]; + } + else if (segment === 4) { + if (sourceEdge[3] <= 0 && targetEdge[3] >= 1) return [ midx + (sourceEdge[2] < 0.5 ? -1 * dx : dx), midy ]; + else if (sourceEdge[2] <= 0 && targetEdge[2] >= 1) return [ midx, midy + (sourceEdge[3] < 0.5 ? -1 * dy : dy) ]; + else return [ midx + dx , midy + (-1 * dy) ]; + } + + }; + + var StateMachine = function (params) { + params = params || {}; + this.type = "StateMachine"; + + var _super = _jp.Connectors.AbstractConnector.apply(this, arguments), + curviness = params.curviness || 10, + margin = params.margin || 5, + proximityLimit = params.proximityLimit || 80, + clockwise = params.orientation && params.orientation === "clockwise", + loopbackRadius = params.loopbackRadius || 25, + showLoopback = params.showLoopback !== false; + + this._compute = function (paintInfo, params) { + var w = Math.abs(params.sourcePos[0] - params.targetPos[0]), + h = Math.abs(params.sourcePos[1] - params.targetPos[1]); + + if (!showLoopback || (params.sourceEndpoint.elementId !== params.targetEndpoint.elementId)) { + var _sx = params.sourcePos[0] < params.targetPos[0] ? 0 : w, + _sy = params.sourcePos[1] < params.targetPos[1] ? 0 : h, + _tx = params.sourcePos[0] < params.targetPos[0] ? w : 0, + _ty = params.sourcePos[1] < params.targetPos[1] ? h : 0; + + // now adjust for the margin + if (params.sourcePos[2] === 0) _sx -= margin; + if (params.sourcePos[2] === 1) _sx += margin; + if (params.sourcePos[3] === 0) _sy -= margin; + if (params.sourcePos[3] === 1) _sy += margin; + if (params.targetPos[2] === 0) _tx -= margin; + if (params.targetPos[2] === 1) _tx += margin; + if (params.targetPos[3] === 0) _ty -= margin; + if (params.targetPos[3] === 1) _ty += margin; + + // + // these connectors are quadratic bezier curves, having a single control point. if both anchors + // are located at 0.5 on their respective faces, the control point is set to the midpoint and you + // get a straight line. this is also the case if the two anchors are within 'proximityLimit', since + // it seems to make good aesthetic sense to do that. outside of that, the control point is positioned + // at 'curviness' pixels away along the normal to the straight line connecting the two anchors. + // + // there may be two improvements to this. firstly, we might actually support the notion of avoiding nodes + // in the UI, or at least making a good effort at doing so. if a connection would pass underneath some node, + // for example, we might increase the distance the control point is away from the midpoint in a bid to + // steer it around that node. this will work within limits, but i think those limits would also be the likely + // limits for, once again, aesthetic good sense in the layout of a chart using these connectors. + // + // the second possible change is actually two possible changes: firstly, it is possible we should gradually + // decrease the 'curviness' as the distance between the anchors decreases; start tailing it off to 0 at some + // point (which should be configurable). secondly, we might slightly increase the 'curviness' for connectors + // with respect to how far their anchor is from the center of its respective face. this could either look cool, + // or stupid, and may indeed work only in a way that is so subtle as to have been a waste of time. + // + + var _midx = (_sx + _tx) / 2, + _midy = (_sy + _ty) / 2, + segment = _segment(_sx, _sy, _tx, _ty), + distance = Math.sqrt(Math.pow(_tx - _sx, 2) + Math.pow(_ty - _sy, 2)), + // calculate the control point. this code will be where we'll put in a rudimentary element avoidance scheme; it + // will work by extending the control point to force the curve to be, um, curvier. + _controlPoint = _findControlPoint(_midx, + _midy, + segment, + params.sourcePos, + params.targetPos, + curviness, curviness, + distance, + proximityLimit); + + _super.addSegment(this, "Bezier", { + x1: _tx, y1: _ty, x2: _sx, y2: _sy, + cp1x: _controlPoint[0], cp1y: _controlPoint[1], + cp2x: _controlPoint[0], cp2y: _controlPoint[1] + }); + } + else { + // a loopback connector. draw an arc from one anchor to the other. + var x1 = params.sourcePos[0], y1 = params.sourcePos[1] - margin, + cx = x1, cy = y1 - loopbackRadius, + // canvas sizing stuff, to ensure the whole painted area is visible. + _w = 2 * loopbackRadius, + _h = 2 * loopbackRadius, + _x = cx - loopbackRadius, + _y = cy - loopbackRadius; + + paintInfo.points[0] = _x; + paintInfo.points[1] = _y; + paintInfo.points[2] = _w; + paintInfo.points[3] = _h; + + // ADD AN ARC SEGMENT. + _super.addSegment(this, "Arc", { + loopback: true, + x1: (x1 - _x) + 4, + y1: y1 - _y, + startAngle: 0, + endAngle: 2 * Math.PI, + r: loopbackRadius, + ac: !clockwise, + x2: (x1 - _x) - 4, + y2: y1 - _y, + cx: cx - _x, + cy: cy - _y + }); + } + }; + }; + _ju.extend(StateMachine, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(StateMachine, "StateMachine"); +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the code for the Bezier connector type. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var Bezier = function (params) { + params = params || {}; + + var _super = _jp.Connectors.AbstractConnector.apply(this, arguments), + majorAnchor = params.curviness || 150, + minorAnchor = 10; + + this.type = "Bezier"; + this.getCurviness = function () { + return majorAnchor; + }; + + this._findControlPoint = function (point, sourceAnchorPosition, targetAnchorPosition, sourceEndpoint, targetEndpoint) { + // determine if the two anchors are perpendicular to each other in their orientation. we swap the control + // points around if so (code could be tightened up) + var soo = sourceEndpoint.anchor.getOrientation(sourceEndpoint), + too = targetEndpoint.anchor.getOrientation(targetEndpoint), + perpendicular = soo[0] != too[0] || soo[1] == too[1], + p = []; + + if (!perpendicular) { + if (soo[0] === 0) // X + p.push(sourceAnchorPosition[0] < targetAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor); + else p.push(point[0] - (majorAnchor * soo[0])); + + if (soo[1] === 0) // Y + p.push(sourceAnchorPosition[1] < targetAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor); + else p.push(point[1] + (majorAnchor * too[1])); + } + else { + if (too[0] === 0) // X + p.push(targetAnchorPosition[0] < sourceAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor); + else p.push(point[0] + (majorAnchor * too[0])); + + if (too[1] === 0) // Y + p.push(targetAnchorPosition[1] < sourceAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor); + else p.push(point[1] + (majorAnchor * soo[1])); + } + + return p; + }; + + this._compute = function (paintInfo, p) { + var sp = p.sourcePos, + tp = p.targetPos, + _w = Math.abs(sp[0] - tp[0]), + _h = Math.abs(sp[1] - tp[1]), + _sx = sp[0] < tp[0] ? _w : 0, + _sy = sp[1] < tp[1] ? _h : 0, + _tx = sp[0] < tp[0] ? 0 : _w, + _ty = sp[1] < tp[1] ? 0 : _h, + _CP = this._findControlPoint([_sx, _sy], sp, tp, p.sourceEndpoint, p.targetEndpoint, paintInfo.so, paintInfo.to), + _CP2 = this._findControlPoint([_tx, _ty], tp, sp, p.targetEndpoint, p.sourceEndpoint, paintInfo.so, paintInfo.to); + + _super.addSegment(this, "Bezier", { + x1: _sx, y1: _sy, x2: _tx, y2: _ty, + cp1x: _CP[0], cp1y: _CP[1], cp2x: _CP2[0], cp2y: _CP2[1] + }); + }; + }; + + _ju.extend(Bezier, _jp.Connectors.AbstractConnector); + _jp.registerConnectorType(Bezier, "Bezier"); + +}).call(this); +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the SVG renderers. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function () { + +// ************************** SVG utility methods ******************************************** + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var svgAttributeMap = { + "joinstyle": "stroke-linejoin", + "stroke-linejoin": "stroke-linejoin", + "stroke-dashoffset": "stroke-dashoffset", + "stroke-linecap": "stroke-linecap" + }, + STROKE_DASHARRAY = "stroke-dasharray", + DASHSTYLE = "dashstyle", + LINEAR_GRADIENT = "linearGradient", + RADIAL_GRADIENT = "radialGradient", + DEFS = "defs", + FILL = "fill", + STOP = "stop", + STROKE = "stroke", + STROKE_WIDTH = "stroke-width", + STYLE = "style", + NONE = "none", + JSPLUMB_GRADIENT = "jsplumb_gradient_", + LINE_WIDTH = "lineWidth", + ns = { + svg: "http://www.w3.org/2000/svg", + xhtml: "http://www.w3.org/1999/xhtml" + }, + _attr = function (node, attributes) { + for (var i in attributes) + node.setAttribute(i, "" + attributes[i]); + }, + _node = function (name, attributes) { + attributes = attributes || {}; + attributes.version = "1.1"; + attributes.xmlns = ns.xhtml; + return jsPlumb.createElementNS(ns.svg, name, null, null, attributes); + }, + _pos = function (d) { + return "position:absolute;left:" + d[0] + "px;top:" + d[1] + "px"; + }, + _clearGradient = function (parent) { + var els = parent.querySelectorAll(" defs linearGradient radialGradient"); + for (var i = 0; i < els.length; i++) + els[i].parentNode.removeChild(els[i]); + }, + _updateGradient = function (parent, node, style, dimensions, uiComponent) { + var id = JSPLUMB_GRADIENT + uiComponent._jsPlumb.instance.idstamp(); + // first clear out any existing gradient + _clearGradient(parent); + // this checks for an 'offset' property in the gradient, and in the absence of it, assumes + // we want a linear gradient. if it's there, we create a radial gradient. + // it is possible that a more explicit means of defining the gradient type would be + // better. relying on 'offset' means that we can never have a radial gradient that uses + // some default offset, for instance. + // issue 244 suggested the 'gradientUnits' attribute; without this, straight/flowchart connectors with gradients would + // not show gradients when the line was perfectly horizontal or vertical. + var g; + if (!style.gradient.offset) + g = _node(LINEAR_GRADIENT, {id: id, gradientUnits: "userSpaceOnUse"}); + else + g = _node(RADIAL_GRADIENT, { id: id }); + + var defs = _node(DEFS); + parent.appendChild(defs); + defs.appendChild(g); + + // the svg radial gradient seems to treat stops in the reverse + // order to how canvas does it. so we want to keep all the maths the same, but + // iterate the actual style declarations in reverse order, if the x indexes are not in order. + for (var i = 0; i < style.gradient.stops.length; i++) { + var styleToUse = uiComponent.segment == 1 || uiComponent.segment == 2 ? i : style.gradient.stops.length - 1 - i, + stopColor = _ju.convertStyle(style.gradient.stops[styleToUse][1], true), + s = _node(STOP, {"offset": Math.floor(style.gradient.stops[i][0] * 100) + "%", "stop-color": stopColor}); + + g.appendChild(s); + } + var applyGradientTo = style.strokeStyle ? STROKE : FILL; + node.setAttribute(applyGradientTo, "url(#" + id + ")"); + }, + _applyStyles = function (parent, node, style, dimensions, uiComponent) { + + node.setAttribute(FILL, style.fillStyle ? _ju.convertStyle(style.fillStyle, true) : NONE); + node.setAttribute(STROKE, style.strokeStyle ? _ju.convertStyle(style.strokeStyle, true) : NONE); + + if (style.gradient) { + _updateGradient(parent, node, style, dimensions, uiComponent); + } + else { + // make sure we clear any existing gradient + _clearGradient(parent); + node.setAttribute(STYLE, ""); + } + + if (style.lineWidth) { + node.setAttribute(STROKE_WIDTH, style.lineWidth); + } + + // in SVG there is a stroke-dasharray attribute we can set, and its syntax looks like + // the syntax in VML but is actually kind of nasty: values are given in the pixel + // coordinate space, whereas in VML they are multiples of the width of the stroked + // line, which makes a lot more sense. for that reason, jsPlumb is supporting both + // the native svg 'stroke-dasharray' attribute, and also the 'dashstyle' concept from + // VML, which will be the preferred method. the code below this converts a dashstyle + // attribute given in terms of stroke width into a pixel representation, by using the + // stroke's lineWidth. + if (style[DASHSTYLE] && style[LINE_WIDTH] && !style[STROKE_DASHARRAY]) { + var sep = style[DASHSTYLE].indexOf(",") == -1 ? " " : ",", + parts = style[DASHSTYLE].split(sep), + styleToUse = ""; + parts.forEach(function (p) { + styleToUse += (Math.floor(p * style.lineWidth) + sep); + }); + node.setAttribute(STROKE_DASHARRAY, styleToUse); + } + else if (style[STROKE_DASHARRAY]) { + node.setAttribute(STROKE_DASHARRAY, style[STROKE_DASHARRAY]); + } + + // extra attributes such as join type, dash offset. + for (var i in svgAttributeMap) { + if (style[i]) { + node.setAttribute(svgAttributeMap[i], style[i]); + } + } + }, + _appendAtIndex = function (svg, path, idx) { + if (svg.childNodes.length > idx) { + svg.insertBefore(path, svg.childNodes[idx]); + } + else svg.appendChild(path); + }; + + /** + utility methods for other objects to use. + */ + _ju.svg = { + node: _node, + attr: _attr, + pos: _pos + }; + + // ************************** / SVG utility methods ******************************************** + + /* + * Base class for SVG components. + */ + var SvgComponent = function (params) { + var pointerEventsSpec = params.pointerEventsSpec || "all", renderer = {}; + + _jp.jsPlumbUIComponent.apply(this, params.originalArgs); + this.canvas = null; + this.path = null; + this.svg = null; + this.bgCanvas = null; + + var clazz = params.cssClass + " " + (params.originalArgs[0].cssClass || ""), + svgParams = { + "style": "", + "width": 0, + "height": 0, + "pointer-events": pointerEventsSpec, + "position": "absolute" + }; + + this.svg = _node("svg", svgParams); + + if (params.useDivWrapper) { + this.canvas = jsPlumb.createElement("div", { position : "absolute" }); + _ju.sizeElement(this.canvas, 0, 0, 1, 1); + this.canvas.className = clazz; + } + else { + _attr(this.svg, { "class": clazz }); + this.canvas = this.svg; + } + + params._jsPlumb.appendElement(this.canvas, params.originalArgs[0].parent); + if (params.useDivWrapper) this.canvas.appendChild(this.svg); + + var displayElements = [ this.canvas ]; + this.getDisplayElements = function () { + return displayElements; + }; + + this.appendDisplayElement = function (el) { + displayElements.push(el); + }; + + this.paint = function (style, anchor, extents) { + if (style != null) { + + var xy = [ this.x, this.y ], wh = [ this.w, this.h ], p; + if (extents != null) { + if (extents.xmin < 0) xy[0] += extents.xmin; + if (extents.ymin < 0) xy[1] += extents.ymin; + wh[0] = extents.xmax + ((extents.xmin < 0) ? -extents.xmin : 0); + wh[1] = extents.ymax + ((extents.ymin < 0) ? -extents.ymin : 0); + } + + if (params.useDivWrapper) { + _ju.sizeElement(this.canvas, xy[0], xy[1], wh[0], wh[1]); + xy[0] = 0; + xy[1] = 0; + p = _pos([ 0, 0 ]); + } + else + p = _pos([ xy[0], xy[1] ]); + + renderer.paint.apply(this, arguments); + + _attr(this.svg, { + "style": p, + "width": wh[0] || 0, + "height": wh[1] || 0 + }); + } + }; + + return { + renderer: renderer + }; + }; + + _ju.extend(SvgComponent, _jp.jsPlumbUIComponent, { + cleanup: function (force) { + if (force || this.typeId == null) { + if (this.canvas) this.canvas._jsPlumb = null; + if (this.svg) this.svg._jsPlumb = null; + if (this.bgCanvas) this.bgCanvas._jsPlumb = null; + + if (this.canvas && this.canvas.parentNode) + this.canvas.parentNode.removeChild(this.canvas); + if (this.bgCanvas && this.bgCanvas.parentNode) + this.canvas.parentNode.removeChild(this.canvas); + + this.svg = null; + this.canvas = null; + this.path = null; + this.group = null; + } + else { + // if not a forced cleanup, just detach from DOM for now. + if (this.canvas && this.canvas.parentNode) this.canvas.parentNode.removeChild(this.canvas); + if (this.bgCanvas && this.bgCanvas.parentNode) this.bgCanvas.parentNode.removeChild(this.bgCanvas); + } + }, + reattach:function(instance) { + var c = instance.getContainer(); + if (this.canvas && this.canvas.parentNode == null) c.appendChild(this.canvas); + if (this.bgCanvas && this.bgCanvas.parentNode == null) c.appendChild(this.bgCanvas); + }, + setVisible: function (v) { + if (this.canvas) { + this.canvas.style.display = v ? "block" : "none"; + } + } + }); + + /* + * Base class for SVG connectors. + */ + _jp.ConnectorRenderers.svg = function (params) { + var self = this, + _super = SvgComponent.apply(this, [ + { + cssClass: params._jsPlumb.connectorClass, + originalArgs: arguments, + pointerEventsSpec: "none", + _jsPlumb: params._jsPlumb + } + ]); + + _super.renderer.paint = function (style, anchor, extents) { + + var segments = self.getSegments(), p = "", offset = [0, 0]; + if (extents.xmin < 0) offset[0] = -extents.xmin; + if (extents.ymin < 0) offset[1] = -extents.ymin; + + if (segments.length > 0) { + + // create path from segments. + for (var i = 0; i < segments.length; i++) { + p += _jp.Segments.svg.SegmentRenderer.getPath(segments[i]); + p += " "; + } + + var a = { + d: p, + transform: "translate(" + offset[0] + "," + offset[1] + ")", + "pointer-events": params["pointer-events"] || "visibleStroke" + }, + outlineStyle = null, + d = [self.x, self.y, self.w, self.h]; + + // outline style. actually means drawing an svg object underneath the main one. + if (style.outlineColor) { + var outlineWidth = style.outlineWidth || 1, + outlineStrokeWidth = style.lineWidth + (2 * outlineWidth); + outlineStyle = _jp.extend({}, style); + delete outlineStyle.gradient; + outlineStyle.strokeStyle = _ju.convertStyle(style.outlineColor); + outlineStyle.lineWidth = outlineStrokeWidth; + + if (self.bgPath == null) { + self.bgPath = _node("path", a); + _jp.addClass(self.bgPath, _jp.connectorOutlineClass); + _appendAtIndex(self.svg, self.bgPath, 0); + } + else { + _attr(self.bgPath, a); + } + + _applyStyles(self.svg, self.bgPath, outlineStyle, d, self); + } + + if (self.path == null) { + self.path = _node("path", a); + _appendAtIndex(self.svg, self.path, style.outlineColor ? 1 : 0); + } + else { + _attr(self.path, a); + } + + _applyStyles(self.svg, self.path, style, d, self); + } + }; + }; + _ju.extend(_jp.ConnectorRenderers.svg, SvgComponent); + +// ******************************* svg segment renderer ***************************************************** + + _jp.Segments.svg = { + SegmentRenderer: { + getPath: function (segment) { + return ({ + "Straight": function () { + var d = segment.getCoordinates(); + return "M " + d.x1 + " " + d.y1 + " L " + d.x2 + " " + d.y2; + }, + "Bezier": function () { + var d = segment.params; + return "M " + d.x1 + " " + d.y1 + + " C " + d.cp1x + " " + d.cp1y + " " + d.cp2x + " " + d.cp2y + " " + d.x2 + " " + d.y2; + }, + "Arc": function () { + var d = segment.params, + laf = segment.sweep > Math.PI ? 1 : 0, + sf = segment.anticlockwise ? 0 : 1; + + return "M" + segment.x1 + " " + segment.y1 + " A " + segment.radius + " " + d.r + " 0 " + laf + "," + sf + " " + segment.x2 + " " + segment.y2; + } + })[segment.type](); + } + } + }; + +// ******************************* /svg segments ***************************************************** + + /* + * Base class for SVG endpoints. + */ + var SvgEndpoint = _jp.SvgEndpoint = function (params) { + var _super = SvgComponent.apply(this, [ + { + cssClass: params._jsPlumb.endpointClass, + originalArgs: arguments, + pointerEventsSpec: "all", + useDivWrapper: true, + _jsPlumb: params._jsPlumb + } + ]); + + _super.renderer.paint = function (style) { + var s = _jp.extend({}, style); + if (s.outlineColor) { + s.strokeWidth = s.outlineWidth; + s.strokeStyle = _ju.convertStyle(s.outlineColor, true); + } + + if (this.node == null) { + this.node = this.makeNode(s); + this.svg.appendChild(this.node); + } + else if (this.updateNode != null) { + this.updateNode(this.node); + } + _applyStyles(this.svg, this.node, s, [ this.x, this.y, this.w, this.h ], this); + _pos(this.node, [ this.x, this.y ]); + }.bind(this); + + }; + _ju.extend(SvgEndpoint, SvgComponent); + + /* + * SVG Dot Endpoint + */ + _jp.Endpoints.svg.Dot = function () { + _jp.Endpoints.Dot.apply(this, arguments); + SvgEndpoint.apply(this, arguments); + this.makeNode = function (style) { + return _node("circle", { + "cx": this.w / 2, + "cy": this.h / 2, + "r": this.radius + }); + }; + this.updateNode = function (node) { + _attr(node, { + "cx": this.w / 2, + "cy": this.h / 2, + "r": this.radius + }); + }; + }; + _ju.extend(_jp.Endpoints.svg.Dot, [_jp.Endpoints.Dot, SvgEndpoint]); + + /* + * SVG Rectangle Endpoint + */ + _jp.Endpoints.svg.Rectangle = function () { + _jp.Endpoints.Rectangle.apply(this, arguments); + SvgEndpoint.apply(this, arguments); + this.makeNode = function (style) { + return _node("rect", { + "width": this.w, + "height": this.h + }); + }; + this.updateNode = function (node) { + _attr(node, { + "width": this.w, + "height": this.h + }); + }; + }; + _ju.extend(_jp.Endpoints.svg.Rectangle, [_jp.Endpoints.Rectangle, SvgEndpoint]); + + /* + * SVG Image Endpoint is the default image endpoint. + */ + _jp.Endpoints.svg.Image = _jp.Endpoints.Image; + /* + * Blank endpoint in svg renderer is the default Blank endpoint. + */ + _jp.Endpoints.svg.Blank = _jp.Endpoints.Blank; + /* + * Label overlay in svg renderer is the default Label overlay. + */ + _jp.Overlays.svg.Label = _jp.Overlays.Label; + /* + * Custom overlay in svg renderer is the default Custom overlay. + */ + _jp.Overlays.svg.Custom = _jp.Overlays.Custom; + + var AbstractSvgArrowOverlay = function (superclass, originalArgs) { + superclass.apply(this, originalArgs); + _jp.jsPlumbUIComponent.apply(this, originalArgs); + this.isAppendedAtTopLevel = false; + var self = this; + this.path = null; + this.paint = function (params, containerExtents) { + // only draws on connections, not endpoints. + if (params.component.svg && containerExtents) { + if (this.path == null) { + this.path = _node("path", { + "pointer-events": "all" + }); + params.component.svg.appendChild(this.path); + + this.canvas = params.component.svg; // for the sake of completeness; this behaves the same as other overlays + } + var clazz = originalArgs && (originalArgs.length == 1) ? (originalArgs[0].cssClass || "") : "", + offset = [0, 0]; + + if (containerExtents.xmin < 0) offset[0] = -containerExtents.xmin; + if (containerExtents.ymin < 0) offset[1] = -containerExtents.ymin; + + _attr(this.path, { + "d": makePath(params.d), + "class": clazz, + stroke: params.strokeStyle ? params.strokeStyle : null, + fill: params.fillStyle ? params.fillStyle : null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + } + }; + var makePath = function (d) { + return (isNaN(d.cxy.x) || isNaN(d.cxy.y)) ? "" : "M" + d.hxy.x + "," + d.hxy.y + + " L" + d.tail[0].x + "," + d.tail[0].y + + " L" + d.cxy.x + "," + d.cxy.y + + " L" + d.tail[1].x + "," + d.tail[1].y + + " L" + d.hxy.x + "," + d.hxy.y; + }; + this.transfer = function(target) { + if (target.canvas && this.path && this.path.parentNode) { + this.path.parentNode.removeChild(this.path); + target.canvas.appendChild(this.path); + } + }; + }; + _ju.extend(AbstractSvgArrowOverlay, [_jp.jsPlumbUIComponent, _jp.Overlays.AbstractOverlay], { + cleanup: function (force) { + if (this.path != null) { + if (force) + this._jsPlumb.instance.removeElement(this.path); + else + if (this.path.parentNode) + this.path.parentNode.removeChild(this.path); + } + }, + reattach:function(instance) { + if (this.path && this.canvas && this.path.parentNode == null) + this.canvas.appendChild(this.path); + }, + setVisible: function (v) { + if (this.path != null) (this.path.style.display = (v ? "block" : "none")); + } + }); + + _jp.Overlays.svg.Arrow = function () { + AbstractSvgArrowOverlay.apply(this, [_jp.Overlays.Arrow, arguments]); + }; + _ju.extend(_jp.Overlays.svg.Arrow, [ _jp.Overlays.Arrow, AbstractSvgArrowOverlay ]); + + _jp.Overlays.svg.PlainArrow = function () { + AbstractSvgArrowOverlay.apply(this, [_jp.Overlays.PlainArrow, arguments]); + }; + _ju.extend(_jp.Overlays.svg.PlainArrow, [ _jp.Overlays.PlainArrow, AbstractSvgArrowOverlay ]); + + _jp.Overlays.svg.Diamond = function () { + AbstractSvgArrowOverlay.apply(this, [_jp.Overlays.Diamond, arguments]); + }; + _ju.extend(_jp.Overlays.svg.Diamond, [ _jp.Overlays.Diamond, AbstractSvgArrowOverlay ]); + + // a test + _jp.Overlays.svg.GuideLines = function () { + var path = null, self = this, p1_1, p1_2; + _jp.Overlays.GuideLines.apply(this, arguments); + this.paint = function (params, containerExtents) { + if (path == null) { + path = _node("path"); + params.connector.svg.appendChild(path); + self.attachListeners(path, params.connector); + self.attachListeners(path, self); + + p1_1 = _node("path"); + params.connector.svg.appendChild(p1_1); + self.attachListeners(p1_1, params.connector); + self.attachListeners(p1_1, self); + + p1_2 = _node("path"); + params.connector.svg.appendChild(p1_2); + self.attachListeners(p1_2, params.connector); + self.attachListeners(p1_2, self); + } + + var offset = [0, 0]; + if (containerExtents.xmin < 0) offset[0] = -containerExtents.xmin; + if (containerExtents.ymin < 0) offset[1] = -containerExtents.ymin; + + _attr(path, { + "d": makePath(params.head, params.tail), + stroke: "red", + fill: null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + + _attr(p1_1, { + "d": makePath(params.tailLine[0], params.tailLine[1]), + stroke: "blue", + fill: null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + + _attr(p1_2, { + "d": makePath(params.headLine[0], params.headLine[1]), + stroke: "green", + fill: null, + transform: "translate(" + offset[0] + "," + offset[1] + ")" + }); + }; + + var makePath = function (d1, d2) { + return "M " + d1.x + "," + d1.y + + " L" + d2.x + "," + d2.y; + }; + }; + _ju.extend(_jp.Overlays.svg.GuideLines, _jp.Overlays.GuideLines); +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the VML renderers. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ + +; +(function () { + + "use strict"; + var root = this, _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + // http://ajaxian.com/archives/the-vml-changes-in-ie-8 + // http://www.nczonline.net/blog/2010/01/19/internet-explorer-8-document-and-browser-modes/ + // http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/ + + var vmlAttributeMap = { + "stroke-linejoin": "joinstyle", + "joinstyle": "joinstyle", + "endcap": "endcap", + "miterlimit": "miterlimit" + }, + jsPlumbStylesheet = null; + + if (document.createStyleSheet && document.namespaces) { + + var ruleClasses = [ + ".jsplumb_vml", "jsplumb\\:textbox", "jsplumb\\:oval", "jsplumb\\:rect", + "jsplumb\\:stroke", "jsplumb\\:shape", "jsplumb\\:group" + ], + rule = "behavior:url(#default#VML);position:absolute;"; + + jsPlumbStylesheet = document.createStyleSheet(); + + for (var i = 0; i < ruleClasses.length; i++) + jsPlumbStylesheet.addRule(ruleClasses[i], rule); + + // in this page it is also mentioned that IE requires the extra arg to the namespace + // http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/ + // but someone commented saying they didn't need it, and it seems jsPlumb doesnt need it either. + // var iev = document.documentMode; + //if (!iev || iev < 8) + document.namespaces.add("jsplumb", "urn:schemas-microsoft-com:vml"); + //else + // document.namespaces.add("jsplumb", "urn:schemas-microsoft-com:vml", "#default#VML"); + } + + _jp.vml = {}; + + var scale = 1000, + + _atts = function (o, atts) { + for (var i in atts) { + // IE8 fix: setattribute does not work after an element has been added to the dom! + // http://www.louisremi.com/2009/03/30/changes-in-vml-for-ie8-or-what-feature-can-the-ie-dev-team-break-for-you-today/ + //o.setAttribute(i, atts[i]); + + /*There is an additional problem when accessing VML elements by using get/setAttribute. The simple solution is following: + + if (document.documentMode==8) { + ele.opacity=1; + } else { + ele.setAttribute(‘opacity’,1); + } + */ + + o[i] = atts[i]; + } + }, + _node = function (name, d, atts, parent, _jsPlumb, deferToJsPlumbContainer) { + atts = atts || {}; + var o = document.createElement("jsplumb:" + name); + if (deferToJsPlumbContainer) + _jsPlumb.appendElement(o, parent); + else + // TODO is this failing? that would be because parent is not a plain DOM element. + // IF SO, uncomment the line below this one and remove this one. + parent.appendChild(o); + //jsPlumb.getElement(parent).appendChild(o); + + o.className = (atts["class"] ? atts["class"] + " " : "") + "jsplumb_vml"; + _pos(o, d); + _atts(o, atts); + return o; + }, + _pos = function (o, d, zIndex) { + o.style.left = d[0] + "px"; + o.style.top = d[1] + "px"; + o.style.width = d[2] + "px"; + o.style.height = d[3] + "px"; + o.style.position = "absolute"; + if (zIndex) + o.style.zIndex = zIndex; + }, + _conv = _jp.vml.convertValue = function (v) { + return Math.floor(v * scale); + }, + // tests if the given style is "transparent" and then sets the appropriate opacity node to 0 if so, + // or 1 if not. TODO in the future, support variable opacity. + _maybeSetOpacity = function (styleToWrite, styleToCheck, type, component) { + if ("transparent" === styleToCheck) + component.setOpacity(type, "0.0"); + else + component.setOpacity(type, "1.0"); + }, + _applyStyles = function (node, style, component, _jsPlumb) { + var styleToWrite = {}; + if (style.strokeStyle) { + styleToWrite.stroked = "true"; + var strokeColor = _ju.convertStyle(style.strokeStyle, true); + styleToWrite.strokecolor = strokeColor; + _maybeSetOpacity(styleToWrite, strokeColor, "stroke", component); + styleToWrite.strokeweight = style.lineWidth + "px"; + } + else styleToWrite.stroked = "false"; + + if (style.fillStyle) { + styleToWrite.filled = "true"; + var fillColor = _ju.convertStyle(style.fillStyle, true); + styleToWrite.fillcolor = fillColor; + _maybeSetOpacity(styleToWrite, fillColor, "fill", component); + } + else styleToWrite.filled = "false"; + + if (style.dashstyle) { + if (component.strokeNode == null) { + component.strokeNode = _node("stroke", [0, 0, 0, 0], { dashstyle: style.dashstyle }, node, _jsPlumb); + } + else + component.strokeNode.dashstyle = style.dashstyle; + } + else if (style["stroke-dasharray"] && style.lineWidth) { + var sep = style["stroke-dasharray"].indexOf(",") == -1 ? " " : ",", + parts = style["stroke-dasharray"].split(sep), + styleToUse = ""; + for (var i = 0; i < parts.length; i++) { + styleToUse += (Math.floor(parts[i] / style.lineWidth) + sep); + } + if (component.strokeNode == null) { + component.strokeNode = _node("stroke", [0, 0, 0, 0], { dashstyle: styleToUse }, node, _jsPlumb); + } + else + component.strokeNode.dashstyle = styleToUse; + } + + _atts(node, styleToWrite); + }, + /* + * Base class for Vml endpoints and connectors. Extends jsPlumbUIComponent. + */ + VmlComponent = function () { + var self = this, renderer = {}; + _jp.jsPlumbUIComponent.apply(this, arguments); + + this.opacityNodes = { + "stroke": null, + "fill": null + }; + this.initOpacityNodes = function (vml) { + self.opacityNodes.stroke = _node("stroke", [0, 0, 1, 1], {opacity: "0.0"}, vml, self._jsPlumb.instance); + self.opacityNodes.fill = _node("fill", [0, 0, 1, 1], {opacity: "0.0"}, vml, self._jsPlumb.instance); + }; + this.setOpacity = function (type, value) { + var node = self.opacityNodes[type]; + if (node) node.opacity = "" + value; + }; + var displayElements = [ ]; + this.getDisplayElements = function () { + return displayElements; + }; + + this.appendDisplayElement = function (el, doNotAppendToCanvas) { + if (!doNotAppendToCanvas) self.canvas.parentNode.appendChild(el); + displayElements.push(el); + }; + }; + _ju.extend(VmlComponent, _jp.jsPlumbUIComponent, { + cleanup: function () { + if (this.bgCanvas) this.bgCanvas.parentNode.removeChild(this.bgCanvas); + if (this.canvas) this.canvas.parentNode.removeChild(this.canvas); + } + }); + + /* + * Base class for Vml connectors. extends VmlComponent. + */ + var VmlConnector = _jp.ConnectorRenderers.vml = function (params, component) { + this.strokeNode = null; + this.canvas = null; + VmlComponent.apply(this, arguments); + var clazz = this._jsPlumb.instance.connectorClass + (params.cssClass ? (" " + params.cssClass) : ""); + this.paint = function (style) { + if (style !== null) { + + // we need to be at least 1 pixel in each direction, because otherwise coordsize gets set to + // 0 and overlays cannot paint. + this.w = Math.max(this.w, 1); + this.h = Math.max(this.h, 1); + + var segments = this.getSegments(), p = { "path": "" }, + d = [this.x, this.y, this.w, this.h]; + + // create path from segments. + for (var i = 0; i < segments.length; i++) { + p.path += _jp.Segments.vml.SegmentRenderer.getPath(segments[i]); + p.path += " "; + } + + //* + if (style.outlineColor) { + var outlineWidth = style.outlineWidth || 1, + outlineStrokeWidth = style.lineWidth + (2 * outlineWidth), + outlineStyle = { + strokeStyle: _ju.convertStyle(style.outlineColor), + lineWidth: outlineStrokeWidth + }; + for (var aa in vmlAttributeMap) outlineStyle[aa] = style[aa]; + + if (this.bgCanvas == null) { + p["class"] = clazz; + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + this.bgCanvas = _node("shape", d, p, params.parent, this._jsPlumb.instance, true); + _pos(this.bgCanvas, d); + this.appendDisplayElement(this.bgCanvas, true); + this.initOpacityNodes(this.bgCanvas, ["stroke"]); + this.bgCanvas._jsPlumb = component; + } + else { + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + _pos(this.bgCanvas, d); + _atts(this.bgCanvas, p); + } + + _applyStyles(this.bgCanvas, outlineStyle, this); + } + //*/ + + if (this.canvas == null) { + p["class"] = clazz; + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + this.canvas = _node("shape", d, p, params.parent, this._jsPlumb.instance, true); + this.appendDisplayElement(this.canvas, true); + this.initOpacityNodes(this.canvas, ["stroke"]); + this.canvas._jsPlumb = component; + } + else { + p.coordsize = (d[2] * scale) + "," + (d[3] * scale); + _pos(this.canvas, d); + _atts(this.canvas, p); + } + + _applyStyles(this.canvas, style, this, this._jsPlumb.instance); + } + }; + + }; + _ju.extend(VmlConnector, VmlComponent, { + setVisible: function (v) { + if (this.canvas) { + this.canvas.style.display = v ? "block" : "none"; + } + if (this.bgCanvas) { + this.bgCanvas.style.display = v ? "block" : "none"; + } + } + }); + + /* + * + * Base class for Vml Endpoints. extends VmlComponent. + * + */ + var VmlEndpoint = _jp.VmlEndpoint = function (params) { + VmlComponent.apply(this, arguments); + this._jsPlumb.vml = null;//, opacityStrokeNode = null, opacityFillNode = null; + this.canvas = document.createElement("div"); + this.canvas.style.position = "absolute"; + this._jsPlumb.clazz = this._jsPlumb.instance.endpointClass + (params.cssClass ? (" " + params.cssClass) : ""); + + // TODO vml endpoint adds class to VML at constructor time. but the addClass method adds VML + // to the enclosing DIV. what to do? seems like it would be better to just target the div. + // HOWEVER...vml connection has no containing div. why not? it feels like it should. + + params._jsPlumb.appendElement(this.canvas, params.parent); + + this.paint = function (style, anchor) { + var p = { }, vml = this._jsPlumb.vml; + + _ju.sizeElement(this.canvas, this.x, this.y, this.w, this.h); + if (this._jsPlumb.vml == null) { + p["class"] = this._jsPlumb.clazz; + vml = this._jsPlumb.vml = this.getVml([0, 0, this.w, this.h], p, anchor, this.canvas, this._jsPlumb.instance); + + this.appendDisplayElement(vml, true); + this.appendDisplayElement(this.canvas, true); + + this.initOpacityNodes(vml, ["fill"]); + } + else { + _pos(vml, [0, 0, this.w, this.h]); + _atts(vml, p); + } + + _applyStyles(vml, style, this); + }; + }; + _ju.extend(VmlEndpoint, VmlComponent); + +// ******************************* vml segments ***************************************************** + + _jp.Segments.vml = { + SegmentRenderer: { + getPath: function (segment) { + return ({ + "Straight": function (segment) { + var d = segment.params; + return "m" + _conv(d.x1) + "," + _conv(d.y1) + " l" + _conv(d.x2) + "," + _conv(d.y2) + " e"; + }, + "Bezier": function (segment) { + var d = segment.params; + return "m" + _conv(d.x1) + "," + _conv(d.y1) + + " c" + _conv(d.cp1x) + "," + _conv(d.cp1y) + "," + _conv(d.cp2x) + "," + _conv(d.cp2y) + "," + _conv(d.x2) + "," + _conv(d.y2) + " e"; + }, + "Arc": function (segment) { + var d = segment.params, + xmin = Math.min(d.x1, d.x2), + xmax = Math.max(d.x1, d.x2), + ymin = Math.min(d.y1, d.y2), + ymax = Math.max(d.y1, d.y2), + sf = segment.anticlockwise ? 1 : 0, + pathType = (segment.anticlockwise ? "at " : "wa "), + makePosString = function () { + if (d.loopback) + return "0,0," + _conv(2 * d.r) + "," + _conv(2 * d.r); + + var xy = [ + null, + [ function () { + return [xmin, ymin ]; + }, function () { + return [xmin - d.r, ymin - d.r ]; + }], + [ function () { + return [xmin - d.r, ymin ]; + }, function () { + return [xmin, ymin - d.r ]; + }], + [ function () { + return [xmin - d.r, ymin - d.r ]; + }, function () { + return [xmin, ymin ]; + }], + [ function () { + return [xmin, ymin - d.r ]; + }, function () { + return [xmin - d.r, ymin ]; + }] + ][segment.segment][sf](); + + return _conv(xy[0]) + "," + _conv(xy[1]) + "," + _conv(xy[0] + (2 * d.r)) + "," + _conv(xy[1] + (2 * d.r)); + }; + + return pathType + " " + makePosString() + "," + _conv(d.x1) + "," + _conv(d.y1) + "," + _conv(d.x2) + "," + _conv(d.y2) + " e"; + } + + })[segment.type](segment); + } + } + }; + +// ******************************* /vml segments ***************************************************** + +// ******************************* vml endpoints ***************************************************** + + _jp.Endpoints.vml.Dot = function () { + _jp.Endpoints.Dot.apply(this, arguments); + VmlEndpoint.apply(this, arguments); + this.getVml = function (d, atts, anchor, parent, _jsPlumb) { + return _node("oval", d, atts, parent, _jsPlumb); + }; + }; + _ju.extend(_jp.Endpoints.vml.Dot, VmlEndpoint); + + _jp.Endpoints.vml.Rectangle = function () { + _jp.Endpoints.Rectangle.apply(this, arguments); + VmlEndpoint.apply(this, arguments); + this.getVml = function (d, atts, anchor, parent, _jsPlumb) { + return _node("rect", d, atts, parent, _jsPlumb); + }; + }; + _ju.extend(_jp.Endpoints.vml.Rectangle, VmlEndpoint); + + /* + * VML Image Endpoint is the same as the default image endpoint. + */ + _jp.Endpoints.vml.Image = _jp.Endpoints.Image; + + /** + * placeholder for Blank endpoint in vml renderer. + */ + _jp.Endpoints.vml.Blank = _jp.Endpoints.Blank; + +// ******************************* /vml endpoints ***************************************************** + +// ******************************* vml overlays ***************************************************** + + /** + * VML Label renderer. uses the default label renderer (which adds an element to the DOM) + */ + _jp.Overlays.vml.Label = _jp.Overlays.Label; + + /** + * VML Custom renderer. uses the default Custom renderer (which adds an element to the DOM) + */ + _jp.Overlays.vml.Custom = _jp.Overlays.Custom; + + /** + * Abstract VML arrow superclass + */ + var AbstractVmlArrowOverlay = function (superclass, originalArgs) { + superclass.apply(this, originalArgs); + VmlComponent.apply(this, originalArgs); + var self = this, path = null; + this.canvas = null; + this.isAppendedAtTopLevel = true; + var getPath = function (d) { + return "m " + _conv(d.hxy.x) + "," + _conv(d.hxy.y) + + " l " + _conv(d.tail[0].x) + "," + _conv(d.tail[0].y) + + " " + _conv(d.cxy.x) + "," + _conv(d.cxy.y) + + " " + _conv(d.tail[1].x) + "," + _conv(d.tail[1].y) + + " x e"; + }; + this.paint = function (params, containerExtents) { + // only draws for connectors, not endpoints. + if (params.component.canvas && containerExtents) { + var p = {}, d = params.d, connector = params.component; + if (params.strokeStyle) { + p.stroked = "true"; + p.strokecolor = _ju.convertStyle(params.strokeStyle, true); + } + if (params.lineWidth) p.strokeweight = params.lineWidth + "px"; + if (params.fillStyle) { + p.filled = "true"; + p.fillcolor = params.fillStyle; + } + + var xmin = Math.min(d.hxy.x, d.tail[0].x, d.tail[1].x, d.cxy.x), + ymin = Math.min(d.hxy.y, d.tail[0].y, d.tail[1].y, d.cxy.y), + xmax = Math.max(d.hxy.x, d.tail[0].x, d.tail[1].x, d.cxy.x), + ymax = Math.max(d.hxy.y, d.tail[0].y, d.tail[1].y, d.cxy.y), + w = Math.abs(xmax - xmin), + h = Math.abs(ymax - ymin), + dim = [xmin, ymin, w, h]; + + // for VML, we create overlays using shapes that have the same dimensions and + // coordsize as their connector - overlays calculate themselves relative to the + // connector (it's how it's been done since the original canvas implementation, because + // for canvas that makes sense). + p.path = getPath(d); + p.coordsize = (connector.w * scale) + "," + (connector.h * scale); + + dim[0] = connector.x; + dim[1] = connector.y; + dim[2] = connector.w; + dim[3] = connector.h; + + if (self.canvas == null) { + var overlayClass = connector._jsPlumb.overlayClass || ""; + var clazz = originalArgs && (originalArgs.length == 1) ? (originalArgs[0].cssClass || "") : ""; + p["class"] = clazz + " " + overlayClass; + self.canvas = _node("shape", dim, p, connector.canvas.parentNode, connector._jsPlumb.instance, true); + connector.appendDisplayElement(self.canvas, true); + } + else { + _pos(self.canvas, dim); + _atts(self.canvas, p); + } + } + }; + this.cleanup = function () { + if (this.canvas != null) this._jsPlumb.instance.removeElement(this.canvas); + }; + }; + _ju.extend(AbstractVmlArrowOverlay, [VmlComponent, _jp.Overlays.AbstractOverlay], { + setVisible: function (state) { + this.canvas.style.display = state ? "block" : "none"; + } + }); + + _jp.Overlays.vml.Arrow = function () { + AbstractVmlArrowOverlay.apply(this, [_jp.Overlays.Arrow, arguments]); + }; + _ju.extend(_jp.Overlays.vml.Arrow, [ _jp.Overlays.Arrow, AbstractVmlArrowOverlay ]); + + _jp.Overlays.vml.PlainArrow = function () { + AbstractVmlArrowOverlay.apply(this, [_jp.Overlays.PlainArrow, arguments]); + }; + _ju.extend(_jp.Overlays.vml.PlainArrow, [ _jp.Overlays.PlainArrow, AbstractVmlArrowOverlay ]); + + _jp.Overlays.vml.Diamond = function () { + AbstractVmlArrowOverlay.apply(this, [_jp.Overlays.Diamond, arguments]); + }; + _ju.extend(_jp.Overlays.vml.Diamond, [ _jp.Overlays.Diamond, AbstractVmlArrowOverlay ]); + +// ******************************* /vml overlays ***************************************************** + +}).call(this); + +/* + * jsPlumb + * + * Title:jsPlumb 1.7.6 + * + * Provides a way to visually connect elements on an HTML page, using SVG or VML. + * + * This file contains the jQuery adapter. + * + * Copyright (c) 2010 - 2015 jsPlumb (hello@jsplumbtoolkit.com) + * + * http://jsplumbtoolkit.com + * http://github.com/sporritt/jsplumb + * + * Dual licensed under the MIT and GPL2 licenses. + */ +; +(function ($, root) { + + "use strict"; + var _jp = root.jsPlumb, _ju = root.jsPlumbUtil; + + var _getElementObject = function (el) { + return typeof(el) == "string" ? $("#" + el) : $(el); + }; + + $.extend(root.jsPlumbInstance.prototype, { + + animationSupported:true, + +// ---------------------------- DOM MANIPULATION --------------------------------------- + + + /** + * gets a DOM element from the given input, which might be a string (in which case we just do document.getElementById), + * a selector (in which case we return el[0]), or a DOM element already (we assume this if it's not either of the other + * two cases). this is the opposite of getElementObject below. + */ + getElement: function (el) { + if (el == null) return null; + if (typeof(el) == "string") return document.getElementById(el); + else if (el.context || el.length != null) return el[0]; + else return el; + }, + + /** + * removes an element from the DOM. doing it via the library is + * safer from a memory perspective, as it ix expected that the library's + * remove method will unbind any event listeners before removing the element from the DOM. + */ + removeElement: function (element) { + _getElementObject(element).remove(); + }, + +// ---------------------------- END DOM MANIPULATION --------------------------------------- + +// ---------------------------- MISCELLANEOUS --------------------------------------- + + /** + * animates the given element. + */ + doAnimate: function (el, properties, options) { + $(el).animate(properties, options); + }, + +// ---------------------------- END MISCELLANEOUS --------------------------------------- + +// -------------------------------------- DRAG/DROP --------------------------------- + + destroyDraggable: function (el) { + if ($(el).data("draggable")) + $(el).draggable("destroy"); + }, + + destroyDroppable: function (el) { + if ($(el).data("droppable")) + $(el).droppable("destroy"); + }, + /** + * initialises the given element to be draggable. + */ + initDraggable: function (el, options, isPlumbedComponent) { + options = options || {}; + el = $(el); + + options.start = _ju.wrap(options.start, function () { + $("body").addClass(this.dragSelectClass); + }, false); + + options.stop = _ju.wrap(options.stop, function () { + $("body").removeClass(this.dragSelectClass); + }); + + // remove helper directive if present and no override + if (!options.doNotRemoveHelper) + options.helper = null; + + + if (isPlumbedComponent == "internal") + options.scope = options.scope || _jp.Defaults.Scope; + + el.draggable(options); + }, + + /** + * initialises the given element to be droppable. + */ + initDroppable: function (el, options) { + options.scope = options.scope || _jp.Defaults.Scope; + $(el).droppable(options); + }, + + isAlreadyDraggable: function (el) { + return $(el).hasClass("ui-draggable"); + }, + + /** + * returns whether or not drag is supported (by the library, not whether or not it is disabled) for the given element. + */ + isDragSupported: function (el, options) { + return $(el).draggable; + }, + + /** + * returns whether or not drop is supported (by the library, not whether or not it is disabled) for the given element. + */ + isDropSupported: function (el, options) { + return $(el).droppable; + }, + /** + * takes the args passed to an event function and returns you an object representing that which is being dragged. + */ + getDragObject: function (eventArgs) { + var o = eventArgs[1].helper || eventArgs[1].draggable; + return o ? o[0] : null; + }, + + getDragScope: function (el) { + return $(el).draggable("option", "scope"); + }, + + getDropEvent: function (args) { + return args[0]; + }, + + getDropScope: function (el) { + return $(el).droppable("option", "scope"); + }, + /** + * takes the args passed to an event function and returns you an object that gives the + * position of the object being moved, as a js object with the same params as the result of + * getOffset, ie: { left: xxx, top: xxx }. + * + * different libraries have different signatures for their event callbacks. + * see getDragObject as well + */ + getUIPosition: function (eventArgs, zoom, dontAdjustHelper) { + var ret; + zoom = zoom || 1; + if (eventArgs.length == 1) { + ret = { left: eventArgs[0].pageX, top: eventArgs[0].pageY }; + } + else { + var ui = eventArgs[1], + _offset = ui.position;//ui.offset; + + ret = _offset || ui.absolutePosition; + + // adjust ui position to account for zoom, because jquery ui does not do this. + if (!dontAdjustHelper) { + ui.position.left /= zoom; + ui.position.top /= zoom; + } + } + return { left: ret.left, top: ret.top }; + }, + + setDragFilter: function (el, filter) { + if (_jp.isAlreadyDraggable(el)) + $(el).draggable("option", "cancel", filter); + }, + + setElementDraggable: function (el, draggable) { + $(el).draggable("option", "disabled", !draggable); + }, + + setDragScope: function (el, scope) { + $(el).draggable("option", "scope", scope); + }, + /** + * mapping of drag events for jQuery + */ + dragEvents: { + 'start': 'start', 'stop': 'stop', 'drag': 'drag', 'step': 'step', + 'over': 'over', 'out': 'out', 'drop': 'drop', 'complete': 'complete' + }, + animEvents: { + 'step': "step", 'complete': 'complete' + }, + getOriginalEvent: function (e) { + return e.originalEvent || e; + }, + /** + * note that jquery ignores the name of the event you wanted to trigger, and figures it out for itself. + * Mottle does not. (YUI, in fact, cannot even pass an original event...but we don't support YUI any longer). + * @param el + * @param event + * @param originalEvent + */ + trigger: function (el, event, originalEvent) { + el = this.getElement(el); + var h = jQuery._data($(el)[0], "handle"); + h(originalEvent); + } + +// -------------------------------------- END DRAG/DROP --------------------------------- + + }); + + $(document).ready(_jp.init); + +})(jQuery, this); + diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery-1.9.0-min.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery-1.9.0-min.js new file mode 100644 index 000000000..50d1b22f2 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery-1.9.0-min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.9.0 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license */(function(e,t){"use strict";function n(e){var t=e.length,n=st.type(e);return st.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}function r(e){var t=Tt[e]={};return st.each(e.match(lt)||[],function(e,n){t[n]=!0}),t}function i(e,n,r,i){if(st.acceptData(e)){var o,a,s=st.expando,u="string"==typeof n,l=e.nodeType,c=l?st.cache:e,f=l?e[s]:e[s]&&s;if(f&&c[f]&&(i||c[f].data)||!u||r!==t)return f||(l?e[s]=f=K.pop()||st.guid++:f=s),c[f]||(c[f]={},l||(c[f].toJSON=st.noop)),("object"==typeof n||"function"==typeof n)&&(i?c[f]=st.extend(c[f],n):c[f].data=st.extend(c[f].data,n)),o=c[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[st.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[st.camelCase(n)])):a=o,a}}function o(e,t,n){if(st.acceptData(e)){var r,i,o,a=e.nodeType,u=a?st.cache:e,l=a?e[st.expando]:st.expando;if(u[l]){if(t&&(r=n?u[l]:u[l].data)){st.isArray(t)?t=t.concat(st.map(t,st.camelCase)):t in r?t=[t]:(t=st.camelCase(t),t=t in r?[t]:t.split(" "));for(i=0,o=t.length;o>i;i++)delete r[t[i]];if(!(n?s:st.isEmptyObject)(r))return}(n||(delete u[l].data,s(u[l])))&&(a?st.cleanData([e],!0):st.support.deleteExpando||u!=u.window?delete u[l]:u[l]=null)}}}function a(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(Nt,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:wt.test(r)?st.parseJSON(r):r}catch(o){}st.data(e,n,r)}else r=t}return r}function s(e){var t;for(t in e)if(("data"!==t||!st.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function u(){return!0}function l(){return!1}function c(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function f(e,t,n){if(t=t||0,st.isFunction(t))return st.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return st.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=st.grep(e,function(e){return 1===e.nodeType});if(Wt.test(t))return st.filter(t,r,!n);t=st.filter(t,r)}return st.grep(e,function(e){return st.inArray(e,t)>=0===n})}function p(e){var t=zt.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function d(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function h(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function g(e){var t=nn.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function m(e,t){for(var n,r=0;null!=(n=e[r]);r++)st._data(n,"globalEval",!t||st._data(t[r],"globalEval"))}function y(e,t){if(1===t.nodeType&&st.hasData(e)){var n,r,i,o=st._data(e),a=st._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)st.event.add(t,n,s[n][r])}a.data&&(a.data=st.extend({},a.data))}}function v(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!st.support.noCloneEvent&&t[st.expando]){r=st._data(t);for(i in r.events)st.removeEvent(t,i,r.handle);t.removeAttribute(st.expando)}"script"===n&&t.text!==e.text?(h(t).text=e.text,g(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),st.support.html5Clone&&e.innerHTML&&!st.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Zt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function b(e,n){var r,i,o=0,a=e.getElementsByTagName!==t?e.getElementsByTagName(n||"*"):e.querySelectorAll!==t?e.querySelectorAll(n||"*"):t;if(!a)for(a=[],r=e.childNodes||e;null!=(i=r[o]);o++)!n||st.nodeName(i,n)?a.push(i):st.merge(a,b(i,n));return n===t||n&&st.nodeName(e,n)?st.merge([e],a):a}function x(e){Zt.test(e.type)&&(e.defaultChecked=e.checked)}function T(e,t){if(t in e)return t;for(var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Nn.length;i--;)if(t=Nn[i]+n,t in e)return t;return r}function w(e,t){return e=t||e,"none"===st.css(e,"display")||!st.contains(e.ownerDocument,e)}function N(e,t){for(var n,r=[],i=0,o=e.length;o>i;i++)n=e[i],n.style&&(r[i]=st._data(n,"olddisplay"),t?(r[i]||"none"!==n.style.display||(n.style.display=""),""===n.style.display&&w(n)&&(r[i]=st._data(n,"olddisplay",S(n.nodeName)))):r[i]||w(n)||st._data(n,"olddisplay",st.css(n,"display")));for(i=0;o>i;i++)n=e[i],n.style&&(t&&"none"!==n.style.display&&""!==n.style.display||(n.style.display=t?r[i]||"":"none"));return e}function C(e,t,n){var r=mn.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function k(e,t,n,r,i){for(var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;4>o;o+=2)"margin"===n&&(a+=st.css(e,n+wn[o],!0,i)),r?("content"===n&&(a-=st.css(e,"padding"+wn[o],!0,i)),"margin"!==n&&(a-=st.css(e,"border"+wn[o]+"Width",!0,i))):(a+=st.css(e,"padding"+wn[o],!0,i),"padding"!==n&&(a+=st.css(e,"border"+wn[o]+"Width",!0,i)));return a}function E(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=ln(e),a=st.support.boxSizing&&"border-box"===st.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=un(e,t,o),(0>i||null==i)&&(i=e.style[t]),yn.test(i))return i;r=a&&(st.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+k(e,t,n||(a?"border":"content"),r,o)+"px"}function S(e){var t=V,n=bn[e];return n||(n=A(e,t),"none"!==n&&n||(cn=(cn||st("':""),e._keyEvent=!1,B},_generateMonthYearHeader:function(e,t,n,r,i,s,o,u){var a=this._get(e,"changeMonth"),f=this._get(e,"changeYear"),l=this._get(e,"showMonthAfterYear"),c='
    ',h="";if(s||!a)h+=''+o[t]+"";else{var p=r&&r.getFullYear()==n,d=i&&i.getFullYear()==n;h+='"}l||(c+=h+(s||!a||!f?" ":""));if(!e.yearshtml){e.yearshtml="";if(s||!f)c+=''+n+"";else{var m=this._get(e,"yearRange").split(":"),g=(new Date).getFullYear(),y=function(e){var t=e.match(/c[+-].*/)?n+parseInt(e.substring(1),10):e.match(/[+-].*/)?g+parseInt(e,10):parseInt(e,10);return isNaN(t)?g:t},b=y(m[0]),w=Math.max(b,y(m[1]||""));b=r?Math.max(b,r.getFullYear()):b,w=i?Math.min(w,i.getFullYear()):w,e.yearshtml+='",c+=e.yearshtml,e.yearshtml=null}}return c+=this._get(e,"yearSuffix"),l&&(c+=(s||!a||!f?" ":"")+h),c+="
    ",c},_adjustInstDate:function(e,t,n){var r=e.drawYear+(n=="Y"?t:0),i=e.drawMonth+(n=="M"?t:0),s=Math.min(e.selectedDay,this._getDaysInMonth(r,i))+(n=="D"?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(r,i,s)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),(n=="M"||n=="Y")&&this._notifyChange(e)},_restrictMinMax:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max"),i=n&&tr?r:i,i},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return t==null?[1,1]:typeof t=="number"?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return(new Date(e,t,1)).getDay()},_canAdjustMonth:function(e,t,n,r){var i=this._getNumberOfMonths(e),s=this._daylightSavingAdjust(new Date(n,r+(t<0?t:i[0]*i[1]),1));return t<0&&s.setDate(this._getDaysInMonth(s.getFullYear(),s.getMonth())),this._isInRange(e,s)},_isInRange:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max");return(!n||t.getTime()>=n.getTime())&&(!r||t.getTime()<=r.getTime())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t=typeof t!="string"?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,n,r){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var i=t?typeof t=="object"?t:this._daylightSavingAdjust(new Date(r,n,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),i,this._getFormatConfig(e))}}),$.fn.datepicker=function(e){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find(document.body).append($.datepicker.dpDiv),$.datepicker.initialized=!0);var t=Array.prototype.slice.call(arguments,1);return typeof e!="string"||e!="isDisabled"&&e!="getDate"&&e!="widget"?e=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t)):this.each(function(){typeof e=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this].concat(t)):$.datepicker._attachDatepicker(this,e)}):$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.9.2",window["DP_jQuery_"+dpuuid]=$}(jQuery),function(e,t){var n="ui-dialog ui-widget ui-widget-content ui-corner-all ",r={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},i={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};e.widget("ui.dialog",{version:"1.9.2",options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var n=e(this).css(t).offset().top;n<0&&e(this).css("top",t.top-n)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.oldPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.options.title=this.options.title||this.originalTitle;var t=this,r=this.options,i=r.title||" ",s,o,u,a,f;s=(this.uiDialog=e("
    ")).addClass(n+r.dialogClass).css({display:"none",outline:0,zIndex:r.zIndex}).attr("tabIndex",-1).keydown(function(n){r.closeOnEscape&&!n.isDefaultPrevented()&&n.keyCode&&n.keyCode===e.ui.keyCode.ESCAPE&&(t.close(n),n.preventDefault())}).mousedown(function(e){t.moveToTop(!1,e)}).appendTo("body"),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(s),o=(this.uiDialogTitlebar=e("
    ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").bind("mousedown",function(){s.focus()}).prependTo(s),u=e("").addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").click(function(e){e.preventDefault(),t.close(e)}).appendTo(o),(this.uiDialogTitlebarCloseText=e("")).addClass("ui-icon ui-icon-closethick").text(r.closeText).appendTo(u),a=e("").uniqueId().addClass("ui-dialog-title").html(i).prependTo(o),f=(this.uiDialogButtonPane=e("
    ")).addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),(this.uiButtonSet=e("
    ")).addClass("ui-dialog-buttonset").appendTo(f),s.attr({role:"dialog","aria-labelledby":a.attr("id")}),o.find("*").add(o).disableSelection(),this._hoverable(u),this._focusable(u),r.draggable&&e.fn.draggable&&this._makeDraggable(),r.resizable&&e.fn.resizable&&this._makeResizable(),this._createButtons(r.buttons),this._isOpen=!1,e.fn.bgiframe&&s.bgiframe(),this._on(s,{keydown:function(t){if(!r.modal||t.keyCode!==e.ui.keyCode.TAB)return;var n=e(":tabbable",s),i=n.filter(":first"),o=n.filter(":last");if(t.target===o[0]&&!t.shiftKey)return i.focus(1),!1;if(t.target===i[0]&&t.shiftKey)return o.focus(1),!1}})},_init:function(){this.options.autoOpen&&this.open()},_destroy:function(){var e,t=this.oldPosition;this.overlay&&this.overlay.destroy(),this.uiDialog.hide(),this.element.removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},close:function(t){var n=this,r,i;if(!this._isOpen)return;if(!1===this._trigger("beforeClose",t))return;return this._isOpen=!1,this.overlay&&this.overlay.destroy(),this.options.hide?this._hide(this.uiDialog,this.options.hide,function(){n._trigger("close",t)}):(this.uiDialog.hide(),this._trigger("close",t)),e.ui.dialog.overlay.resize(),this.options.modal&&(r=0,e(".ui-dialog").each(function(){this!==n.uiDialog[0]&&(i=e(this).css("z-index"),isNaN(i)||(r=Math.max(r,i)))}),e.ui.dialog.maxZ=r),this},isOpen:function(){return this._isOpen},moveToTop:function(t,n){var r=this.options,i;return r.modal&&!t||!r.stack&&!r.modal?this._trigger("focus",n):(r.zIndex>e.ui.dialog.maxZ&&(e.ui.dialog.maxZ=r.zIndex),this.overlay&&(e.ui.dialog.maxZ+=1,e.ui.dialog.overlay.maxZ=e.ui.dialog.maxZ,this.overlay.$el.css("z-index",e.ui.dialog.overlay.maxZ)),i={scrollTop:this.element.scrollTop(),scrollLeft:this.element.scrollLeft()},e.ui.dialog.maxZ+=1,this.uiDialog.css("z-index",e.ui.dialog.maxZ),this.element.attr(i),this._trigger("focus",n),this)},open:function(){if(this._isOpen)return;var t,n=this.options,r=this.uiDialog;return this._size(),this._position(n.position),r.show(n.show),this.overlay=n.modal?new e.ui.dialog.overlay(this):null,this.moveToTop(!0),t=this.element.find(":tabbable"),t.length||(t=this.uiDialogButtonPane.find(":tabbable"),t.length||(t=r)),t.eq(0).focus(),this._isOpen=!0,this._trigger("open"),this},_createButtons:function(t){var n=this,r=!1;this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),typeof t=="object"&&t!==null&&e.each(t,function(){return!(r=!0)}),r?(e.each(t,function(t,r){var i,s;r=e.isFunction(r)?{click:r,text:t}:r,r=e.extend({type:"button"},r),s=r.click,r.click=function(){s.apply(n.element[0],arguments)},i=e("",r).appendTo(n.uiButtonSet),e.fn.button&&i.button()}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog)):this.uiDialog.removeClass("ui-dialog-buttons")},_makeDraggable:function(){function r(e){return{position:e.position,offset:e.offset}}var t=this,n=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(n,i){e(this).addClass("ui-dialog-dragging"),t._trigger("dragStart",n,r(i))},drag:function(e,n){t._trigger("drag",e,r(n))},stop:function(i,s){n.position=[s.position.left-t.document.scrollLeft(),s.position.top-t.document.scrollTop()],e(this).removeClass("ui-dialog-dragging"),t._trigger("dragStop",i,r(s)),e.ui.dialog.overlay.resize()}})},_makeResizable:function(n){function u(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}n=n===t?this.options.resizable:n;var r=this,i=this.options,s=this.uiDialog.css("position"),o=typeof n=="string"?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:i.maxWidth,maxHeight:i.maxHeight,minWidth:i.minWidth,minHeight:this._minHeight(),handles:o,start:function(t,n){e(this).addClass("ui-dialog-resizing"),r._trigger("resizeStart",t,u(n))},resize:function(e,t){r._trigger("resize",e,u(t))},stop:function(t,n){e(this).removeClass("ui-dialog-resizing"),i.height=e(this).height(),i.width=e(this).width(),r._trigger("resizeStop",t,u(n)),e.ui.dialog.overlay.resize()}}).css("position",s).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var e=this.options;return e.height==="auto"?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(t){var n=[],r=[0,0],i;if(t){if(typeof t=="string"||typeof t=="object"&&"0"in t)n=t.split?t.split(" "):[t[0],t[1]],n.length===1&&(n[1]=n[0]),e.each(["left","top"],function(e,t){+n[e]===n[e]&&(r[e]=n[e],n[e]=t)}),t={my:n[0]+(r[0]<0?r[0]:"+"+r[0])+" "+n[1]+(r[1]<0?r[1]:"+"+r[1]),at:n.join(" ")};t=e.extend({},e.ui.dialog.prototype.options.position,t)}else t=e.ui.dialog.prototype.options.position;i=this.uiDialog.is(":visible"),i||this.uiDialog.show(),this.uiDialog.position(t),i||this.uiDialog.hide()},_setOptions:function(t){var n=this,s={},o=!1;e.each(t,function(e,t){n._setOption(e,t),e in r&&(o=!0),e in i&&(s[e]=t)}),o&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",s)},_setOption:function(t,r){var i,s,o=this.uiDialog;switch(t){case"buttons":this._createButtons(r);break;case"closeText":this.uiDialogTitlebarCloseText.text(""+r);break;case"dialogClass":o.removeClass(this.options.dialogClass).addClass(n+r);break;case"disabled":r?o.addClass("ui-dialog-disabled"):o.removeClass("ui-dialog-disabled");break;case"draggable":i=o.is(":data(draggable)"),i&&!r&&o.draggable("destroy"),!i&&r&&this._makeDraggable();break;case"position":this._position(r);break;case"resizable":s=o.is(":data(resizable)"),s&&!r&&o.resizable("destroy"),s&&typeof r=="string"&&o.resizable("option","handles",r),!s&&r!==!1&&this._makeResizable(r);break;case"title":e(".ui-dialog-title",this.uiDialogTitlebar).html(""+(r||" "))}this._super(t,r)},_size:function(){var t,n,r,i=this.options,s=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),i.minWidth>i.width&&(i.width=i.minWidth),t=this.uiDialog.css({height:"auto",width:i.width}).outerHeight(),n=Math.max(0,i.minHeight-t),i.height==="auto"?e.support.minHeight?this.element.css({minHeight:n,height:"auto"}):(this.uiDialog.show(),r=this.element.css("height","auto").height(),s||this.uiDialog.hide(),this.element.height(Math.max(r,n))):this.element.height(Math.max(i.height-t,0)),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),e.extend(e.ui.dialog,{uuid:0,maxZ:0,getTitleId:function(e){var t=e.attr("id");return t||(this.uuid+=1,t=this.uuid),"ui-dialog-title-"+t},overlay:function(t){this.$el=e.ui.dialog.overlay.create(t)}}),e.extend(e.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:e.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(e){return e+".dialog-overlay"}).join(" "),create:function(t){this.instances.length===0&&(setTimeout(function(){e.ui.dialog.overlay.instances.length&&e(document).bind(e.ui.dialog.overlay.events,function(t){if(e(t.target).zIndex()").addClass("ui-widget-overlay");return e(document).bind("keydown.dialog-overlay",function(r){var i=e.ui.dialog.overlay.instances;i.length!==0&&i[i.length-1]===n&&t.options.closeOnEscape&&!r.isDefaultPrevented()&&r.keyCode&&r.keyCode===e.ui.keyCode.ESCAPE&&(t.close(r),r.preventDefault())}),n.appendTo(document.body).css({width:this.width(),height:this.height()}),e.fn.bgiframe&&n.bgiframe(),this.instances.push(n),n},destroy:function(t){var n=e.inArray(t,this.instances),r=0;n!==-1&&this.oldInstances.push(this.instances.splice(n,1)[0]),this.instances.length===0&&e([document,window]).unbind(".dialog-overlay"),t.height(0).width(0).remove(),e.each(this.instances,function(){r=Math.max(r,this.css("z-index"))}),this.maxZ=r},height:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),n=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),t1&&b.splice.apply(b,[1,0].concat(b.splice(w,c+1))),r.dequeue()}}(jQuery),function(e,t){e.effects.effect.clip=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"vertical",a=u==="vertical",f=a?"height":"width",l=a?"top":"left",c={},h,p,d;e.effects.save(r,i),r.show(),h=e.effects.createWrapper(r).css({overflow:"hidden"}),p=r[0].tagName==="IMG"?h:r,d=p[f](),o&&(p.css(f,0),p.css(l,d/2)),c[f]=o?d:0,c[l]=o?0:d/2,p.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o||r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}}(jQuery),function(e,t){e.effects.effect.drop=function(t,n){var r=e(this),i=["position","top","bottom","left","right","opacity","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left"?"pos":"neg",l={opacity:o?1:0},c;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),c=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0)/2,o&&r.css("opacity",0).css(a,f==="pos"?-c:c),l[a]=(o?f==="pos"?"+=":"-=":f==="pos"?"-=":"+=")+c,r.animate(l,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}}(jQuery),function(e,t){e.effects.effect.explode=function(t,n){function y(){c.push(this),c.length===r*i&&b()}function b(){s.css({visibility:"visible"}),e(c).remove(),u||s.hide(),n()}var r=t.pieces?Math.round(Math.sqrt(t.pieces)):3,i=r,s=e(this),o=e.effects.setMode(s,t.mode||"hide"),u=o==="show",a=s.show().css("visibility","hidden").offset(),f=Math.ceil(s.outerWidth()/i),l=Math.ceil(s.outerHeight()/r),c=[],h,p,d,v,m,g;for(h=0;h
    ").css({position:"absolute",visibility:"visible",left:-p*f,top:-h*l}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:f,height:l,left:d+(u?m*f:0),top:v+(u?g*l:0),opacity:u?0:1}).animate({left:d+(u?0:m*f),top:v+(u?0:g*l),opacity:u?1:0},t.duration||500,t.easing,y)}}}(jQuery),function(e,t){e.effects.effect.fade=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"toggle");r.animate({opacity:i},{queue:!1,duration:t.duration,easing:t.easing,complete:n})}}(jQuery),function(e,t){e.effects.effect.fold=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=s==="hide",a=t.size||15,f=/([0-9]+)%/.exec(a),l=!!t.horizFirst,c=o!==l,h=c?["width","height"]:["height","width"],p=t.duration/2,d,v,m={},g={};e.effects.save(r,i),r.show(),d=e.effects.createWrapper(r).css({overflow:"hidden"}),v=c?[d.width(),d.height()]:[d.height(),d.width()],f&&(a=parseInt(f[1],10)/100*v[u?0:1]),o&&d.css(l?{height:0,width:a}:{height:a,width:0}),m[h[0]]=o?v[0]:a,g[h[1]]=o?v[1]:0,d.animate(m,p,t.easing).animate(g,p,t.easing,function(){u&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()})}}(jQuery),function(e,t){e.effects.effect.highlight=function(t,n){var r=e(this),i=["backgroundImage","backgroundColor","opacity"],s=e.effects.setMode(r,t.mode||"show"),o={backgroundColor:r.css("backgroundColor")};s==="hide"&&(o.opacity=0),e.effects.save(r,i),r.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(o,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),n()}})}}(jQuery),function(e,t){e.effects.effect.pulsate=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"show"),s=i==="show",o=i==="hide",u=s||i==="hide",a=(t.times||5)*2+(u?1:0),f=t.duration/a,l=0,c=r.queue(),h=c.length,p;if(s||!r.is(":visible"))r.css("opacity",0).show(),l=1;for(p=1;p1&&c.splice.apply(c,[1,0].concat(c.splice(h,a+1))),r.dequeue()}}(jQuery),function(e,t){e.effects.effect.puff=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"hide"),s=i==="hide",o=parseInt(t.percent,10)||150,u=o/100,a={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()};e.extend(t,{effect:"scale",queue:!1,fade:!0,mode:i,complete:n,percent:s?o:100,from:s?a:{height:a.height*u,width:a.width*u,outerHeight:a.outerHeight*u,outerWidth:a.outerWidth*u}}),r.effect(t)},e.effects.effect.scale=function(t,n){var r=e(this),i=e.extend(!0,{},t),s=e.effects.setMode(r,t.mode||"effect"),o=parseInt(t.percent,10)||(parseInt(t.percent,10)===0?0:s==="hide"?0:100),u=t.direction||"both",a=t.origin,f={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()},l={y:u!=="horizontal"?o/100:1,x:u!=="vertical"?o/100:1};i.effect="size",i.queue=!1,i.complete=n,s!=="effect"&&(i.origin=a||["middle","center"],i.restore=!0),i.from=t.from||(s==="show"?{height:0,width:0,outerHeight:0,outerWidth:0}:f),i.to={height:f.height*l.y,width:f.width*l.x,outerHeight:f.outerHeight*l.y,outerWidth:f.outerWidth*l.x},i.fade&&(s==="show"&&(i.from.opacity=0,i.to.opacity=1),s==="hide"&&(i.from.opacity=1,i.to.opacity=0)),r.effect(i)},e.effects.effect.size=function(t,n){var r,i,s,o=e(this),u=["position","top","bottom","left","right","width","height","overflow","opacity"],a=["position","top","bottom","left","right","overflow","opacity"],f=["width","height","overflow"],l=["fontSize"],c=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=e.effects.setMode(o,t.mode||"effect"),d=t.restore||p!=="effect",v=t.scale||"both",m=t.origin||["middle","center"],g=o.css("position"),y=d?u:a,b={height:0,width:0,outerHeight:0,outerWidth:0};p==="show"&&o.show(),r={height:o.height(),width:o.width(),outerHeight:o.outerHeight(),outerWidth:o.outerWidth()},t.mode==="toggle"&&p==="show"?(o.from=t.to||b,o.to=t.from||r):(o.from=t.from||(p==="show"?b:r),o.to=t.to||(p==="hide"?b:r)),s={from:{y:o.from.height/r.height,x:o.from.width/r.width},to:{y:o.to.height/r.height,x:o.to.width/r.width}};if(v==="box"||v==="both")s.from.y!==s.to.y&&(y=y.concat(c),o.from=e.effects.setTransition(o,c,s.from.y,o.from),o.to=e.effects.setTransition(o,c,s.to.y,o.to)),s.from.x!==s.to.x&&(y=y.concat(h),o.from=e.effects.setTransition(o,h,s.from.x,o.from),o.to=e.effects.setTransition(o,h,s.to.x,o.to));(v==="content"||v==="both")&&s.from.y!==s.to.y&&(y=y.concat(l).concat(f),o.from=e.effects.setTransition(o,l,s.from.y,o.from),o.to=e.effects.setTransition(o,l,s.to.y,o.to)),e.effects.save(o,y),o.show(),e.effects.createWrapper(o),o.css("overflow","hidden").css(o.from),m&&(i=e.effects.getBaseline(m,r),o.from.top=(r.outerHeight-o.outerHeight())*i.y,o.from.left=(r.outerWidth-o.outerWidth())*i.x,o.to.top=(r.outerHeight-o.to.outerHeight)*i.y,o.to.left=(r.outerWidth-o.to.outerWidth)*i.x),o.css(o.from);if(v==="content"||v==="both")c=c.concat(["marginTop","marginBottom"]).concat(l),h=h.concat(["marginLeft","marginRight"]),f=u.concat(c).concat(h),o.find("*[width]").each(function(){var n=e(this),r={height:n.height(),width:n.width(),outerHeight:n.outerHeight(),outerWidth:n.outerWidth()};d&&e.effects.save(n,f),n.from={height:r.height*s.from.y,width:r.width*s.from.x,outerHeight:r.outerHeight*s.from.y,outerWidth:r.outerWidth*s.from.x},n.to={height:r.height*s.to.y,width:r.width*s.to.x,outerHeight:r.height*s.to.y,outerWidth:r.width*s.to.x},s.from.y!==s.to.y&&(n.from=e.effects.setTransition(n,c,s.from.y,n.from),n.to=e.effects.setTransition(n,c,s.to.y,n.to)),s.from.x!==s.to.x&&(n.from=e.effects.setTransition(n,h,s.from.x,n.from),n.to=e.effects.setTransition(n,h,s.to.x,n.to)),n.css(n.from),n.animate(n.to,t.duration,t.easing,function(){d&&e.effects.restore(n,f)})});o.animate(o.to,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o.to.opacity===0&&o.css("opacity",o.from.opacity),p==="hide"&&o.hide(),e.effects.restore(o,y),d||(g==="static"?o.css({position:"relative",top:o.to.top,left:o.to.left}):e.each(["top","left"],function(e,t){o.css(t,function(t,n){var r=parseInt(n,10),i=e?o.to.left:o.to.top;return n==="auto"?i+"px":r+i+"px"})})),e.effects.removeWrapper(o),n()}})}}(jQuery),function(e,t){e.effects.effect.shake=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"effect"),o=t.direction||"left",u=t.distance||20,a=t.times||3,f=a*2+1,l=Math.round(t.duration/f),c=o==="up"||o==="down"?"top":"left",h=o==="up"||o==="left",p={},d={},v={},m,g=r.queue(),y=g.length;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),p[c]=(h?"-=":"+=")+u,d[c]=(h?"+=":"-=")+u*2,v[c]=(h?"-=":"+=")+u*2,r.animate(p,l,t.easing);for(m=1;m1&&g.splice.apply(g,[1,0].concat(g.splice(y,f+1))),r.dequeue()}}(jQuery),function(e,t){e.effects.effect.slide=function(t,n){var r=e(this),i=["position","top","bottom","left","right","width","height"],s=e.effects.setMode(r,t.mode||"show"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left",l,c={};e.effects.save(r,i),r.show(),l=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(r).css({overflow:"hidden"}),o&&r.css(a,f?isNaN(l)?"-"+l:-l:l),c[a]=(o?f?"+=":"-=":f?"-=":"+=")+l,r.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}}(jQuery),function(e,t){e.effects.effect.transfer=function(t,n){var r=e(this),i=e(t.to),s=i.css("position")==="fixed",o=e("body"),u=s?o.scrollTop():0,a=s?o.scrollLeft():0,f=i.offset(),l={top:f.top-u,left:f.left-a,height:i.innerHeight(),width:i.innerWidth()},c=r.offset(),h=e('
    ').appendTo(document.body).addClass(t.className).css({top:c.top-u,left:c.left-a,height:r.innerHeight(),width:r.innerWidth(),position:s?"fixed":"absolute"}).animate(l,t.duration,t.easing,function(){h.remove(),n()})}}(jQuery),function(e,t){var n=!1;e.widget("ui.menu",{version:"1.9.2",defaultElement:"
      ",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}).bind("click"+this.eventNamespace,e.proxy(function(e){this.options.disabled&&e.preventDefault()},this)),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item > a":function(e){e.preventDefault()},"click .ui-state-disabled > a":function(e){e.preventDefault()},"click .ui-menu-item:has(a)":function(t){var r=e(t.target).closest(".ui-menu-item");!n&&r.not(".ui-state-disabled").length&&(n=!0,this.select(t),r.has(".ui-menu").length?this.expand(t):this.element.is(":focus")||(this.element.trigger("focus",[!0]),this.active&&this.active.parents(".ui-menu").length===1&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){var n=e(t.currentTarget);n.siblings().children(".ui-state-active").removeClass("ui-state-active"),this.focus(t,n)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var n=this.active||this.element.children(".ui-menu-item").eq(0);t||this.focus(e,n)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){e(t.target).closest(".ui-menu").length||this.collapseAll(t),n=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").andSelf().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var n,r,i,s,o,u=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:u=!1,r=this.previousFilter||"",i=String.fromCharCode(t.keyCode),s=!1,clearTimeout(this.filterTimer),i===r?s=!0:i=r+i,o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())}),n=s&&n.index(this.active.next())!==-1?this.active.nextAll(".ui-menu-item"):n,n.length||(i=String.fromCharCode(t.keyCode),o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())})),n.length?(this.focus(t,n),n.length>1?(this.previousFilter=i,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}u&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(e):this.select(e))},refresh:function(){var t,n=this.options.icons.submenu,r=this.element.find(this.options.menus);r.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),r=t.prev("a"),i=e("").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);r.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",r.attr("id"))}),t=r.add(this.element),t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),t.children(":not(.ui-menu-item)").each(function(){var t=e(this);/[^\-—–\s]/.test(t.text())||t.addClass("ui-widget-content ui-menu-divider")}),t.children(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},focus:function(e,t){var n,r;this.blur(e,e&&e.type==="focus"),this._scrollIntoView(t),this.active=t.first(),r=this.active.children("a").addClass("ui-state-focus"),this.options.role&&this.element.attr("aria-activedescendant",r.attr("id")),this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"),e&&e.type==="keydown"?this._close():this.timer=this._delay(function(){this._close()},this.delay),n=t.children(".ui-menu"),n.length&&/^mouse/.test(e.type)&&this._startOpening(n),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var n,r,i,s,o,u;this._hasScroll()&&(n=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,r=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,i=t.offset().top-this.activeMenu.offset().top-n-r,s=this.activeMenu.scrollTop(),o=this.activeMenu.height(),u=t.height(),i<0?this.activeMenu.scrollTop(s+i):i+u>o&&this.activeMenu.scrollTop(s+i-o+u))},blur:function(e,t){t||clearTimeout(this.timer);if(!this.active)return;this.active.children("a").removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active})},_startOpening:function(e){clearTimeout(this.timer);if(e.attr("aria-hidden")!=="true")return;this.timer=this._delay(function(){this._close(),this._open(e)},this.delay)},_open:function(t){var n=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(n)},collapseAll:function(t,n){clearTimeout(this.timer),this.timer=this._delay(function(){var r=n?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));r.length||(r=this.element),this._close(r),this.blur(t),this.activeMenu=r},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find("a.ui-state-active").removeClass("ui-state-active")},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").children(".ui-menu-item").first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,n){var r;this.active&&(e==="first"||e==="last"?r=this.active[e==="first"?"prevAll":"nextAll"](".ui-menu-item").eq(-1):r=this.active[e+"All"](".ui-menu-item").eq(0));if(!r||!r.length||!this.active)r=this.activeMenu.children(".ui-menu-item")[t]();this.focus(n,r)},nextPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isLastItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r-i<0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item")[this.active?"last":"first"]())},previousPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isFirstItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r+i>0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item").first())},_hasScroll:function(){return this.element.outerHeight()
    "),o=s.children()[0];return e("body").append(s),r=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,r===i&&(i=s[0].clientWidth),s.remove(),n=r-i},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width0?"right":"center",vertical:u<0?"top":o>0?"bottom":"middle"};lr(i(o),i(u))?h.important="horizontal":h.important="vertical",t.using.call(this,e,h)}),a.offset(e.extend(C,{using:u}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,i=n.isWindow?n.scrollLeft:n.offset.left,s=n.width,o=e.left-t.collisionPosition.marginLeft,u=i-o,a=o+t.collisionWidth-s-i,f;t.collisionWidth>s?u>0&&a<=0?(f=e.left+u+t.collisionWidth-s-i,e.left+=u-f):a>0&&u<=0?e.left=i:u>a?e.left=i+s-t.collisionWidth:e.left=i:u>0?e.left+=u:a>0?e.left-=a:e.left=r(e.left-o,e.left)},top:function(e,t){var n=t.within,i=n.isWindow?n.scrollTop:n.offset.top,s=t.within.height,o=e.top-t.collisionPosition.marginTop,u=i-o,a=o+t.collisionHeight-s-i,f;t.collisionHeight>s?u>0&&a<=0?(f=e.top+u+t.collisionHeight-s-i,e.top+=u-f):a>0&&u<=0?e.top=i:u>a?e.top=i+s-t.collisionHeight:e.top=i:u>0?e.top+=u:a>0?e.top-=a:e.top=r(e.top-o,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,s=n.width,o=n.isWindow?n.scrollLeft:n.offset.left,u=e.left-t.collisionPosition.marginLeft,a=u-o,f=u+t.collisionWidth-s-o,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-s-r;if(p<0||p0){d=e.left-t.collisionPosition.marginLeft+l+c+h-o;if(d>0||i(d)a&&(v<0||v0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-o,e.top+c+h+p>f&&(d>0||i(d)10&&i<11,t.innerHTML="",n.removeChild(t)}(),e.uiBackCompat!==!1&&function(e){var n=e.fn.position;e.fn.position=function(r){if(!r||!r.offset)return n.call(this,r);var i=r.offset.split(" "),s=r.at.split(" ");return i.length===1&&(i[1]=i[0]),/^\d/.test(i[0])&&(i[0]="+"+i[0]),/^\d/.test(i[1])&&(i[1]="+"+i[1]),s.length===1&&(/left|center|right/.test(s[0])?s[1]="center":(s[1]=s[0],s[0]="center")),n.call(this,e.extend(r,{at:s[0]+i[0]+" "+s[1]+i[1],offset:t}))}}(jQuery)}(jQuery),function(e,t){e.widget("ui.progressbar",{version:"1.9.2",options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=e("
    ").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(e){return e===t?this._value():(this._setOption("value",e),this)},_setOption:function(e,t){e==="value"&&(this.options.value=t,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),this._super(e,t)},_value:function(){var e=this.options.value;return typeof e!="number"&&(e=0),Math.min(this.options.max,Math.max(this.min,e))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var e=this.value(),t=this._percentage();this.oldValue!==e&&(this.oldValue=e,this._trigger("change")),this.valueDiv.toggle(e>this.min).toggleClass("ui-corner-right",e===this.options.max).width(t.toFixed(0)+"%"),this.element.attr("aria-valuenow",e)}})}(jQuery),function(e,t){var n=5;e.widget("ui.slider",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var t,r,i=this.options,s=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),o="",u=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(i.disabled?" ui-slider-disabled ui-disabled":"")),this.range=e([]),i.range&&(i.range===!0&&(i.values||(i.values=[this._valueMin(),this._valueMin()]),i.values.length&&i.values.length!==2&&(i.values=[i.values[0],i.values[0]])),this.range=e("
    ").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(i.range==="min"||i.range==="max"?" ui-slider-range-"+i.range:""))),r=i.values&&i.values.length||1;for(t=s.length;tn&&(i=n,s=e(this),o=t)}),c.range===!0&&this.values(1)===c.min&&(o+=1,s=e(this.handles[o])),u=this._start(t,o),u===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,s.addClass("ui-state-active").focus(),a=s.offset(),f=!e(t.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=f?{left:0,top:0}:{left:t.pageX-a.left-s.width()/2,top:t.pageY-a.top-s.height()/2-(parseInt(s.css("borderTopWidth"),10)||0)-(parseInt(s.css("borderBottomWidth"),10)||0)+(parseInt(s.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,r),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},n=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,n),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,n,r,i,s;return this.orientation==="horizontal"?(t=this.elementSize.width,n=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,n=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),r=n/t,r>1&&(r=1),r<0&&(r=0),this.orientation==="vertical"&&(r=1-r),i=this._valueMax()-this._valueMin(),s=this._valueMin()+r*i,this._trimAlignValue(s)},_start:function(e,t){var n={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("start",e,n)},_slide:function(e,t,n){var r,i,s;this.options.values&&this.options.values.length?(r=this.values(t?0:1),this.options.values.length===2&&this.options.range===!0&&(t===0&&n>r||t===1&&n1){this.options.values[t]=this._trimAlignValue(n),this._refreshValue(),this._change(null,t);return}if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();r=this.options.values,i=arguments[0];for(s=0;s=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,n=(e-this._valueMin())%t,r=e-n;return Math.abs(n)*2>=t&&(r+=n>0?t:-t),parseFloat(r.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,n,r,i,s,o=this.options.range,u=this.options,a=this,f=this._animateOff?!1:u.animate,l={};this.options.values&&this.options.values.length?this.handles.each(function(r){n=(a.values(r)-a._valueMin())/(a._valueMax()-a._valueMin())*100,l[a.orientation==="horizontal"?"left":"bottom"]=n+"%",e(this).stop(1,1)[f?"animate":"css"](l,u.animate),a.options.range===!0&&(a.orientation==="horizontal"?(r===0&&a.range.stop(1,1)[f?"animate":"css"]({left:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({width:n-t+"%"},{queue:!1,duration:u.animate})):(r===0&&a.range.stop(1,1)[f?"animate":"css"]({bottom:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({height:n-t+"%"},{queue:!1,duration:u.animate}))),t=n}):(r=this.value(),i=this._valueMin(),s=this._valueMax(),n=s!==i?(r-i)/(s-i)*100:0,l[this.orientation==="horizontal"?"left":"bottom"]=n+"%",this.handle.stop(1,1)[f?"animate":"css"](l,u.animate),o==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[f?"animate":"css"]({width:n+"%"},u.animate),o==="max"&&this.orientation==="horizontal"&&this.range[f?"animate":"css"]({width:100-n+"%"},{queue:!1,duration:u.animate}),o==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[f?"animate":"css"]({height:n+"%"},u.animate),o==="max"&&this.orientation==="vertical"&&this.range[f?"animate":"css"]({height:100-n+"%"},{queue:!1,duration:u.animate}))}})}(jQuery),function(e){function t(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.widget("ui.spinner",{version:"1.9.2",defaultElement:"",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var t={},n=this.element;return e.each(["min","max","step"],function(e,r){var i=n.attr(r);i!==undefined&&i.length&&(t[r]=i)}),t},_events:{keydown:function(e){this._start(e)&&this._keydown(e)&&e.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(e){if(this.cancelBlur){delete this.cancelBlur;return}this._refresh(),this.previous!==this.element.val()&&this._trigger("change",e)},mousewheel:function(e,t){if(!t)return;if(!this.spinning&&!this._start(e))return!1;this._spin((t>0?1:-1)*this.options.step,e),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(e)},100),e.preventDefault()},"mousedown .ui-spinner-button":function(t){function r(){var e=this.element[0]===this.document[0].activeElement;e||(this.element.focus(),this.previous=n,this._delay(function(){this.previous=n}))}var n;n=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),t.preventDefault(),r.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,r.call(this)});if(this._start(t)===!1)return;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){if(!e(t.currentTarget).hasClass("ui-state-active"))return;if(this._start(t)===!1)return!1;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var e=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=e.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(e.height()*.5)&&e.height()>0&&e.height(e.height()),this.options.disabled&&this.disable()},_keydown:function(t){var n=this.options,r=e.ui.keyCode;switch(t.keyCode){case r.UP:return this._repeat(null,1,t),!0;case r.DOWN:return this._repeat(null,-1,t),!0;case r.PAGE_UP:return this._repeat(null,n.page,t),!0;case r.PAGE_DOWN:return this._repeat(null,-n.page,t),!0}return!1},_uiSpinnerHtml:function(){return""},_buttonHtml:function(){return""+""+""+""+""},_start:function(e){return!this.spinning&&this._trigger("start",e)===!1?!1:(this.counter||(this.counter=1),this.spinning=!0,!0)},_repeat:function(e,t,n){e=e||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,t,n)},e),this._spin(t*this.options.step,n)},_spin:function(e,t){var n=this.value()||0;this.counter||(this.counter=1),n=this._adjustValue(n+e*this._increment(this.counter));if(!this.spinning||this._trigger("spin",t,{value:n})!==!1)this._value(n),this.counter++},_increment:function(t){var n=this.options.incremental;return n?e.isFunction(n)?n(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var e=this._precisionOf(this.options.step);return this.options.min!==null&&(e=Math.max(e,this._precisionOf(this.options.min))),e},_precisionOf:function(e){var t=e.toString(),n=t.indexOf(".");return n===-1?0:t.length-n-1},_adjustValue:function(e){var t,n,r=this.options;return t=r.min!==null?r.min:0,n=e-t,n=Math.round(n/r.step)*r.step,e=t+n,e=parseFloat(e.toFixed(this._precision())),r.max!==null&&e>r.max?r.max:r.min!==null&&e1&&e.href.replace(r,"")===location.href.replace(r,"").replace(/\s/g,"%20")}var n=0,r=/#.*$/;e.widget("ui.tabs",{version:"1.9.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var t=this,n=this.options,r=n.active,i=location.hash.substring(1);this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",n.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs();if(r===null){i&&this.tabs.each(function(t,n){if(e(n).attr("aria-controls")===i)return r=t,!1}),r===null&&(r=this.tabs.index(this.tabs.filter(".ui-tabs-active")));if(r===null||r===-1)r=this.tabs.length?0:!1}r!==!1&&(r=this.tabs.index(this.tabs.eq(r)),r===-1&&(r=n.collapsible?!1:0)),n.active=r,!n.collapsible&&n.active===!1&&this.anchors.length&&(n.active=0),e.isArray(n.disabled)&&(n.disabled=e.unique(n.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.options.active!==!1&&this.anchors.length?this.active=this._findActive(this.options.active):this.active=e(),this._refresh(),this.active.length&&this.load(n.active)},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var n=e(this.document[0].activeElement).closest("li"),r=this.tabs.index(n),i=!0;if(this._handlePageNav(t))return;switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:r++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:i=!1,r--;break;case e.ui.keyCode.END:r=this.anchors.length-1;break;case e.ui.keyCode.HOME:r=0;break;case e.ui.keyCode.SPACE:t.preventDefault(),clearTimeout(this.activating),this._activate(r);return;case e.ui.keyCode.ENTER:t.preventDefault(),clearTimeout(this.activating),this._activate(r===this.options.active?!1:r);return;default:return}t.preventDefault(),clearTimeout(this.activating),r=this._focusNextTab(r,i),t.ctrlKey||(n.attr("aria-selected","false"),this.tabs.eq(r).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",r)},this.delay))},_panelKeydown:function(t){if(this._handlePageNav(t))return;t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP)return this._activate(this._focusNextTab(this.options.active-1,!1)),!0;if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN)return this._activate(this._focusNextTab(this.options.active+1,!0)),!0},_findNextTab:function(t,n){function i(){return t>r&&(t=0),t<0&&(t=r),t}var r=this.tabs.length-1;while(e.inArray(i(),this.options.disabled)!==-1)t=n?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,t){if(e==="active"){this._activate(t);return}if(e==="disabled"){this._setupDisabled(t);return}this._super(e,t),e==="collapsible"&&(this.element.toggleClass("ui-tabs-collapsible",t),!t&&this.options.active===!1&&this._activate(0)),e==="event"&&this._setupEvents(t),e==="heightStyle"&&this._setupHeightStyle(t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+i()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,n=this.tablist.children(":has(a[href])");t.disabled=e.map(n.filter(".ui-state-disabled"),function(e){return n.index(e)}),this._processTabs(),t.active===!1||!this.anchors.length?(t.active=!1,this.active=e()):this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(n,r){var i,o,u,a=e(r).uniqueId().attr("id"),f=e(r).closest("li"),l=f.attr("aria-controls");s(r)?(i=r.hash,o=t.element.find(t._sanitizeSelector(i))):(u=t._tabId(f),i="#"+u,o=t.element.find(i),o.length||(o=t._createPanel(u),o.insertAfter(t.panels[n-1]||t.tablist)),o.attr("aria-live","polite")),o.length&&(t.panels=t.panels.add(o)),l&&f.data("ui-tabs-aria-controls",l),f.attr({"aria-controls":i.substring(1),"aria-labelledby":a}),o.attr("aria-labelledby",a)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("
    ").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var n=0,r;r=this.tabs[n];n++)t===!0||e.inArray(n,t)!==-1?e(r).addClass("ui-state-disabled").attr("aria-disabled","true"):e(r).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var n={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,n),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var n,r,i=this.element.parent();t==="fill"?(e.support.minHeight||(r=i.css("overflow"),i.css("overflow","hidden")),n=i.height(),this.element.siblings(":visible").each(function(){var t=e(this),r=t.css("position");if(r==="absolute"||r==="fixed")return;n-=t.outerHeight(!0)}),r&&i.css("overflow",r),this.element.children().not(this.panels).each(function(){n-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,n-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):t==="auto"&&(n=0,this.panels.each(function(){n=Math.max(n,e(this).height("").height())}).height(n))},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i.closest("li"),o=s[0]===r[0],u=o&&n.collapsible,a=u?e():this._getPanelForTab(s),f=r.length?this._getPanelForTab(r):e(),l={oldTab:r,oldPanel:f,newTab:u?e():s,newPanel:a};t.preventDefault();if(s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||o&&!n.collapsible||this._trigger("beforeActivate",t,l)===!1)return;n.active=u?!1:this.tabs.index(s),this.active=o?e():s,this.xhr&&this.xhr.abort(),!f.length&&!a.length&&e.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,l)},_toggle:function(t,n){function o(){r.running=!1,r._trigger("activate",t,n)}function u(){n.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),i.length&&r.options.show?r._show(i,r.options.show,o):(i.show(),o())}var r=this,i=n.newPanel,s=n.oldPanel;this.running=!0,s.length&&this.options.hide?this._hide(s,this.options.hide,function(){n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),s.hide(),u()),s.attr({"aria-expanded":"false","aria-hidden":"true"}),n.oldTab.attr("aria-selected","false"),i.length&&s.length?n.oldTab.attr("tabIndex",-1):i.length&&this.tabs.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),i.attr({"aria-expanded":"true","aria-hidden":"false"}),n.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var n,r=this._findActive(t);if(r[0]===this.active[0])return;r.length||(r=this.active),n=r.find(".ui-tabs-anchor")[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return typeof e=="string"&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeData("href.tabs").removeData("load.tabs").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),n=t.data("ui-tabs-aria-controls");n?t.attr("aria-controls",n):t.removeAttr("aria-controls")}),this.panels.show(),this.options.heightStyle!=="content"&&this.panels.css("height","")},enable:function(n){var r=this.options.disabled;if(r===!1)return;n===t?r=!1:(n=this._getIndex(n),e.isArray(r)?r=e.map(r,function(e){return e!==n?e:null}):r=e.map(this.tabs,function(e,t){return t!==n?t:null})),this._setupDisabled(r)},disable:function(n){var r=this.options.disabled;if(r===!0)return;if(n===t)r=!0;else{n=this._getIndex(n);if(e.inArray(n,r)!==-1)return;e.isArray(r)?r=e.merge([n],r).sort():r=[n]}this._setupDisabled(r)},load:function(t,n){t=this._getIndex(t);var r=this,i=this.tabs.eq(t),o=i.find(".ui-tabs-anchor"),u=this._getPanelForTab(i),a={tab:i,panel:u};if(s(o[0]))return;this.xhr=e.ajax(this._ajaxSettings(o,n,a)),this.xhr&&this.xhr.statusText!=="canceled"&&(i.addClass("ui-tabs-loading"),u.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){u.html(e),r._trigger("load",n,a)},1)}).complete(function(e,t){setTimeout(function(){t==="abort"&&r.panels.stop(!1,!0),i.removeClass("ui-tabs-loading"),u.removeAttr("aria-busy"),e===r.xhr&&delete r.xhr},1)}))},_ajaxSettings:function(t,n,r){var i=this;return{url:t.attr("href"),beforeSend:function(t,s){return i._trigger("beforeLoad",n,e.extend({jqXHR:t,ajaxSettings:s},r))}}},_getPanelForTab:function(t){var n=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+n))}}),e.uiBackCompat!==!1&&(e.ui.tabs.prototype._ui=function(e,t){return{tab:e,panel:t,index:this.anchors.index(e)}},e.widget("ui.tabs",e.ui.tabs,{url:function(e,t){this.anchors.eq(e).attr("href",t)}}),e.widget("ui.tabs",e.ui.tabs,{options:{ajaxOptions:null,cache:!1},_create:function(){this._super();var t=this;this._on({tabsbeforeload:function(n,r){if(e.data(r.tab[0],"cache.tabs")){n.preventDefault();return}r.jqXHR.success(function(){t.options.cache&&e.data(r.tab[0],"cache.tabs",!0)})}})},_ajaxSettings:function(t,n,r){var i=this.options.ajaxOptions;return e.extend({},i,{error:function(e,t){try{i.error(e,t,r.tab.closest("li").index(),r.tab[0])}catch(n){}}},this._superApply(arguments))},_setOption:function(e,t){e==="cache"&&t===!1&&this.anchors.removeData("cache.tabs"),this._super(e,t)},_destroy:function(){this.anchors.removeData("cache.tabs"),this._super()},url:function(e){this.anchors.eq(e).removeData("cache.tabs"),this._superApply(arguments)}}),e.widget("ui.tabs",e.ui.tabs,{abort:function(){this.xhr&&this.xhr.abort()}}),e.widget("ui.tabs",e.ui.tabs,{options:{spinner:"Loading…"},_create:function(){this._super(),this._on({tabsbeforeload:function(e,t){if(e.target!==this.element[0]||!this.options.spinner)return;var n=t.tab.find("span"),r=n.html();n.html(this.options.spinner),t.jqXHR.complete(function(){n.html(r)})}})}}),e.widget("ui.tabs",e.ui.tabs,{options:{enable:null,disable:null},enable:function(t){var n=this.options,r;if(t&&n.disabled===!0||e.isArray(n.disabled)&&e.inArray(t,n.disabled)!==-1)r=!0;this._superApply(arguments),r&&this._trigger("enable",null,this._ui(this.anchors[t],this.panels[t]))},disable:function(t){var n=this.options,r;if(t&&n.disabled===!1||e.isArray(n.disabled)&&e.inArray(t,n.disabled)===-1)r=!0;this._superApply(arguments),r&&this._trigger("disable",null,this._ui(this.anchors[t],this.panels[t]))}}),e.widget("ui.tabs",e.ui.tabs,{options:{add:null,remove:null,tabTemplate:"
  • #{label}
  • "},add:function(n,r,i){i===t&&(i=this.anchors.length);var s,o,u=this.options,a=e(u.tabTemplate.replace(/#\{href\}/g,n).replace(/#\{label\}/g,r)),f=n.indexOf("#")?this._tabId(a):n.replace("#","");return a.addClass("ui-state-default ui-corner-top").data("ui-tabs-destroy",!0),a.attr("aria-controls",f),s=i>=this.tabs.length,o=this.element.find("#"+f),o.length||(o=this._createPanel(f),s?i>0?o.insertAfter(this.panels.eq(-1)):o.appendTo(this.element):o.insertBefore(this.panels[i])),o.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").hide(),s?a.appendTo(this.tablist):a.insertBefore(this.tabs[i]),u.disabled=e.map(u.disabled,function(e){return e>=i?++e:e}),this.refresh(),this.tabs.length===1&&u.active===!1&&this.option("active",0),this._trigger("add",null,this._ui(this.anchors[i],this.panels[i])),this},remove:function(t){t=this._getIndex(t);var n=this.options,r=this.tabs.eq(t).remove(),i=this._getPanelForTab(r).remove();return r.hasClass("ui-tabs-active")&&this.anchors.length>2&&this._activate(t+(t+1=t?--e:e}),this.refresh(),this._trigger("remove",null,this._ui(r.find("a")[0],i[0])),this}}),e.widget("ui.tabs",e.ui.tabs,{length:function(){return this.anchors.length}}),e.widget("ui.tabs",e.ui.tabs,{options:{idPrefix:"ui-tabs-"},_tabId:function(t){var n=t.is("li")?t.find("a[href]"):t;return n=n[0],e(n).closest("li").attr("aria-controls")||n.title&&n.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF\-]/g,"")||this.options.idPrefix+i()}}),e.widget("ui.tabs",e.ui.tabs,{options:{panelTemplate:"
    "},_createPanel:function(t){return e(this.options.panelTemplate).attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)}}),e.widget("ui.tabs",e.ui.tabs,{_create:function(){var e=this.options;e.active===null&&e.selected!==t&&(e.active=e.selected===-1?!1:e.selected),this._super(),e.selected=e.active,e.selected===!1&&(e.selected=-1)},_setOption:function(e,t){if(e!=="selected")return this._super(e,t);var n=this.options;this._super("active",t===-1?!1:t),n.selected=n.active,n.selected===!1&&(n.selected=-1)},_eventHandler:function(){this._superApply(arguments),this.options.selected=this.options.active,this.options.selected===!1&&(this.options.selected=-1)}}),e.widget("ui.tabs",e.ui.tabs,{options:{show:null,select:null},_create:function(){this._super(),this.options.active!==!1&&this._trigger("show",null,this._ui(this.active.find(".ui-tabs-anchor")[0],this._getPanelForTab(this.active)[0]))},_trigger:function(e,t,n){var r,i,s=this._superApply(arguments);return s?(e==="beforeActivate"?(r=n.newTab.length?n.newTab:n.oldTab,i=n.newPanel.length?n.newPanel:n.oldPanel,s=this._super("select",t,{tab:r.find(".ui-tabs-anchor")[0],panel:i[0],index:r.closest("li").index()})):e==="activate"&&n.newTab.length&&(s=this._super("show",t,{tab:n.newTab.find(".ui-tabs-anchor")[0],panel:n.newPanel[0],index:n.newTab.closest("li").index()})),s):!1}}),e.widget("ui.tabs",e.ui.tabs,{select:function(e){e=this._getIndex(e);if(e===-1){if(!this.options.collapsible||this.options.selected===-1)return;e=this.options.selected}this.anchors.eq(e).trigger(this.options.event+this.eventNamespace)}}),function(){var t=0;e.widget("ui.tabs",e.ui.tabs,{options:{cookie:null},_create:function(){var e=this.options,t;e.active==null&&e.cookie&&(t=parseInt(this._cookie(),10),t===-1&&(t=!1),e.active=t),this._super()},_cookie:function(n){var r=[this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++t)];return arguments.length&&(r.push(n===!1?-1:n),r.push(this.options.cookie)),e.cookie.apply(null,r)},_refresh:function(){this._super(),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_eventHandler:function(){this._superApply(arguments),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_destroy:function(){this._super(),this.options.cookie&&this._cookie(null,this.options.cookie)}})}(),e.widget("ui.tabs",e.ui.tabs,{_trigger:function(t,n,r){var i=e.extend({},r);return t==="load"&&(i.panel=i.panel[0],i.tab=i.tab.find(".ui-tabs-anchor")[0]),this._super(t,n,i)}}),e.widget("ui.tabs",e.ui.tabs,{options:{fx:null},_getFx:function(){var t,n,r=this.options.fx;return r&&(e.isArray(r)?(t=r[0],n=r[1]):t=n=r),r?{show:n,hide:t}:null},_toggle:function(e,t){function o(){n.running=!1,n._trigger("activate",e,t)}function u(){t.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&s.show?r.animate(s.show,s.show.duration,function(){o()}):(r.show(),o())}var n=this,r=t.newPanel,i=t.oldPanel,s=this._getFx();if(!s)return this._super(e,t);n.running=!0,i.length&&s.hide?i.animate(s.hide,s.hide.duration,function(){t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i.hide(),u())}}))}(jQuery),function(e){function n(t,n){var r=(t.attr("aria-describedby")||"").split(/\s+/);r.push(n),t.data("ui-tooltip-id",n).attr("aria-describedby",e.trim(r.join(" ")))}function r(t){var n=t.data("ui-tooltip-id"),r=(t.attr("aria-describedby")||"").split(/\s+/),i=e.inArray(n,r);i!==-1&&r.splice(i,1),t.removeData("ui-tooltip-id"),r=e.trim(r.join(" ")),r?t.attr("aria-describedby",r):t.removeAttr("aria-describedby")}var t=0;e.widget("ui.tooltip",{version:"1.9.2",options:{content:function(){return e(this).attr("title")},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(t,n){var r=this;if(t==="disabled"){this[n?"_disable":"_enable"](),this.options[t]=n;return}this._super(t,n),t==="content"&&e.each(this.tooltips,function(e,t){r._updateContent(t)})},_disable:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0)}),this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var n=this,r=e(t?t.target:this.element).closest(this.options.items);if(!r.length||r.data("ui-tooltip-id"))return;r.attr("title")&&r.data("ui-tooltip-title",r.attr("title")),r.data("ui-tooltip-open",!0),t&&t.type==="mouseover"&&r.parents().each(function(){var t=e(this),r;t.data("ui-tooltip-open")&&(r=e.Event("blur"),r.target=r.currentTarget=this,n.close(r,!0)),t.attr("title")&&(t.uniqueId(),n.parents[this.id]={element:this,title:t.attr("title")},t.attr("title",""))}),this._updateContent(r,t)},_updateContent:function(e,t){var n,r=this.options.content,i=this,s=t?t.type:null;if(typeof r=="string")return this._open(t,e,r);n=r.call(e[0],function(n){if(!e.data("ui-tooltip-open"))return;i._delay(function(){t&&(t.type=s),this._open(t,e,n)})}),n&&this._open(t,e,n)},_open:function(t,r,i){function f(e){a.of=e;if(s.is(":hidden"))return;s.position(a)}var s,o,u,a=e.extend({},this.options.position);if(!i)return;s=this._find(r);if(s.length){s.find(".ui-tooltip-content").html(i);return}r.is("[title]")&&(t&&t.type==="mouseover"?r.attr("title",""):r.removeAttr("title")),s=this._tooltip(r),n(r,s.attr("id")),s.find(".ui-tooltip-content").html(i),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:f}),f(t)):s.position(e.extend({of:r},this.options.position)),s.hide(),this._show(s,this.options.show),this.options.show&&this.options.show.delay&&(u=setInterval(function(){s.is(":visible")&&(f(a.of),clearInterval(u))},e.fx.interval)),this._trigger("open",t,{tooltip:s}),o={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var n=e.Event(t);n.currentTarget=r[0],this.close(n,!0)}},remove:function(){this._removeTooltip(s)}};if(!t||t.type==="mouseover")o.mouseleave="close";if(!t||t.type==="focusin")o.focusout="close";this._on(!0,r,o)},close:function(t){var n=this,i=e(t?t.currentTarget:this.element),s=this._find(i);if(this.closing)return;i.data("ui-tooltip-title")&&i.attr("title",i.data("ui-tooltip-title")),r(i),s.stop(!0),this._hide(s,this.options.hide,function(){n._removeTooltip(e(this))}),i.removeData("ui-tooltip-open"),this._off(i,"mouseleave focusout keyup"),i[0]!==this.element[0]&&this._off(i,"remove"),this._off(this.document,"mousemove"),t&&t.type==="mouseleave"&&e.each(this.parents,function(t,r){e(r.element).attr("title",r.title),delete n.parents[t]}),this.closing=!0,this._trigger("close",t,{tooltip:s}),this.closing=!1},_tooltip:function(n){var r="ui-tooltip-"+t++,i=e("
    ").attr({id:r,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return e("
    ").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),e.fn.bgiframe&&i.bgiframe(),this.tooltips[r]=n,i},_find:function(t){var n=t.data("ui-tooltip-id");return n?e("#"+n):e()},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0),e("#"+n).remove(),r.data("ui-tooltip-title")&&(r.attr("title",r.data("ui-tooltip-title")),r.removeData("ui-tooltip-title"))})}})}(jQuery); \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery.ui.touch-punch-0.2.2.min.js b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery.ui.touch-punch-0.2.2.min.js new file mode 100644 index 000000000..33d6f97e5 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/external/jquery.ui.touch-punch-0.2.2.min.js @@ -0,0 +1,11 @@ +/* + * jQuery UI Touch Punch 0.2.2 + * + * Copyright 2011, Dave Furfero + * Dual licensed under the MIT or GPL Version 2 licenses. + * + * Depends: + * jquery.ui.widget.js + * jquery.ui.mouse.js + */ +(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery); \ No newline at end of file diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-GPLv2-LICENSE.txt b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-GPLv2-LICENSE.txt new file mode 100644 index 000000000..11dddd00e --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-GPLv2-LICENSE.txt @@ -0,0 +1,278 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-MIT-LICENSE.txt b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-MIT-LICENSE.txt new file mode 100644 index 000000000..2bbacc516 --- /dev/null +++ b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/jsPlumb-MIT-LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2010 - 2014 jsPlumb, http://jsplumbtoolkit.com/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/logo-bw.png b/src/Concerto/PanelBundle/Resources/public/angularjs/bower_components/jsPlumb/logo-bw.png new file mode 100644 index 0000000000000000000000000000000000000000..bd71b59fab4bb935442d17469e821997fee6de9d GIT binary patch literal 2486 zcmV;n2}$;eP)J&;C26Tpw6deVs2#PZPLPgPm+8KW^7PXE#SOjrkpaq8v10=g|w+W#cksqa@ zf)ock4o%x6yYC+V*j*ZFlKqjiG{b&pcJ|IY_niB^d-mLS?zvY~l`4*Wn0K2%6{Vr- zs2PH)qh<)Ij+!B;I%Ot>sIH2P`5SP=J4!Q|rNCu~ z%m!wrqdeDLE2?*79S5Qajm6mC&_LjMyHV{oBDZ&k;pXvlMdUrb;j8E!wW6u1uD!ke z=yLT$s;=E_TnEGngG6eXG^;K2eFj!fz8{ z=qHlNAQ6Twi7-4tVzEWQ)2M#RbKNf-q*RTliZB-dk@rs*k)EEO=PaxOvLf>Bcgk%w zqRNMbHi1t{EcS=#Bol_=E?_$_*YmsuV`XCPd)iSIB@OQ)3>9LjS3w!`TRplMe4~wHZIy#E}c|}AzJ3C|L+HP)cuC0t!g%Rb) zoM7e#ebB9*$YnBC^)=Gs{e4GRIH zD0;ReF1~-EsQyCWww^Hj)kOV7#CY-e;|8)lVR(Mvc~>Fwb%j+?6#d(Y#lDB?*+5gP z=RK$JxUqIacRIZ-uP>hKt}!AP`tkU=I|m0F0?&IMc-T13t=-+-`^Onm{CNCo;4+0J zvl<%a1)les!1GphOQgCkola*;nP+7YCDINoGR7P)BI3ki8-bqyO{i`Iogm111DS66DRApY}v9}fpZm>=jY&~dWxuCA2X&O)zv_g z!l1&3fa|O=Px-!oj_bNLK|KC@5&5OUN+1L52F?I(wo&x#IIGBUemwppa2If%z)|Ej z?DG_si^%PcG0%FQx44vfRuoYJQK21=#}}b`Ik4NPp5L8H_2qsC5!ZDWJ0h*BI#|qR z5Cq4I>NfyT{bs3LthF%_!5EV*dm=epB_cy=?M;#D&(i7iJ`pi~JpMUgy{K++jOkTq zQ`juV+>l5l{+{RDgtePcJ#*A?z7MP!V|PjZ`w_ABJ3Z-i5^}#waMoF#8gng?AUR-F~%3w9{}?eHYZc5 zUzbWmL}K~zqGEj~K!mjyCsV1%#&Ea5&jZi91UL_91MUk`sY`Xtk$57Jc+vO$TSWCC zV0A}F$8}>3D{Kf;sWoGD^6g|xOG|rQP0h!*$)7 zQq)!Croi(?b`A~>$3(V?>IPsQur9Lpl5(i1YGDqQMU==xi7`%khw%ps&8)Rw)^YAF z#A30>f&D;iXlUq^F{0t&k&(6I=>YWg_5D{w)&nSz?ZE{nrF)n-XET zcB*4T&QVjjprh7~OeBj%(TFt$L`I94DcEp05ZM#jEkHzGC&&G`VtuD&AJrX(-A461 zAOwy<^~S8@Y!5u|PT%+EPQ|v4c^{4|S1oBjvuDqqBkzzjiarQ{$g9P=P8<2|R4Pn_ zp|2t<5qXMSI=WU=pKx7w-V{vdmO_zPMxp!J_zd0$U{a=<$CLc&7 zljop%fxu2+ag8y*snnjr5P(`cYl1Gr03vc!5mP5s%HdGKsxHen55J=dNTgDaNfa#y zRAG6g>JT8aU{f{}5q;@B0@SYli@=F{h#0URP7I99W>x=VY@h z6TQ79?Hem|RK5h{SQ|yL*c+&3fh8icBwtPGUSw_f=Hy7Ptb{D-<9%mQ~f8lBv{>1JAn@sLRhG0?^60 zDhk5tZEB&k)rIHGlm>4(#hClZEa83OvYC@Q&o+D&>9ma!|*=gpOUcm7hzuD;dtUQsv!V-_Y7iK3geDyELIlZp2B_M;UR0(vt7ZsA5`Bwxgoa z(G}!Y|3p_;SEXk_Rg{TI9p(G}+guquLW3CT8ZxfJ3 zWEC(ANJLR|=V4)31yICM3Imc$v9APB)e%vB)QWtz)JqvvOb?1?eZKF{6>EI~&8R+6 z?!jIa(}RlA^C}KMj=aOPD#k_CQ8NTpN6irY4V!Z07*qoM6N<$g2}$S Az5oCK literal 0 HcmV?d00001