~bcsaller/juju-gui/phantom-testing

« back to all changes in this revision

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

  • Committer: Benjamin Saller
  • Author(s): Benjamin Saller
  • Date: 2013-01-22 13:43:22 UTC
  • mfrom: (334.2.4 menu-click-fix)
  • Revision ID: bcsaller@gmail.com-20130122134322-z50f41gyqy8658z2
Fix various breakage around menu handling

Fixed issues from merge around method name change and fixed strange
interaction issues with click and dragstart both interacting with the menu on
non-drag events (dragstart it seems is called on any bound targets click).

R=frankban, teknico
CC=
https://codereview.appspot.com/7174045

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
          mouseover: 'serviceStatusMouseOver',
28
28
          mouseout: 'serviceStatusMouseOut'
29
29
        },
30
 
        '.zoomPlane': {
31
 
          click: 'zoomPlaneClick'
 
30
        '.zoom-plane': {
 
31
          click: 'canvasClick'
32
32
        },
33
33
        '.graph-list-picker .picker-button': {
34
34
          click: 'showGraphListPicker'
95
95
      //   service_click_action.<action>
96
96
      // with the service, the SVG node, and the view
97
97
      // as arguments.
98
 
      (context.service_click_actions[curr_click_action])(
 
98
      context.service_click_actions[curr_click_action](
99
99
          d, context, this);
100
100
    },
101
101
 
106
106
      // The browser sends a click event right before the dblclick one, and it
107
107
      // opens the service menu: close it before moving to the service details.
108
108
      self.service_click_actions.hideServiceMenu(null, self);
109
 
      (self.service_click_actions.show_service)(service, self);
 
109
      self.service_click_actions.show_service(service, self);
110
110
    },
111
111
 
112
112
    serviceMouseEnter: function(d, context) {
173
173
     * If the user clicks on the background we cancel any active add
174
174
     * relation.
175
175
     */
176
 
    zoomPlaneClick: function(d, self) {
 
176
    canvasClick: function(d, self) {
177
177
      var container = self.get('container'),
178
178
          topo = self.get('component');
179
179
      container.all('.environment-menu.active').removeClass('active');
180
 
      self.service_click_actions.toggleControlPanel(null, self);
 
180
      self.service_click_actions.hideServiceMenu(null, self);
181
181
      topo.fire('clearState');
182
182
    },
183
183
 
188
188
      var box = topo.get('active_service');
189
189
      var service = topo.serviceForBox(box);
190
190
      context.service_click_actions
191
 
             .toggleControlPanel(box, context);
 
191
             .hideServiceMenu(d, context);
192
192
      context.service_click_actions
193
193
             .show_service(service, context);
194
194
    },
200
200
      var box = topo.get('active_service');
201
201
      var service = topo.serviceForBox(box);
202
202
      context.service_click_actions
203
 
             .toggleControlPanel(box, context);
 
203
             .hideServiceMenu(box, context);
204
204
      context.service_click_actions
205
205
             .destroyServiceConfirm(service, context);
206
206
    },
276
276
      var topo = self.get('component');
277
277
      d.oldX = d.x;
278
278
      d.oldY = d.y;
279
 
      self.get('container').all('.environment-menu.active')
280
 
          .removeClass('active');
281
 
      self.service_click_actions.hideServiceMenu(null, self);
 
279
      d.inDrag = 1;
282
280
    },
283
281
 
284
282
    dragend: function(d,  self) {
287
285
        topo.fire('addRelationDragEnd');
288
286
      }
289
287
      else {
 
288
        if (!d.inDrag ||
 
289
            (d.oldX === d.x &&
 
290
             d.oldY === d.y)) {
 
291
          return;
 
292
        }
290
293
        topo.get('env').update_annotations(
291
294
            d.id, {'gui.x': d.x, 'gui.y': d.y},
292
295
            function() {
293
 
              // Force a reposition at the end.
294
296
              d.inDrag = false;
295
297
              //self.drag.call(self.getServiceNode(d.id),
296
 
              //               d, self, {x:d.x, y: d.y}, false);
 
298
              //               d, self, {x: d.x, y: d.y}, false);
297
299
            });
298
300
      }
299
301
    },
353
355
      // Clear any state while dragging.
354
356
      self.get('container').all('.environment-menu.active')
355
357
          .removeClass('active');
 
358
 
 
359
      if (d.inDrag === 1) {
 
360
        self.service_click_actions.hideServiceMenu(null, self);
 
361
        d.inDrag = 2;
 
362
      }
356
363
      topo.fire('cancelRelationBuild');
357
364
      // Update relation lines for just this service.
358
365
      topo.fire('serviceMoved', { service: d });