comparison app/assets/javascripts/init.tabs.js @ 112:2b1041e8c35e

Allows parameter-based width passing. Requires switching to .search.
author Edho Arief <edho@myconan.net>
date Mon, 12 Nov 2012 13:01:31 +0700
parents a92e732a2caa
children b72f99d7b8cf
comparison
equal deleted inserted replaced
111:a92e732a2caa 112:2b1041e8c35e
5 $('#highlight pre').text(raw); 5 $('#highlight pre').text(raw);
6 window.prettyPrint && prettyPrint(); 6 window.prettyPrint && prettyPrint();
7 7
8 $('#markdown div').html(marked(raw)); 8 $('#markdown div').html(marked(raw));
9 9
10 mode = window.location.hash.substr(1); 10 paste_resize = function(size) {
11 if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').tab('show'); } 11 var paste = $('#paste'),
12 else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').tab('show'); } 12 title = $('#tab-resize a.btn');
13 title.html(title.html().replace(/(full|\d+px)/, size));
14 if (size == 'full') {
15 paste.css('width', '');
16 paste.data('width', '0');
17 } else {
18 paste.css('width', size);
19 paste.data('width', size);
20 }
21 }
13 22
14 $('#tab-resize ul a').click(function() { 23 $('#tab-resize ul a').click(function() {
15 var size = $(this).data('size'), 24 paste_resize($(this).data('size'));
16 paste = $('#paste'),
17 title = $('#tab-resize a.btn');
18 title.html(title.html().replace(/(Width: ).*\n/, '$1' + size + '\n'));
19 if (size == 'full') {
20 paste.css('width', '');
21 } else {
22 paste.css('width', size);
23 }
24 }); 25 });
26
27 mode = window.location.search.substr(1).split('.');
28 if (mode[0] == 'highlight') { $('#paste-tabs li:eq(1) a').tab('show'); }
29 else if (mode[0] == 'markdown') { $('#paste-tabs li:eq(2) a').tab('show'); }
30 if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); }
25 } 31 }
26 }); 32 });