diff options
author | Phil Hughes <me@iamphill.com> | 2016-03-01 11:25:59 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-03-11 09:02:43 +0000 |
commit | 5e145918b4dc20672ca212d094a73b87476d1db5 (patch) | |
tree | f5251a850c82c25f59bb0f594a216a741236f678 /app/assets | |
parent | f7da99aef7044592d957df750dcf6e4185c51694 (diff) | |
download | gitlab-ce-5e145918b4dc20672ca212d094a73b87476d1db5.tar.gz |
Updated UI of award emoji
Closes #13878
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 37 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/blocks.scss | 4 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/awards.scss | 189 |
3 files changed, 115 insertions, 115 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 8f89d3e61a2..351f871de94 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -1,6 +1,6 @@ class @AwardsHandler constructor: (@post_emoji_url, @noteable_type, @noteable_id, @aliases) -> - $(".add-award").click (event) => + $(".js-add-award").click (event) => event.stopPropagation() event.preventDefault() @@ -11,18 +11,28 @@ class @AwardsHandler if $(".emoji-menu").is(":visible") $(".emoji-menu").hide() + $(".awards").off "click" + $(".awards").on "click", ".js-emoji-btn", @handleClick + @renderFrequentlyUsedBlock() - @setupSearch() + + handleClick: (e) -> + e.preventDefault() + emoji = $(this).find(".icon").data "emoji" + awards_handler.addAward emoji showEmojiMenu: -> if $(".emoji-menu").length $(".emoji-menu").show() $("#emoji_search").focus() else - $.get "/emojis", (response) -> - $(".add-award").after response + $('.js-add-award').addClass "is-loading" + $.get "/emojis", (response) => + $('.js-add-award').removeClass "is-loading" + $(".js-award-holder").append response $(".emoji-menu").show() $("#emoji_search").focus() + @setupSearch() addAward: (emoji) -> emoji = @normilizeEmojiName(emoji) @@ -39,7 +49,7 @@ class @AwardsHandler if @isActive(emoji) @decrementCounter(emoji) else - counter = @findEmojiIcon(emoji).siblings(".counter") + counter = @findEmojiIcon(emoji).siblings(".js-counter") counter.text(parseInt(counter.text()) + 1) counter.parent().addClass("active") @addMeToAuthorList(emoji) @@ -53,7 +63,7 @@ class @AwardsHandler @findEmojiIcon(emoji).parent().hasClass("active") decrementCounter: (emoji) -> - counter = @findEmojiIcon(emoji).siblings(".counter") + counter = @findEmojiIcon(emoji).siblings(".js-counter") emojiIcon = counter.parent() if parseInt(counter.text()) > 1 counter.text(parseInt(counter.text()) - 1) @@ -98,14 +108,13 @@ class @AwardsHandler emojiCssClass = @resolveNameToCssClass(emoji) nodes = [] - nodes.push("<div class='award active' title='me'>") - nodes.push("<div class='icon emoji-icon #{emojiCssClass}' data-emoji='#{emoji}'></div>") - nodes.push("<div class='counter'>1</div>") - nodes.push("</div>") - - emoji_node = $(nodes.join("\n")).insertBefore(".awards-controls").find(".emoji-icon").data("emoji", emoji) + nodes.push "<button class='btn award-control js-emoji-btn has_tooltip active' title='me'>" + nodes.push "<div class='icon emoji-icon #{emojiCssClass}' data-emoji='#{emoji}'></div>" + nodes.push "<span class='award-control-text js-counter'>1</span>" + nodes.push "</button>" - $(".award").tooltip() + emoji_node = $(nodes.join("\n")).insertBefore(".js-award-holder").find(".emoji-icon").data("emoji", emoji) + $('.award-control').tooltip() resolveNameToCssClass: (emoji) -> emoji_icon = $(".emoji-menu-content [data-emoji='#{emoji}']") @@ -128,7 +137,7 @@ class @AwardsHandler callback.call() findEmojiIcon: (emoji) -> - $(".award [data-emoji='#{emoji}']") + $(".awards > .js-emoji-btn [data-emoji='#{emoji}']") scrollToAwards: -> $('body, html').animate({ diff --git a/app/assets/stylesheets/framework/blocks.scss b/app/assets/stylesheets/framework/blocks.scss index e6609ac7108..6edabe20136 100644 --- a/app/assets/stylesheets/framework/blocks.scss +++ b/app/assets/stylesheets/framework/blocks.scss @@ -157,3 +157,7 @@ float: right; } } + +.content-block-small { + padding: 10px 0; +} diff --git a/app/assets/stylesheets/pages/awards.scss b/app/assets/stylesheets/pages/awards.scss index 87dd30f4111..e692730bddf 100644 --- a/app/assets/stylesheets/pages/awards.scss +++ b/app/assets/stylesheets/pages/awards.scss @@ -1,125 +1,112 @@ .awards { - @include clearfix; line-height: 34px; .emoji-icon { width: 20px; height: 20px; - margin: 7px 0 0 5px; } +} - .award { - @include border-radius(5px); +.emoji-menu { + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + min-width: 160px; + font-size: 14px; + background-color: #fff; + border: 1px solid #F1F2F4; + border-radius: 2px; + box-shadow: 0 6px 12px rgba(0,0,0,.175); + + .emoji-menu-content { + padding: $gl-padding; + width: 300px; + height: 300px; + overflow-y: scroll; + + input.emoji-search{ + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAFu0lEQVRIia1WTahkVxH+quqce7vf6zdvJpHoIlkYJ2SiJiIokmQjgoGgIAaEIYuYXWICgojiwkmC4taFwhjcyIDusogEIwwiSSCKPwsdwzAg0SjJ9Izzk5n3+nXfe8+pqizOvd395scfsJqi6dPnnDr11Vc/NJ1OwUTosqJLCmYCHCAC2mSHs+ojZv6AO46Y+20AhIneJsafhPhXVZSXDk7qi+aOLhtQNuBmQtcarAKjTXpn2+l3u2yPunvZSABRucjcAV/eMZuM48/Go/g1d19kc4wq+e8MZjWkbI/P5t2P3RFFbv7SQdyBlBUx8N8OTuqjMcof+N94yMPrY2DMm/ytnb32J0QrY+6AqsHM4Q64O9SKDmerKDD3Oy/tNL9vk342CC8RuU6n0ymCMHb22scu7zQngtASOjUHE1BX4UUAv4b7Ow6qiXCXuz/UdvogAAweDY943/b4cAz0ZlYHXeMsnT07RVb7wMUr8ykI4H5HVkMd5Rcb4/jNURVOL5qErAaAUUdCCIJ5kx5q2nw8m39ImEAAsjpE6PStB0YfMcd1wqqG3Xn7A3PfZyyKnNjaqD4fmE/fCNKshirIyY1xvI+Av6g5QIAIIWX7cJPss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TzZdPj6Qii6cP1cSvIdl3iQkNYyi9HH0I22y+93tY3DcQkTZgQtM+POoCr8x97eylkmtrgKuztrvXJ21x/aNKuqIkZ/fntRfCdcTfhUTAIhRzoDojJD0aSNLLwMzmpT7+JaLtyf1MwDo6qz9djFaUq3t9MlFmy/c1OCSceY9fMsVaL9mvH9ocXdkdWxv1scAePG0THAhMOaLdOw/Gvxfxb1w4eCapyIENUcV5M3/u8FitAxZ25P6GAHT3UX39Srw+QOb1ZffA98Dl2Wy1BYkAAAAAElFTkSuQmCC"); + background-repeat: no-repeat; + background-position: right 5px center; + background-size: 16px; + } + } +} - border: 1px solid; - padding: 0px 10px; - float: left; - margin-right: 5px; - border-color: $border-color; - cursor: pointer; +.emoji-menu-list { + list-style: none; + padding-left: 0; + margin-bottom: 0; +} - &:hover { - background-color: #dce0e5; - } +.emoji-menu-list-item { + padding: 3px; + margin-left: 1px; + margin-right: 1px; +} + +.emoji-menu-btn { + display: block; + cursor: pointer; + width: 30px; + height: 30px; + padding: 0; + background: none; + border: 0; + border-radius: 4px; + + &:hover { + background-color: #ededed; + } + + .emoji-icon { + display: inline-block; + position: relative; + top: 3px; + } +} - &.active { - border-color: $border-gray-light; - background-color: $gray-light; +.award-menu-holder { + display: inline-block; + position: relative; +} - &:hover { - background-color: #dce0e5; - } +.award-control { + margin-right: 5px; + line-height: 20px; + outline: 0; - .counter { - font-weight: bold; - } - } + &.active, + &:active { + background-color: #ededed; + box-shadow: none; + outline: 0; + } - .icon { - float: left; - margin-right: 10px; + &.is-loading { + .award-control-icon { + display: none; } - .counter { - float: left; + .award-control-icon-loading { + display: block; } } - .awards-controls { - position: relative; - margin-left: 10px; + .icon, + .award-control-icon { float: left; + margin-right: 5px; + font-size: 20px; + } - .add-award { - font-size: 24px; - color: $gl-gray; - position: relative; - top: 2px; - - &:hover, - &:link { - text-decoration: none; - } - } + .award-control-icon-loading { + display: none; + } - .emoji-menu{ - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - padding: 5px 0; - margin: 2px 0 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,.15); - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); - box-shadow: 0 6px 12px rgba(0,0,0,.175); - - .emoji-menu-content { - padding: $gl-padding; - width: 300px; - height: 300px; - overflow-y: scroll; - - h5 { - clear: left; - } - - ul { - list-style-type: none; - margin-left: -20px; - margin-bottom: 20px; - overflow: auto; - } - - input.emoji-search{ - background: image-url("icon-search.png") 240px no-repeat; - } - - li { - cursor: pointer; - width: 30px; - height: 30px; - text-align: center; - float: left; - margin: 3px; - list-decorate: none; - @include border-radius(5px); - - &:hover { - background-color: #ccc; - } - } - } - } + .award-control-icon { + color: #DCDCDC; } } |