diff -r ded85569cb98 -r 7de2652f7ee8 client/js/renderer/scene.js --- a/client/js/renderer/scene.js Fri May 16 17:36:21 2014 +0200 +++ b/client/js/renderer/scene.js Sun May 18 10:31:12 2014 +0200 @@ -1,5 +1,5 @@ -define(['jquery', 'underscore', 'requtils', 'renderer/miniframe'], function ($, _, requtils, MiniFrame) { +define(['jquery', 'underscore', 'filesaver', 'requtils', 'renderer/miniframe'], function ($, _, filesaver, requtils, MiniFrame) { 'use strict'; var Utils = requtils.getUtils(); @@ -255,6 +255,7 @@ bindClick(".Rk-AddEdge-Button", "addEdgeBtn"); bindClick(".Rk-Save-Button", "save"); bindClick(".Rk-Open-Button", "open"); + bindClick(".Rk-Export-Button", "exportProject"); this.$.find(".Rk-Bookmarklet-Button") /*jshint scripturl:true */ .attr("href","javascript:" + Utils._BOOKMARKLET_CODE(_renkan)) @@ -455,6 +456,7 @@ '
<%-translate("Add Node")%>
<% } %>' + '<% if (options.show_addedge_button) { %>
' + '
<%-translate("Add Edge")%>
<% } %>' + + '<% if (options.show_export_button) { %>
<%-translate("Download Project")%>
<% } %>' + '<% if (options.show_save_button) { %>
<% } %>' + '<% if (options.show_open_button) { %>
<%-translate("Open Project")%>
<% } %>' + '<% if (options.show_bookmarklet) { %>
' + @@ -1176,6 +1178,33 @@ } return false; }, + exportProject: function() { + var projectJSON = this.renkan.project.toJSON(), + downloadLink = document.createElement("a"), + projectId = projectJSON.id, + fileNameToSaveAs = projectId + ".json"; + + // clean ids + delete projectJSON.id; + _.each(projectJSON.nodes, function(e,i,l) { + delete e._id; + delete e.id; + }); + _.each(projectJSON.edges, function(e,i,l) { + delete e._id; + delete e.id; + }); + _.each(projectJSON.views, function(e,i,l) { + delete e._id; + delete e.id; + }); + projectJSON.users = []; + + var projectJSONStr = JSON.stringify(projectJSON, null, 2); + var blob = new Blob([projectJSONStr], {type: "application/json;charset=utf-8"}); + filesaver(blob,fileNameToSaveAs); + + }, foldBins: function() { var foldBinsButton = this.$.find(".Rk-Fold-Bins"), bins = this.renkan.$.find(".Rk-Bins");