demo-helper-jquery.js 1002 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * This file contains the JS that handles the first init of each jQuery demonstration, and also switching
  3. * between render modes.
  4. */
  5. jsPlumb.bind("ready", function() {
  6. jsPlumb.DemoList.init();
  7. // chrome fix.
  8. document.onselectstart = function () { return false; };
  9. // render mode
  10. var resetRenderMode = function(desiredMode) {
  11. var newMode = jsPlumb.setRenderMode(desiredMode);
  12. $(".rmode").removeClass("selected");
  13. $(".rmode[mode='" + newMode + "']").addClass("selected");
  14. var disableList = (newMode === jsPlumb.VML) ? ".rmode[mode='canvas'],.rmode[mode='svg']" : ".rmode[mode='vml']";
  15. $(disableList).attr("disabled", true);
  16. jsPlumbDemo.init();
  17. };
  18. $(".rmode").bind("click", function() {
  19. var desiredMode = $(this).attr("mode");
  20. if (jsPlumbDemo.reset) jsPlumbDemo.reset();
  21. jsPlumb.reset();
  22. resetRenderMode(desiredMode);
  23. });
  24. // explanation div is draggable
  25. $("#explanation,.renderMode").draggable();
  26. resetRenderMode(jsPlumb.SVG);
  27. });