{% if editmode %}
<style>
.accordion {
margin: 37px;
}
.accordion dt {
padding: 10px;
font-size: 14px;
color: #a963e7;
}
.accordion dd {
padding: 10px;
background-color: #569dd5;
color: #ffffff;
}
.accordion dt a {
display: block;
color: #38659e;
font-weight: bold;
text-transform: uppercase;
}
dd {
font-size: 14px;
color: #000000;
}
</style>
<div class="areablock-main">
<div class="areablock-title area-box-padding">
Instagram Beiträge Einbinden
</div>
<div class="areablock-body area-box-padding">
<dl class="accordion">
<dt><a href="">Hilfe zu Instagram Beitrag Einbinden</a></dt>
<dd>
<span>
Um den HTML-Code einzubetten, müssen Sie den Post für den Artikel in Iherem Account öffnen.<br/><br/>Klicken Sie auf die Schaltfläche mit den drei Punkten, die sich neben jedem Foto / Video befindet, und wählen Sie dann "Einbetten" => Code kopieren. Sehen Sie sich einfach den folgenden Screenshot an, wenn Sie Schwierigkeiten haben, diesen Knopf zu finden.<br/><br/><b>Fügen Sie nun den Code im CMS in das nachfolgende Textfeld!</b>
</span>
<br/>
<img src="/bundles/app/static/backend/image/edm-style/instagram-hilfe-screen.png" height="250" style="margin-top: 30px;"/>
</dd>
</dl>
{% for i in pimcore_block('instagramblock').iterator %}
<div class="schreiben">
<span class="parentbox">
{{ pimcore_textarea("instagramCode",{
"nl2br": true,
"height": 100,
"width": 735
}) }}
</span>
</div>
<div style="width:100%;height:1px;border-bottom: 1px solid #474747; margin-bottom: 30px;margin-top: 30px;"></div>
{% endfor %}
<br /><br /><br />
</div>
</div>
<script>
(function($) {
var allPanels = $('.accordion > dd');
$('.accordion > dd').hide();
$('.accordion > dt > a').click(function() {
if($(this).parent().next().is(":visible")){
allPanels.slideUp();
return false;
} else {
$(this).parent().next().slideDown();
return false;
}
});
})(jQuery);
</script>
{% else %}
{% set contInstagramblock = pimcore_block('instagramblock').getCount() %}
{% set counter = 1 %}
{% set randomID = random() %}
{% set direktausgabe = "" %}
{% set posts = "posts"~randomID %}
{% set posts = [] %}
{% for i in pimcore_block('instagramblock').iterator %}
{% set codepush = pimcore_textarea("instagramCode",{"htmlspecialchars": false}) %}
{% set direktausgabe = direktausgabe~'<div class="centered-flex">' ~ codepush ~ '</div>' %}
{% set posts = posts|merge([codepush]) %}
{% set counter = counter + 1 %}
{% endfor %}
{% set randomID = random() %}
{% set trackingObj = pimcore_website_config('konfiguration_tracking') %}
{% set buttontext = app_value(trackingObj, 'getButtontext') %}
{% set instagraminfotext = app_value(trackingObj, 'getInstagraminfotext') %}
{% set allowsocialmedia = allow_tracking() %}
{% if allowsocialmedia is empty %}
<div class="text-center" data-social-feed="btn_{{ randomID }}">
<div>{{ instagraminfotext |raw }}</div>
<div class="btn-wrp">
<button data-showposts>{{ buttontext |raw}}</button>
</div>
</div>
{% endif %}
<div class="owl-carousel owl-theme" data-social-feed="content_{{ randomID }}" data-slider="{{ randomID }}"
{{ (allowsocialmedia is not empty) ? ' style="display:block;"' : '' }}>
{% if allowsocialmedia is not empty %} {{ direktausgabe |raw }} {% endif %}
</div>
<script type="text/javascript">
(function () {
var moduleName = 'teaser_slider_{{ randomID }}_module', // naming convention XXX_module
showFeedBtn = document.querySelector('[data-social-feed="btn_{{ randomID }}"]'),
feedContainer = document.querySelector('[data-social-feed="content_{{ randomID }}"]');
if (typeof selt === 'undefined') {
selt = {
modules: {}
};
} else if (!selt.modules) {
selt.modules = {};
}
selt.modules[moduleName] = {
name: moduleName,
spritelist: 'instagram',
scriptSrc: null,
init: function () {
selt.modules.addSprite(this);
// only add feeds with user consent
if (showFeedBtn) {
showFeedBtn.addEventListener('click', callAllSprites, false)
}
{% if allowsocialmedia is not empty %}
var itemCount = {{ contInstagramblock }},
itemCountArray;
switch (true) {
case (itemCount > 2):
itemCountArray = [3, 2];
break;
case (itemCount == 2):
itemCountArray = [2, 2];
break;
default:
itemCountArray = [1, 1];
}
initSlider(itemCountArray);
{% endif %}
},
showFeed: function () {
// post is an array of code snippets copied from instagram
var posts = {{ posts|json_encode() }},
itemCount = posts.length,
itemCountArray;
showFeedBtn.parentNode.removeChild(showFeedBtn);
posts.forEach(function (el) {
// create a post from the code snippet copied from
// instagram post
var post = document.createElement("div");
post.classList.add('centered-flex');
post.innerHTML = el;
// remove the script tag but capture the source
var scripts = post.getElementsByTagName('script'),
i = scripts.length;
while (i--) {
this.scriptSrc = scripts[i].getAttribute('src');
scripts[i].parentNode.removeChild(scripts[i]);
}
feedContainer.appendChild(post);
});
// used to tell the slider how many posts to show
// based on the number of items
switch (true) {
case (itemCount > 2):
itemCountArray = [3, 2];
break;
case (itemCount == 2):
itemCountArray = [2, 2];
break;
default:
itemCountArray = [1, 1];
}
// html is injected. Now init the slider
initSlider(itemCountArray);
}
};
function callAllSprites() {
// $.cookie("allowsocialmedia", 'allow');
selt.modules.callSpriteListMethod('instagram', 'showFeed', function () {
selt.loadExternalJavascript(scriptSrc);
})
};
function initSlider(itemCountArray) {
galleryEl = $('[data-slider="{{ randomID }}"]');
galleryEl.owlCarousel({
center: false,
loop: false,
items: 1,
margin: 20,
nav: true,
navText: [
'<svg viewBox="0 0 27.2 105.2" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"><polygon class="st0" points="25.4,105.2 0,52 25.4,0 27.2,0.9 2.2,52 27.2,104.3"/></svg>',
'<svg viewBox="0 0 27.2 105.2" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"><polygon class="st0" points="25.4,105.2 0,52 25.4,0 27.2,0.9 2.2,52 27.2,104.3"/></svg>'
],
responsive: {
1280: {
items: itemCountArray[0]
},
880: {
items: itemCountArray[1]
}
}
});
}
}());//EOS
</script>
{% endif %}