diff --git a/examples/timeline/editing/editingItemsCallbacks.html b/examples/timeline/editing/editingItemsCallbacks.html
index 8797683f..6a49f3a4 100644
--- a/examples/timeline/editing/editingItemsCallbacks.html
+++ b/examples/timeline/editing/editingItemsCallbacks.html
@@ -10,6 +10,9 @@
}
+
+
+
@@ -42,24 +45,30 @@
editable: true,
onAdd: function (item, callback) {
- item.content = prompt('Enter text content for new item:', item.content);
- if (item.content != null) {
- callback(item); // send back adjusted new item
- }
- else {
- callback(null); // cancel item creation
- }
+ prettyPrompt('Add item', 'Enter text content for new item:', item.content, function (value) {
+ if (value) {
+ item.content = value;
+ callback(item); // send back adjusted new item
+ }
+ else {
+ callback(null); // cancel item creation
+ }
+ });
},
onMove: function (item, callback) {
- if (confirm('Do you really want to move the item to\n' +
+ var title = 'Do you really want to move the item to\n' +
'start: ' + item.start + '\n' +
- 'end: ' + item.end + '?')) {
- callback(item); // send back item as confirmation (can be changed)
- }
- else {
- callback(null); // cancel editing item
- }
+ 'end: ' + item.end + '?';
+
+ prettyConfirm('Move item', title, function (ok) {
+ if (ok) {
+ callback(item); // send back item as confirmation (can be changed)
+ }
+ else {
+ callback(null); // cancel editing item
+ }
+ });
},
onMoving: function (item, callback) {
@@ -71,22 +80,26 @@
},
onUpdate: function (item, callback) {
- item.content = prompt('Edit items text:', item.content);
- if (item.content != null) {
- callback(item); // send back adjusted item
- }
- else {
- callback(null); // cancel updating the item
- }
+ prettyPrompt('Update item', 'Edit items text:', item.content, function (value) {
+ if (value) {
+ item.content = value;
+ callback(item); // send back adjusted item
+ }
+ else {
+ callback(null); // cancel updating the item
+ }
+ });
},
onRemove: function (item, callback) {
- if (confirm('Remove item ' + item.content + '?')) {
- callback(item); // confirm deletion
- }
- else {
- callback(null); // cancel deletion
- }
+ prettyConfirm('Remove item', 'Do you really want to remove item ' + item.content + '?', function (ok) {
+ if (ok) {
+ callback(item); // confirm deletion
+ }
+ else {
+ callback(null); // cancel deletion
+ }
+ });
}
};
var timeline = new vis.Timeline(container, items, options);
@@ -103,6 +116,27 @@
log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg);
}
+ function prettyConfirm(title, text, callback) {
+ swal({
+ title: title,
+ text: text,
+ type: 'warning',
+ showCancelButton: true,
+ confirmButtonColor: "#DD6B55"
+ }, callback);
+ }
+
+ function prettyPrompt(title, text, inputValue, callback) {
+ console.log(title, text, inputValue)
+ swal({
+ title: title,
+ text: text,
+ type: 'input',
+ showCancelButton: true,
+ inputValue: inputValue
+ }, callback);
+ }
+