demo-helper-yui3.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. jsPlumb.DemoList.init();
  10. // render mode
  11. var resetRenderMode = function(desiredMode) {
  12. var newMode = jsPlumb.setRenderMode(desiredMode);
  13. Y.all(".rmode").each(function(e) { e.removeClass("selected"); });
  14. Y.all(".rmode[mode='" + newMode + "']").each(function(e) { e.addClass("selected"); });
  15. var disableList = (newMode === jsPlumb.VML) ? ".rmode[mode='canvas'],.rmode[mode='svg']" : ".rmode[mode='vml']";
  16. Y.all(disableList).each(function(e) {
  17. e.setAttribute("disabled", true)
  18. });
  19. jsPlumbDemo.init();
  20. };
  21. Y.all(".rmode").each(function(r) {
  22. r.on("click", function() {
  23. var desiredMode = r.getAttribute("mode");
  24. if (jsPlumbDemo.reset) jsPlumbDemo.reset();
  25. jsPlumb.reset();
  26. resetRenderMode(desiredMode);
  27. });
  28. });
  29. resetRenderMode(jsPlumb.SVG);
  30. });
  31. });