demo-helper-mootools.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * This file contains the JS that handles the first init of each MooTools demonstration, and also switching
  3. * between render modes. it also initialises ".window" elements to be draggable. from jsPlumb 1.3.4
  4. * elements are no longer initialised as draggable automatically.
  5. */
  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. $$(".rmode").each(function(e) { e.removeClass("selected"); });
  14. $$(".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. $$(disableList).each(function(e) {
  17. e.set("disabled", true);
  18. });
  19. jsPlumbDemo.init();
  20. };
  21. $$(".rmode").each(function(r) {
  22. r.addEvent("click", function() {
  23. var desiredMode = $(this).get("mode");
  24. if (jsPlumbDemo.reset) jsPlumbDemo.reset();
  25. jsPlumb.reset();
  26. resetRenderMode(desiredMode);
  27. });
  28. });
  29. resetRenderMode(jsPlumb.SVG);
  30. });