Mercurial > zeropaste
changeset 103:a8768ad51926
Allows hash-based onload tab switch.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Mon, 12 Nov 2012 11:28:11 +0700 |
parents | 7a514c733e6c |
children | 9825e51ba30f |
files | app/assets/javascripts/init.tabs.js app/views/pastes/show.html.erb |
diffstat | 2 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/app/assets/javascripts/init.tabs.js Mon Nov 12 11:12:20 2012 +0700 +++ b/app/assets/javascripts/init.tabs.js Mon Nov 12 11:28:11 2012 +0700 @@ -2,5 +2,8 @@ raw = $('#plain > pre').text(); $('#highlight > pre').text(raw); $('#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(); } window.prettyPrint && prettyPrint(); });
--- a/app/views/pastes/show.html.erb Mon Nov 12 11:12:20 2012 +0700 +++ b/app/views/pastes/show.html.erb Mon Nov 12 11:28:11 2012 +0700 @@ -5,7 +5,7 @@ </div> <div class="tabbable"> - <ul class="nav nav-tabs"> + <ul id="paste-tabs" class="nav nav-tabs"> <li class="active"><%= link_to 'Plain', '#plain', :data => { :toggle => 'tab' } %></li> <li><%= link_to 'Highlight', '#highlight', :data => { :toggle => 'tab' } %></li> <li><%= link_to 'Markdown', '#markdown', :data => { :toggle => 'tab' } %></li>