Mercurial > zeropaste
comparison app/assets/javascripts/init.tabs.js @ 122:a836cfe4092f
Use hash instead of search because IE can't into replaceState.
Also probably better cached by browsers.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Mon, 12 Nov 2012 15:21:01 +0700 |
parents | dd7181c021de |
children | 5b58b0d6841c |
comparison
equal
deleted
inserted
replaced
121:dd7181c021de | 122:a836cfe4092f |
---|---|
12 | 12 |
13 update_state = function() { | 13 update_state = function() { |
14 var paste = $('#paste'), | 14 var paste = $('#paste'), |
15 mode = paste.data('mode'), | 15 mode = paste.data('mode'), |
16 width = paste.data('width'), | 16 width = paste.data('width'), |
17 qstring = '?' + mode + '.' + width; | 17 qstring = '#' + mode + '.' + width; |
18 if (width == 'auto') { | 18 if (width == 'auto') { |
19 qstring = '?'; | 19 qstring = '#'; |
20 if (mode != 'plain') { | 20 if (mode != 'plain') { |
21 qstring += mode; | 21 qstring += mode; |
22 } | 22 } |
23 } | 23 } |
24 history.replaceState(null, '', qstring); | 24 window.location = qstring; |
25 }; | 25 }; |
26 | 26 |
27 paste_resize = function(size) { | 27 paste_resize = function(size) { |
28 var paste = $('#paste'), | 28 var paste = $('#paste'), |
29 title = $('#tab-resize a.btn'); | 29 title = $('#tab-resize a.btn'); |
46 paste_resize($(this).data('size')); | 46 paste_resize($(this).data('size')); |
47 $('.open').removeClass('open'); | 47 $('.open').removeClass('open'); |
48 return false; | 48 return false; |
49 }); | 49 }); |
50 | 50 |
51 mode = window.location.search.substr(1).split('.'); | 51 mode = window.location.hash.substr(1).split('.'); |
52 if (mode[0] == 'highlight') { $('#paste-tabs li:eq(1) a').click(); } | 52 if (mode[0] == 'highlight') { $('#paste-tabs li:eq(1) a').click(); } |
53 else if (mode[0] == 'markdown') { $('#paste-tabs li:eq(2) a').click(); } | 53 else if (mode[0] == 'markdown') { $('#paste-tabs li:eq(2) a').click(); } |
54 if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); } | 54 if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); } |
55 | 55 |
56 } | 56 } |