var svgLoader = '';
var $ = jQuery;
var timer = 0;
function getCityByNameAndState(c,s){
if(c.toString().length > 2){
var request = $.ajax({
url: "/addon/cityGetByNameAndState/",
type: "POST",
data: {city:c,id_state:s},
dataType: 'json',
async: false,
cache: false,
}).responseJSON;
return request;
}
}
function getCityByName(a){
if(a.toString().length > 2){
var request = $.ajax({
url: "/addon/cityGetByName/",
type: "POST",
data: {value : a},
dataType: 'json',
async: false,
cache: false,
}).responseJSON;
return request;
}
}
function checkCitySelected(){
var isSelected = $('#city_SelectedList').children().length;
if(isSelected > 0)
return true;
else
return false;
}
$(document).ready(function(){
$('.dropdown').on({
mouseover: function(){
if($(window).width()>991){
$(this).addClass('open');
}
},
mouseleave: function(){
if($(window).width()>991){
$(this).removeClass('open');
}
}
});
$('.linkto').click(function(e){
e.preventDefault();
var tag = $($(this).attr('href'));
$('html,body').animate({scrollTop: (tag.offset().top)-100},'slow');
})
$('#hit .right').on('click','', function(){
if(!$('#hit').hasClass('show')){
$('#hit').addClass('show').animate({left:"0"},"slow");
ga('send', 'event', 'hit-miesiaca-wyswietlenie', 'show')
} else {
$('#hit').animate({left:"-310"},"slow", function(){
$('#hit').removeClass('show');
});
}
});
$('#hit .left').on('click','.remove', function(){
$('#hit').animate({left:"-310"},"slow",function(){
$('#hit').removeClass('show');
});
});
$(window).scroll(function(){
if ($(this).scrollTop() > 600) {
$('#goTop').fadeIn('1000');
} else {
$('#goTop').fadeOut('500');
}
});
$('.goTop, #goTop').click(function(){
$('html, body').animate({scrollTop:0}, 'slow');
return false;
});
$("#newsletter_trigger").click(function(){
$('#modalNewsletter').modal('show');
$('#modalNewsletter .modal-body').load('/addon/newsletterPopup/', []);
});
$('#mainSearchList').css("display", "none");
// wyszukiwarka główna
$('#mainSearchList').on('click', '.mainSearchListRow', function() {
$('#mainSearchList').parent(this).css("display", "none");
$('#mainSearchList').css("display", "none");
$("#mainSearchSelectedList").children().remove();
$("#inputSearch").val($(this).text());
//$('#mainSearchSelectedList').append('
');
$('#mainSearchSelectedList').append('');
$('.mainSearchListRow').remove();
});
$('#mainSearchSelectedList').on('click', '.mainSearchListRow', function() {
$('#'+$(this).attr('id')).remove();
});
$('.mainSearchControl').on("keyup click paste", function(){
clearTimeout(timer);
timer = setTimeout(function(){
$('#mainSearchList').parent(this).css("display", "none");
$('#mainSearchList').css("display", "none");
var a = $('#inputSearch').val();
if(a.toString().length > 2){
var request = $.ajax({
url: "/addon/getSearchData/",
type: "POST",
data: {value : a, module: $("body").attr("id")},
dataType: 'json',
async: true,
cache: true,
beforeSend: function(){
$('.searchLoading').show().html(''+svgLoader+'
');
},
success : function(mainSearchList) {
$('#mainSearchList').children().remove();
//console.log(mainSearchList);
if(mainSearchList === undefined || mainSearchList.length ==0){
$('#mainSearchList').parent(this).css("display", "none");
$('#mainSearchList').css("display", "none");
}
for(x in mainSearchList){
$('#mainSearchList').append(''+mainSearchList[x].search_result_string+'');
$('#mainSearchList').parent(this).css("display", "block");
$('#mainSearchList').css("display", "block");
}
$('.searchLoading').hide().children().remove();
}
})
}
},500);
});
// wybór miasta główna wyszukiwarka
$('#cityMainSearchList').on('click', '.cityMainSearchListRow', function() {
$('#cityMainSearchList').parent(this).css("display", "none");
$("#citySelectedMainSearchList").children().remove();
$("#inputCityMain").val($(this).text());
$('#citySelectedMainSearchList').append('');
$('.cityMainSearchListRow').remove();
});
$('#citySelectedMainSearchList').on('click', '.selectedCityMainSearchListRow', function() {
$('#'+$(this).attr('id')).remove();
});
$('.cityMainSearchControl').on("keyup click paste", function(){
clearTimeout(timer);
timer = setTimeout(function(){
$('#cityMainSearchList').children().remove()
var a = $('.cityMainSearchControl').val();
var cityMainSearchList = getCityByName(a);
for(x in cityMainSearchList){
$('#cityMainSearchList').append(''+cityMainSearchList[x].city+', '+cityMainSearchList[x].state+'');
$('#cityMainSearchList').parent(this).css("display", "block");
}
},500);
});
$('#idState').on("change", function(){
$("#stateName").attr('value',$("option:selected", this).attr('rel'));
// kod który zmienia zmienia akcję żeby byl od razu poprawny link
/*var stateName = '';
stateName = $("option:selected", this).attr('rel')
if(stateName != '')
$("#form").attr("action",'/Praca/'+stateName+'-'+$('#idState').val()+'/');
else
$("#form").attr("action",'/Praca/');*/
});
//$('#city_SelectedList').css("display", "none");
$('#cityList').on('click', '.cityListRow', function() {
if($('#cityList').hasClass('dropdown-menu')){
$('#cityList').parent(this).css( "display", "none" );
}
if($('#cityList').hasClass('city-only-one')){
$("#city_SelectedList").children().remove();
}
if($('#cityList').hasClass('city-validate')){
$('#city_SelectedList').append(''+$(this).text()+' ');
}else{
$('#city_SelectedList').append(''+$(this).text()+' ');
}
$('#city_SelectedList').css("display", "inline-block");
var getLinkClearAllFilters = $('.clearAllFilters').attr('data-link');
var getTextClearAllFilters = $('.clearAllFilters').attr('data-text');
$('.clearAllFilters').addClass('clearAllFiltersActive');
$('.clearAllFilters').append(''+getTextClearAllFilters+'');
$('.cityListRow').remove();
$('#cityInput').val('');
if($('#cityList').hasClass('city-validate')){
var form = $('#cityList').closest("form").attr("id");
if(form){
var bootstrapValidator = $('#'+form).data('bootstrapValidator');
bootstrapValidator.updateStatus($('#cityInput').attr('name'),'VALID');
}
}
});
$('#city_SelectedList').on('click', '.selectedCityListRow', function() {
$('#'+$(this).attr('id')).remove();
if ( $('#city_SelectedList').children().length > 0 ) {
//$('#city_SelectedList').css("display", "block");
}else {
//$('#city_SelectedList').css( "display", "none" );
}
var status = checkCitySelected();
if($('#cityList').hasClass('city-validate')){
if(!status){
var form = $('#cityList').closest("form").attr("id");
if(form){
var bootstrapValidator = $('#'+form).data('bootstrapValidator');
bootstrapValidator.updateStatus($('#cityInput').attr('name'),'INVALID');
}
}
}
});
$('.cityControl').on("keyup click paste", function(){
clearTimeout(timer);
timer = setTimeout(function(){
$('#cityList').children().remove()
var a = $('.cityControl').val();
if($('.cityControl').hasClass('city-state')){
var id_state = $('#id_state').val();
var cityList = getCityByNameAndState(a,id_state);
}else{
var cityList = getCityByName(a);
}
for(x in cityList){
$('#cityList').append(''+cityList[x].city+', '+cityList[x].state+'');
$('#cityList').parent(this).css( "display", "inline-block" );
$('#cityList').css({"overflow-y":"auto"});
}
},500);
});
// wybór firmy
$('#companyList').on('click', '.companyListRow', function() {
$('#companyList').parent(this).css( "display", "none" );
$('#company_SelectedList').append(''+$(this).text()+' ');
$('#company_SelectedList').css("display", "inline-block");
$('.companyListRow').remove();
$('#companyInput').val('');
});
$('#company_SelectedList').on('click', '.selectedCompanyListRow', function() {
$('#'+$(this).attr('id')).remove();
if ( $('#company_SelectedList').children().length > 0 ) {
$('#company_SelectedList').css( "display", "inline-block" );
var getLinkClearAllFilters = $('.clearAllFilters').attr('data-link');
var getTextClearAllFilters = $('.clearAllFilters').attr('data-text');
$('.clearAllFilters').addClass('clearAllFiltersActive');
$('.clearAllFilters').append(''+getTextClearAllFilters+'');
}else {
//$('#company_SelectedList').css( "display", "none" );
}
});
$('.companyControl').on("keyup click paste", function(){
clearTimeout(timer);
timer = setTimeout(function(){
$('#companyList').children().remove()
var a = $('.companyControl').val();
var id_state = $('#id_state').val();
//alert(id_state);
//var companyList = getCompanyByName(a);
if(a.toString().length > 2){
$.ajax({
url: "/addon/getCompanyByName/",
type: "POST",
data: {value : a},
dataType: 'json',
async: true,
cache: true,
success : function(companyList) {
for(x in companyList){
$('#companyList').append(''+companyList[x].company_name+'');
$('#companyList').parent(this).css("display", "inline-block");
$('#companyList').css({"overflow-y":"auto"});
}
}
})
}
},500);
});
if($(".select-block").length){
$(".select-block").selectpicker({style: 'btn-default', menuStyle: 'dropdown-inverse'});
}
$('.clearAllFilters').click(function(e){
e.preventDefault();
$('.select-block').selectpicker('deselectAll');
$('ul[id*="SelectedList"] li').remove();
$(this).remove();
})
$('ul[id*="_SelectedList"]').on('click', 'li', function() {
var list = $(this).data('list-name');
var id = $(this).data('id');
//console.log(list+' '+id);
$('#'+list).find('option[value="'+id+'"]').prop('selected', false);
$('#'+list).selectpicker('refresh');
$(this).remove();
});
/* ------------------------------------------------------------------------------------------------------------- */
$('.btnPhotoChoose').click(function(){
$(this).after('');
var url = this.href;
var title = this.title;
$("#dialogPhotoChoose").empty().html('
Wczytywanie ');
$("#dialogPhotoChoose").load(url, [], function(){
$("#dialogPhotoChoose").dialog("open");
});
$("#dialogPhotoChoose").dialog({
closeText: 'Zamknij',
title: title,
modal: true,
bgiframe: true,
autoOpen: true,
height: 500,
minHeight: 300,
maxHeight: 800,
width: 980,
minWidth: 980,
draggable: true,
resizeable: true,
zIndex: 999,
closeOnEscape: true,
buttons:{
"Zamknij": function(){
$(this).dialog("close");
}
},
close: function(){
$('#dialogPhotoChoose').remove();
}
});
return false;
});
/* ------------------------------------------------------------------------------------------------------------- */
$('.btnSearchTag').click(function(){
$(this).after('');
var id_list_tag = $('#id_tag').val();
var multiple = $('#id_tag').attr('title');
var lang = $('#labelLang').val();
var url = this.href+'&id_list_tag='+id_list_tag+'&multiple='+multiple+'&lang='+lang;
var title = this.title;
$("#dialogSearchTag").empty().html('
Wczytywanie ');
$("#dialogSearchTag").load(url, [], function(){
$("#dialogSearchTag").dialog("open");
});
$("#dialogSearchTag").dialog({
closeText: 'Zamknij',
title: title,
modal: true,
bgiframe: true,
autoOpen: true,
height: 500,
minHeight: 300,
maxHeight: 800,
width: 980,
minWidth: 980,
draggable: true,
resizeable: true,
zIndex: 999,
closeOnEscape: true,
buttons:{
"Zamknij": function(){
$(this).dialog("close");
}
},
close: function(){
$('#dialogSearchTag').remove();
}
});
return false;
});
/* ------------------------------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------------- */
$('.btnSearchArticle').click(function(){
$(this).after('');
var url = this.href;
var title = this.title;
$("#dialogSearchArticle").empty().html('
Wczytywanie ');
$("#dialogSearchArticle").load(url, [], function(){
$("#dialogSearchArticle").dialog("open");
});
$("#dialogSearchArticle").dialog({
closeText: 'Zamknij',
title: title,
modal: true,
bgiframe: true,
autoOpen: true,
height: 500,
minHeight: 300,
maxHeight: 800,
width: 980,
minWidth: 980,
draggable: true,
resizeable: true,
zIndex: 200000,
closeOnEscape: true,
buttons:{
"Zamknij": function(){
$(this).dialog("close");
}
},
close: function(){
$('#dialogSearchArticle').remove();
}
});
return false;
});
/* ------------------------------------------------------------------------------------------------------------- */
/* Polish initialisation for the jQuery UI date picker plugin. */
/* Written by Jacek Wysocki (jacek.wysocki@gmail.com). */
jQuery(function($){
$.datepicker.regional['pl'] ={
closeText: 'Zamknij',
prevText: '<Poprzedni',
nextText: 'Następny>',
currentText: 'Dziś',
monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec',
'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
monthNamesShort: ['Sty','Lu','Mar','Kw','Maj','Cze',
'Lip','Sie','Wrz','Pa','Lis','Gru'],
dayNames: ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'],
dayNamesShort: ['Nie','Pn','Wt','Śr','Czw','Pt','So'],
dayNamesMin: ['N','Pn','Wt','Śr','Cz','Pt','So'],
weekHeader: 'Tydz',
dateFormat: 'dd.mm.yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['pl']);
});
$('input.datepicker').datepicker({ dateFormat: 'yy-mm-dd' });
$('div.datepicker').on('click', function(){
$(this).find('input').datepicker({ dateFormat: 'yy-mm-dd' }).focus();
});
$('a[href=#topPage]').click(function(){
$('html, body').animate({scrollTop:0}, 'slow');
return false;
});
});
function setUniformHeight(element,minWidth){var maxHeight = 0;
$(element).each(function(){
w = $(this).outerHeight(false);
if ( w > maxHeight)
maxHeight = w;
});
if($(window).width()>minWidth){
$(element).css('height',maxHeight);
} else {
$(element).css('height','auto');
}
}
function setUniformHeightInElement(element,children,minWidth){var i = 0;
var maxHeightItem = new Array();
$(element).each(function(){
$(this).addClass('box_'+i);
var maxHeight = 0;
$('.box_'+i+' '+children).each(function(){
w = $(this).outerHeight(false);
if ( w > maxHeight)
maxHeight = w;
});
maxHeightItem[i] = maxHeight;
if($(window).width()>minWidth){
$('.box_'+i+' '+children).css('height',maxHeightItem[i]);
} else {
$('.box_'+i+' '+children).css('height','auto');
}
i++;
});
}
function opinionAdd(id,object,type){
var params = {
url: "/addon/opinionAdd/",
method: "POST",
dataType: "text",
async: true,
success: function(data){
if(data){
$('#modalOpinion').modal('show');
$('#modalOpinion .modal-body').html(data);
$('#modalOpinion').on('shown.bs.modal', function() {
$('#attributeForm').bootstrapValidator('resetForm', true);
});
}
}
};
if(type=='producer'){
params.data = { id_producer: id, action: "add"};
}else if(type=='product'){
params.data = { id_product: id, action: "add"};
}else if(type=='user'){
params.data = { id_user: id, action: "add"};
}
//console.log(params);
$.ajax(params);
}