# HG changeset patch # User Edho Arief # Date 1352698303 -25200 # Node ID e8c632b0eb8013ffa9df74d73c6fcfd1937e038d # Parent 90eee69e4ee9d3b71cf637357e1d5dc997c9e970 Check if current location is a show paste before triggering tabs js. diff -r 90eee69e4ee9 -r e8c632b0eb80 app/assets/javascripts/init.tabs.js --- a/app/assets/javascripts/init.tabs.js Mon Nov 12 12:28:51 2012 +0700 +++ b/app/assets/javascripts/init.tabs.js Mon Nov 12 12:31:43 2012 +0700 @@ -1,24 +1,26 @@ $(document).ready(function() { - raw = $('#plain pre').text(); - - $('#highlight pre').text(raw); - window.prettyPrint && prettyPrint(); + if ($('#paste-tabs').length == 1) { + raw = $('#plain pre').text(); - $('#markdown div').html(marked(raw)); + $('#highlight pre').text(raw); + window.prettyPrint && prettyPrint(); - mode = window.location.hash.substr(1); - if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').click(); } - else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').click(); } + $('#markdown div').html(marked(raw)); + + mode = window.location.hash.substr(1); + if (mode == 'highlight') { $('#paste-tabs li:eq(1) a').click(); } + else if (mode == 'markdown') { $('#paste-tabs li:eq(2) a').click(); } - $('#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); - } - }); + $('#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); + } + }); + } });