mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Implements bootstrap modal as confirm dialog.
This commit is contained in:
parent
79542a4b13
commit
d1433ab4b6
6 changed files with 97 additions and 12 deletions
|
@ -209,24 +209,51 @@ body {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#popup {
|
#modal {
|
||||||
.modal;
|
.modal;
|
||||||
.fade;
|
.fade;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
& > div {
|
& > div {
|
||||||
.modal-dialog;
|
.modal-dialog;
|
||||||
|
& > div {
|
||||||
.modal-content;
|
.modal-content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#popup-title {
|
header {
|
||||||
.modal-header;
|
.modal-header;
|
||||||
|
|
||||||
|
.title {
|
||||||
.modal-title;
|
.modal-title;
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#popup-body {
|
&.no-title header {display: none;}
|
||||||
.modal-body;
|
|
||||||
|
.content {
|
||||||
|
.modal-body;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
.modal-footer;
|
||||||
|
|
||||||
|
button {
|
||||||
|
.btn;
|
||||||
|
&#modal-cancel {.btn-link;}
|
||||||
|
&#modal-confirm {.btn-primary;}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
#modal > div > div {
|
||||||
|
width: 600px;
|
||||||
|
margin: 30px auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Various styles
|
* Various styles
|
||||||
|
|
4
css/style.min.css
vendored
4
css/style.min.css
vendored
File diff suppressed because one or more lines are too long
21
index.html
21
index.html
|
@ -40,10 +40,23 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="popup" role="dialog"><div>
|
<div id="modal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
|
||||||
<h2 id="popup-title"></h2>
|
<div><div>
|
||||||
<div id="popup-body"></div>
|
<header>
|
||||||
</div></div>
|
<button type="button" class="close" data-dismiss="modal">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
<span class="sr-only" data-y18n="close">Close</span>
|
||||||
|
</button>
|
||||||
|
<h4 class="title" id="modalLabel"></h4>
|
||||||
|
</header>
|
||||||
|
<div class="content"></div>
|
||||||
|
<footer>
|
||||||
|
<button type="button" id="modal-cancel" data-action="cancel" data-y18n="cancel">Cancel</button>
|
||||||
|
<button type="button" id="modal-confirm" data-action="confirm" data-y18n="ok">OK</button>
|
||||||
|
</footer>
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="js/vendor/jquery-1.10.1.min.js"></script>
|
<script type="text/javascript" src="js/vendor/jquery-1.10.1.min.js"></script>
|
||||||
<script type="text/javascript" src="js/vendor/handlebars-v1.3.0.js"></script>
|
<script type="text/javascript" src="js/vendor/handlebars-v1.3.0.js"></script>
|
||||||
|
|
43
js/app.js
43
js/app.js
|
@ -228,6 +228,7 @@ app = Sammy('#main', function (sam) {
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
$('div.loader').remove();
|
$('div.loader').remove();
|
||||||
|
$('#modal').modal('hide');
|
||||||
|
|
||||||
if (enableSlide) {
|
if (enableSlide) {
|
||||||
function leSwap() {
|
function leSwap() {
|
||||||
|
@ -279,6 +280,48 @@ app = Sammy('#main', function (sam) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
confirm: function(title, content, confirmCallback, cancelCallback) {
|
||||||
|
// Default callbacks
|
||||||
|
confirmCallback = typeof confirmCallback !== 'undefined' ? confirmCallback : function() {};
|
||||||
|
cancelCallback = typeof cancelCallback !== 'undefined' ? cancelCallback : function() {};
|
||||||
|
|
||||||
|
// Get modal element
|
||||||
|
box = $('#modal');
|
||||||
|
|
||||||
|
// Modal title
|
||||||
|
if (typeof title === 'string' && title.length) {
|
||||||
|
$('.title', box).html(title);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
box.addClass('no-title');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modal content
|
||||||
|
$('.content', box).html(content);
|
||||||
|
|
||||||
|
// Handle buttons
|
||||||
|
$('footer button', box)
|
||||||
|
.click(function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Reset & Hide modal
|
||||||
|
box
|
||||||
|
.removeClass('no-title')
|
||||||
|
.modal('hide');
|
||||||
|
|
||||||
|
// Do corresponding callback
|
||||||
|
if ($(this).data('action') == 'confirm') {
|
||||||
|
confirmCallback();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cancelCallback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show modal
|
||||||
|
return box.modal('show');
|
||||||
|
},
|
||||||
|
|
||||||
arraySortById: function(arr) {
|
arraySortById: function(arr) {
|
||||||
arr.sort(function(a, b){
|
arr.sort(function(a, b){
|
||||||
if (a.id > b.id) {
|
if (a.id > b.id) {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
"both" : "Both",
|
"both" : "Both",
|
||||||
"home" : "Home",
|
"home" : "Home",
|
||||||
"read_more" : "Read more",
|
"read_more" : "Read more",
|
||||||
|
"cancel" : "Cancel",
|
||||||
|
|
||||||
"installing" : "Installing",
|
"installing" : "Installing",
|
||||||
"installed" : "Installed",
|
"installed" : "Installed",
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
"both" : "Les deux",
|
"both" : "Les deux",
|
||||||
"home" : "Accueil",
|
"home" : "Accueil",
|
||||||
"read_more" : "En savoir plus",
|
"read_more" : "En savoir plus",
|
||||||
|
"cancel" : "Annuler",
|
||||||
|
|
||||||
"installing" : "Installation",
|
"installing" : "Installation",
|
||||||
"installed" : "Installé",
|
"installed" : "Installé",
|
||||||
|
|
Loading…
Add table
Reference in a new issue