Commit 0b45cf55 authored by Phil Hughes's avatar Phil Hughes Committed by Fatih Acet

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
parent 4caf38a1
class @AwardsHandler class @AwardsHandler
constructor: (@aliases) -> constructor: ->
$(".js-add-award").on "click", (event) => @aliases = emojiAliases()
$(document).on "click", ".js-add-award", (event) =>
event.stopPropagation() event.stopPropagation()
event.preventDefault() event.preventDefault()
@showEmojiMenu() @showEmojiMenu $(event.currentTarget)
$("html").on 'click', (event) -> $("html").on 'click', (event) ->
if !$(event.target).closest(".emoji-menu").length if !$(event.target).closest(".emoji-menu").length
if $(".emoji-menu").is(":visible") if $(".emoji-menu").is(":visible")
$(".emoji-menu").removeClass "is-visible" $(".emoji-menu").removeClass "is-visible"
$(".awards") $(document)
.off "click" .off "click", ".js-emoji-btn"
.on "click", ".js-emoji-btn", @handleClick .on "click", ".js-emoji-btn", @handleClick
@renderFrequentlyUsedBlock() handleClick: (e) =>
handleClick: (e) ->
e.preventDefault() e.preventDefault()
$emojiBtn = $(e.currentTarget) $emojiBtn = $(e.currentTarget)
awardUrl = $emojiBtn.closest('.js-votes-block').data 'award-url' awardUrl = $emojiBtn.closest('.js-votes-block').data 'award-url'
...@@ -26,8 +26,13 @@ class @AwardsHandler ...@@ -26,8 +26,13 @@ class @AwardsHandler
.data "emoji" .data "emoji"
@addAward awardUrl, emoji @addAward awardUrl, emoji
showEmojiMenu: -> showEmojiMenu: ($addBtn) ->
if $(".emoji-menu").length 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" if $(".emoji-menu").is ".is-visible"
$(".emoji-menu").removeClass "is-visible" $(".emoji-menu").removeClass "is-visible"
$("#emoji_search").blur() $("#emoji_search").blur()
...@@ -35,10 +40,11 @@ class @AwardsHandler ...@@ -35,10 +40,11 @@ class @AwardsHandler
$(".emoji-menu").addClass "is-visible" $(".emoji-menu").addClass "is-visible"
$("#emoji_search").focus() $("#emoji_search").focus()
else else
$('.js-add-award').addClass "is-loading" $addBtn.addClass "is-loading"
$.get "/emojis", (response) => $.get $addBtn.data('award-menu-url'), (response) =>
$('.js-add-award').removeClass "is-loading" $addBtn.removeClass "is-loading"
$(".js-award-holder").append response $addBtn.closest('.js-award-holder').append response
@renderFrequentlyUsedBlock()
setTimeout => setTimeout =>
$(".emoji-menu").addClass "is-visible" $(".emoji-menu").addClass "is-visible"
$("#emoji_search").focus() $("#emoji_search").focus()
...@@ -128,7 +134,7 @@ class @AwardsHandler ...@@ -128,7 +134,7 @@ class @AwardsHandler
</button>" </button>"
emoji_node = $(buttonHtml) emoji_node = $(buttonHtml)
.insertBefore(".js-award-holder") .insertBefore(".js-award-holder:not(.js-award-action-btn)")
.find(".emoji-icon") .find(".emoji-icon")
.data("emoji", emoji) .data("emoji", emoji)
$('.award-control').tooltip() $('.award-control').tooltip()
...@@ -173,16 +179,15 @@ class @AwardsHandler ...@@ -173,16 +179,15 @@ class @AwardsHandler
if $.cookie('frequently_used_emojis') if $.cookie('frequently_used_emojis')
frequently_used_emojis = @getFrequentlyUsedEmojis() frequently_used_emojis = @getFrequentlyUsedEmojis()
ul = $("<ul>") ul = $("<ul class='clearfix emoji-menu-list'>")
for emoji in frequently_used_emojis 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")) $("input.emoji-search").after(ul).after($("<h5>").text("Frequently used"))
setupSearch: -> setupSearch: ->
$("input.emoji-search").keyup (ev) => $("input.emoji-search").on 'keyup', (ev) =>
term = $(ev.target).val() term = $(ev.target).val()
# Clean previous search results # Clean previous search results
......
...@@ -23,6 +23,7 @@ class Dispatcher ...@@ -23,6 +23,7 @@ class Dispatcher
new Issue() new Issue()
shortcut_handler = new ShortcutsIssuable() shortcut_handler = new ShortcutsIssuable()
new ZenMode() new ZenMode()
window.awards_handler = new AwardsHandler()
when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show' when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show'
new Milestone() new Milestone()
when 'dashboard:todos:index' when 'dashboard:todos:index'
...@@ -53,6 +54,7 @@ class Dispatcher ...@@ -53,6 +54,7 @@ class Dispatcher
new Diff() new Diff()
shortcut_handler = new ShortcutsIssuable(true) shortcut_handler = new ShortcutsIssuable(true)
new ZenMode() new ZenMode()
window.awards_handler = new AwardsHandler()
when "projects:merge_requests:diffs" when "projects:merge_requests:diffs"
new Diff() new Diff()
new ZenMode() new ZenMode()
......
window.emojiAliases = ->
JSON.parse('<%= AwardEmoji.aliases.to_json %>')
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
} }
&.is-loading { &.is-loading {
.award-control-icon { .award-control-icon-normal {
display: none; display: none;
} }
......
...@@ -20,15 +20,9 @@ ul.notes { ...@@ -20,15 +20,9 @@ ul.notes {
.timeline-content { .timeline-content {
margin-left: 55px; 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; white-space: nowrap;
} }
...@@ -45,6 +39,53 @@ ul.notes { ...@@ -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 { .discussion-body {
padding-top: 15px; padding-top: 15px;
} }
...@@ -58,7 +99,6 @@ ul.notes { ...@@ -58,7 +99,6 @@ ul.notes {
.note { .note {
display: block; display: block;
position: relative; position: relative;
border-bottom: 1px solid $table-border-gray;
&.is-editting { &.is-editting {
.note-header, .note-header,
...@@ -73,17 +113,17 @@ ul.notes { ...@@ -73,17 +113,17 @@ ul.notes {
} }
.note-body { .note-body {
overflow: auto;
.note-text { .note-text {
overflow: auto; overflow: auto;
word-wrap: break-word; word-wrap: break-word;
@include md-typography; @include md-typography;
// On diffs code should wrap nicely and not overflow // On diffs code should wrap nicely and not overflow
pre {
code { code {
white-space: pre-wrap; white-space: pre-wrap;
} }
}
// Reset ul style types since we're nested inside a ul already // Reset ul style types since we're nested inside a ul already
& > ul { & > ul {
...@@ -109,10 +149,6 @@ ul.notes { ...@@ -109,10 +149,6 @@ ul.notes {
border-color: darken(#f5f5f5, 8%); border-color: darken(#f5f5f5, 8%);
margin: 10px 0; margin: 10px 0;
} }
code {
word-break: keep-all;
}
} }
} }
...@@ -120,6 +156,9 @@ ul.notes { ...@@ -120,6 +156,9 @@ ul.notes {
padding-bottom: 3px; padding-bottom: 3px;
} }
&:last-child {
border-bottom: 1px solid $border-color;
}
} }
} }
...@@ -137,149 +176,60 @@ ul.notes { ...@@ -137,149 +176,60 @@ ul.notes {
font-family: $regular_font; font-family: $regular_font;
td { td {
border: 1px solid $table-border-gray; border: 1px solid #ddd;
border-left: none; border-left: none;
&.notes_line { &.notes_line {
vertical-align: middle; vertical-align: middle;
text-align: center; text-align: center;
padding: 10px 0; padding: 10px 0;
background: $background-color; background: #fff;
color: $text-color; color: $text-color;
} }
&.notes_line2 { &.notes_line2 {
text-align: center; text-align: center;
padding: 10px 0; padding: 10px 0;
border-left: 1px solid #ddd !important; border-left: 1px solid #ddd !important;
} }
&.notes_content { &.notes_content {
background-color: $background-color; background-color: #fff;
border-width: 1px 0; border-width: 1px 0;
padding: 0; padding-top: 0;
vertical-align: top; vertical-align: top;
white-space: normal; &.parallel{
&.parallel {
border-width: 1px; 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 * Actions for Discussions/Notes
*/ */
.discussion-actions, .discussion,
.note-actions { .note {
.discussion-actions,
.note-actions {
float: right; float: right;
margin-left: 10px; margin-left: 10px;
color: $notes-action-color;
}
.discussion-actions {
@media (max-width: $screen-md-max) {
float: none;
margin-left: 0;
.note-action-button { a {
margin-left: 0; margin-left: 5px;
} color: $gl-gray;
}
}
.note-action-button {
display: inline-block;
margin-left: 10px;
line-height: 24px;
.fa {
color: $notes-action-color;
position: relative;
top: 1px;
font-size: 17px;
}
&.js-note-delete { i.fa {
i { font-size: 16px;
&:hover { line-height: 16px;
color: $gl-text-red;
}
}
} }
&.js-note-edit {
i {
&:hover { &: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 { .diff-file .note .note-actions {
right: 0; right: 0;
top: 0; top: 0;
...@@ -292,7 +242,8 @@ ul.notes { ...@@ -292,7 +242,8 @@ ul.notes {
.diff-file tr.line_holder { .diff-file tr.line_holder {
@mixin show-add-diff-note { @mixin show-add-diff-note {
display: inline-block; filter: alpha(opacity=100);
opacity: 1.0;
} }
.add-diff-note { .add-diff-note {
...@@ -302,12 +253,17 @@ ul.notes { ...@@ -302,12 +253,17 @@ ul.notes {
padding: 4px; padding: 4px;
font-size: 16px; font-size: 16px;
color: $gl-link-color; color: $gl-link-color;
margin-left: -56px; margin-left: -60px;
position: absolute; position: absolute;
z-index: 10; z-index: 10;
width: 32px; width: 32px;
transition: all 0.2s ease;
// "hide" it by default // "hide" it by default
display: none; opacity: 0.0;
filter: alpha(opacity=0);
&:hover { &:hover {
background: $gl-info; background: $gl-info;
color: #fff; color: #fff;
...@@ -323,20 +279,33 @@ ul.notes { ...@@ -323,20 +279,33 @@ ul.notes {
} }
} }
.disabled-comment { .note-action-award-holder {
margin-left: -$gl-padding-top; .emoji-menu {
margin-right: -$gl-padding-top; left: auto;
background-color: $gray-light; right: -15px;
border-radius: $border-radius-base; transform-origin: 100% -45px;
border: 1px solid $border-gray-normal; }
color: $note-disabled-comment-color; }
line-height: 200px;
.note-award-control {
display: block;
.disabled-comment-text { &:hover,
line-height: normal; &:focus {
text-decoration: none;
} }
a { .award-control-icon-loading {
color: $gl-link-color; display: none;
}
&.is-loading {
.award-control-icon-normal {
display: none;
}
.award-control-icon-loading {
display: block;
}
} }
} }
...@@ -6,17 +6,9 @@ ...@@ -6,17 +6,9 @@
= awards.count = awards.count
- if current_user - if current_user
%div.award-menu-holder.js-award-holder .award-menu-holder.js-award-holder
%button.btn.award-control.js-add-award{ type: "button" } %button.btn.award-control.js-add-award{ type: "button", data: { award_menu_url: emojis_path } }
= icon('smile-o', {class: "award-control-icon"}) = icon('smile-o', {class: "award-control-icon award-control-icon-normal"})
= icon('spinner spin', {class: "award-control-icon award-control-icon-loading"}) = icon('spinner spin', {class: "award-control-icon award-control-icon-loading"})
%span.award-control-text %span.award-control-text
Add Add
- if current_user
:javascript
var aliases = #{AwardEmoji.aliases.to_json};
window.awards_handler = new AwardsHandler(
aliases
);
...@@ -9,14 +9,20 @@ ...@@ -9,14 +9,20 @@
= image_tag avatar_icon(note.author), alt: '', class: 'avatar s40' = image_tag avatar_icon(note.author), alt: '', class: 'avatar s40'
.timeline-content .timeline-content
.note-header .note-header
= link_to_member(note.project, note.author, avatar: false) - if note_editable?(note)
.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 .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) - access = note.project.team.human_max_access(note.author.id)
- if access - if access
%span.note-role %span.note-role
...@@ -32,6 +38,7 @@ ...@@ -32,6 +38,7 @@
= markdown(note.note, pipeline: :note, cache_key: [note, "note"]) = markdown(note.note, pipeline: :note, cache_key: [note, "note"])
- if note_editable - if note_editable
= render 'projects/notes/edit_form', note: note = 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) = edited_time_ago_with_tooltip(note, placement: 'bottom', html_class: 'note_edited_ago', include_author: true)
- if note.attachment.url - if note.attachment.url
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment