comparison app/assets/javascripts/init.tabs.js @ 110:e8c632b0eb80

Check if current location is a show paste before triggering tabs js.
author Edho Arief <edho@myconan.net>
date Mon, 12 Nov 2012 12:31:43 +0700
parents 90eee69e4ee9
children a92e732a2caa
comparison
equal deleted inserted replaced
109:90eee69e4ee9 110:e8c632b0eb80
1 $(document).ready(function() { 1 $(document).ready(function() {
2 raw = $('#plain pre').text(); 2 if ($('#paste-tabs').length == 1) {
3 raw = $('#plain pre').text();
3 4
4 $('#highlight pre').text(raw); 5 $('#highlight pre').text(raw);
5 window.prettyPrint && prettyPrint(); 6 window.prettyPrint && prettyPrint();
6 7
7 $('#markdown div').html(marked(raw)); 8 $('#markdown div').html(marked(raw));
8 9
9 mode = window.location.hash.substr(1); 10 mode = window.location.hash.substr(1);
10 if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').click(); } 11 if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').click(); }
11 else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').click(); } 12 else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').click(); }
12 13
13 $('#tab-resize ul a').click(function() { 14 $('#tab-resize ul a').click(function() {
14 var size = $(this).data('size'), 15 var size = $(this).data('size'),
15 paste = $('#paste'), 16 paste = $('#paste'),
16 title = $('#tab-resize a.btn'); 17 title = $('#tab-resize a.btn');
17 title.html(title.html().replace(/(Width: ).*\n/, '$1' + size + '\n')); 18 title.html(title.html().replace(/(Width: ).*\n/, '$1' + size + '\n'));
18 if (size == 'full') { 19 if (size == 'full') {
19 paste.css('width', ''); 20 paste.css('width', '');
20 } else { 21 } else {
21 paste.css('width', size); 22 paste.css('width', size);
22 } 23 }
23 }); 24 });
25 }
24 }); 26 });