Commit 07fb0f6f authored by Karl's avatar Karl
Browse files

Die neuen Eigenen Suchfoki funktionieren jetzt.

Es muss noch getestet werden inwiefern die Version Kompatibel zur alten Version ist.
Es muss noch getestet werden inwiefern die Version ohne Javascript läuft
parent b2c8fe20
This diff is collapsed.
$(document).ready(function() {
getDocumentReadyForUse($("#foki > li.active > a").attr("aria-controls"));
$('iframe').iFrameResize();
createCustomFocuses();
var focus = $("#foki > li.active > a").attr("aria-controls");
var custom = $("#foki > li.active").hasClass("custom-focus-tab-selector");
getDocumentReadyForUse(focus, custom);
});
function tabs() {
//return;
$("#foki > li.tab-selector > a").each(function() {
if ($(this).attr("target") != "_blank") {
$(this).attr("href", "#" + $(this).attr("aria-controls"));
......@@ -29,16 +30,19 @@ function tabs() {
});
}
function getDocumentReadyForUse(fokus) {
function getDocumentReadyForUse(fokus, custom = false) {
clickLog();
popovers();
if (fokus === "bilder") imageLoader();
if (custom) initialLoadContent(fokus);
//pagination();
tabs();
theme();
fokiChanger();
pluginInfo();
productWidget();
$('iframe:not(.resized)').iFrameResize();
$('iframe').addClass("resized");
}
function pluginInfo() {
......@@ -305,4 +309,172 @@ function productWidget() {
});
}
$(".lightSliderContainer").removeClass("hidden");
}
function createCustomFocuses() {
for (var key in localStorage) {
if (key.startsWith("focus_")) {
var focus = loadFocusById(key);
var active = false;
if (getActiveFocusId() === getIdFromName(focus.name)) {
active = true;
}
addFocus(focus, active);
addTab(focus, active);
}
}
}
/*
@if( $metager->getFokus() === "produktsuche" )
<li id="produktsucheTabSelector" class="active tab-selector" role="presentation" data-loaded="1">
<a aria-controls="produktsuche" data-href="#produktsuche" href="#produktsuche">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@else
<li id="produktsucheTabSelector" class="tab-selector" role="presentation" data-loaded="0">
<a aria-controls="produktsuche" data-href="{!! $metager->generateSearchLink('produktsuche') !!}" href="{!! $metager->generateSearchLink('produktsuche', false) !!}">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@endif
*/
function addFocus(focus, active = false) {
var id = getIdFromName(focus.name);
var foki = document.getElementById("foki");
// create <input>
var focusElement = document.createElement("li");
focusElement.id = id + "TabSelector";
focusElement.classList.add("tab-selector");
focusElement.classList.add("custom-focus-tab-selector");
if (active) {
focusElement.classList.add("active");
focusElement.setAttribute("data-loaded", "1");
} else {
focusElement.setAttribute("data-loaded", "0");
}
focusElement.setAttribute("role", "presentation");
// create <a>
var focusElementLink = document.createElement("a");
focusElementLink.setAttribute("aria-controls", id);
var searchLink = generateSearchLinkForFocus(focus)
focusElementLink.setAttribute("data-href", searchLink);
focusElementLink.setAttribute("href", searchLink);
// create <span> glyphicon
var focusElementIcon = document.createElement("span");
focusElementIcon.classList.add("glyphicon");
focusElementIcon.classList.add("glyphicon-cog");
// create <span> focusname
var focusElementName = document.createElement("span");
focusElementName.classList.add("hidden-xs");
focusElementName.innerHTML = focus.name;
// add new elements
var mapsTabSelector = document.getElementById("mapsTabSelector");
foki.insertBefore(focusElement, mapsTabSelector);
focusElement.appendChild(focusElementLink);
focusElementLink.appendChild(focusElementIcon);
focusElementLink.appendChild(focusElementName);
}
/*
@if( $metager->getFokus() === "produktsuche" )
<div role="tabpanel" class="tab-pane active" id="produktsuche">
<div class="row">
@yield('results')
</div>
</div>
@else
<div role="tabpanel" class="tab-pane" id="produktsuche">
<div class="loader">
<img src="/img/ajax-loader.gif" alt="" />
</div>
</div>
@endif
*/
function addTab(focus, active = false) {
var id = getIdFromName(focus.name);
// create tab div
var tabPane = document.createElement("div");
tabPane.id = id;
tabPane.classList.add("tab-pane");
if (active) {
tabPane.classList.add("active");
}
tabPane.setAttribute("role", "tabpanel");
// create row div
var row = document.createElement("div");
row.classList.add("loader");
// create loader image
var img = document.createElement("img");
img.setAttribute("src", "/img/ajax-loader.gif");
img.setAttribute("alt", "");
row.appendChild(img);
// add new elements
var tabs = document.getElementById("main-content-tabs");
tabs.appendChild(tabPane)
tabPane.appendChild(row);
}
function getIdFromName(name) {
return "focus_" + name.split(" ").join("_").toLowerCase();
}
function loadFocusById(id) {
return JSON.parse(localStorage.getItem(id));
}
function getActiveFocusId() {
var search = window.location.search;
var from = search.indexOf("focus=") + "focus=".length;
var to = search.substring(from).indexOf("&") + from;
if (to <= 0) {
to = search.substring(from).length;
}
id = search.substring(from, to);
return id;
}
// TODO catch error if link is http://localhost:8000/meta/meta.ger3?
function generateSearchLinkForFocus(focus) {
var link = document.location.href;
// remove old engine settings
// not yet tested
/*
while (link.indexOf("engine_") !== -1) {
var from = search.indexOf("engine_");
var to = search.substring(from).indexOf("&") + from;
if (to === 0) {
to = search.substring(from).length;
}
link = link.substring(0, from) + link.substring(to);
}
*/
// add new engine settings
for (var key in focus) {
if (key.startsWith("engine_")) {
var focusName = key.substring("engine_".length);
link += "&" + focusName + "=" + focus[key];
}
}
link += "&out=results";
link = replaceFocusInUrl(link);
return link;
}
function replaceFocusInUrl(url) {
var from = url.indexOf("focus=");
var to = url.substring(from).indexOf("&") + from;
if (to === 0) {
to = url.substring(from).length;
}
url = url.substring(0, from) + url.substring(to);
return url + "&focus=angepasst";
}
function initialLoadContent(fokus) {
var link = $("#" + fokus + "TabSelector a").attr("data-href");
$.get(link, function(data) {
$("#" + fokus).html(data);
getDocumentReadyForUse(fokus);
});
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ $(document).ready(function() {
if (location.href.indexOf("#plugin-modal") > -1) {
$("#plugin-modal").modal("show");
}
$('#addFocusBtn').removeClass('hide');
$("button").popover();
if (localStorage) {
var theme = localStorage.getItem("theme");
......@@ -219,14 +220,12 @@ function saveFocus() {
focus[$(this).attr("name")] = $(this).val();
});
focus["name"] = name;
if (localStorage.getItem(id) === null) {
addFocus(name);
}
if (oldId !== "") {
localStorage.removeItem(oldId);
removeFocusById(oldId);
}
localStorage.setItem(id, JSON.stringify(focus));
addFocus(name);
$("#create-focus-modal").modal("hide");
}
......@@ -260,7 +259,7 @@ function addFocus(name) {
newFocus.classList.add("hide");
newFocus.type = "radio";
newFocus.name = "focus";
newFocus.value = name;
newFocus.value = id;
newFocus.setAttribute("Form", "searchForm");
newFocus.checked = true;
newFocus.required = true;
......@@ -322,4 +321,19 @@ function loadFocusById(id) {
function uncheckAll() {
$(".focusCheckbox").prop("checked", false);
}
function resetOptions() {
localStorage.removeItem("pers");
var keys = [];
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i)
keys.push(key);
}
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.startsWith("param_" || key.startsWith("focus"))) {
localStorage.removeItem(key);
}
}
}
\ No newline at end of file
$(document).ready(function() {
// Wenn LocalStorage verfügbar ist, geben wir die Möglichkeit die Einstellungen dort zu speichern
tickOptions();
$(".allUnchecker").click(uncheckAll);
if (localStorage) {
$("#save").removeClass("hidden");
if (localStorage.getItem("pers")) {
$("#reset").removeClass("hidden");
}
$("#save").click(function() {
resetOptions();
localStorage.setItem("pers", true);
$("input[type=checkbox]:checked, input[type=hidden]").each(function(el) {
localStorage.setItem($(this).attr("name"), $(this).val());
......@@ -18,10 +13,6 @@ $(document).ready(function() {
});
document.location.href = $("#save").attr("data-href");
});
$("#reset").click(function() {
resetOptions();
document.location.href = $("#save").attr("data-href");
});
}
$(".checker").click(function() {
var selector = "." + $(this).attr("data-type");
......@@ -31,9 +22,6 @@ $(document).ready(function() {
$(selector + " input").prop("checked", true);
}
});
$(".allUnchecker").click(function() {
$(".focusCheckbox").prop("checked", false);
});
$("#unten").click(function() {
$("#settings-form").append("<input type=\"hidden\" name=\"usage\" value=\"once\">");
switch (getLanguage()) {
......@@ -62,8 +50,6 @@ $(document).ready(function() {
break;
}
});
uncheckAll();
$(".checker, .allUnchecker").removeClass("hide");
$("#settings-focus").val("angepasst");
});
......@@ -85,21 +71,6 @@ function tickOptions() {
}
}
function resetOptions() {
localStorage.removeItem("pers");
var keys = [];
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i)
keys.push(key);
}
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.startsWith("param_" || key.startsWith("focus"))) {
localStorage.removeItem(key);
}
}
}
function getLanguage() {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
......@@ -107,8 +78,4 @@ function getLanguage() {
return metaData[m]["content"];
}
}
}
}
function uncheckAll() {
$(".focusCheckbox").prop("checked", false);
\ No newline at end of file
}
\ No newline at end of file
{
"js/editLanguage.js": "js/editLanguage-7a1cbfb2ba.js",
"js/kontakt.js": "js/kontakt-de49d68db3.js",
"js/scriptResultPage.js": "js/scriptResultPage-991a866191.js",
"js/scriptStartPage.js": "js/scriptStartPage-01079f6b22.js",
"js/settings.js": "js/settings-e16aea51e9.js",
"js/scriptResultPage.js": "js/scriptResultPage-1eb7e4a36b.js",
"js/scriptStartPage.js": "js/scriptStartPage-ebe8cec134.js",
"js/settings.js": "js/settings-6ff0eab621.js",
"js/widgets.js": "js/widgets-866379dd63.js"
}
\ No newline at end of file
......@@ -7189,9 +7189,6 @@ By Class
.bold {
font-weight: bold;
}
.settings-btn {
margin-top: 25px;
}
.fokus-category {
font-size: 20px;
}
......@@ -7898,6 +7895,19 @@ footer a {
#settings-btn > * {
vertical-align: middle;
}
#settingsButtons {
display: -webkit-box;
display: flex;
flex-wrap: wrap;
}
#settingsButtons a,
#settingsButtons input {
margin-top: 25px;
}
#settings-abort-btn {
color: white;
margin-right: auto;
}
/*input[type=text]:focus, textarea:focus, input[type=email]:focus, input[type=tel]:focus {
outline-color: rgb(255, 128, 0);
-webkit-box-shadow: 0px 0px 2px 2px rgba(255, 128, 0, 1);
......
This diff is collapsed.
$(document).ready(function() {
getDocumentReadyForUse($("#foki > li.active > a").attr("aria-controls"));
$('iframe').iFrameResize();
createCustomFocuses();
var focus = $("#foki > li.active > a").attr("aria-controls");
var custom = $("#foki > li.active").hasClass("custom-focus-tab-selector");
getDocumentReadyForUse(focus, custom);
});
function tabs() {
//return;
$("#foki > li.tab-selector > a").each(function() {
if ($(this).attr("target") != "_blank") {
$(this).attr("href", "#" + $(this).attr("aria-controls"));
......@@ -29,16 +30,19 @@ function tabs() {
});
}
function getDocumentReadyForUse(fokus) {
function getDocumentReadyForUse(fokus, custom = false) {
clickLog();
popovers();
if (fokus === "bilder") imageLoader();
if (custom) initialLoadContent(fokus);
//pagination();
tabs();
theme();
fokiChanger();
pluginInfo();
productWidget();
$('iframe:not(.resized)').iFrameResize();
$('iframe').addClass("resized");
}
function pluginInfo() {
......@@ -305,4 +309,172 @@ function productWidget() {
});
}
$(".lightSliderContainer").removeClass("hidden");
}
function createCustomFocuses() {
for (var key in localStorage) {
if (key.startsWith("focus_")) {
var focus = loadFocusById(key);
var active = false;
if (getActiveFocusId() === getIdFromName(focus.name)) {
active = true;
}
addFocus(focus, active);
addTab(focus, active);
}
}
}
/*
@if( $metager->getFokus() === "produktsuche" )
<li id="produktsucheTabSelector" class="active tab-selector" role="presentation" data-loaded="1">
<a aria-controls="produktsuche" data-href="#produktsuche" href="#produktsuche">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@else
<li id="produktsucheTabSelector" class="tab-selector" role="presentation" data-loaded="0">
<a aria-controls="produktsuche" data-href="{!! $metager->generateSearchLink('produktsuche') !!}" href="{!! $metager->generateSearchLink('produktsuche', false) !!}">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@endif
*/
function addFocus(focus, active = false) {
var id = getIdFromName(focus.name);
var foki = document.getElementById("foki");
// create <input>
var focusElement = document.createElement("li");
focusElement.id = id + "TabSelector";
focusElement.classList.add("tab-selector");
focusElement.classList.add("custom-focus-tab-selector");
if (active) {
focusElement.classList.add("active");
focusElement.setAttribute("data-loaded", "1");
} else {
focusElement.setAttribute("data-loaded", "0");
}
focusElement.setAttribute("role", "presentation");
// create <a>
var focusElementLink = document.createElement("a");
focusElementLink.setAttribute("aria-controls", id);
var searchLink = generateSearchLinkForFocus(focus)
focusElementLink.setAttribute("data-href", searchLink);
focusElementLink.setAttribute("href", searchLink);
// create <span> glyphicon
var focusElementIcon = document.createElement("span");
focusElementIcon.classList.add("glyphicon");
focusElementIcon.classList.add("glyphicon-cog");
// create <span> focusname
var focusElementName = document.createElement("span");
focusElementName.classList.add("hidden-xs");
focusElementName.innerHTML = focus.name;
// add new elements
var mapsTabSelector = document.getElementById("mapsTabSelector");
foki.insertBefore(focusElement, mapsTabSelector);
focusElement.appendChild(focusElementLink);
focusElementLink.appendChild(focusElementIcon);
focusElementLink.appendChild(focusElementName);
}
/*
@if( $metager->getFokus() === "produktsuche" )
<div role="tabpanel" class="tab-pane active" id="produktsuche">
<div class="row">
@yield('results')
</div>
</div>
@else
<div role="tabpanel" class="tab-pane" id="produktsuche">
<div class="loader">
<img src="/img/ajax-loader.gif" alt="" />
</div>
</div>
@endif
*/
function addTab(focus, active = false) {
var id = getIdFromName(focus.name);
// create tab div
var tabPane = document.createElement("div");
tabPane.id = id;
tabPane.classList.add("tab-pane");
if (active) {
tabPane.classList.add("active");
}
tabPane.setAttribute("role", "tabpanel");
// create row div
var row = document.createElement("div");
row.classList.add("loader");
// create loader image
var img = document.createElement("img");
img.setAttribute("src", "/img/ajax-loader.gif");
img.setAttribute("alt", "");
row.appendChild(img);
// add new elements
var tabs = document.getElementById("main-content-tabs");
tabs.appendChild(tabPane)
tabPane.appendChild(row);
}
function getIdFromName(name) {
return "focus_" + name.split(" ").join("_").toLowerCase();
}
function loadFocusById(id) {
return JSON.parse(localStorage.getItem(id));
}
function getActiveFocusId() {
var search = window.location.search;
var from = search.indexOf("focus=") + "focus=".length;
var to = search.substring(from).indexOf("&") + from;
if (to <= 0) {
to = search.substring(from).length;
}
id = search.substring(from, to);
return id;
}
// TODO catch error if link is http://localhost:8000/meta/meta.ger3?
function generateSearchLinkForFocus(focus) {
var link = document.location.href;
// remove old engine settings
// not yet tested
/*
while (link.indexOf("engine_") !== -1) {
var from = search.indexOf("engine_");
var to = search.substring(from).indexOf("&") + from;
if (to === 0) {
to = search.substring(from).length;
}
link = link.substring(0, from) + link.substring(to);
}
*/
// add new engine settings
for (var key in focus) {
if (key.startsWith("engine_")) {
var focusName = key.substring("engine_".length);
link += "&" + focusName + "=" + focus[key];
}
}
link += "&out=results";
link = replaceFocusInUrl(link);
return link;
}
function replaceFocusInUrl(url) {
var from = url.indexOf("focus=");
var to = url.substring(from).indexOf("&") + from;
if (to === 0) {
to = url.substring(from).length;
}
url = url.substring(0, from) + url.substring(to);
return url + "&focus=angepasst";
}
function initialLoadContent(fokus) {
var link = $("#" + fokus + "TabSelector a").attr("data-href");
$.get(link, function(data) {
$("#" + fokus).html(data);
getDocumentReadyForUse(fokus);
});
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ $(document).ready(function() {
if (location.href.indexOf("#plugin-modal") > -1) {
$("#plugin-modal").modal("show");
}