##// END OF EJS Templates
Document more function....
Matthias BUSSONNIER -
Show More
@@ -18,8 +18,11 b' var IPython = (function (IPython) {'
18 var key = IPython.utils.keycodes;
18 var key = IPython.utils.keycodes;
19
19
20 /**
20 /**
21 * Construct a new TextCell, codemirror mode is by default 'htmlmixed', and cell type is 'text'
22 * cell start as not redered.
23 *
21 * @class TextCell
24 * @class TextCell
22 * @constructs TextCell
25 * @constructor TextCell
23 */
26 */
24 var TextCell = function () {
27 var TextCell = function () {
25 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
28 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
@@ -30,7 +33,8 b' var IPython = (function (IPython) {'
30
33
31 TextCell.prototype = new IPython.Cell();
34 TextCell.prototype = new IPython.Cell();
32
35
33 /** create the DOM element of the TextCell
36 /**
37 * Create the DOM element of the TextCell
34 * @method create_element
38 * @method create_element
35 * @private
39 * @private
36 */
40 */
@@ -56,7 +60,8 b' var IPython = (function (IPython) {'
56 };
60 };
57
61
58
62
59 /** bind the DOM evet to cell actions
63 /**
64 * Bind the DOM evet to cell actions
60 * Need to be called after TextCell.create_element
65 * Need to be called after TextCell.create_element
61 * @private
66 * @private
62 * @method bind_event
67 * @method bind_event
@@ -77,13 +82,16 b' var IPython = (function (IPython) {'
77 });
82 });
78 };
83 };
79
84
80 /** This method gets called in CodeMirror's onKeyDown/onKeyPress
85 /**
86 * This method gets called in CodeMirror's onKeyDown/onKeyPress
81 * handlers and is used to provide custom key handling.
87 * handlers and is used to provide custom key handling.
82 *
88 *
89 * Subclass should override this method to have custom handeling
90 *
83 * @method handle_codemirror_keyevent
91 * @method handle_codemirror_keyevent
84 * @param {CodeMirror } editor - The codemirror instance bound to the cell
92 * @param {CodeMirror} editor - The codemirror instance bound to the cell
85 * @param {event} event -
93 * @param {event} event -
86 * @return {Boolean} <tt>true</tt> if CodeMirror should ignore the event, `false` Otherwise
94 * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise
87 */
95 */
88 TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {
96 TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {
89
97
@@ -95,7 +103,7 b' var IPython = (function (IPython) {'
95 };
103 };
96
104
97 /**
105 /**
98 * Select the current cell
106 * Select the current cell and trigger 'focus'
99 * @method select
107 * @method select
100 */
108 */
101 TextCell.prototype.select = function () {
109 TextCell.prototype.select = function () {
@@ -104,7 +112,8 b' var IPython = (function (IPython) {'
104 output.trigger('focus');
112 output.trigger('focus');
105 };
113 };
106
114
107 /** unselect the current cell
115 /**
116 * unselect the current cell and `render` it
108 * @method unselect
117 * @method unselect
109 */
118 */
110 TextCell.prototype.unselect = function() {
119 TextCell.prototype.unselect = function() {
@@ -113,7 +122,9 b' var IPython = (function (IPython) {'
113 IPython.Cell.prototype.unselect.apply(this);
122 IPython.Cell.prototype.unselect.apply(this);
114 };
123 };
115
124
116 /** put the current cell in edition mode
125 /**
126 *
127 * put the current cell in edition mode
117 * @method edit
128 * @method edit
118 */
129 */
119 TextCell.prototype.edit = function () {
130 TextCell.prototype.edit = function () {
@@ -137,7 +148,8 b' var IPython = (function (IPython) {'
137 };
148 };
138
149
139
150
140 /** Subclasses must define render.
151 /**
152 * Empty, Subclasses must define render.
141 * @method render
153 * @method render
142 */
154 */
143 TextCell.prototype.render = function () {};
155 TextCell.prototype.render = function () {};
@@ -211,8 +223,10 b' var IPython = (function (IPython) {'
211 }
223 }
212 };
224 };
213
225
214 /** Create Text cell from JSON
226 /**
227 * Create Text cell from JSON
215 * @param {json} data - JSON serialized text-cell
228 * @param {json} data - JSON serialized text-cell
229 * @method fromJSON
216 */
230 */
217 TextCell.prototype.fromJSON = function (data) {
231 TextCell.prototype.fromJSON = function (data) {
218 IPython.Cell.prototype.fromJSON.apply(this, arguments);
232 IPython.Cell.prototype.fromJSON.apply(this, arguments);
@@ -229,7 +243,9 b' var IPython = (function (IPython) {'
229 }
243 }
230 };
244 };
231
245
232
246 /** Generate JSON from cell
247 * @return {object} cell data serialised to json
248 */
233 TextCell.prototype.toJSON = function () {
249 TextCell.prototype.toJSON = function () {
234 var data = IPython.Cell.prototype.toJSON.apply(this);
250 var data = IPython.Cell.prototype.toJSON.apply(this);
235 data.cell_type = this.cell_type;
251 data.cell_type = this.cell_type;
@@ -239,7 +255,7 b' var IPython = (function (IPython) {'
239
255
240
256
241 /**
257 /**
242 * @constructs HtmlCell
258 * @constructor HtmlCell
243 * @class HtmlCell
259 * @class HtmlCell
244 * @extends TextCell
260 * @extends TextCell
245 */
261 */
@@ -252,7 +268,9 b' var IPython = (function (IPython) {'
252
268
253 HTMLCell.prototype = new TextCell();
269 HTMLCell.prototype = new TextCell();
254
270
255
271 /**
272 * @method render
273 */
256 HTMLCell.prototype.render = function () {
274 HTMLCell.prototype.render = function () {
257 if (this.rendered === false) {
275 if (this.rendered === false) {
258 var text = this.get_text();
276 var text = this.get_text();
@@ -266,9 +284,9 b' var IPython = (function (IPython) {'
266 };
284 };
267
285
268
286
269 // MarkdownCell
287 /**
270 /** @class MarkdownCell
288 * @class MarkdownCell
271 * @constructs MarkdownCell
289 * @constructor MarkdownCell
272 * @extends HtmlCell
290 * @extends HtmlCell
273 */
291 */
274 var MarkdownCell = function () {
292 var MarkdownCell = function () {
@@ -280,7 +298,9 b' var IPython = (function (IPython) {'
280
298
281 MarkdownCell.prototype = new TextCell();
299 MarkdownCell.prototype = new TextCell();
282
300
283
301 /**
302 * @method render
303 */
284 MarkdownCell.prototype.render = function () {
304 MarkdownCell.prototype.render = function () {
285 if (this.rendered === false) {
305 if (this.rendered === false) {
286 var text = this.get_text();
306 var text = this.get_text();
@@ -319,7 +339,9 b' var IPython = (function (IPython) {'
319
339
320 // RawCell
340 // RawCell
321
341
322 /** @construct RawCell
342 /**
343 * @class RawCell
344 * @constructor RawCell
323 * @extends TextCell
345 * @extends TextCell
324 */
346 */
325 var RawCell = function () {
347 var RawCell = function () {
@@ -337,21 +359,23 b' var IPython = (function (IPython) {'
337
359
338 RawCell.prototype = new TextCell();
360 RawCell.prototype = new TextCell();
339
361
362 /**
363 * Trigger autodetection of highlight scheme for current cell
364 * @method auto_highlight
365 */
340 RawCell.prototype.auto_highlight = function () {
366 RawCell.prototype.auto_highlight = function () {
341 this._auto_highlight(IPython.config.raw_cell_highlight);
367 this._auto_highlight(IPython.config.raw_cell_highlight);
342 };
368 };
343
369
370 /** @method render **/
344 RawCell.prototype.render = function () {
371 RawCell.prototype.render = function () {
345 this.rendered = true;
372 this.rendered = true;
346 this.edit();
373 this.edit();
347 };
374 };
348
375
349
376
377 /** @method handle_codemirror_keyevent **/
350 RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {
378 RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {
351 // This method gets called in CodeMirror's onKeyDown/onKeyPress
352 // handlers and is used to provide custom key handling. Its return
353 // value is used to determine if CodeMirror should ignore the event:
354 // true = ignore, false = don't ignore.
355
379
356 var that = this;
380 var that = this;
357 if (event.which === key.UPARROW && event.type === 'keydown') {
381 if (event.which === key.UPARROW && event.type === 'keydown') {
@@ -376,14 +400,14 b' var IPython = (function (IPython) {'
376 return false;
400 return false;
377 };
401 };
378
402
379
403 /** @method select **/
380 RawCell.prototype.select = function () {
404 RawCell.prototype.select = function () {
381 IPython.Cell.prototype.select.apply(this);
405 IPython.Cell.prototype.select.apply(this);
382 this.code_mirror.refresh();
406 this.code_mirror.refresh();
383 this.code_mirror.focus();
407 this.code_mirror.focus();
384 };
408 };
385
409
386
410 /** @method at_top **/
387 RawCell.prototype.at_top = function () {
411 RawCell.prototype.at_top = function () {
388 var cursor = this.code_mirror.getCursor();
412 var cursor = this.code_mirror.getCursor();
389 if (cursor.line === 0 && cursor.ch === 0) {
413 if (cursor.line === 0 && cursor.ch === 0) {
@@ -394,6 +418,7 b' var IPython = (function (IPython) {'
394 };
418 };
395
419
396
420
421 /** @method at_bottom **/
397 RawCell.prototype.at_bottom = function () {
422 RawCell.prototype.at_bottom = function () {
398 var cursor = this.code_mirror.getCursor();
423 var cursor = this.code_mirror.getCursor();
399 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
424 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
@@ -404,20 +429,30 b' var IPython = (function (IPython) {'
404 };
429 };
405
430
406
431
407 /** @constructs HeadingCell
432 /**
433 * @class HeadingCell
434 * @extends TextCell
435 */
436
437 /**
438 * @constructor HeadingCell
408 * @extends TextCell
439 * @extends TextCell
409 */
440 */
410 var HeadingCell = function () {
441 var HeadingCell = function () {
411 this.placeholder = "Type Heading Here";
442 this.placeholder = "Type Heading Here";
412 IPython.TextCell.apply(this, arguments);
443 IPython.TextCell.apply(this, arguments);
413 this.cell_type = 'heading';
444 /**
445 * heading level of the cell, use getter and setter to access
446 * @property level
447 */
414 this.level = 1;
448 this.level = 1;
449 this.cell_type = 'heading';
415 };
450 };
416
451
417
452
418 HeadingCell.prototype = new TextCell();
453 HeadingCell.prototype = new TextCell();
419
454
420 /** from json */
455 /** @method fromJSON */
421 HeadingCell.prototype.fromJSON = function (data) {
456 HeadingCell.prototype.fromJSON = function (data) {
422 if (data.level != undefined){
457 if (data.level != undefined){
423 this.level = data.level;
458 this.level = data.level;
@@ -426,6 +461,7 b' var IPython = (function (IPython) {'
426 };
461 };
427
462
428
463
464 /** @method toJSON */
429 HeadingCell.prototype.toJSON = function () {
465 HeadingCell.prototype.toJSON = function () {
430 var data = IPython.TextCell.prototype.toJSON.apply(this);
466 var data = IPython.TextCell.prototype.toJSON.apply(this);
431 data.level = this.get_level();
467 data.level = this.get_level();
@@ -433,6 +469,10 b' var IPython = (function (IPython) {'
433 };
469 };
434
470
435
471
472 /**
473 * Change heading level of cell, and re-render
474 * @method set_level
475 */
436 HeadingCell.prototype.set_level = function (level) {
476 HeadingCell.prototype.set_level = function (level) {
437 this.level = level;
477 this.level = level;
438 if (this.rendered) {
478 if (this.rendered) {
@@ -442,6 +482,7 b' var IPython = (function (IPython) {'
442 };
482 };
443
483
444 /** The depth of header cell, based on html (h1 to h6)
484 /** The depth of header cell, based on html (h1 to h6)
485 * @method get_level
445 * @return {integer} level - for 1 to 6
486 * @return {integer} level - for 1 to 6
446 */
487 */
447 HeadingCell.prototype.get_level = function () {
488 HeadingCell.prototype.get_level = function () {
General Comments 0
You need to be logged in to leave comments. Login now