changeset 287:77c157a9e645

Fix hash magic links.
author edogawaconan <me@myconan.net>
date Wed, 16 Oct 2013 04:17:42 +0900
parents 08dfa1a4fe4e
children c8757469da39
files app/assets/javascripts/zp.hash_magic.js app/views/pastes/show.html.erb
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/app/assets/javascripts/zp.hash_magic.js	Wed Oct 16 04:05:52 2013 +0900
+++ b/app/assets/javascripts/zp.hash_magic.js	Wed Oct 16 04:17:42 2013 +0900
@@ -2,9 +2,13 @@
 (function($) {
   window.zp.hash_magic = {
     load_hash: function() {
-      var format = window.location.hash.slice(1)
-      if (format == "") format = "pl"
-      zp.formatter.links().filter("[href=#" + format + "]").tab('show')
+      var
+        format = window.location.hash.slice(1),
+        tab_link = function(fmt) {
+                     return zp.formatter.links().filter("[href='#" + fmt + "']")
+                   }
+      if(!tab_link(format).length) format = "pl"
+      tab_link(format).click()
     },
     set_hash: function(e) {
       if (typeof e !== "undefined") {
--- a/app/views/pastes/show.html.erb	Wed Oct 16 04:05:52 2013 +0900
+++ b/app/views/pastes/show.html.erb	Wed Oct 16 04:17:42 2013 +0900
@@ -12,7 +12,7 @@
 
 <div id="paste-show" data-id="<%= @paste.id %>">
   <ul id="paste-mode" class="nav nav-tabs">
-    <li><%= link_to 'Plain', '#pl', :data => { :toggle => 'pill' } %></li>
+    <li><%= link_to 'Plain', '#pl', :class => "active", :data => { :toggle => 'pill' } %></li>
     <li><%= link_to 'Highlight', '#hl', :data => { :toggle => 'pill' } %></li>
     <li><%= link_to 'Markdown', '#md', :data => { :toggle => 'pill' } %></li>
   </ul>