@@ -13,6 +13,10 @@ const Main = (function() {
1313 // other html elements
1414 let tooltip = { } ;
1515 let tree = { } ;
16+ let options = {
17+ showSyntax : false ,
18+ showLinksOnMove : false
19+ } ;
1620
1721 //--------------------------------
1822 // public functions
@@ -42,12 +46,24 @@ const Main = (function() {
4246 rm . resizeRow ( e . detail . object . idx , e . detail . y ) ;
4347 } ) ;
4448
49+ svg . on ( 'word-move-start' , function ( ) {
50+ if ( ! options . showLinksOnMove && options . showSyntax ) {
51+ setSyntaxVisibility ( false ) ;
52+ }
53+ } ) ;
54+
4555 svg . on ( 'word-move' , function ( e ) {
4656 tooltip . clear ( )
4757 lm . stopEditing ( ) ;
4858 rm . moveWordOnRow ( e . detail . object , e . detail . x ) ;
4959 } ) ;
5060
61+ svg . on ( 'word-move-end' , function ( e ) {
62+ if ( ! options . showLinksOnMove && options . showSyntax ) {
63+ setSyntaxVisibility ( true ) ;
64+ }
65+ } ) ;
66+
5167 svg . on ( 'row-recalculate-slots' , function ( e ) {
5268 links . forEach ( link => {
5369 link . resetSlotRecalculation ( ) ;
@@ -78,16 +94,21 @@ const Main = (function() {
7894 }
7995 }
8096
81- // let showSyntax = true;
82- // document.getElementById('syntax-toggle').onclick = function() {
83- // showSyntax = !showSyntax;
84- // this.innerHTML = showSyntax ? 'Hide syntax' : 'Show syntax';
85- // links.forEach(l => {
86- // if (!l.top) {
87- // showSyntax ? l.show() : l.hide();
88- // }
89- // });
90- // }
97+ document . querySelectorAll ( '#options input' ) . forEach ( input => {
98+ input . onclick = function ( ) {
99+ let option = this . getAttribute ( 'data-option' ) ;
100+ switch ( option ) {
101+ case 'syntax' :
102+ options . showSyntax = this . checked ;
103+ setSyntaxVisibility ( ) ;
104+ break ;
105+ case 'links' :
106+ options . showLinksOnMove = this . checked ;
107+ break ;
108+ default : ;
109+ }
110+ } ;
111+ } ) ;
91112
92113 function setActiveTab ( pageId , modalId = "modal" ) {
93114 let m = document . getElementById ( modalId ) ;
@@ -163,6 +184,7 @@ const Main = (function() {
163184 clear ( ) ;
164185 ymlToJson . convert ( 'taxonomy.yml.txt' , function ( taxonomy ) {
165186 [ words , links , clusters ] = buildWordsAndLinks ( ) ;
187+ setSyntaxVisibility ( ) ;
166188 draw ( ) ;
167189
168190 tm . buildTree ( taxonomy ) ;
@@ -206,6 +228,21 @@ const Main = (function() {
206228 //--------------------------------
207229 // private functions
208230 //--------------------------------
231+
232+ /** options to set visibility of syntax tree
233+ */
234+ function setSyntaxVisibility ( bool ) {
235+ bool = ( bool === undefined ) ? options . showSyntax : bool ;
236+ links . forEach ( l => {
237+ if ( ! l . top ) {
238+ bool ? l . show ( ) : l . hide ( ) ;
239+ }
240+ } ) ;
241+ if ( rm . rows . length > 0 ) {
242+ rm . resizeAll ( ) ;
243+ }
244+ }
245+
209246 function buildWordsAndLinks ( ) {
210247 // construct word objects and tags from tokens, entities, and triggers
211248 const words = parser . tokens . map ( ( token , i ) => {
0 commit comments