Mercurial > zeropaste
annotate 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 |
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 |
112
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
10 paste_resize = function(size) { |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
11 var paste = $('#paste'), |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
12 title = $('#tab-resize a.btn'); |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
13 title.html(title.html().replace(/(full|\d+px)/, size)); |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
14 if (size == 'full') { |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
15 paste.css('width', ''); |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
16 paste.data('width', '0'); |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
17 } else { |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
18 paste.css('width', size); |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
19 paste.data('width', size); |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
20 } |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
21 } |
108
a949b71c9afb
Allows paste content width resize.
Edho Arief <edho@myconan.net>
parents:
104
diff
changeset
|
22 |
110
e8c632b0eb80
Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents:
109
diff
changeset
|
23 $('#tab-resize ul a').click(function() { |
112
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
24 paste_resize($(this).data('size')); |
110
e8c632b0eb80
Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents:
109
diff
changeset
|
25 }); |
112
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
26 |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
27 mode = window.location.search.substr(1).split('.'); |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
28 if (mode[0] == 'highlight') { $('#paste-tabs li:eq(1) a').tab('show'); } |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
29 else if (mode[0] == 'markdown') { $('#paste-tabs li:eq(2) a').tab('show'); } |
2b1041e8c35e
Allows parameter-based width passing. Requires switching to .search.
Edho Arief <edho@myconan.net>
parents:
111
diff
changeset
|
30 if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); } |
110
e8c632b0eb80
Check if current location is a show paste before triggering tabs js.
Edho Arief <edho@myconan.net>
parents:
109
diff
changeset
|
31 } |
59
1833de28583a
Turns out the init file is required.
Edho Arief <edho@myconan.net>
parents:
diff
changeset
|
32 }); |