moved all aptches from cipf plugin to fbpatch
This commit is contained in:
29
plugins/fbpatch/js/modals.js
Normal file
29
plugins/fbpatch/js/modals.js
Normal file
@@ -0,0 +1,29 @@
|
||||
let modal_wrapper_CIPF = document.querySelector('#de-fb-modal-wrapper-');
|
||||
|
||||
// create an observer on first #de-fb-modal-wrapper- to check if child nodes are added
|
||||
const observer_CIPF = new MutationObserver(wait_for_close_button_CIPF);
|
||||
observer_CIPF.observe(modal_wrapper_CIPF, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
|
||||
// observe mutations to see if they include the creation of the button .modal-close
|
||||
// if the button is created, add an eventListener to it
|
||||
function wait_for_close_button_CIPF(mutationsList) {
|
||||
mutationsList.forEach((mutation) => {
|
||||
// check if nodes were added
|
||||
if (mutation.type !== 'childList')
|
||||
return;
|
||||
// check if added nodes includes the button .modal-close
|
||||
let modal_close = document.querySelector('#de-fb-modal-wrapper- .modal-close');
|
||||
if (modal_close !== null) {
|
||||
modal_close.addEventListener("click", delete_modal_CIPF);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// when triggered, the .modal-close button will remove all childs from #de-fb-modal-wrapper-
|
||||
function delete_modal_CIPF() {
|
||||
modal_wrapper_CIPF.innerHTML = '';
|
||||
}
|
||||
|
||||
9
plugins/fbpatch/js/urls.js
Normal file
9
plugins/fbpatch/js/urls.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// https://stackoverflow.com/questions/12741517/how-to-make-url-validation-without-http-or-add-it-after-validation-passed/44848476#44848476
|
||||
|
||||
let old_url = jQuery.validator.methods.url;
|
||||
jQuery.validator.addMethod( 'url', function(value, element) {
|
||||
let url = old_url.bind(this);
|
||||
return url(value, element) || url('http://' + value, element);
|
||||
}, 'Please enter a valid URL'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user