Minor optimizations to improve boot performance

pull/417/head
Thibaut Courouble 9 years ago
parent 2e915c135a
commit 18199101d7

@ -36,7 +36,8 @@ class app.views.Search extends app.View
return return
focus: -> focus: ->
@input.focus() unless document.activeElement is @input @delay =>
@input.focus() unless document.activeElement is @input
return return
autoFocus: => autoFocus: =>

@ -23,7 +23,7 @@ class app.views.Sidebar extends app.View
@docList = new app.views.DocList @docList = new app.views.DocList
@docPicker = new app.views.DocPicker unless app.isSingleDoc() @docPicker = new app.views.DocPicker unless app.isSingleDoc()
app.on 'ready', @showDocList app.on 'ready', @onReady
$.on document, 'click', @onGlobalClick if @docPicker $.on document, 'click', @onGlobalClick if @docPicker
return return
@ -32,13 +32,18 @@ class app.views.Sidebar extends app.View
@hover?.hide() @hover?.hide()
@saveScrollPosition() @saveScrollPosition()
@view?.deactivate() @view?.deactivate()
@html @view = view @view = view
@append @tmpl('sidebarSettings') if @view is @docList and @docPicker @render()
@view.activate() @view.activate()
@restoreScrollPosition() @restoreScrollPosition()
if view is @docPicker then @search.disable() else @search.enable() if view is @docPicker then @search.disable() else @search.enable()
return return
render: ->
@html @view
@append @tmpl('sidebarSettings') if @view is @docList and @docPicker
return
showDocList: (reset) => showDocList: (reset) =>
@show @docList @show @docList
if reset is true if reset is true
@ -54,6 +59,11 @@ class app.views.Sidebar extends app.View
@show @results @show @results
return return
onReady: =>
@view = @docList
@render()
@view.activate()
reset: -> reset: ->
@showDocList true @showDocList true
return return

@ -17,10 +17,6 @@ class app.views.SidebarHover extends app.View
delete @constructor.events.mouseover delete @constructor.events.mouseover
super super
init: ->
@offsetTop = @el.offsetTop
return
show: (el) -> show: (el) ->
unless el is @cursor unless el is @cursor
@hide() @hide()
@ -28,6 +24,7 @@ class app.views.SidebarHover extends app.View
@cursor = el @cursor = el
@clone = @makeClone @cursor @clone = @makeClone @cursor
$.append document.body, @clone $.append document.body, @clone
@offsetTop ?= @el.offsetTop
@position() @position()
return return

Loading…
Cancel
Save