Commit adf94ffb authored by Christopher Rogers's avatar Christopher Rogers

Simplifies layout language selection and js init logic

Signed-off-by: 's avatarChristopher Rogers <chrissrogers@gmail.com>
parent 68807cd4
$(function() {
var toc = $("#toc").tocify({
selectors: "h1,h2",
extendPage: false,
theme: "none",
smoothScroll: false,
showEffectSpeed: 0,
hideEffectSpeed: 180,
ignoreSelector: ".toc-ignore",
hashGenerator: 'pretty',
highlightOffset: 60,
scrollTo: -2,
scrollHistory: true,
hashGenerator: function(text, element) {
return element[0].getAttribute('id');
}
}).data("toc-tocify");
// Hack to make already open sections to start opened,
// instead of displaying an ugly animation
setTimeout(function() {
toc.setOption("showEffectSpeed", 180);
},50);
});
...@@ -13,6 +13,7 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the ...@@ -13,6 +13,7 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations License for the specific language governing permissions and limitations
under the License. under the License.
%> %>
<% language_tabs = current_page.data.language_tabs %>
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
...@@ -26,45 +27,16 @@ under the License. ...@@ -26,45 +27,16 @@ under the License.
<%= stylesheet_link_tag "screen", media: 'screen' %> <%= stylesheet_link_tag "screen", media: 'screen' %>
<%= stylesheet_link_tag "print", media: 'print' %> <%= stylesheet_link_tag "print", media: 'print' %>
<script src="//code.jquery.com/jquery-1.10.1.min.js"></script> <script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<%= javascript_include_tag "all" %> <%= javascript_include_tag "all" %>
<script> <% if language_tabs %>
$(function() { <script>
var toc = $("#toc").tocify({ $(function() {
selectors: "h1,h2", setupLanguages(<%= language_tabs.map{ |lang| lang.is_a?(Hash) ? lang.keys.first : lang }.to_json %>);
extendPage: false, });
theme: "none", </script>
smoothScroll: false, <% end %>
showEffectSpeed: 0,
hideEffectSpeed: 180,
ignoreSelector: ".toc-ignore",
hashGenerator: 'pretty',
highlightOffset: 60,
scrollTo: -2,
scrollHistory: true,
hashGenerator: function(text, element) {
return element[0].getAttribute('id');
}
}).data("toc-tocify");
// Hack to make already open sections to start opened,
// instead of displaying an ugly animation
setTimeout(function() {
toc.setOption("showEffectSpeed", 180);
},50);
setupLanguages([
<% if current_page.data.language_tabs %>
<% current_page.data.language_tabs.each do |lang| %>
<% if lang.is_a? Hash %>
'<%= lang.keys[0] %>',
<% else %>
'<%= lang %>',
<% end %>
<% end %>
<% end %>
]);
});
</script>
</head> </head>
<body class="<%= page_classes %>"> <body class="<%= page_classes %>">
...@@ -73,35 +45,33 @@ under the License. ...@@ -73,35 +45,33 @@ under the License.
<div id="toc"> <div id="toc">
</div> </div>
<% if current_page.data.toc_footers %> <% if current_page.data.toc_footers %>
<ul class="toc-footer"> <ul class="toc-footer">
<% current_page.data.toc_footers.each do |footer| %> <% current_page.data.toc_footers.each do |footer| %>
<li><%= footer %></li> <li><%= footer %></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>
</div> </div>
<div class="page-wrapper"> <div class="page-wrapper">
<div class="content"> <div class="content">
<%= yield %> <%= yield %>
<% if current_page.data.includes %> <% current_page.data.includes && current_page.data.includes.each do |include| %>
<% current_page.data.includes.each do |include| %> <%= partial "includes/#{include}" %>
<%= partial "includes/#{include}" %>
<% end %>
<% end %> <% end %>
</div> </div>
<div class="dark-box"> <div class="dark-box">
<div id="lang-selector"> <% if language_tabs %>
<% if current_page.data.language_tabs %> <div id="lang-selector">
<% current_page.data.language_tabs.each do |lang| %> <% language_tabs.each do |lang| %>
<% if lang.is_a? Hash %> <% if lang.is_a? Hash %>
<a href="#" data-language-name="<%= lang.keys[0] %>"><%= lang.values[0] %></a> <a href="#" data-language-name="<%= lang.keys[0] %>"><%= lang.values[0] %></a>
<% else %> <% else %>
<a href="#" data-language-name="<%= lang %>"><%= lang %></a> <a href="#" data-language-name="<%= lang %>"><%= lang %></a>
<% end %> <% end %>
<% end %> <% end %>
<% end %> </div>
</div> <% end %>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment