Skip to content

Commit

Permalink
chore(all): dist build
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanood committed Dec 7, 2016
1 parent 15bb415 commit 8ad8e75
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 266 deletions.
7 changes: 6 additions & 1 deletion dist/amd/validation/validationRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ define(['exports'], function (exports) {
if (!selectWrapper) {
return;
}
this.removeMessage(selectWrapper, error);

if ($(selectWrapper.parentElement).children().hasClass('md-input-validation')) {
this.removeMessage(selectWrapper.parentElement, error);
} else {
this.removeMessage(selectWrapper, error);
}

var _input2 = selectWrapper.querySelector('input');
if (_input2 && selectWrapper.querySelectorAll('.' + this.className).length === 0) {
Expand Down
265 changes: 135 additions & 130 deletions dist/aurelia-materialize-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2909,136 +2909,141 @@ export class MdStaggeredList {
}
}
export class MaterializeFormValidationRenderer {
className = 'md-input-validation';
classNameFirst = 'md-input-validation-first';
render(instruction) {
for (let { error, elements } of instruction.unrender) {
for (let element of elements) {
this.remove(element, error);
}
}
for (let { error, elements } of instruction.render) {
for (let element of elements) {
this.add(element, error);
}
}
}
add(element, error) {
switch (element.tagName) {
case 'MD-INPUT': {
let label = element.querySelector('label');
let input = element.querySelector('input') || element.querySelector('textarea');
if (label) {
label.removeAttribute('data-error');
}
if (input) {
input.classList.remove('valid');
input.classList.add('invalid');
error.target = input;
if (input.hasAttribute('data-show-errortext')) {
this.addMessage(element, error);
}
}
break;
}
case 'SELECT': {
const selectWrapper = element.closest('.select-wrapper');
if (!selectWrapper) {
return;
}
let input = selectWrapper.querySelector('input');
if (input) {
input.classList.remove('valid');
input.classList.add('invalid');
error.target = input;
if (!(input.hasAttribute('data-show-errortext') &&
input.getAttribute('data-show-errortext') === 'false')) {
this.addMessage(selectWrapper, error);
}
}
break;
}
case 'INPUT' : {
if (element.hasAttribute('md-datepicker')) {
element.classList.remove('valid');
element.classList.add('invalid');
if (!(element.hasAttribute('data-show-errortext') &&
element.getAttribute('data-show-errortext') === 'false')) {
this.addMessage(element.parentNode, error);
}
}
break;
}
default: break;
}
}
remove(element, error) {
switch (element.tagName) {
case 'MD-INPUT': {
this.removeMessage(element, error);
let input = element.querySelector('input') || element.querySelector('textarea');
if (input && element.querySelectorAll('.' + this.className).length === 0) {
input.classList.remove('invalid');
input.classList.add('valid');
}
break;
}
case 'SELECT': {
const selectWrapper = element.closest('.select-wrapper');
if (!selectWrapper) {
return;
}
this.removeMessage(selectWrapper, error);
let input = selectWrapper.querySelector('input');
if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) {
input.classList.remove('invalid');
input.classList.add('valid');
}
break;
}
case 'INPUT' : {
if (element.hasAttribute('md-datepicker')) {
this.removeMessage(element.parentNode, error);
if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) {
element.classList.remove('invalid');
element.classList.add('valid');
}
}
break;
}
default: break;
}
}
addMessage(element, error) {
let message = document.createElement('div');
message.id = `md-input-validation-${error.id}`;
message.textContent = error.message;
message.className = this.className;
if (element.querySelectorAll('.' + this.className).length === 0) {
message.className += ' ' + this.classNameFirst;
}
message.style.opacity = 0;
element.appendChild(message, element.nextSibling);
window.getComputedStyle(message).opacity;
message.style.opacity = 1;
}
removeMessage(element, error) {
let message = element.querySelector(`#md-input-validation-${error.id}`);
if (message) {
element.removeChild(message);
}
}
}
export class MaterializeFormValidationRenderer {
className = 'md-input-validation';
classNameFirst = 'md-input-validation-first';
render(instruction) {
for (let { error, elements } of instruction.unrender) {
for (let element of elements) {
this.remove(element, error);
}
}
for (let { error, elements } of instruction.render) {
for (let element of elements) {
this.add(element, error);
}
}
}
add(element, error) {
switch (element.tagName) {
case 'MD-INPUT': {
let label = element.querySelector('label');
let input = element.querySelector('input') || element.querySelector('textarea');
if (label) {
label.removeAttribute('data-error');
}
if (input) {
input.classList.remove('valid');
input.classList.add('invalid');
error.target = input;
if (input.hasAttribute('data-show-errortext')) {
this.addMessage(element, error);
}
}
break;
}
case 'SELECT': {
const selectWrapper = element.closest('.select-wrapper');
if (!selectWrapper) {
return;
}
let input = selectWrapper.querySelector('input');
if (input) {
input.classList.remove('valid');
input.classList.add('invalid');
error.target = input;
if (!(input.hasAttribute('data-show-errortext') &&
input.getAttribute('data-show-errortext') === 'false')) {
this.addMessage(selectWrapper, error);
}
}
break;
}
case 'INPUT' : {
if (element.hasAttribute('md-datepicker')) {
element.classList.remove('valid');
element.classList.add('invalid');
if (!(element.hasAttribute('data-show-errortext') &&
element.getAttribute('data-show-errortext') === 'false')) {
this.addMessage(element.parentNode, error);
}
}
break;
}
default: break;
}
}
remove(element, error) {
switch (element.tagName) {
case 'MD-INPUT': {
this.removeMessage(element, error);
let input = element.querySelector('input') || element.querySelector('textarea');
if (input && element.querySelectorAll('.' + this.className).length === 0) {
input.classList.remove('invalid');
input.classList.add('valid');
}
break;
}
case 'SELECT': {
const selectWrapper = element.closest('.select-wrapper');
if (!selectWrapper) {
return;
}
if ($(selectWrapper.parentElement).children().hasClass('md-input-validation') ) {
this.removeMessage(selectWrapper.parentElement, error);
} else {
this.removeMessage(selectWrapper, error);
}
let input = selectWrapper.querySelector('input');
if (input && selectWrapper.querySelectorAll('.' + this.className).length === 0) {
input.classList.remove('invalid');
input.classList.add('valid');
}
break;
}
case 'INPUT' : {
if (element.hasAttribute('md-datepicker')) {
this.removeMessage(element.parentNode, error);
if (element && element.parentNode.querySelectorAll('.' + this.className).length === 0) {
element.classList.remove('invalid');
element.classList.add('valid');
}
}
break;
}
default: break;
}
}
addMessage(element, error) {
let message = document.createElement('div');
message.id = `md-input-validation-${error.id}`;
message.textContent = error.message;
message.className = this.className;
if (element.querySelectorAll('.' + this.className).length === 0) {
message.className += ' ' + this.classNameFirst;
}
message.style.opacity = 0;
element.appendChild(message, element.nextSibling);
window.getComputedStyle(message).opacity;
message.style.opacity = 1;
}
removeMessage(element, error) {
let message = element.querySelector(`#md-input-validation-${error.id}`);
if (message) {
element.removeChild(message);
}
}
}
@customAttribute('md-waves')
@inject(Element)
Expand Down
7 changes: 6 additions & 1 deletion dist/commonjs/validation/validationRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ var MaterializeFormValidationRenderer = exports.MaterializeFormValidationRendere
if (!selectWrapper) {
return;
}
this.removeMessage(selectWrapper, error);

if ($(selectWrapper.parentElement).children().hasClass('md-input-validation')) {
this.removeMessage(selectWrapper.parentElement, error);
} else {
this.removeMessage(selectWrapper, error);
}

var _input2 = selectWrapper.querySelector('input');
if (_input2 && selectWrapper.querySelectorAll('.' + this.className).length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion dist/dev/dist/dev/validation/validationRenderer.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion dist/dev/validation/validationRenderer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8ad8e75

Please sign in to comment.