changeset 224:6e9718a1ee11

Combine event-related actions
author Edho Arief <edho@myconan.net>
date Sun, 12 May 2013 12:56:49 +0900
parents 45ccec189bd7
children 9998d8b6c524
files app/assets/javascripts/zp.hash_magic.js
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
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()