~bac/juju-gui/1103207

« back to all changes in this revision

Viewing changes to app/views/topology/mega.js

  • Committer: Matthew Scott
  • Date: 2013-01-09 17:23:33 UTC
  • mfrom: (307 juju-gui)
  • mto: This revision was merged to the branch mainline in revision 312.
  • Revision ID: matthew.scott@canonical.com-20130109172333-ad6ndevmn5p44dz0
Merging with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
        }
129
129
      },
130
130
      yui: {
131
 
        windowresize: {
132
 
          callback: 'setSizesFromViewport',
133
 
          context: 'module'},
134
131
        rendered: 'renderedHandler',
135
132
        show: 'show',
136
133
        hide: 'hide',
655
652
 
656
653
      this.update();
657
654
 
658
 
      // Set the sizes from the viewport.
659
 
      this.setSizesFromViewport();
660
 
 
661
655
      // Ensure relation labels are sized properly.
662
656
      container.all('.rel-label').each(function(label) {
663
657
        var width = label.one('text').getClientRect().width + 10;
703
697
      picker.one('.picker-expanded').removeClass('active');
704
698
    },
705
699
 
706
 
    /*
707
 
         * Set the visualization size based on the viewport
708
 
         */
709
 
    setSizesFromViewport: function() {
710
 
      // This event allows other page components that may unintentionally
711
 
      // affect the page size, such as the charm panel, to get out of the
712
 
      // way before we compute sizes.  Note the
713
 
      // "afterPageSizeRecalculation" event at the end of this function.
714
 
      // start with some reasonable defaults
715
 
      console.log('setSizesFromViewPort', this, arguments);
716
 
      var topo = this.get('component'),
717
 
          container = this.get('container'),
718
 
          vis = topo.vis,
719
 
          xscale = topo.xScale,
720
 
          yscale = topo.yScale,
721
 
          svg = container.one('svg'),
722
 
          canvas = container.one('.topology-canvas');
723
 
 
724
 
      topo.fire('beforePageSizeRecalculation');
725
 
      // Get the canvas out of the way so we can calculate the size
726
 
      // correctly (the canvas contains the svg).  We want it to be the
727
 
      // smallest size we accept--no smaller or bigger--or else the
728
 
      // presence or absence of scrollbars may affect our calculations
729
 
      // incorrectly.
730
 
      canvas.setStyles({height: 600, width: 800});
731
 
      var dimensions = utils.getEffectiveViewportSize(true, 800, 600);
732
 
      // Set the svg sizes.
733
 
      svg.setAttribute('width', dimensions.width)
734
 
            .setAttribute('height', dimensions.height);
735
 
 
736
 
      // Set the internal rect's size.
737
 
      svg.one('rect')
738
 
            .setAttribute('width', dimensions.width)
739
 
            .setAttribute('height', dimensions.height);
740
 
      canvas
741
 
            .setStyle('height', dimensions.height)
742
 
            .setStyle('width', dimensions.width);
743
 
 
744
 
      // Reset the scale parameters
745
 
      topo.xScale.domain([-dimensions.width / 2, dimensions.width / 2])
746
 
            .range([0, dimensions.width]);
747
 
      topo.yScale.domain([-dimensions.height / 2, dimensions.height / 2])
748
 
            .range([dimensions.height, 0]);
749
 
 
750
 
      topo.set('size', [dimensions.width, dimensions.height]);
751
 
      topo.fire('afterPageSizeRecalculation');
752
 
    },
753
 
 
754
 
    /*
755
 
         * Update the location of the active service panel
756
 
         */
757
700
    updateServiceMenuLocation: function() {
758
701
      var topo = this.get('component'),
759
702
          container = this.get('container'),
894
837
    'd3',
895
838
    'd3-components',
896
839
    'juju-templates',
897
 
    'node',
898
 
    'event',
899
840
    'juju-models',
900
841
    'juju-env'
901
842
  ]