539 lines
20 KiB
JavaScript
539 lines
20 KiB
JavaScript
/* WINDOW onLOAD jQUERY */
|
|
var szerokoscOkna;
|
|
var extendSession = 0;
|
|
var ajax_wait_cursor = true;
|
|
|
|
// window.addEventListener("error", function(e){
|
|
// if(!system_url){
|
|
// return;
|
|
// }
|
|
//
|
|
// $.post(system_url+'/helper/blad', {
|
|
// url: document.location.href,
|
|
// blad: e.message,
|
|
// skrot: e.error.message,
|
|
// stos: e.error.stack,
|
|
// plik: e.filename,
|
|
// linia: e.lineno,
|
|
// kolumna: e.colno
|
|
// });
|
|
// });
|
|
|
|
$(document).ready(function(){
|
|
|
|
//setInterval(function(){alert('test: '+$('*[src=""],*[href=""]').length);},3000);
|
|
//ustawTabIndexy()
|
|
/*if(typeof system_url=='undefined')
|
|
{
|
|
var c = getCookie('system_url');
|
|
if(c!='')
|
|
{
|
|
system_url = decodeURIComponent(c);
|
|
delete c;
|
|
}
|
|
}*/
|
|
document.cookie = 'rozdzielczosc=' + screen.width + 'x' + screen.height + '; path=/';
|
|
|
|
document.onkeydown = function(evt) {
|
|
evt = evt || window.event;
|
|
if (evt.keyCode == 27) {
|
|
if($("#zakryjcontent:visible").height() != null)
|
|
{
|
|
$("#zakryjcontent .zamknij").click();
|
|
}
|
|
}
|
|
else if(evt.keyCode==8)
|
|
{
|
|
if($("[id*=niebezpiecznaOperacja]:visible").height() != null)
|
|
{
|
|
evt.preventDefault();
|
|
}
|
|
}
|
|
};
|
|
|
|
kasowanieClick();
|
|
|
|
/*$("a#wyloguj").click(
|
|
function() {
|
|
return confirm("Wylogować ?");
|
|
}
|
|
);*/
|
|
|
|
if ( self != top )
|
|
{
|
|
top.location = self.location;
|
|
}
|
|
|
|
repozytorium();
|
|
|
|
$(window).resize(function() {
|
|
if($("#zakryjcontent:visible").height() != null) {
|
|
oknoDynamiczneResize(1,szerokoscOkna);
|
|
}
|
|
repozytorium();
|
|
});
|
|
|
|
|
|
$('form').submit(
|
|
function() {
|
|
var form = $(this);
|
|
var submit = form.find('input[type=submit]');
|
|
form.css('opacity','0.8');
|
|
submit.attr('disabled','true').css('opacity','0.5');
|
|
setTimeout(function(){submit.removeAttr('disabled').css('opacity','1'),form.css('opacity','1')},2000);
|
|
|
|
var liczbaPol = $(this).serializeArray().length;
|
|
if(liczbaPol > 5990){
|
|
alert('Formularz nie może zostać przesłany, gdyż przekroczono limit 6000 pól.');
|
|
return false;
|
|
}
|
|
}
|
|
);
|
|
|
|
/* AJAX INFO */
|
|
var content = $('#content');
|
|
if(content.length==1)
|
|
{
|
|
//if($('#ajax_loading_e_dziennik').get(0)==undefined)
|
|
//{
|
|
// $('body').append('<div id="ajax_loading_e_dziennik" style="display:none; padding:5px; position:fixed; bottom:10px; -moz-border-radius: 2px; -webkit-border-radius: 2px; -moz-box-shadow: 0px 0px 2px #1783DB; -webkit-box-shadow: 0px 0px 2px #1783DB; box-shadow: 0px 0px 2px #1783DB; border-radius: 2px;"><img src="'+system_url+'/dziennik/wait_iam_loading3.gif" alt=""/></div>');
|
|
// var ajax_loading = $('#ajax_loading_e_dziennik');
|
|
// ajax_loading.css({
|
|
// 'left' : parseInt(content.offset().left+parseInt(content.css('width'))+20)
|
|
// });
|
|
//}
|
|
|
|
$(document).ajaxSend(function() {
|
|
//ajax_loading.stop(true, false).fadeIn('normal');
|
|
if(ajax_wait_cursor)
|
|
{
|
|
$('body').prepend('<style id="cursor_loading">*{cursor:wait;}</style>');
|
|
}
|
|
});
|
|
|
|
$(document).ajaxComplete(function(event, xhr, settings) {
|
|
// if(settings.url!=system_url+'/helper/generujtokenos' &&
|
|
// settings.url!=system_url+'/dyrektor/ajaxzastepstwaplandladnia' &&
|
|
// settings.url!=system_url+'/helper/numerlekcji'){
|
|
// //alert(xhr.responseText);
|
|
// generowanieTokenow();
|
|
// }
|
|
|
|
if(strpos(xhr.responseText, '<form')){
|
|
//alert(xhr.responseText);
|
|
generowanieTokenow();
|
|
}
|
|
|
|
//ajax_loading.stop(true, false).fadeOut('normal');
|
|
okienkaInformacyjne();
|
|
//ustawTabIndexy();
|
|
$('style#cursor_loading').remove();
|
|
});
|
|
|
|
// do autozalogowania, by przedluzyc sesje
|
|
$('body').on('change', 'input, textarea, select', function(){
|
|
extendSession = 1;
|
|
});
|
|
|
|
sprawdzZalogowanie(); // dołożone dodatkowo 09.01.2014
|
|
//zapiszLekcjeOffline();
|
|
okienkaInformacyjne();
|
|
|
|
generowanieTokenow();
|
|
|
|
$('input[autocomplete=off]').filter(":visible").attr('readonly','1').focus(
|
|
function(){
|
|
$(this).removeAttr('readonly');
|
|
}
|
|
);
|
|
}
|
|
/* AJAX INFO STOP */
|
|
|
|
$('a.szczesliwy_numerek').tipsy({html:false,gravity: "w",opacity: 1}).click(function() {return false;});
|
|
|
|
$('.powiadomienie_menu').parent('a').css('position','relative');
|
|
|
|
$("body").on('mouseover mouseleave focus blur','a.info:not(.info-click)', function(e){
|
|
if (e.type === 'mouseover' || e.type === 'focusin')
|
|
{
|
|
var dymek = $(this).find('span:not(.sr-only)');
|
|
if(!dymek.length) return false;
|
|
|
|
if($(this).data('tooltip')){
|
|
return false;
|
|
}
|
|
|
|
if(!dymek.html().trim().length){
|
|
dymek.css('display','none');
|
|
return false;
|
|
}
|
|
|
|
var elOffset = $(this).offset();
|
|
|
|
var dymek_style = '';
|
|
if(dymek.attr('style') != undefined){
|
|
dymek_style = ' style="'+dymek.attr('style')+'"';
|
|
}
|
|
|
|
if(!$('#mbtooltips').length)
|
|
$('body').append('<div id="mbtooltips"></div>');
|
|
|
|
$('body #mbtooltips').html('');
|
|
$('body #mbtooltips').append('<span'+dymek_style+'>'+dymek.html()+'</span>');
|
|
|
|
var tooltip = $('body #mbtooltips span:last');
|
|
tooltip.css('top', '1px').css('left', '1px').css('width', dymek.width()).height(dymek.height()).css('display','block');
|
|
|
|
var top = elOffset.top-15-tooltip.height();
|
|
var left = elOffset.left;
|
|
|
|
|
|
if(left+tooltip.width()+15 > $(window).scrollLeft()+$(window).width()){
|
|
left -= (left+tooltip.width()+15) - ($(window).scrollLeft()+$(window).width());
|
|
}
|
|
|
|
if(top < $(window).scrollTop()){
|
|
top = elOffset.top+25;
|
|
}
|
|
|
|
tooltip.css('top', top+'px').css('left', left+'px');
|
|
|
|
dymek.css('display','none');
|
|
|
|
if (!dymek.parent().find('.sr-only').length) {
|
|
dymek.after('<span class="sr-only">' + dymek.html() + '</span>');
|
|
}
|
|
|
|
$(this).data('tooltip', { tooltip: tooltip });
|
|
tooltip.data('tooltip', { parent: $(this) });
|
|
|
|
tooltip.on('mouseenter', function(){
|
|
clearTimeout($(this).data('tooltip').parent.data('tooltip').tmt);
|
|
}).off('mouseleave').on('mouseleave', function(){
|
|
var parent = $(this).data('tooltip').parent;
|
|
var data = parent.data('tooltip');
|
|
data.tmt = setTimeout(function(){
|
|
if(data && data.tooltip){
|
|
data.tooltip.remove();
|
|
parent.data('tooltip', false);
|
|
}
|
|
}, 100);
|
|
parent.data('tooltip', data);
|
|
});
|
|
|
|
}else if(e.type === 'mouseleave' || e.type === 'focusout'){
|
|
var ths = $(this);
|
|
var data = $(this).data('tooltip');
|
|
data.tmt = setTimeout(function(){
|
|
if(data && data.tooltip){
|
|
data.tooltip.remove();
|
|
ths.data('tooltip', false);
|
|
}
|
|
}, 100);
|
|
$(this).data('tooltip', data);
|
|
// $('body #mbtooltips').html('');
|
|
}
|
|
});
|
|
//setInterval(function(){ustawTabIndexy();},1000);
|
|
|
|
// do wyłączania tooltipów przy klikaniu na inny element w przeglądarce mobilnej
|
|
if(isMobile()){
|
|
$('body').on('click', '*', function(){
|
|
$('body #mbtooltips').html('');
|
|
});
|
|
}
|
|
|
|
$('.info-click').live('click',
|
|
function() {
|
|
$(this).find('span').toggle();
|
|
}
|
|
).mouseleave(
|
|
function() {
|
|
$(this).find('span:visible').toggle();
|
|
}
|
|
);
|
|
|
|
$('.przecinek_na_kropke').live('change',
|
|
function() {
|
|
var wartosc = $(this).val();
|
|
if(wartosc!='' && wartosc!=undefined)
|
|
{
|
|
$(this).val($(this).val().replace(",", "."));
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
$('body').on('focusout', 'input', function(){
|
|
var type = $(this).attr('type');
|
|
var types = new Array('text', 'number', 'email', 'color', 'date', 'month', 'range', 'search', 'tel', 'time', 'url', 'week');
|
|
if($(this).attr('data-dozwolona-spacja') || types.indexOf(type) == -1){
|
|
return true;
|
|
}
|
|
|
|
$(this).val( $(this).val().trim() );
|
|
});
|
|
|
|
$('.bez_spacji').keyup(
|
|
function() {
|
|
var wartosc = $(this).val();
|
|
if(wartosc!='' && wartosc!=undefined)
|
|
{
|
|
$(this).val($(this).val().replace(" ", ""));
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
$('.walidacja_liczba').live('change',
|
|
function() {
|
|
var wartosc = $(this).val();
|
|
if(wartosc!='' && wartosc!==undefined)
|
|
{
|
|
$(this).val($(this).val().replace(",", "."));
|
|
if(isNaN($(this).val()))
|
|
{
|
|
alert('Podano niepoprawną wartość - wymagana jest liczba.');
|
|
$(this).val('');
|
|
}
|
|
else if($(this).hasClass('kwota'))
|
|
{
|
|
$(this).val(parseFloat($(this).val()).toFixed(2));
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
$('.walidacja_pesel').live('change',
|
|
function() {
|
|
var pole = $(this);
|
|
var wartosc = pole.val();
|
|
if(wartosc!='' && wartosc!==undefined)
|
|
{
|
|
$.post(
|
|
system_url+'/helper/sprawdzpesel', {pesel:wartosc},
|
|
function(data)
|
|
{
|
|
if(data==0)
|
|
{
|
|
alert('Podany nr PESEL jest nieprawidłowy!');
|
|
pole.val('');
|
|
}
|
|
}
|
|
)
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
$('.walidacja_email').change(
|
|
function()
|
|
{
|
|
var pole = $(this);
|
|
var email = pole.val();
|
|
if(email!='' && email!==undefined)
|
|
{
|
|
$.post(
|
|
system_url+'/helper/sprawdzmaila', {email:email},
|
|
function(data)
|
|
{
|
|
if(data!=1)
|
|
{
|
|
alert("Wygląda na to, że podany adres e-mail \""+email+"\" jest niepoprawny!");
|
|
pole.val('');
|
|
}
|
|
}
|
|
)
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
$('body').on('change', '.walidacja_isbn', function(){
|
|
var pole = $(this);
|
|
var wartosc = pole.val();
|
|
pole.attr('walidacja', 'false');
|
|
if(wartosc!='' && wartosc!==undefined){
|
|
$.post(system_url+'/helper/sprawdzisbn', {isbn:wartosc},
|
|
function(data){
|
|
if(data==0){
|
|
pole.attr('walidacja','false');
|
|
}else{
|
|
pole.val(data);
|
|
pole.attr('walidacja','true');
|
|
}
|
|
}
|
|
)
|
|
}
|
|
return false;
|
|
});
|
|
|
|
// uruchomienie podstrony przez rekord tabeli
|
|
$('body').on('mouseup keypress', 'table[link] tbody tr.podswietl[rel], table[link] tr.podswietl[rel]', function(e){
|
|
|
|
if($(e.target).is('[data-link-no-click]') || $(e.target).parents('[data-link-no-click]').length){
|
|
return true;
|
|
}else if($(e.target).is('a')){
|
|
var url = $(e.target).attr('href');
|
|
}else if($(e.target).parents('a').length){
|
|
var url = $(e.target).parents('a').attr('href');
|
|
}else{
|
|
var url = $(this).parents().filter('table[link]').eq(0).attr('link')+$(this).attr('rel');
|
|
}
|
|
|
|
otworzLink(url, e);
|
|
return true;
|
|
});
|
|
|
|
// zapobieganie uruchamiania scrollowania
|
|
$('body').on('mousedown', 'table[link] tbody tr.podswietl[rel], table[link] tr.podswietl[rel]', function(e){
|
|
if(e.which === 2){
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
// tooltip
|
|
$('.autoTooltip').tipsy({html:true,gravity: 's',opacity: 1, live: true, align: 'left'});
|
|
|
|
// automatyczne zaznaczenie pola option o podanej wartosci
|
|
$('select[opt]').each(function(){
|
|
$(this).val( $(this).attr('opt') );
|
|
});
|
|
|
|
// wczytywanie do tooltipa tresci z url podanego w atrybucie
|
|
$('body').on('click', '[clickTooltipAjax]', function(e){
|
|
var ths = $(this);
|
|
|
|
if(ths.attr('original-title')){
|
|
e.stopImmediatePropagation();
|
|
|
|
ths.tipsy("show");
|
|
$('body').one('click', clickTooltipAjaxHide);
|
|
}else{
|
|
|
|
$.post(ths.attr('clickTooltipAjax'), jQuery.parseJSON(ths.attr('data-json')),
|
|
function(data){
|
|
ths.attr('title', data);
|
|
ths.tipsy({trigger: 'manual', html:true, gravity: 'n', opacity: 1, width: ths.data('width')}).tipsy('show');
|
|
$('body').one('click', clickTooltipAjaxHide);
|
|
}
|
|
);
|
|
}
|
|
});
|
|
|
|
var clickTooltipAjaxHide = function(e){
|
|
$('[clickTooltipAjax][original-title]').tipsy("hide");
|
|
}
|
|
|
|
$('body').on('click', 'tr.zaznacz-checkbox', function(event){
|
|
if($(event.target).is('input.zaznacz[type=checkbox], .nie-zaznaczaj')){
|
|
return true;
|
|
}
|
|
|
|
var checkbox = $(this).find('input.zaznacz[type=checkbox]:not([disabled])').first();
|
|
checkbox.attr('checked', !checkbox.is(':checked') ).change();
|
|
return false;
|
|
});
|
|
|
|
$('body').on('click', 'tr.zaznacz-radio', function(event){
|
|
$(this).find('input.zaznacz[type=radio]:not([disabled])').first().attr('checked', true).change();
|
|
});
|
|
|
|
|
|
$('body').on('click', '.mobidziennik_wiadomosci_link_confirm', function(event){
|
|
return confirm("Jeśli stronę \""+$(this).attr('href')+"\" uznajesz za bezpieczną, potwierdź OK w celu przejścia do niej.");
|
|
});
|
|
|
|
|
|
// scrolltop by attr in url
|
|
if(document.location.hash.length && document.location.hash.indexOf('scrolltop:')){
|
|
var scrolltop = document.location.hash.split('scrolltop:');
|
|
$('body, html').scrollTop( parseInt(scrolltop[1]) );
|
|
}
|
|
|
|
var mouseleaveItems = [];
|
|
var mouseleaveTimeouts = [];
|
|
|
|
function showMenuItem(item) {
|
|
$(item).css('background', '#fff');
|
|
$(item).css('position', 'relative');
|
|
$(item).children('ul').css('visibility', 'visible').css('opacity', '1');
|
|
}
|
|
|
|
function hideMenuItem(item) {
|
|
$(item).css('background', '');
|
|
var ul = $(item).find('ul');
|
|
ul.css('visibility', '').css('opacity', '0');
|
|
}
|
|
|
|
function getMenuLevel(item) {
|
|
var level = 0;
|
|
if ($(item).parent().parent().parent().parent().parent().prop('id') === 'menu_gray') {
|
|
level = 1;
|
|
} else if ($(item).parent().parent().parent().parent().parent().parent().parent().prop('id') === 'menu_gray') {
|
|
level = 2;
|
|
} else if ($(item).parent().parent().parent().parent().parent().parent().parent().parent().parent().prop('id') === 'menu_gray') {
|
|
level = 3;
|
|
}
|
|
return level;
|
|
}
|
|
|
|
function menuMouseenter() {
|
|
var level = getMenuLevel(this);
|
|
for (var i = level; i <= 3; i++) {
|
|
clearTimeout(mouseleaveTimeouts[i]);
|
|
if (mouseleaveItems[level] !== this) {
|
|
hideMenuItem(mouseleaveItems[i]);
|
|
}
|
|
}
|
|
showMenuItem(this);
|
|
}
|
|
|
|
function menuMouseleave() {
|
|
var item = this;
|
|
var level = getMenuLevel(item);
|
|
if (level === 0 && $(item).find('ul').length === 0) {
|
|
hideMenuItem(item);
|
|
} else {
|
|
mouseleaveItems[level] = item;
|
|
mouseleaveTimeouts[level] = setTimeout(function() {
|
|
hideMenuItem(item);
|
|
}, 400);
|
|
}
|
|
}
|
|
|
|
function menuFocus() {
|
|
|
|
$(this).mouseenter();
|
|
}
|
|
|
|
function menuBlur() {
|
|
$(this).mouseleave();
|
|
}
|
|
|
|
$('body').on('mouseenter', '#menu_gray li', menuMouseenter);
|
|
$('body').on('mouseleave', '#menu_gray li', menuMouseleave);
|
|
$('body').on('focus', '#menu_gray a', menuFocus);
|
|
$('body').on('blur', '#menu_gray a', menuBlur);
|
|
|
|
if($('body').attr('data-zablokowany') == 'true'){
|
|
$('body').on('click change', 'input[type=text], input[type=password], input[type=checkbox], input[type=radio], textarea, select, .ui-dropdownchecklist, .ui-dropdownchecklist-selector', function(){
|
|
if($(this).attr('data-dostepnosc-zablokowany') == 'true' || getCookie('dziennik-zablokowany-alert')){
|
|
return true;
|
|
}
|
|
|
|
setCookie('dziennik-zablokowany-alert', '1', 0.0416); // 1h
|
|
alert('Dziennik został zablokowany lub przeniesiony do archiwum. Dokonywanie wszelkich zmian jest niemożliwe.');
|
|
return false;
|
|
});
|
|
}
|
|
|
|
$('body').on('change', 'input.hasDatepicker:not([readonly])', function(){
|
|
if(!isValidDate($(this).val())){
|
|
$(this).val('');
|
|
}
|
|
});
|
|
}
|
|
);
|