// Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. define(['jquery', 'codemirror/lib/codemirror', 'bootstrap', 'base/js/i18n'], function($, CodeMirror, bs, i18n) { "use strict"; /** * A wrapper around bootstrap modal for easier use * Pass it an option dictionary with the following properties: * * - body : or , main content of the dialog * if pass a it will be wrapped in a p tag and * html element escaped, unless you specify sanitize=false * option. * - title : Dialog title, default to empty string. * - buttons : dict of btn_options who keys are button label. * see btn_options below for description * - open : callback to trigger on dialog open. * - destroy: * - notebook : notebook instance * - keyboard_manager: keyboard manager instance. * * Unlike bootstrap modals, the backdrop options is set by default * to 'static'. * * The rest of the options are passed as is to bootstrap modals. * * btn_options: dict with the following property: * * - click : callback to trigger on click * - class : css classes to add to button. * * * **/ var modal = function (options) { var modal = $("
") .addClass("modal") .addClass("fade") .attr("role", "dialog"); var dialog = $("
") .addClass("modal-dialog") .appendTo(modal); var dialog_content = $("
") .addClass("modal-content") .appendTo(dialog); if(typeof(options.body) === 'string' && options.sanitize !== false){ options.body = $("

").text(options.body); } dialog_content.append( $("

") .addClass("modal-header") .mousedown(function() { $(".modal").draggable({handle: '.modal-header'}); }) .append($("