function imgHoverIn(event) { if ($(event.target).attr('src') != null) { $(event.target).attr('src', getHoveredImgSrc($(event.target).attr('src'))); } if ($(event.target).css('background-image') != '') { $(event.target).css('background-image', getHoveredImgSrc($(event.target).css('background-image'))); } } function imgClickIn(event) { if ($(event.target).attr('src') != null) { $(event.target).attr('src', getClickedImgSrc($(event.target).attr('src'))); } if ($(event.target).css('background-image') != '') { $(event.target).css('background-image', getClickedImgSrc($(event.target).css('background-image'))); } } function imgOut(event) { if ($(event.target).attr('src') != null) { $(event.target).attr('src', getBaseImgSrc($(event.target).attr('src'))); } if ($(event.target).css('background-image') != '') { $(event.target).css('background-image', getBaseImgSrc($(event.target).css('background-image'))); } } function registerGalleryEventHandlers() { $(".gallery").fancybox(); } /** * Registers event handlers for hovered images. */ function registerHoverEventHandlers() { var selector = '.hovered'; $(selector).hover(imgHoverIn, imgOut); } /** * Registers event handlers for clicked images. */ function registerClickEventHandlers() { var selector = '.clicked'; $(selector).mousedown(imgClickIn); $(selector).mouseup(imgOut); } /** * Registers event handlers for displaying "more" content. */ function registerMoreContentEventHandlers() { var moreDivSelector = 'div.more'; $(moreDivSelector + ' .link').toggle(function() { $(this).next(moreDivSelector + ' .content').show(); }, function() { $(this).next(moreDivSelector + ' .content').hide(); }); } /** * Registers event handles for the top navigation menu. */ function registerMenuItemEventHandlers() { $('#top_navigation li.menuItem') .mouseenter(function() { $(this).addClass('active'); }) .mouseleave(function() { $(this).removeClass('active'); }); } /** * Prefetches the given image array. * @param images the image array to prefetch */ function prefetchImages(images) { if (images != null) { var image = new Image(); for (var i = 0; i < images.length; ++i) { image.src = images[i]; } } } function generateHighlightLinks() { var url = '/./php/events/'; $('.programm .dates .highlight').each(function (index, element) { var html = $(element).html(); html = '' + html + ''; $(element).html(html); }); } function generateProgramDatesLinks() { var urlPrefix = '/./php'; $('.programm.bl .dates .place').each(function (index, element) { var html = $(element).html(); var url = urlPrefix + '/kinos/bl'; $(element).html('' + html + ''); }); $('.programm.bb .dates .place').each(function (index, element) { var html = $(element).html(); var url = urlPrefix + '/kinos/bb'; $(element).html('' + html + ''); }); } function generateFootnoteLinks() { var urlPrefix = '/./php'; $('.programm.bl .footnote .link').each(function (index, element) { var html = $(element).html(); var url = urlPrefix + '/events/bl/'; $(element).html('' + html + ''); }); } function registerValidationEventHandlers() { $('input[type=submit].validate').click(function() { var valid = true; $(this).closest('form').each(function (i, element) { valid = valid && validate(element); }); return valid; }); } /** * Registers event handlers for captchas. */ function registerCaptchaEventHandlers() { $('div.captcha .new_image').click(function() { $(this).closest('.captcha').find('img').attr('src', '/./securimage/securimage_show.php?' + Math.random()); }); } /** * Initializes datepicker elements ('.datepicker'). */ function initDatepickers() { $.datepicker.setDefaults ({ dateFormat: 'd. MM yy', dayNames: [ 'Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag' ], dayNamesShort: [ 'So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa' ], dayNamesMin: [ 'So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa' ], monthNames: [ 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ], monthNamesShort: [ 'Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez' ] }); $('.datepicker').datepicker(); } function updateAllNewEmailAddresses(location, select) { $('input[type=checkbox].' + location + '.new').prop('checked', select); } function updateAllUnsentAddresses(location, select) { var daysBack = parseInt($('#select_unsent_addresses_' + location + '_days').val()); var thresholdTimestamp = Date.now(); thresholdTimestamp -= daysBack * 24 * 60 * 60 * 1000; $('#address_book tr').each(function(index, row) { var timestamp = $(row).find('.' + location + '.last_mail_sent .timestamp').text(); if (timestamp == null || timestamp == '' || timestamp < (thresholdTimestamp / 1000)) { $(row).find('.email.' + location + ' input[type=checkbox]') .prop('checked', select); } }); } function registerNewsletterEventHandlers() { $('#select_new_addresses_bl').click(function() { updateAllNewEmailAddresses('bl', $(this).is(':checked')); }); $('#select_new_addresses_bb').click(function() { updateAllNewEmailAddresses('bb', $(this).is(':checked')); }); $('#select_unsent_addresses_bl').click(function() { updateAllUnsentAddresses('bl', $(this).is(':checked')); }); $('#select_unsent_addresses_bb').click(function() { updateAllUnsentAddresses('bb', $(this).is(':checked')); }); } function setAlertifyDefaults() { alertify .logPosition("top left") .delay(0) .closeLogOnClick(true) .setLogTemplate(function (input){ return input + '

(auf Nachricht klicken, um sie zu entfernen)'; }); } $(document).ready(function() { registerHoverEventHandlers(); registerClickEventHandlers(); registerMoreContentEventHandlers(); registerMenuItemEventHandlers(); registerGalleryEventHandlers(); registerNewsletterEventHandlers(); generateProgramDatesLinks(); generateHighlightLinks(); generateFootnoteLinks(); registerValidationEventHandlers(); registerCaptchaEventHandlers(); initDatepickers(); setAlertifyDefaults(); prefetchImages(); });