Commit 23866f67 by Carsten Brandt

improved usability for the apidoc search

parent 003bdf6a
...@@ -119,8 +119,12 @@ table.summary-table .col-defined { width: 15%; } ...@@ -119,8 +119,12 @@ table.summary-table .col-defined { width: 15%; }
top: 50px; top: 50px;
z-index: 1000; z-index: 1000;
background: #fff; border-radius: 0;
border: solid 1px #000; /* reset all due to android browser issues http://caniuse.com/#search=border-radius */
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
} }
#search-results { #search-results {
......
...@@ -83,15 +83,13 @@ $this->beginPage(); ...@@ -83,15 +83,13 @@ $this->beginPage();
$this->registerJsFile('./jssearch.index.js', 'yii\apidoc\templates\bootstrap\assets\JsSearchAsset'); $this->registerJsFile('./jssearch.index.js', 'yii\apidoc\templates\bootstrap\assets\JsSearchAsset');
$this->registerJs(<<<JS $this->registerJs(<<<JS
$('#searchbox').focus(); var searchBox = $('#searchbox');
$(document).on("keyup", function(event) { // focus the search field
if (event.which == 27) { searchBox.focus();
$('#search-resultbox').hide();
}
});
$('#searchbox').on("keyup", function(event) { // search when typing in search field
searchBox.on("keyup", function(event) {
var query = $(this).val(); var query = $(this).val();
if (query == '' || event.which == 27) { if (query == '' || event.which == 27) {
...@@ -151,13 +149,22 @@ $('#searchbox').on("keyup", function(event) { ...@@ -151,13 +149,22 @@ $('#searchbox').on("keyup", function(event) {
$('#search-results').html(resHtml); $('#search-results').html(resHtml);
} }
}); });
// hide the search results on ESC
$(document).on("keyup", function(event) { if (event.which == 27) { $('#search-resultbox').hide(); } });
// hide search results on click to document
$(document).bind('click', function (e) { $('#search-resultbox').hide(); });
// except the following:
searchBox.bind('click', function(e) { e.stopPropagation(); });
$('#search-resultbox').bind('click', function(e) { e.stopPropagation(); });
JS JS
); );
NavBar::end(); NavBar::end();
?> ?>
<div id="search-resultbox" style="display: none;"> <div id="search-resultbox" style="display: none;" class="modal-content">
<ul id="search-results"> <ul id="search-results">
</ul> </ul>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment