mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Created a method to prompt user password.
This commit is contained in:
parent
c495337aa6
commit
7e09e0f2f9
@ -118,6 +118,12 @@ var ComunicWeb = {
|
|||||||
* Prompt the user to input a string
|
* Prompt the user to input a string
|
||||||
*/
|
*/
|
||||||
inputString: function(title, message, defaultValue, callback){},
|
inputString: function(title, message, defaultValue, callback){},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt the user to enter his password
|
||||||
|
*/
|
||||||
|
promptPassword: function(info){},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -383,3 +383,84 @@ ComunicWeb.common.messages.inputString = function(title, message, defaultValue,
|
|||||||
$(modal).modal('show');
|
$(modal).modal('show');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt the user to input his password
|
||||||
|
*
|
||||||
|
* @param {Object} info Additionnal information
|
||||||
|
*/
|
||||||
|
ComunicWeb.common.messages.promptPassword = function(info){
|
||||||
|
|
||||||
|
var dialog = ComunicWeb.common.messages.createDialogSkeleton({
|
||||||
|
type: "danger",
|
||||||
|
title: "Password required"
|
||||||
|
});
|
||||||
|
$(dialog.modal).modal("show");
|
||||||
|
|
||||||
|
//Create modal close function
|
||||||
|
var closeModal = function(e, password){
|
||||||
|
$(dialog.modal).modal("hide");
|
||||||
|
emptyElem(dialog.modal);
|
||||||
|
dialog.modal.remove();
|
||||||
|
|
||||||
|
//Callback
|
||||||
|
if(info.callback)
|
||||||
|
info.callback(password);
|
||||||
|
};
|
||||||
|
dialog.cancelButton.addEventListener("click", closeModal);
|
||||||
|
dialog.closeModal.addEventListener("click", closeModal);
|
||||||
|
|
||||||
|
//Set dialog body
|
||||||
|
var passwordForm = createElem2({
|
||||||
|
appendTo: dialog.modalBody,
|
||||||
|
type: "div"
|
||||||
|
});
|
||||||
|
|
||||||
|
createElem2({
|
||||||
|
appendTo: passwordForm,
|
||||||
|
type: "p",
|
||||||
|
innerHTML: "We need your password to continue."
|
||||||
|
});
|
||||||
|
|
||||||
|
//Create pasword input group
|
||||||
|
var inputGroup = createElem2({
|
||||||
|
appendTo: passwordForm,
|
||||||
|
type: "div",
|
||||||
|
class: "input-group input-group-sm"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Create password input
|
||||||
|
var passwordInput = createElem2({
|
||||||
|
appendTo: inputGroup,
|
||||||
|
type: "input",
|
||||||
|
class: "form-control",
|
||||||
|
elemType: "password"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Create input group
|
||||||
|
var inputGroupContainer = createElem2({
|
||||||
|
appendTo: inputGroup,
|
||||||
|
type: "span",
|
||||||
|
class: "input-group-btn"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Add submit button
|
||||||
|
var submitButton = createElem2({
|
||||||
|
appendTo: inputGroupContainer,
|
||||||
|
type: "button",
|
||||||
|
class: "btn btn-danger",
|
||||||
|
innerHTML: "Confirm deletion"
|
||||||
|
});
|
||||||
|
|
||||||
|
submitButton.addEventListener("click", function(e){
|
||||||
|
|
||||||
|
//Check given password
|
||||||
|
var password = passwordInput.value;
|
||||||
|
if(password.length < 4)
|
||||||
|
return notify("Please check given password !", "danger");
|
||||||
|
|
||||||
|
//Close modal
|
||||||
|
closeModal(null, password);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user