mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Merge branch 'master' of github.com:squidfunk/mkdocs-material
This commit is contained in:
commit
285c9cc6f5
@ -274,18 +274,39 @@ generated by users interacting with the feedback widget with the help of some
|
|||||||
|
|
||||||
``` js
|
``` js
|
||||||
var feedback = document.forms.feedback
|
var feedback = document.forms.feedback
|
||||||
|
feedback.hidden = false // (1)!
|
||||||
|
|
||||||
feedback.addEventListener("submit", function(ev) {
|
feedback.addEventListener("submit", function(ev) {
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
|
|
||||||
/* Retrieve page and feedback value */
|
var page = document.location.pathname // (2)!
|
||||||
var page = document.location.pathname
|
|
||||||
var data = ev.submitter.getAttribute("data-md-value")
|
var data = ev.submitter.getAttribute("data-md-value")
|
||||||
|
|
||||||
/* Send feedback value */
|
console.log(page, data) // (3)!
|
||||||
console.log(page, data)
|
|
||||||
|
feedback.firstElementChild.disabled = true // (4)!
|
||||||
|
|
||||||
|
var note = feedback.querySelector(
|
||||||
|
".md-feedback__note [data-md-value='" + data + "']"
|
||||||
|
)
|
||||||
|
if (note)
|
||||||
|
note.hidden = false // (5)!
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
1. The feedback widget is hidden by default so that it does not appear when
|
||||||
|
people have JavaScript turned off. So, it needs to be turned on here.
|
||||||
|
|
||||||
|
2. Retrieve page and feedback value.
|
||||||
|
|
||||||
|
3. Replace this with the code that sends the data off to your analytics
|
||||||
|
provider.
|
||||||
|
|
||||||
|
4. Disable the form after submission.
|
||||||
|
|
||||||
|
5. Show the configured notes. Which one is shown depends on the user
|
||||||
|
feedback.
|
||||||
|
|
||||||
=== ":octicons-file-code-16: `mkdocs.yml`"
|
=== ":octicons-file-code-16: `mkdocs.yml`"
|
||||||
|
|
||||||
``` yaml
|
``` yaml
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{% macro render_authors(authors) %}
|
{% macro render_authors(authors) %}
|
||||||
|
{% set git_authors = config.plugins.get("git-authors") %}
|
||||||
<span class="md-source-file__fact">
|
<span class="md-source-file__fact">
|
||||||
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
|
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
|
||||||
{% if authors | length == 1 %}
|
{% if authors | length == 1 %}
|
||||||
@ -28,9 +29,13 @@
|
|||||||
</span>
|
</span>
|
||||||
<nav>
|
<nav>
|
||||||
{% for author in authors %}
|
{% for author in authors %}
|
||||||
|
{%- if git_authors.config.show_email_address %}
|
||||||
<a href="mailto:{{ author.email }}">
|
<a href="mailto:{{ author.email }}">
|
||||||
{{- author.name -}}
|
{{- author.name -}}
|
||||||
</a>
|
</a>
|
||||||
|
{%- else -%}
|
||||||
|
{{- author.name -}}
|
||||||
|
{% endif -%}
|
||||||
{%- if loop.revindex > 1 %}, {% endif -%}
|
{%- if loop.revindex > 1 %}, {% endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
<!-- Render authors -->
|
<!-- Render authors -->
|
||||||
{% macro render_authors(authors) %}
|
{% macro render_authors(authors) %}
|
||||||
|
{% set git_authors = config.plugins.get("git-authors") %}
|
||||||
<span class="md-source-file__fact">
|
<span class="md-source-file__fact">
|
||||||
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
|
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
|
||||||
{% if authors | length == 1 %}
|
{% if authors | length == 1 %}
|
||||||
@ -54,9 +55,13 @@
|
|||||||
</span>
|
</span>
|
||||||
<nav>
|
<nav>
|
||||||
{% for author in authors %}
|
{% for author in authors %}
|
||||||
|
{%- if git_authors.config.show_email_address %}
|
||||||
<a href="mailto:{{ author.email }}">
|
<a href="mailto:{{ author.email }}">
|
||||||
{{- author.name -}}
|
{{- author.name -}}
|
||||||
</a>
|
</a>
|
||||||
|
{%- else -%}
|
||||||
|
{{- author.name -}}
|
||||||
|
{% endif -%}
|
||||||
{%- if loop.revindex > 1 %}, {% endif -%}
|
{%- if loop.revindex > 1 %}, {% endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</nav>
|
</nav>
|
||||||
|
Loading…
Reference in New Issue
Block a user