page.js
65 lines
| 1.9 KiB
| application/javascript
|
JavascriptLexer
|
r17188 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
define([ | ||||
'base/js/namespace', | ||||
|
r17200 | 'jquery', | ||
|
r19179 | 'base/js/events', | ||
], function(IPython, $, events){ | ||||
|
r12103 | "use strict"; | ||
|
r6192 | |||
var Page = function () { | ||||
this.bind_events(); | ||||
}; | ||||
Page.prototype.bind_events = function () { | ||||
|
r20107 | // resize site on: | ||
// - window resize | ||||
// - header change | ||||
// - page load | ||||
var _handle_resize = $.proxy(this._resize_site, this); | ||||
$(window).resize(_handle_resize); | ||||
// On document ready, resize codemirror. | ||||
$(document).ready(_handle_resize); | ||||
events.on('resize-header.Page', _handle_resize); | ||||
|
r6192 | }; | ||
Page.prototype.show = function () { | ||||
|
r19176 | /** | ||
* The header and site divs start out hidden to prevent FLOUC. | ||||
* Main scripts should call this method after styling everything. | ||||
*/ | ||||
|
r6193 | this.show_header(); | ||
this.show_site(); | ||||
}; | ||||
Page.prototype.show_header = function () { | ||||
|
r19176 | /** | ||
* The header and site divs start out hidden to prevent FLOUC. | ||||
* Main scripts should call this method after styling everything. | ||||
* TODO: selector are hardcoded, pass as constructor argument | ||||
*/ | ||||
|
r6192 | $('div#header').css('display','block'); | ||
|
r6193 | }; | ||
Page.prototype.show_site = function () { | ||||
|
r19176 | /** | ||
* The header and site divs start out hidden to prevent FLOUC. | ||||
* Main scripts should call this method after styling everything. | ||||
* TODO: selector are hardcoded, pass as constructor argument | ||||
*/ | ||||
|
r20107 | $('div#site').css('display', 'block'); | ||
this._resize_site(); | ||||
|
r6192 | }; | ||
|
r20107 | Page.prototype._resize_site = function() { | ||
// Update the site's size. | ||||
|
r20657 | $('div#site').height($(window).height() - $('#header').height()); | ||
|
r19179 | }; | ||
|
r17188 | // Register self in the global namespace for convenience. | ||
|
r6192 | IPython.Page = Page; | ||
|
r17201 | return {'Page': Page}; | ||
|
r17188 | }); | ||