FEATURE: add working confirm dialog

This commit is contained in:
Michal Kváček
2016-09-13 03:51:50 +02:00
parent ea5aa8d873
commit 8476d5fbd7
5 changed files with 67 additions and 36 deletions
+37 -21
View File
@@ -1346,7 +1346,6 @@ $ (function () {
});
$ (function () {
$ ("body").addClass ("loaded");
@@ -1364,7 +1363,6 @@ $ (function () {
}
});
/**
* Makes slug from input string
*
@@ -1401,24 +1399,45 @@ function slugify(text, trimSpaces) {
// bind some custom methods
$ (document).ready (function () {
$ ('.confirm').click (function () {
var confirmMessage = $ (this).data ('confirm-message');
var previousTitle, previousMessage;
// set some default message
if (typeof confirmMessage == 'undefined') {
confirmMessage = 'Really?';
}
$ ('.confirm').click (function (e) {
return confirm (confirmMessage);
var titleElement = $ ('#confirmation-title');
var messageElement = $ ('#confirmation-message');
previousTitle = titleElement.text ();
previousMessage = messageElement.text ();
var confirmTitle = $ (this).data ('title');
var confirmMessage = $ (this).data ('message');
var href = $ (this).attr ('href');
$ ('#confirm-button').attr ('href', href);
if (confirmTitle)
titleElement.text (confirmTitle);
if (confirmMessage)
messageElement.text (confirmMessage);
$ ('#confirm-modal').modal ('show');
e.preventDefault ();
});
$('#lockUrl').change(function () {
$ ('#confirm-modal').on ('hidden.bs.modal', function () {
$ ('#confirmation-title').text (previousTitle);
$ ('#confirmation-message').text (previousMessage);
});
$ ('#lockUrl').change (function () {
$ ('.slug-source').keyup ();
});
$ ('.slug-target').keyup (function () {
$ (this).val (slugify ($ (this).val (), false));
$('#lockUrl').prop('checked', true);
$ ('#lockUrl').prop ('checked', true);
});
$ ('.slug-source').keyup (function () {
@@ -1430,22 +1449,19 @@ $ (document).ready (function () {
target.val (slugify (source.val (), true));
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
$ (function () {
$ ('[data-toggle="tooltip"]').tooltip ()
});
// find if any error occured and mark tab with that error
$('.has-error').each(function () {
var error = $(this);
var tabCard = error.closest('.tab-pane');
$ ('.has-error').each (function () {
var error = $ (this);
var tabCard = error.closest ('.tab-pane');
$("#"+tabCard.prop('id')+"-tab").addClass('tab-with-error');
$ ("#" + tabCard.prop ('id') + "-tab").addClass ('tab-with-error');
});
});
/***********************************************
* NProgress Settings
***********************************************/