whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [7/50] Commit fd8c7eb: get the server working again (part 1?)
Date Fri, 22 Jan 2016 02:40:52 GMT
Commit fd8c7eb24a77e578ad5db952b21e21a1977ab6cf:
    get the server working again (part 1?)


Branch: refs/heads/master
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
views/main.js.rb                                             | +++++ ----
------------------------------------------------------------
18 changes: 10 additions, 8 deletions.
------------------------------------------------------------


diff --git a/views/main.js.rb b/views/main.js.rb
index 14a51a5..0b4b05a 100644
--- a/views/main.js.rb
+++ b/views/main.js.rb
@@ -8,10 +8,6 @@ def initialize
   def componentWillMount()
     Main.navigate = self.navigate
     self.navigate(@@path, true)
-
-    window.addEventListener :popstate do |event|
-      self.navigate(event.state.path, true)
-    end
   end
 
   def navigate(path, replace)
@@ -21,10 +17,12 @@ def navigate(path, replace)
       item = Agenda
     end
 
-    if replace
-      history.replaceState({path: path}, nil, path)
-    else
-      history.pushState({path: path}, nil, path)
+    if defined? history
+      if replace
+        history.replaceState({path: path}, nil, path)
+      else
+        history.pushState({path: path}, nil, path)
+      end
     end
 
     @item = item
@@ -57,6 +55,10 @@ def render
   end
 
   def componentDidMount()
+    window.addEventListener :popstate do |event|
+      self.navigate(event.state.path, true)
+    end
+
     def window.onresize()
       main = document.querySelector('main')
       header = document.querySelector('header.navbar')

Mime
View raw message