-
Notifications
You must be signed in to change notification settings - Fork 611
Update navbar design and improve search UI #1084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
03491d5
89c598e
8650771
d0da0c8
831f80c
b17b606
0048ef1
b83f783
23003ff
cd0754b
07da74b
ec7e9b9
7146752
535b25d
b8bb98c
75a3e38
9fe9ed1
4c062ec
21b220e
afaaa2e
2f3da84
ae5a14c
97a865b
6a4dcd1
2d89914
e35fe6e
1fa0853
d2d68a0
39bc218
0d5a896
f97426e
eb7a39d
614a1ad
d54e103
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,7 @@ if (!empty($_SERVER['BASE_PAGE']) | |
| <!-- External and third party libraries. --> | ||
| <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> | ||
| <?php | ||
| $jsfiles = ["ext/hogan-3.0.2.min.js", "ext/typeahead.jquery.min.js", "ext/FuzzySearch.min.js", "ext/mousetrap.min.js", "ext/jquery.scrollTo.min.js", "search.js", "common.js"]; | ||
| $jsfiles = ["ext/FuzzySearch.min.js", "ext/mousetrap.min.js", "ext/jquery.scrollTo.min.js", "search.js", "common.js"]; | ||
| foreach ($jsfiles as $filename) { | ||
| $path = dirname(__DIR__) . '/js/' . $filename; | ||
| echo '<script src="/cached.php?t=' . @filemtime($path) . '&f=/js/' . $filename . '"></script>' . "\n"; | ||
|
|
@@ -108,5 +108,51 @@ if (!empty($_SERVER['BASE_PAGE']) | |
|
|
||
| <a id="toTop" href="javascript:;"><span id="toTopHover"></span><img width="40" height="40" alt="To Top" src="/images/[email protected]"></a> | ||
|
|
||
| <div id="search-modal-backdrop" class="search-modal-backdrop"> | ||
| <div | ||
| role="dialog" | ||
| aria-label="Search modal" | ||
| id="search-modal" | ||
| class="search-modal" | ||
| > | ||
| <div class="search-modal-header"> | ||
| <div class="search-modal-form"> | ||
| <div class="search-modal-input-icon"> | ||
| <!-- https://feathericons.com search --> | ||
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg> | ||
| </div> | ||
| <input | ||
| type="text" | ||
lhsazevedo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| id="search-modal-input" | ||
| class="search-modal-input" | ||
| placeholder="Search PHP docs" | ||
| /> | ||
| </div> | ||
|
|
||
| <button aria-label="Close" class="search-modal-close-btn"> | ||
| <!-- https://pictogrammers.com/library/mdi/icon/close/ --> | ||
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/></svg> | ||
| </button> | ||
| </div> | ||
| <div | ||
| role="listbox" | ||
| aria-label="Search results" | ||
| id="search-modal-results" | ||
| class="search-modal-results" | ||
| ></div> | ||
| <div class="search-modal-helper-text"> | ||
| <div> | ||
| <span class="search-modal-helper-key">↑ ↓</span> to navigate • | ||
| <span class="search-modal-helper-key">Enter</span> to select • | ||
| <span class="search-modal-helper-key">Esc</span> to close | ||
| </div> | ||
lhsazevedo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <div> | ||
| Press <span class="search-modal-helper-key">Enter</span> without | ||
| selection to search using Google | ||
lhsazevedo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,10 +10,11 @@ String.prototype.toInt = function () { | |||||
|
|
||||||
| var PHP_NET = {}; | ||||||
|
|
||||||
| PHP_NET.HEADER_HEIGHT = 52; | ||||||
| PHP_NET.HEADER_HEIGHT = 64; | ||||||
|
|
||||||
| Mousetrap.bind('up up down down left right left right b a enter', function () { | ||||||
| $(".brand img").attr("src", "/images/php_konami.gif"); | ||||||
| window.scrollTo(0, 0); | ||||||
| }); | ||||||
| Mousetrap.bind("?", function () { | ||||||
| $("#trick").slideToggle(); | ||||||
|
|
@@ -100,12 +101,10 @@ Mousetrap.bind("b o r k", function () { | |||||
| Mousetrap.unbind("b o r k"); | ||||||
| }); | ||||||
|
|
||||||
| var FIXED_HEADER_HEIGHT = 50; | ||||||
|
|
||||||
| function cycle(to, from) { | ||||||
| from.removeClass("current"); | ||||||
| to.addClass("current"); | ||||||
| $.scrollTo(to.offset().top - FIXED_HEADER_HEIGHT); | ||||||
| $.scrollTo(to.offset().top); | ||||||
| } | ||||||
|
|
||||||
| function getNextOrPreviousSibling(node, forward) { | ||||||
|
|
@@ -253,28 +252,25 @@ function globalsearch(txt) { | |||||
| cache = JSON.parse(cache); | ||||||
|
|
||||||
| if (cache) { | ||||||
| for (var type in cache.data) { | ||||||
| var elms = cache.data[type].elements; | ||||||
| for (var node in elms) { | ||||||
| if (elms[node].description.toLowerCase().contains(term) || elms[node].name.toLowerCase().contains(term)) { | ||||||
| $("#goto .results ul").append("<li><a href='/manual/en/" + elms[node].id + ".php'>" + elms[node].name + ": " + elms[node].description + "</a></li>"); | ||||||
| if ($("#goto .results ul li") > 30) { | ||||||
| return; | ||||||
| } | ||||||
| for (const node of cache.data) { | ||||||
| if ( | ||||||
| node.description.toLowerCase().contains(term) || | ||||||
| node.name.toLowerCase().contains(term) | ||||||
| ) { | ||||||
| $("#goto .results ul").append(` | ||||||
| <li> | ||||||
| <a href='/manual/en/${node.id}.php'> | ||||||
|
||||||
| <a href='/manual/en/${node.id}.php'> | |
| <a href='/manual/LANG/${node.id}.php'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, it probably should. Actually, this code is part of the "global search" feature that triggers with g then a. I wasn’t aware of it until I had to adjust the code to prevent breaking due to changes in the search index structure.
TBH, I believe that we could just remove it and use g a as another shortcut to the new search dialog, but may be out of scope for this PR.
For now I've pushed a commit for the anchor href you pointed and the cache key a few lines before it.

Uh oh!
There was an error while loading. Please reload this page.