Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50650 views
1
// Copyright (c) IPython Development Team.
2
// Distributed under the terms of the Modified BSD License.
3
4
define([
5
'base/js/namespace',
6
'jquery',
7
'base/js/events',
8
], function(IPython, $, events){
9
"use strict";
10
11
var Page = function () {
12
this.bind_events();
13
};
14
15
Page.prototype.bind_events = function () {
16
// resize site on:
17
// - window resize
18
// - header change
19
// - page load
20
var _handle_resize = $.proxy(this._resize_site, this);
21
22
$(window).resize(_handle_resize);
23
24
// On document ready, resize codemirror.
25
$(document).ready(_handle_resize);
26
events.on('resize-header.Page', _handle_resize);
27
};
28
29
Page.prototype.show = function () {
30
/**
31
* The header and site divs start out hidden to prevent FLOUC.
32
* Main scripts should call this method after styling everything.
33
*/
34
this.show_header();
35
this.show_site();
36
};
37
38
Page.prototype.show_header = function () {
39
/**
40
* The header and site divs start out hidden to prevent FLOUC.
41
* Main scripts should call this method after styling everything.
42
* TODO: selector are hardcoded, pass as constructor argument
43
*/
44
$('div#header').css('display','block');
45
};
46
47
Page.prototype.show_site = function () {
48
/**
49
* The header and site divs start out hidden to prevent FLOUC.
50
* Main scripts should call this method after styling everything.
51
* TODO: selector are hardcoded, pass as constructor argument
52
*/
53
$('div#site').css('display', 'block');
54
this._resize_site();
55
};
56
57
Page.prototype._resize_site = function() {
58
// Update the site's size.
59
$('div#site').height($(window).height() - $('#header').height());
60
};
61
62
// Register self in the global namespace for convenience.
63
IPython.Page = Page;
64
return {'Page': Page};
65
});
66
67