.m-dox-search ul#search-results li#search-current a {
background-color: #34424d;
}
+.m-dox-search ul#search-results li#search-current.m-dox-search-copied a {
+ background-color: #2a703f;
+}
.m-dox-search-typed {
color: #5b9dd9;
}
.m-dox-search ul#search-results li#search-current a {
background-color: #34424d;
}
+.m-dox-search ul#search-results li#search-current.m-dox-search-copied a {
+ background-color: #2a703f;
+}
.m-dox-search-typed {
color: #5b9dd9;
}
.m-dox-search ul#search-results li#search-current a {
background-color: var(--default-filled-background-color);
}
+.m-dox-search ul#search-results li#search-current.m-dox-search-copied a {
+ background-color: var(--success-filled-background-color);
+}
.m-dox-search-typed {
color: var(--link-color);
}
.m-dox-search ul#search-results li#search-current a {
background-color: #fbf0ec;
}
+.m-dox-search ul#search-results li#search-current.m-dox-search-copied a {
+ background-color: #4dd376;
+}
.m-dox-search-typed {
color: #ea7944;
}
.m-dox-search ul#search-results li#search-current a {
background-color: #fbf0ec;
}
+.m-dox-search ul#search-results li#search-current.m-dox-search-copied a {
+ background-color: #4dd376;
+}
.m-dox-search-typed {
color: #ea7944;
}
'M_SEARCH_DISABLED': ['NO'],
'M_SEARCH_DOWNLOAD_BINARY': ['NO'],
'M_SEARCH_HELP': [
-"""Search for symbols, directories, files, pages or modules. You can omit any
-prefix from the symbol or file path; adding a <code>:</code> or <code>/</code>
-suffix lists all members of given symbol or directory. Navigate through the
-list using <span class="m-label m-dim">↓</span> and
-<span class="m-label m-dim">↑</span>, press
-<span class="m-label m-dim">Enter</span> to go."""],
+"""<p class="m-noindent">Search for symbols, directories, files, pages or
+modules. You can omit any prefix from the symbol or file path; adding a
+<code>:</code> or <code>/</code> suffix lists all members of given symbol or
+directory.</p>
+<p class="m-noindent">Use <span class="m-label m-dim">↓</span>
+/ <span class="m-label m-dim">↑</span> to navigate through the list,
+<span class="m-label m-dim">Enter</span> to go.
+<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
+copy a link to the result using <span class="m-label m-dim">⌘</span>
+<span class="m-label m-dim">L</span> while <span class="m-label m-dim">⌘</span>
+<span class="m-label m-dim">M</span> produces a Markdown link.</p>
+"""],
'M_SEARCH_BASE_URL': [''],
'M_SEARCH_EXTERNAL_URL': ['']
}
}
/* Labels + */
- list += '<li' + (i ? '' : ' id="search-current"') + '><a href="' + results[i].url + '" onmouseover="selectResult(event)"><div class="m-label m-flat ' + color + '">' + type + '</div>' + (results[i].flags & 2 ? '<div class="m-label m-danger">deprecated</div>' : '') + (results[i].flags & 4 ? '<div class="m-label m-danger">deleted</div>' : '');
+ list += '<li' + (i ? '' : ' id="search-current"') + '><a href="' + results[i].url + '" onmouseover="selectResult(event)" data-md-link-title="' + this.escape(results[i].name.substr(results[i].name.length - value.length - results[i].suffixLength)) + '"><div class="m-label m-flat ' + color + '">' + type + '</div>' + (results[i].flags & 2 ? '<div class="m-label m-danger">deprecated</div>' : '') + (results[i].flags & 4 ? '<div class="m-label m-danger">deleted</div>' : '');
/* Render the alias (cut off from the right) */
if(results[i].alias) {
return false;
}
+/* istanbul ignore next */
+function copyToKeyboard(text) {
+ /* Append to the popup, appending to document.body would cause it to
+ scroll when focused */
+ let searchPopup = document.getElementsByClassName('m-dox-search')[0];
+ let textarea = document.createElement("textarea");
+ textarea.value = text;
+ searchPopup.appendChild(textarea);
+ textarea.focus();
+ textarea.select();
+
+ document.execCommand('copy');
+
+ searchPopup.removeChild(textarea);
+ document.getElementById('search-input').focus();
+}
+
/* Only in case we're running in a browser. Why a simple if(document) doesn't
work is beyond me. */ /* istanbul ignore if */
if(typeof document !== 'undefined') {
return false; /* so the form doesn't get sent */
+ /* Copy (Markdown) link to keyboard */
+ } else if((event.key.toLowerCase() == 'l' || event.key.toLowerCase() == 'm') && event.metaKey) {
+ let result = document.getElementById('search-current');
+ if(result) {
+ let plain = event.key.toLowerCase() == 'l';
+ let link = plain ? result.firstElementChild.href :
+ '[' + result.firstElementChild.dataset.mdLinkTitle + '](' + result.firstElementChild.href + ')';
+
+ copyToKeyboard(link);
+
+ /* Add CSS class to the element for visual feedback (this
+ will get removed on keyup), but only if it's not already
+ there (in case of key repeat, e.g.) */
+ if(result.className.indexOf('m-dox-search-copied') == -1)
+ result.className += ' m-dox-search-copied';
+ console.log("Copied " + (plain ? "link" : "Markdown link") + " to " + result.firstElementChild.dataset.mdLinkTitle);
+ }
+
+ return false; /* so L doesn't get entered into the box */
+
/* Looks like the user is inserting some text (and not cutting,
copying or whatever), allow autocompletion for the new
character. The oninput event resets this back to false, so this
}
};
+ document.onkeyup = function(event) {
+ /* Remove highlight after key is released after a link copy */
+ if((event.key.toLowerCase() == 'l' || event.key.toLowerCase() == 'm') && event.metaKey) {
+ let result = document.getElementById('search-current');
+ if(result) result.className = result.className.replace(' m-dox-search-copied', '');
+ }
+ };
+
/* Allow selecting items by mouse hover only after it moves once the
results are populated. This prevents a random item getting selected if
the cursor is left motionless over the result area. */
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
- Search for symbols, directories, files, pages or modules. You can omit any
- prefix from the symbol or file path; adding a <code>:</code> or <code>/</code>
- suffix lists all members of given symbol or directory. Navigate through the
- list using <span class="m-label m-dim">↓</span> and
- <span class="m-label m-dim">↑</span>, press
+ <p class="m-noindent">Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ <code>:</code> or <code>/</code> suffix lists all members of given symbol or
+ directory.</p>
+ <p class="m-noindent">Use <span class="m-label m-dim">↓</span>
+ / <span class="m-label m-dim">↑</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
+ <span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
+ copy a link to the result using <span class="m-label m-dim">⌘</span>
+ <span class="m-label m-dim">L</span> while <span class="m-label m-dim">⌘</span>
+ <span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
- Search for symbols, directories, files, pages or modules. You can omit any
- prefix from the symbol or file path; adding a <code>:</code> or <code>/</code>
- suffix lists all members of given symbol or directory. Navigate through the
- list using <span class="m-label m-dim">↓</span> and
- <span class="m-label m-dim">↑</span>, press
+ <p class="m-noindent">Search for symbols, directories, files, pages or
+ modules. You can omit any prefix from the symbol or file path; adding a
+ <code>:</code> or <code>/</code> suffix lists all members of given symbol or
+ directory.</p>
+ <p class="m-noindent">Use <span class="m-label m-dim">↓</span>
+ / <span class="m-label m-dim">↑</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
+ <span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
+ copy a link to the result using <span class="m-label m-dim">⌘</span>
+ <span class="m-label m-dim">L</span> while <span class="m-label m-dim">⌘</span>
+ <span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
'M_SEARCH_BASE_URL': '',
'M_SEARCH_EXTERNAL_URL': '',
'M_SEARCH_HELP':
-"""Search for symbols, directories, files, pages or modules. You can omit any
-prefix from the symbol or file path; adding a <code>:</code> or <code>/</code>
-suffix lists all members of given symbol or directory. Navigate through the
-list using <span class="m-label m-dim">↓</span> and
-<span class="m-label m-dim">↑</span>, press
-<span class="m-label m-dim">Enter</span> to go.""",
+"""<p class="m-noindent">Search for symbols, directories, files, pages or
+modules. You can omit any prefix from the symbol or file path; adding a
+<code>:</code> or <code>/</code> suffix lists all members of given symbol or
+directory.</p>
+<p class="m-noindent">Use <span class="m-label m-dim">↓</span>
+/ <span class="m-label m-dim">↑</span> to navigate through the list,
+<span class="m-label m-dim">Enter</span> to go.
+<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
+copy a link to the result using <span class="m-label m-dim">⌘</span>
+<span class="m-label m-dim">L</span> while <span class="m-label m-dim">⌘</span>
+<span class="m-label m-dim">M</span> produces a Markdown link.</p>
+""",
'M_THEME_COLOR': '#22272e',
'OUTPUT_DIRECTORY': '',
'PROJECT_BRIEF': 'is cool',