annotate app/assets/javascripts/zp.hash_magic.coffee @ 392:95bb6750003e

Update the latest domain/https.
author nanaya <me@myconan.net>
date Sat, 13 Jun 2015 08:41:51 +0900
parents 5a4d31e97937
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
349
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
1 #= require zp.formatter
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
2 window.zp.hash_magic =
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
3 load_hash: ->
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
4 format = window.location.hash.slice(1)
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
5 tab_link = (fmt) -> zp.formatter.links().filter("[href='##{fmt}']")
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
6
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
7 format = "pl" unless tab_link(format).length
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
8 tab_link(format).click()
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
9
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
10 set_hash: (e) ->
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
11 format = zp.formatter.current()
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
12 newpath = window.location.pathname
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
13 newpath += "##{format}" if (format != "pl")
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
14 history.replaceState null, "", newpath
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
15
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
16 init: ->
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
17 return unless $("#paste").length
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
18 @load_hash()
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
19 if (history.replaceState)
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
20 @set_hash()
f802099acd37 coffee: hash_magic.
edogawaconan <me@myconan.net>
parents: 340
diff changeset
21 zp.formatter.links().on("shown.bs.tab", this.set_hash)