Mercurial > zeropaste
comparison app/assets/javascripts/zp.hash_magic.js @ 340:4b91c0c1938c
A more specific binding.
| author | edogawaconan <me@myconan.net> |
|---|---|
| date | Wed, 28 May 2014 15:18:50 +0900 |
| parents | e855e58d137e |
| children |
comparison
equal
deleted
inserted
replaced
| 339:62d16b74e3d7 | 340:4b91c0c1938c |
|---|---|
| 9 } | 9 } |
| 10 if(!tab_link(format).length) format = "pl" | 10 if(!tab_link(format).length) format = "pl" |
| 11 tab_link(format).click() | 11 tab_link(format).click() |
| 12 }, | 12 }, |
| 13 set_hash: function(e) { | 13 set_hash: function(e) { |
| 14 if (typeof e !== "undefined") { | |
| 15 if (zp.formatter.links().filter(e.target).length === 0) return | |
| 16 else e.preventDefault() | |
| 17 } | |
| 18 var | 14 var |
| 19 format = zp.formatter.current(), | 15 format = zp.formatter.current(), |
| 20 newpath = window.location.pathname | 16 newpath = window.location.pathname |
| 21 if (format !== "pl") { newpath += "#" + format } | 17 if (format !== "pl") { newpath += "#" + format } |
| 22 history.replaceState(null, "", newpath) | 18 history.replaceState(null, "", newpath) |
| 24 init: function() { | 20 init: function() { |
| 25 if (!$("#paste").length) return | 21 if (!$("#paste").length) return |
| 26 this.load_hash() | 22 this.load_hash() |
| 27 if (history.replaceState) { | 23 if (history.replaceState) { |
| 28 this.set_hash() | 24 this.set_hash() |
| 29 $(document).on('click', $.proxy(this.set_hash, this)) | 25 zp.formatter.links().on('shown.bs.tab', this.set_hash) |
| 30 } | 26 } |
| 31 } | 27 } |
| 32 } | 28 } |
| 33 })(jQuery) | 29 })(jQuery) |
