1 _kiwi
.view
.Panel
= Backbone
.View
.extend({
8 initialize: function (options
) {
9 this.initializePanel(options
);
12 initializePanel: function (options
) {
13 this.$el
.css('display', 'none');
14 options
= options
|| {};
16 // Containing element for this panel
17 if (options
.container
) {
18 this.$container
= $(options
.container
);
20 this.$container
= $('#kiwi .panels .container1');
23 this.$el
.appendTo(this.$container
);
27 this.model
.set({"view": this}, {"silent": true});
37 // Hide all other panels and show this one
38 this.$container
.children('.panel').css('display', 'none');
39 $this.css('display', 'block');
41 // Show this panels memberlist
42 var members
= this.model
.get("members");
44 $('#kiwi .right_bar').removeClass('disabled');
47 // Memberlist not found for this panel, hide any active ones
48 $('#kiwi .right_bar').addClass('disabled').children().removeClass('active');
51 // Remove any alerts and activity counters for this panel
53 this.model
.tab
.find('.activity').text('0').addClass('zero');
55 _kiwi
.app
.panels
.trigger('active', this.model
, _kiwi
.app
.panels().active
);
56 this.model
.trigger('active', this.model
);
58 _kiwi
.app
.view
.doLayout();
60 if (!this.model
.isApplet())
61 this.scrollToBottom(true);
65 alert: function (level
) {
66 // No need to highlight if this si the active panel
67 if (this.model
== _kiwi
.app
.panels().active
) return;
70 types
= ['none', 'action', 'activity', 'highlight'];
72 // Default alert level
73 level
= level
|| 'none';
75 // If this alert level does not exist, assume clearing current level
76 type_idx
= _
.indexOf(types
, level
);
82 // Only 'upgrade' the alert. Never down (unless clearing)
83 if (type_idx
!== 0 && type_idx
<= this.alert_level
) {
87 // Clear any existing levels
88 this.model
.tab
.removeClass(function (i
, css
) {
89 return (css
.match(/\balert_\S+/g) || []).join(' ');
92 // Add the new level if there is one
93 if (level
!== 'none') {
94 this.model
.tab
.addClass('alert_' + level
);
97 this.alert_level
= type_idx
;
101 // Scroll to the bottom of the panel
102 scrollToBottom: function (force_down
) {
103 // If this isn't the active panel, don't scroll
104 if (this.model
!== _kiwi
.app
.panels().active
) return;
106 // Don't scroll down if we're scrolled up the panel a little
107 if (force_down
|| this.$container
.scrollTop() + this.$container
.height() > this.$el
.outerHeight() - 150) {
108 this.$container
[0].scrollTop
= this.$container
[0].scrollHeight
;