summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-03-31 10:55:37 +0100
committerFatih Acet <acetfatih@gmail.com>2016-05-19 14:07:27 -0500
commit0b45cf55dddb66b7c6328bc6d5233d023c031e5c (patch)
tree9f55bf0b91bfcbfa44af03a89896d6abf0477432
parent4caf38a1d583f1561affc278ff0ddc0174e47b72 (diff)
downloadgitlab-ce-0b45cf55dddb66b7c6328bc6d5233d023c031e5c.tar.gz
Uses the same emoji-menu and just moves it around depending where it should be viewed
# Conflicts: # app/assets/javascripts/awards_handler.coffee # app/assets/stylesheets/pages/notes.scss # app/helpers/issues_helper.rb # app/views/projects/notes/_note.html.haml
-rw-r--r--app/assets/javascripts/awards_handler.coffee41
-rw-r--r--app/assets/javascripts/dispatcher.js.coffee2
-rw-r--r--app/assets/javascripts/lib/emoji_aliases.js.coffee.erb2
-rw-r--r--app/assets/stylesheets/pages/awards.scss2
-rw-r--r--app/assets/stylesheets/pages/notes.scss249
-rw-r--r--app/views/emoji_awards/_awards_block.html.haml14
-rw-r--r--app/views/projects/notes/_note.html.haml23
7 files changed, 155 insertions, 178 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee
index 105b0c34e95..9e3d9f09126 100644
--- a/app/assets/javascripts/awards_handler.coffee
+++ b/app/assets/javascripts/awards_handler.coffee
@@ -1,23 +1,23 @@
class @AwardsHandler
- constructor: (@aliases) ->
- $(".js-add-award").on "click", (event) =>
+ constructor: ->
+ @aliases = emojiAliases()
+
+ $(document).on "click", ".js-add-award", (event) =>
event.stopPropagation()
event.preventDefault()
- @showEmojiMenu()
+ @showEmojiMenu $(event.currentTarget)
$("html").on 'click', (event) ->
if !$(event.target).closest(".emoji-menu").length
if $(".emoji-menu").is(":visible")
$(".emoji-menu").removeClass "is-visible"
- $(".awards")
- .off "click"
+ $(document)
+ .off "click", ".js-emoji-btn"
.on "click", ".js-emoji-btn", @handleClick
- @renderFrequentlyUsedBlock()
-
- handleClick: (e) ->
+ handleClick: (e) =>
e.preventDefault()
$emojiBtn = $(e.currentTarget)
awardUrl = $emojiBtn.closest('.js-votes-block').data 'award-url'
@@ -26,8 +26,13 @@ class @AwardsHandler
.data "emoji"
@addAward awardUrl, emoji
- showEmojiMenu: ->
+ showEmojiMenu: ($addBtn) ->
if $(".emoji-menu").length
+ $holder = $addBtn.closest('.js-award-holder')
+
+ if $holder.find('.emoji-menu').length is 0
+ $(".emoji-menu").detach().appendTo $holder
+
if $(".emoji-menu").is ".is-visible"
$(".emoji-menu").removeClass "is-visible"
$("#emoji_search").blur()
@@ -35,10 +40,11 @@ class @AwardsHandler
$(".emoji-menu").addClass "is-visible"
$("#emoji_search").focus()
else
- $('.js-add-award').addClass "is-loading"
- $.get "/emojis", (response) =>
- $('.js-add-award').removeClass "is-loading"
- $(".js-award-holder").append response
+ $addBtn.addClass "is-loading"
+ $.get $addBtn.data('award-menu-url'), (response) =>
+ $addBtn.removeClass "is-loading"
+ $addBtn.closest('.js-award-holder').append response
+ @renderFrequentlyUsedBlock()
setTimeout =>
$(".emoji-menu").addClass "is-visible"
$("#emoji_search").focus()
@@ -128,7 +134,7 @@ class @AwardsHandler
</button>"
emoji_node = $(buttonHtml)
- .insertBefore(".js-award-holder")
+ .insertBefore(".js-award-holder:not(.js-award-action-btn)")
.find(".emoji-icon")
.data("emoji", emoji)
$('.award-control').tooltip()
@@ -173,16 +179,15 @@ class @AwardsHandler
if $.cookie('frequently_used_emojis')
frequently_used_emojis = @getFrequentlyUsedEmojis()
- ul = $("<ul>")
+ ul = $("<ul class='clearfix emoji-menu-list'>")
for emoji in frequently_used_emojis
- do (emoji) ->
- $(".emoji-menu-content [data-emoji='#{emoji}']").closest("li").clone().appendTo(ul)
+ $(".emoji-menu-content [data-emoji='#{emoji}']").closest("li").clone().appendTo(ul)
$("input.emoji-search").after(ul).after($("<h5>").text("Frequently used"))
setupSearch: ->
- $("input.emoji-search").keyup (ev) =>
+ $("input.emoji-search").on 'keyup', (ev) =>
term = $(ev.target).val()
# Clean previous search results
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
index f91aa3c5ad7..ff8bcf89918 100644
--- a/app/assets/javascripts/dispatcher.js.coffee
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -23,6 +23,7 @@ class Dispatcher
new Issue()
shortcut_handler = new ShortcutsIssuable()
new ZenMode()
+ window.awards_handler = new AwardsHandler()
when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show'
new Milestone()
when 'dashboard:todos:index'
@@ -53,6 +54,7 @@ class Dispatcher
new Diff()
shortcut_handler = new ShortcutsIssuable(true)
new ZenMode()
+ window.awards_handler = new AwardsHandler()
when "projects:merge_requests:diffs"
new Diff()
new ZenMode()
diff --git a/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb b/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb
new file mode 100644
index 00000000000..66f640a3cb7
--- /dev/null
+++ b/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb
@@ -0,0 +1,2 @@
+window.emojiAliases = ->
+ JSON.parse('<%= AwardEmoji.aliases.to_json %>')
diff --git a/app/assets/stylesheets/pages/awards.scss b/app/assets/stylesheets/pages/awards.scss
index 37bf38fa65d..c7c8d2dda45 100644
--- a/app/assets/stylesheets/pages/awards.scss
+++ b/app/assets/stylesheets/pages/awards.scss
@@ -107,7 +107,7 @@
}
&.is-loading {
- .award-control-icon {
+ .award-control-icon-normal {
display: none;
}
diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss
index a3e1ac13a43..411cd3cd230 100644
--- a/app/assets/stylesheets/pages/notes.scss
+++ b/app/assets/stylesheets/pages/notes.scss
@@ -20,15 +20,9 @@ ul.notes {
.timeline-content {
margin-left: 55px;
-
- &.timeline-content-form {
- @media (max-width: $screen-sm-max) {
- margin-left: 0;
- }
- }
}
- .note-created-ago, .note-updated-at {
+ .note_created_ago, .note-updated-at {
white-space: nowrap;
}
@@ -45,6 +39,53 @@ ul.notes {
}
}
+ .discussion-header,
+ .note-header {
+ @extend .cgray;
+
+ a:hover {
+ text-decoration: none;
+ }
+
+ .avatar {
+ float: left;
+ margin-right: 10px;
+ }
+
+ .discussion-last-update,
+ .note-last-update {
+ &:before {
+ content: "\00b7";
+ }
+
+ a {
+ color: $gl-gray;
+
+ &:hover {
+ text-decoration: underline;
+ }
+ }
+ }
+ .author {
+ color: #4c4e54;
+ margin-right: 3px;
+
+ &:hover {
+ color: $gl-link-color;
+ }
+ }
+ .author-username {
+ }
+
+ .note-role {
+ float: right;
+ margin-top: 1px;
+ border: 1px solid #bbb;
+ background-color: transparent;
+ color: $gl-gray;
+ }
+ }
+
.discussion-body {
padding-top: 15px;
}
@@ -58,7 +99,6 @@ ul.notes {
.note {
display: block;
position: relative;
- border-bottom: 1px solid $table-border-gray;
&.is-editting {
.note-header,
@@ -73,16 +113,16 @@ ul.notes {
}
.note-body {
- overflow: auto;
-
.note-text {
overflow: auto;
word-wrap: break-word;
@include md-typography;
// On diffs code should wrap nicely and not overflow
- code {
- white-space: pre-wrap;
+ pre {
+ code {
+ white-space: pre-wrap;
+ }
}
// Reset ul style types since we're nested inside a ul already
@@ -109,10 +149,6 @@ ul.notes {
border-color: darken(#f5f5f5, 8%);
margin: 10px 0;
}
-
- code {
- word-break: keep-all;
- }
}
}
@@ -120,6 +156,9 @@ ul.notes {
padding-bottom: 3px;
}
+ &:last-child {
+ border-bottom: 1px solid $border-color;
+ }
}
}
@@ -137,149 +176,60 @@ ul.notes {
font-family: $regular_font;
td {
- border: 1px solid $table-border-gray;
+ border: 1px solid #ddd;
border-left: none;
&.notes_line {
vertical-align: middle;
text-align: center;
padding: 10px 0;
- background: $background-color;
+ background: #fff;
color: $text-color;
}
-
&.notes_line2 {
text-align: center;
padding: 10px 0;
border-left: 1px solid #ddd !important;
}
-
&.notes_content {
- background-color: $background-color;
+ background-color: #fff;
border-width: 1px 0;
- padding: 0;
+ padding-top: 0;
vertical-align: top;
- white-space: normal;
-
- &.parallel {
+ &.parallel{
border-width: 1px;
}
-
- .notes {
- background-color: $white-light;
- }
-
- a code {
- top: 0;
- margin-right: 0;
- }
- }
- }
-}
-
-.discussion-header,
-.note-header {
- a {
- color: inherit;
-
- &:hover {
- color: $gl-link-color;
- text-decoration: none;
}
}
-
- .author_link {
- color: $gl-gray;
- }
-}
-
-.note-headline-light,
-.discussion-headline-light {
- color: $notes-light-color;
-}
-
-.discussion-headline-light {
- a {
- color: $gl-link-color;
- }
}
/**
* Actions for Discussions/Notes
*/
-.discussion-actions,
-.note-actions {
- float: right;
- margin-left: 10px;
- color: $notes-action-color;
-}
-
-.discussion-actions {
- @media (max-width: $screen-md-max) {
- float: none;
- margin-left: 0;
-
- .note-action-button {
- margin-left: 0;
- }
- }
-}
+.discussion,
+.note {
+ .discussion-actions,
+ .note-actions {
+ float: right;
+ margin-left: 10px;
-.note-action-button {
- display: inline-block;
- margin-left: 10px;
- line-height: 24px;
-
- .fa {
- color: $notes-action-color;
- position: relative;
- top: 1px;
- font-size: 17px;
- }
+ a {
+ margin-left: 5px;
+ color: $gl-gray;
- &.js-note-delete {
- i {
- &:hover {
- color: $gl-text-red;
+ i.fa {
+ font-size: 16px;
+ line-height: 16px;
}
- }
- }
- &.js-note-edit {
- i {
&:hover {
- color: $gl-link-color;
+ @extend .cgray;
+ &.danger { @extend .cred; }
}
}
}
}
-
-.discussion-toggle-button {
- line-height: 20px;
- font-size: 13px;
-
- .fa {
- margin-right: 3px;
- font-size: 10px;
- line-height: 18px;
- vertical-align: top;
- }
-}
-
-.note-role {
- position: relative;
- top: -2px;
- display: inline-block;
- padding-left: 4px;
- padding-right: 4px;
- color: $notes-role-color;
- font-size: 12px;
- line-height: 20px;
- border: 1px solid $notes-role-border-color;
- border-radius: $border-radius-base;
-}
-
.diff-file .note .note-actions {
right: 0;
top: 0;
@@ -292,7 +242,8 @@ ul.notes {
.diff-file tr.line_holder {
@mixin show-add-diff-note {
- display: inline-block;
+ filter: alpha(opacity=100);
+ opacity: 1.0;
}
.add-diff-note {
@@ -302,12 +253,17 @@ ul.notes {
padding: 4px;
font-size: 16px;
color: $gl-link-color;
- margin-left: -56px;
+ margin-left: -60px;
position: absolute;
z-index: 10;
width: 32px;
+
+ transition: all 0.2s ease;
+
// "hide" it by default
- display: none;
+ opacity: 0.0;
+ filter: alpha(opacity=0);
+
&:hover {
background: $gl-info;
color: #fff;
@@ -323,20 +279,33 @@ ul.notes {
}
}
-.disabled-comment {
- margin-left: -$gl-padding-top;
- margin-right: -$gl-padding-top;
- background-color: $gray-light;
- border-radius: $border-radius-base;
- border: 1px solid $border-gray-normal;
- color: $note-disabled-comment-color;
- line-height: 200px;
-
- .disabled-comment-text {
- line-height: normal;
+.note-action-award-holder {
+ .emoji-menu {
+ left: auto;
+ right: -15px;
+ transform-origin: 100% -45px;
+ }
+}
+
+.note-award-control {
+ display: block;
+
+ &:hover,
+ &:focus {
+ text-decoration: none;
}
- a {
- color: $gl-link-color;
+ .award-control-icon-loading {
+ display: none;
+ }
+
+ &.is-loading {
+ .award-control-icon-normal {
+ display: none;
+ }
+
+ .award-control-icon-loading {
+ display: block;
+ }
}
}
diff --git a/app/views/emoji_awards/_awards_block.html.haml b/app/views/emoji_awards/_awards_block.html.haml
index da1de1c1deb..79ebaa6777e 100644
--- a/app/views/emoji_awards/_awards_block.html.haml
+++ b/app/views/emoji_awards/_awards_block.html.haml
@@ -6,17 +6,9 @@
= awards.count
- if current_user
- %div.award-menu-holder.js-award-holder
- %button.btn.award-control.js-add-award{ type: "button" }
- = icon('smile-o', {class: "award-control-icon"})
+ .award-menu-holder.js-award-holder
+ %button.btn.award-control.js-add-award{ type: "button", data: { award_menu_url: emojis_path } }
+ = icon('smile-o', {class: "award-control-icon award-control-icon-normal"})
= icon('spinner spin', {class: "award-control-icon award-control-icon-loading"})
%span.award-control-text
Add
-
-- if current_user
- :javascript
- var aliases = #{AwardEmoji.aliases.to_json};
-
- window.awards_handler = new AwardsHandler(
- aliases
- );
diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml
index 9fbc9a45549..b7fbd89da9c 100644
--- a/app/views/projects/notes/_note.html.haml
+++ b/app/views/projects/notes/_note.html.haml
@@ -9,14 +9,20 @@
= image_tag avatar_icon(note.author), alt: '', class: 'avatar s40'
.timeline-content
.note-header
- = link_to_member(note.project, note.author, avatar: false)
- .inline.note-headline-light
- = note.author.to_reference
- - unless note.system
- commented
- %a{ href: "##{dom_id(note)}" }
- = time_ago_with_tooltip(note.created_at, placement: 'bottom', html_class: 'note-created-ago')
- .note-actions
+ - if note_editable?(note)
+ .note-actions
+ = link_to '#', title: 'Edit comment', class: 'js-note-edit' do
+ = icon('pencil-square-o')
+
+ .award-menu-holder.note-action-award-holder.js-award-holder.js-award-action-btn
+ = link_to '#', title: 'Award emoji', class: 'note-award-control js-add-award', data: { award_menu_url: emojis_path } do
+ = icon('smile-o', {class: "award-control-icon award-control-icon-normal"})
+ = icon('spinner spin', {class: "award-control-icon award-control-icon-loading"})
+
+ = link_to namespace_project_note_path(note.project.namespace, note.project, note), title: 'Remove comment', method: :delete, data: { confirm: 'Are you sure you want to remove this comment?' }, remote: true, class: 'js-note-delete danger' do
+ = icon('trash-o')
+
+ - unless note.system
- access = note.project.team.human_max_access(note.author.id)
- if access
%span.note-role
@@ -32,6 +38,7 @@
= markdown(note.note, pipeline: :note, cache_key: [note, "note"])
- if note_editable
= render 'projects/notes/edit_form', note: note
+ = render 'emoji_awards/awards_block', awardable: note
= edited_time_ago_with_tooltip(note, placement: 'bottom', html_class: 'note_edited_ago', include_author: true)
- if note.attachment.url