{"action":"created","comment":{"url":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments/39316882","id":39316882,"diff_hunk":"@@ -0,0 +1,562 @@\n+var Backbone = require(\"backbone\");\n+var _ = require(\"underscore\");\n+var ExerciseModels = require(\"./models\");\n+var $ = require(\"jquery\");\n+var Quill = require(\"quilljs\");\n+var Dropzone = require(\"dropzone\");\n+var get_cookie = require(\"utils/get_cookie\");\n+var UndoManager = require(\"backbone-undo\");\n+var JSZip = require(\"jszip\");\n+var fileSaver = require(\"browser-filesaver\");\n+var JSZipUtils = require(\"jszip-utils\");\n+\n+require(\"../../less/exercises.less\");\n+require(\"quilljs/dist/quill.snow.css\");\n+require(\"dropzone/dist/dropzone.css\");\n+\n+var ExerciseListView = Backbone.View.extend({\n+\n+    initialize: function() {\n+        this.render();\n+        this.listenTo(this.collection, \"add\", this.render);\n+        this.listenTo(this.collection, \"remove\", this.render);\n+    },\n+\n+    events: {\n+        \"click .create\": \"add_exercise\",\n+        \"click .delete\": \"delete_exercise\"\n+    },\n+\n+    template: require(\"./hbtemplates/exercise_list.handlebars\"),\n+\n+    render: function (){\n+        this.$el.html(this.template({exercise_list: this.collection.toJSON()}))\n+    },\n+\n+    add_exercise: function() {\n+        this.collection.create();\n+    },\n+\n+    delete_exercise: function(ev) {\n+        var id = ev.currentTarget.value;\n+        var model = this.collection.get(id);\n+        model.destroy();\n+        return false;\n+    }\n+});\n+\n+var FileUploadView = Backbone.View.extend({\n+\n+    initialize: function(options) {\n+        _.bindAll(this, \"file_uploaded\");\n+        this.callback = options.callback;\n+        this.modal = options.modal;\n+        this.render();\n+    },\n+\n+    template: require(\"./hbtemplates/file_upload.handlebars\"),\n+\n+    modal_template: require(\"./hbtemplates/file_upload_modal.handlebars\"),\n+\n+    render: function() {\n+\n+        if (this.modal) {\n+            this.$el.html(this.modal_template());\n+            this.$(\".modal-body\").append(this.template());\n+            $(\"body\").append(this.el);\n+            this.$(\".modal\").modal({show: true});\n+            this.$(\".modal\").on(\"hide.bs.modal\", this.close);\n+        } else {\n+            this.$el.html(this.template());\n+        }\n+\n+        // TODO parameterize to allow different file uploads depending on initialization.\n+        this.dropzone = new Dropzone(this.$(\"#dropzone\").get(0), {maxFiles: 1, clickable: [\"#dropzone\", \".fileinput-button\"], acceptedFiles: \"image/*\", url: window.Urls.file_upload(), headers: {\"X-CSRFToken\": get_cookie(\"csrftoken\")}});\n+        this.dropzone.on(\"success\", this.file_uploaded);\n+\n+    },\n+\n+    file_uploaded: function(file) {\n+        this.callback(JSON.parse(file.xhr.response).filename);\n+        this.close();\n+    },\n+\n+    close: function() {\n+        if (this.modal) {\n+            this.$(\".modal\").modal('hide');\n+        }\n+        this.remove();\n+    }\n+});\n+\n+var EditorView = Backbone.View.extend({\n+\n+    tagName: \"div\",\n+\n+    initialize: function(options) {\n+        _.bindAll(this, \"return_markdown\", \"add_image\", \"deactivate_editor\", \"activate_editor\", \"save_and_close\", \"save\", \"render\");\n+        this.edit_key = options.edit_key;\n+        this.editing = false;\n+        this.render();\n+        this.listenTo(this.model, \"change:\" + this.edit_key, this.render);\n+    },\n+\n+    events: {\n+        \"click .ql-image\": \"add_image_popup\"\n+    },\n+\n+    add_image_popup: function() {\n+        var view = new FileUploadView({callback: this.add_image, modal: true});\n+    },\n+\n+    add_image: function(filename) {\n+        this.editor.insertEmbed(this.editor.getSelection() !== null ? this.editor.getSelection().start : this.editor.getLength(), \"image\", \"/media/\" + filename);\n+        this.save();\n+    },\n+\n+    edit_template: require(\"./hbtemplates/editor.handlebars\"),\n+\n+    view_template: require(\"./hbtemplates/editor_view.handlebars\"),\n+\n+    render: function() {\n+        if (this.editing) {\n+            if (!this.setting_model) {\n+                this.render_editor();\n+            }\n+        } else {\n+            this.render_content();\n+        }\n+        this.setting_model = false;\n+    },\n+\n+    render_content: function() {\n+        this.$el.html(this.view_template({content: this.model.get(this.edit_key)}));\n+    },\n+\n+    render_editor: function() {\n+        this.editor.setHTML(this.view_template({content: this.model.get(this.edit_key)}));\n+    },\n+\n+    activate_editor: function() {\n+        this.$el.html(this.edit_template());\n+        this.editor = new Quill(this.$(\".editor\")[0], {\n+            modules: {\n+                'toolbar': { container: this.$('#toolbar')[0] }\n+            },\n+            theme: 'snow'\n+        });\n+        this.render_editor();\n+        this.editor.on(\"text-change\", _.debounce(this.save, 500));\n+        this.editing = true;\n+    },\n+\n+    deactivate_editor: function() {\n+        delete this.editor;\n+        this.editing = false;\n+        this.render();\n+    },\n+\n+    toggle_editor: function() {\n+        if (this.editor) {\n+            this.deactivate_editor();\n+        } else {\n+            this.activate_editor();\n+        }\n+    },\n+\n+    save: function(delta, source) {","path":"contentcuration/contentcuration/static/js/exercise_creation/views.js","position":176,"original_position":167,"commit_id":"7c1cdd5326dd39a65b47e4a13164bd7239ea0976","original_commit_id":"87dae792a681604210ca57a9bcef1b95ed3faa78","user":{"login":"rtibbles","id":1680573,"avatar_url":"https://avatars.githubusercontent.com/u/1680573?v=3","gravatar_id":"","url":"https://api.github.com/users/rtibbles","html_url":"https://github.com/rtibbles","followers_url":"https://api.github.com/users/rtibbles/followers","following_url":"https://api.github.com/users/rtibbles/following{/other_user}","gists_url":"https://api.github.com/users/rtibbles/gists{/gist_id}","starred_url":"https://api.github.com/users/rtibbles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtibbles/subscriptions","organizations_url":"https://api.github.com/users/rtibbles/orgs","repos_url":"https://api.github.com/users/rtibbles/repos","events_url":"https://api.github.com/users/rtibbles/events{/privacy}","received_events_url":"https://api.github.com/users/rtibbles/received_events","type":"User","site_admin":false},"body":"Added comment to this effect.","created_at":"2015-09-11T21:00:14Z","updated_at":"2015-09-11T21:00:14Z","html_url":"https://github.com/fle-internal/content-curation/pull/15#discussion_r39316882","pull_request_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments/39316882"},"html":{"href":"https://github.com/fle-internal/content-curation/pull/15#discussion_r39316882"},"pull_request":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/fle-internal/content-curation/pulls/15","id":44613725,"html_url":"https://github.com/fle-internal/content-curation/pull/15","diff_url":"https://github.com/fle-internal/content-curation/pull/15.diff","patch_url":"https://github.com/fle-internal/content-curation/pull/15.patch","issue_url":"https://api.github.com/repos/fle-internal/content-curation/issues/15","number":15,"state":"open","locked":false,"title":"Exercise creation MVP","user":{"login":"rtibbles","id":1680573,"avatar_url":"https://avatars.githubusercontent.com/u/1680573?v=3","gravatar_id":"","url":"https://api.github.com/users/rtibbles","html_url":"https://github.com/rtibbles","followers_url":"https://api.github.com/users/rtibbles/followers","following_url":"https://api.github.com/users/rtibbles/following{/other_user}","gists_url":"https://api.github.com/users/rtibbles/gists{/gist_id}","starred_url":"https://api.github.com/users/rtibbles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtibbles/subscriptions","organizations_url":"https://api.github.com/users/rtibbles/orgs","repos_url":"https://api.github.com/users/rtibbles/repos","events_url":"https://api.github.com/users/rtibbles/events{/privacy}","received_events_url":"https://api.github.com/users/rtibbles/received_events","type":"User","site_admin":false},"body":"Summary of features:\r\n* Create, edit, and modify exercises and nested assessment items.\r\n* Upload images\r\n* Export exercise as .exercise file that is a zip that contains all relevant json and image files.\r\n\r\n@jtamiace @jamalex @MCGallaspy ","created_at":"2015-09-09T23:41:21Z","updated_at":"2015-09-11T21:00:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"53bddd54b8cc79e89bd4cae75ef4b745e1428900","assignee":{"login":"MCGallaspy","id":8888020,"avatar_url":"https://avatars.githubusercontent.com/u/8888020?v=3","gravatar_id":"","url":"https://api.github.com/users/MCGallaspy","html_url":"https://github.com/MCGallaspy","followers_url":"https://api.github.com/users/MCGallaspy/followers","following_url":"https://api.github.com/users/MCGallaspy/following{/other_user}","gists_url":"https://api.github.com/users/MCGallaspy/gists{/gist_id}","starred_url":"https://api.github.com/users/MCGallaspy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MCGallaspy/subscriptions","organizations_url":"https://api.github.com/users/MCGallaspy/orgs","repos_url":"https://api.github.com/users/MCGallaspy/repos","events_url":"https://api.github.com/users/MCGallaspy/events{/privacy}","received_events_url":"https://api.github.com/users/MCGallaspy/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/15/commits","review_comments_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/15/comments","review_comment_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fle-internal/content-curation/issues/15/comments","statuses_url":"https://api.github.com/repos/fle-internal/content-curation/statuses/7c1cdd5326dd39a65b47e4a13164bd7239ea0976","head":{"label":"rtibbles:exercise_creation","ref":"exercise_creation","sha":"7c1cdd5326dd39a65b47e4a13164bd7239ea0976","user":{"login":"rtibbles","id":1680573,"avatar_url":"https://avatars.githubusercontent.com/u/1680573?v=3","gravatar_id":"","url":"https://api.github.com/users/rtibbles","html_url":"https://github.com/rtibbles","followers_url":"https://api.github.com/users/rtibbles/followers","following_url":"https://api.github.com/users/rtibbles/following{/other_user}","gists_url":"https://api.github.com/users/rtibbles/gists{/gist_id}","starred_url":"https://api.github.com/users/rtibbles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtibbles/subscriptions","organizations_url":"https://api.github.com/users/rtibbles/orgs","repos_url":"https://api.github.com/users/rtibbles/repos","events_url":"https://api.github.com/users/rtibbles/events{/privacy}","received_events_url":"https://api.github.com/users/rtibbles/received_events","type":"User","site_admin":false},"repo":{"id":38903347,"name":"content-curation","full_name":"rtibbles/content-curation","owner":{"login":"rtibbles","id":1680573,"avatar_url":"https://avatars.githubusercontent.com/u/1680573?v=3","gravatar_id":"","url":"https://api.github.com/users/rtibbles","html_url":"https://github.com/rtibbles","followers_url":"https://api.github.com/users/rtibbles/followers","following_url":"https://api.github.com/users/rtibbles/following{/other_user}","gists_url":"https://api.github.com/users/rtibbles/gists{/gist_id}","starred_url":"https://api.github.com/users/rtibbles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtibbles/subscriptions","organizations_url":"https://api.github.com/users/rtibbles/orgs","repos_url":"https://api.github.com/users/rtibbles/repos","events_url":"https://api.github.com/users/rtibbles/events{/privacy}","received_events_url":"https://api.github.com/users/rtibbles/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rtibbles/content-curation","description":"","fork":true,"url":"https://api.github.com/repos/rtibbles/content-curation","forks_url":"https://api.github.com/repos/rtibbles/content-curation/forks","keys_url":"https://api.github.com/repos/rtibbles/content-curation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rtibbles/content-curation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rtibbles/content-curation/teams","hooks_url":"https://api.github.com/repos/rtibbles/content-curation/hooks","issue_events_url":"https://api.github.com/repos/rtibbles/content-curation/issues/events{/number}","events_url":"https://api.github.com/repos/rtibbles/content-curation/events","assignees_url":"https://api.github.com/repos/rtibbles/content-curation/assignees{/user}","branches_url":"https://api.github.com/repos/rtibbles/content-curation/branches{/branch}","tags_url":"https://api.github.com/repos/rtibbles/content-curation/tags","blobs_url":"https://api.github.com/repos/rtibbles/content-curation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rtibbles/content-curation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rtibbles/content-curation/git/refs{/sha}","trees_url":"https://api.github.com/repos/rtibbles/content-curation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rtibbles/content-curation/statuses/{sha}","languages_url":"https://api.github.com/repos/rtibbles/content-curation/languages","stargazers_url":"https://api.github.com/repos/rtibbles/content-curation/stargazers","contributors_url":"https://api.github.com/repos/rtibbles/content-curation/contributors","subscribers_url":"https://api.github.com/repos/rtibbles/content-curation/subscribers","subscription_url":"https://api.github.com/repos/rtibbles/content-curation/subscription","commits_url":"https://api.github.com/repos/rtibbles/content-curation/commits{/sha}","git_commits_url":"https://api.github.com/repos/rtibbles/content-curation/git/commits{/sha}","comments_url":"https://api.github.com/repos/rtibbles/content-curation/comments{/number}","issue_comment_url":"https://api.github.com/repos/rtibbles/content-curation/issues/comments{/number}","contents_url":"https://api.github.com/repos/rtibbles/content-curation/contents/{+path}","compare_url":"https://api.github.com/repos/rtibbles/content-curation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rtibbles/content-curation/merges","archive_url":"https://api.github.com/repos/rtibbles/content-curation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rtibbles/content-curation/downloads","issues_url":"https://api.github.com/repos/rtibbles/content-curation/issues{/number}","pulls_url":"https://api.github.com/repos/rtibbles/content-curation/pulls{/number}","milestones_url":"https://api.github.com/repos/rtibbles/content-curation/milestones{/number}","notifications_url":"https://api.github.com/repos/rtibbles/content-curation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rtibbles/content-curation/labels{/name}","releases_url":"https://api.github.com/repos/rtibbles/content-curation/releases{/id}","created_at":"2015-07-10T21:43:18Z","updated_at":"2015-07-17T16:55:58Z","pushed_at":"2015-09-11T20:59:37Z","git_url":"git://github.com/rtibbles/content-curation.git","ssh_url":"git@github.com:rtibbles/content-curation.git","clone_url":"https://github.com/rtibbles/content-curation.git","svn_url":"https://github.com/rtibbles/content-curation","homepage":null,"size":487,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fle-internal:master","ref":"master","sha":"87c489038095edfb650d049afefa8c95b8a8ebde","user":{"login":"fle-internal","id":6564452,"avatar_url":"https://avatars.githubusercontent.com/u/6564452?v=3","gravatar_id":"","url":"https://api.github.com/users/fle-internal","html_url":"https://github.com/fle-internal","followers_url":"https://api.github.com/users/fle-internal/followers","following_url":"https://api.github.com/users/fle-internal/following{/other_user}","gists_url":"https://api.github.com/users/fle-internal/gists{/gist_id}","starred_url":"https://api.github.com/users/fle-internal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fle-internal/subscriptions","organizations_url":"https://api.github.com/users/fle-internal/orgs","repos_url":"https://api.github.com/users/fle-internal/repos","events_url":"https://api.github.com/users/fle-internal/events{/privacy}","received_events_url":"https://api.github.com/users/fle-internal/received_events","type":"Organization","site_admin":false},"repo":{"id":35178170,"name":"content-curation","full_name":"fle-internal/content-curation","owner":{"login":"fle-internal","id":6564452,"avatar_url":"https://avatars.githubusercontent.com/u/6564452?v=3","gravatar_id":"","url":"https://api.github.com/users/fle-internal","html_url":"https://github.com/fle-internal","followers_url":"https://api.github.com/users/fle-internal/followers","following_url":"https://api.github.com/users/fle-internal/following{/other_user}","gists_url":"https://api.github.com/users/fle-internal/gists{/gist_id}","starred_url":"https://api.github.com/users/fle-internal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fle-internal/subscriptions","organizations_url":"https://api.github.com/users/fle-internal/orgs","repos_url":"https://api.github.com/users/fle-internal/repos","events_url":"https://api.github.com/users/fle-internal/events{/privacy}","received_events_url":"https://api.github.com/users/fle-internal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fle-internal/content-curation","description":"","fork":false,"url":"https://api.github.com/repos/fle-internal/content-curation","forks_url":"https://api.github.com/repos/fle-internal/content-curation/forks","keys_url":"https://api.github.com/repos/fle-internal/content-curation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fle-internal/content-curation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fle-internal/content-curation/teams","hooks_url":"https://api.github.com/repos/fle-internal/content-curation/hooks","issue_events_url":"https://api.github.com/repos/fle-internal/content-curation/issues/events{/number}","events_url":"https://api.github.com/repos/fle-internal/content-curation/events","assignees_url":"https://api.github.com/repos/fle-internal/content-curation/assignees{/user}","branches_url":"https://api.github.com/repos/fle-internal/content-curation/branches{/branch}","tags_url":"https://api.github.com/repos/fle-internal/content-curation/tags","blobs_url":"https://api.github.com/repos/fle-internal/content-curation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fle-internal/content-curation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fle-internal/content-curation/git/refs{/sha}","trees_url":"https://api.github.com/repos/fle-internal/content-curation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fle-internal/content-curation/statuses/{sha}","languages_url":"https://api.github.com/repos/fle-internal/content-curation/languages","stargazers_url":"https://api.github.com/repos/fle-internal/content-curation/stargazers","contributors_url":"https://api.github.com/repos/fle-internal/content-curation/contributors","subscribers_url":"https://api.github.com/repos/fle-internal/content-curation/subscribers","subscription_url":"https://api.github.com/repos/fle-internal/content-curation/subscription","commits_url":"https://api.github.com/repos/fle-internal/content-curation/commits{/sha}","git_commits_url":"https://api.github.com/repos/fle-internal/content-curation/git/commits{/sha}","comments_url":"https://api.github.com/repos/fle-internal/content-curation/comments{/number}","issue_comment_url":"https://api.github.com/repos/fle-internal/content-curation/issues/comments{/number}","contents_url":"https://api.github.com/repos/fle-internal/content-curation/contents/{+path}","compare_url":"https://api.github.com/repos/fle-internal/content-curation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fle-internal/content-curation/merges","archive_url":"https://api.github.com/repos/fle-internal/content-curation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fle-internal/content-curation/downloads","issues_url":"https://api.github.com/repos/fle-internal/content-curation/issues{/number}","pulls_url":"https://api.github.com/repos/fle-internal/content-curation/pulls{/number}","milestones_url":"https://api.github.com/repos/fle-internal/content-curation/milestones{/number}","notifications_url":"https://api.github.com/repos/fle-internal/content-curation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fle-internal/content-curation/labels{/name}","releases_url":"https://api.github.com/repos/fle-internal/content-curation/releases{/id}","created_at":"2015-05-06T19:18:28Z","updated_at":"2015-07-17T17:25:30Z","pushed_at":"2015-09-11T20:59:37Z","git_url":"git://github.com/fle-internal/content-curation.git","ssh_url":"git@github.com:fle-internal/content-curation.git","clone_url":"https://github.com/fle-internal/content-curation.git","svn_url":"https://github.com/fle-internal/content-curation","homepage":null,"size":745,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/15"},"html":{"href":"https://github.com/fle-internal/content-curation/pull/15"},"issue":{"href":"https://api.github.com/repos/fle-internal/content-curation/issues/15"},"comments":{"href":"https://api.github.com/repos/fle-internal/content-curation/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/fle-internal/content-curation/statuses/7c1cdd5326dd39a65b47e4a13164bd7239ea0976"}}}}