comparison app/assets/javascripts/zp.hash_magic.js @ 223:45ccec189bd7

Fix overzealous preventDefault.
author Edho Arief <edho@myconan.net>
date Sun, 12 May 2013 12:48:13 +0900
parents 22c4b5f90e24
children 6e9718a1ee11
comparison
equal deleted inserted replaced
222:9bc35555d3e3 223:45ccec189bd7
12 if (width !== undefined) { 12 if (width !== undefined) {
13 zp.viewer_width.resize(width) 13 zp.viewer_width.resize(width)
14 } 14 }
15 }, 15 },
16 set_hash: function(e) { 16 set_hash: function(e) {
17 if (typeof e !== "undefined" &&
18 zp.formatter.links().filter(e.target).length === 0 &&
19 zp.viewer_width.links().filter(e.target).length === 0) { return }
17 var 20 var
18 format = zp.formatter.current(), 21 format = zp.formatter.current(),
19 width = zp.viewer_width.current, 22 width = zp.viewer_width.current,
20 hash = "#!" 23 hash = "#!"
21 hash += format 24 hash += format
22 if (width !== "auto") { hash += "." + width } 25 if (width !== "auto") { hash += "." + width }
23 if (hash === "#!pl") { hash = " " } 26 if (hash === "#!pl") { hash = " " }
24 history.replaceState(null, "", hash) 27 history.replaceState(null, "", hash)
25 if (e !== undefined) { e.preventDefault() } 28 if (typeof e !== "undefined") { e.preventDefault() }
26 }, 29 },
27 init: function() { 30 init: function() {
28 this.load_hash() 31 this.load_hash()
29 if (history.replaceState) { 32 if (history.replaceState) {
30 this.set_hash() 33 this.set_hash()