annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
59
1833de28583a Turns out the init file is required.
Edho Arief <edho@myconan.net>
parents:
diff changeset
1 $(document).ready(function() {
110
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
2 if ($('#paste-tabs').length == 1) {
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
3 raw = $('#plain pre').text();
104
9825e51ba30f Minor reorganization.
Edho Arief <edho@myconan.net>
parents: 103
diff changeset
4
110
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
5 $('#highlight pre').text(raw);
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
6 window.prettyPrint && prettyPrint();
104
9825e51ba30f Minor reorganization.
Edho Arief <edho@myconan.net>
parents: 103
diff changeset
7
110
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
8 $('#markdown div').html(marked(raw));
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
9
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
10 mode = window.location.hash.substr(1);
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
11 if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').click(); }
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
12 else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').click(); }
108
a949b71c9afb Allows paste content width resize.
Edho Arief <edho@myconan.net>
parents: 104
diff changeset
13
110
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
14 $('#tab-resize ul a').click(function() {
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
15 var size = $(this).data('size'),
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
16 paste = $('#paste'),
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
17 title = $('#tab-resize a.btn');
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
18 title.html(title.html().replace(/(Width: ).*\n/, '$1' + size + '\n'));
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
19 if (size == 'full') {
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
20 paste.css('width', '');
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
21 } else {
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
22 paste.css('width', size);
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
23 }
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
24 });
e8c632b0eb80 Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents: 109
diff changeset
25 }
59
1833de28583a Turns out the init file is required.
Edho Arief <edho@myconan.net>
parents:
diff changeset
26 });