More review changes

This commit is contained in:
Jonathan Frederic 2014-07-01 12:04:27 -07:00 committed by Jonathan Frederic
parent 669db572f2
commit ee76005bc2
15 changed files with 72 additions and 57 deletions

View File

@ -90,11 +90,11 @@ define([
return modal.modal(options);
};
var edit_metadata = function (md, callback, name, keyboard_manager, notebook) {
name = name || "Cell";
var edit_metadata = function (options) {
options.name = options.name || "Cell";
var error_div = $('<div/>').css('color', 'red');
var message =
"Manually edit the JSON below to manipulate the metadata for this " + name + "." +
"Manually edit the JSON below to manipulate the metadata for this " + options.name + "." +
" We recommend putting custom metadata attributes in an appropriately named sub-structure," +
" so they don't conflict with those of others.";
@ -102,7 +102,7 @@ define([
.attr('rows', '13')
.attr('cols', '80')
.attr('name', 'metadata')
.text(JSON.stringify(md || {}, null, 2));
.text(JSON.stringify(options.md || {}, null, 2));
var dialogform = $('<div/>').attr('title', 'Edit the metadata')
.append(
@ -125,7 +125,7 @@ define([
mode: 'application/json',
});
var modal = modal({
title: "Edit " + name + " Metadata",
title: "Edit " + options.name + " Metadata",
body: dialogform,
buttons: {
OK: { class : "btn-primary",
@ -139,12 +139,14 @@ define([
error_div.text('WARNING: Could not save invalid JSON.');
return false;
}
callback(new_md);
options.callback(new_md);
}
},
Cancel: {}
}
}, keyboard_manager, notebook);
},
notebook: options.notebook,
keyboard_manager: options.keyboard_manager,
});
modal.on('shown.bs.modal', function(){ editor.refresh(); });
};
@ -155,7 +157,7 @@ define([
};
// Backwards compatability.
IPython.Dialog = dialog;
IPython.dialog = dialog;
return dialog;
});

View File

@ -242,7 +242,7 @@ define([
return !( data === undefined || data.handler === undefined );
};
return {
var keyboard = {
keycodes : keycodes,
inv_keycodes : inv_keycodes,
ShortcutManager : ShortcutManager,
@ -251,4 +251,9 @@ define([
shortcut_to_event : shortcut_to_event,
event_to_shortcut : event_to_shortcut
};
// For backwards compatability.
IPython.keyboard = keyboard;
return keyboard;
});

View File

@ -4,9 +4,6 @@
define([
'base/js/namespace',
'jquery',
'components/jquery-ui/ui/minified/jquery-ui.min',
'components/bootstrap/js/bootstrap.min',
'auth/js/loginwidget'
], function(IPython, $){
"use strict";

View File

@ -1,10 +1,7 @@
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
var ipython = ipython || {};
require(['base/js/page'], function(page) {
var page_instance = new page.Page();
page_instance.show();
ipython.page = page_instance;
});

View File

@ -551,7 +551,7 @@ define([
};
// Backwards compatability.
IPython.Utils = utils;
IPython.utils = utils;
return utils;
});

View File

@ -8,16 +8,19 @@ define([
], function(IPython, $, textcell) {
"use strict";
/**
* @constructor
* @class CellToolbar
* @param {The cell to attach the metadata UI to} cell
*/
var CellToolbar = function (cell, events, notebook) {
var CellToolbar = function (options) {
// Constructor
//
// Parameters:
// options: dictionary
// Dictionary of keyword arguments.
// events: $(Events) instance
// cell: Cell instance
// notebook: Notebook instance
CellToolbar._instances.push(this);
this.notebook = notebook;
this.events = events;
this.cell = cell;
this.notebook = options.notebook;
this.events = options.events;
this.cell = options.cell;
this.create_element();
this.rebuild();
return this;

View File

@ -129,7 +129,10 @@ define([
var input = $('<div></div>').addClass('input');
var prompt = $('<div/>').addClass('prompt input_prompt');
var inner_cell = $('<div/>').addClass('inner_cell');
this.celltoolbar = new celltoolbar.CellToolbar(this, this.events, this.notebook);
this.celltoolbar = new celltoolbar.CellToolbar({
cell: this,
events: this.events,
notebook: this.notebook});
inner_cell.append(this.celltoolbar.element);
var input_area = $('<div/>').addClass('input_area');
this.code_mirror = CodeMirror(input_area.get(0), this.cm_config);
@ -159,7 +162,11 @@ define([
var output = $('<div></div>');
cell.append(input).append(widget_area).append(output);
this.element = cell;
this.output_area = new outputarea.OutputArea(output, true, this.events, this.keyboard_manager);
this.output_area = new outputarea.OutputArea({
selector: output,
prompt_area: true,
events: this.events,
keyboard_manager: this.keyboard_manager});
this.completer = new completer.Completer(this, this.events);
};

View File

@ -6,7 +6,6 @@ require([
'jquery',
'notebook/js/notebook',
'base/js/utils',
'base/js/keyboard',
'base/js/page',
'notebook/js/layoutmanager',
'base/js/events',
@ -24,7 +23,6 @@ require([
$,
notebook,
utils,
keyboard,
page,
layoutmanager,
events,
@ -134,5 +132,4 @@ require([
IPython.keyboard_manager = keyboard_manager;
IPython.save_widget = save_widget;
IPython.config = user_config;
IPython.keyboard = keyboard;
});

View File

@ -192,7 +192,9 @@ define([
that.notebook.move_cell_down();
});
this.element.find('#edit_nb_metadata').click(function () {
that.notebook.edit_metadata();
that.notebook.edit_metadata({
notebook: that.notebook,
keyboard_manager: that.notebook.keyboard_manager});
});
// View

View File

@ -13,8 +13,6 @@ define([
'components/marked/lib/marked',
'notebook/js/mathjaxutils',
'base/js/keyboard',
'components/jquery-ui/ui/minified/jquery-ui.min',
'components/bootstrap/js/bootstrap.min',
], function (
IPython,
$,
@ -80,11 +78,6 @@ define([
});
}
// Backwards compatability.
IPython.keyboard_manager = this.keyboard_manager;
IPython.save_widget = this.save_widget;
IPython.keyboard = this.keyboard;
this.element = $(selector);
this.element.scroll();
this.element.data("notebook", this);
@ -314,9 +307,14 @@ define([
Notebook.prototype.edit_metadata = function () {
var that = this;
dialog.edit_metadata(this.metadata, function (md) {
that.metadata = md;
}, 'Notebook');
dialog.edit_metadata({
md: this.metadata,
callback: function (md) {
that.metadata = md;
},
name: 'Notebook',
notebook: this,
keyboard_manager: this.keyboard_manager});
};
// Cell indexing, retrieval, etc.

View File

@ -35,12 +35,12 @@ define([
// if timeout <= 0
// click_callback : function called if user click on notification
// could return false to prevent the notification to be dismissed
NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, opts) {
opts = opts || {};
NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, options) {
options = options || {};
var callback = click_callback || function() {return false;};
var that = this;
this.inner.attr('class', opts.icon);
this.inner.attr('title', opts.title);
this.inner.attr('class', options.icon);
this.inner.attr('title', options.title);
this.inner.text(msg);
this.element.fadeIn(100);
if (this.timeout !== null) {

View File

@ -17,20 +17,20 @@ define([
* @constructor
*/
var OutputArea = function (selector, prompt_area, events, keyboard_manager) {
this.selector = selector;
this.events = events;
this.keyboard_manager = keyboard_manager;
this.wrapper = $(selector);
var OutputArea = function (options) {
this.selector = options.selector;
this.events = options.events;
this.keyboard_manager = options.keyboard_manager;
this.wrapper = $(options.selector);
this.outputs = [];
this.collapsed = false;
this.scrolled = false;
this.trusted = true;
this.clear_queued = null;
if (prompt_area === undefined) {
if (options.prompt_area === undefined) {
this.prompt_area = true;
} else {
this.prompt_area = prompt_area;
this.prompt_area = options.prompt_area;
}
this.create_elements();
this.style();

View File

@ -7,7 +7,7 @@ define([
'base/js/utils',
'base/js/dialog',
'base/js/keyboard',
'dateformat/date.format',
'dateformat',
], function(IPython, $, utils, dialog, keyboard) {
"use strict";

View File

@ -76,7 +76,10 @@ define([
var prompt = $('<div/>').addClass('prompt input_prompt');
cell.append(prompt);
var inner_cell = $('<div/>').addClass('inner_cell');
this.celltoolbar = new celltoolbar.CellToolbar(this, this.events, this.notebook);
this.celltoolbar = new celltoolbar.CellToolbar({
cell: this,
events: this.events,
notebook: this.notebook});
inner_cell.append(this.celltoolbar.element);
var input_area = $('<div/>').addClass('input_area');
this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config);
@ -451,11 +454,11 @@ define([
IPython.RawCell = RawCell;
IPython.HeadingCell = HeadingCell;
var Cells = {
var textcell = {
'TextCell': TextCell,
'MarkdownCell': MarkdownCell,
'RawCell': RawCell,
'HeadingCell': HeadingCell,
};
return Cells;
return textcell;
});

View File

@ -24,6 +24,7 @@
backbone : 'components/backbone/backbone-min',
jquery: 'components/jquery/jquery.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
dateformat: 'dateformat/date.format',
},
shim: {
underscore: {
@ -35,6 +36,9 @@
},
bootstraptour: {
exports: "Tour"
},
dateformat: {
exports: "dateFormat"
}
}
});