diff --git a/app/Http/Controllers/StartpageController.php b/app/Http/Controllers/StartpageController.php index 65cc6dab750986e93d84a55e1de35a4ad20a90e1..1eb1bfbff6af0aab7a151e6b079466b3eff6f86f 100644 --- a/app/Http/Controllers/StartpageController.php +++ b/app/Http/Controllers/StartpageController.php @@ -22,8 +22,23 @@ class StartpageController extends Controller $focusPages = []; $theme = "default"; + $optionParams = ['param_sprueche', 'param_newtab', 'param_maps', 'param_autocomplete', 'param_lang', 'param_key']; + $option_values = []; + + foreach ($optionParams as $param) { + $value = $request->input($param); + if ($value) { + $option_values[$param] = $value; + } + } + + $autocomplete = 'on'; + if(in_array('autocomplete', array_keys($option_values))) { + $autocomplete = $option_values['autocomplete']; + } + foreach ($request->all() as $key => $value) { - if ($value === 'on' && $key != 'param_sprueche' && $key != 'param_newtab' && $key !== 'param_maps' && $key !== 'param_autocomplete' && $key !== 'param_lang') { + if ($value === 'on' && !in_array($key, $optionParams)) { $focusPages[] = str_replace('param_', '', $key); } if ($key === 'param_theme') { @@ -43,16 +58,12 @@ class StartpageController extends Controller ->with('browser', (new Agent())->browser()) ->with('navbarFocus', 'suche') ->with('theme', $theme) - ->with('autocomplete', $request->input('param_autocomplete', 'on')) ->with('foki', $this->loadFoki()) ->with('focus', $request->input('focus', 'web')) - ->with('lang', $request->input('param_lang', $lang)) - ->with('resultCount', $request->input('param_resultCount', '20')) ->with('time', $request->input('param_time', '1500')) - ->with('sprueche', $request->input('param_sprueche', 'on')) - ->with('newtab', $request->input('param_newtab', 'on')) - ->with('maps', $maps = $request->input('param_maps', 'off')) - ->with('key', $request->input('param_key', '')); + ->with('request', $request->input('request', 'GET')) + ->with('option_values', $option_values) + ->with('autocomplete', $autocomplete); } public function loadPage($subpage) diff --git a/resources/assets/js/scriptStartPage.js b/resources/assets/js/scriptStartPage.js index 071411f56978faf39bf769a10692e7f3a18ad3b8..32893b828d59430a698c33e0cdfd3035e3f9b67e 100644 --- a/resources/assets/js/scriptStartPage.js +++ b/resources/assets/js/scriptStartPage.js @@ -28,9 +28,7 @@ function loadLocalStorage () { $('#theme').attr('href', '/css/theme.css.php?r=' + theme[0] + '&g=' + theme[1] + '&b=' + theme[2] + '&a=' + theme[3]); } } - if (localStorage.getItem('pers') && !isUseOnce()) { - setSettings(); - } + setSettings(); } } @@ -79,9 +77,9 @@ function setActionListeners () { * Loads stored settings from local storage */ function setSettings () { + var acceptedParams = ['autocomplete', 'key', 'lang', 'newtab', 'sprueche']; for (var key in localStorage) { var value = localStorage.getItem(key); - var acceptedParams = ['autocomplete', 'key', 'lang', 'maps', 'newtab', 'sprueche', 'autocomplete']; var accepted = false; for (var i in acceptedParams) { if (key === 'param_' + acceptedParams[i]) { @@ -90,19 +88,13 @@ function setSettings () { } if (accepted) { key = key.substring(6); - $('#searchForm').append('<input type="hidden" name="' + key + '" value="' + value + '">'); + // Check for existing hidden fields for this key + var existing = $('.search-hidden input[name="' + key + '"]'); + if (existing.length === 0) { + // if none exist, create a new one + $('.search-hidden').append('<input type="hidden" name="' + key + '" value="' + value + '">'); + } } - $('#foki input[type=radio]#angepasst').attr('checked', true); - } - // Change the value of the lang input field to the given parameter - var lang = localStorage.getItem('param_lang'); - if (lang !== null) { - $('input[name=lang]').val(lang); - } - // Change the value of the lang input field to the given parameter - var autocomplete = localStorage.getItem('param_autocomplete'); - if (autocomplete !== null) { - $('input[name=eingabe]').attr('autocomplete', autocomplete); } // Change the request method to the given parameter var requestMethod = localStorage.getItem('request'); diff --git a/resources/assets/less/metager/start-page.less b/resources/assets/less/metager/start-page.less index 400b9e8f1901247866640827e8e74a660d47e056..71df74f721fe161fa48b82d96c8292784e26e0e7 100644 --- a/resources/assets/less/metager/start-page.less +++ b/resources/assets/less/metager/start-page.less @@ -1,28 +1,87 @@ -#searchForm { - select { - font-size: 15px; - -webkit-appearance: none; - -moz-appearance: none; - appearance: none; - background-color: white; - padding-right: 35px; +.mg-panel { + @media(max-width: @screen-sm) { + width: 100%; } - input { - height: 40px; - font-size: 16px; + @media(min-width: @screen-sm) { + width: @screen-sm; } - button { - font-size: 16px; +} + +.search-bar { + display: flex; + align-items: stretch; + font-size: 16px; + .search-focus-selector { + background-color: transparent; + border: 1px solid #aaa; + border-radius: 5px 0px 0px 5px; + select { + width: 100%; + color: #777; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background-color: transparent; + padding-right: 35px; + } + } + .search-input-submit { + flex-grow: 1; + border-left: none; + border: 1px solid #aaa; + border-left: none; + border-radius: 0px 5px 5px 0px; + display: flex; + } + .search-input { + flex-grow: 1; + input { + border: none; + height: 40px; + &:focus { + outline-color: rgb(255, 128, 0); + -webkit-box-shadow: 0px 0px 2px 2px rgba(255, 128, 0, 1); + -moz-box-shadow: 0px 0px 2px 2px rgba(255, 128, 0, 1); + box-shadow: 0px 0px 2px 2px rgba(255, 128, 0, 1); + border-color: rgba(255, 128, 0, 1); + } + } + } + .search-submit { + border-left: 1px solid #aaa; + button { + width: 50px; + line-height: 100%; + border: 0; + background-color: transparent; + padding: 0; + height: 100%; + } + } + .search-hidden { + display: none; + } + @media (max-width: @screen-xs-max) { + flex-direction: column-reverse; + .search-focus-selector { + border: 1px solid #aaa; + border-top: none; + border-radius: 5px; + } + .search-input-submit { + border: 1px solid #aaa; + border-radius: 5px; + } } } -.focus-selector { +.search-focus-selector { background-color: white; position: relative; + text-overflow: ellipsis; &:after { content: "\f078"; - font: 15px "FontAwesome", sans-serif; - //text-align: center; + font: 15px "FontAwesome", sans-serif; //text-align: center; line-height: 30px; color: #aaa; background-color: transparent; diff --git a/resources/assets/less/metager/static-pages.less b/resources/assets/less/metager/static-pages.less index 357a3ee1d1df762267a0c3ad17ac087df1358ede..5be98ca8c7e7367032796d8f52ae159a05268b02 100644 --- a/resources/assets/less/metager/static-pages.less +++ b/resources/assets/less/metager/static-pages.less @@ -206,15 +206,6 @@ nav { } } -#searchForm button { - width: 50px; - line-height: 100%; - height: 28px; - border: 0; - background-color: transparent; - padding: 0; -} - li#info { white-space: pre-line; } @@ -553,12 +544,6 @@ label a { } } -#submit-inputgroup { - background-color: inherit; - border-left: 0; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} - input[name=eingabe] { border-right: 0; box-shadow: inset 0 1px 0px rgba(0, 0, 0, 0.075); diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 737c502799473f9b0e1c9682a05bc95bf92ac8eb..940fc8307bea06f73da139d65a6e7fd3efc8621e 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -263,34 +263,37 @@ </div> </div>--> <fieldset> - <form id="searchForm" @if(Request::has('request') && Request::input('request') === "POST") method="POST" @elseif(Request::has('request') && Request::input('request') === "GET") method="GET" @else method="GET" @endif action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/meta/meta.ger3") }}" accept-charset="UTF-8"> - <div class="input-group"> - <div class="focus-selector input-group-addon"> - <select name="focus" style="font-family: FontAwesome, sans-serif;"> - <option value="web" style="font-family: FontAwesome, sans-serif;" selected > Websuche</option> - <option value="nachrichten" style="font-family: FontAwesome, sans-serif;" > Nachrichtensuche</option> - <option value="wissenschaft" style="font-family: FontAwesome, sans-serif;" > Wissenschaftssuche</option> - <option value="produktsuche" style="font-family: FontAwesome, sans-serif;" > Produktsuche</option> - <option value="maps" style="font-family: FontAwesome, sans-serif;" > Kartensuche</option> - </select> + <form id="searchForm" method={{ $request }} action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/meta/meta.ger3") }}" accept-charset="UTF-8"> + <div class="search-bar"> + <div class="search-focus-selector"> + <select name="focus" style="font-family: FontAwesome, sans-serif;"> + <option value="web" style="font-family: FontAwesome, sans-serif;" selected > Websuche</option> + <option value="nachrichten" style="font-family: FontAwesome, sans-serif;" > Nachrichtensuche</option> + <option value="wissenschaft" style="font-family: FontAwesome, sans-serif;" > Wissenschaftssuche</option> + <option value="produktsuche" style="font-family: FontAwesome, sans-serif;" > Produktsuche</option> + <option value="maps" style="font-family: FontAwesome, sans-serif;" > Kartensuche</option> + </select> </div> - <input type="text" name="eingabe" required="" autofocus="" autocomplete="{{$autocomplete}}" class="form-control" placeholder="{{ trans('index.placeholder') }}"> - <input type="hidden" name="encoding" value="utf8"> - <input type="hidden" name="lang" value={{ $lang }} > - <input type="hidden" name="resultCount" value={{ $resultCount }} > - <input type="hidden" name="time" value={{ $time }} > - <input type="hidden" name="sprueche" value={{ $sprueche }} > - <input type="hidden" name="newtab" value={{ $newtab }} > - <input type="hidden" name="maps" value={{ $maps }} > - <input type="hidden" name="key" value={{ $key }} > - @foreach ($focusPages as $fp) - <input type="hidden" name={{ $fp }} value="on"> - @endforeach - <input type="hidden" name="theme" value={{ $theme }}> - <div class="input-group-addon" id="submit-inputgroup"> - <button type="submit"> - <i class="fa fa-search" aria-hidden="true"></i> - </button> + <div class="search-input-submit"> + <div class="search-input"> + <input type="text" name="eingabe" required="" autofocus="" autocomplete="{{$autocomplete}}" class="form-control" placeholder="{{ trans('index.placeholder') }}"> + </div> + <div class="search-submit" id="submit-inputgroup"> + <button type="submit"> + <i class="fa fa-search" aria-hidden="true"></i> + </button> + </div> + </div> + <div class="search-hidden"> + <input type="hidden" name="encoding" value="utf8"> + @foreach($option_values as $option => $value) + <input type="hidden" name={{ $option }} value={{ $value }}> + @endforeach + <input type="hidden" name="time" value={{ $time }}> + @foreach ($focusPages as $fp) + <input type="hidden" name={{ $fp }} value="on"> + @endforeach + <input type="hidden" name="theme" value={{ $theme }}> </div> </div> </form>