Pre registration

This commit is contained in:
Godwin
2016-05-30 18:24:07 -07:00
parent 530a3e8192
commit c8d6140ed8
74 changed files with 6726 additions and 792 deletions
+79
View File
@@ -0,0 +1,79 @@
(function() {
var pens = {};
Array.prototype.forEach.call(document.querySelectorAll('.textarea'), function(editor) {
startEditing(editor);
});
function startEditing(editor) {
var name = editor.dataset.name;
pens[name] = new Pen({
editor: editor,
class: 'pen',
textarea: '<textarea name="' + name + '"></textarea>',
list: ['p', 'h3', 'h4', 'blockquote', 'insertorderedlist', 'insertunorderedlist', 'bold', 'italic', 'underline', 'strikethrough', 'createlink', 'insertimage'],
title: {
'p': 'Paragraph',
'h3': 'Major Heading',
'h4': 'Minor Heading',
'blockquote': 'Quotation',
'insertorderedlist': 'Ordered List',
'insertunorderedlist': 'Unordered List',
'bold': 'Bold',
'italic': 'Italic',
'underline': 'Underline',
'strikethrough': 'Strikethrough',
'createlink': 'Link',
'insertimage': 'Image'
}
});
}
Array.prototype.forEach.call(document.querySelectorAll('form'), function(form) {
var shouldAllowAlert = false;
form.addEventListener('submit', function() {
if (shouldAllowAlert) {
return;
}
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.innerHTML;
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) {
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(); });
});
});
})();
-37
View File
@@ -1,37 +0,0 @@
#= require froala_editor.min.js
$ ->
$('[data-editable]').editable({inlineMode: true, blockTags: ["n", "p", "h2", "blockquote", "pre"], buttons: ["formatBlock", "bold", "italic", "underline", "insertOrderedList", "insertUnorderedList", "sep", "createLink", "insertImage", "insertVideo", "html", "undo", "redo"]})
$('[data-editor]').editable({inlineMode: false, blockTags: ["n", "p", "h2", "blockquote", "pre"], buttons: ["formatBlock", "bold", "italic", "underline", "insertOrderedList", "insertUnorderedList", "sep", "createLink", "html", "undo", "redo"]})
$('.field.country-select-field select').change () ->
$country = $(this)
country = $country.val()
$territory = $('.field.subregion-select-field select')
if $territory.data().country == country
$territory.removeClass('can cant').addClass('can')
return
$.post '/location/territories', {country: country},
(json) ->
$territory.html('')
if json && Object.keys(json).length
$.each json, (code, name) ->
$territory.append($('<option>').text(name).attr('value', code))
return
$territory.removeClass('can cant').addClass('can')
$territory.data().country = country
else
$territory.removeClass('can cant').addClass('cant')
return
, 'json'
$('img + input[type="file"]').change () ->
readURL(this);
return
readURL = (input) ->
reader = null
if input.files && input.files[0]
reader = new FileReader()
reader.readAsDataURL input.files[0]
reader.onload = (e) ->
$(input).prev().attr('src', e.target.result)
return
+16
View File
@@ -0,0 +1,16 @@
(function() {
Array.prototype.forEach.call(document.querySelectorAll('.number-field,.email-field,.text-field'), function(field) {
var input = field.querySelector('input');
var positionLabel = function(input) {
field.classList[input.value ? 'remove' : 'add']('empty');
}
positionLabel(input);
input.addEventListener('keyup', function(event) { positionLabel(event.target); });
input.addEventListener('blur', function(event) { field.classList.remove('focused'); });
input.addEventListener('focus', function(event) { field.classList.add('focused'); });
});
var errorField = document.querySelector('.input-field.has-error input, .input-field.has-error textarea');
if (errorField) {
errorField.focus();
}
})();