function initMap(domElement) {
$maps = $('.mapCanvas');
// nur bestimmte map nachladen
if(domElement != undefined) {
$maps = $(domElement + ' .mapCanvas');
}
// Google Map API 3
$maps.each(function(index, Element) {
$infotext = $(Element).children('.infotext');
var myOptions = {
'zoom': parseInt($(this).data('zoom')),
'mapTypeId': google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
var map;
var geocoder;
var marker;
var address = $(this).data('title');
geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
myOptions.center = results[0].geometry.location;
map = new google.maps.Map(Element, myOptions);
marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
});
}
});
});
};
initMap();
$.reloadContent = function(type, bereich) {
$.ajax({
url: '/content-reload/',
type: 'post',
data: { id: bereich },
success: function(ret) {
$('#'+ type +'-'+ bereich).replaceWith(ret);
// Lade google map neu
if(bereich == 'google-maps'){
initMap();
}
// tinymce neu laden
tinymce.remove();
initTinymce();
}
});
}
$(function() {
// Cookie Message ausblenden
$('.msg-close, .msg-confirm').on('keypress click', function(){
$.ajax({
url: '/cookie/',
type: 'post',
success: function() {
$("#cookie-disclaimer").toggleClass('fadeInUp fadeOutDown');
}
});
return false;
});
$('body').on('click', '[data-type="download"]', function(e) {
window.location.href = $(this).data('href');
return false;
});
$('body').on('click', '[data-open]', function(e) {
e.preventDefault();
var $this = $(this);
var $remote = $this.attr('href') || $this.data('href');
var $modalID = $this.data('open');
if ($('#' + $modalID).length > 0){
$('#' + $modalID).remove();
}
$('body').append('');
$.get($remote, function(html) {
$('#' + $modalID).html(html);
$('#' + $modalID).modal({keyboard: false});
});
});
$('body').on('click', '[data-close], .modal-header .close', function(e) {
e.preventDefault();
var $modalID = $(this).data('close');
if ($modalID == 'this') {
$(this).parents('.modal').modal('hide');
$(this).parents('.modal').remove();
}
else {
$('#' + $modalID).modal('hide');
$('#' + $modalID).remove();
}
// dynamischer Reload des Content Bereiches falls typ und bereich id vorhanden
if (typeof $(this).data('type') !== "undefined" && typeof $(this).data('bereich') !== "undefined") {
// Infos für bereich ID
var type = $(this).data('type');
var bereich = $(this).data('bereich');
//reload content
$.ajax({
url: '/content-reload/',
type: 'post',
data: { id: bereich },
success: function(ret) {
$('#'+ type +'-'+ bereich).replaceWith(ret);
// Lade google map neu
if(bereich == 'google-maps'){
initMap();
}
// tinymce neu laden
tinymce.remove();
initTinymce();
}
});
}
});
// equal row height
function equalRowHeight(){
var rowHeight = $(".equal").parent('div').height();
$('.equal').each(function(){
$(this).height(rowHeight);
});
}
equalRowHeight();
});