228 lines
6.2 KiB
JavaScript
Vendored
228 lines
6.2 KiB
JavaScript
Vendored
(function ($) {
|
|
/**
|
|
* @param {object} _options
|
|
*/
|
|
$.fn.loadMoreNews = function (_options) {
|
|
var nextPage = 2;
|
|
var isLoading = false;
|
|
var page = 1;
|
|
var options = {
|
|
loadingElementId: '#loading',
|
|
container: '',
|
|
url: document.location.pathname
|
|
};
|
|
|
|
$.extend(options, _options);
|
|
var $isLoading = $(options.loadingElementId, this);
|
|
$isLoading.hide();
|
|
|
|
this.click(function (e) {
|
|
e.preventDefault();
|
|
if (!isLoading) {
|
|
// Set flag and update UI
|
|
isLoading = 1;
|
|
$isLoading.show();
|
|
var $button = $(this).attr("disabled", "disabled");
|
|
var $container = $(options.container)
|
|
|
|
// Fire request for the next page
|
|
$.ajax({url: options.url + (options.url.indexOf('?') >= 0 ? '&' : '?') + 'pagina=' + nextPage})
|
|
.always(function () {
|
|
// Whether success or failure, update the UI again
|
|
isLoading = 0;
|
|
$isLoading.hide();
|
|
$button.removeAttr("disabled");
|
|
})
|
|
.done(function (data) {
|
|
if (!data) {
|
|
// When no data was returned, disable the button permanently
|
|
page = -1;
|
|
$button.attr("disabled", "disabled").text("Geen nieuws meer.");
|
|
return;
|
|
}
|
|
|
|
$container.each(function () {
|
|
var id = this.toString();
|
|
$(id).append($('<div>'+data+'</div>').find(id).length ? $('<div>'+data+'</div>').find(id).children() : $(data));
|
|
});
|
|
++nextPage;
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
}(jQuery));
|
|
|
|
$(function () {
|
|
$('[data-loadmorenews]').each(function () {
|
|
$(this).loadMoreNews($(this).data('loadmorenews'));
|
|
});
|
|
});
|
|
|
|
(function ($) {
|
|
|
|
/**
|
|
* @param {object} _options
|
|
*/
|
|
$.fn.menu = function (_options) {
|
|
var options = {
|
|
menuSubmenuClass: 'has_submenu'
|
|
};
|
|
$.extend(options, _options);
|
|
var $menus = $(this).children('.' + options.menuSubmenuClass);
|
|
var $container = $(this);
|
|
|
|
$menus.on( "mouseenter", function () {
|
|
var $menuItem = $(this);
|
|
$('.menu-submenu > ul.submenu').slideUp(400, function(){$(this).closest('.menu-submenu').remove()});
|
|
$('.hover', $container).removeClass('hover');
|
|
$menuItem.addClass('hover');
|
|
var submenu = $('<div style="width: ' + $menuItem.outerWidth() + 'px"><a href="' + $menuItem.find('a').attr('href') + '" style="width: ' + $menuItem.outerWidth() + 'px"></a></div>').append($menuItem.children('ul.submenu').clone());
|
|
var pos = $menuItem.offset();
|
|
submenu.addClass('menu-submenu').css({top: pos.top, left: pos.left});
|
|
submenu.on( "mouseleave", function() {
|
|
$('.menu-submenu > ul.submenu').slideUp(400, function(){$(this).closest('.menu-submenu').remove()});
|
|
$menuItem.removeClass('hover');
|
|
} );
|
|
$('body').append(submenu);
|
|
submenu.children('ul.submenu').slideDown();
|
|
|
|
submenu.find('ul.submenu').subMenu({});
|
|
openPlayerInNewScreen();
|
|
});
|
|
};
|
|
|
|
/**
|
|
* @param {object} _options
|
|
*/
|
|
$.fn.subMenu = function (_options) {
|
|
var options = {
|
|
menuSubmenuClass: 'has_submenu'
|
|
};
|
|
$.extend(options, _options);
|
|
var $container = $(this);
|
|
|
|
$container.find('li.' + options.menuSubmenuClass + ' > a').click(function(e) {
|
|
e.preventDefault();
|
|
var $li = $(this).closest('li');
|
|
$li.children('ul.submenu').slideToggle();
|
|
$li.toggleClass('opened');
|
|
});
|
|
};
|
|
|
|
}(jQuery));
|
|
|
|
$(function () {
|
|
$('.menu').menu({});
|
|
$('.mobile-menu').subMenu({});
|
|
$('.mobile_menu_button a').click(function() {
|
|
$('.mobile_menu_container').show();
|
|
});
|
|
$('.mobile_close_menu_button a').click(function() {
|
|
$('.mobile_menu_container').hide();
|
|
});
|
|
$('.mobile_menu_container').click(function(e){
|
|
var $target = $(e.target);
|
|
if(!$target.closest('#mobile_menu_nav').length &&
|
|
$('.mobile_menu_container').is(":visible")) {
|
|
$('.mobile_menu_container').hide();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(function () {
|
|
$(".prettyPhoto[rel^='prettyPhoto']").prettyPhoto({
|
|
show_title: false,
|
|
slideshow: 3000,
|
|
overlay_gallery: true,
|
|
social_tools: ''
|
|
});
|
|
});
|
|
|
|
(function ($) {
|
|
|
|
/**
|
|
* @param {object} _options
|
|
*/
|
|
$.fn.snapTo = function (_options) {
|
|
var options = {
|
|
elementClass: 'post'
|
|
};
|
|
$.extend(options, _options);
|
|
var $container = $(this);
|
|
var $elements = $container.find('.' + options.elementClass + ':visible');
|
|
var stopSnapTo = false;
|
|
|
|
var snapTimeout = null;
|
|
var snapHandler = function() {
|
|
if (!stopSnapTo) {
|
|
stopSnapTo = true;
|
|
var y = $container.scrollLeft();
|
|
$elements.each(function () {
|
|
var offset = $(this).offset();
|
|
if (offset.left > -(window.screen.width / 2) && offset.left < window.screen.width / 2) {
|
|
$container.animate({
|
|
scrollLeft: Math.round(y + offset.left) + 'px'
|
|
}, 300);
|
|
return false;
|
|
}
|
|
});
|
|
if (snapTimeout) {
|
|
clearTimeout(snapTimeout);
|
|
}
|
|
snapTimeout = setTimeout(function () {
|
|
stopSnapTo = false;
|
|
}, 500);
|
|
}
|
|
}
|
|
var snapToHandlerTimer = null;
|
|
var scrollHandler = function() {
|
|
if (snapToHandlerTimer) {
|
|
clearTimeout(snapToHandlerTimer);
|
|
}
|
|
snapToHandlerTimer = setTimeout(snapHandler, 300);
|
|
};
|
|
|
|
$container.on( "scroll", scrollHandler);
|
|
};
|
|
|
|
}(jQuery));
|
|
|
|
$(function () {
|
|
$('[data-snapto]').each(function () {
|
|
$(this).snapTo($(this).data('snapto'));
|
|
});
|
|
});
|
|
|
|
(function ($) {
|
|
|
|
/**
|
|
* @param {object} _options
|
|
*/
|
|
$.fn.tabs = function (_options) {
|
|
var options = {
|
|
tabClass: 'box_header',
|
|
activeClass: 'active',
|
|
contentClass: 'tab_content'
|
|
};
|
|
$.extend(options, _options);
|
|
var $tabs = $(this).find('.' + options.tabClass);
|
|
var $container = $(this);
|
|
|
|
$tabs.click(function (e) {
|
|
e.preventDefault();
|
|
$tabs.removeClass(options.activeClass);
|
|
$container.find('.' + options.contentClass).removeClass(options.activeClass);
|
|
$container.find('#' + $(this).data('tab-content-id')).addClass(options.activeClass);
|
|
$(this).addClass(options.activeClass);
|
|
});
|
|
};
|
|
|
|
}(jQuery));
|
|
|
|
$(function () {
|
|
$('[data-tabs]').each(function () {
|
|
$(this).tabs($(this).data('tabs') ?? {});
|
|
});
|
|
});
|