Mercurial > zeropaste
comparison app/assets/javascripts/init.tabs.js @ 134:3c777dbd6b11
Moved function declarations to beginning.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Mon, 12 Nov 2012 17:30:22 +0700 |
parents | 342373709d16 |
children | 0cd87e69dd65 |
comparison
equal
deleted
inserted
replaced
133:342373709d16 | 134:3c777dbd6b11 |
---|---|
1 $(document).ready(function() { | 1 $(document).ready(function() { |
2 if ($('#paste-show').length !== 1) { | 2 if ($('#paste-show').length !== 1) { |
3 return; | 3 return; |
4 } | 4 } |
5 var raw = $('#plain pre').text(), | 5 var raw = $('#plain pre').text(), |
6 markdown = $('#markdown div'); | 6 markdown = $('#markdown div'), |
7 update_state = function() { | |
8 var paste = $('#paste'), | |
9 mode = paste.data('mode'), | |
10 width = paste.data('width'), | |
11 qstring = '#!' + mode + '.' + width; | |
12 if (width == 'auto') { | |
13 qstring = '#!'; | |
14 if (mode != 'plain') { | |
15 qstring += mode; | |
16 } | |
17 } | |
18 window.location = qstring; | |
19 }, | |
20 paste_resize = function(size) { | |
21 var paste = $('#paste'), | |
22 title = $('#paste-resize a.btn'); | |
23 title.html(title.html().replace(/(auto|\d+px)/, size)); | |
24 if (size == 'auto') { | |
25 paste.css('width', ''); | |
26 paste.data('width', size); | |
27 } else { | |
28 paste.css('width', size); | |
29 paste.data('width', size); | |
30 } | |
31 update_state(); | |
32 }; | |
7 | 33 |
8 markdown.html(marked(raw)); | 34 markdown.html(marked(raw)); |
9 $('#highlight pre').text(raw); | 35 $('#highlight pre').text(raw); |
10 | 36 |
11 markdown.find('pre').addClass('prettyprint'); | 37 markdown.find('pre').addClass('prettyprint'); |
12 markdown.find('a').prop('rel', 'nofollow'); | 38 markdown.find('a').prop('rel', 'nofollow'); |
13 prettyPrint(); | 39 prettyPrint(); |
14 | |
15 update_state = function() { | |
16 var paste = $('#paste'), | |
17 mode = paste.data('mode'), | |
18 width = paste.data('width'), | |
19 qstring = '#!' + mode + '.' + width; | |
20 if (width == 'auto') { | |
21 qstring = '#!'; | |
22 if (mode != 'plain') { | |
23 qstring += mode; | |
24 } | |
25 } | |
26 window.location = qstring; | |
27 }; | |
28 | |
29 paste_resize = function(size) { | |
30 var paste = $('#paste'), | |
31 title = $('#paste-resize a.btn'); | |
32 title.html(title.html().replace(/(auto|\d+px)/, size)); | |
33 if (size == 'auto') { | |
34 paste.css('width', ''); | |
35 paste.data('width', size); | |
36 } else { | |
37 paste.css('width', size); | |
38 paste.data('width', size); | |
39 } | |
40 update_state(); | |
41 } | |
42 | 40 |
43 $('#paste-mode a').click(function() { | 41 $('#paste-mode a').click(function() { |
44 $('#paste').data('mode', $(this).prop('href').split('#')[1]); | 42 $('#paste').data('mode', $(this).prop('href').split('#')[1]); |
45 update_state(); | 43 update_state(); |
46 }); | 44 }); |