// nif app
var nif = {};
var $ = jQuery.noConflict();
$(document).ready(function () {
var $body = $('body');
var $navbar = $('.navbar');
// Fix navbar
$navbar.affix({
offset: {
top: 39
}
});
$navbar.on({
'affix.bs.affix': function () {
$body.addClass('fixed');
},
'affix-top.bs.affix': function () {
$body.removeClass('fixed');
}
});
// parallax
$(window).trigger('resize').trigger('scroll');
// Carousel init
$(".owl-carousel:not(.home-creatives-carousel)").owlCarousel({
loop: true,
items:1,
dots: true,
autoplay: true
});
// Banner carousel init
$(".home-creatives-carousel").owlCarousel({
loop: true,
items: 1,
dots: false,
autoplay: true
});
//Akadalymentes verzio
var actualStylesheets = $.cookie('actualStyles');
var replaceableStylesheets = $.stylesheets.getReplaceables().join();
var accessableBtn = $("#accessable_version");
var defaultBtn = $("#default_version");
if ( actualStylesheets == '/css/accessible.css' ) {
$.stylesheets.clear().add('/css/accessible.css');
accessableBtn.hide();
defaultBtn.css('display', 'block');
}
accessableBtn.on('click', function() {
$.stylesheets.clear().add('/css/accessible.css');
if('undefined' != typeof fontreload) {
fontreload('px');
}
defaultBtn.css('display', 'block');
$(this).hide();
return false;
});
defaultBtn.on('click', function() {
$.stylesheets.clear().add(replaceableStylesheets);
if('undefined' != typeof fontreload) {
fontreload('px');
}
$(this).hide();
accessableBtn.show();
return false;
});
var $siteSearchTabs = $('#site-search-tabs');
// tabs - photoset grid
$siteSearchTabs.on('shown.bs.tab', function(e) {
var $activeTabContent = $( '#' + $(e.target).attr('aria-controls') );
nif.photosetGrid.init( $activeTabContent.find( '.photoset-grid' ) );
});
// Photoset grid
if ( !$body.hasClass('search-results') ) {
// default
nif.photosetGrid.init();
} else {
// tabs - photoset grid
var $tabLink = $siteSearchTabs.find('li.active').find('a');
var $activeTabContent = $( '#' + $tabLink.attr('aria-controls') );
nif.photosetGrid.init( $activeTabContent.find( '.photoset-grid' ) );
}
});
(function ($, nif) {
nif.photosetGrid = {
gridSelector: '.photoset-grid',
$grid: $(),
initPhotosetGrid: function () {
this.$grid.each( function (index) {
var $this = $(this);
$this.imagesLoaded(function () {
$this.photosetGrid({
layout: $this.data('gridlayout').toString(),
width: '100%',
gutter: '5px',
onInit: function () {},
onComplete: function () {
$this.find('.photoset-row').each(function () {
var smallestHeight = 0;
$(this).find('img').each(function () {
var image = $(this);
if (0 == smallestHeight || smallestHeight > image.height()) {
smallestHeight = image.height();
}
image.css('margin-top', 0);
});
$(this).height( smallestHeight );
});
$this.css({'visibility': 'visible'});
}
});
});
});
},
init: function ( $grid ) {
if ( $grid ) {
this.$grid = $grid;
} else {
this.$grid = $(this.gridSelector);
}
if ( this.$grid.length ) {
this.initPhotosetGrid();
}
}
};
})(window.jQuery, window.nif = window.nif = {});
//Akadalymentes verzio
$.stylesheets = (function () {
var stylesheets,
add,
clear;
add = function (cssfiles) {
if ( cssfiles ) {
$.cookie('actualStyles', cssfiles, 1);
}
cssfiles = cssfiles.split(',');
for (var i = 0; i < cssfiles.length; i++) {
if ( !$('head #skin-print, head #skin-print-real').length ) {
$('head').append('');
}
else {
$('head #skin-print').before('');
}
}
return stylesheets;
};
clear = function () {
$('head link[rel="stylesheet"]:not([id="skin-print"]):not([id="skin-print-real"]):not(.not_replaceable)').remove();
return stylesheets;
};
getReplaceables = function() {
var $replaceables = $('head link[rel="stylesheet"]:not([id="skin-print"]):not([id="skin-print-real"]):not(.not_replaceable)');
var srcs = [];
$replaceables.each( function() {
var src = $(this).attr('href');
srcs.push( src.replace( basePath, '' ) );
});
return srcs;
};
return stylesheets = {
add: add,
clear: clear,
getReplaceables: getReplaceables
};
} ());
/**
* Advanced project search
*/
(function ($, nif) {
var project_year_types_config = {
attributes: {
'implement': [ 'phase_implement_start_date_year', 'phase_implement_end_date_year' ],
'complete': [ 'phase_complete_service_date_year' ]
},
labels: {
'phase_implement_start_date_year': 'Kivitelezés kezdete',
'phase_implement_end_date_year': 'Kivitelezés várható befejezése',
'phase_complete_service_date_year': 'Forgalomba helyezés dátuma'
}
};
var project_year_groups = {};
nif.projects = nif.projects || {};
nif.projects.advancedSearch = {
$yearSelector: $(),
$phaseSelector: $(),
$yearTypeSelector: $(),
init: function (params) {
project_year_groups = params.yearGroups;
this.$yearSelector = $('#project_year');
this.$phaseSelector = $('#project_phase');
this.$yearTypeSelector = $('#project_year_type');
this.bindEvents();
},
bindEvents: function () {
this.$phaseSelector.on( 'change', $.proxy( this.selectFirst, this ) );
this.$phaseSelector.on( 'change', $.proxy( this.updateYearTypes, this ) );
this.$phaseSelector.on( 'change', $.proxy( this.updateYears, this ) );
this.$yearTypeSelector.on( 'change', $.proxy( this.updateYears, this ) );
},
updateYearTypes: function ( event ) {
var selectedPhase = event.target.value;
var options = '';
this.$yearTypeSelector.html( '' );
if ( ! project_year_types_config.attributes.hasOwnProperty( selectedPhase ) ) {
this.$yearTypeSelector.html( '' );
this.$yearSelector.val(null).prop('disabled', true);
this.$yearTypeSelector.val(null).prop('disabled', true);
return;
}
if ( this.$yearTypeSelector.prop( 'disabled' ) ) {
this.$yearSelector.prop('disabled', false);
this.$yearTypeSelector.prop('disabled', false);
}
options += '';
$.each( project_year_types_config.attributes[ selectedPhase ], function ( index, attribute ) {
options += '';
} );
this.$yearTypeSelector.html( options );
if ( this.$yearTypeSelector.find('option').length === 2 ) {
this.$yearTypeSelector.val( this.$yearTypeSelector.find('option:eq(1)').val() ).trigger('change');
}
},
updateYears: function () {
var years = [];
var options = '';
var phase = this.$phaseSelector.val();
var year_type = this.$yearTypeSelector.val();
this.$yearSelector.html( '' );
if ( project_year_groups.hasOwnProperty( phase ) ) {
if ( project_year_groups[ phase ].hasOwnProperty( year_type ) ) {
years = project_year_groups[ phase ][ year_type ];
} else {
years = project_year_groups[ phase ][ 'all' ];
}
$.each( years, function ( index, year ) {
options += '';
} );
}
this.$yearSelector.html( options );
}
};
})(window.jQuery, window.nif);