demo-helper-jquery.js 899 B

1234567891011121314151617181920212223242526272829
  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. // chrome fix.
  7. document.onselectstart = function () { return false; };
  8. // render mode
  9. var resetRenderMode = function(desiredMode) {
  10. var newMode = jsPlumb.setRenderMode(desiredMode);
  11. $(".rmode").removeClass("selected");
  12. $(".rmode[mode='" + newMode + "']").addClass("selected");
  13. var disableList = (newMode === jsPlumb.VML) ? ".rmode[mode='canvas'],.rmode[mode='svg']" : ".rmode[mode='vml']";
  14. $(disableList).attr("disabled", true);
  15. jsPlumbDemo.init();
  16. };
  17. $(".rmode").bind("click", function() {
  18. var desiredMode = $(this).attr("mode");
  19. if (jsPlumbDemo.reset) jsPlumbDemo.reset();
  20. jsPlumb.reset();
  21. resetRenderMode(desiredMode);
  22. });
  23. resetRenderMode(jsPlumb.CANVAS);
  24. });