Revision a37c5497 snf-cyclades-app/synnefo/ui/static/snf/js/views_ext.js
b/snf-cyclades-app/synnefo/ui/static/snf/js/views_ext.js | ||
---|---|---|
518 | 518 |
} |
519 | 519 |
} |
520 | 520 |
}); |
521 |
|
|
522 |
views.ext.SelectModelView = views.ext.ModelView.extend({ |
|
523 |
select: function() { |
|
524 |
if (!this.delegate_checked) { |
|
525 |
this.input.attr("checked", true); |
|
526 |
this.item.addClass("selected"); |
|
527 |
} |
|
528 |
this.selected = true; |
|
529 |
this.trigger("change:select", this, this.selected); |
|
530 |
}, |
|
531 |
|
|
532 |
deselect: function() { |
|
533 |
if (!this.delegate_checked) { |
|
534 |
this.input.attr("checked", false); |
|
535 |
this.item.removeClass("selected"); |
|
536 |
} |
|
537 |
this.selected = false; |
|
538 |
this.trigger("change:select", this, this.selected); |
|
539 |
}, |
|
540 |
|
|
541 |
toggle_select: function() { |
|
542 |
if (this.selected) { |
|
543 |
this.deselect(); |
|
544 |
} else { |
|
545 |
this.select(); |
|
546 |
} |
|
547 |
}, |
|
548 |
|
|
549 |
post_init_element: function() { |
|
550 |
this.input = $(this.$("input").get(0)); |
|
551 |
this.item = $(this.$(".select-item").get(0)); |
|
552 |
this.delegate_checked = this.model.get('noselect'); |
|
553 |
this.deselect(); |
|
554 |
|
|
555 |
var self = this; |
|
556 |
if (self.model.get('forced')) { |
|
557 |
this.select(); |
|
558 |
this.input.attr("disabled", true); |
|
559 |
$(this.el).attr('title', this.forced_title); |
|
560 |
$(this.el).tooltip({ |
|
561 |
'tipClass': 'tooltip', |
|
562 |
'position': 'top center', |
|
563 |
'offset': [29, 0] |
|
564 |
}); |
|
565 |
} |
|
566 |
|
|
567 |
$(this.item).click(function(e) { |
|
568 |
if (self.model.get('forced')) { return } |
|
569 |
e.stopPropagation(); |
|
570 |
self.toggle_select(); |
|
571 |
}); |
|
572 |
|
|
573 |
views.ext.SelectModelView.__super__.post_init_element.apply(this, |
|
574 |
arguments); |
|
575 |
} |
|
576 |
}); |
|
577 |
|
|
521 | 578 |
|
522 | 579 |
views.ext.ModelCreateView = views.ext.ModelView.extend({}); |
523 | 580 |
views.ext.ModelEditView = views.ext.ModelCreateView.extend({}); |
Also available in: Unified diff