Mercurial > zeropaste
annotate app/assets/javascripts/init.tabs.js @ 111:a92e732a2caa
Correct way to switch tab.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Mon, 12 Nov 2012 12:35:33 +0700 |
parents | e8c632b0eb80 |
children | 2b1041e8c35e |
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 | 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 | 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); |
111 | 11 if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').tab('show'); } |
12 else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').tab('show'); } | |
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 }); |