demo-helper-yui3.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * This file contains the JS that handles the first init of each YUI3 demonstration, and also switching
  3. * between render modes.
  4. */
  5. YUI().use("node", function(Y) {
  6. jsPlumb.bind("ready", function() {
  7. // chrome fix.
  8. document.onselectstart = function () { return false; };
  9. // render mode
  10. var resetRenderMode = function(desiredMode) {
  11. var newMode = jsPlumb.setRenderMode(desiredMode);
  12. Y.all(".rmode").each(function(e) { e.removeClass("selected"); });
  13. Y.all(".rmode[mode='" + newMode + "']").each(function(e) { e.addClass("selected"); });
  14. var disableList = (newMode === jsPlumb.VML) ? ".rmode[mode='canvas'],.rmode[mode='svg']" : ".rmode[mode='vml']";
  15. Y.all(disableList).each(function(e) {
  16. e.setAttribute("disabled", true)
  17. });
  18. jsPlumbDemo.init();
  19. };
  20. Y.all(".rmode").each(function(r) {
  21. r.on("click", function() {
  22. var desiredMode = r.getAttribute("mode");
  23. if (jsPlumbDemo.reset) jsPlumbDemo.reset();
  24. jsPlumb.reset();
  25. resetRenderMode(desiredMode);
  26. });
  27. });
  28. resetRenderMode(jsPlumb.CANVAS);
  29. });
  30. });