# HG changeset patch # User Edho Arief # Date 1352700091 -25200 # Node ID 2b1041e8c35e3a85ec27c265215832c958d12636 # Parent a92e732a2caa1e2d2a6950efc23aff247b7bda00 Allows parameter-based width passing. Requires switching to .search. diff -r a92e732a2caa -r 2b1041e8c35e app/assets/javascripts/init.tabs.js --- a/app/assets/javascripts/init.tabs.js Mon Nov 12 12:35:33 2012 +0700 +++ b/app/assets/javascripts/init.tabs.js Mon Nov 12 13:01:31 2012 +0700 @@ -7,20 +7,26 @@ $('#markdown div').html(marked(raw)); - mode = window.location.hash.substr(1); - if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').tab('show'); } - else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').tab('show'); } + paste_resize = function(size) { + var paste = $('#paste'), + title = $('#tab-resize a.btn'); + title.html(title.html().replace(/(full|\d+px)/, size)); + if (size == 'full') { + paste.css('width', ''); + paste.data('width', '0'); + } else { + paste.css('width', size); + paste.data('width', size); + } + } $('#tab-resize ul a').click(function() { - var size = $(this).data('size'), - paste = $('#paste'), - title = $('#tab-resize a.btn'); - title.html(title.html().replace(/(Width: ).*\n/, '$1' + size + '\n')); - if (size == 'full') { - paste.css('width', ''); - } else { - paste.css('width', size); - } + paste_resize($(this).data('size')); }); + + mode = window.location.search.substr(1).split('.'); + if (mode[0] == 'highlight') { $('#paste-tabs li:eq(1) a').tab('show'); } + else if (mode[0] == 'markdown') { $('#paste-tabs li:eq(2) a').tab('show'); } + if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); } } }); diff -r a92e732a2caa -r 2b1041e8c35e app/views/pastes/show.html.erb --- a/app/views/pastes/show.html.erb Mon Nov 12 12:35:33 2012 +0700 +++ b/app/views/pastes/show.html.erb Mon Nov 12 13:01:31 2012 +0700 @@ -24,7 +24,7 @@ -
+
<%= @paste.paste %>