##// END OF EJS Templates
Address review comments
Jonathan Frederic -
Show More
@@ -68,7 +68,7 define([
68 this.default_cell_type = this.config.default_cell_type || 'code';
68 this.default_cell_type = this.config.default_cell_type || 'code';
69
69
70 // Create default scroll manager.
70 // Create default scroll manager.
71 this.scrollmanager = new scrollmanager.SlideScrollManager(this);
71 this.scroll_manager = new scrollmanager.SlideScrollManager(this);
72
72
73 // default_kernel_name is a temporary measure while we implement proper
73 // default_kernel_name is a temporary measure while we implement proper
74 // kernel selection and delayed start. Do not rely on it.
74 // kernel selection and delayed start. Do not rely on it.
@@ -3,10 +3,10
3 define(['jquery'], function($){
3 define(['jquery'], function($){
4 "use strict";
4 "use strict";
5
5
6 var ScrollManager = function(notebook) {
6 var ScrollManager = function(notebook, options) {
7 // Public constructor.
7 // Public constructor.
8 this.notebook = notebook;
8 this.notebook = notebook;
9 this.animation_speed = 250; //ms
9 this.animation_speed = options.animation_speed || 250; //ms
10 };
10 };
11
11
12 ScrollManager.prototype.scroll = function (delta) {
12 ScrollManager.prototype.scroll = function (delta) {
@@ -20,13 +20,18 define(['jquery'], function($){
20 return false;
20 return false;
21 };
21 };
22
22
23 ScrollManager.prototype.scroll_to = function(destination) {
23 ScrollManager.prototype.scroll_to = function(selector) {
24 // Scroll to an element in the notebook.
24 // Scroll to an element in the notebook.
25 $('#notebook').animate({'scrollTop': $(destination).offset().top + $('#notebook').scrollTop() - $('#notebook').offset().top}, this.animation_speed);
25 $('#notebook').animate({'scrollTop': $(selector).offset().top + $('#notebook').scrollTop() - $('#notebook').offset().top}, this.animation_speed);
26 };
26 };
27
27
28 ScrollManager.prototype.scroll_some = function(pages) {
28 ScrollManager.prototype.scroll_some = function(pages) {
29 // Scroll up or down a given number of pages.
29 // Scroll up or down a given number of pages.
30 //
31 // Parameters
32 // ----------
33 // pages: integer
34 // number of pages to scroll the document, may be positive or negative.
30 $('#notebook').animate({'scrollTop': $('#notebook').scrollTop() + pages * $('#notebook').height()}, this.animation_speed);
35 $('#notebook').animate({'scrollTop': $('#notebook').scrollTop() + pages * $('#notebook').height()}, this.animation_speed);
31 };
36 };
32
37
@@ -57,13 +62,22 define(['jquery'], function($){
57 };
62 };
58
63
59
64
60 var TargetScrollManager = function(notebook) {
65 var TargetScrollManager = function(notebook, options) {
61 // Public constructor.
66 // Public constructor.
62 ScrollManager.apply(this, [notebook]);
67 ScrollManager.apply(this, [notebook, options]);
63 };
68 };
64 TargetScrollManager.prototype = new ScrollManager();
69 TargetScrollManager.prototype = new ScrollManager();
65
70
66 TargetScrollManager.prototype.is_target = function (index) {
71 TargetScrollManager.prototype.is_target = function (index) {
72 // Check if a cell should be a scroll stop.
73 //
74 // Returns `true` if the cell is a cell that the scroll manager
75 // should scroll to. Otherwise, false is returned.
76 //
77 // Parameters
78 // ----------
79 // index: integer
80 // index of the cell to test.
67 return false;
81 return false;
68 };
82 };
69
83
@@ -93,9 +107,9 define(['jquery'], function($){
93 };
107 };
94
108
95
109
96 var SlideScrollManager = function(notebook) {
110 var SlideScrollManager = function(notebook, options) {
97 // Public constructor.
111 // Public constructor.
98 TargetScrollManager.apply(this, [notebook]);
112 TargetScrollManager.apply(this, [notebook, options]);
99 };
113 };
100 SlideScrollManager.prototype = new TargetScrollManager();
114 SlideScrollManager.prototype = new TargetScrollManager();
101
115
@@ -103,14 +117,15 define(['jquery'], function($){
103 var cell = this.notebook.get_cell(index);
117 var cell = this.notebook.get_cell(index);
104 return cell.metadata && cell.metadata.slideshow &&
118 return cell.metadata && cell.metadata.slideshow &&
105 cell.metadata.slideshow.slide_type &&
119 cell.metadata.slideshow.slide_type &&
106 cell.metadata.slideshow.slide_type === "slide";
120 (cell.metadata.slideshow.slide_type === "slide" ||
121 cell.metadata.slideshow.slide_type === "subslide");
107 };
122 };
108
123
109
124
110 var HeadingScrollManager = function(notebook, heading_level) {
125 var HeadingScrollManager = function(notebook, options) {
111 // Public constructor.
126 // Public constructor.
112 TargetScrollManager.apply(this, [notebook]);
127 TargetScrollManager.apply(this, [notebook, options]);
113 this._level = heading_level;
128 this._level = options.heading_level || 1;
114 };
129 };
115 HeadingScrollManager.prototype = new TargetScrollManager();
130 HeadingScrollManager.prototype = new TargetScrollManager();
116
131
General Comments 0
You need to be logged in to leave comments. Login now