@@ -208,6 +208,7 @@ $(function() {
208208 // Add event listeners
209209 let row = d3 . select ( this . element . context )
210210
211+ //Create table for each row of the settings table
211212 options_table = row . append ( "table" )
212213 . attr ( "draggable" , true )
213214 . classed ( "added-table" , true )
@@ -221,7 +222,7 @@ $(function() {
221222 $ ( row . node ( ) ) . settings_row ( "direct_drop_event" , e )
222223 } ) ,
223224
224- // Add sliders and buttons
225+ // Add sliders and buttons to first row
225226 primary_row = options_table . append ( "tr" )
226227 . classed ( "settings-row" , true ) ;
227228 drag_col = primary_row . append ( "td" )
@@ -296,8 +297,7 @@ $(function() {
296297 . on ( "change" , function ( ) { $ ( row . node ( ) ) . settings_row ( "change_secondary_color" , this . value ) } ) ;
297298 } ;
298299
299-
300- //creates a new slider for the scale input
300+ //Creates elements for scale column right-to-left
301301 scale_col . append ( "input" )
302302 . attr ( "type" , "range" )
303303 . classed ( "scale-slider" , true )
@@ -317,11 +317,9 @@ $(function() {
317317 . on ( "mouseup" , function ( ) { $ ( row . node ( ) ) . settings_row ( "toggle_draggable" , true ) } )
318318 . on ( "mouseleave" , function ( ) { $ ( row . node ( ) ) . settings_row ( "toggle_draggable" , true ) } ) ;
319319
320- // Add scale input
321320 scale_col . append ( "label" )
322321 . text ( "Scale:" ) ;
323322
324-
325323 // Add opacity input
326324 opacity_col . append ( "label" )
327325 . text ( "Opacity:" ) ;
@@ -447,32 +445,31 @@ $(function() {
447445 . style ( "float" , "right" )
448446 . on ( "click" , function ( ) { $ ( row . node ( ) ) . settings_row ( "toggle_second_row" ) } ) ;
449447
450- let more_options = options_table . append ( "tr" )
448+ //Creates second row for additional options
449+ let secondary_row = options_table . append ( "tr" )
451450 . classed ( "settings-row" , true )
452451 . classed ( "second-row" , true )
453452 . style ( "margin-right" , "0px" )
454453 . style ( "display" , "none" ) ;
455454
456- col_one = more_options . append ( "td" ) ,
457- baseline_col = more_options . append ( "td" )
458- . classed ( "baseline-col" , true )
459- . classed ( "slider-col" , true )
460- . attr ( "colspan" , "3" ) ,
461- col_four = more_options . append ( "td" ) ,
462- col_five = more_options . append ( "td" ) ,
463- hide_strand_col = more_options . append ( "td" )
464- . classed ( "hide-strand-col" , true )
465- . attr ( "colspan" , "3" )
466- . style ( "white-space" , "nowrap" ) ,
467- col_seven = more_options . append ( "td" )
468- . style ( "width" , "30%" )
469- . style ( "white-space" , "normal" ) ,
470- reset_col = more_options . append ( "td" )
471- . classed ( "reset-col" , true ) ;
472-
473- //creates a new slider for the scale input
455+ //Adds options to secondary row, with cells for features which may be added in the future
456+ secondary_row . append ( "td" ) ,
457+ baseline_col = secondary_row . append ( "td" )
458+ . classed ( "baseline-col" , true )
459+ . classed ( "slider-col" , true )
460+ . attr ( "colspan" , "3" ) ,
461+ secondary_row . append ( "td" ) ,
462+ secondary_row . append ( "td" ) ,
463+ hide_strand_col = secondary_row . append ( "td" )
464+ . classed ( "hide-strand-col" , true )
465+ . attr ( "colspan" , "3" )
466+ . style ( "white-space" , "nowrap" ) ,
467+ secondary_row . append ( "td" )
468+ reset_col = secondary_row . append ( "td" )
469+ . classed ( "reset-col" , true ) ;
470+
471+ //Creates elements for baseline col, right-to-left
474472 baseline_col . append ( "input" )
475- . style ( "float" , "right" )
476473 . attr ( "type" , "range" )
477474 . classed ( "shift-slider" , true )
478475 . attr ( "value" , 50 )
@@ -495,9 +492,11 @@ $(function() {
495492 . text ( "Shift occupancy:" )
496493 . style ( "float" , "right" ) ;
497494
495+ //Creates hide-strand input
498496 forward = hide_strand_col . append ( "div" )
499497 . attr ( "title" , "forward" )
500498 . style ( "float" , "left" )
499+ . style ( "margin-left" , "10%" )
501500 . style ( "margin-right" , "15px" )
502501 forward . append ( "label" )
503502 . text ( "Show forward:" )
@@ -509,9 +508,6 @@ $(function() {
509508 . on ( "input" , function ( ) {
510509 self . toggle_forward ( ! d3 . select ( this ) . property ( "checked" ) ) ;
511510 } )
512-
513-
514-
515511 reverse = hide_strand_col . append ( "div" )
516512 . attr ( "title" , "reverse" )
517513 reverse . append ( "label" )
@@ -526,6 +522,7 @@ $(function() {
526522 self . toggle_reverse ( ! d3 . select ( this ) . property ( "checked" ) ) ;
527523 } )
528524
525+ //Add reset button
529526 reset_col . append ( "input" )
530527 . attr ( "type" , "button" )
531528 . attr ( "value" , "Reset" )
@@ -534,55 +531,6 @@ $(function() {
534531 . on ( "click" , function ( ) { $ ( row . node ( ) ) . settings_row ( "reset" ) } ) ;
535532 } ,
536533
537- disable_direction_checkboxes : function ( disable , plot = true ) {
538- this . hide_forward = disable ;
539- this . hide_reverse = disable ;
540- if ( disable ) {
541- d3 . select ( this . element . context ) . selectAll ( "input.direction_checkbox" )
542- . attr ( "disabled" , true )
543- . property ( 'checked' , false ) ;
544- d3 . select ( this . element . context ) . selectAll ( "td.hide-strand-col" )
545- . style ( "opacity" , ".5" ) ;
546- } else {
547- d3 . select ( this . element . context ) . selectAll ( "input.direction_checkbox" )
548- . attr ( "disabled" , null )
549- . property ( 'checked' , true ) ;
550- d3 . select ( this . element . context ) . selectAll ( "td.hide-strand-col" )
551- . style ( "opacity" , "1" ) ;
552- }
553- if ( plot ) {
554- this . plot_composite ( ) ;
555- }
556- } ,
557-
558- toggle_forward : function ( hide ) {
559- this . hide_forward = hide ;
560- d3 . select ( this . element . context ) . select ( "input.forward_checkbox" ) . property ( "checked" , ! hide ) ;
561- this . plot_composite ( ) ;
562- } ,
563-
564- toggle_reverse : function ( hide ) {
565- this . hide_reverse = hide ;
566- d3 . select ( this . element . context ) . select ( "div.forward input" ) . property ( "checked" , ! hide ) ;
567- this . plot_composite ( )
568- } ,
569-
570- change_baseline : function ( new_baseline , plot = true ) {
571- if ( isNaN ( new_baseline ) ) {
572- d3 . select ( this . element . context ) . select ( "td.baseline-col input.setting-text" ) . node ( ) . value = this . baseline ;
573- d3 . select ( this . element . context ) . select ( "td.baseline-col input.shift-slider" ) . node ( ) . value = ( this . baseline ) * $ ( "#main-plot" ) . main_plot ( "export" ) . ymax + 50 ;
574-
575- } else {
576- new_baseline = new_baseline !== "" ? parseFloat ( new_baseline ) : 0 ;
577- this . baseline = new_baseline ;
578- d3 . select ( this . element . context ) . select ( "td.baseline-col input.setting-text" ) . node ( ) . value = ( new_baseline > 0 ? "+" : "" ) + Math . round ( new_baseline * 100 ) / 100 ;
579- d3 . select ( this . element . context ) . select ( "td.baseline-col input.shift-slider" ) . node ( ) . value = ( new_baseline ) * $ ( "#main-plot" ) . main_plot ( "export" ) . ymax + 50 ;
580- if ( plot ) {
581- this . plot_composite ( )
582- }
583- }
584- } ,
585-
586534 // Remove the row
587535 _destroy : function ( ) {
588536 d3 . select ( this . element . context ) . remove ( )
@@ -745,6 +693,7 @@ $(function() {
745693 this . options . name = new_name ;
746694 $ ( "#main-plot" ) . main_plot ( "change_name" , this . options . idx , new_name ) ;
747695
696+ //Manually adjust width of name divs
748697 let largestWidth = 0 ;
749698 d3 . selectAll ( '.name-col' ) . each ( function ( ) {
750699 let box = d3 . select ( this ) ;
@@ -865,6 +814,59 @@ $(function() {
865814 }
866815 } ,
867816
817+ //Disables direction checkboxes if composite is hidden
818+ disable_direction_checkboxes : function ( disable , plot = true ) {
819+ this . hide_forward = disable ;
820+ this . hide_reverse = disable ;
821+ if ( disable ) {
822+ d3 . select ( this . element . context ) . selectAll ( "input.direction_checkbox" )
823+ . attr ( "disabled" , true )
824+ . property ( 'checked' , false ) ;
825+ d3 . select ( this . element . context ) . selectAll ( "td.hide-strand-col" )
826+ . style ( "opacity" , ".5" ) ;
827+ } else {
828+ d3 . select ( this . element . context ) . selectAll ( "input.direction_checkbox" )
829+ . attr ( "disabled" , null )
830+ . property ( 'checked' , true ) ;
831+ d3 . select ( this . element . context ) . selectAll ( "td.hide-strand-col" )
832+ . style ( "opacity" , "1" ) ;
833+ }
834+ if ( plot ) {
835+ this . plot_composite ( ) ;
836+ }
837+ } ,
838+
839+ //Hides forward strand
840+ toggle_forward : function ( hide ) {
841+ this . hide_forward = hide ;
842+ d3 . select ( this . element . context ) . select ( "input.forward_checkbox" ) . property ( "checked" , ! hide ) ;
843+ this . plot_composite ( ) ;
844+ } ,
845+
846+ //Hides reverse strand
847+ toggle_reverse : function ( hide ) {
848+ this . hide_reverse = hide ;
849+ d3 . select ( this . element . context ) . select ( "div.forward input" ) . property ( "checked" , ! hide ) ;
850+ this . plot_composite ( )
851+ } ,
852+
853+ //Changes baseline occupancy, adjusting slider for plot scale
854+ change_baseline : function ( new_baseline , plot = true ) {
855+ if ( isNaN ( new_baseline ) ) {
856+ d3 . select ( this . element . context ) . select ( "td.baseline-col input.setting-text" ) . node ( ) . value = this . baseline ;
857+ d3 . select ( this . element . context ) . select ( "td.baseline-col input.shift-slider" ) . node ( ) . value = ( this . baseline ) * $ ( "#main-plot" ) . main_plot ( "export" ) . ymax + 50 ;
858+
859+ } else {
860+ new_baseline = new_baseline !== "" ? parseFloat ( new_baseline ) : 0 ;
861+ this . baseline = new_baseline ;
862+ d3 . select ( this . element . context ) . select ( "td.baseline-col input.setting-text" ) . node ( ) . value = ( new_baseline > 0 ? "+" : "" ) + Math . round ( new_baseline * 100 ) / 100 ;
863+ d3 . select ( this . element . context ) . select ( "td.baseline-col input.shift-slider" ) . node ( ) . value = ( new_baseline ) * $ ( "#main-plot" ) . main_plot ( "export" ) . ymax + 50 ;
864+ if ( plot ) {
865+ this . plot_composite ( )
866+ }
867+ }
868+ } ,
869+
868870 add_id : function ( id ) {
869871 this . options . ids . push ( id ) ;
870872 let id_list = d3 . select ( this . element . context ) . select ( ".id-col .id-list" ) ,
0 commit comments