-
Notifications
You must be signed in to change notification settings - Fork 967
/
page.js
136 lines (124 loc) · 4.59 KB
/
page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
define([
'layout/masthead',
'layout/panel',
'mvc/ui/ui-modal',
'mvc/base-mvc'
], function( Masthead, Panel, Modal, BaseMVC ) {
// ============================================================================
var PageLayoutView = Backbone.View.extend( BaseMVC.LoggableMixin ).extend({
_logNamespace : 'layout',
el : 'body',
className : 'full-content',
_panelIds : [
'left', 'center', 'right'
],
defaultOptions : {
message_box_visible : false,
message_box_content : '',
message_box_class : 'info',
show_inactivity_warning : false,
inactivity_box_content : ''
},
initialize : function( options ) {
// TODO: remove globals
this.log( this + '.initialize:', options );
_.extend( this, _.pick( options, this._panelIds ) );
this.options = _.defaults( _.omit( options, this._panelIds ), this.defaultOptions );
Galaxy.modal = this.modal = new Modal.View();
this.masthead = new Masthead.View( this.options.config );
this.$el.attr( 'scroll', 'no' );
this.$el.append( this._template() );
this.$el.append( this.masthead.$el );
this.$el.append( this.modal.$el );
this.$messagebox = this.$( '#messagebox' );
this.$inactivebox = this.$( '#inactivebox' );
},
render : function() {
// TODO: Remove this line after select2 update
$( '.select2-hidden-accessible' ).remove();
this.log( this + '.render:' );
this.masthead.render();
this.renderMessageBox();
this.renderInactivityBox();
this.renderPanels();
return this;
},
/** Render message box */
renderMessageBox : function() {
if ( this.options.message_box_visible ){
var content = this.options.message_box_content || '';
var level = this.options.message_box_class || 'info';
this.$el.addClass( 'has-message-box' );
this.$messagebox
.attr( 'class', 'panel-' + level + '-message' )
.html( content )
.toggle( !!content )
.show();
} else {
this.$el.removeClass( 'has-message-box' );
this.$messagebox.hide();
}
return this;
},
/** Render inactivity warning */
renderInactivityBox : function() {
if( this.options.show_inactivity_warning ){
var content = this.options.inactivity_box_content || '';
var verificationLink = $( '<a/>' ).attr( 'href', Galaxy.root + 'user/resend_verification' ).html( 'Resend verification.' );
this.$el.addClass( 'has-inactivity-box' );
this.$inactivebox
.html( content )
.append( ' ' + verificationLink )
.toggle( !!content )
.show();
} else {
this.$el.removeClass( 'has-inactivity-box' );
this.$inactivebox.hide();
}
return this;
},
/** Render panels */
renderPanels : function() {
var page = this;
this._panelIds.forEach( function( panelId ){
if( _.has( page, panelId ) ){
page[ panelId ].setElement( '#' + panelId );
page[ panelId ].render();
} else if ( panelId !== 'center' ) {
page.center.$el.css( panelId, 0 );
}
});
return this;
},
/** body template */
_template: function() {
return [
'<div id="everything">',
'<div id="background"/>',
'<div id="messagebox"/>',
'<div id="inactivebox" class="panel-warning-message"/>',
'<div id="left"/>',
'<div id="center" class="inbound"/>',
'<div id="right"/>',
'</div>',
'<div id="dd-helper"/>',
'<noscript>',
'<div class="overlay overlay-background noscript-overlay">',
'<div>',
'<h3 class="title">Javascript Required for Galaxy</h3>',
'<div>',
'The Galaxy analysis interface requires a browser with Javascript enabled.<br>',
'Please enable Javascript and refresh this page',
'</div>',
'</div>',
'</div>',
'</noscript>'
].join('');
},
toString : function() { return 'PageLayoutView' }
});
// ============================================================================
return {
PageLayoutView: PageLayoutView
};
});