jQuery.noConflict(); jQuery(function($) { function bindLL(){ $('.pager--infinite-scroll.pager li').removeClass('loading'); $('.pager--infinite-scroll.pager li > a').click(function(e){ e.preventDefault(); $(this).parent().addClass('loading'); }); } function likes(){ $('.news-int-mr-lk').unbind('click'); $('.news-int-mr-lk').click(function(e){ e.preventDefault(); var nid = $(this).attr('nid'); var liked = $(this).text(); var newliked = parseFloat(liked) + 1; var newliked = '' + newliked; $(this).html(newliked); $(this).unbind('click'); $(this).css('cursor','default'); $.post('/likes',{ nid: nid }); }); } function broles(){ // org $('.trgrl a:not(.loading)').click(function(e){ e.preventDefault(); $(this).addClass('loading'); $('.trgrl a').removeClass('active'); $(this).addClass('active'); if ($(this).hasClass('trgrlall')) $('#edit-r').val(''); if ($(this).hasClass('trgrlprof')) $('#edit-r').val('6'); if ($(this).hasClass('trgrlmol')) $('#edit-r').val('8'); if ($(this).hasClass('trgrlbol')) $('#edit-r').val('7'); $('#edit-submit-org').trigger('click'); }); $('.view-org.view-display-id-page #edit-reg, .view-org.view-display-id-page #edit-sort-by').change(function(){ $(this).parent().addClass('loading'); $('.view-org.view-display-id-page #edit-submit-org').trigger('click'); }); $('#orgact .view-content:not(.slick-initialized), .view-authors.view-display-id-block .view-content:not(.slick-initialized)').slick({ infinite: true, arrows: false, slidesToShow: 10, slidesToScroll: 9, variableWidth: true, speed: 500, responsive: [ { breakpoint: 1185, settings: { slidesToShow: 11, slidesToScroll: 11, infinite: true, dots: true } }, { breakpoint: 830, settings: { slidesToShow: 8, slidesToScroll: 8, infinite: true, dots: true } }, { breakpoint: 630, settings: { slidesToShow: 6, slidesToScroll: 6, infinite: true, dots: true } }, { breakpoint: 410, settings: { slidesToShow: 3, slidesToScroll: 3 } } ] }); } function upfilter(){ $('a.upl').removeClass('loading'); $('a.upl').each(function(){ $('input[name="'+$(this).attr('n')+'"]').val(''); }); $('a.upl:not(.loading)').click(function(e){ e.preventDefault(); $(this).addClass('loading'); $('a.upl').removeClass('active'); var n = $(this).attr('n'); var v = $(this).attr('v'); $(this).addClass('active'); if (n != 'default') { $('a.upl').each(function(){ $('input[name="'+$(this).attr('n')+'"]').val(''); }); $('input[name="'+n+'"]').val(v); } else { $('a.upl').each(function(){ $('input[name="'+$(this).attr('n')+'"]').val(v); }); } $('.views-exposed-widget .form-submit').trigger('click'); }); } $('body').on('change','.field-name-field-pphoto input.form-file',function(){ $(this).next('.input-group-btn').children().trigger('mousedown'); }); function avatarChange(){ // $('#edit-field-pphoto input.form-file').unbind('change'); // $('#edit-field-pphoto input.form-file').change(function() { // $(this).next('.input-group-btn').children().trigger('mousedown'); // }); $('#edit-field-pphoto img, #edit-field-pphoto label.control-label').unbind('click'); $('#edit-field-pphoto img, #edit-field-pphoto label.control-label').click(function(e){ e.preventDefault(); // if ($('#edit-field-pphoto button[name*="_remove_"]').length > 0) { // $('#edit-field-pphoto button[name*="_remove_"]').mousedown(); // } else { // $('#edit-field-pphoto input[name="files[field_pphoto_und_0]"]').trigger('click'); $(this).parents().find('.field-type-image').children().find('input[name="files[field_pphoto_und_0]"]').trigger('click'); // } }); } function addSotr(){ $.get('/admin/people/create',function(d){ var content = $(d).find('#user-register-form'); $('#edit-group_st > .panel-body').html(content); $('#edit-group_st #user-register-form').attr('action',$('#edit-group_st #user-register-form').attr('action')+'?destination='+window.location.pathname.substr(1)); $('#edit-group_st #user-register-form .form-submit').text('Добавить сотрудника'); $('#edit-group_st input[name="field_org[und][0][value]"]').val($('#edit-group_sp input[name="field_org[und][0][value]"]').val()); $('#edit-group_st input[name="field_city[und][0][value]"]').val($('#edit-group_sp input[name="field_city[und][0][value]"]').val()); $('#edit-group_st select[name="field_reg[und]"]').val($('#edit-group_sp select[name="field_reg[und]"]').val()); $('#edit-group_st > .panel-body .form-item-admin-language:last input, #edit-group_st > .panel-body #edit-roles-change-9').prop('checked',true); $('#user-profile-form > div > .form-actions').hide(); }); } function editSotr(uid){ $.get('/user/'+uid+'/edit',function(d){ var content = $(d).find('#user-profile-form'); $('#edit-group_st #user-profile-form').attr('action',$('#edit-group_st #user-profile-form').attr('action')+'?destination='+window.location.pathname.substr(1)); $('#block-system-main > #user-profile-form > div > .form-actions').hide(); }); } function loadSotr(){ $('#edit-group_st > .panel-body').load('/sotrudniki',function(){ $('.new-sotr').click(function(e){ e.preventDefault(); addSotr(); }); $('.sotred').click(function(e){ e.preventDefault(); editSotr($(this).attr('ref')); }); }); } // ajax complete jQuery(document).ajaxComplete(function(event, xhr, settings) { bindLL(); $('.news-comments .form-item.form-type-managed-file label').hide(); $('.news-comments .file-widget').show(); $('.news-comments .file-widget .form-file').change(function(){ $('.news-comments .file-widget button[name*="upload"]').mousedown(); }); $('.news-comments textarea').val(''); // comments $('#comments').each(function(){ if ($(this).text().trim() == '') { $(this).hide(); } else { $(this).show(); } }); // org broles(); if ($('#edit-r').length > 0) { $('.trgrl a').removeClass('active'); if ($('#edit-r').val() == null) $('.trgrlall').addClass('active'); if ($('#edit-r').val() == '6') $('.trgrlprof').addClass('active'); if ($('#edit-r').val() == '7') $('.trgrlbol').addClass('active'); if ($('#edit-r').val() == '8') $('.trgrlmol').addClass('active'); $(this).addClass('active'); } $('.trgrl a, #edit-reg-wrapper .form-item-reg.form-type-select').removeClass('loading'); // calendar click $('#calendar .pager a').click(function(){ $(this).children('img').hide(); }); // media upfilter(); //likes likes(); // avatar avatarChange(); }); $(document).on('click', function (e) { if ($(e.target).closest('.user-menu a').length !== 0) { window.location = $(e.target).attr('href'); } if ($(e.target).closest('.block-user').length === 0) { $('.user-menu').hide(); } }); $(document).ready(function(){ bindLL(); // user menu $('.block-user').click(function(e){ e.preventDefault(); $('.user-menu').show(); }); // comments $('.news-comments textarea').val(''); $('.news-comments .form-item.form-type-managed-file').click(function(){ $(this).children('label').hide(); $('.news-comments .file-widget').show(); }); $('.news-comments .file-widget .form-file').change(function(){ $('.news-comments .file-widget button[name*="upload"]').mousedown(); }); $('#comments').each(function(){ if ($(this).text().trim() == '') { $(this).hide(); } else { $(this).show(); } }); // likes likes(); // dropdown menu $('.navbar-toggle').click(function(event) { $('.navbar-collapse').toggle('in'); }); // org broles(); // media upfilter(); // photo $('#block-views-pgl-block-1').each(function(){ var count = $(this).children().find('img').size(); $(this).children('h2').text('Фотографии ('+count+')'); }) // tabs $('.vertical-tabs-list a').click(function(){ $('html, body').animate({ scrollTop: parseInt($(this).parents().find('form').offset().top)-5 }, 100); }); $('.profile-lc a').click(function(e){ e.preventDefault(); var n = $('#'+$('.profile-l a.active').attr('t')); var nw = $('#'+$(this).attr('t')); n.hide(); nw.show(); $('.profile-l a').removeClass('active'); $(this).addClass('active'); }); // gallery bgl(); $('.news-pgl-small:not(.slick-initialized)').slick({ infinite: false, arrows: false, slidesToShow: 9, slidesToScroll: 10, variableWidth: true, speed: 500, }); // avatar change avatarChange(); // captcha placeholder $('.form-item-captcha-response').each(function(){ var el = $(this).clone(); el.children().remove(); var ct = el.text().trim(); $(this).html().replace(ct,''); $(this).children('.form-text').attr('placeholder',ct); }); // calendar click $('#calendar .pager a').click(function(){ $(this).children('img').hide(); }); // video title click $('.news-gl-title').click(function(e){ e.preventDefault(); window.location = $(this).parent().next('.media-play').attr('href'); }); }); $(window).load(function(){ // sotrudniki loadSotr(); }); });