Merge pull request #744 from captainsafia/fix-dialog-button-layout

Fix button layout in dialog windows
This commit is contained in:
Min RK 2016-02-07 13:07:29 +01:00
commit 7117528dab
7 changed files with 39 additions and 30 deletions

View File

@ -184,8 +184,10 @@ define(function(require) {
var modal_obj = modal({ var modal_obj = modal({
title: "Edit " + options.name + " Metadata", title: "Edit " + options.name + " Metadata",
body: dialogform, body: dialogform,
default_button: "Cancel",
buttons: { buttons: {
OK: { class : "btn-primary", Cancel: {},
Edit: { class : "btn-primary",
click: function() { click: function() {
/** /**
* validate json and set it * validate json and set it
@ -200,8 +202,7 @@ define(function(require) {
} }
options.callback(new_md); options.callback(new_md);
} }
}, }
Cancel: {}
}, },
notebook: options.notebook, notebook: options.notebook,
keyboard_manager: options.keyboard_manager, keyboard_manager: options.keyboard_manager,

View File

@ -72,7 +72,9 @@ define([
var d = dialog.modal({ var d = dialog.modal({
title: "Rename File", title: "Rename File",
body: dialog_body, body: dialog_body,
default_button: "Cancel",
buttons : { buttons : {
"Cancel": {},
"OK": { "OK": {
class: "btn-primary", class: "btn-primary",
click: function () { click: function () {
@ -89,9 +91,8 @@ define([
); );
return false; return false;
} }
}, }
"Cancel": {} },
},
open : function () { open : function () {
// Upon ENTER, click the OK button. // Upon ENTER, click the OK button.
d.find('input[type="text"]').keydown(function (event) { d.find('input[type="text"]').keydown(function (event) {

View File

@ -276,13 +276,13 @@ define([
title : 'Kernel not found', title : 'Kernel not found',
body : body, body : body,
buttons : { buttons : {
'Continue without kernel' : { 'Continue Without Kernel' : {
class : 'btn-danger', class : 'btn-danger',
click : function () { click : function () {
that.events.trigger('no_kernel.Kernel'); that.events.trigger('no_kernel.Kernel');
} }
}, },
OK : { 'Set Kernel' : {
class : 'btn-primary', class : 'btn-primary',
click : function () { click : function () {
that.set_kernel(select.val()); that.set_kernel(select.val());

View File

@ -1996,7 +1996,7 @@ define(function (require) {
'Are you sure you want to restart the current kernel and re-execute the whole notebook? All variables and outputs will be lost.' 'Are you sure you want to restart the current kernel and re-execute the whole notebook? All variables and outputs will be lost.'
), ),
buttons : { buttons : {
"Restart & run all cells" : { "Restart and Run All Cells" : {
"class" : "btn-danger", "class" : "btn-danger",
"click" : function () { "click" : function () {
that.execute_all_cells(); that.execute_all_cells();
@ -2023,7 +2023,7 @@ define(function (require) {
'Do you want to restart the current kernel and clear all output? All variables and outputs will be lost.' 'Do you want to restart the current kernel and clear all output? All variables and outputs will be lost.'
), ),
buttons : { buttons : {
"Restart & clear all outputs" : { "Restart and Clear All Outputs" : {
"class" : "btn-danger", "class" : "btn-danger",
"click" : function (){ "click" : function (){
that.clear_all_output(); that.clear_all_output();
@ -2084,7 +2084,7 @@ define(function (require) {
options.dialog.keyboard_manager = this.keyboard_manager; options.dialog.keyboard_manager = this.keyboard_manager;
// add 'Continue running' cancel button // add 'Continue running' cancel button
var buttons = { var buttons = {
"Continue running": {}, "Continue Running": {},
}; };
// hook up button.click actions after restart promise resolves // hook up button.click actions after restart promise resolves
Object.keys(options.dialog.buttons).map(function (key) { Object.keys(options.dialog.buttons).map(function (key) {
@ -2975,15 +2975,16 @@ define(function (require) {
keyboard_manager: this.keyboard_manager, keyboard_manager: this.keyboard_manager,
title : "Revert notebook to checkpoint", title : "Revert notebook to checkpoint",
body : body, body : body,
default_button: "Cancel",
buttons : { buttons : {
Cancel: {},
Revert : { Revert : {
class : "btn-danger", class : "btn-danger",
click : function () { click : function () {
that.restore_checkpoint(checkpoint.id); that.restore_checkpoint(checkpoint.id);
} }
},
Cancel : {}
} }
}
}); });
}; };

View File

@ -176,14 +176,15 @@ define([
body : msg, body : msg,
keyboard_manager: that.keyboard_manager, keyboard_manager: that.keyboard_manager,
notebook: that.notebook, notebook: that.notebook,
default_button: "Don't Restart",
buttons : { buttons : {
"Try restarting now": { "Don't Restart": {},
"Try Restarting Now": {
class: "btn-danger", class: "btn-danger",
click: function () { click: function () {
that.notebook.start_session(); that.notebook.start_session();
} }
}, }
"Don't restart": {}
} }
}); });

View File

@ -82,8 +82,10 @@ define([
body: dialog_body, body: dialog_body,
notebook: options.notebook, notebook: options.notebook,
keyboard_manager: this.keyboard_manager, keyboard_manager: this.keyboard_manager,
default_button: "Cancel",
buttons : { buttons : {
"OK": { "Cancel": {},
"Rename": {
class: "btn-primary", class: "btn-primary",
click: function () { click: function () {
var new_name = d.find('input').val(); var new_name = d.find('input').val();
@ -108,9 +110,8 @@ define([
return false; return false;
} }
} }
}, }
"Cancel": {} },
},
open : function () { open : function () {
/** /**
* Upon ENTER, click the OK button. * Upon ENTER, click the OK button.

View File

@ -742,8 +742,10 @@ define([
var d = dialog.modal({ var d = dialog.modal({
title : "Rename "+ item_type, title : "Rename "+ item_type,
body : dialog_body, body : dialog_body,
default_button: "Cancel",
buttons : { buttons : {
OK : { Cancel: {},
Rename : {
class: "btn-primary", class: "btn-primary",
click: function() { click: function() {
that.contents.rename(item_path, utils.url_path_join(that.notebook_path, input.val())).then(function() { that.contents.rename(item_path, utils.url_path_join(that.notebook_path, input.val())).then(function() {
@ -763,8 +765,7 @@ define([
console.warn('Error durring renaming :', e); console.warn('Error durring renaming :', e);
}); });
} }
}, }
Cancel : {}
}, },
open : function () { open : function () {
// Upon ENTER, click the OK button. // Upon ENTER, click the OK button.
@ -861,7 +862,9 @@ define([
dialog.modal({ dialog.modal({
title : "Delete", title : "Delete",
body : message, body : message,
default_button: "Cancel",
buttons : { buttons : {
Cancel: {},
Delete : { Delete : {
class: "btn-danger", class: "btn-danger",
click: function() { click: function() {
@ -889,8 +892,7 @@ define([
}); });
}); });
} }
}, }
Cancel : {}
} }
}); });
}; };
@ -906,7 +908,9 @@ define([
dialog.modal({ dialog.modal({
title : "Duplicate", title : "Duplicate",
body : message, body : message,
default_button: "Cancel",
buttons : { buttons : {
Cancel: {},
Duplicate : { Duplicate : {
class: "btn-primary", class: "btn-primary",
click: function() { click: function() {
@ -929,8 +933,7 @@ define([
}); });
}); });
} }
}, }
Cancel : {}
} }
}); });
}; };
@ -1027,15 +1030,16 @@ define([
dialog.modal({ dialog.modal({
title : "Replace file", title : "Replace file",
body : 'There is already a file named ' + filename + ', do you want to replace it?', body : 'There is already a file named ' + filename + ', do you want to replace it?',
default_button: "Cancel",
buttons : { buttons : {
Cancel : {
click: function() { item.remove(); }
},
Overwrite : { Overwrite : {
class: "btn-danger", class: "btn-danger",
click: function () { click: function () {
that.contents.save(path, model).then(on_success); that.contents.save(path, model).then(on_success);
} }
},
Cancel : {
click: function() { item.remove(); }
} }
} }
}); });