From 30e602a7400f3b38918a55f1470610b8d4ee49d7 Mon Sep 17 00:00:00 2001
From: Jason Croft
Date: Thu, 12 May 2016 12:28:08 -0400
Subject: Enable snippet exporting.
---
public/js/index.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 56 insertions(+), 5 deletions(-)
(limited to 'public/js')
diff --git a/public/js/index.js b/public/js/index.js
index 199c678e..bdb9d478 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -554,8 +554,8 @@ var ui = {
markdown: $(".ui-view-area .markdown-body")
},
modal: {
- snippetProjects: $("#snippetImportModalProjects"),
- snippetSnippets: $("#snippetImportModalSnippets")
+ snippetImportProjects: $("#snippetImportModalProjects"),
+ snippetImportSnippets: $("#snippetImportModalSnippets")
}
};
@@ -1150,7 +1150,33 @@ ui.toolbar.export.googleDrive.click(function (e) {
//export to gist
ui.toolbar.export.gist.attr("href", noteurl + "/gist");
//export to snippet
-ui.toolbar.export.snippet.attr("href", noteurl + "/snippet");
+ui.toolbar.export.snippet.click(function() {
+ $.get(serverurl + '/gitlab')
+ .success(function (data) {
+ $("#snippetExportModalAccessToken").val(data.accesstoken);
+ $("#snippetExportModalBaseURL").val(data.baseURL);
+ $("#snippetExportModalLoading").hide();
+ $("#snippetExportModal").modal('toggle');
+ $("#snippetExportModalProjects").find('option').remove().end().append('');
+ if (data.projects) {
+ data.projects.sort(function(a,b) {
+ return (a.path_with_namespace < b.path_with_namespace) ? -1 : ((a.path_with_namespace > b.path_with_namespace) ? 1 : 0);
+ });
+ data.projects.forEach(function(project) {
+ $('