-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
layout.js
189 lines (134 loc) · 6.88 KB
/
layout.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
Copyright 2012-2013 OpenBroadcaster, Inc.
This file is part of OpenBroadcaster Server.
OpenBroadcaster Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenBroadcaster Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with OpenBroadcaster Server. If not, see <http://www.gnu.org/licenses/>.
*/
function Layout()
{
this.set_main_size = function()
{
var main = $('#layout_main');
var main_extra_width = parseInt(main.css('borderLeftWidth')) + parseInt(main.css('borderRightWidth'))
+ parseInt(main.css('margin-left')) + parseInt(main.css('margin-right'))
+ parseInt(main.css('padding-left')) + parseInt(main.css('padding-right'));
$('#layout_main').width( $('#layout_container').width() - $('#layout_sidebar').outerWidth(true) - main_extra_width - 14);
var main_extra_height = parseInt(main.css('borderTopWidth')) + parseInt(main.css('borderBottomWidth'))
+ parseInt(main.css('margin-top')) + parseInt(main.css('margin-bottom'))
+ parseInt(main.css('padding-top')) + parseInt(main.css('padding-bottom'));
$('#layout_main').height( $(window).height() - $('#layout_footer').outerHeight(true) - main_extra_height );
var searchbox = $('#sidebar_search_media_container');
var sidebar = $('#layout_sidebar');
var sidebar_extra_height = parseInt(sidebar.css('borderTopWidth')) + parseInt(sidebar.css('borderBottomWidth'))
+ parseInt(sidebar.css('margin-top')) + parseInt(sidebar.css('margin-bottom'))
+ parseInt(sidebar.css('padding-top')) + parseInt(sidebar.css('padding-bottom'));
var searchbox_extra_height = parseInt(searchbox.css('borderTopWidth')) + parseInt(searchbox.css('borderBottomWidth'))
+ parseInt(searchbox.css('margin-top')) + parseInt(searchbox.css('margin-bottom'))
+ parseInt(searchbox.css('padding-top')) + parseInt(searchbox.css('padding-bottom'));
var searchbox_height = $('#layout_main').height() - $('#sidebar_player').outerHeight(true) - searchbox_extra_height - sidebar_extra_height - 25;
$('#sidebar_search_media_container').height( searchbox_height );
$('#sidebar_search_playlist_container').height( searchbox_height );
// var search_results_container = searchbox_height - 72 - $('#sidebar_search_media_select_buttons').height() - parseInt($('#sidebar_search_media_select_buttons').css('padding-top')) - parseInt($('#sidebar_search_media_select_buttons').css('padding-bottom')) - $('#sidebar_search_media_buttons').height() - parseInt($('#sidebar_search_media_buttons').css('padding-top')) - parseInt($('#sidebar_search_media_buttons').css('padding-bottom'));
// using a "dumb" constant here, since sometimes heights are not available (above) if hidden. Something more intelligent can be done at some point.
var playlist_results_container = searchbox_height - 158;
var media_results_container = searchbox_height - 158;
if(media_results_container < 0) media_results_container = 0;
if(playlist_results_container < 0) playlist_results_container = 0;
$('#sidebar_search_media_results_container').height( media_results_container );
$('#sidebar_search_playlist_results_container').height( playlist_results_container );
}
this.home = function()
{
$('#layout_main').html(html.get('main.html'));
}
this.open_dom_window = function()
{
$.openDOMWindow({
windowBGColor: '#333',
modal: 1,
});
this.set_main_size(); // window open/close disrupts sizing
}
this.close_dom_window = function()
{
$.closeDOMWindow();
this.set_main_size(); // window open/close disrupts sizing
}
this.permissions_update = function(context)
{
if(typeof(context)==='undefined') context = 'body';
var available_permissions = new Array();
// determine available permissions without item id. (we just need access to 1 item in order to show) if item id is not specified.
$.each(settings.permissions, function(index,permission)
{
var permission_array = permission.split(':');
available_permissions.push(permission_array[0]);
});
// show/hide based on available permissions.
$(context).find('[data-permissions]').each(function(index,element)
{
var permissions_list = $(element).attr('data-permissions').split(' ');
var has_permission = false;
for(var i in permissions_list)
{
if(available_permissions.indexOf(permissions_list[i])!=-1 || settings.permissions.indexOf(permissions_list[i])!=-1) { has_permission = true; break; }
}
if(has_permission) $(element).show();
else $(element).hide();
});
// if our menu has no items, hide the menu...
$(context).find('#footer_box_left .sf-menu > li').each(function(index,element)
{
var count = 0;
$(element).find('li').each(function(i,e) { if($(e).css('display')!='none') count++; });
if(count==0) $(element).hide();
else $(element).show();
});
}
this.table_fixed_headers = function($headers,$table)
{
$headers.width($table.width())
$headers.find('th:visible').each(function(index,element)
{
if(!$(element).attr('data-column')) return;
$column = $table.find('td:visible[data-column='+$(element).attr('data-column')+']').first();
if(!$column.length) return;
// wrap out table heading if <div> so we can have it cut off if too long.
if(!$(element).find('div').length)
$(element).html('<div style="overflow: hidden; white-space: nowrap; width: '+$column.width()+'px;">'+$(element).html()+'</div>');
$(element).width($column.width());
});
}
}
layout = new Layout();
layout.docready_complete = false;
$(document).ready(function() {
if(!layout.docready_complete)
{
//layout.set_main_size();
$(window).resize(function() { layout.set_main_size(); });
layout.home();
// mousewheel scrolling
$('#layout_main').bind('mousewheel', function(event, delta) {
if(delta>0) $('#layout_main').scrollTo('-=35px');
else $('#layout_main').scrollTo('+=35px');
return false;
});
$("ul.sf-menu").superfish({autoArrows: false, speed: 'fast', delay: 300});
// show/hide functionality based on permissions...
callbacks.permissions_update.push(function() { layout.permissions_update(); });
layout.docready_complete = true;
}
});
$(window).load(function() {
layout.set_main_size();
ModulePlayerMap.init_map();
});