Skip to content

Instantly share code, notes, and snippets.

@HenderOrlando
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save HenderOrlando/9402802 to your computer and use it in GitHub Desktop.

Select an option

Save HenderOrlando/9402802 to your computer and use it in GitHub Desktop.
Archivos de ejemplo para llamar el modal.
BootstrapDialog.alert('Hi Apple!', function(){
alert('Hi Orange!');
});
BootstrapDialog.confirm('Hi Apple, are you sure?', function(result){
if(result) {
alert('Yup.');
}else {
alert('Nope.');
}
});
BootstrapDialog.show({
type: typesDialog['success'],
title: 'Draggable Dialog',
draggable: true,
message: function(dialog) {
var $content = $('<div><button class="btn btn-success">Revert button status right now.</button></div>');
var $footerButton = dialog.getButton('btn-1');
$content.find('button').click({$footerButton: $footerButton}, function(event) {
event.data.$footerButton.enable();
event.data.$footerButton.stopSpin();
dialog.setClosable(true);
});
return $content;
},
draggable: true,
onshow: function(dialog){
alert('Dialog is popping up, its message is ' + dialog.getMessage());
},
onhide: function(dialogRef){
alert('Dialog is popping down, its message is ' + dialog.getMessage());
}
buttons: [{
label: 'Title 1',
cssClass: 'btn-primary',
action: function(dialog) {
dialog.setTitle('Title 1');
}
}, {
label: 'Close',
action: function(dialog){
dialog.close();
}
}, {
id: 'btn-1',
label: 'Click to disable and spin.',
action: function(dialog) {
var $button = this; // 'this' here is a jQuery object that wrapping the <button> DOM element.
$button.disable();
$button.spin();
dialog.setClosable(false);
}
}, {
id: 'button-c',
label: '(C) Button C',
hotkey: 67,
action: function(){
alert('This is Button C but you won\'t see me dance.');
}
}]
});
var dialogInstance = new BootstrapDialog({
type: typesDialog['warning'],
size: sizesDialog['lg'],
message: $textAndPic,
buttons: [{
id: 'btn-1',
label: 'Button 1'
}, {
label: 'Dialog CLOSABLE!',
icon: {
stacked: true,
icons: [
{
icon: 'fa fa-square-o fa-stack-2x',
},
{
icon: 'fa fa-twitter fa-stack-1x'
}
]
},
cssClass: 'btn-success',
action: function(dialogRef){
dialogRef.setClosable(true);
}
}, {
label: 'Dialog UNCLOSABLE!',
icon: {
stacked: 'fa-lg',
icons: [
{
icon: 'fa fa-square-o fa-stack-2x',
},
{
icon: 'fa fa-twitter fa-stack-1x'
}
]
}
cssClass: 'btn-warning',
action: function(dialogRef){
dialogRef.setClosable(false);
}
}, {
icon: 'glyphicon glyphicon-send',
label: 'Send ajax request',
cssClass: 'btn-primary',
autospin: true,
action: function(dialogRef){
dialogRef.enableButtons(false);
dialogRef.setClosable(false);
dialogRef.getModalBody().html('Dialog closes in 5 seconds.');
setTimeout(function(){
dialogRef.close();
}, 5000);
}
}]
});
dialogInstance.realize();
var btn1 = dialogInstance.getButton('btn-1');
btn1.click({'name': 'Apple'}, function(event){
alert('Hi, ' + event.data.name);
});
dialogInstance.open();
var dialog = new BootstrapDialog({
message: function(dialogRef){
var $message = $('<div>OK, this dialog has no header and footer, but you can close the dialog using this button: </div>');
var $button = $('<button class="btn btn-primary btn-lg btn-block">Close the dialog</button>');
$button.on('click', {dialogRef: dialogRef}, function(event){
event.data.dialogRef.close();
});
$message.append($button);
return $message;
},
closable: false
});
dialog.realize();
dialog.getModalHeader().hide();
dialog.getModalFooter().hide();
dialog.getModalBody().css('background-color', '#0088cc');
dialog.getModalBody().css('color', '#fff');
dialog.open();
typesDialog = {
'default' : BootstrapDialog.TYPE_DEFAULT,
'info' : BootstrapDialog.TYPE_INFO,
'primary' : BootstrapDialog.TYPE_PRIMARY,
'success' : BootstrapDialog.TYPE_SUCCESS,
'warning' : BootstrapDialog.TYPE_WARNING,
'danger' : BootstrapDialog.TYPE_DANGER
};
sizesDialog = {
'default' : BootstrapDialog.SIZE_NORMAL,
'lg' : BootstrapDialog.SIZE_LARGE,
};
var data1 = 'Apple';
var data2 = 'Orange';
var data3 = ['Banana', 'Pear'];
BootstrapDialog.show({
message: 'Hi Apple!',
data: {
'data1': data1,
'data2': data2,
'data3': data3
},
buttons: [{
label: 'See what you got',
cssClass: 'btn-primary',
action: function(dialogRef){
alert(dialogRef.getData('data1'));
alert(dialogRef.getData('data2'));
alert(dialogRef.getData('data3').join(', '));
}
}]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment