Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show modal in same position (height) as trigger of modal #81

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</div>
</div>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#@referersModalId">
<button type="submit" class="btn btn-secondary modal-trigger" data-bs-toggle="modal" data-bs-target="#@referersModalId">
<span data-feather="file-text"></span> referrers (@item.Referers.Count)
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/* globals feather:false */

(function() {
(function () {
'use strict';

feather.replace();


function clearInput() {
var initiators = document.querySelectorAll('[data-clear]');
initiators.forEach(function(initiator) {
initiators.forEach(function (initiator) {
initiator.addEventListener('click',
function(e) {
function (e) {
var target = e.currentTarget;
var selector = target.getAttribute('data-clear');
var input = document.querySelector(selector);
Expand All @@ -21,7 +20,7 @@

function confirmSubmit() {
var initiators = document.querySelectorAll('[data-confirm]');
initiators.forEach(function(initiator) {
initiators.forEach(function (initiator) {
var form = initiator.form;
form.addEventListener('submit',
function (e) {
Expand All @@ -36,6 +35,25 @@
});
}

function adjustModalPosition() {
var modalTriggers = document.querySelectorAll('.modal-trigger');
modalTriggers.forEach(function (modalTrigger) {
modalTrigger.addEventListener('click',
function () {
ellinge marked this conversation as resolved.
Show resolved Hide resolved
if (modalTrigger.dataset.bsTarget) {
var modalDialog = document.querySelector(modalTrigger.dataset.bsTarget + " .modal-dialog");
if (modalDialog) {
modalDialog.style = "position: fixed;" +
"top: " + modalTrigger.getBoundingClientRect().top + "px;" +
"left: 50%;" +
"transform: translate(-50%, -50%);";
}
}
});
});
}

clearInput();
confirmSubmit();
})()
adjustModalPosition();
})()