{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/28277568","id":28277568,"diff_hunk":"@@ -495,6 +495,213 @@\n             }\n         });\n \n+        FieldViews.ImageFieldView = FieldViews.FieldView.extend({\n+\n+            fieldType: 'image',\n+\n+            templateSelector: '#field_image-tpl',\n+            uploadButtonSelector: '.upload-button-input',\n+\n+            titleAdd: gettext(\"Upload an image\"),\n+            titleEdit: gettext(\"Change image\"),\n+            titleRemove: gettext(\"Remove\"),\n+\n+            titleUploading: gettext(\"Uploading\"),\n+            titleRemoving: gettext(\"Removing\"),\n+\n+            titleImageAlt: '',\n+\n+            iconUpload: '<i class=\"icon fa fa-camera\" aria-hidden=\"true\"></i>',\n+            iconRemove: '<i class=\"icon fa fa-remove\" aria-hidden=\"true\"></i>',\n+            iconProgress: '<i class=\"icon fa fa-spinner fa-pulse fa-spin\" aria-hidden=\"true\"></i>',\n+\n+            errorMessage: gettext(\"An error has occurred. Refresh the page, and then try again.\"),\n+\n+            events: {\n+                'click .u-field-upload-button': 'clickedUploadButton',\n+                'click .u-field-remove-button': 'clickedRemoveButton',\n+                'click .upload-submit': 'clickedUploadButton'\n+            },\n+\n+            initialize: function (options) {\n+                this._super(options);\n+                _.bindAll(this, 'render', 'imageChangeSucceeded', 'imageChangeFailed', 'fileSelected',\n+                          'watchForPageUnload', 'onBeforeUnload');\n+                this.listenTo(this.model, \"change:\" + this.options.valueAttribute, this.render);\n+            },\n+\n+            render: function () {\n+                this.$el.html(this.template({\n+                    id: this.options.valueAttribute,\n+                    imageUrl: _.result(this, 'imageUrl'),\n+                    imageAltText: _.result(this, 'imageAltText'),\n+                    uploadButtonIcon: _.result(this, 'iconUpload'),\n+                    uploadButtonTitle: _.result(this, 'uploadButtonTitle'),\n+                    removeButtonIcon: _.result(this, 'iconRemove'),\n+                    removeButtonTitle: _.result(this, 'removeButtonTitle')\n+                }));\n+                this.updateButtonsVisibility();\n+                this.watchForPageUnload();\n+                return this;\n+            },\n+\n+            showErrorMessage: function (message) {\n+                return message;\n+            },\n+\n+            imageUrl: function () {\n+                return '';\n+            },\n+\n+            uploadButtonTitle: function () {\n+                if (this.isShowingPlaceholder()) {\n+                    return _.result(this, 'titleAdd')\n+                } else {\n+                    return _.result(this, 'titleEdit')\n+                }\n+            },\n+\n+            removeButtonTitle: function () {\n+                return this.titleRemove;\n+            },\n+\n+            isEditingAllowed: function () {\n+                return true\n+            },\n+\n+            isShowingPlaceholder: function () {\n+                return false;\n+            },\n+\n+            setUploadButtonVisibility: function (state) {\n+                this.$('.u-field-upload-button').css('display', state);\n+            },\n+\n+            setRemoveButtonVisibility: function (state) {\n+                this.$('.u-field-remove-button').css('display', state);\n+            },\n+\n+            updateButtonsVisibility: function () {\n+                if (!this.isEditingAllowed() || !this.options.editable) {\n+                    this.setUploadButtonVisibility('none');\n+                }\n+\n+                if (this.isShowingPlaceholder() || !this.options.editable) {\n+                    this.setRemoveButtonVisibility('none');\n+                }\n+            },\n+\n+            clickedUploadButton: function (e, data) {\n+                $(this.uploadButtonSelector).fileupload({\n+                    url: this.options.imageUploadUrl,\n+                    type: 'POST',\n+                    add: this.fileSelected,\n+                    done: this.imageChangeSucceeded,\n+                    fail: this.imageChangeFailed\n+                });\n+            },\n+\n+            clickedRemoveButton: function (e, data) {\n+                var view = this;\n+                this.setCurrentStatus('removing');\n+                this.setUploadButtonVisibility('none');\n+                this.showRemovalInProgressMessage();\n+                 $.ajax({\n+                    type: 'POST',\n+                    url: this.options.imageRemoveUrl,\n+                    success: function (data, status, xhr) {","path":"lms/static/js/views/fields.js","position":118,"original_position":118,"commit_id":"54ef36dda5331ffb639525ce53cf22645e030dbf","original_commit_id":"54ef36dda5331ffb639525ce53cf22645e030dbf","user":{"login":"andy-armstrong","id":5985072,"avatar_url":"https://avatars.githubusercontent.com/u/5985072?v=3","gravatar_id":"","url":"https://api.github.com/users/andy-armstrong","html_url":"https://github.com/andy-armstrong","followers_url":"https://api.github.com/users/andy-armstrong/followers","following_url":"https://api.github.com/users/andy-armstrong/following{/other_user}","gists_url":"https://api.github.com/users/andy-armstrong/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-armstrong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-armstrong/subscriptions","organizations_url":"https://api.github.com/users/andy-armstrong/orgs","repos_url":"https://api.github.com/users/andy-armstrong/repos","events_url":"https://api.github.com/users/andy-armstrong/events{/privacy}","received_events_url":"https://api.github.com/users/andy-armstrong/received_events","type":"User","site_admin":false},"body":"Nit: I prefer using promises now rather than passing in callbacks.","created_at":"2015-04-13T20:49:03Z","updated_at":"2015-04-13T20:49:03Z","html_url":"https://github.com/edx/edx-platform/pull/7629#discussion_r28277568","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/7629","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/28277568"},"html":{"href":"https://github.com/edx/edx-platform/pull/7629#discussion_r28277568"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7629"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/7629","id":32850249,"html_url":"https://github.com/edx/edx-platform/pull/7629","diff_url":"https://github.com/edx/edx-platform/pull/7629.diff","patch_url":"https://github.com/edx/edx-platform/pull/7629.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/7629","number":7629,"state":"open","locked":false,"title":"profile photo","user":{"login":"muhammad-ammar","id":6767924,"avatar_url":"https://avatars.githubusercontent.com/u/6767924?v=3","gravatar_id":"","url":"https://api.github.com/users/muhammad-ammar","html_url":"https://github.com/muhammad-ammar","followers_url":"https://api.github.com/users/muhammad-ammar/followers","following_url":"https://api.github.com/users/muhammad-ammar/following{/other_user}","gists_url":"https://api.github.com/users/muhammad-ammar/gists{/gist_id}","starred_url":"https://api.github.com/users/muhammad-ammar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muhammad-ammar/subscriptions","organizations_url":"https://api.github.com/users/muhammad-ammar/orgs","repos_url":"https://api.github.com/users/muhammad-ammar/repos","events_url":"https://api.github.com/users/muhammad-ammar/events{/privacy}","received_events_url":"https://api.github.com/users/muhammad-ammar/received_events","type":"User","site_admin":false},"body":"sandbox: http://tnl1538.m.sandbox.edx.org/","created_at":"2015-04-08T11:19:07Z","updated_at":"2015-04-13T20:49:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e6da32b2b51d561e928a8b6093d0af83f0c8ad0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/7629/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/7629/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/7629/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/54ef36dda5331ffb639525ce53cf22645e030dbf","head":{"label":"edx:usman/tnl1538-profile-photo","ref":"usman/tnl1538-profile-photo","sha":"54ef36dda5331ffb639525ce53cf22645e030dbf","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-04-13T20:48:15Z","pushed_at":"2015-04-13T20:48:15Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://openedx.org/","size":1885920,"stargazers_count":1860,"watchers_count":1860,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1059,"mirror_url":null,"open_issues_count":154,"forks":1059,"open_issues":154,"watchers":1860,"default_branch":"master"}},"base":{"label":"edx:usman/tnl1499-account-settings","ref":"usman/tnl1499-account-settings","sha":"8ed2931460108ef084158471c7eec0663f99d076","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-04-13T20:48:15Z","pushed_at":"2015-04-13T20:48:15Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://openedx.org/","size":1885920,"stargazers_count":1860,"watchers_count":1860,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1059,"mirror_url":null,"open_issues_count":154,"forks":1059,"open_issues":154,"watchers":1860,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7629"},"html":{"href":"https://github.com/edx/edx-platform/pull/7629"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/7629"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/7629/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7629/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/7629/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/54ef36dda5331ffb639525ce53cf22645e030dbf"}}}}