diff app/assets/javascripts/zp.hash_magic.js @ 224:6e9718a1ee11

Combine event-related actions
author Edho Arief <edho@myconan.net>
date Sun, 12 May 2013 12:56:49 +0900
parents 45ccec189bd7
children e3468efc9ec9
line wrap: on
line diff
--- a/app/assets/javascripts/zp.hash_magic.js	Sun May 12 12:48:13 2013 +0900
+++ b/app/assets/javascripts/zp.hash_magic.js	Sun May 12 12:56:49 2013 +0900
@@ -14,9 +14,11 @@
       }
     },
     set_hash: function(e) {
-      if (typeof e !== "undefined" &&
-          zp.formatter.links().filter(e.target).length === 0 &&
-          zp.viewer_width.links().filter(e.target).length === 0) { return }
+      if (typeof e !== "undefined") {
+        if (zp.formatter.links().filter(e.target).length === 0 &&
+            zp.viewer_width.links().filter(e.target).length === 0) { return }
+        else e.preventDefault()
+      }
       var
         format = zp.formatter.current(),
         width = zp.viewer_width.current,
@@ -25,7 +27,6 @@
       if (width !== "auto") { hash += "." + width }
       if (hash === "#!pl") { hash = " " }
       history.replaceState(null, "", hash)
-      if (typeof e !== "undefined") { e.preventDefault() }
     },
     init: function() {
       this.load_hash()