diff --git a/assets/javascripts/views/search/search.coffee b/assets/javascripts/views/search/search.coffee index addd030e..96b8e8f2 100644 --- a/assets/javascripts/views/search/search.coffee +++ b/assets/javascripts/views/search/search.coffee @@ -36,7 +36,8 @@ class app.views.Search extends app.View return focus: -> - @input.focus() unless document.activeElement is @input + @delay => + @input.focus() unless document.activeElement is @input return autoFocus: => diff --git a/assets/javascripts/views/sidebar/sidebar.coffee b/assets/javascripts/views/sidebar/sidebar.coffee index 86e6ace0..94dcb967 100644 --- a/assets/javascripts/views/sidebar/sidebar.coffee +++ b/assets/javascripts/views/sidebar/sidebar.coffee @@ -23,7 +23,7 @@ class app.views.Sidebar extends app.View @docList = new app.views.DocList @docPicker = new app.views.DocPicker unless app.isSingleDoc() - app.on 'ready', @showDocList + app.on 'ready', @onReady $.on document, 'click', @onGlobalClick if @docPicker return @@ -32,13 +32,18 @@ class app.views.Sidebar extends app.View @hover?.hide() @saveScrollPosition() @view?.deactivate() - @html @view = view - @append @tmpl('sidebarSettings') if @view is @docList and @docPicker + @view = view + @render() @view.activate() @restoreScrollPosition() if view is @docPicker then @search.disable() else @search.enable() return + render: -> + @html @view + @append @tmpl('sidebarSettings') if @view is @docList and @docPicker + return + showDocList: (reset) => @show @docList if reset is true @@ -54,6 +59,11 @@ class app.views.Sidebar extends app.View @show @results return + onReady: => + @view = @docList + @render() + @view.activate() + reset: -> @showDocList true return diff --git a/assets/javascripts/views/sidebar/sidebar_hover.coffee b/assets/javascripts/views/sidebar/sidebar_hover.coffee index e749371c..abb232a4 100644 --- a/assets/javascripts/views/sidebar/sidebar_hover.coffee +++ b/assets/javascripts/views/sidebar/sidebar_hover.coffee @@ -17,10 +17,6 @@ class app.views.SidebarHover extends app.View delete @constructor.events.mouseover super - init: -> - @offsetTop = @el.offsetTop - return - show: (el) -> unless el is @cursor @hide() @@ -28,6 +24,7 @@ class app.views.SidebarHover extends app.View @cursor = el @clone = @makeClone @cursor $.append document.body, @clone + @offsetTop ?= @el.offsetTop @position() return