fractals/p5/p5.dom.min.js

1 line
20 KiB
JavaScript
Raw Normal View History

2019-01-22 16:38:35 +00:00
/*! p5.js v0.7.2 September 02, 2018 */ !function(a,b){"function"==typeof define&&define.amd?define("p5.dom",["p5"],function(a){b(a)}):b("object"==typeof exports?require("../p5"):a.p5)}(this,function(a){function b(b){var c=document;return"string"==typeof b&&"#"===b[0]?(b=b.slice(1),c=document.getElementById(b)||document):b instanceof a.Element?c=b.elt:b instanceof HTMLElement&&(c=b),c}function c(b,c,d){(c._userNode?c._userNode:document.body).appendChild(b);var e=d?new a.MediaElement(b,c):new a.Element(b,c);return c._elements.push(e),e}function d(a,b,d,e){var f=document.createElement(b);"string"==typeof(d=d||"")&&(d=[d]);for(var g=0;g<d.length;g++){var h=document.createElement("source");h.src=d[g],f.appendChild(h)}if(void 0!==e){var i=function(){e(),f.removeEventListener("canplaythrough",i)};f.addEventListener("canplaythrough",i)}var j=c(f,a,!0);return j.loadedmetadata=!1,f.addEventListener("loadedmetadata",function(){j.width=f.videoWidth,j.height=f.videoHeight,0===j.elt.width&&(j.elt.width=f.videoWidth),0===j.elt.height&&(j.elt.height=f.videoHeight),j.presetPlaybackRate&&(j.elt.playbackRate=j.presetPlaybackRate,delete j.presetPlaybackRate),j.loadedmetadata=!0}),j}a.prototype.select=function(c,d){a._validateParameters("select",arguments);var e=null,f=b(d);return"."===c[0]?(c=c.slice(1),e=f.getElementsByClassName(c),e=e.length?e[0]:null):"#"===c[0]?(c=c.slice(1),e=f.getElementById(c)):(e=f.getElementsByTagName(c),e=e.length?e[0]:null),e?this._wrapElement(e):null},a.prototype.selectAll=function(c,d){a._validateParameters("selectAll",arguments);var e,f=[],g=b(d);if("."===c[0]?(c=c.slice(1),e=g.getElementsByClassName(c)):e=g.getElementsByTagName(c),e)for(var h=0;h<e.length;h++){var i=this._wrapElement(e[h]);f.push(i)}return f},a.prototype._wrapElement=function(b){var c=Array.prototype.slice.call(b.children);if("INPUT"===b.tagName&&"checkbox"===b.type){var d=new a.Element(b,this);return d.checked=function(){return 0===arguments.length?this.elt.checked:(arguments[0]?this.elt.checked=!0:this.elt.checked=!1,this)},d}return"VIDEO"===b.tagName||"AUDIO"===b.tagName?new a.MediaElement(b,this):"SELECT"===b.tagName?this.createSelect(new a.Element(b,this)):c.length>0&&c.every(function(a){return"INPUT"===a.tagName||"LABEL"===a.tagName})?this.createRadio(new a.Element(b,this)):new a.Element(b,this)},a.prototype.removeElements=function(b){a._validateParameters("removeElements",arguments);for(var c=0;c<this._elements.length;c++)this._elements[c].elt instanceof HTMLCanvasElement||this._elements[c].remove()},["div","p","span"].forEach(function(b){var d="create"+b.charAt(0).toUpperCase()+b.slice(1);a.prototype[d]=function(a){var d=document.createElement(b);return d.innerHTML=void 0===a?"":a,c(d,this)}}),a.prototype.createImg=function(){a._validateParameters("createImg",arguments);var b,d=document.createElement("img"),e=arguments,f=function(){b.width=d.offsetWidth||d.width,b.height=d.offsetHeight||d.height,e.length>1&&"function"==typeof e[1]?(b.fn=e[1],b.fn()):e.length>1&&"function"==typeof e[2]&&(b.fn=e[2],b.fn())};return d.src=e[0],e.length>1&&"string"==typeof e[1]&&(d.alt=e[1]),d.onload=function(){f()},b=c(d,this)},a.prototype.createA=function(b,d,e){a._validateParameters("createA",arguments);var f=document.createElement("a");return f.href=b,f.innerHTML=d,e&&(f.target=e),c(f,this)},a.prototype.createSlider=function(b,d,e,f){a._validateParameters("createSlider",arguments);var g=document.createElement("input");return g.type="range",g.min=b,g.max=d,0===f?g.step=1e-18:f&&(g.step=f),"number"==typeof e&&(g.value=e),c(g,this)},a.prototype.createButton=function(b,d){a._validateParameters("createButton",arguments);var e=document.createElement("button");return e.innerHTML=b,d&&(e.value=d),c(e,this)},a.prototype.createCheckbox=function(){a._validateParameters("createCheckbox",arguments);var b=document.createElement("div"),d=document.createElement("input");d.type="checkbox",b.appendChild(d);var e=c(b,this);if(e.checked=function(){var a=e.elt.getElementsByTagName("input")[0];if(a){if(0===arguments.length)return a.checked;arguments[0]?a.checked=!0:a.check