3
var anima = (function ($) {
7
userAgentInit = function() {
8
document.documentElement.setAttribute('data-useragent', navigator.userAgent);
12
mainMenu = function () {
13
$('.js-open-main-menu').on('click', function (e) {
15
$('.js-menu-container').addClass('show-menu');
16
$('.js-menu-overlay').addClass('visible');
18
$('.js-close-main-menu, .js-menu-overlay').on('click', function (e) {
20
$('.js-menu-container').removeClass('show-menu');
21
$('.js-menu-overlay').removeClass('visible');
26
niceSroll = function() {
27
var $niceScrollHandler = $('html:has(body.nicescroll)');
28
if ($niceScrollHandler.length) {
29
$niceScrollHandler.niceScroll({
32
cursorborder: '1px solid #222',
34
cursorborderradius: 0,
37
autohidemode: 'leave',
38
railpadding: {right: 2},
44
niceScrollReinit = function () {
45
if (!$('html').getNiceScroll().length) {
48
document.addEventListener('visibilitychange', function() {
49
if(!document.hidden && !$('html').getNiceScroll().length) {
55
niceScrollShowEvent = function () {
56
document.addEventListener('visibilitychange', function() {
57
if(!document.hidden && $('html').getNiceScroll().length) {
58
$('html').getNiceScroll()[0].show();
64
headroom = function () {
65
$('.headroom').headroom({
75
goToTopBtn = function() {
76
var $backBtn = $('.js-back-to-top-btn');
78
$(window).scroll(function () {
79
if ($(this).scrollTop() > 300) {
80
$backBtn.removeClass('hidden');
82
$backBtn.addClass('hidden');
85
$backBtn.on('click', function (e) {
87
if ($('body.nicescroll').length) {
88
$('html').getNiceScroll()[0].doScrollTop(0, 1000);
90
$('body, html').stop(true, false).animate({
100
positionIndicator = function () {
101
if ($('.js-post-reading-time').is(':visible')) {
102
imagesLoaded('.post-view-article', function () {
103
var getMax = function() {
104
return $(document).height() - $(window).height();
106
var getValue = function() {
107
return $(window).scrollTop();
109
var progressBar, max, value, width;
110
if('max' in document.createElement('progress')){
112
progressBar = $('progress');
114
progressBar.attr({ max: getMax() });
115
$(document).on('scroll', function(){
117
progressBar.attr({ value: getValue() });
119
$(window).resize(function(){
121
progressBar.attr({ max: getMax(), value: getValue() });
125
progressBar = $('.progress-bar'),
128
var getWidth = function(){
131
width = (value/max) * 100;
135
var setWidth = function(){
136
progressBar.css({ width: getWidth() });
138
$(document).on('scroll', setWidth);
139
$(window).on('resize', function(){
149
readingTime = function () {
150
var $postArticleContent = $('.post-article-content');
151
if ($postArticleContent.length) {
152
$postArticleContent.readingTime({
153
wordCountTarget: $('.js-post-reading-time').find('.js-word-count'),
154
lessThanAMinuteString: 'меньше минуты',
155
minShortFormString: 'мин'
162
imageLightbox = function () {
163
if ($('.anima-image-popup').length) {
169
beforeOpen: function() {
170
this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
171
this.st.mainClass = 'mfp-zoom-in';
175
closeOnContentClick: true,
180
titleSrc: function (item) {
181
if (item.img && item.img.length > 0) {
182
var alt = item.img.attr('alt');
183
if (alt && alt !== "undefined") {
190
$('.anima-image-popup').magnificPopup(mfOptions);
195
filterTagsSelector = function () {
196
[].slice.call(document.querySelectorAll('select.cs-select')).forEach(function(el) {
203
flassMessages = function() {
204
var successMessage = $('.success-flash');
205
if(successMessage.length) {
206
setTimeout(function () {
207
successMessage.hide(300);
214
$(document).foundation();
222
niceScrollShowEvent();
223
filterTagsSelector();