Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $("#type").change(function(){
- var desc = $("#type option:selected").attr("title");
- $("#desc").html(desc);
- });
- });
- /******* KOMPONENTY jQuery (mniej lub bardziej uniwersalne ;-)) ***********/
- (function($){
- /**
- * FAKTURY ELEKTRONICZNE
- *
- * */
- $.fn.fakturyElektroniczne = function(options) {
- // this object
- var self = $(this);
- daneDoFakturyWrapper(self, options);
- self.change(function() {
- daneDoFakturyWrapper(self, options);
- });
- };
- // prywatna funkcja dla faktur elektronicznych
- var daneDoFakturyWrapper = function(checkbox, options) {
- // get dane do faktury kontener
- var daneDoFaktury = $("#" + options.wrapper);
- if($(checkbox).is(":checked")) {
- daneDoFaktury.show();
- }else {
- // iterujemy siê po elementach
- $(daneDoFaktury).find("input").each(function(idx, elem) {
- // czyœcimy wartoœci w inputach
- $(elem).val("");
- });
- daneDoFaktury.hide();
- }
- };
- /********************************/
- /**
- * OBSLUGA ZNIZKI - 100 % Dla dziecka do lat 4
- */
- /**
- * Rodzaj miejsca (id: 1,2,3)
- *
- * 1 - do siedzenia
- * 2 - kuszetka
- * 3 - sypialne
- *
- */
- $.fn.obslugaZnizkiDlaDziecka = function(options) {
- // this object
- var self = $(this);
- var kod_znizki = $("#kod_znizki");
- var klasa_wagonu;
- klasa_wagonu = $("#klasa_wagonu").html();
- if(self.is(":checked")) {
- var checkedOption = $("input[type='radio'].rodzaj_miejsca:checked").val();
- // obsluga kontenerow na potrzeby biletomanii
- switchRelief(checkedOption);
- // ustawiamy zaznaczona opcje dla konkretnego kontenera
- var idx;
- if(checkedOption == 1) {
- idx = 1;
- }else {
- idx = 2;
- }
- //$("#rodzaj_ulgi_wrap_"+idx+" select").val($("#rodzaj_ulgi_wrap_"+idx+" select").val());
- // znizka dla dzieci ( 100 % Dla dziecka do lat 4 )
- var znizka_selected = $(".znizki_wrapper").find("option:selected");
- if(znizka_selected.val() == 77) {
- $("#rodzaj_ulgi_wrap_"+idx+" select").val(znizka_selected.val());
- $(".tr_section").hide();
- }else {
- $(".tr_section").show();
- }
- komunikatSprzedazTestowaDlaZnizek(znizka_selected.attr("value"));
- }
- self.change(function() {
- // pobieramy klase
- klasa_wagonu = $("#klasa_wagonu").html();
- // usuwamy opis dla znizki
- $('#kod_znizki_opis').find('ul').remove();
- // get id miejsca
- var id = $(this).attr("id");
- switchRelief(id);
- // obsluga znizki - 100% dla dziecka do lat 4
- var usluga;
- if(id == 1) { // dla siedzacych
- usluga = 1;
- }else { // pozostale
- usluga = 2;
- }
- komunikatSprzedazTestowaDlaZnizek(0);
- // pobieramy zaznaczony element z konkretnego kontenera
- //var select = $("#rodzaj_ulgi_wrap_" + usluga + " select option:selected");
- // przywracamy ustawienia domyœlne dla rodzaju ulgi, liczby osób wed³ug taryfy normalnej, ulgowej
- $("#rodzaj_ulgi_wrap_" + usluga + " select option:first").attr('selected','selected');
- $('#liczba_n').val($("#liczba_n option:eq(1)").val());
- $("#liczba_u option:first").attr('selected','selected');
- /*
- if(select.val() == 77) {
- $(".tr_section").hide();
- if(self.val() == 1) {
- $("#klasa_wagonu").find("option[value='1']").remove();
- }
- }else {
- $(".tr_section").show();
- }
- */
- });
- isCheckedValueByForm();
- self.pobierzKlase = function() {
- return klasa_wagonu;
- }
- return self;
- };
- function switchRelief(id) {
- var usluga1; // dla siedzacych
- var usluga2; // dla kuszetek, sypialnych
- if(id==1) {
- usluga1 = 1;
- usluga2 = 2;
- } else {
- usluga1 = 2;
- usluga2 = 1;
- }
- var wrap_sel_1 = $("#rodzaj_ulgi_wrap_" + usluga1);
- var wrap_sel_2 = $("#rodzaj_ulgi_wrap_" + usluga2);
- wrap_sel_1.show();
- wrap_sel_1.find('select').removeAttr('disabled');
- wrap_sel_2.hide();
- wrap_sel_2.find('select').attr('disabled', 'disabled');
- }
- /*********************************/
- /**
- * Obsluga ulgi
- *
- */
- $.fn.obslugaUlgi = function(options) {
- // this obj
- var self = $(this);
- // klasa wagonu
- var klasa_wagonu_obj = $("#klasa_wagonu");
- //var klasa_wagonu_temp_txt = $("#klasa_wagonu option:eq(0)");
- var klasa_wagonu_temp_txt = options.klasa_wagonu;
- var usluga = $(".rodzaj_miejsca"); // rodzaj miejsca
- if(self.val() == 77) {
- if($("input[type='radio'].rodzaj_miejsca:checked").val() == 1) {
- // pozostawiamy tylko drug¹ klasê
- klasa_wagonu_obj.find("option").each(function() {
- if($(this).val() != "2") { // 2 klasa
- $(this).remove();
- }
- });
- }
- }
- komunikatSprzedazTestowaDlaZnizek(self.val());
- // change method
- self.change(function(){
- var desc = $(this).find("option:selected").attr("title");
- var replace ="";
- for (var i = 0, len = desc.length; i < len; i++) {
- //var code = desc[i] +" : "+ desc[i].charCodeAt();
- //console.log(code);
- if(desc[i].charCodeAt() === 8222) {
- replace += "<li>";
- }else if(desc[i].charCodeAt() === 8221) {
- replace+= "</li>";
- }else if(desc[i].charCodeAt() === 13) {
- replace+= "<br />";
- }else if(desc[i].charCodeAt() === 171) {
- replace+= "<font color=red>";
- }else if(desc[i].charCodeAt() === 187) {
- replace+= "</font";
- }else{
- replace+=desc[i];
- }
- }
- $("#kod_znizki_opis").html("<ul>"+replace+"</ul>");
- // obsluga znizki dla dzieci ( 100 % Dla dziecka do lat 4 - kod znizki: 77)
- var checkedOption = $("input[type='radio'].rodzaj_miejsca:checked").val();
- var idx;
- if(checkedOption == 1) {
- idx = 1;
- }else {
- idx = 2;
- }
- var id = $("#rodzaj_ulgi_wrap_"+idx+" select option:selected").val();
- if(id == 77) {
- $(".tr_section").hide();
- if(idx == 1) {
- //klasa_wagonu_obj.find("option[value='1']").remove();
- klasa_wagonu_obj.find("option").each(function() {
- if($(this).val() != "2") { // 2 klasa
- $(this).remove();
- }
- });
- }
- }else {
- $(".tr_section").show();
- if(klasa_wagonu_obj.find("option[value='1']").length == 0 && idx == 1) {
- //klasa_wagonu_obj.prepend('<option value="1">'+klasa_wagonu_temp_txt.text()+'</option>');
- klasa_wagonu_obj.html(klasa_wagonu_temp_txt);
- }
- }
- komunikatSprzedazTestowaDlaZnizek(id);
- isCheckedValueByForm();
- });
- }
- function komunikatSprzedazTestowaDlaZnizek(id) {
- var znizka_msg = $("#znizka_msg");
- if(id == 77 || id == 40 || id == 41 || id == 42 || id == 44) {
- znizka_msg.show();
- }else {
- znizka_msg.hide();
- }
- }
- function isCheckedValueByForm() {
- // miejsce zajete: , wskazane miejsce
- if(!$("#rezerwacja_obok_miejsca_juz_zajetego").is(":checked") && !$("#rezerwacja_miejsca_wskazanego").is(":checked")) {
- $("#tr_rezerwacja_obok_miejsca_juz_zajetego_wagon").hide();
- $("#tr_rezerwacja_obok_miejsca_juz_zajetego_miejsce").hide();
- }
- // kolorowa karta
- if(!$("#pokaz_kolorowa_karte").is(":checked")) {
- $("#tr_pokaz_kolorowa_karte").hide();
- }
- // karta_duzej_rodziny
- if(!$("#karta_duzej_rodziny").is(":checked")) {
- $("#tr_pokaz_karte_duzej_rodziny").hide();
- }
- }
- /******************/
- /**
- *
- * Plugin odpowiedzialny za obsluge podglad biletu.jsp
- *
- */
- $.fn.podgladBiletu = function(options) {
- // this object
- var self = $(this);
- var arrow_box_ext = $(".arrow_box_ext"); // strzalka do rozwijania kontentu z informacjami szczegolowymi o bilecie
- var standard_data = $("#standard_data"); // box z informacjami ogolnymi o bilecie
- var external_data = $("#external_data"); // box z informacjami szczegolowymi o bilecie
- var price_sections = $(".price_sections"); // wrapper opakowujacy wszystkie ceny
- var price_section_wrap = $(".price_section_wrap"); // box z cenami
- var kup_bilet_button = $(".kup_bilet_button"); // przycisk kup bilet
- var kod_ceny_input = $("[name='kodc']"); // input typu hidden, kod ceny
- var submit_button = $("#submitButton"); // button submitujacy
- var timer_clock = $(".timer"); // timer
- var timer_delay_info = $(".timer_delay_info"); // komunikat po uplynieciu czasu
- // funkcja inicjujaca plugin
- self.init = function() {
- // ukrywamy œrodkowa belkê z informacjami ogolnymi o bilecie po 3sek.
- hideExternalData();
- if(timer_clock.length > 0) {
- // inicjujemy timera
- var timer = new TimerIC();
- timer.init(timer_clock);
- timer.getInstance().addListener(function() {
- // wy³¹czamy wszystkie ceny
- if(timer.getSecond() <= 0) {
- deactiveFunctionSection();
- timer_clock.hide();
- timer_delay_info.show();
- }
- }, "visible");
- // w przypadku przeladownia strony
- if(timer.getSecond() <= 0) {
- deactiveFunctionSection();
- timer_clock.hide();
- timer_delay_info.show();
- }
- }
- if(price_sections.find(".box_shadow_inactive").length == 0) {
- submit_button.attr("disabled","disabled");
- }
- };
- // obluga strzalki w ogolnej sekcji
- arrow_box_ext.toggle(function() {
- external_data.hide('slow', function() {
- arrow_box_ext.removeClass('arrow_box_up').addClass('arrow_box_down');
- });
- }, function() {
- external_data.show('slow', function() {
- arrow_box_ext.removeClass('arrow_box_down').addClass('arrow_box_up');
- });
- });
- // oblsuga ceny dla zdarzenia onClick
- price_section_wrap.click(function() {
- // czyœcimy wszystkie aktywne przyciski
- removeActivePriceSection(price_sections);
- // aktywujemy przycisk
- $(this).removeClass('box_shadow_normal').addClass('box_shadow_inactive');
- $(this).find('.kup_bilet_button').removeClass('blue_bg').addClass('orange_bg');
- // pobieramy kod ceny
- var kod_ceny = jQuery.trim($(this).find("#kod_c").text());
- // ustawiamy kod ceny
- kod_ceny_input.val(kod_ceny);
- // aktywujemy glowny przycisk submitujacy
- submit_button.removeClass('submit_input_deactive').removeAttr('disabled');
- });
- // ukrywamy dane szczegolowe biletu
- function hideExternalData() {
- setTimeout( function() {
- external_data.show('slow', function() {
- arrow_box_ext.removeClass('arrow_box_down').addClass('arrow_box_up');
- });
- }, 3000);
- }
- // funkcja czyszczaca wszystkie aktywne sekcje cenowe
- function removeActivePriceSection(wrapper) {
- wrapper.find('.price_section_wrap').each(function( index ) {
- $(this).removeClass('box_shadow_inactive').addClass('box_shadow_normal');
- $(this).find('.kup_bilet_button').removeClass('orange_bg').addClass('blue_bg');
- });
- }
- function deactiveFunctionSection() {
- price_sections.find(".price_section_wrap").each(function(index) {
- // usuwamy akcje onClick
- $(this).unbind("click");
- // usuwamy kursor
- $(this).css("cursor", "auto");
- // usuwamy style dla sekcji
- $(this).removeClass('box_shadow_inactive box_shadow_normal').addClass('box_shadow_deactive');
- // ikonka info
- $(this).find('.price_info_wrap').children().removeClass('price_info_icon').addClass('price_info_icon_shadow');
- // cena - etykieta
- $(this).find('.price_value_wrap').children().removeClass('price_style');
- // nazwa ceny
- $(this).find('.price_name_wrap').children().removeClass('style_type_14');
- // kup bilet - przycisk
- $(this).find('.price_button_wrap').children().remove();
- $(this).find('.price_button_wrap').append(" ");
- });
- submit_button.attr("disabled", "disabled").addClass("submit_input_deactive") ;
- }
- // execute init
- self.init();
- };
- // plugin obslugujacy widok logowanie.jsp
- $.fn.logowanie = function(options) {
- // this object
- var self = $(this);
- var zaloguj_sie_button = $("[name='actlogin']"); // przycisk zaloguj sie
- var timer_clock = $(".timer"); // timer
- var timer_delay_info = $(".timer_delay_info"); // komunikat po uplynieciu czasu
- self.init = function() {
- // sprawdzamy czy istnieje komponent timer-a
- if(timer_clock.length > 0) {
- // timer
- var timer = new TimerIC();
- timer.init(timer_clock);
- timer.getInstance().addListener(function() {
- // wy³¹czamy wszystkie ceny
- if(timer.getSecond() <= 0) {
- zaloguj_sie_button.addClass('grey_bg').attr('disabled', 'disabled');
- timer_clock.hide();
- timer_delay_info.show();
- }
- }, "visible");
- // sprawdzamy timera (przeladowanie strony)
- if(timer.getSecond() <= 0) {
- zaloguj_sie_button.addClass('grey_bg').attr('disabled', 'disabled');
- }
- }
- };
- // inicjujemy komponenty
- self.init();
- };
- // plugin obslugujacy widok rejestracja.jsp
- $.fn.rejestracja = function(options) {
- // this obj
- var self = $(this);
- var dalej_button = $('[name="actlogin"]'); // przycisk dalej
- var timer_clock = $(".timer"); // timer
- var timer_delay_info = $(".timer_delay_info"); // komunikat po uplynieciu czasu
- self.init = function() {
- if(timer_clock.length > 0) {
- // timer
- var timer = new TimerIC();
- timer.init(timer_clock);
- timer.getInstance().addListener(function() {
- // wy³¹czamy wszystkie ceny
- if(timer.getSecond() <= 0) {
- timer_clock.hide();
- timer_delay_info.show();
- dalej_button.addClass('grey_bg').attr('disabled', 'disabled');
- }
- }, "visible");
- // sprawdzamy timera (przeladowanie strony)
- if(timer.getSecond() <= 0) {
- dalej_button.addClass('grey_bg').attr('disabled', 'disabled');
- }
- }
- };
- // inicjujemy komponenty
- self.init();
- };
- // plugin obslugujacy widok rejestracja_podglad.jsp
- $.fn.rejestracjaPodglad = function() {
- // this obj
- var self = $(this);
- var dalej_button = $('[name="actlogin"]'); // przycisk dalej
- var timer_clock = $(".timer"); // timer
- var timer_delay_info = $(".timer_delay_info"); // komunikat po uplynieciu czasu
- self.init = function() {
- if(timer_clock.length > 0) {
- // timer
- var timer = new TimerIC();
- timer.init(timer_clock);
- timer.getInstance().addListener(function() {
- // wy³¹czamy wszystkie ceny
- if(timer.getSecond() <= 0) {
- timer_clock.hide();
- timer_delay_info.show();
- dalej_button.addClass('grey_bg').attr('disabled', 'disabled');
- }
- }, "visible");
- // sprawdzamy timera (przeladowanie strony)
- if(timer.getSecond() <= 0) {
- dalej_button.addClass('grey_bg').attr('disabled', 'disabled');
- }
- }
- };
- // inicjujemy komponenty
- self.init();
- };
- // plugin obslugujacy platnosc.jsp
- $.fn.platnosc = function() {
- // this object
- var self = $(this);
- var arrow_box_ext = $(".arrow_box_ext"); // arrow
- var external_data = $(".external_data_platnosc"); // div z danymi rozszerzonymi
- self.init = function() {
- hideExternalData();
- };
- arrow_box_ext.toggle(function() {
- $(this).parent().parent().next().hide('slow', function() {
- $(this).parent().find('.arrow_box_ext').removeClass('arrow_box_up').addClass('arrow_box_down');
- });
- }, function() {
- $(this).parent().parent().next().show('slow', function() {
- $(this).parent().find('.arrow_box_ext').removeClass('arrow_box_down').addClass('arrow_box_up');
- });
- });
- // ukrywamy dane szczegolowe biletu
- function hideExternalData() {
- setTimeout( function() {
- arrow_box_ext.find('external_data_platnosc').show('slow', function() {
- arrow_box_ext.removeClass('arrow_box_down').addClass('arrow_box_up');
- });
- external_data.show('slow', function() {
- arrow_box_ext.removeClass('arrow_box_down').addClass('arrow_box_up');
- });
- }, 3000);
- }
- self.init();
- };
- $.fn.kontoGoscRejestracja = function() {
- // self
- var self = $(this);
- var dalej_button = $('[name="actlogin"]'); // przycisk dalej
- var timer_clock = $(".timer"); // timer
- var timer_delay_info = $(".timer_delay_info"); // komunikat po uplynieciu czasu
- self.init = function() {
- if(timer_clock.length > 0) {
- // timer
- var timer = new TimerIC();
- timer.init(timer_clock);
- timer.getInstance().addListener(function() {
- // wy³¹czamy wszystkie ceny
- if(timer.getSecond() <= 0) {
- timer_clock.hide();
- timer_delay_info.show();
- dalej_button.addClass('grey_bg').attr('disabled', 'disabled');
- }
- }, "visible");
- // sprawdzamy timera (przeladowanie strony)
- if(timer.getSecond() <= 0) {
- dalej_button.addClass('grey_bg').attr('disabled', 'disabled');
- }
- }
- };
- self.init();
- };
- /** Define class TimerIC **/
- var TimerIC = function () {
- // private property
- var timer = '';
- this.getInstance = function() {
- return this.timer;
- },
- this.init = function(timer_obj) {
- var option = {
- time: {
- Days: {
- show: false
- },
- Hours: {
- show: false
- },
- Minutes: {
- show: true,
- text: "Minuta",
- color: "#fa7819"
- },
- Seconds: {
- show: true,
- text: "Sekundy",
- color: "#0071bc"
- }
- },
- circle_bg_color: "#e5e6e7",
- animation_interval: "ticks",
- count_past_zero: false
- };
- this.timer = timer_obj.TimeCircles(option);
- return this.timer;
- },
- this.getSecond = function() {
- var time = this.getInstance().getTime();
- var split_time = time.toString().split('.');
- return parseInt(split_time[0]);
- };
- };
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement