// GLOBAL VAR var events; var device = 'desktop', request_managment_final_check = false, get_final_confirm = false, is_mobile = false; $.holdReady(true); $.get(base_url + 'application/views/configs/dic.cfg',function(content){ var config = content.split(/\[.\]/).filter(Boolean); config = config[parseInt(lang_id-1)].split(/\n/).filter(Boolean); $.each(config,function(i,v){ eval(v); }) $.holdReady(false); }) $(function() { check_device(); $(window).on('resize', function() { check_device(); }) var temp_submit_action = null; $temp_submit_button = $('body').find('form [id=temp_submit]'); $temp_submit_button.on('click', function() { temp_submit_action = this; }) if ($('#slider').length > 0) $('#slider').lqslider({ listSelector : '.slider__wrapper ul', itemSelector : '.slider__item', autoPlay: true, autoPlayInterval : 10000, paginationListSelector : $('#slider .slider__footer__pagination'), paginationItemSelector : 'span', prevSelector: $('#slider .slider__footer__pagination__back'), nextSelector: $('#slider .slider__footer__pagination__next'), currentClass : 'active', direction:'rtl', touch : true, on_end : function() {} }); $('body').on('click','#loginuser .avatar', function(event) { event.stopPropagation(); var menu = $('#loginuser .menu'); if (!is_mobile) { menu.addClass('open').show(); menu.data('user_menu', setTimeout(function () { menu.removeClass('open').hide(); }, 2000)); } else { if (menu.hasClass('open')) { menu.removeClass('open').hide(); } else { menu.addClass('open').show(); } } }) if (is_mobile) { $('body').on('click touchstarts', function() { if ($('#loginuser .menu').hasClass('open')) { $('#loginuser .menu').removeClass('open').hide(); } }) $('body').on('click touchstarts', '#loginuser .menu', function(event) { event.stopPropagation(); }) } $('body').on('mouseenter mouseleave','#loginuser .menu',function(event) { var menu = $('#loginuser .menu'); if (event.type == 'mouseenter') { clearTimeout(menu.data('user_menu')); } if (event.type == 'mouseleave') { menu.data('user_menu', setTimeout(function () { menu.hide(); }, 500)); } }) // TAB CLICK CONTROLL $('body').on('click', '.tab:not(.link)', function(event) { event.preventDefault(); if (!$(this).hasClass('disabled')) { var _parent = $(this).parent(); var tab = $(this); _parent.find('.active').removeClass('active'); $(this).addClass('active'); var _content_tab = _parent.parent().find('.'+_parent.parent().attr('id')+'_tab'); _content_tab.find('> .show').removeClass('show'); var current_content = _content_tab.find('div#'+$(this).attr('href')) current_content.addClass('show'); $('body').find('[class^=related_'+_parent.parent().attr('id')+']').find('> .show').removeClass('show'); $('body').find('[id^=related_'+$(this).attr('href')+']').addClass('show'); switch(_parent.parent().attr('id')) { case 'corridor_media': if (!tab.hasClass('loaded')) { current_content.addClass('loading'); $.when(common_request({ url : base_url + 'get_rss', data : { path : current_content.attr('path'), capture : 'rss_feed' } }, 'rest')) .then(function(res) { var r = $.parseJSON(res); current_content.html(r.h); current_content.removeClass('loading'); start_loading(); tab.addClass('loaded'); }) } break; case 'events' : if ($(this).attr('href') == 'upcoming_event') { $('#upcoming_event').find('a.active').trigger('click') $('#event_archive').show(); $('#course_archive').hide(); } else { $('#event_archive').hide(); $('#course_archive').show(); } break; } } }) $('body').on('click touch', '.header__extra_search > i, .search__close', function(event) { var _section = $('body').find('.header__extra_search form'); _section.toggleClass('close'); if (!_section.hasClass('close')) { _section.find('input').focus() } }) $('body').on('keyup', function(event) { if (event.keyCode == 27 && !$('body').find('.header__extra_search form').hasClass('close')) { $('body').find('.header__extra_search form').addClass('close'); } }) $('body').on('click', '#calendar', function(event) { common_loading_overlay(); event.preventDefault(); // events = get_events(); $.when(common_request({url:base_url+'index.php?ctrl=event&actn=get'})).then(function(res) { $('body').find('#submit_prevent').remove(); var allEvents = $.parseJSON(res); var params = { maxWidth : 400, instance_id : 'calendar', title : calendar_title, content : '
', on_open : function(dialog,params) { dialog.find('#upcoming_events_instance').datepicker({ dateFormat: 'yy/mm/dd', regional:'fa', onSelect:function(date_text){ show_day_event(allEvents,date_text); }, onChangeMonthYear:function(year,month){ cu_date = [parseInt(year.toString()),parseInt(month.toString())]; } }); var cu_date = current_date(); cu_date = cu_date.jalali; let showToday = cu_date.join("/"); show_day_event(allEvents, showToday) setInterval(function() { generate_event_calendar(allEvents,cu_date[1],cu_date[0]); },1000) } } global_dialog($(this), params); return false; }) }) $('body').on('click', '#upcoming_event > .tab_holder a', function(event) { event.preventDefault(); var _parent = $(this).parent(); _parent.find('.active').removeClass('active'); $(this).addClass('active'); var _upcoming_event_tab = $(this).parents('#upcoming_event').find('.upcoming_event_tab'); _upcoming_event_tab.find('.show').removeClass('show'); _upcoming_event_tab.find('div#'+$(this).attr('href')).addClass('show'); }) // FOOTER STATISTIC if (typeof statistic_chart_data != 'undefined'){ var statistic_chart_color = ['#1abfd8','#9575cd','#f05703'] var cols = []; var rows = []; $.each(statistic_chart_data, function(i,v) { cols.push(v[0]); rows.push(parseInt(v[1])); }) var config = { element : $('body').find('#footer_top .chart'), chart : { type : 'line', backgroundColor : 'transparent' }, legend: { enabled: false, }, tooltip : { enabled : true, useHTML : true, formatter : function() { return '' + farsidigit(this.x.replace(/-/gi,'/')) + '' + farsidigit(todigits(this.y)) + ' ' + '' }, }, yAxis : { gridLineColor : 'transparent', labels : {enabled : false}, min: 0, title: { text: null }, }, xAxis: { linewidth : 0, tickLength : 0, lineColor : 'transparent', labels : {enabled : false}, categories: cols, }, plotOptions : { series : { lineWidth : 1, lineColor : '#23568b', states : { hover : {lineWidth : 1} }, marker : { fillColor : '#f5f5f5', lineWidth : 2, lineColor : '#23568b', } } }, series: [{ color : '#23568b', data : rows, }] } charter(config); } // SUBSERVICE HEADER EXPANDE $('body').on('click', '#sub_service_list .sub_service_header:not(.no_child) > .title,#sub_service_list .sub_service_header:not(.no_child) > .more', function(event) { event.preventDefault(); if ($(this).parent().parent().hasClass('close')) $(this).parent().parent().removeClass('close').addClass('open') else $(this).parent().parent().removeClass('open').addClass('close') }) // CONSTRACTOR SHOW INFO POPUP $('body').on('click','#contractor_list .info a', function(event) { event.preventDefault(); var content = $(this).next().html(); global_message({type:'notify', message:content, timeout: false, close:true, pos:'centerTop'}); }) $('body').on('submit', '#search form', function(e) { if ($(this).find('input').val() == '') { e.preventDefault(); $(this).find('input').focus(); } }) $('body').on('click','#final_submit',function(event) { if (event.isTrigger == undefined) get_final_confirm = true; }) $('body').on('submit','form[name=request_managment]',function(event) { var form = $(this); var message_items = []; var flag = true; form.find('#message').remove(); if (global_validate($(this)) === false) { event.preventDefault(); return false; } if (form.find('#state_id').is(':visible') && form.find('#state_id').find(':radio:checked').length <= 0) { message_items.push('انتخاب محل حمایت الزامی است.'); flag = false; } if (form.find('#courses').is(':visible') && form.find('#courses').find(':radio:checked').length <= 0) { message_items.push('انتخاب دوره های آموزشی الزامی است.'); flag = false; } if (!flag) { event.preventDefault(); $.each(message_items, function(i,v) { if (i < 6) global_message({type:'error', message:v}); else return false; }) return false; } if (get_final_confirm && !request_managment_final_check && temp_submit_action === null && form.find('#final_submit').size() > 0) { event.preventDefault(); var params = { maxWidth : 500, title : 'تایید ثبت نهایی', content : 'کاربر گرامی،
در صورت انتخاب گزینه تایید و ثبت اطلاعات ، تا بررسی درخواست توسط کارشناسان امکان ویرایش اطلاعات وجود ندارد.', button : [{ id : 'register_course_service', style : 'background-color : #b92206', title : 'تایید و ثبت نهایی اطلاعات', eval : { onclick : 'confirm_final_register($("#final_submit"))' } }] } global_dialog(form, params); return false; } common_loading_overlay(); }) $('body').on('click','#service_view #course li .more', function() { var _this = $(this).parent(); var params = { maxWidth : 600, maxHeight : '60vh', title : 'اطلاعات دوره آموزشی', content : _this.find('.popup_info').html(), } if (_this.attr('path') != undefined) { params['button'] = [{ id : 'register_course_service', style : 'background-color : #b92206', title : 'ثبت نام در دوره' }] if (is_login) { params['button'][0]['eval'] = { href : _this.attr('path') } } else { params['button'][0]['eval'] = { onclick : 'load_login_dialog({callback_success : \''+_this.attr('path')+'\'})' } } } global_dialog(_this, params); return false; }) // FAQ $('body').on('click', '#faq h1', function(event) { event.preventDefault(); if ($(this).parent().hasClass('close')) $(this).parent().removeClass('close').addClass('open') else $(this).parent().removeClass('open').addClass('close') }) $('body').on('click', 'i.clear_input', function() { $(this).parent().find('input[type=text]').val('').trigger('keyup'); }) $('body').on('keydown keyup', '#faq input', function() { var _input = $(this); _input.removeData('text'); var search_string = $.trim(_input.val()); var ac_result_list = $('
'); // $('#faq li .hgltkw').contents().unwrap(); $('#faq .search_area').removeClass('active'); clearTimeout(autoget_timer); autoget_timer = setTimeout(function(){ if($.trim(search_string) != '') { $('#faq .search_area').addClass('active'); $('#faq li').each(function() { li = $(this); if(li.text().indexOf(search_string) == -1) { li.hide(); } else { li.show(); if (li.hasClass('close')) li.removeClass('close'); } // $(this).html(highlight(search_string, $(this).html())); }) } else { $('#faq li').show(); } }, 500); }) // SHOW CREDIT INFORMATION ON CLICK INFO BUTTON $('body').on('click','.show_description', function() { var content = $(this).next().html(); global_message({type:'notify', message:content, timeout: false, close:true, pos:'centerTop'}); }) $('body').on('keyup', '#search_in_service input', function(e) { var _list = $('#sub_service_list'), _input = $(this); if(_input.val() == '') { _list.find('li').removeAttr('style'); } else if($.trim(_input.val()) != _input.data('text')) { _input.removeData('text'); var search_string = $.trim(_input.val()); var search_result = []; if($.trim(search_string) != '') { _list.find('li .sub_service_header span').each(function(index,value) { if($(value).text().indexOf(search_string) == -1) $(value).parents('li').hide(); else $(value).parents('li').show(); }) } } }) $('body').find('.draw_chart').each(function() { draw_report_chart($(this)); }) $('body').find('.block:first').addClass('open') $('body').on('click','p.head', function() { $(this).parent().toggleClass('open') }) $('body').on('click', '.gloabl_login__botton_holder .company_register', function(event) { event.preventDefault(); var _this = $(this); var params = { maxWidth : 600, title : create_company_dialog_title, content : create_company_dialog_content, button : [{ id : 'create_company_confirm', style : 'background-color : #2ea96b', title : create_company_dialog_confirm, eval : { href : _this.attr('href') } }] } global_dialog($(this), params); return false; }) $('body').on('mouseenter', '#mega_menu .gHmrv2 .first_level .parent', function(){ let content = $(this).attr('data-title') || ''; console.log(content) $(this).parent().find('.content').html(content) }) // $('body').on('mouseleave', '#mega_menu_0_menu li', function(){ // $(this).parents('ul').find('.content').html('') // }) }) function check_device() { if (/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) { is_mobile = true; device = 'mobile' } }