validation.js 897 B

1234567891011121314151617181920
  1. function validateSources(list) {
  2. return list.reduce(function(acc,x) {
  3. var event = new CustomEvent('validation');
  4. event.initCustomEvent('validation',true,true,querySourceRaw(x));
  5. var el = qi(x),
  6. listener = el && el.validation,
  7. res = !listener || listener && el.dispatchEvent(event);
  8. if (!res) { console.log("Validation failed:" + x); }
  9. if (el) el.style.background = res ? '' : 'pink';
  10. return res && acc; },true); }
  11. (function () {
  12. function CustomEvent ( event, params ) {
  13. params = params || { bubbles: false, cancelable: false, detail: undefined };
  14. var evt = document.createEvent( 'CustomEvent' );
  15. evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
  16. return evt; };
  17. CustomEvent.prototype = window.Event.prototype;
  18. window.CustomEvent = CustomEvent; })();