Added toolbar to comment form

This commit is contained in:
Phil Hughes 2016-03-30 10:00:43 +01:00
parent 0331fa3f3d
commit 3c2b0e7572
9 changed files with 130 additions and 109 deletions

View file

@ -6,25 +6,10 @@ class @Issue
constructor: -> constructor: ->
# Prevent duplicate event bindings # Prevent duplicate event bindings
@disableTaskList() @disableTaskList()
@fixAffixScroll()
if $('a.btn-close').length if $('a.btn-close').length
@initTaskList() @initTaskList()
@initIssueBtnEventListeners() @initIssueBtnEventListeners()
fixAffixScroll: ->
fixAffix = ->
$discussion = $('.issuable-discussion')
$sidebar = $('.issuable-sidebar')
if $sidebar.hasClass('no-affix')
$sidebar.removeClass(['affix-top','affix'])
discussionHeight = $discussion.height()
sidebarHeight = $sidebar.height()
if sidebarHeight > discussionHeight
$discussion.height(sidebarHeight + 50)
$sidebar.addClass('no-affix')
$(window).on('resize', fixAffix)
fixAffix()
initTaskList: -> initTaskList: ->
$('.detail-page-description .js-task-list-container').taskList('enable') $('.detail-page-description .js-task-list-container').taskList('enable')
$(document).on 'tasklist:changed', '.detail-page-description .js-task-list-container', @updateTaskList $(document).on 'tasklist:changed', '.detail-page-description .js-task-list-container', @updateTaskList

View file

@ -15,8 +15,6 @@ class @MergeRequest
this.$('.show-all-commits').on 'click', => this.$('.show-all-commits').on 'click', =>
this.showAllCommits() this.showAllCommits()
@fixAffixScroll();
@initTabs() @initTabs()
# Prevent duplicate event bindings # Prevent duplicate event bindings
@ -30,20 +28,6 @@ class @MergeRequest
$: (selector) -> $: (selector) ->
this.$el.find(selector) this.$el.find(selector)
fixAffixScroll: ->
fixAffix = ->
$discussion = $('.issuable-discussion')
$sidebar = $('.issuable-sidebar')
if $sidebar.hasClass('no-affix')
$sidebar.removeClass(['affix-top','affix'])
discussionHeight = $discussion.height()
sidebarHeight = $sidebar.height()
if sidebarHeight > discussionHeight
$discussion.height(sidebarHeight + 50)
$sidebar.addClass('no-affix')
$(window).on('resize', fixAffix)
fixAffix()
initTabs: -> initTabs: ->
if @opts.action != 'new' if @opts.action != 'new'
# `MergeRequests#new` has no tab-persisting or lazy-loading behavior # `MergeRequests#new` has no tab-persisting or lazy-loading behavior

View file

@ -1,4 +1,5 @@
#= require autosave #= require autosave
#= require autosize
#= require dropzone #= require dropzone
#= require dropzone_input #= require dropzone_input
#= require gfm_auto_complete #= require gfm_auto_complete
@ -287,6 +288,8 @@ class @Notes
else else
previewButton.removeClass("turn-on").addClass "turn-off" previewButton.removeClass("turn-on").addClass "turn-off"
autosize(textarea)
new Autosave textarea, [ new Autosave textarea, [
"Note" "Note"
form.find("#note_commit_id").val() form.find("#note_commit_id").val()
@ -368,6 +371,9 @@ class @Notes
textarea = form.find("textarea") textarea = form.find("textarea")
textarea.focus() textarea.focus()
if isNewForm
autosize(textarea)
# HACK (rspeicher/DouweM): Work around a Chrome 43 bug(?). # HACK (rspeicher/DouweM): Work around a Chrome 43 bug(?).
# The textarea has the correct value, Chrome just won't show it unless we # The textarea has the correct value, Chrome just won't show it unless we
# modify it, so let's clear it and re-set it! # modify it, so let's clear it and re-set it!

View file

@ -1,9 +1,7 @@
.div-dropzone-wrapper { .div-dropzone-wrapper {
.div-dropzone { .div-dropzone {
position: relative; position: relative;
padding: 0; margin-bottom: -5px;
border: 0;
margin-bottom: 5px;
.div-dropzone-focus { .div-dropzone-focus {
border-color: #66afe9 !important; border-color: #66afe9 !important;
@ -25,12 +23,10 @@
.div-dropzone-spinner { .div-dropzone-spinner {
position: absolute; position: absolute;
top: 100%; bottom: 10px;
left: 100%; right: 5px;
margin-top: -1.1em;
margin-left: -1.1em;
opacity: 0; opacity: 0;
font-size: 30px; font-size: 20px;
transition: opacity 200ms ease-in-out; transition: opacity 200ms ease-in-out;
} }

View file

@ -1,42 +1,51 @@
.zennable { .zen-backdrop {
.zen-backdrop { &.fullscreen {
&.fullscreen { background-color: white;
background-color: white; position: fixed;
position: fixed; top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1031;
textarea {
border: none;
box-shadow: none;
border-radius: 0;
color: #000;
font-size: 20px;
line-height: 26px;
padding: 30px;
display: block;
outline: none;
resize: none;
height: 100vh;
max-width: 900px;
margin: 0 auto;
}
.zen-control-leave {
display: block;
position: absolute;
top: 0; top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1031;
textarea {
border: none;
box-shadow: none;
border-radius: 0;
color: #000;
font-size: 20px;
line-height: 26px;
padding: 30px;
display: block;
outline: none;
resize: none;
height: 100vh;
max-width: 900px;
margin: 0 auto;
}
.zen-control-leave {
display: block;
position: absolute;
top: 0;
}
} }
} }
} }
.zen-cotrol { .zen-cotrol {
padding: 0;
color: #555; color: #555;
line-height: 31px; background: none;
border: 0;
}
.zen-control-full {
color: #959494;
&:hover {
color: $gl-link-color;
text-decoration: none;
}
} }
.zen-control-leave { .zen-control-leave {

View file

@ -47,9 +47,7 @@
padding-left: 0; padding-left: 0;
padding-right: 0; padding-right: 0;
font-family: $regular_font; font-family: $regular_font;
border-left: 0; border: 0;
border-right: 0;
resize: none!important; // TODO: Find a way to remove this !important
&:focus { &:focus {
outline: 0; outline: 0;
@ -63,10 +61,11 @@
} }
.common-note-form { .common-note-form {
margin: 0; .md-area {
padding: $gl-padding; padding: $gl-padding-top $gl-padding;
border: 1px solid #E5E5E5; border: 1px solid #E5E5E5;
border-radius: $border-radius-base; border-radius: $border-radius-base;
}
} }
.note-form-actions { .note-form-actions {
@ -151,11 +150,43 @@
} }
} }
.comment-hints { .comment-toolbar {
color: #999; padding-top: $gl-padding-top;
background: #fff; border-top: 1px solid $border-color;
padding: 7px; }
margin-top: -7px;
border: 1px solid $border-color; .toolbar-button {
font-size: 13px; float: left;
margin-right: $gl-padding;
padding: 0;
background: none;
border: 0;
color: #959494;
font-size: 14px;
line-height: 16px;
&:hover,
&:focus {
color: $gl-link-color;
outline: 0;
}
&:last-child {
margin-right: 0;
}
}
.toolbar-button-icon {
position: relative;
top: 1px;
margin-right: 3px;
color: inherit;
font-size: 16px;
}
.toolbar-text {
float: left;
color: #959494;
font-size: 14px;
line-height: 16px;
} }

View file

@ -1,20 +1,19 @@
.md-area .md-area
.md-header.clearfix .md-header
%ul.nav-links.pull-left %ul.nav-links
%li.active %li.active
%a.js-md-write-button{ href: "#md-write-holder" } %a.js-md-write-button{ href: "#md-write-holder" }
Write Write
%li %li
%a.js-md-preview-button{ href: "#md-preview-holder" } %a.js-md-preview-button{ href: "#md-preview-holder" }
Preview Preview
.pull-right %li.pull-right
%a.zen-cotrol.js-zen-enter{ href: "#" } %button.zen-cotrol.zen-control-full.js-zen-enter{ type: 'button' }
Go full screen Go full screen
.md-write-holder .md-write-holder
= yield = yield
.md.md-preview-holder.hide .md.md-preview-holder.js-md-preview.hide{class: (preview_class if defined?(preview_class))}
.js-md-preview{class: (preview_class if defined?(preview_class))}
- if defined?(referenced_users) && referenced_users - if defined?(referenced_users) && referenced_users
%div.referenced-users.hide %div.referenced-users.hide

View file

@ -1,9 +1,8 @@
.zennable .zen-backdrop
.zen-backdrop - classes << ' js-gfm-input js-autosize markdown-area'
- classes << ' js-gfm-input js-autosize markdown-area' - if defined?(f) && f
- if defined?(f) && f = f.text_area attr, class: classes, placeholder: "Write a comment or drag your files here..."
= f.text_area attr, class: classes, placeholder: "Write a comment or drag your files here..." - else
- else = text_area_tag attr, nil, class: classes, placeholder: "Write a comment or drag your files here..."
= text_area_tag attr, nil, class: classes, placeholder: "Write a comment or drag your files here..." %a.zen-cotrol.zen-control-leave.js-zen-leave{ href: "#" }
%a.zen-cotrol.zen-control-leave.js-zen-leave{ href: "#" } = icon('compress')
= icon('compress')

View file

@ -1,9 +1,21 @@
.comment-hints.clearfix .comment-toolbar.clearfix
.pull-left %button.toolbar-button.js-toolbar-button{ type: 'button', data: { prefix: ':' }, tabindex: '-1' }
= icon('smile-o', class: 'toolbar-button-icon')
Emoji
.toolbar-text
Styling with
= link_to 'Markdown', help_page_path('markdown', 'markdown'), target: '_blank', tabindex: -1 = link_to 'Markdown', help_page_path('markdown', 'markdown'), target: '_blank', tabindex: -1
tip: is supported
= random_markdown_tip %button.toolbar-button.markdown-selector.pull-right{ type: 'button', tabindex: '-1' }
.pull-right = icon('file-image-o', class: 'toolbar-button-icon')
= link_to '#', class: 'markdown-selector', tabindex: -1 do Attach a file
= icon('paperclip')
Attach a file -# .comment-hints.clearfix
-# .pull-left
-# = link_to 'Markdown', help_page_path('markdown', 'markdown'), target: '_blank', tabindex: -1
-# tip:
-# = random_markdown_tip
-# .pull-right
-# = link_to '#', class: 'markdown-selector', tabindex: -1 do
-# = icon('paperclip')
-# Attach a file