site-libsoc/Server/public/js/components/navbar-component.js

639 lines
20 KiB
JavaScript
Raw Normal View History

(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
import { S as SvelteElement, i as init, a as attribute_to_object, b as insert_dev, s as safe_not_equal, d as dispatch_dev, v as validate_slots, c as validate_store, e as component_subscribe, o as onMount, E as getContext, g as globals, j as validate_each_argument, f as empty, n as noop, h as detach_dev, C as binding_callbacks, t as text, l as space, k as element, p as attr_dev, m as add_location, q as src_url_equal, u as append_dev, y as listen_dev, w as set_data_dev, x as destroy_each, z as run_all } from './index-d19aafba.js';
import { w as writable } from './index-4664ced0.js';
import { loadLocaleContent, locales } from '../../../../../../../../../js/libraries/serverTools.js';
/* src\navbar\navbar-component.svelte generated by Svelte v3.52.0 */
const { Object: Object_1 } = globals;
const file = "src\\navbar\\navbar-component.svelte";
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[17] = list[i][0];
child_ctx[18] = list[i][1];
return child_ctx;
}
// (87:4) {#if Object.keys($content).length!=0}
function create_if_block(ctx) {
let t0_value = /*fixHeading*/ ctx[11]() + "";
let t0;
let t1;
let header;
let input;
let t2;
let label;
let span0;
let t3;
let a0;
let img0;
let img0_src_value;
let t4;
let span1;
let raw_value = /*$content*/ ctx[4].orgName + "";
let t5;
let nav;
let ul;
let li0;
let a1;
let t6_value = /*$content*/ ctx[4].manifesto + "";
let t6;
let t7;
let li1;
let a2;
let t8_value = /*$content*/ ctx[4].joinUs + "";
let t8;
let t9;
let li2;
let a3;
let t10_value = /*$content*/ ctx[4].groups + "";
let t10;
let t11;
let li3;
let a4;
let t12_value = /*$content*/ ctx[4].communes + "";
let t12;
let t13;
let li4;
let a5;
let t14_value = /*$content*/ ctx[4].cooperatives + "";
let t14;
let t15;
let li5;
let a6;
let t16_value = /*$content*/ ctx[4].parties + "";
let t16;
let t17;
let li6;
let a7;
let t18_value = /*$content*/ ctx[4].partners + "";
let t18;
let t19;
let li7;
let button;
let picture;
let source0;
let t20;
let source1;
let t21;
let img1;
let t22;
let div;
let mounted;
let dispose;
let each_value = Object.entries(locales);
validate_each_argument(each_value);
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
const block = {
c: function create() {
t0 = text(t0_value);
t1 = space();
header = element("header");
input = element("input");
t2 = space();
label = element("label");
span0 = element("span");
t3 = space();
a0 = element("a");
img0 = element("img");
t4 = space();
span1 = element("span");
t5 = space();
nav = element("nav");
ul = element("ul");
li0 = element("li");
a1 = element("a");
t6 = text(t6_value);
t7 = space();
li1 = element("li");
a2 = element("a");
t8 = text(t8_value);
t9 = space();
li2 = element("li");
a3 = element("a");
t10 = text(t10_value);
t11 = space();
li3 = element("li");
a4 = element("a");
t12 = text(t12_value);
t13 = space();
li4 = element("li");
a5 = element("a");
t14 = text(t14_value);
t15 = space();
li5 = element("li");
a6 = element("a");
t16 = text(t16_value);
t17 = space();
li6 = element("li");
a7 = element("a");
t18 = text(t18_value);
t19 = space();
li7 = element("li");
button = element("button");
picture = element("picture");
source0 = element("source");
t20 = space();
source1 = element("source");
t21 = space();
img1 = element("img");
t22 = space();
div = element("div");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr_dev(input, "type", "checkbox");
attr_dev(input, "id", "side-menu");
add_location(input, file, 90, 12, 2866);
attr_dev(span0, "id", "hamb-line");
add_location(span0, file, 91, 45, 2997);
attr_dev(label, "id", "hamb");
attr_dev(label, "for", "side-menu");
add_location(label, file, 91, 12, 2964);
if (!src_url_equal(img0.src, img0_src_value = "/img/common/flag.png")) attr_dev(img0, "src", img0_src_value);
attr_dev(img0, "id", "navbar-logo");
attr_dev(img0, "alt", "logo");
add_location(img0, file, 94, 16, 3139);
attr_dev(span1, "id", "navbar-logo-text");
add_location(span1, file, 95, 16, 3217);
attr_dev(a0, "id", "logo-container");
attr_dev(a0, "href", "/" + /*locale*/ ctx[7] + "/");
add_location(a0, file, 93, 12, 3074);
attr_dev(a1, "href", "/" + /*locale*/ ctx[7] + "/manifesto");
add_location(a1, file, 100, 24, 3429);
add_location(li0, file, 100, 20, 3425);
attr_dev(a2, "href", "/" + /*locale*/ ctx[7] + "/join-us");
add_location(a2, file, 101, 24, 3518);
add_location(li1, file, 101, 20, 3514);
attr_dev(a3, "href", "/" + /*locale*/ ctx[7] + "/groups");
add_location(a3, file, 102, 24, 3602);
add_location(li2, file, 102, 20, 3598);
attr_dev(a4, "href", "/" + /*locale*/ ctx[7] + "/communes");
add_location(a4, file, 103, 24, 3685);
add_location(li3, file, 103, 20, 3681);
attr_dev(a5, "href", "/" + /*locale*/ ctx[7] + "/cooperatives");
add_location(a5, file, 104, 24, 3772);
add_location(li4, file, 104, 20, 3768);
attr_dev(a6, "href", "/" + /*locale*/ ctx[7] + "/parties");
add_location(a6, file, 105, 24, 3867);
add_location(li5, file, 105, 20, 3863);
attr_dev(a7, "href", "/" + /*locale*/ ctx[7] + "/partners");
add_location(a7, file, 106, 24, 3952);
add_location(li6, file, 106, 20, 3948);
attr_dev(source0, "srcset", "/img/common/globe.webp");
add_location(source0, file, 110, 32, 4182);
attr_dev(source1, "srcset", "/img/common/globe.png");
add_location(source1, file, 111, 32, 4256);
attr_dev(img1, "id", "locales-img");
attr_dev(img1, "alt", "globe");
add_location(img1, file, 112, 32, 4329);
add_location(picture, file, 109, 28, 4139);
add_location(button, file, 108, 24, 4078);
attr_dev(li7, "id", "locales");
add_location(li7, file, 107, 20, 4035);
attr_dev(div, "id", "locales-dropdown");
add_location(div, file, 116, 20, 4487);
attr_dev(ul, "id", "menu");
add_location(ul, file, 99, 16, 3389);
attr_dev(nav, "id", "nav");
add_location(nav, file, 98, 12, 3357);
attr_dev(header, "id", "navbar");
add_location(header, file, 88, 8, 2776);
},
m: function mount(target, anchor) {
insert_dev(target, t0, anchor);
insert_dev(target, t1, anchor);
insert_dev(target, header, anchor);
append_dev(header, input);
/*input_binding*/ ctx[12](input);
append_dev(header, t2);
append_dev(header, label);
append_dev(label, span0);
append_dev(header, t3);
append_dev(header, a0);
append_dev(a0, img0);
append_dev(a0, t4);
append_dev(a0, span1);
span1.innerHTML = raw_value;
/*span1_binding*/ ctx[13](span1);
append_dev(header, t5);
append_dev(header, nav);
append_dev(nav, ul);
append_dev(ul, li0);
append_dev(li0, a1);
append_dev(a1, t6);
append_dev(ul, t7);
append_dev(ul, li1);
append_dev(li1, a2);
append_dev(a2, t8);
append_dev(ul, t9);
append_dev(ul, li2);
append_dev(li2, a3);
append_dev(a3, t10);
append_dev(ul, t11);
append_dev(ul, li3);
append_dev(li3, a4);
append_dev(a4, t12);
append_dev(ul, t13);
append_dev(ul, li4);
append_dev(li4, a5);
append_dev(a5, t14);
append_dev(ul, t15);
append_dev(ul, li5);
append_dev(li5, a6);
append_dev(a6, t16);
append_dev(ul, t17);
append_dev(ul, li6);
append_dev(li6, a7);
append_dev(a7, t18);
append_dev(ul, t19);
append_dev(ul, li7);
append_dev(li7, button);
append_dev(button, picture);
append_dev(picture, source0);
append_dev(picture, t20);
append_dev(picture, source1);
append_dev(picture, t21);
append_dev(picture, img1);
append_dev(ul, t22);
append_dev(ul, div);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div, null);
}
/*div_binding*/ ctx[15](div);
/*header_binding*/ ctx[16](header);
if (!mounted) {
dispose = [
listen_dev(input, "click", /*changeNavbar*/ ctx[8], false, false, false),
listen_dev(button, "click", /*showLocales*/ ctx[9], false, false, false)
];
mounted = true;
}
},
p: function update(ctx, dirty) {
if (dirty & /*$content*/ 16 && raw_value !== (raw_value = /*$content*/ ctx[4].orgName + "")) span1.innerHTML = raw_value; if (dirty & /*$content*/ 16 && t6_value !== (t6_value = /*$content*/ ctx[4].manifesto + "")) set_data_dev(t6, t6_value);
if (dirty & /*$content*/ 16 && t8_value !== (t8_value = /*$content*/ ctx[4].joinUs + "")) set_data_dev(t8, t8_value);
if (dirty & /*$content*/ 16 && t10_value !== (t10_value = /*$content*/ ctx[4].groups + "")) set_data_dev(t10, t10_value);
if (dirty & /*$content*/ 16 && t12_value !== (t12_value = /*$content*/ ctx[4].communes + "")) set_data_dev(t12, t12_value);
if (dirty & /*$content*/ 16 && t14_value !== (t14_value = /*$content*/ ctx[4].cooperatives + "")) set_data_dev(t14, t14_value);
if (dirty & /*$content*/ 16 && t16_value !== (t16_value = /*$content*/ ctx[4].parties + "")) set_data_dev(t16, t16_value);
if (dirty & /*$content*/ 16 && t18_value !== (t18_value = /*$content*/ ctx[4].partners + "")) set_data_dev(t18, t18_value);
if (dirty & /*changeLocale, Object, locales*/ 1024) {
each_value = Object.entries(locales);
validate_each_argument(each_value);
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
each_blocks[i].m(div, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
}
},
d: function destroy(detaching) {
if (detaching) detach_dev(t0);
if (detaching) detach_dev(t1);
if (detaching) detach_dev(header);
/*input_binding*/ ctx[12](null);
/*span1_binding*/ ctx[13](null);
destroy_each(each_blocks, detaching);
/*div_binding*/ ctx[15](null);
/*header_binding*/ ctx[16](null);
mounted = false;
run_all(dispose);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_if_block.name,
type: "if",
source: "(87:4) {#if Object.keys($content).length!=0}",
ctx
});
return block;
}
// (118:24) {#each Object.entries(locales) as [loc,name]}
function create_each_block(ctx) {
let button;
let t_value = /*name*/ ctx[18] + "";
let t;
let mounted;
let dispose;
function click_handler() {
return /*click_handler*/ ctx[14](/*loc*/ ctx[17]);
}
const block = {
c: function create() {
button = element("button");
t = text(t_value);
add_location(button, file, 118, 28, 4643);
},
m: function mount(target, anchor) {
insert_dev(target, button, anchor);
append_dev(button, t);
if (!mounted) {
dispose = listen_dev(button, "click", click_handler, false, false, false);
mounted = true;
}
},
p: function update(new_ctx, dirty) {
ctx = new_ctx;
},
d: function destroy(detaching) {
if (detaching) detach_dev(button);
mounted = false;
dispose();
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_each_block.name,
type: "each",
source: "(118:24) {#each Object.entries(locales) as [loc,name]}",
ctx
});
return block;
}
function create_fragment(ctx) {
let show_if = Object.keys(/*$content*/ ctx[4]).length != 0;
let if_block_anchor;
let if_block = show_if && create_if_block(ctx);
const block = {
c: function create() {
if (if_block) if_block.c();
if_block_anchor = empty();
this.c = noop;
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
},
m: function mount(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert_dev(target, if_block_anchor, anchor);
},
p: function update(ctx, [dirty]) {
if (dirty & /*$content*/ 16) show_if = Object.keys(/*$content*/ ctx[4]).length != 0;
if (show_if) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block(ctx);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
i: noop,
o: noop,
d: function destroy(detaching) {
if (if_block) if_block.d(detaching);
if (detaching) detach_dev(if_block_anchor);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_fragment.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance($$self, $$props, $$invalidate) {
let $content;
let { $$slots: slots = {}, $$scope } = $$props;
validate_slots('navbar-component', slots, []);
let hambInput;
let navbar;
let localesDropdown;
let loaded = writable(0);
let content = writable({});
validate_store(content, 'content');
component_subscribe($$self, content, value => $$invalidate(4, $content = value));
let logoText;
let locale = loadLocaleContent(content, "navbar-component", loaded);
function changeNavbar() {
if (hambInput.checked) {
$$invalidate(1, navbar.style.background = "white", navbar);
} else {
setTimeout(
() => {
$$invalidate(1, navbar.style.position = "relative", navbar);
$$invalidate(1, navbar.style.background = "", navbar);
$$invalidate(1, navbar.style.boxShadow = "", navbar);
},
510
);
}
}
function showLocales() {
if (localesDropdown.style.display == "block") {
$$invalidate(2, localesDropdown.style.display = "none", localesDropdown);
} else {
$$invalidate(2, localesDropdown.style.display = "block", localesDropdown);
}
}
function changeLocale(lang) {
localStorage.setItem("locale", lang);
let locSplit = location.href.split("/");
let localesSymbols = Object.keys(locales);
locSplit = locSplit.filter(x => !localesSymbols.includes(x));
let loc = locSplit.slice(0, locSplit.length - 1).join("/") + "/" + lang + "/" + locSplit[locSplit.length - 1];
location.href = loc;
}
function fixHeading() {
if (locale == "ru") {
let func = () => {
if (logoText == undefined) {
setTimeout(func, 100);
} else {
if ((window.innerWidth < 1700 && window.innerWidth > 1400 || window.innerWidth < 400) && logoText.style.lineHeight != "100%") {
$$invalidate(3, logoText.style.lineHeight = "120%", logoText);
$$invalidate(3, logoText.style.top = "1rem", logoText);
$$invalidate(3, logoText.style.width = "16rem", logoText);
} else if ((window.innerWidth > 1700 || window.innerWidth > 400 && window.innerWidth < 1400) && logoText.style.lineHeight != "400%") {
$$invalidate(3, logoText.style.lineHeight = "400%", logoText);
$$invalidate(3, logoText.style.top = "0rem", logoText);
$$invalidate(3, logoText.style.width = "auto", logoText);
}
}
};
func();
addEventListener("resize", func);
}
}
onMount(() => {
});
const writable_props = [];
Object_1.keys($$props).forEach(key => {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<navbar-component> was created with unknown prop '${key}'`);
});
function input_binding($$value) {
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
hambInput = $$value;
$$invalidate(0, hambInput);
});
}
function span1_binding($$value) {
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
logoText = $$value;
$$invalidate(3, logoText);
});
}
const click_handler = loc => changeLocale(loc);
function div_binding($$value) {
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
localesDropdown = $$value;
$$invalidate(2, localesDropdown);
});
}
function header_binding($$value) {
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
navbar = $$value;
$$invalidate(1, navbar);
});
}
$$self.$capture_state = () => ({
onMount,
getContext,
writable,
loadLocaleContent,
locales,
hambInput,
navbar,
localesDropdown,
loaded,
content,
logoText,
locale,
changeNavbar,
showLocales,
changeLocale,
fixHeading,
$content
});
$$self.$inject_state = $$props => {
if ('hambInput' in $$props) $$invalidate(0, hambInput = $$props.hambInput);
if ('navbar' in $$props) $$invalidate(1, navbar = $$props.navbar);
if ('localesDropdown' in $$props) $$invalidate(2, localesDropdown = $$props.localesDropdown);
if ('loaded' in $$props) $$invalidate(5, loaded = $$props.loaded);
if ('content' in $$props) $$invalidate(6, content = $$props.content);
if ('logoText' in $$props) $$invalidate(3, logoText = $$props.logoText);
if ('locale' in $$props) $$invalidate(7, locale = $$props.locale);
};
if ($$props && "$$inject" in $$props) {
$$self.$inject_state($$props.$$inject);
}
return [
hambInput,
navbar,
localesDropdown,
logoText,
$content,
loaded,
content,
locale,
changeNavbar,
showLocales,
changeLocale,
fixHeading,
input_binding,
span1_binding,
click_handler,
div_binding,
header_binding
];
}
class Navbar_component extends SvelteElement {
constructor(options) {
super();
this.shadowRoot.innerHTML = `<style>@import '/css/common.css';#navbar{position:relative;top:0;width:min(100%,116rem);z-index:1000000000;height:5.26rem}#navbar *{font-family:var(--sans-serif, sans-serif)}#logo-container{display:flex;position:absolute;margin-left:1rem;height:100%;max-height:5.26rem;color:black;z-index:1;flex-direction:row;flex-wrap:nowrap;align-items:center}#navbar-logo{height:3.5rem;width:3.5rem;object-fit:contain;border-radius:10rem}#navbar-logo-text{position:relative;word-wrap:normal;height:100%;line-height:400%;font-size:1.4rem;color:#292222;font-family:var(--sans-serif, sans-serif);font-weight:400;padding-left:1.2rem}#nav{position:fixed;width:100%;height:100%;background-color:white;overflow:hidden;z-index:0}#menu a{display:block;padding:1.2rem;padding-top:1rem;padding-bottom:1rem;color:black;font-size:1.4rem}#menu a:hover{background-color:rgb(220, 220, 220)}#menu a:active{background-color:#f7aec0}#menu li{list-style-type:none}#nav{max-height:0}#hamb{position:absolute;cursor:pointer;right:0rem;padding:2.8rem 2rem;z-index:9999}#hamb-line{background:black;display:block;height:2px;position:relative;width:24px}#hamb-line::before,#hamb-line::after{background:black;content:'';display:block;height:100%;position:absolute;transition:all .2s ease-out;width:100%}#hamb-line::before{top:5px}#hamb-line::after{top:-5px}#side-menu{display:none}#side-menu:checked~nav{display:block;max-height:100%;padding-top:5.625rem}#side-menu:checked~#logo-container{position:fixed}#side-menu:checked~#hamb{position:fixed}#side-menu:checked~#logo-container{position:fixed}#side-menu:checked~#hamb #hamb-line{background:transparent}#side-menu:checked~#hamb #hamb-line::before{transform:rotate(-45deg);top:0}#side-menu:checked~#hamb #hamb-line::after{transform:rotate(45deg);top:0}#locales{position:relative}#locales button{width:100%;text-align:left;height:4rem}#locales button:hover{opacity:0.5}#locales-img{position:relative;top:0rem;height:2rem;margin-left:1.2rem}#locales-dropdown{position:absolute;display:none;top:5.6rem;right:1.8rem;border:#404040 solid 0.1rem;padding:1.4rem;background-color:white}#locales-dropdown button{display:block;font-family:var(--sans-serif,sans-serif);font-size:1.3rem;width:100%}#locales-dropdown button:hover{color:rgb(127, 127, 127)}#locales-dropdown>:first-child{padding-bottom:0.5rem}#locales-dropdown>:nth-child(2){padding-top:0.5rem}@media only screen and (min-width: 1400px){#navbar{position:relative;width:min(95%,116rem);left:50%;transform:translateX(-50%)}#nav{max-height:none;top:0;position:relative;float:right;width:fit-content;background-color:transparent;overflow:visible}#side-menu:checked~nav{padding-top:0}#menu li{float:left}#menu a:hover{background-color:transparent;color:rgb(127, 127, 127)}#menu a{padding:0.9rem;padding-top:1.9rem;padding-bottom:1.9rem}#hamb{display:none}#locales{position:relative;margin-right:1.8rem}#locales-img{top:0.9rem}#locales-dropdown{top:5,7rem}}</style>`;
init(
this,
{
target: this.shadowRoot,
props: attribute_to_object(this.attributes),
customElement: true
},
instance,
create_fragment,
safe_not_equal,
{},
null
);
if (options) {
if (options.target) {
insert_dev(options.target, this, options.anchor);
}
}
}
}
customElements.define("navbar-component", Navbar_component);
export { Navbar_component as default };