From 22fccff4435849a08d62eeaa590a5d256bca8569 Mon Sep 17 00:00:00 2001 From: Julien Rebetez Date: Thu, 22 Oct 2015 10:02:28 +0200 Subject: [PATCH] Add a new insert-image action and corresponding dialog to insert inline images from menu. --- notebook/static/base/js/dialog.js | 51 ++++++++++++++++++++++++- notebook/static/notebook/js/actions.js | 7 ++++ notebook/static/notebook/js/menubar.js | 1 + notebook/static/notebook/js/notebook.js | 40 +++++++++++++++++++ notebook/static/notebook/js/textcell.js | 19 +++++++++ notebook/templates/notebook.html | 2 + 6 files changed, 119 insertions(+), 1 deletion(-) diff --git a/notebook/static/base/js/dialog.js b/notebook/static/base/js/dialog.js index 02c113597..8492c431c 100644 --- a/notebook/static/base/js/dialog.js +++ b/notebook/static/base/js/dialog.js @@ -80,6 +80,9 @@ define(function(require) { .addClass("btn btn-default btn-sm") .attr("data-dismiss", "modal") .text(label); + if (btn_opts.id) { + button.attr('id', btn_opts.id); + } if (btn_opts.click) { button.click($.proxy(btn_opts.click, dialog_content)); } @@ -269,12 +272,58 @@ define(function(require) { modal_obj.on('shown.bs.modal', function(){ editor.refresh(); }); }; + var insert_image = function (options) { + var message = + "Select a file to insert."; + var file_input = $('') + .attr('type', 'file') + .attr('accept', 'image/*') + .attr('name', 'file') + .on('change', function(file) { + var $btn = $(modal_obj).find('#btn_ok'); + if (this.files.length > 0) { + $btn.removeClass('disabled'); + } else { + $btn.addClass('disabled'); + } + }); + var dialogform = $('
').attr('title', 'Edit attachments') + .append( + $('
').append( + $('
').append( + $('