git @ Cat's Eye Technologies yoob.js / master eg / element-factory.html
master

Tree @master (Download .tar.gz)

element-factory.html @masterraw · history · blame

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>yoob/element-factory.js Demo</title>
</head>
<body>

<h1>yoob/element-factory.js Demo</h1>
<h4>Look at the browser's console to see the effect of some controls.</h4>

<div id="container"></div>

</body>
<script src="../src/yoob/element-factory.js"></script>
<script type="text/javascript">
  var container = document.getElementById('container');

  var p = yoob.makeParagraph(container, "This element was created by Javascript.");
  var panel = yoob.makePanel(container, "Collapsible Panel", false);
  yoob.makeButton(panel, "Click me!", function(e) {
      p.style.border = "1px solid black";
  });

  var select = yoob.makeSelect(panel, "Select:", [
      ['0', 'Zero'],
      ['1', 'One']
  ], function(key) {
      console.log(key);
  }, '1');

  var canvas = yoob.makeCanvas(container, 100, 100);
  canvas.style.border = "1px solid blue";

  yoob.makeLineBreak(container);

  yoob.makeRangeControl(container, {
      label: "Speed:",
      min: 0,
      max: 100,
      value: 50,
      callback: function(v) {
          console.log('new speed:' + v);
      }
  });

  yoob.makeLineBreak(container);

  var svg = yoob.makeSVG(container);
  svg.style.height = "300px";
  svg.style.width = "500px";
  svg.style.border = "1px solid red";

  yoob.makeSVGElem(this.svg, "rect", {
      x: 100,
      y: 100,
      width: 500,
      height: 200,
      fill: "#603020"
  });
  
  yoob.makeSVGElem(this.svg, "circle", {
      cx: 100,
      cy: 100,
      r: 50,
      fill: "black",
      stroke: "white"
  });
</script>