comparison app/assets/javascripts/zp.hash_magic.js @ 287:77c157a9e645

Fix hash magic links.
author edogawaconan <me@myconan.net>
date Wed, 16 Oct 2013 04:17:42 +0900
parents fa4a1ba990ae
children e855e58d137e
comparison
equal deleted inserted replaced
286:08dfa1a4fe4e 287:77c157a9e645
1 //= require zp.formatter 1 //= require zp.formatter
2 (function($) { 2 (function($) {
3 window.zp.hash_magic = { 3 window.zp.hash_magic = {
4 load_hash: function() { 4 load_hash: function() {
5 var format = window.location.hash.slice(1) 5 var
6 if (format == "") format = "pl" 6 format = window.location.hash.slice(1),
7 zp.formatter.links().filter("[href=#" + format + "]").tab('show') 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()
8 }, 12 },
9 set_hash: function(e) { 13 set_hash: function(e) {
10 if (typeof e !== "undefined") { 14 if (typeof e !== "undefined") {
11 if (zp.formatter.links().filter(e.target).length === 0) return 15 if (zp.formatter.links().filter(e.target).length === 0) return
12 else e.preventDefault() 16 else e.preventDefault()