Commits

edogawaconan committed 77c157a

Fix hash magic links.

Comments (0)

Files changed (2)

app/assets/javascripts/zp.hash_magic.js

 (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") {

app/views/pastes/show.html.erb

 
 <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>