[docs] add edit link on narrow screens (mobile) (#11014)

This commit is contained in:
Ivan Blinkov 2020-05-18 17:38:36 +03:00 committed by GitHub
parent bf66693a85
commit 452ad9bf2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -7,6 +7,7 @@ function onResize() {
$('body').attr('data-offset', window_height.toString()); $('body').attr('data-offset', window_height.toString());
var sidebar = $('#sidebar'); var sidebar = $('#sidebar');
var languages = $('#languages-dropdown') var languages = $('#languages-dropdown')
var edit = $('#edit-link');
var single_page_switch = $('#single-page-switch'); var single_page_switch = $('#single-page-switch');
if ((sidebar.width() - single_page_switch.width() - sidebar.find('.dropdown-toggle').width()) >= 36) { if ((sidebar.width() - single_page_switch.width() - sidebar.find('.dropdown-toggle').width()) >= 36) {
single_page_switch.addClass('float-right'); single_page_switch.addClass('float-right');
@ -15,10 +16,13 @@ function onResize() {
} }
if (is_wide) { if (is_wide) {
sidebar.removeClass('collapse'); sidebar.removeClass('collapse');
edit.detach().appendTo($('#edit-wrapper'));
languages.detach().appendTo($('#languages-wrapper')); languages.detach().appendTo($('#languages-wrapper'));
} else { } else {
sidebar.addClass('collapse'); sidebar.addClass('collapse');
languages.detach().insertBefore(single_page_switch); edit.detach().insertBefore(single_page_switch);
edit.addClass('float-right');
languages.detach().insertBefore(edit);
languages.addClass('float-right'); languages.addClass('float-right');
single_page_switch.removeClass('float-right'); single_page_switch.removeClass('float-right');
} }

View File

@ -23,8 +23,8 @@
{% set edit_url = page.edit_url %} {% set edit_url = page.edit_url %}
{% endif %} {% endif %}
{% if edit_url %} {% if edit_url %}
<li class="nav-item"> <li id="edit-wrapper" class="nav-item">
<a href="{{ edit_url }}" title="Edit this article" class="nav-link" rel="external nofollow noreferrer" target="_blank"><img src="/images/mkdocs/edit.svg" alt="Edit this article" class="mt-1" height="22" /></a> <a id="edit-link" href="{{ edit_url }}" title="Edit this article" class="nav-link" rel="external nofollow noreferrer" target="_blank"><img src="/images/mkdocs/edit.svg" alt="Edit this article" class="mt-1" height="22" /></a>
</li> </li>
{% endif %} {% endif %}
<li class="nav-item"> <li class="nav-item">