-
Notifications
You must be signed in to change notification settings - Fork 0
/
playground-blade.js
57 lines (57 loc) · 2.03 KB
/
playground-blade.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Playground application handling.
*/
window.playground = {
/**
* Form handling for Playground.
*/
forms: {
/**
* Enable editors on forms.
*/
editor: function(selector) {
selector = '' == selector ? '.editor' : selector;
// console.debug('playground.forms.editor', {
// selector: selector
// })
ClassicEditor.create(document.querySelector(selector)).catch(error => {
console.error(error);
});
// .then(editorInstance => {
// console.debug('playground.forms.editor', {
// editorInstance: editorInstance
// })
// editorInstance.ui.focusTracker.on('change:isFocused', (evt, name, isFocused) => {
// console.debug('playground.forms.editor', {
// evt: evt,
// name: name,
// isFocused: isFocused,
// })
// if (!isFocused) {
// editorInstance.updateSourceElement();
// }
// });
// });
},
/**
* Enable form validation.
*/
validation: function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// console.debug('playground.forms.validation', {
// forms: forms
// });
// Loop over them and prevent submission
Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}
}
}