Mercurial > zeropaste
annotate app/assets/javascripts/zp.hash_magic.js @ 347:3ce44f960d3a
coffee: autosize_box_fix.
author | edogawaconan <me@myconan.net> |
---|---|
date | Thu, 03 Jul 2014 14:53:46 +0900 |
parents | 4b91c0c1938c |
children |
rev | line source |
---|---|
214
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
1 //= require zp.formatter |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
2 (function($) { |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
3 window.zp.hash_magic = { |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
4 load_hash: function() { |
287 | 5 var |
6 format = window.location.hash.slice(1), | |
7 tab_link = function(fmt) { | |
8 return zp.formatter.links().filter("[href='#" + fmt + "']") | |
9 } | |
10 if(!tab_link(format).length) format = "pl" | |
11 tab_link(format).click() | |
214
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
12 }, |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
13 set_hash: function(e) { |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
14 var |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
15 format = zp.formatter.current(), |
308
e855e58d137e
Always include current path when replacing state.
edogawaconan <me@myconan.net>
parents:
287
diff
changeset
|
16 newpath = window.location.pathname |
e855e58d137e
Always include current path when replacing state.
edogawaconan <me@myconan.net>
parents:
287
diff
changeset
|
17 if (format !== "pl") { newpath += "#" + format } |
e855e58d137e
Always include current path when replacing state.
edogawaconan <me@myconan.net>
parents:
287
diff
changeset
|
18 history.replaceState(null, "", newpath) |
214
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
19 }, |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
20 init: function() { |
232
e3468efc9ec9
Do check if we're on the right place
Edho Arief <edho@myconan.net>
parents:
224
diff
changeset
|
21 if (!$("#paste").length) return |
214
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
22 this.load_hash() |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
23 if (history.replaceState) { |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
24 this.set_hash() |
340 | 25 zp.formatter.links().on('shown.bs.tab', this.set_hash) |
214
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
26 } |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
27 } |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
28 } |
22c4b5f90e24
Massive javascript and html refactor. Also, ie9
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
29 })(jQuery) |