@@ -45,6 +45,7 @@ describe('ModeBar', function() {
45
45
_fullData : [ ] ,
46
46
_context : {
47
47
displaylogo : true ,
48
+ showSendToCloud : false ,
48
49
displayModeBar : true ,
49
50
modeBarButtonsToRemove : [ ] ,
50
51
modeBarButtonsToAdd : [ ] ,
@@ -55,15 +56,15 @@ describe('ModeBar', function() {
55
56
}
56
57
57
58
function countGroups ( modeBar ) {
58
- return d3 . select ( modeBar . element ) . selectAll ( 'div.modebar-group' ) [ 0 ] . length ;
59
+ return d3 . select ( modeBar . element ) . selectAll ( 'div.modebar-group' ) . size ( ) ;
59
60
}
60
61
61
62
function countButtons ( modeBar ) {
62
- return d3 . select ( modeBar . element ) . selectAll ( 'a.modebar-btn' ) [ 0 ] . length ;
63
+ return d3 . select ( modeBar . element ) . selectAll ( 'a.modebar-btn' ) . size ( ) ;
63
64
}
64
65
65
66
function countLogo ( modeBar ) {
66
- return d3 . select ( modeBar . element ) . selectAll ( 'a.plotlyjsicon' ) [ 0 ] . length ;
67
+ return d3 . select ( modeBar . element ) . selectAll ( 'a.plotlyjsicon' ) . size ( ) ;
67
68
}
68
69
69
70
function checkBtnAttr ( modeBar , index , attr ) {
@@ -334,7 +335,7 @@ describe('ModeBar', function() {
334
335
335
336
it ( 'creates mode bar (unselectable cartesian version)' , function ( ) {
336
337
var buttons = getButtons ( [
337
- [ 'toImage' , 'sendDataToCloud' ] ,
338
+ [ 'toImage' ] ,
338
339
[ 'zoom2d' , 'pan2d' ] ,
339
340
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
340
341
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -352,7 +353,7 @@ describe('ModeBar', function() {
352
353
353
354
it ( 'creates mode bar (selectable scatter version)' , function ( ) {
354
355
var buttons = getButtons ( [
355
- [ 'toImage' , 'sendDataToCloud' ] ,
356
+ [ 'toImage' ] ,
356
357
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
357
358
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
358
359
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -376,7 +377,7 @@ describe('ModeBar', function() {
376
377
377
378
it ( 'creates mode bar (selectable box version)' , function ( ) {
378
379
var buttons = getButtons ( [
379
- [ 'toImage' , 'sendDataToCloud' ] ,
380
+ [ 'toImage' ] ,
380
381
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
381
382
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
382
383
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -400,7 +401,7 @@ describe('ModeBar', function() {
400
401
401
402
it ( 'creates mode bar (cartesian fixed-axes version)' , function ( ) {
402
403
var buttons = getButtons ( [
403
- [ 'toImage' , 'sendDataToCloud' ] ,
404
+ [ 'toImage' ] ,
404
405
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
405
406
] ) ;
406
407
@@ -415,7 +416,7 @@ describe('ModeBar', function() {
415
416
416
417
it ( 'creates mode bar (gl3d version)' , function ( ) {
417
418
var buttons = getButtons ( [
418
- [ 'toImage' , 'sendDataToCloud' ] ,
419
+ [ 'toImage' ] ,
419
420
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
420
421
[ 'resetCameraDefault3d' , 'resetCameraLastSave3d' ] ,
421
422
[ 'hoverClosest3d' ]
@@ -432,7 +433,7 @@ describe('ModeBar', function() {
432
433
433
434
it ( 'creates mode bar (geo version)' , function ( ) {
434
435
var buttons = getButtons ( [
435
- [ 'toImage' , 'sendDataToCloud' ] ,
436
+ [ 'toImage' ] ,
436
437
[ 'pan2d' ] ,
437
438
[ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ] ,
438
439
[ 'hoverClosestGeo' ]
@@ -449,7 +450,7 @@ describe('ModeBar', function() {
449
450
450
451
it ( 'creates mode bar (geo + selected version)' , function ( ) {
451
452
var buttons = getButtons ( [
452
- [ 'toImage' , 'sendDataToCloud' ] ,
453
+ [ 'toImage' ] ,
453
454
[ 'pan2d' , 'select2d' , 'lasso2d' ] ,
454
455
[ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ] ,
455
456
[ 'hoverClosestGeo' ]
@@ -472,7 +473,7 @@ describe('ModeBar', function() {
472
473
473
474
it ( 'creates mode bar (mapbox version)' , function ( ) {
474
475
var buttons = getButtons ( [
475
- [ 'toImage' , 'sendDataToCloud' ] ,
476
+ [ 'toImage' ] ,
476
477
[ 'pan2d' ] ,
477
478
[ 'resetViewMapbox' ] ,
478
479
[ 'toggleHover' ]
@@ -489,7 +490,7 @@ describe('ModeBar', function() {
489
490
490
491
it ( 'creates mode bar (mapbox + selected version)' , function ( ) {
491
492
var buttons = getButtons ( [
492
- [ 'toImage' , 'sendDataToCloud' ] ,
493
+ [ 'toImage' ] ,
493
494
[ 'pan2d' , 'select2d' , 'lasso2d' ] ,
494
495
[ 'resetViewMapbox' ] ,
495
496
[ 'toggleHover' ]
@@ -512,7 +513,7 @@ describe('ModeBar', function() {
512
513
513
514
it ( 'creates mode bar (gl2d version)' , function ( ) {
514
515
var buttons = getButtons ( [
515
- [ 'toImage' , 'sendDataToCloud' ] ,
516
+ [ 'toImage' ] ,
516
517
[ 'zoom2d' , 'pan2d' ] ,
517
518
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
518
519
[ 'hoverClosestGl2d' ]
@@ -530,7 +531,7 @@ describe('ModeBar', function() {
530
531
531
532
it ( 'creates mode bar (pie version)' , function ( ) {
532
533
var buttons = getButtons ( [
533
- [ 'toImage' , 'sendDataToCloud' ] ,
534
+ [ 'toImage' ] ,
534
535
[ 'hoverClosestPie' ]
535
536
] ) ;
536
537
@@ -545,7 +546,7 @@ describe('ModeBar', function() {
545
546
546
547
it ( 'creates mode bar (cartesian + gl3d version)' , function ( ) {
547
548
var buttons = getButtons ( [
548
- [ 'toImage' , 'sendDataToCloud' ] ,
549
+ [ 'toImage' ] ,
549
550
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
550
551
[ 'resetViews' ] ,
551
552
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -562,7 +563,7 @@ describe('ModeBar', function() {
562
563
563
564
it ( 'creates mode bar (cartesian + geo unselectable version)' , function ( ) {
564
565
var buttons = getButtons ( [
565
- [ 'toImage' , 'sendDataToCloud' ] ,
566
+ [ 'toImage' ] ,
566
567
[ 'zoom2d' , 'pan2d' ] ,
567
568
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ] ,
568
569
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -580,7 +581,7 @@ describe('ModeBar', function() {
580
581
581
582
it ( 'creates mode bar (cartesian + geo selectable version)' , function ( ) {
582
583
var buttons = getButtons ( [
583
- [ 'toImage' , 'sendDataToCloud' ] ,
584
+ [ 'toImage' ] ,
584
585
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
585
586
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ] ,
586
587
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -604,7 +605,7 @@ describe('ModeBar', function() {
604
605
605
606
it ( 'creates mode bar (cartesian + pie version)' , function ( ) {
606
607
var buttons = getButtons ( [
607
- [ 'toImage' , 'sendDataToCloud' ] ,
608
+ [ 'toImage' ] ,
608
609
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
609
610
[ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
610
611
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
@@ -628,7 +629,7 @@ describe('ModeBar', function() {
628
629
629
630
it ( 'creates mode bar (gl3d + geo version)' , function ( ) {
630
631
var buttons = getButtons ( [
631
- [ 'toImage' , 'sendDataToCloud' ] ,
632
+ [ 'toImage' ] ,
632
633
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
633
634
[ 'resetViews' ] ,
634
635
[ 'toggleHover' ]
@@ -645,7 +646,7 @@ describe('ModeBar', function() {
645
646
646
647
it ( 'creates mode bar (un-selectable ternary version)' , function ( ) {
647
648
var buttons = getButtons ( [
648
- [ 'toImage' , 'sendDataToCloud' ] ,
649
+ [ 'toImage' ] ,
649
650
[ 'zoom2d' , 'pan2d' ] ,
650
651
[ 'toggleHover' ]
651
652
] ) ;
@@ -661,7 +662,7 @@ describe('ModeBar', function() {
661
662
662
663
it ( 'creates mode bar (selectable ternary version)' , function ( ) {
663
664
var buttons = getButtons ( [
664
- [ 'toImage' , 'sendDataToCloud' ] ,
665
+ [ 'toImage' ] ,
665
666
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
666
667
[ 'toggleHover' ]
667
668
] ) ;
@@ -683,7 +684,7 @@ describe('ModeBar', function() {
683
684
684
685
it ( 'creates mode bar (ternary + cartesian version)' , function ( ) {
685
686
var buttons = getButtons ( [
686
- [ 'toImage' , 'sendDataToCloud' ] ,
687
+ [ 'toImage' ] ,
687
688
[ 'zoom2d' , 'pan2d' ] ,
688
689
[ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
689
690
] ) ;
@@ -699,7 +700,7 @@ describe('ModeBar', function() {
699
700
700
701
it ( 'creates mode bar (ternary + gl3d version)' , function ( ) {
701
702
var buttons = getButtons ( [
702
- [ 'toImage' , 'sendDataToCloud' ] ,
703
+ [ 'toImage' ] ,
703
704
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
704
705
[ 'resetViews' ] ,
705
706
[ 'toggleHover' ]
@@ -756,6 +757,23 @@ describe('ModeBar', function() {
756
757
expect ( countLogo ( gd . _fullLayout . _modeBar ) ) . toEqual ( 0 ) ;
757
758
} ) ;
758
759
760
+ it ( 'displays/hides cloud link according to showSendToCloud config arg' , function ( ) {
761
+ var gd = getMockGraphInfo ( ) ;
762
+ gd . _fullLayout . _basePlotModules = [ { name : 'pie' } ] ;
763
+ manageModeBar ( gd ) ;
764
+ checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
765
+ [ 'toImage' ] ,
766
+ [ 'hoverClosestPie' ]
767
+ ] ) , 1 ) ;
768
+
769
+ gd . _context . showSendToCloud = true ;
770
+ manageModeBar ( gd ) ;
771
+ checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
772
+ [ 'toImage' , 'sendDataToCloud' ] ,
773
+ [ 'hoverClosestPie' ]
774
+ ] ) , 1 ) ;
775
+ } ) ;
776
+
759
777
it ( 'always displays the logo if watermark config arg is true' , function ( ) {
760
778
var gd = getMockGraphInfo ( ) ;
761
779
gd . _context . displaylogo = false ;
@@ -778,18 +796,20 @@ describe('ModeBar', function() {
778
796
var gd = setupGraphInfo ( ) ;
779
797
manageModeBar ( gd ) ;
780
798
799
+ expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 11 ) ;
800
+
781
801
gd . _fullLayout . _basePlotModules = [ { name : 'gl3d' } ] ;
782
802
manageModeBar ( gd ) ;
783
803
784
- expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 10 ) ;
804
+ expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 9 ) ;
785
805
} ) ;
786
806
787
807
it ( 'updates mode bar buttons if modeBarButtonsToRemove changes' , function ( ) {
788
808
var gd = setupGraphInfo ( ) ;
789
809
manageModeBar ( gd ) ;
790
810
var initialButtonCount = countButtons ( gd . _fullLayout . _modeBar ) ;
791
811
792
- gd . _context . modeBarButtonsToRemove = [ 'toImage' , 'sendDataToCloud ' ] ;
812
+ gd . _context . modeBarButtonsToRemove = [ 'toImage' , 'zoom2d ' ] ;
793
813
manageModeBar ( gd ) ;
794
814
795
815
expect ( countButtons ( gd . _fullLayout . _modeBar ) )
@@ -829,7 +849,7 @@ describe('ModeBar', function() {
829
849
830
850
var modeBar = gd . _fullLayout . _modeBar ;
831
851
expect ( countGroups ( modeBar ) ) . toEqual ( 6 ) ;
832
- expect ( countButtons ( modeBar ) ) . toEqual ( 11 ) ;
852
+ expect ( countButtons ( modeBar ) ) . toEqual ( 10 ) ;
833
853
} ) ;
834
854
835
855
it ( 'sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove (2)' , function ( ) {
@@ -849,7 +869,7 @@ describe('ModeBar', function() {
849
869
850
870
var modeBar = gd . _fullLayout . _modeBar ;
851
871
expect ( countGroups ( modeBar ) ) . toEqual ( 7 ) ;
852
- expect ( countButtons ( modeBar ) ) . toEqual ( 13 ) ;
872
+ expect ( countButtons ( modeBar ) ) . toEqual ( 12 ) ;
853
873
} ) ;
854
874
855
875
it ( 'sets up buttons with fully custom modeBarButtons' , function ( ) {
0 commit comments