New registration process

This commit is contained in:
Godwin
2017-05-30 19:24:44 -07:00
parent 4115c8996f
commit c871b1ab3d
270 changed files with 94667 additions and 137 deletions
+78 -78
View File
@@ -1,10 +1,6 @@
(function() {
var pens = {};
Array.prototype.forEach.call(document.querySelectorAll('.textarea .editor'), function(editor) {
startEditing(editor);
});
function startEditing(editor) {
var name = editor.dataset.name;
pens[name] = new Quill(editor, {
@@ -22,89 +18,93 @@
return pens[name];
}
Array.prototype.forEach.call(document.querySelectorAll('form'), function(form) {
var shouldAllowAlert = false;
form.addEventListener('submit', function() {
if (shouldAllowAlert) {
return;
window.editorEndEdit = function(form) {
Array.prototype.forEach.call(form.querySelectorAll('.textarea'), function(editor) {
var name = editor.dataset.name;
var textarea = form.querySelector('textarea[name="' + name + '"]');
if (!textarea) {
textarea = document.createElement('textarea');
textarea.name = name;
textarea.style.display = 'none';
form.appendChild(textarea);
}
textarea.value = editor.getElementsByClassName('ql-editor')[0].innerHTML;
if (pens[name]) {
pens[name].destroy();
}
Array.prototype.forEach.call(document.querySelectorAll('.textarea'), function(editor) {
var name = editor.dataset.name;
var textarea = document.querySelector('textarea[name="' + name + '"]');
if (!textarea) {
textarea = document.createElement('textarea');
textarea.name = name;
textarea.style.display = 'none';
form.appendChild(textarea);
}
textarea.value = editor.getElementsByClassName('ql-editor')[0].innerHTML;
if (pens[name]) {
pens[name].destroy();
}
});
}, false);
Array.prototype.forEach.call(form.querySelectorAll('button'), function(button) {
form.addEventListener('click', function(event) {
shouldAllowAlert = (event.target.value === 'cancel');
});
});
});
};
Array.prototype.forEach.call(document.querySelectorAll('.check-box-field .other input'), function(input) {
var checkbox = document.getElementById(input.parentElement.parentElement.attributes.for.value);
input.addEventListener('keyup', function(event) {
if (event.target.value) {
var initEditor = function(node) {
Array.prototype.forEach.call(node.querySelectorAll('.textarea .editor'), function(editor) {
startEditing(editor);
});
Array.prototype.forEach.call(node.querySelectorAll('form'), function(form) {
form.addEventListener('submit', function() { window.editorEndEdit(form); }, false);
});
Array.prototype.forEach.call(node.querySelectorAll('.check-box-field .other input'), function(input) {
var checkbox = node.getElementById(input.parentElement.parentElement.attributes.for.value);
input.addEventListener('keyup', function(event) {
if (event.target.value) {
checkbox.checked = true;
}
});
input.addEventListener('click', function(event) {
checkbox.checked = true;
}
});
input.addEventListener('click', function(event) {
checkbox.checked = true;
});
var setRequired = function() {
if (checkbox.checked) {
input.setAttribute('required', 'required');
} else {
input.removeAttribute('required');
}
};
Array.prototype.forEach.call(document.querySelectorAll('.check-box-field input'), function(_input) {
_input.addEventListener('change', function(event) { setRequired(); });
});
});
Array.prototype.forEach.call(document.querySelectorAll('[data-toggles]'), function(checkbox) {
var toggles = document.getElementById(checkbox.dataset.toggles);
toggles.classList.add('toggleable');
var form = checkbox.parentNode;
while (form && form.nodeName != 'FORM') {
form = form.parentNode;
}
var toggle = function() {
toggles.classList[checkbox.checked ? 'add' : 'remove']('open');
if (form) {
});
var setRequired = function() {
if (checkbox.checked) {
form.removeAttribute('novalidate');
input.setAttribute('required', 'required');
} else {
form.setAttribute('novalidate', 'novalidate');
input.removeAttribute('required');
}
}
};
toggle();
checkbox.addEventListener('change', function(event) { toggle(); });
});
};
Array.prototype.forEach.call(node.querySelectorAll('.check-box-field input'), function(_input) {
_input.addEventListener('change', function(event) { setRequired(); });
});
});
Array.prototype.forEach.call(document.querySelectorAll('fieldset.translator'), function(translator) {
Array.prototype.forEach.call(translator.querySelectorAll('.locale-select a'), function(selector) {
selector.addEventListener('click', function(event) {
event.preventDefault();
var locale = event.target.parentElement.getAttribute('data-locale');
Array.prototype.forEach.call(translator.querySelectorAll('.locale-select li'), function(_selector) {
_selector.className = _selector.getAttribute('data-locale') == locale ? 'selected' : '';
});
Array.prototype.forEach.call(translator.querySelectorAll('.text-editors li'), function(editor) {
editor.className = editor.getAttribute('data-locale') == locale ? 'selected' : '';
Array.prototype.forEach.call(node.querySelectorAll('[data-toggles]'), function(checkbox) {
var toggles = node.getElementById(checkbox.dataset.toggles);
toggles.classList.add('toggleable');
var form = checkbox.parentNode;
while (form && form.nodeName != 'FORM') {
form = form.parentNode;
}
var toggle = function() {
toggles.classList[checkbox.checked ? 'add' : 'remove']('open');
if (form) {
if (checkbox.checked) {
form.removeAttribute('novalidate');
} else {
form.setAttribute('novalidate', 'novalidate');
}
}
};
toggle();
checkbox.addEventListener('change', function(event) { toggle(); });
});
Array.prototype.forEach.call(node.querySelectorAll('fieldset.translator'), function(translator) {
Array.prototype.forEach.call(translator.querySelectorAll('.locale-select a'), function(selector) {
selector.addEventListener('click', function(event) {
event.preventDefault();
var locale = event.target.parentElement.getAttribute('data-locale');
Array.prototype.forEach.call(translator.querySelectorAll('.locale-select li'), function(_selector) {
_selector.className = _selector.getAttribute('data-locale') == locale ? 'selected' : '';
});
Array.prototype.forEach.call(translator.querySelectorAll('.text-editors li'), function(editor) {
editor.className = editor.getAttribute('data-locale') == locale ? 'selected' : '';
});
});
});
});
});
};
if (!window.initNodeFunctions) {
window.initNodeFunctions = [];
}
window.initNodeFunctions.push(initEditor);
initEditor(document);
})();
+20 -5
View File
@@ -151,7 +151,10 @@
errorField.focus();
}
window.initNodeFunctions = [ function(node) {
if (!window.initNodeFunctions) {
window.initNodeFunctions = [];
}
window.initNodeFunctions.push(function(node) {
forEachElement('.number-field,.email-field,.text-field,.password-field,.search-field', function(field) {
var input = field.querySelector('input');
var positionLabel = function(input) {
@@ -169,6 +172,7 @@
field.classList.add('focused');
});
}, node || document);
forEachElement('form.js-xhr', function(form) {
if (form.addEventListener) {
forEachElement('button', function(button) {
@@ -178,12 +182,23 @@
});
}, form);
form.addEventListener('submit', function(event) {
var btnvalue = form.getAttribute('data-button-value');
var btnname = form.getAttribute('data-button-name');
if (btnvalue) {
var btn = form.querySelector('button[name="' + btnname + '"][value="' + btnvalue + '"]');
if (btn && btn.getAttribute('data-no-xhr') === '1') {
return;
}
}
event.preventDefault();
form.classList.add('requesting');
if (typeof window.editorEndEdit === "function") {
window.editorEndEdit(form);
}
var data = new FormData(form);
var button = form.getAttribute('data-button-value');
if (button) {
data.append(form.getAttribute('data-button-name'), button);
if (btnname) {
data.append(btnname, btnvalue);
}
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
@@ -239,7 +254,7 @@
}
});
});
} ];
});
window.initNode = function(node) {
forEach(initNodeFunctions, function(fn) {
fn(node);