##// END OF EJS Templates
bootstrap dialogs
MinRK -
Show More
@@ -30,9 +30,9 b' IPython.mathjaxutils = (function (IPython) {'
30 MathJax.Hub.Configured();
30 MathJax.Hub.Configured();
31 } else if (window.mathjax_url != "") {
31 } else if (window.mathjax_url != "") {
32 // Don't have MathJax, but should. Show dialog.
32 // Don't have MathJax, but should. Show dialog.
33 var dialog = $('<div></div>')
33 var message = $('<div/>')
34 .append(
34 .append(
35 $("<p></p>").addClass('dialog').html(
35 $("<p/></p>").addClass('dialog').html(
36 "Math/LaTeX rendering will be disabled."
36 "Math/LaTeX rendering will be disabled."
37 )
37 )
38 ).append(
38 ).append(
@@ -68,11 +68,14 b' IPython.mathjaxutils = (function (IPython) {'
68 $("<p></p>").addClass('dialog').html(
68 $("<p></p>").addClass('dialog').html(
69 "which will prevent this dialog from appearing."
69 "which will prevent this dialog from appearing."
70 )
70 )
71 ).dialog({
71 )
72 title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
72 IPython.dialog.modal({
73 width: "70%",
73 title : "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
74 modal: true,
74 body : message,
75 })
75 buttons : {
76 OK : {class: "btn-danger"}
77 }
78 });
76 } else {
79 } else {
77 // No MathJax, but none expected. No dialog.
80 // No MathJax, but none expected. No dialog.
78 };
81 };
@@ -1341,21 +1341,18 b' var IPython = (function (IPython) {'
1341 */
1341 */
1342 Notebook.prototype.restart_kernel = function () {
1342 Notebook.prototype.restart_kernel = function () {
1343 var that = this;
1343 var that = this;
1344 var dialog = $('<div/>');
1344 IPython.dialog.modal({
1345 dialog.html('Do you want to restart the current kernel? You will lose all variables defined in it.');
1345 title : "Restart kernel or continue running?",
1346 $(document.body).append(dialog);
1346 body : $("<p/>").html(
1347 dialog.dialog({
1347 'Do you want to restart the current kernel? You will lose all variables defined in it.'
1348 resizable: false,
1348 ),
1349 modal: true,
1350 title: "Restart kernel or continue running?",
1351 closeText: '',
1352 buttons : {
1349 buttons : {
1353 "Restart": function () {
1350 "Continue running" : {},
1354 that.kernel.restart();
1351 "Restart" : {
1355 $(this).dialog('close');
1352 "class" : "btn-danger",
1356 },
1353 "click" : function() {
1357 "Continue running": function () {
1354 that.kernel.restart();
1358 $(this).dialog('close');
1355 }
1359 }
1356 }
1360 }
1357 }
1361 });
1358 });
@@ -1526,24 +1523,16 b' var IPython = (function (IPython) {'
1526 };
1523 };
1527 };
1524 };
1528 if (data.worksheets.length > 1) {
1525 if (data.worksheets.length > 1) {
1529 var dialog = $('<div/>');
1526 IPython.dialog.modal({
1530 dialog.html("This notebook has " + data.worksheets.length + " worksheets, " +
1527 title : "Multiple worksheets",
1531 "but this version of IPython can only handle the first. " +
1528 body : "This notebook has " + data.worksheets.length + " worksheets, " +
1532 "If you save this notebook, worksheets after the first will be lost."
1529 "but this version of IPython can only handle the first. " +
1533 );
1530 "If you save this notebook, worksheets after the first will be lost.",
1534 this.element.append(dialog);
1535 dialog.dialog({
1536 resizable: false,
1537 modal: true,
1538 title: "Multiple worksheets",
1539 closeText: "",
1540 close: function(event, ui) {$(this).dialog('destroy').remove();},
1541 buttons : {
1531 buttons : {
1542 "OK": function () {
1532 OK : {
1543 $(this).dialog('close');
1533 class : "btn-danger"
1544 }
1534 }
1545 },
1535 }
1546 width: 400
1547 });
1536 });
1548 }
1537 }
1549 };
1538 };
@@ -1722,27 +1711,20 b' var IPython = (function (IPython) {'
1722 this.select(0);
1711 this.select(0);
1723 this.scroll_to_top();
1712 this.scroll_to_top();
1724 if (data.orig_nbformat !== undefined && data.nbformat !== data.orig_nbformat) {
1713 if (data.orig_nbformat !== undefined && data.nbformat !== data.orig_nbformat) {
1725 msg = "This notebook has been converted from an older " +
1714 var msg = "This notebook has been converted from an older " +
1726 "notebook format (v"+data.orig_nbformat+") to the current notebook " +
1715 "notebook format (v"+data.orig_nbformat+") to the current notebook " +
1727 "format (v"+data.nbformat+"). The next time you save this notebook, the " +
1716 "format (v"+data.nbformat+"). The next time you save this notebook, the " +
1728 "newer notebook format will be used and older verions of IPython " +
1717 "newer notebook format will be used and older versions of IPython " +
1729 "may not be able to read it. To keep the older version, close the " +
1718 "may not be able to read it. To keep the older version, close the " +
1730 "notebook without saving it.";
1719 "notebook without saving it.";
1731 var dialog = $('<div/>');
1720 IPython.dialog.modal({
1732 dialog.html(msg);
1721 title : "Notebook converted",
1733 this.element.append(dialog);
1722 body : msg,
1734 dialog.dialog({
1735 resizable: false,
1736 modal: true,
1737 title: "Notebook converted",
1738 closeText: "",
1739 close: function(event, ui) {$(this).dialog('destroy').remove();},
1740 buttons : {
1723 buttons : {
1741 "OK": function () {
1724 OK : {
1742 $(this).dialog('close');
1725 class : "btn-primary"
1743 }
1726 }
1744 },
1727 }
1745 width: 400
1746 });
1728 });
1747 } else if (data.orig_nbformat_minor !== undefined && data.nbformat_minor !== data.orig_nbformat_minor) {
1729 } else if (data.orig_nbformat_minor !== undefined && data.nbformat_minor !== data.orig_nbformat_minor) {
1748 var that = this;
1730 var that = this;
@@ -1752,21 +1734,14 b' var IPython = (function (IPython) {'
1752 this_vs + ". You can still work with this notebook, but some features " +
1734 this_vs + ". You can still work with this notebook, but some features " +
1753 "introduced in later notebook versions may not be available."
1735 "introduced in later notebook versions may not be available."
1754
1736
1755 var dialog = $('<div/>');
1737 IPython.dialog.modal({
1756 dialog.html(msg);
1738 title : "Newer Notebook",
1757 this.element.append(dialog);
1739 body : msg,
1758 dialog.dialog({
1759 resizable: false,
1760 modal: true,
1761 title: "Newer Notebook",
1762 closeText: "",
1763 close: function(event, ui) {$(this).dialog('destroy').remove();},
1764 buttons : {
1740 buttons : {
1765 "OK": function () {
1741 OK : {
1766 $(this).dialog('close');
1742 class : "btn-danger"
1767 }
1743 }
1768 },
1744 }
1769 width: 400
1770 });
1745 });
1771
1746
1772 }
1747 }
@@ -1795,21 +1770,13 b' var IPython = (function (IPython) {'
1795 "this notebook is in a newer format than is supported by this " +
1770 "this notebook is in a newer format than is supported by this " +
1796 "version of IPython. This version can load notebook formats " +
1771 "version of IPython. This version can load notebook formats " +
1797 "v"+this.nbformat+" or earlier.";
1772 "v"+this.nbformat+" or earlier.";
1798 var dialog = $('<div/>');
1773
1799 dialog.html(msg);
1774 IPython.dialog.modal({
1800 this.element.append(dialog);
1801 dialog.dialog({
1802 resizable: false,
1803 modal: true,
1804 title: "Error loading notebook",
1775 title: "Error loading notebook",
1805 closeText: "",
1776 body : msg,
1806 close: function(event, ui) {$(this).dialog('destroy').remove();},
1807 buttons : {
1777 buttons : {
1808 "OK": function () {
1778 "OK": {}
1809 $(this).dialog('close');
1779 }
1810 }
1811 },
1812 width: 400
1813 });
1780 });
1814 }
1781 }
1815 }
1782 }
@@ -1917,7 +1884,7 b' var IPython = (function (IPython) {'
1917 console.log("restore dialog, but no checkpoint to restore to!");
1884 console.log("restore dialog, but no checkpoint to restore to!");
1918 return;
1885 return;
1919 }
1886 }
1920 var dialog = $('<div/>').append(
1887 var body = $('<div/>').append(
1921 $('<p/>').addClass("p-space").text(
1888 $('<p/>').addClass("p-space").text(
1922 "Are you sure you want to revert the notebook to " +
1889 "Are you sure you want to revert the notebook to " +
1923 "the latest checkpoint?"
1890 "the latest checkpoint?"
@@ -1934,23 +1901,18 b' var IPython = (function (IPython) {'
1934 ).css("text-align", "center")
1901 ).css("text-align", "center")
1935 );
1902 );
1936
1903
1937 $(document.body).append(dialog);
1904 IPython.dialog.modal({
1938
1905 title : "Revert notebook to checkpoint",
1939 dialog.dialog({
1906 body : body,
1940 resizable: false,
1941 modal: true,
1942 title: "Revert notebook to checkpoint",
1943 closeText: '',
1944 buttons : {
1907 buttons : {
1945 "Revert": function () {
1908 Revert : {
1946 that.restore_checkpoint(checkpoint.checkpoint_id);
1909 class : "btn-danger",
1947 $(this).dialog('close');
1910 click : function () {
1911 that.restore_checkpoint(checkpoint.checkpoint_id);
1912 }
1948 },
1913 },
1949 "Cancel": function () {
1914 Cancel : {}
1950 $(this).dialog('close');
1951 }
1915 }
1952 },
1953 width: 400
1954 });
1916 });
1955 }
1917 }
1956
1918
@@ -92,28 +92,24 b' var IPython = (function (IPython) {'
92 });
92 });
93
93
94 $([IPython.events]).on('status_dead.Kernel',function () {
94 $([IPython.events]).on('status_dead.Kernel',function () {
95 var dialog = $('<div/>');
95 var msg = 'The kernel has died, and the automatic restart has failed.' +
96 dialog.html('The kernel has died, and the automatic restart has failed.' +
97 ' It is possible the kernel cannot be restarted.' +
96 ' It is possible the kernel cannot be restarted.' +
98 ' If you are not able to restart the kernel, you will still be able to save' +
97 ' If you are not able to restart the kernel, you will still be able to save' +
99 ' the notebook, but running code will no longer work until the notebook' +
98 ' the notebook, but running code will no longer work until the notebook' +
100 ' is reopened.'
99 ' is reopened.';
101 );
100
102 $(document.body).append(dialog);
101 IPython.dialog.modal({
103 dialog.dialog({
104 resizable: false,
105 modal: true,
106 title: "Dead kernel",
102 title: "Dead kernel",
107 close: function(event, ui) {$(this).dialog('destroy').remove();},
103 body : msg,
108 buttons : {
104 buttons : {
109 "Manual Restart": function () {
105 "Manual Restart": {
110 $([IPython.events]).trigger('status_restarting.Kernel');
106 class: "btn-danger",
111 IPython.notebook.start_kernel();
107 click: function () {
112 $(this).dialog('close');
108 $([IPython.events]).trigger('status_restarting.Kernel');
109 IPython.notebook.start_kernel();
110 }
113 },
111 },
114 "Don't restart": function () {
112 "Don't restart": {}
115 $(this).dialog('close');
116 }
117 }
113 }
118 });
114 });
119 });
115 });
@@ -134,25 +130,18 b' var IPython = (function (IPython) {'
134 msg = "A WebSocket connection to could not be established." +
130 msg = "A WebSocket connection to could not be established." +
135 " You will NOT be able to run code. Check your" +
131 " You will NOT be able to run code. Check your" +
136 " network connection or notebook server configuration.";
132 " network connection or notebook server configuration.";
137 var dialog = $('<div/>');
133 IPython.dialog.modal({
138 dialog.html(msg);
139 $(document.body).append(dialog);
140 dialog.dialog({
141 resizable: false,
142 modal: true,
143 title: "WebSocket connection failed",
134 title: "WebSocket connection failed",
144 closeText: "",
135 body: msg,
145 close: function(event, ui) {$(this).dialog('destroy').remove();},
146 buttons : {
136 buttons : {
147 "OK": function () {
137 "OK": {},
148 $(this).dialog('close');
138 "Reconnect": {
149 },
139 click: function () {
150 "Reconnect": function () {
140 knw.set_message('Reconnecting WebSockets', 1000);
151 knw.set_message('Reconnecting WebSockets', 1000);
141 setTimeout(function () {
152 setTimeout(function () {
142 kernel.start_channels();
153 kernel.start_channels();
143 }, 5000);
154 }, 5000);
144 }
155 $(this).dialog('close');
156 }
145 }
157 }
146 }
158 });
147 });
@@ -69,28 +69,23 b' var IPython = (function (IPython) {'
69
69
70 SaveWidget.prototype.rename_notebook = function () {
70 SaveWidget.prototype.rename_notebook = function () {
71 var that = this;
71 var that = this;
72 var dialog = $('<div/>');
72 var dialog = $('<div/>').append($("<p/>").addClass("rename-message")
73 dialog.append(
73 .html('Enter a new notebook name:'));
74 $('<p/>').html('Enter a new notebook name:')
75 .css({'margin-bottom': '10px'})
76 );
77 dialog.append(
74 dialog.append(
78 $('<input/>').attr('type','text').attr('size','25')
75 $('<input/>').attr('type','text').attr('size','25')
79 .addClass('ui-widget ui-widget-content')
76 .val(IPython.notebook.get_notebook_name())
80 .attr('value',IPython.notebook.get_notebook_name())
81 );
77 );
82 // $(document.body).append(dialog);
78 IPython.dialog.modal({
83 dialog.dialog({
84 resizable: false,
85 modal: true,
86 title: "Rename Notebook",
79 title: "Rename Notebook",
87 closeText: "",
80 body: dialog,
88 close: function(event, ui) {$(this).dialog('destroy').remove();},
89 buttons : {
81 buttons : {
90 "OK": function () {
82 "Cancel": {},
91 var new_name = $(this).find('input').attr('value');
83 "OK": {
84 class: "btn-primary",
85 click: function () {
86 var new_name = $(this).find('input').val();
92 if (!IPython.notebook.test_notebook_name(new_name)) {
87 if (!IPython.notebook.test_notebook_name(new_name)) {
93 $(this).find('h3').html(
88 $(this).find('.rename-message').html(
94 "Invalid notebook name. Notebook names must "+
89 "Invalid notebook name. Notebook names must "+
95 "have 1 or more characters and can contain any characters " +
90 "have 1 or more characters and can contain any characters " +
96 "except :/\\. Please enter a new notebook name:"
91 "except :/\\. Please enter a new notebook name:"
@@ -98,21 +93,18 b' var IPython = (function (IPython) {'
98 } else {
93 } else {
99 IPython.notebook.set_notebook_name(new_name);
94 IPython.notebook.set_notebook_name(new_name);
100 IPython.notebook.save_notebook();
95 IPython.notebook.save_notebook();
101 $(this).dialog('close');
102 }
96 }
97 }}
103 },
98 },
104 "Cancel": function () {
105 $(this).dialog('close');
106 }
107 },
108 open : function (event, ui) {
99 open : function (event, ui) {
109 var that = $(this);
100 var that = $(this);
110 // Upon ENTER, click the OK button.
101 // Upon ENTER, click the OK button.
111 that.find('input[type="text"]').keydown(function (event, ui) {
102 that.find('input[type="text"]').keydown(function (event, ui) {
112 if (event.which === utils.keycodes.ENTER) {
103 if (event.which === utils.keycodes.ENTER) {
113 that.parent().find('button').first().click();
104 that.find('.btn-primary').first().click();
114 }
105 }
115 });
106 });
107 that.find('input[type="text"]').focus();
116 }
108 }
117 });
109 });
118 }
110 }
@@ -220,6 +220,7 b' class="notebook_app"'
220
220
221 <script src="{{ static_url("base/js/events.js") }}" type="text/javascript" charset="utf-8"></script>
221 <script src="{{ static_url("base/js/events.js") }}" type="text/javascript" charset="utf-8"></script>
222 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
222 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
223 <script src="{{ static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
223 <script src="{{ static_url("notebook/js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
224 <script src="{{ static_url("notebook/js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
224 <script src="{{ static_url("notebook/js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
225 <script src="{{ static_url("notebook/js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
225 <script src="{{ static_url("notebook/js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
226 <script src="{{ static_url("notebook/js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
General Comments 0
You need to be logged in to leave comments. Login now