view app/assets/javascripts/init.tabs.js @ 110:e8c632b0eb80

Check if current location is a show paste before triggering tabs js.
author Edho Arief <edho@myconan.net>
date Mon, 12 Nov 2012 12:31:43 +0700
parents 90eee69e4ee9
children a92e732a2caa
line wrap: on
line source

$(document).ready(function() {
  if ($('#paste-tabs').length == 1) {
    raw = $('#plain pre').text();

    $('#highlight pre').text(raw);
    window.prettyPrint && prettyPrint();

    $('#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);
      }
    });
  }
});