page.js
58 lines
| 1.7 KiB
| application/javascript
|
JavascriptLexer
Jonathan Frederic
|
r17188 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
define([ | ||||
'base/js/namespace', | ||||
Jonathan Frederic
|
r17200 | 'jquery', | ||
Jonathan Frederic
|
r19179 | 'base/js/events', | ||
], function(IPython, $, events){ | ||||
Matthias BUSSONNIER
|
r12103 | "use strict"; | ||
Brian Granger
|
r6192 | |||
var Page = function () { | ||||
this.bind_events(); | ||||
Jonathan Frederic
|
r19655 | |||
// When the page is ready, resize the header. | ||||
var that = this; | ||||
$(function() { that._resize_header(); }); | ||||
Brian Granger
|
r6192 | }; | ||
Page.prototype.bind_events = function () { | ||||
Jonathan Frederic
|
r19179 | events.on('resize-header.Page', $.proxy(this._resize_header, this)); | ||
Brian Granger
|
r6192 | }; | ||
Page.prototype.show = function () { | ||||
Jonathan Frederic
|
r19176 | /** | ||
* The header and site divs start out hidden to prevent FLOUC. | ||||
* Main scripts should call this method after styling everything. | ||||
*/ | ||||
Brian Granger
|
r6193 | this.show_header(); | ||
this.show_site(); | ||||
}; | ||||
Page.prototype.show_header = function () { | ||||
Jonathan Frederic
|
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 | ||||
*/ | ||||
Brian Granger
|
r6192 | $('div#header').css('display','block'); | ||
Brian Granger
|
r6193 | }; | ||
Page.prototype.show_site = function () { | ||||
Jonathan Frederic
|
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 | ||||
*/ | ||||
Brian Granger
|
r6192 | $('div#site').css('display','block'); | ||
}; | ||||
Jonathan Frederic
|
r19179 | Page.prototype._resize_header = function() { | ||
// Update the header's size. | ||||
$('#header-spacer').height($('#header').height()); | ||||
}; | ||||
Jonathan Frederic
|
r17188 | // Register self in the global namespace for convenience. | ||
Brian Granger
|
r6192 | IPython.Page = Page; | ||
Jonathan Frederic
|
r17201 | return {'Page': Page}; | ||
Jonathan Frederic
|
r17188 | }); | ||