Mercurial > zeropaste
comparison app/assets/javascripts/init.tabs.js @ 137:3241fe970c13
Yet another indentation fix.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Mon, 12 Nov 2012 17:43:33 +0700 |
parents | b327d80c5ff9 |
children | 13ada93ad6a2 |
comparison
equal
deleted
inserted
replaced
136:b327d80c5ff9 | 137:3241fe970c13 |
---|---|
5 var update_state = function() { | 5 var update_state = function() { |
6 var paste = $('#paste'), | 6 var paste = $('#paste'), |
7 mode = paste.data('mode'), | 7 mode = paste.data('mode'), |
8 width = paste.data('width'), | 8 width = paste.data('width'), |
9 qstring = '#!' + mode + '.' + width; | 9 qstring = '#!' + mode + '.' + width; |
10 if (width == 'auto') { | 10 if (width == 'auto') { |
11 qstring = '#!'; | 11 qstring = '#!'; |
12 if (mode != 'plain') { | 12 if (mode != 'plain') { |
13 qstring += mode; | 13 qstring += mode; |
14 } | |
15 } | 14 } |
16 window.location = qstring; | 15 } |
17 }, | 16 window.location = qstring; |
18 paste_resize = function(size) { | 17 }, |
19 var paste = $('#paste'), | 18 paste_resize = function(size) { |
20 title = $('#paste-resize a.btn'); | 19 var paste = $('#paste'), |
21 title.html(title.html().replace(/(auto|\d+px)/, size)); | 20 title = $('#paste-resize a.btn'); |
22 if (size == 'auto') { | 21 title.html(title.html().replace(/(auto|\d+px)/, size)); |
23 paste.css('width', ''); | 22 if (size == 'auto') { |
24 paste.data('width', size); | 23 paste.css('width', ''); |
25 } else { | 24 paste.data('width', size); |
26 paste.css('width', size); | 25 } else { |
27 paste.data('width', size); | 26 paste.css('width', size); |
28 } | 27 paste.data('width', size); |
29 update_state(); | 28 } |
30 }, | 29 update_state(); |
31 paste_resize_menu_handler = function() { | 30 }, |
32 paste_resize($(this).data('size')); | 31 paste_resize_menu_handler = function() { |
33 $('.open').removeClass('open'); | 32 paste_resize($(this).data('size')); |
34 return false; | 33 $('.open').removeClass('open'); |
35 }, | 34 return false; |
36 paste_mode_state_handler = function() { | 35 }, |
37 $('#paste').data('mode', $(this).prop('href').split('#')[1]); | 36 paste_mode_state_handler = function() { |
38 update_state(); | 37 $('#paste').data('mode', $(this).prop('href').split('#')[1]); |
39 }, | 38 update_state(); |
40 init_state = function() { | 39 }, |
41 mode = window.location.hash.substr(2).split('.'); | 40 init_state = function() { |
42 if (mode[0] == 'highlight') { $('#paste-mode a:eq(1)').click(); } | 41 mode = window.location.hash.substr(2).split('.'); |
43 else if (mode[0] == 'markdown') { $('#paste-mode a:eq(2)').click(); }; | 42 if (mode[0] == 'highlight') { $('#paste-mode a:eq(1)').click(); } |
44 if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); } | 43 else if (mode[0] == 'markdown') { $('#paste-mode a:eq(2)').click(); }; |
45 }, | 44 if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); } |
46 init_tabs_base = function() { | 45 }, |
47 var raw = $('#plain pre').text(), | 46 init_tabs_base = function() { |
48 markdown = $('#markdown div'); | 47 var raw = $('#plain pre').text(), |
49 markdown.html(marked(raw)); | 48 markdown = $('#markdown div'); |
50 $('#highlight pre').text(raw); | 49 markdown.html(marked(raw)); |
50 $('#highlight pre').text(raw); | |
51 | 51 |
52 markdown.find('pre').addClass('prettyprint'); | 52 markdown.find('pre').addClass('prettyprint'); |
53 markdown.find('a').prop('rel', 'nofollow'); | 53 markdown.find('a').prop('rel', 'nofollow'); |
54 prettyPrint(); | 54 prettyPrint(); |
55 }, | 55 }, |
56 init_tabs_menu = function() { | 56 init_tabs_menu = function() { |
57 $('#paste-mode a').click(paste_mode_state_handler); | 57 $('#paste-mode a').click(paste_mode_state_handler); |
58 $('#paste-resize ul a').click(paste_resize_menu_handler); | 58 $('#paste-resize ul a').click(paste_resize_menu_handler); |
59 }; | 59 }; |
60 | 60 |
61 init_tabs_base(); | 61 init_tabs_base(); |
62 init_tabs_menu(); | 62 init_tabs_menu(); |
63 init_state(); | 63 init_state(); |
64 update_state(); | 64 update_state(); |