diff options
author | Jacob Schatz <jschatz1@gmail.com> | 2016-05-19 17:46:39 -0500 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2016-05-19 17:46:39 -0500 |
commit | 569c05e0d934a488c3bae480f9359418e902c31b (patch) | |
tree | 096f4e4fe78cd70aec16a7335aa3feef1881dbfc | |
parent | bd0cecfdf6ec504421b44f1174040c5003c13f65 (diff) | |
download | gitlab-ce-editable-issue-page.tar.gz |
add changable title.editable-issue-page
-rw-r--r-- | app/assets/javascripts/gl_change_element.js.coffee | 8 | ||||
-rw-r--r-- | app/assets/javascripts/issue.js.coffee | 20 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/detail_page.scss | 6 |
3 files changed, 34 insertions, 0 deletions
diff --git a/app/assets/javascripts/gl_change_element.js.coffee b/app/assets/javascripts/gl_change_element.js.coffee new file mode 100644 index 00000000000..f706b68d1ff --- /dev/null +++ b/app/assets/javascripts/gl_change_element.js.coffee @@ -0,0 +1,8 @@ +$.fn.changeElementType = (newType) -> + attrs = {} + $.each @[0].attributes, (i, attr) -> + attrs[attr.nodeName] = attr.nodeValue + return + @replaceWith -> + $('<' + newType + '/>', attrs).append $(this).contents() + return
\ No newline at end of file diff --git a/app/assets/javascripts/issue.js.coffee b/app/assets/javascripts/issue.js.coffee index 157361404e0..a538b54d7e5 100644 --- a/app/assets/javascripts/issue.js.coffee +++ b/app/assets/javascripts/issue.js.coffee @@ -9,6 +9,7 @@ class @Issue if $('a.btn-close').length @initTaskList() @initIssueBtnEventListeners() + @initEditableIssue() @initMergeRequests() @initRelatedBranches() @@ -18,6 +19,25 @@ class @Issue $('.detail-page-description .js-task-list-container').taskList('enable') $(document).on 'tasklist:changed', '.detail-page-description .js-task-list-container', @updateTaskList + initEditableIssue: -> + console.log('initEditableIssue') + # Rather than check permissions. It is cheaper to add through JS if possible. + $('.detail-page-description .title') + .on('mouseover', (e) -> + $(this).css('border', '1px solid #CCC') + ) + .on('mouseout', (e) -> + $(this).css('border', 'none') + ) + .on('click', (e) -> + $this = $(this) + oldText = $this.text().trim() + console.log(oldText) + $this.text('') + $this.changeElementType('input') + $this.val(oldText) + ) + initIssueBtnEventListeners: -> _this = @ issueFailMessage = 'Unable to update this issue at this time.' diff --git a/app/assets/stylesheets/pages/detail_page.scss b/app/assets/stylesheets/pages/detail_page.scss index 5e61e61d85c..b1131dae083 100644 --- a/app/assets/stylesheets/pages/detail_page.scss +++ b/app/assets/stylesheets/pages/detail_page.scss @@ -22,7 +22,13 @@ .title { margin: 0; font-size: 23px; + padding: 5px; color: $gl-gray-dark; + + &:hover { + padding: 4px; + cursor: text; + } } .description { |