349
|
1 #= require zp.formatter
|
|
2 window.zp.hash_magic =
|
|
3 load_hash: ->
|
|
4 format = window.location.hash.slice(1)
|
|
5 tab_link = (fmt) -> zp.formatter.links().filter("[href='##{fmt}']")
|
|
6
|
|
7 format = "pl" unless tab_link(format).length
|
|
8 tab_link(format).click()
|
|
9
|
|
10 set_hash: (e) ->
|
|
11 format = zp.formatter.current()
|
|
12 newpath = window.location.pathname
|
|
13 newpath += "##{format}" if (format != "pl")
|
|
14 history.replaceState null, "", newpath
|
|
15
|
|
16 init: ->
|
|
17 return unless $("#paste").length
|
|
18 @load_hash()
|
|
19 if (history.replaceState)
|
|
20 @set_hash()
|
|
21 zp.formatter.links().on("shown.bs.tab", this.set_hash)
|