comparison 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
comparison
equal deleted inserted replaced
223:45ccec189bd7 224:6e9718a1ee11
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" && 17 if (typeof e !== "undefined") {
18 zp.formatter.links().filter(e.target).length === 0 && 18 if (zp.formatter.links().filter(e.target).length === 0 &&
19 zp.viewer_width.links().filter(e.target).length === 0) { return } 19 zp.viewer_width.links().filter(e.target).length === 0) { return }
20 else e.preventDefault()
21 }
20 var 22 var
21 format = zp.formatter.current(), 23 format = zp.formatter.current(),
22 width = zp.viewer_width.current, 24 width = zp.viewer_width.current,
23 hash = "#!" 25 hash = "#!"
24 hash += format 26 hash += format
25 if (width !== "auto") { hash += "." + width } 27 if (width !== "auto") { hash += "." + width }
26 if (hash === "#!pl") { hash = " " } 28 if (hash === "#!pl") { hash = " " }
27 history.replaceState(null, "", hash) 29 history.replaceState(null, "", hash)
28 if (typeof e !== "undefined") { e.preventDefault() }
29 }, 30 },
30 init: function() { 31 init: function() {
31 this.load_hash() 32 this.load_hash()
32 if (history.replaceState) { 33 if (history.replaceState) {
33 this.set_hash() 34 this.set_hash()