##// END OF EJS Templates
tweak raw placeholder
tweak raw placeholder

File last commit:

r12103:dc60758c
r13769:91c37c15
Show More
pager.js
176 lines | 6.1 KiB | application/javascript | JavascriptLexer
Brian E. Granger
More review changes....
r4609 //----------------------------------------------------------------------------
// Copyright (C) 2008-2011 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
Brian E. Granger
Refactoring pager into its own class.
r4357
//============================================================================
// Pager
//============================================================================
var IPython = (function (IPython) {
Matthias BUSSONNIER
"use strict" in most (if not all) our javascript...
r12103 "use strict";
Brian E. Granger
Refactoring pager into its own class.
r4357
var utils = IPython.utils;
Brian E. Granger
Left panel is now working.
r4363 var Pager = function (pager_selector, pager_splitter_selector) {
Brian E. Granger
Refactoring pager into its own class.
r4357 this.pager_element = $(pager_selector);
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 this.pager_button_area = $('#pager_button_area');
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 var that = this;
Brian E. Granger
Work on save widget, kernel status widget and notebook section.
r4372 this.percentage_height = 0.40;
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 this.pager_splitter_element = $(pager_splitter_selector)
.draggable({
containment: 'window',
axis:'y',
helper: null ,
Matthias BUSSONNIER
pep 8 and js...
r6739 drag: function(event, ui) {
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 // recalculate the amount of space the pager should take
MinRK
fix bad `$(body)`
r10908 var pheight = ($(document.body).height()-event.clientY-4);
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 var downprct = pheight/IPython.layout_manager.app_height();
Matthias BUSSONNIER
pep 8 and js...
r6739 downprct = Math.min(0.9, downprct);
if (downprct < 0.1) {
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 that.percentage_height = 0.1;
that.collapse({'duration':0});
Matthias BUSSONNIER
pep 8 and js...
r6739 } else if (downprct > 0.2) {
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 that.percentage_height = downprct;
that.expand({'duration':0});
}
IPython.layout_manager.do_resize();
}
});
this.expanded = false;
Brian E. Granger
Refactoring pager into its own class.
r4357 this.style();
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 this.create_button_area();
Brian E. Granger
Refactoring pager into its own class.
r4357 this.bind_events();
};
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 Pager.prototype.create_button_area = function(){
var that = this;
this.pager_button_area.append(
$('<a>').attr('role', "button")
Erik Tollerud
Added clickable icon to collapse pager...
r10469 .attr('title',"Open the pager in an external window")
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 .addClass('ui-button')
.click(function(){that.detach()})
Erik Tollerud
Added clickable icon to collapse pager...
r10469 .attr('style','position: absolute; right: 20px;')
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 .append(
Bussonnier Matthias
change detach icon and tab title
r8449 $('<span>').addClass("ui-icon ui-icon-extlink")
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 )
)
Erik Tollerud
Added clickable icon to collapse pager...
r10469 this.pager_button_area.append(
$('<a>').attr('role', "button")
Erik Tollerud
Collapse -> Close in button description as suggested by @fperez
r10474 .attr('title',"Close the pager")
Erik Tollerud
Added clickable icon to collapse pager...
r10469 .addClass('ui-button')
.click(function(){that.collapse()})
.attr('style','position: absolute; right: 5px;')
.append(
$('<span>').addClass("ui-icon ui-icon-close")
)
)
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 };
Brian E. Granger
Refactoring pager into its own class.
r4357 Pager.prototype.style = function () {
Brian E. Granger
Left panel is now working.
r4363 this.pager_splitter_element.addClass('border-box-sizing ui-widget ui-state-default');
MinRK
pager styling...
r10914 this.pager_element.addClass('border-box-sizing');
this.pager_element.find(".container").addClass('border-box-sizing');
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 this.pager_splitter_element.attr('title', 'Click to Show/Hide pager area, drag to Resize');
Brian E. Granger
Refactoring pager into its own class.
r4357 };
Pager.prototype.bind_events = function () {
var that = this;
Brian E. Granger
Pager is working again.
r4361
Matthias BUSSONNIER
pep 8 and js...
r6739 this.pager_element.bind('collapse_pager', function (event, extrap) {
Mikhail Korobov
Some bugs in js (mostly scoping bugs) are fixed
r8839 var time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 that.pager_element.hide(time);
Brian E. Granger
Pager is working again.
r4361 });
Matthias BUSSONNIER
pep 8 and js...
r6739 this.pager_element.bind('expand_pager', function (event, extrap) {
Mikhail Korobov
Some bugs in js (mostly scoping bugs) are fixed
r8839 var time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 that.pager_element.show(time);
Brian E. Granger
Refactoring pager into its own class.
r4357 });
Brian E. Granger
Left panel is now working.
r4363 this.pager_splitter_element.hover(
Brian E. Granger
Refactoring pager into its own class.
r4357 function () {
Brian E. Granger
Left panel is now working.
r4363 that.pager_splitter_element.addClass('ui-state-hover');
Brian E. Granger
Refactoring pager into its own class.
r4357 },
function () {
Brian E. Granger
Left panel is now working.
r4363 that.pager_splitter_element.removeClass('ui-state-hover');
Brian E. Granger
Refactoring pager into its own class.
r4357 }
);
Brian E. Granger
Pager is working again.
r4361
Brian E. Granger
Left panel is now working.
r4363 this.pager_splitter_element.click(function () {
Brian E. Granger
Pager is working again.
r4361 that.toggle();
});
Brian E. Granger
Left panel is now working.
r4363
Brian Granger
Major refactoring of the Notebook, Kernel and CodeCell JavaScript....
r7168 $([IPython.events]).on('open_with_text.Pager', function (event, data) {
if (data.text.trim() !== '') {
that.clear();
that.expand();
that.append_text(data.text);
};
});
Brian E. Granger
Refactoring pager into its own class.
r4357 };
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 Pager.prototype.collapse = function (extrap) {
Brian E. Granger
Pager is working again.
r4361 if (this.expanded === true) {
this.expanded = false;
Matthias BUSSONNIER
pep 8 and js...
r6739 this.pager_element.add($('div#notebook')).trigger('collapse_pager', extrap);
Brian E. Granger
Pager is working again.
r4361 };
Brian E. Granger
Refactoring pager into its own class.
r4357 };
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 Pager.prototype.expand = function (extrap) {
Brian E. Granger
Pager is working again.
r4361 if (this.expanded !== true) {
this.expanded = true;
Matthias BUSSONNIER
pep 8 and js...
r6739 this.pager_element.add($('div#notebook')).trigger('expand_pager', extrap);
Brian E. Granger
Pager is working again.
r4361 };
};
Pager.prototype.toggle = function () {
if (this.expanded === true) {
this.collapse();
} else {
this.expand();
};
Brian E. Granger
Refactoring pager into its own class.
r4357 };
Pager.prototype.clear = function (text) {
MinRK
pager styling...
r10914 this.pager_element.find(".container").empty();
Brian E. Granger
Refactoring pager into its own class.
r4357 };
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 Pager.prototype.detach = function(){
MinRK
fix Pager.detach...
r11542 var w = window.open("","_blank");
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 $(w.document.head)
.append(
$('<link>')
.attr('rel',"stylesheet")
.attr('href',"/static/css/notebook.css")
.attr('type',"text/css")
Bussonnier Matthias
change detach icon and tab title
r8449 )
.append(
$('<title>').text("IPython Pager")
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 );
MinRK
fix Pager.detach...
r11542 var pager_body = $(w.document.body);
pager_body.css('overflow','scroll');
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265
MinRK
fix Pager.detach...
r11542 pager_body.append(this.pager_element.clone().children());
Matthias BUSSONNIER
This create the ability to detach the pager...
r8265 w.document.close();
this.collapse();
}
Brian E. Granger
Refactoring pager into its own class.
r4357
Pager.prototype.append_text = function (text) {
MinRK
pager styling...
r10914 this.pager_element.find(".container").append($('<pre/>').html(utils.fixCarriageReturn(utils.fixConsole(text))));
Matthias BUSSONNIER
Make pager resizable, and remember size......
r6723 };
Brian E. Granger
Refactoring pager into its own class.
r4357
IPython.Pager = Pager;
return IPython;
}(IPython));