Last active
August 29, 2015 14:07
-
-
Save Batistleman/3ebf2bcf6f4baf877ea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="raphael.savage.js" ></script> | |
<script type="text/javascript"> | |
$(function() { | |
// Connect the div to a Savage.Editor instance. | |
var savageEditor = new Savage.Editor("savage-editor"); | |
// When the get json button is clicked: | |
$("#savage-editor-get-json").on("click", function(){ | |
var jsonRepresentation = savageEditor.saveToJSON(); | |
// jsonRepresentation will now contain the full svg data of the editor. You could store this in a database. | |
}); | |
$("#savage-editor-load-json").on("click", function(){ | |
// you can retreive the json description from your database, or write something manually: | |
var jsonRepresentation = '{"objects":[{"type":"arrow","start":{"x":129,"y":196},"stop":{"x":264,"y":195},"color":"#ee0000"}]}'; | |
// clear the editor if you want | |
savageEditor.clearEditor(); | |
// load the json into the editor. | |
savageEditor.loadFromJSON(jsonRepresentation); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment