Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $(document).ready(function(){
- $('.arrowup').hide();
- $('.arrowup').on('click', function(){
- var scrolled = window.pageYOffset || document.documentElement.scrollTop;
- if(scrolled >= 1000)
- $("html, body").stop().animate({ scrollTop: 0 }, "slow");
- });
- if($('#label1').length > 0){
- var label1 = $('#label1').offset().top;
- }
- if($('#label2').length > 0){
- var label2 = $('#label2').offset().top;
- }
- if($('#label3').length > 0){
- var label3 = $('#label3').offset().top;
- }
- window.onscroll = function() {
- var scrolled = window.pageYOffset || document.documentElement.scrollTop;
- if(scrolled >= 1000)
- $('.arrowup').show();
- else
- $('.arrowup').hide();
- if(scrolled < label1 && scrolled != 0){
- //$("html, body").stop().animate({ scrollTop: label1 }, "fast");
- }
- }
- //Inputmask
- if($('.tel').length > 0)
- $('.tel').inputmask();
- if($("#inputzip").length > 0){
- $("#inputzip").fileinput({language: 'ru', showCaption: true, showPreview: false, showRemove: false,
- showUpload: false,
- showClose: false,
- allowedFileExtensions: ['zip'],
- maxFileCount: 1
- });
- }
- function checkField(type, field){
- var pattern = '';
- field = $.trim(field);
- switch(type){
- case 'text':
- //pattern = new RegExp(/^[а-яА-Яa-zA-Zё -]{1,10000}$/);
- if(field != '')
- return true;
- else
- return false;
- //return pattern.test(field);
- break;
- case 'textand':
- //pattern = new RegExp(/^[а-яА-Яa-zA-Z" ё]{1,10000}$/);
- //return pattern.test(field);
- if(field != '')
- return true;
- else
- return false;
- break;
- case 'textandspec':
- //pattern = new RegExp(/^[а-яА-Яa-zA-Z0-9ё" ,\(\).\/\-№;:!\n]{1,10000}$/);
- //return pattern.test(field);
- if(field != '')
- return true;
- else
- return false;
- break;
- case 'digital':
- //pattern = new RegExp(/^[0-9 ]{1,10000}$/);
- //return pattern.test(field);
- if(field != '')
- return true;
- else
- return false;
- break;
- case 'digitaland':
- //pattern = new RegExp(/^[0-9\- \(\)]{1,10000}$/);
- //return pattern.test(field);
- if(field != '')
- return true;
- else
- return false;
- break;
- case 'tel':
- pattern = new RegExp(/^\+7\([0-9]{3}\)[0-9]{3}-[0-9]{2}-[0-9]{2}$/);
- return pattern.test(field);
- break;
- case 'date':
- pattern = new RegExp(/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/);
- return pattern.test(field);
- break;
- case 'url':
- pattern = new RegExp(/^(https?:\/\/)?([\da-zA-Zа-я\.-]+)\.([a-zа-я\.]{2,6})([\/\w \.-]*)*\/?$/);
- return pattern.test(field);
- break;
- case 'email':
- pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
- return pattern.test(field);
- break;
- // case 'onlyletter':
- // pattern = new RegExp(/^[а-яА-Яa-zA-Z ]{3,25}$/);
- // return pattern.test(field);
- // break;
- //
- // case 'letternumber':
- // pattern = new RegExp(/^[а-яА-Яa-zA-Z0-9 ]{3,100}$/);
- // return pattern.test(field);
- // break;
- //
- // case 'letternumber2':
- // pattern = new RegExp(/^[а-яА-Яa-zA-Z0-9 ,№]{3,100}$/);
- // return pattern.test(field);
- // break;
- //
- // case 'login':
- // pattern = new RegExp(/^[a-zA-Z0-9]{3,25}$/);
- // return pattern.test(field);
- // break;
- }
- }
- function checkForm(){
- $('[data-kivvalidation]').each(function(){
- var type = $(this).data('kivtype');
- var res = '';
- //debugger;
- switch(type){
- case 'text':
- res = checkField('text', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'textand':
- res = checkField('textand', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'textandspec':
- res = checkField('textandspec', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'digital':
- res = checkField('digital', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'digitaland':
- res = checkField('digitaland', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'email':
- res = checkField('email', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'tel':
- res = checkField('tel', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'checked':
- if($(this).prop('checked') && $(this).data('kivmusthave') == true){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- if($(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }
- }
- break;
- case 'file':
- //res = checkField('file', $(this).val());
- var layout = $(this).data('kivlayout');
- switch(layout) {
- case 'bootstrap-inputfile':
- if($(this).val() != '' && $(this).data('kivmusthave') == true){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- if($(this).data('kivmusthave') == false){
- //console.log($(this).data('kivmusthave'));
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //console.log('2'+$(this).data('kivmusthave'));
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }
- }
- break;
- default:
- //as usual
- }
- break;
- case 'date':
- res = checkField('date', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case'url':
- res = checkField('url', $(this).val());
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- case 'select':
- res = checkField('textandspec', $(this).val()); //digital
- if(res){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if(($(this).val() != '' && $(this).data('kivmusthave') == true) || ($(this).val() == '' && $(this).data('kivmusthave') == true) || ($(this).val() != '' && $(this).data('kivmusthave') == false)){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- // var select = $('.cd-dropdown input');
- // if(select.val() != ''){
- // select.addClass('validfield');
- // select.removeClass('invalidfield');
- // }else{
- // select.addClass('invalidfield');
- // select.removeClass('validfield');
- // }
- break;
- case 'notempty':
- if($(this).val() != ''){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }else{
- //empty and necessary? OR not empty and not necessary
- if($(this).val() == '' && $(this).data('kivmusthave') == true){
- $(this).addClass('invalidfield');
- $(this).removeClass('validfield');
- }else{
- if($(this).val() == '' && $(this).data('kivmusthave') == false){
- $(this).addClass('validfield');
- $(this).removeClass('invalidfield');
- }
- }
- }
- break;
- }
- });
- // if($('.kv-fileinput-error').length > 0){
- // var inpt = $('.kv-fileinput-error');
- // inpt.each(function(){
- // if($(this).html() != ''){
- //
- // }
- // });
- // }
- }
- //Подсветить ошибки
- function lightError(form){
- form.find('.lighterror').removeClass('lighterror');
- var invfield = form.find('.invalidfield');
- invfield.addClass('lighterror');
- //выбор файла
- if(form.find('.file-input').find('.invalidfield').length > 0){
- form.find('.file-input').find('.invalidfield').each(function(){
- //$('.file-input').addClass('lighterror');
- //debugger;
- $(this).parents('.file-input').addClass('lighterror');
- })
- }
- if(form.find('.checkbox').hasClass('invalidfield'))
- form.find('.checkbox.invalidfield').parent().addClass('lighterror');
- if($('#eduoffice_title').val() == '' && $('#other_work_place').val() == ''){
- $('#s2id_eduoffice').addClass('lighterror');
- $('#other_work_place').addClass('lighterror');
- }else{
- $('#s2id_eduoffice').removeClass('lighterror');
- $('#other_work_place').removeClass('lighterror');
- }
- // if(form.find('#eduoffice_title').hasClass('invalidfield')){
- // form.find('#s2id_eduoffice').addClass('lighterror');
- // }
- if(form.find('#work_okrug_title').hasClass('invalidfield')){
- form.find('#s2id_work_okrug').addClass('lighterror');
- }
- if(form.find('.cd-dropdown input').hasClass('invalidfield')){
- form.find('.cd-dropdown input').parent().addClass('lighterror');
- }
- if(form.find('#school_name_hidden').hasClass('invalidfield')){
- form.find('.select2-container.rsform-input-box').addClass('lighterror');
- }
- }
- var formvalidation = $('[data-kivvalidationform]');
- if(formvalidation.length > 0){
- btnsbmt = formvalidation.find("[data-kivbuttonsubmit]");
- btnsbmt.on('click', function(event){
- if($(this).hasClass('disabled')){
- // подсвечиваем незаполненные поля и форму не отправляем, если есть незаполненные поля
- //clearErrorLabel();
- lightError(formvalidation);
- //event.preventDefault();
- return false;
- }
- else{
- // Все хорошо, все заполнено, отправляем форму
- formvalidation.submit();
- $(this).hide();
- }
- });
- setInterval(function(){
- // Запускаем функцию проверки полей на заполненность
- checkForm();
- // Считаем к-во полей требующих проверки и успешно проверенных полей
- var countFiled = formvalidation.find('[data-kivvalidation]').length;
- var countTrueCheckedField = formvalidation.find('[data-kivvalidation].validfield').length;
- console.log(countFiled);
- console.log(countTrueCheckedField);
- // Вешаем условие-тригер на кнопку отправки формы
- if(countFiled != countTrueCheckedField){
- if(btnsbmt.hasClass('disabled')){
- return false
- } else {
- btnsbmt.addClass('disabled')
- }
- } else {
- console.log('undisable');
- btnsbmt.removeClass('disabled')
- }
- }, 200);
- }
- $('.idvideo').click(function(){
- var youtubeid = $(this).data("youtube");
- $("#modalvideo iframe").attr('src','//www.youtube.com/embed/'+youtubeid);
- });
- $('#modalvideo .lio_mod_close').on('click', function(){
- //var num = jQuery(this).data('fid');
- var video = $("#modalvideo iframe").attr("src");
- $('#modalvideo iframe').attr("src","");
- $('#modalvideo iframe').attr("src",video);
- });
- $('#ModalVideo').on('hidden.bs.modal', function (e) {
- var video = $("#modalvideo iframe").attr("src");
- $('#modalvideo iframe').attr("src","");
- $('#modalvideo iframe').attr("src",video);
- });
- $('#modalslides .lio_mod_close').on('click', function(){
- //var num = jQuery(this).data('fid');
- $('#modalslides iframe').contents().find('video').each(function ()
- {
- this.currentTime = 0;
- this.pause();
- });
- // var video = $("#modalslides iframe").attr("src");
- // $('#modalslides iframe').attr("src","");
- // $('#modalslides iframe').attr("src",video);
- });
- $('#ModalSlides').on('hidden.bs.modal', function (e) {
- $('#modalslides iframe').contents().find('video').each(function ()
- {
- this.currentTime = 0;
- this.pause();
- });
- // var video = $("#modalslides iframe").attr("src");
- // $('#modalslides iframe').attr("src","");
- // $('#modalslides iframe').attr("src",video);
- });
- // $('.idslides').click(function(){
- // var idslides = $(this).data("id");
- // $("#modalslides").find('[data-id='+idslides+']').show();
- // });
- //
- // $('#modalslides .lio_mod_close').click(function(){
- // $("#modalslides .modal-presentation").hide();
- // debugger;
- // });
- //
- //
- // $('#ModalSlides').on('hidden.bs.modal', function (e) {
- // $("#modalslides .modal-presentation").hide();
- // debugger;
- // });
- $('.idimages').click(function(){
- var idimages = $(this).data("id");
- $("#modalimages").find('[data-id='+idimages+']').show();
- });
- $('#modalimages .lio_mod_close').on('click', function(){
- $("#modalimages .modal-images").hide();
- });
- $('#ModalImages').on('hidden.bs.modal', function (e) {
- $("#modaliamges .modal-images").hide();
- });
- $('#modalimages .carousel').carousel({'interval': 0});
- $('#modalimages .carousel').each(function(){
- if($(this).find('.carousel-inner .item').length == 1){
- $(this).find('.carousel-control').hide();
- }
- });
- $('#vfs .carousel').carousel({'interval': 0});
- $('#vfs .carousel').each(function(){
- if($(this).find('.carousel-inner .item').length == 1){
- $(this).find('.carousel-control').hide();
- }
- });
- // $('.right').on('click', function(){
- // console.log('right');
- // $(this).carousel('next');
- // });
- //
- // $('.left').on('click', function(){
- // console.log('left');
- // $(this).carousel('prev');
- // });
- $('.reset').click(function(){
- $('.filt_name').val('');
- $('.filt_nam').val('');
- $('.filt_dist').val('');
- $('.cd-dropdown input').val('');
- });
- // $('.modal-presentation').each(function(){
- // var src = $(this).data('url');
- // var item = $(this);
- //
- // if(src != ''){
- // $.ajax({
- // type: "GET",
- // url: 'https://www.slideshare.net/api/oembed/2?url='+src,
- // dataType: 'jsonp',
- // success: function (data) {
- // //debugger;
- // console.log(data);
- // item.html(data.html);
- // }
- // });
- // }
- //
- //
- // });
- if($('.vote-for-us').length > 0){
- function endOfScroll(){
- var $pdf = $('#pdf_iframe');
- var iframe = document.getElementById('pdf_iframe');
- setTimeout( function() {
- var heightOfIframe = $pdf.height();
- var heightOfPDF = $pdf.contents().height();
- if(heightOfIframe > heightOfPDF - 20){
- voteVisible();
- }
- else {
- $pdf.contents().scroll(function () {
- var scrollHeight = $pdf.contents().scrollTop();
- if (scrollHeight + heightOfIframe > heightOfPDF - 20) {
- $pdf.contents().off('scroll');
- voteVisible();
- }
- })
- }
- }, 1000)
- }
- function voteVisible(){
- $('.send-vote').removeClass('disabled');
- grecaptchablock.show();
- $('.attention').hide();
- $('.btn.send-vote').attr('title', '');
- }
- $('.btn.disabled.send-vote').tooltip();
- var grecaptchablock = $('.g-recaptcha');
- $('.vote-for-us').on('click', function(){
- // $('#vfs').modal('show');
- // $('#vfs').find('.userid').val($(this).data('id'));
- // $('.send-vote').show();
- // $('.message').hide();
- // $('.message').html('');
- $('#vfs').modal('show');
- $('#vfs').find('.userid').val($(this).data('id'));
- $('.attention').show();
- var timerTime = 0;
- $('.btn.send-vote').attr('title', 'Работа просмотрена не до конца');
- $('.info-block').html('<div style="margin-bottom: 10px; padding-left: 15px; padding-right: 15px;">Конкурсная работа <b>'+$(this).data('title')+'</b>, автор <b>'+$(this).data('fio')+'</b></div>');
- //debugger;
- grecaptchablock.hide();
- if($(this).data('youtube') != ''){
- $('.video-frame iframe').attr('src', '//www.youtube.com/embed/'+$(this).data('youtube')+'?autoplay=1');
- $('.video-frame').show();
- $.ajax({
- method: 'GET',
- url: "https://www.googleapis.com/youtube/v3/videos?id="+$(this).data('youtube')+"&key=AIzaSyDTj0c5bDFaEKUqRGtvWXowwDJ9dJ8TFAk&part=contentDetails"
- }).then(function (data){
- var r = $.makeArray(data.items);
- var time = r[0].contentDetails.duration;
- var matchtext = '';
- var h = '';
- var m = '';
- var s = '';
- var regexH = /(\d+)H/;
- var regexM = /(\d+)M/;
- var regexS = /(\d+)S/;
- matchtext = time.match(regexH);
- if( typeof matchtext !== "undefined" && matchtext) h = matchtext[1]; else h = 0;
- matchtext = time.match(regexM);
- if( typeof matchtext !== "undefined" && matchtext) m = matchtext[1]; else m = 0;
- matchtext = time.match(regexS);
- if( typeof matchtext !== "undefined" && matchtext) s = matchtext[1]; else s = 0;
- timerTime = parseInt(s)+ parseInt(m)*60+ parseInt(h)*60*60;
- var now = new Date();
- if(timerTime != 0){
- now = now.setMinutes(now.getMinutes() + parseInt((timerTime-timerTime*0.25)/60), now.getSeconds() + parseInt((timerTime)%60*0.25));
- }
- //now = now.setMinutes(now.getMinutes(), now.getSeconds() + 10);
- $('#CDT').countdown(now, function(event) {
- //$(this).html(event.strftime('%H:%M:%S'));
- $(this).html(event.strftime('%M:%S'));
- });
- });
- }
- //debugger;
- if($(this).data('youtube') == '' && $(this).data('pdfsrc') != ''){
- var ee = $(this).data('pdfsrc');
- //debugger;
- setTimeout(function(){
- //debugger;
- $('#pdf_iframe').attr('src', $('#pdf_iframe').attr('src')+'?pdfsrc='+ee+'&width='+$('#vfs .modal-content').width())-30;
- }, 200, ee);
- $('#vfs .modal-dialog').css('width', '1000px');
- $('.pdf-frame').show();
- endOfScroll();
- }
- if($(this).data('youtube') == '' && $(this).data('pdfsrc') == ''
- && $('#vfs #carousel-example-generic-1-'+$(this).data('id')).length > 0){
- $('#vfs .modal-images').show();
- $('#vfs #carousel-example-generic-1-'+$(this).data('id')).show();
- var now = new Date();
- now = now.setMinutes(now.getMinutes()+1);
- $('#CDT').countdown(now, function(event) {
- //$(this).html(event.strftime('%H:%M:%S'));
- $(this).html(event.strftime('%M:%S'));
- });
- }
- $('.send-vote').show();
- $('.send-vote').addClass('disabled');
- $('.message').hide();
- $('.message').html('');
- });
- $('#CDT').on('finish.countdown', function(){
- voteVisible();
- });
- $('#vfs').on('hide.bs.modal', function(e){
- //$('#vfs').find('.userid').val('');
- //grecaptcha.reset();
- $('#vfs').find('.userid').val('');
- grecaptcha.reset();
- $('.video-frame iframe').attr('src','');
- $('.video-frame').hide();
- if($('#CDT').html() != '')
- $('#CDT').countdown('stop');
- $('#CDT').html('');
- $('.pdf-frame').hide();
- $('#vfs .slide').hide();
- $('#vfs .modal-images').hide();
- $('#pdf_iframe').attr('src', '/templates/bootstrap/build/js/pdfjs/pdfjs.php');
- $('#pdf_iframe').contents().off('scroll');
- $('#vfs .modal-dialog').css('width', 'auto');
- $('.info-block').html('');
- });
- $('#vfs').on('shown.bs.modal', function(e){
- // if($('.carousel').length > 0){
- // $('.carousel').carousel({'interval': 0});
- //debugger;
- // }
- });
- $('.send-vote').on('click', function(){
- var resp = grecaptcha.getResponse();
- // $.ajax({
- // method: 'POST',
- // url: "/index.php?option=com_partisipants&task=kiv.check",
- // data: 'checkid='+resp
- //
- // }).then(function (data){
- // var d = JSON.parse(data);
- //
- // if(d['checkresult'] == true){
- //Can we vote for partisipant?
- $.ajax({
- method: 'POST',
- url: "/index.php?option=com_partisipants&task=kiv.voting",
- data: 'id='+$('#vfs .userid').val()+'&checkid='+resp
- }).then(function (data){
- var d2 = JSON.parse(data);
- grecaptcha.reset();
- if(d2['result'] == 0){
- //Already voted
- $('.message').html('<div class="alert alert-danger">Вы уже голосовали за данного кандидата!</div>');
- }
- if(d2['result'] == 1){
- //Success
- $('.message').html('<div class="alert alert-success">Спасибо! Ваш голос учтен!</div>');
- setTimeout(function(){location.reload();}, 1500);
- }
- if(d2['result'] == 0 || d2['result'] == 1){
- $('.message').show();
- $('.send-vote').hide();
- }
- });
- // }
- // });
- });
- }
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement