Mercurial > zeropaste
annotate app/assets/javascripts/init.tabs.js @ 109:90eee69e4ee9
Shorter selector.
| author | Edho Arief <edho@myconan.net> | 
|---|---|
| date | Mon, 12 Nov 2012 12:28:51 +0700 | 
| parents | a949b71c9afb | 
| children | e8c632b0eb80 | 
| rev | line source | 
|---|---|
| 59 
1833de28583a
Turns out the init file is required.
 Edho Arief <edho@myconan.net> parents: diff
changeset | 1 $(document).ready(function() { | 
| 109 | 2 raw = $('#plain pre').text(); | 
| 104 | 3 | 
| 4 $('#highlight pre').text(raw); | |
| 5 window.prettyPrint && prettyPrint(); | |
| 6 | |
| 7 $('#markdown div').html(marked(raw)); | |
| 8 | |
| 103 
a8768ad51926
Allows hash-based onload tab switch.
 Edho Arief <edho@myconan.net> parents: 
100diff
changeset | 9 mode = window.location.hash.substr(1); | 
| 
a8768ad51926
Allows hash-based onload tab switch.
 Edho Arief <edho@myconan.net> parents: 
100diff
changeset | 10 if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').click(); } | 
| 
a8768ad51926
Allows hash-based onload tab switch.
 Edho Arief <edho@myconan.net> parents: 
100diff
changeset | 11 else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').click(); } | 
| 108 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 12 | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 13 $('#tab-resize ul a').click(function() { | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 14 var size = $(this).data('size'), | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 15 paste = $('#paste'), | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 16 title = $('#tab-resize a.btn'); | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 17 title.html(title.html().replace(/(Width: ).*\n/, '$1' + size + '\n')); | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 18 if (size == 'full') { | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 19 paste.css('width', ''); | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 20 } else { | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 21 paste.css('width', size); | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 22 } | 
| 
a949b71c9afb
Allows paste content width resize.
 Edho Arief <edho@myconan.net> parents: 
104diff
changeset | 23 }); | 
| 59 
1833de28583a
Turns out the init file is required.
 Edho Arief <edho@myconan.net> parents: diff
changeset | 24 }); | 
