forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontents.js
More file actions
52 lines (44 loc) · 1.56 KB
/
contents.js
File metadata and controls
52 lines (44 loc) · 1.56 KB
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
const localize = require('./localize').localize;
const Client = require('./client').Client;
const Login = require('./login').Login;
const Contents = (function() {
const on_load = function() {
Client.activate_by_client_type();
update_content_class();
init_draggable();
};
const on_unload = function() {
const $unbind_later = $('.unbind_later');
if ($unbind_later.length > 0) {
$unbind_later.off();
}
};
const update_content_class = function() {
// This is required for our css to work.
$('#content').removeClass()
.addClass($('#content_class').text());
};
const init_draggable = function() {
$('.draggable').draggable();
};
const show_login_if_logout = function(shouldReplacePageContents) {
if (!Client.get_boolean('is_logged_in') && shouldReplacePageContents) {
$('#content').find(' > .container').addClass('center-text')
.html($('<p/>', {
class: 'notice-msg',
html : localize('Please [_1] to view this page',
['<a class="login_link" href="javascript:;">' + localize('login') + '</a>']),
}));
$('.login_link').click(function() { Login.redirect_to_login(); });
}
return !Client.get_boolean('is_logged_in');
};
return {
on_load : on_load,
on_unload: on_unload,
show_login_if_logout: show_login_if_logout,
};
})();
module.exports = {
Contents: Contents,
};