$( document ).ready(function() { // Mobile Navigation $('#nav-button').on('click', function(event) { console.log('clicked'); event.preventDefault(); if( $('body').hasClass('open') ) { $('body').removeClass('open'); } else { $('body').addClass('open'); } }); $('.main').on('click', function() { if( $('body').hasClass('open') ) { $('body').removeClass('open'); } }); /* Fonksiyonlar */ var islem = 1; (function ( $ ) { $.fn.loader = function() { var div = ''+ '
'+ '
'+ '
'+ ''+ '
'+ '
'+ '
'; return this.html(div); }; }( jQuery )); (function ( $ ) { $.fn.resetter = function() { this[0].reset(); this.find('select').val(0); this.find('select').trigger( 'change' ); }; }( jQuery )); (function ( $ ) { $.fn.messages = function(sonuc) { el = this; el.fadeOut( "fast", function() { var div = ''; if ( sonuc.durum == 1 || sonuc.durum == 2 ) div += '
'; else if ( sonuc.durum == 3 ) div += '
'; else div += '
'; $.each(sonuc.mesajlar, function( index, value ) { div += '

'+value+'

'; }); div += '
'; el.html(div).fadeIn(); }); }; }( jQuery )); alerts = function(sonuc) { var div = ''; $.each(sonuc.mesajlar, function( index, value ) { div += value+'
'; }); if (sonuc.html) div += sonuc.html; if ( sonuc.durum == 1 || sonuc.durum == 2 ) title = 'Başarı'; else if ( sonuc.durum == 3 ) title = 'Bilgi'; else title = 'Hata'; $.alert({ title: title, content: div, confirmButtonClass: 'button-dark', confirmButton: 'TAMAM', }); }; $( "#davetiye-kaydet" ).on("click", function(event) { event.preventDefault(); if ( islem == 1 ) { islem = 0; form = $(this).parents( "form" ); data = form.serialize(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=davetiye&islem=kaydet", type: 'POST', data: data, cache: false, success: function(result) { islem = 1; sonuc = JSON.parse(result); form.find('.mesajlar').messages(sonuc); if ( sonuc.durum == 1 ) { setTimeout(function(){ location.reload(); }, 2000); } } }); } }); /* Giriş */ $( "#giris-belirle" ).on("click", function(event) { event.preventDefault(); if ( islem == 1 ) { islem = 0; form = $(this).parents( "form" ); data = form.serialize(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=giris&islem=belirle", type: 'POST', data: data, cache: false, success: function(result) { sonuc = JSON.parse(result); if ( sonuc.durum == 1 ) { form.resetter(); } islem = 1; $( "#mesajlar" ).messages(sonuc); } }); } }); $( "#giris-yenile" ).on("click", function(event) { event.preventDefault(); if ( islem == 1 ) { islem = 0; form = $(this).parents( "form" ); data = form.serialize(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=giris&islem=yenile", type: 'POST', data: data, cache: false, success: function(result) { sonuc = JSON.parse(result); if ( sonuc.durum == 1 ) { form.resetter(); } islem = 1; $( "#mesajlar" ).messages(sonuc); } }); } }); $( "#giris-yap" ).on("click", function(event) { event.preventDefault(); if ( islem == 1 ) { islem = 0; form = $(this).parents( "form" ); data = form.serialize(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=giris&islem=yap", type: 'POST', data: data, cache: false, success: function(result) { sonuc = JSON.parse(result); form.find('.mesajlar').messages(sonuc); if ( sonuc.durum == 1 ) { setTimeout(function(){ window.location = "https://www.cetinyillik.com/"; }, 2000); } else { islem = 1; } } }); } }); /* Kayıt */ $("#kayit-ogrenci-kod").on("click", function(event) { event.preventDefault(); var dialog = $.dialog({ icon: 'fa fa-spinner fa-spin', title: "Kontrol Ediliyor", content: "Yıllık kodu kontrol ediliyor, lütfen bekleyin." }); form = $(this).parents( "form" ); data = form.serialize(); $( "#kayit-ogrenci-form" ).slideUp(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=kod&islem=ogrenci", type: 'POST', data: data, cache: false, success: function(result) { sonuc = JSON.parse(result); dialog.close(); form.find('.mesajlar').messages(sonuc); if ( sonuc.durum == 1 ) { $( "#kayit-ogrenci-form" ).html(sonuc.html).slideDown(); $( ".number" ).numeric(); $("#kayit-ogrenci-form select").select2(); $("#kayit-ogrenci-form .phone").mask("(999)999-99-99"); } } }); }); $( "#kayit-ogrenci-form" ).on("click", "#kayit-ol", function(event) { event.preventDefault(); if ( islem == 1 ) { islem = 0; form = $(this).parents( "form" ); data = form.serialize(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=kayit&islem=ogrenci", type: 'POST', data: data, cache: false, success: function(result) { sonuc = JSON.parse(result); form.find('.mesajlar').messages(sonuc); if ( sonuc.durum == 1 ) { window.location = "https://www.cetinyillik.com/"; } else { islem = 1; } } }); } }); $("#kayit-ogretmen-kod").on("click", function(event) { event.preventDefault(); var dialog = $.dialog({ icon: 'fa fa-spinner fa-spin', title: "Kontrol Ediliyor", content: "Yıllık kodu kontrol ediliyor, lütfen bekleyin." }); form = $(this).parents( "form" ); data = form.serialize(); $( "#kayit-ogretmen-form" ).slideUp(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=kod&islem=ogretmen", type: 'POST', data: data, cache: false, success: function(result) { sonuc = JSON.parse(result); dialog.close(); form.find('.mesajlar').messages(sonuc); if ( sonuc.durum == 1 ) { $( "#kayit-ogretmen-form" ).html(sonuc.html).slideDown(); $("#kayit-ogretmen-form select").select2(); $("#kayit-ogretmen-form .phone").mask("(999)999-99-99"); } } }); }); $( "#kayit-ogretmen-form" ).on("click", "#kayit-ol", function(event) { event.preventDefault(); if ( islem == 1 ) { islem = 0; form = $(this).parents( "form" ); data = form.serialize(); $.ajax({ url: "?modul=api&yetki=ortak&bolum=kayit&islem=ogretmen", type: 'POST', data: data, cache: false, success: function(result) { sonuc = JSON.parse(result); form.find('.mesajlar').messages(sonuc); if ( sonuc.durum == 1 ) { window.location = "https://www.cetinyillik.com/"; } else { islem = 1; } } }); } }); /* Eklentiler */ $('.bxslider').bxSlider({ auto: true, mode: 'fade', speed: 500, auto: true, nextText: '', prevText: '' }); $( ".grow" ).autoGrow(); $(".phone").mask("(999)999-99-99"); $(".code").mask("999999"); $(".coded").mask("99-99-****"); $(".clock").mask("99:99"); $( ".number" ).numeric(); $('select').select2(); $('.date-time-after').datetimepicker({ format: 'YYYY-MM-DD HH:mm', ignoreReadonly: true, icons: { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-arrow-up", down: "fa fa-arrow-down", previous: "fa fa-arrow-left", next: "fa fa-arrow-right" }, minDate: 'now' }); $('.date-month').datetimepicker({ format: 'MM-YYYY', ignoreReadonly: true, icons: { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-arrow-up", down: "fa fa-arrow-down", previous: "fa fa-arrow-left", next: "fa fa-arrow-right" }, }); $('.date').datetimepicker({ format: 'YYYY-MM-DD', ignoreReadonly: true, icons: { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-arrow-up", down: "fa fa-arrow-down", previous: "fa fa-arrow-left", next: "fa fa-arrow-right" } }); $('.date-year').datetimepicker({ format: 'YYYY', ignoreReadonly: true, icons: { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-arrow-up", down: "fa fa-arrow-down", previous: "fa fa-arrow-left", next: "fa fa-arrow-right", clear: 'fa fa-times', }, showClear: true }); $('.date-time').datetimepicker({ format: 'YYYY-MM-DD HH:mm', ignoreReadonly: true, icons: { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-arrow-up", down: "fa fa-arrow-down", previous: "fa fa-arrow-left", next: "fa fa-arrow-right" } }); });