fire a warning before closing an unsaved file

This commit is contained in:
ilvalle
2013-06-12 13:18:48 +02:00
parent 6af173c853
commit 4f15c03686
3 changed files with 18 additions and 8 deletions
+11 -5
View File
@@ -55,12 +55,18 @@ jQuery(document).on('shown click', 'a[data-toggle="tab"]', function (e) {
jQuery(document).on('click', '#filesTab button[class="close"]', function (e) {
var tab_body = jQuery(jQuery(this).parent().attr("href")); // it should be a div
var tab_header = jQuery(this).parent().parent(); // it should be a li
if (tab_header.hasClass('active') === true) { //Set active an other tab
jQuery(tab_header).prev().children('a[data-toggle="tab"]').tab('show'); // Select first tab
var saved = jQuery(tab_body.find('textarea').data('editor')).data('saved');
var close = true;
if (saved === false) {
close = confirm("You are closing an unsaved file")
}
if (close) {
if (tab_header.hasClass('active') === true) { //Set active an other tab
jQuery(tab_header).prev().children('a[data-toggle="tab"]').tab('show'); // Select first tab
}
tab_header.remove(); //remove li of tab
tab_body.remove(); //remove li of tab
}
tab_header.remove(); //remove li of tab
tab_body.remove(); //remove li of tab
});
// Revert current file