diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 90fc0c629..4b2687d2b 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -294,13 +294,17 @@ class Sidebar extends App.Controller toggleTab: (e) -> name = $(e.target).closest('.sidebar-tab').data('content') + if name - @el.find('.ticket-zoom .sidebar-tab').removeClass('active') - $(e.target).closest('.sidebar-tab').addClass('active') + if name is @currentTab + @toggleSidebar() + else + @el.find('.ticket-zoom .sidebar-tab').removeClass('active') + $(e.target).closest('.sidebar-tab').addClass('active') - @toggleContent(name) + @toggleContent(name) - @showSidebar() + @showSidebar() toggleContent: (name) -> @@ -309,6 +313,7 @@ class Sidebar extends App.Controller @el.find('.sidebar-content[data-content=' + name + ']').removeClass('hide') title = @el.find('.sidebar-content[data-content=' + name + ']').data('title') @el.find('.sidebar h2').html(title) + @currentTab = name class Edit extends App.Controller @@ -318,6 +323,8 @@ class Edit extends App.Controller 'click .visibility.toggle': 'toggle_visibility' 'click .pop-selectable': 'select_type' 'click .pop-selected': 'show_selectable_types' + 'focus textarea': 'show_controls' + 'blur textarea': 'hide_controls' constructor: -> super @@ -466,6 +473,15 @@ class Edit extends App.Controller @type = type typeIcon.addClass @type + show_controls: => + @el.addClass('mode--edit') + # scroll to bottom + @el.scrollParent().scrollTop(99999) + + hide_controls: => + if !@el.find('textarea').val() + @el.removeClass('mode--edit') + autosaveStop: => @clearInterval( 'autosave' ) diff --git a/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco index 5018fde3d..1cd3fb312 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco @@ -2,31 +2,33 @@