Revision bfb11987 snf-cyclades-app/synnefo/ui/static/snf/js/views_ext.js
b/snf-cyclades-app/synnefo/ui/static/snf/js/views_ext.js | ||
---|---|---|
453 | 453 |
} |
454 | 454 |
}, |
455 | 455 |
|
456 |
action_cls_map: { |
|
457 |
'remove': 'destroy' |
|
458 |
}, |
|
459 |
|
|
460 |
_set_confirm: function(action) { |
|
461 |
this.pending_action = action; |
|
462 |
this.set_action_indicator(action); |
|
463 |
}, |
|
464 |
|
|
465 |
_unset_confirm: function(action) { |
|
466 |
this.pending_action = undefined; |
|
467 |
this.reset_action_indicator(action); |
|
468 |
}, |
|
469 |
|
|
470 |
set_action_indicator: function(action) { |
|
471 |
action = this.action_cls_map[action] || action; |
|
472 |
var indicator = this.el.find(".action-indicator"); |
|
473 |
indicator = $(indicator[indicator.length - 1]); |
|
474 |
indicator.attr("class", "").addClass("state action-indicator " + action); |
|
475 |
}, |
|
476 |
|
|
477 |
reset_action_indicator: function() { |
|
478 |
var indicator = this.el.find(".action-indicator"); |
|
479 |
indicator = $(indicator[indicator.length - 1]); |
|
480 |
indicator.attr("class", "").addClass("state action-indicator"); |
|
481 |
if (this.pending_action) { |
|
482 |
this.set_action_indicator(this.pending_action); |
|
483 |
} |
|
484 |
}, |
|
485 |
|
|
456 | 486 |
set_confirm: function() {}, |
457 | 487 |
unset_confirm: function() {}, |
458 | 488 |
|
459 | 489 |
init_action_methods: function(actions) { |
490 |
var self = this; |
|
491 |
if (this.model && this.model.actions) { |
|
492 |
this.model.actions.bind("reset-pending", function() { |
|
493 |
this._unset_confirm(); |
|
494 |
}, this); |
|
495 |
this.model.actions.bind("set-pending", function(action) { |
|
496 |
console.log("ACTION", action); |
|
497 |
this._set_confirm(action) |
|
498 |
}, this); |
|
499 |
} |
|
460 | 500 |
_.each(actions.actions, function(action) { |
501 |
this.el.find(".action-container." + action).hover(function() { |
|
502 |
self.set_action_indicator(action); |
|
503 |
}, function() { |
|
504 |
self.reset_action_indicator(); |
|
505 |
}); |
|
461 | 506 |
var method; |
462 | 507 |
method = 'set_{0}_confirm'.format(action); |
463 | 508 |
if (this[method]) { return } |
464 | 509 |
this[method] = _.bind(function(model, ev) { |
465 | 510 |
if (ev) { ev.stopPropagation() } |
466 | 511 |
var data = {}; |
512 |
this._set_confirm(action); |
|
467 | 513 |
this.set_confirm(action); |
468 | 514 |
this.model.actions.set_pending_action(action); |
469 | 515 |
}, this); |
... | ... | |
472 | 518 |
this[method] = _.bind(function(model, ev) { |
473 | 519 |
if (ev) { ev.stopPropagation() } |
474 | 520 |
var data = {}; |
521 |
this._unset_confirm(action); |
|
475 | 522 |
this.unset_confirm(action); |
476 | 523 |
this.model.actions.unset_pending_action(action); |
477 | 524 |
}, this); |
Also available in: Unified diff