Skip to content

Commit

Permalink
Contents Synced Toc
Browse files Browse the repository at this point in the history
  • Loading branch information
ROBOTIS-Will committed Aug 2, 2018
1 parent ddbde01 commit 78834fa
Show file tree
Hide file tree
Showing 45 changed files with 4,773 additions and 2,420 deletions.
Binary file modified .jekyll-metadata
Binary file not shown.
Binary file not shown.
Binary file modified .sass-cache/d345dd4f5049edbd7d4baa3fcba462b4d95c1ca8/_base.scssc
Binary file not shown.
Binary file not shown.
Binary file modified .sass-cache/d345dd4f5049edbd7d4baa3fcba462b4d95c1ca8/_page.scssc
Binary file not shown.
38 changes: 7 additions & 31 deletions _includes/masthead.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,37 +284,6 @@
<button class="mobile_button" onclick="movetopage('https://github.com/ROBOTIS-GIT');" style="background-image: url(/assets/images/github_mobile_logo.png); width: 30%;">GitHub</button>
</div>

<!-- local navigation
<div class="local_navigation">
<select id="local_navigation_depth1">
<option value = "default">Select Category</option>
{% for nav in site.data.navigation.main %}
{% if page.lang=='kr' %}
{% if nav.titlekr %}
{% assign depth1_title=nav.titlekr %}
{% assign depth1_url=nav.url %}
{% else %}
{% assign depth1_title=null %}
{% assign depth1_url=null %}
{% endif %}
{% elsif page.lang=='en' %}
{% if nav.title %}
{% assign depth1_title=nav.title %}
{% assign depth1_url=nav.url %}
{% else %}
{% assign depth1_title=null %}
{% assign depth1_url=null %}
{% endif %}
{% else %}
{% assign depth1_title=null %}
{% assign depth1_url=null %}
{% endif %}
<option id="{{ depth1_title }}" value = "{{ depth1_title }}">{{ depth1_title }}</option>
{% endfor %}
</select>
</div>
-->

<!-- Google Custom Search -->
<form class="searchbox" method="get" id="site_search">
<script>
Expand All @@ -331,6 +300,13 @@
<gcse:search></gcse:search>
</form>
<!-- end of Google Custom Search -->
<!-- {% if page.lang=='kr' %}
{% else %}
<form class="searchbox" id="search-form">
<input type="search" placeholder="Search" style="height:56px;width:230px;size:16px;">
<button type="submit" style="height:56px;width:55px;">Search</button>
</form>
{% endif %} -->

</div>
</div>
18 changes: 11 additions & 7 deletions _includes/nav_list
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
{% else %}

{% assign toplevel_id = navurl | split: "/" %}
{% assign toppage_id = toplevel_id | reverse %}
{% if nav.children != null %}
<li class="has-children">
<input type="checkbox" name="toplevel" id="{{ toplevel_id.last }}">
<label for="{{ toplevel_id.last }}"><button class="tocLevel1" id="{{ toplevel_id.last }}" onclick="movetopage('{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ navurl }}');">{{ forloop.index }}. {{ navtitle }}</button></label>
<input type="checkbox" name="toplevel" id="{{ toppage_id[1] }}_{{ toplevel_id.last | remove: "#" | prepend: "toc_" }}">
<label for="{{ toppage_id[1] }}_{{ toplevel_id.last | remove: "#" | prepend: "toc_" }}"><button class="tocLevel1" onclick="movetopage('{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ navurl }}');">{{ forloop.index }}. {{ navtitle }}</button></label>
{% else %}
<li>
<a id="{{ toplevel_id.last }}" href="{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ navurl }}">{{ forloop.index }}. {{ navtitle }}</a>
<a id="{{ toppage_id[1] }}_{{ toplevel_id.last | remove: "#" | prepend: "toc_" }}" href="{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ navurl }}">{{ forloop.index }}. {{ navtitle }}</a>
</li>
{% endif %}
{% assign parent_index = forloop.index %}
Expand Down Expand Up @@ -76,17 +77,18 @@
{% endif %}

{% assign midlevel_id = childurl | split: "/" %}
{% assign midtoppage_id = midlevel_id | reverse %}
{% if child.children != null %}
{% if childtitle != null %}
{% assign child_index = child_index | plus: 1 %}
<li class="has-grandchildren">
<input type="checkbox" name="sublevel" id="{{ midlevel_id.last }}">
<label for="{{ midlevel_id.last }}"><button class="tocLevel2" id="{{ midlevel_id.last }}" onclick="movetopage('{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ childurl }}');">{{ parent_index }}. {{ child_index }}. {{ childtitle }}</button></label>
<input type="checkbox" name="sublevel" id="{{ midtoppage_id[1] }}_{{ midlevel_id.last | remove: "#" | prepend: "toc_" }}">
<label for="{{ midtoppage_id[1] }}_{{ midlevel_id.last | remove: "#" | prepend: "toc_" }}"><button class="tocLevel2" onclick="movetopage('{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ childurl }}');">{{ parent_index }}. {{ child_index }}. {{ childtitle }}</button></label>
{% endif %}
{% else %}
{% if childtitle != null %}
{% assign child_index = child_index | plus: 1 %}
<li><a id="{{ midlevel_id.last }}" href="{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ childurl }}">{{ parent_index }}. {{ child_index }}. {{ childtitle }}</a></li>
<li><a class="tocLevel2" id="{{ midtoppage_id[1] }}_{{ midlevel_id.last | remove: "#" | prepend: "toc_" }}" href="{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ childurl }}">{{ parent_index }}. {{ child_index }}. {{ childtitle }}</a></li>
{% endif %}
{% endif %}

Expand Down Expand Up @@ -129,8 +131,10 @@
{% endif %}

{% if grandchildtitle != null %}
{% assign lowlevel_id = grandchildurl | split: "/" %}
{% assign lowpage_id = lowlevel_id | reverse %}
<li>
<a href="{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ grandchildurl }}">- {{ grandchildtitle }}</a>
<a class="tocLevel3" id="{{ lowpage_id[1] }}_{{ lowlevel_id.last | remove: "#" | prepend: "toc_" }}" href="{{ site.url }}{{ site.baseurl }}/docs/{{page.lang}}{{ grandchildurl }}">- {{ grandchildtitle }}</a>
</li>
{% endif %}

Expand Down
57 changes: 46 additions & 11 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

function extendsearchtool() {
if (toggle_search_tool == 0) {
$('#site_search').css('display', 'block');
$('.searchbox').css('display', 'block');
$('#archive').css('margin-top', '40px');
toggle_search_tool = 1;
}
else {
$('#site_search').css('display', 'none');
$('.searchbox').css('display', 'none');
$('#archive').css('margin-top', '0px');
toggle_search_tool = 0;
}
Expand All @@ -56,27 +56,62 @@
alignTop: true,
overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
});

// Implmentation for Local search engine with JSON file
// $.getJSON('/test.json', function(idx) {
// $.each(idx, function(v){
// console.log(v);
// console.log(idx[v].header3);
// })
// });

});
</script>
<!-- <script>
<script>
$(function () {
var currentHash = window.location.href.split('#')[1];
var currentHash = $(location).attr('hash');
var filename = $(location).attr('href').split('/').reverse()[1];
$(document).scroll(function () {
$('.header-link').each(function () {
var top = window.pageYOffset;
var distance = top - $(this).offset().top;
var hash = $(this).attr('href');
var rawHash = $(this).attr('href');
var contentId = rawHash.replace('#', '');
var tocId = rawHash.replace('#', filename+'_toc_');
var searchContentId = $('#'+contentId);
var searchTocId = $('#'+tocId);

if (distance < 30 && distance > -30 && currentHash != hash) {
currentHash = hash;
// console.log(currentHash);
window.history.pushState(window.location.href, "title", currentHash); //Update browser URL with current anchor
// $('#' + currentHash).attr("color", "#FF6D6D"); //Syntax error
if (distance < 50 && distance > -50 && currentHash != tocId) {
// window.history.pushState(window.location.href, "title", currentHash); //Update browser URL history with current anchor
if ((searchContentId.hasClass('class-h1') || searchContentId.hasClass('class-h2') || searchContentId.hasClass('class-h3')) && $('.nav__items').has('#'+tocId).length) {
// console.log(contentId);
// console.log(tocId);
searchTocId.prop("checked", true); //Open folded Toc menu
$('.current_contents').removeClass("current_contents");

//Check if Buttoned ToC with children
// console.log(searchTocId);
if( searchTocId.prop("tagName") == "INPUT" ) {
console.log("input detected");
if( searchTocId.prop("name") == "sublevel" ) {
searchTocId.closest("li.has-grandchildren").find("label > button").addClass("current_contents");
}
}
else {
searchTocId.addClass("current_contents");
}

// Open folded Toc menu
searchTocId.closest("li.has-grandchildren").find("input").first().prop("checked", true);
searchTocId.closest("li.has-children").find("input").first().prop("checked", true);

currentHash = tocId;
}
}
});
});
});
</script> -->
</script>
<script>
window.onscroll = function () {
var offset = 64 - window.pageYOffset;
Expand Down
5 changes: 5 additions & 0 deletions _sass/robotis/_navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
right: 45px;
}

.current_contents {
color: red !important;
font-weight: 600 !important;
}

.backtotop {
display: block;
position: fixed;
Expand Down
8 changes: 7 additions & 1 deletion _sass/robotis/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ html {
.nav__items>li>ul>li a, .nav__items>li>ul>li label {
background-color: $mobile-middle-bgcolor;
color: $middle-textcolor;
max-width: 100%;
}

.nav__items>li>ul>li>ul>li a {
Expand Down Expand Up @@ -142,7 +143,12 @@ html {
display: none;
}

#site_search {
// #site_search {
// max-width: 100%;
// display: none;
// height: 40px;
// }
.searchbox {
max-width: 100%;
display: none;
height: 40px;
Expand Down
88 changes: 51 additions & 37 deletions _site/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@

function extendsearchtool() {
if (toggle_search_tool == 0) {
$('#site_search').css('display', 'block');
$('.searchbox').css('display', 'block');
$('#archive').css('margin-top', '40px');
toggle_search_tool = 1;
}
else {
$('#site_search').css('display', 'none');
$('.searchbox').css('display', 'none');
$('#archive').css('margin-top', '0px');
toggle_search_tool = 0;
}
Expand All @@ -199,22 +199,57 @@
alignTop: true,
overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
});

// Implmentation for Local search engine with JSON file
// $.getJSON('/test.json', function(idx) {
// $.each(idx, function(v){
// console.log(v);
// console.log(idx[v].header3);
// })
// });

});
</script>
<script>
$(function () {
var currentHash = window.location.href.split('#')[1];
var currentHash = $(location).attr('hash');
var filename = $(location).attr('href').split('/').reverse()[1];
$(document).scroll(function () {
$('.header-link').each(function () {
var top = window.pageYOffset;
var distance = top - $(this).offset().top;
var hash = $(this).attr('href');

if (distance < 30 && distance > -30 && currentHash != hash) {
currentHash = hash;
// console.log(currentHash);
window.history.pushState(window.location.href, "title", currentHash); //Update browser URL with current anchor
// $('#' + currentHash).attr("color", "#FF6D6D"); //Syntax error
var rawHash = $(this).attr('href');
var contentId = rawHash.replace('#', '');
var tocId = rawHash.replace('#', filename+'_toc_');
var searchContentId = $('#'+contentId);
var searchTocId = $('#'+tocId);

if (distance < 50 && distance > -50 && currentHash != tocId) {
// window.history.pushState(window.location.href, "title", currentHash); //Update browser URL history with current anchor
if ((searchContentId.hasClass('class-h1') || searchContentId.hasClass('class-h2') || searchContentId.hasClass('class-h3')) && $('.nav__items').has('#'+tocId).length) {
// console.log(contentId);
// console.log(tocId);
searchTocId.prop("checked", true); //Open folded Toc menu
$('.current_contents').removeClass("current_contents");

//Check if Buttoned ToC with children
// console.log(searchTocId);
if( searchTocId.prop("tagName") == "INPUT" ) {
console.log("input detected");
if( searchTocId.prop("name") == "sublevel" ) {
searchTocId.closest("li.has-grandchildren").find("label > button").addClass("current_contents");
}
}
else {
searchTocId.addClass("current_contents");
}

// Open folded Toc menu
searchTocId.closest("li.has-grandchildren").find("input").first().prop("checked", true);
searchTocId.closest("li.has-children").find("input").first().prop("checked", true);

currentHash = tocId;
}
}
});
});
Expand Down Expand Up @@ -3332,33 +3367,6 @@
<button class="mobile_button" onclick="movetopage('https://github.com/ROBOTIS-GIT');" style="background-image: url(/assets/images/github_mobile_logo.png); width: 30%;">GitHub</button>
</div>

<!-- local navigation
<div class="local_navigation">
<select id="local_navigation_depth1">
<option value = "default">Select Category</option>
<option id="DYNAMIXEL" value = "DYNAMIXEL">DYNAMIXEL</option>
<option id="PLATFORM" value = "PLATFORM">PLATFORM</option>
<option id="STEAM" value = "STEAM">STEAM</option>
<option id="SOFTWARE" value = "SOFTWARE">SOFTWARE</option>
<option id="PARTS" value = "PARTS">PARTS</option>
<option id="FAQ" value = "FAQ">FAQ</option>
</select>
</div>
-->

<!-- Google Custom Search -->
<form class="searchbox" method="get" id="site_search">
<script>
Expand All @@ -3375,6 +3383,12 @@
<gcse:search></gcse:search>
</form>
<!-- end of Google Custom Search -->
<!--
<form class="searchbox" id="search-form">
<input type="search" placeholder="Search" style="height:56px;width:230px;size:16px;">
<button type="submit" style="height:56px;width:55px;">Search</button>
</form>
-->

</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion _site/assets/css/main.css

Large diffs are not rendered by default.

Loading

0 comments on commit 78834fa

Please sign in to comment.