Ver Fonte

Minor optimizations to improve boot performance

Thibaut Courouble há 9 anos atrás
pai
commit
18199101d7

+ 2 - 1
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: =>

+ 13 - 3
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

+ 1 - 4
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