Commit 7ab56a7a authored by Dominik Hebeler's avatar Dominik Hebeler

fixed layout and removed some unnecessary resources

parent 16cef9b4
$(function() {
setLabelText();
setKeyListeners();
setDropdownListeners();
});
/**
* Sets all action listeners for this page
*/
function setKeyListeners() {
$(document).keydown(function(event) {
if ($("input#show-create-focus").is(":checked")) {
if (event.keyCode == 27) {
$("input#show-create-focus").prop("checked", false);
} else if (event.keyCode == 13) {
$("#customSearchForm").submit();
}
}
});
}
function setDropdownListeners() {
// Listener for 'Open/Collapse all' label
$("input:checkbox#toggle-dropdowns").change(function() {
if ($(this).is(":checked")) {
// Open all dropdowns
$(".focus-dropdown-toggle").prop("checked", true);
} else {
// Close all dropdowns
$(".focus-dropdown-toggle").prop("checked", false);
}
setLabelText();
});
// Change 'Open/Collapse' all when single dropdown is changed
$(".focus-dropdown-toggle").change(function() {
var expanded = false;
$(".focus-dropdown-toggle").each(function() {
if ($(this).is(":checked")) {
expanded = true;
}
});
if (expanded === true) {
$("input:checkbox#toggle-dropdowns").prop("checked", true);
} else {
$("input:checkbox#toggle-dropdowns").prop("checked", false);
}
setLabelText();
});
}
//
// Adjusts the 'Open/Colapse all' label
function setLabelText() {
if ($("input:checkbox#toggle-dropdowns").is(":checked")) {
$("#toggle-dropdowns-label").html(
t("close-dropdowns") +
' <i class="fa fa-minus-square" aria-hidden="true"></i>'
);
} else {
$("#toggle-dropdowns-label").html(
t("open-dropdowns") +
' <i class="fa fa-plus-square" aria-hidden="true"></i>'
);
}
}
$(function() {
loadLocalStorage();
setActionListenersSearchbar();
updateLangLabelCode();
});
function setActionListenersSearchbar() {
$("#input-key").change(saveKey);
$("#input-lang").change(saveLang);
}
function saveKey() {
var key = $("#input-key").val();
localStorage.setItem("key", key);
}
function loadKey() {
var key = localStorage.getItem("key");
if (key != null) {
$("#input-key").val(key);
}
}
function saveLang() {
var lang = $("#input-lang").val();
if (lang != "all") localStorage.setItem("lang", lang);
else localStorage.removeItem("lang");
updateLangLabelCode(lang);
}
function loadLang() {
var lang = localStorage.getItem("lang");
if (lang != null) {
$("#input-lang").val(lang);
}
}
/**
* Loads the user theme and stored settings from local storage
*/
function loadLocalStorage() {
if (localStorage) {
setSettings();
loadKey();
loadLang();
}
}
function setSettings() {
var acceptedParams = ["autocomplete", "key", "lang", "newtab", "sprueche"];
for (var key in localStorage) {
var value = localStorage.getItem(key);
var accepted = false;
for (var i in acceptedParams) {
if (key === "param_" + acceptedParams[i]) {
accepted = true;
}
}
if (accepted) {
key = key.substring(6);
// 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 + '">'
);
}
}
}
// Change the request method to the given parameter
var requestMethod = localStorage.getItem("request");
if (
requestMethod !== null &&
(requestMethod === "GET" || requestMethod === "POST")
) {
$("#searchForm").attr("method", requestMethod);
}
}
function updateLangLabelCode(langcode = null) {
if (!langcode) {
var langcode = localStorage.getItem("lang");
}
if (langcode == "all") langcode = "";
$("#lang-label-code").html(langcode);
}
$(document).ready(function () {
// Wenn LocalStorage verfügbar ist, geben wir die Möglichkeit die Einstellungen dort zu speichern
tickOptions();
if (localStorage) {
$('#save').removeClass('hidden');
$('#save').click(function () {
localStorage.setItem('pers', true);
$('input[type=checkbox]:checked, input[type=hidden]').each(function () {
localStorage.setItem($(this).attr('name'), $(this).val());
});
$('select').each(function () {
localStorage.setItem($(this).attr('name'), $(this).val());
});
$('input[type=text]').each(function () {
localStorage.setItem($(this).attr('name'), $(this).val());
});
document.location.href = $('#save').attr('data-href');
});
}
$('.checker').click(function () {
var selector = '.' + $(this).attr('data-type');
if ($(selector + ' input:checked').length) {
$(selector + ' input').prop('checked', false);
} else {
$(selector + ' input').prop('checked', true);
}
});
$('#unten').click(function () {
$('#settings-form').append('<input type="hidden" name="usage" value="once">');
switch (getLanguage()) {
case 'de':
alert('Auf der folgenden Startseite sind Ihre Einstellungen nun einmalig gespeichert. Nach Ihrer ersten Suche sind diese wieder verloren. Wenn Sie diese speichern möchten, können Sie sich allerdings ein Lesezeichen für die generierte Startseite einrichten.');
break;
case 'en':
alert('On the following startpage your settings are saved one-time. They will be lost after your first search. Though if you want to save them, you can create a bookmark for the generated startpage.');
break;
case 'es':
// alert(""); TODO
break;
}
});
$('#plugin').click(function () {
$('form').attr('action', $('#save').attr('data-href') + '#plugin-modal');
switch (getLanguage()) {
case 'de':
alert('Ihr Browserplugin mit den persönlichen Sucheinstellungen wurde generiert. Folgen Sie bitte der Anleitung auf der folgenden Seite um es zu installieren. Beachten Sie: Zuvor sollten Sie ein eventuell bereits installiertes MetaGer-Plugin entfernen.');
break;
case 'en':
alert('Your browser plugin with personal settings was generated. Please follow the instructions on the following page to install it. Notice that beforehand you might have to delete a former MetaGer plugin.');
break;
case 'es':
// alert(""); TODO
break;
}
});
$('#settings-focus').val('angepasst');
});
function tickOptions () {
if (localStorage && localStorage.getItem('pers')) {
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
var value = localStorage.getItem(key);
if (key.startsWith('param_')) {
if ($('input[name=' + key + ']').length) {
$('input[name=' + key + ']').attr('checked', '');
} else {
$('select[name=' + key + '] > option[value=' + value + ']').attr('selected', true);
}
}
}
} else {
$('div.web input').attr('checked', true);
}
}
function getLanguage () {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
if (metaData[m]['httpEquiv'] == 'language') {
return metaData[m]['content'];
}
}
}
......@@ -464,6 +464,7 @@ a {
border-bottom: 1px solid #ccc;
@media (max-width: @screen-mobile) {
.card;
margin: 0;
}
&>div {
padding-right: 16px;
......@@ -498,6 +499,7 @@ a {
padding: 0 8px;
@media(max-width: @screen-mobile){
.card;
margin: 0;
}
input[type=checkbox]{
display: none;
......@@ -527,10 +529,6 @@ a {
#filter-toggle {
flex-direction: column;
}
#settings {
}
#result-count{
}
}
> div {
margin-left: 8px;
......@@ -549,7 +547,6 @@ a {
#result-count {
flex-grow: 1;
text-align: right;
width: 100%;
}
.option-toggle {
text-align: center;
......
......@@ -14,7 +14,6 @@
<i class="fas fa-angle-double-down"></i>
</a>
<script src="{{ mix('js/scriptStartPage.js') }}" defer></script>
<script src="{{ mix('js/searchbar.js') }}" defer></script>
@endsection
@section('additional-content')
......
......@@ -45,6 +45,5 @@
@include('parts.sidebar-opener', ['class' => 'fixed'])
<script src="{{ mix('js/lib.js') }}"></script>
<script src="{{ mix('js/scriptResultPage.js') }}" defer></script>
<script src="{{ mix('js/searchbar.js') }}" defer></script>
</body>
</html>
{{-- Don't forget <script src="{{ mix('js/searchbar.js') }}"></script> --}}
<fieldset>
<form id="searchForm" method={{ $request }} action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/meta/meta.ger3 ") }}" accept-charset="UTF-8">
<div class="searchbar {{$class ?? ''}}">
......
......@@ -46,7 +46,6 @@ mix
"resources/js/lib/jquery.js",
"resources/js/lib/jquery-ui.min.js",
"resources/js/lib/bootstrap.js",
"resources/js/lib/iframeResizer.min.js",
"resources/js/lib/md5.js"
],
"public/js/lib.js"
......@@ -66,9 +65,6 @@ mix
],
"public/js/scriptResultPage.js"
)
.babel("resources/js/searchbar.js", "public/js/searchbar.js")
.babel("resources/js/focus-creator.js", "public/js/focus-creator.js")
.babel("resources/js/focus-creator.js", "public/js/focus-creator.js")
.babel("resources/js/editLanguage.js", "public/js/editLanguage.js")
.babel("resources/js/bitpay.js", "public/js/bitpay.js")
// utility
......
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