// Sticky Plugin v1.0.0 for jQuery // ============= // Author: Anthony Garand // Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk) // Improvements by Leonardo C. Daronco (daronco) // Created: 2/14/2011 // Date: 2/12/2012 // Website: http://labs.anthonygarand.com/sticky // Description: Makes an element on the page stick on the screen as you scroll // It will only set the 'top' and 'position' of your element, you // might need to adjust the width in some cases. function setCookie(cname, cvalue, exdays) { const d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); let expires = "expires="+ d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i -1; } var all_selected = document.getElementsByTagName('*'); for (var i = 0; i < all_selected.length; i++) { if (all_selected[i].getAttribute("type") == "selected") { all_selected[i].addEventListener('click', function(e) { if (!getSelection().isCollapsed) return; var found = false; for (var i = 0; i < e.path.length; i++) { var elm = e.path[i]; if (hasClass(elm, 'message')) { found = true; break; } } if (!found) { return; } if (hasClass(elm, 'checked')) { elm.classList.remove('checked'); } else { elm.classList.add('checked'); } }); } } (function($) { var defaults = { topSpacing: 0, bottomSpacing: 0, className: 'is-sticky', wrapperClassName: 'sticky-wrapper', center: false, getWidthFrom: '', responsiveWidth: false }, $window = $(window), $document = $(document), sticked = [], windowHeight = $window.height(), scroller = function() { var scrollTop = $window.scrollTop(), documentHeight = $document.height(), dwh = documentHeight - windowHeight, extra = (scrollTop > dwh) ? dwh - scrollTop : 0; for (var i = 0; i < sticked.length; i++) { var s = sticked[i], elementTop = s.stickyWrapper.offset().top, etse = elementTop - s.topSpacing - extra; if (scrollTop <= etse) { if (s.currentTop !== null) { s.stickyElement .css('position', '') .css('top', ''); s.stickyElement.trigger('sticky-end', [s]).parent().removeClass(s.className); s.currentTop = null; } } else { var newTop = documentHeight - s.stickyElement.outerHeight() - s.topSpacing - s.bottomSpacing - scrollTop - extra; if (newTop < 0) { newTop = newTop + s.topSpacing; } else { newTop = s.topSpacing; } if (s.currentTop != newTop) { s.stickyElement .css('position', 'fixed') .css('top', newTop); if (typeof s.getWidthFrom !== 'undefined') { s.stickyElement.css('width', $(s.getWidthFrom).width()); } s.stickyElement.trigger('sticky-start', [s]).parent().addClass(s.className); s.currentTop = newTop; } } } }, resizer = function() { windowHeight = $window.height(); for (var i = 0; i < sticked.length; i++) { var s = sticked[i]; if (typeof s.getWidthFrom !== 'undefined' && s.responsiveWidth === true) { s.stickyElement.css('width', $(s.getWidthFrom).width()); } } }, methods = { init: function(options) { var o = $.extend({}, defaults, options); return this.each(function() { var stickyElement = $(this); var stickyId = stickyElement.attr('id'); var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName var wrapper = $('
') .attr('id', stickyId + '-sticky-wrapper') .addClass(o.wrapperClassName); stickyElement.wrapAll(wrapper); if (o.center) { stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"}); } if (stickyElement.css("float") == "right") { stickyElement.css({"float":"none"}).parent().css({"float":"right"}); } var stickyWrapper = stickyElement.parent(); stickyWrapper.css('height', stickyElement.outerHeight()); sticked.push({ topSpacing: o.topSpacing, bottomSpacing: o.bottomSpacing, stickyElement: stickyElement, currentTop: null, stickyWrapper: stickyWrapper, className: o.className, getWidthFrom: o.getWidthFrom, responsiveWidth: o.responsiveWidth }); }); }, update: scroller, unstick: function(options) { return this.each(function() { var unstickyElement = $(this); var removeIdx = -1; for (var i = 0; i < sticked.length; i++) { if (sticked[i].stickyElement.get(0) == unstickyElement.get(0)) { removeIdx = i; } } if(removeIdx != -1) { sticked.splice(removeIdx,1); unstickyElement.unwrap(); unstickyElement.removeAttr('style'); } }); } }; // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer): if (window.addEventListener) { window.addEventListener('scroll', scroller, false); window.addEventListener('resize', resizer, false); } else if (window.attachEvent) { window.attachEvent('onscroll', scroller); window.attachEvent('onresize', resizer); } $.fn.sticky = function(method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method ) { return methods.init.apply( this, arguments ); } else { $.error('Method ' + method + ' does not exist on jQuery.sticky'); } }; $.fn.unstick = function(method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method ) { return methods.unstick.apply( this, arguments ); } else { $.error('Method ' + method + ' does not exist on jQuery.sticky'); } }; $(function() { setTimeout(scroller, 0); }); })(jQuery); function modal_window(elem, parameter) { if (parameter == "close") { var donation = document.getElementsByName('donation_form'); donation.forEach(function(entry) { entry.contentWindow.location.reload(true); }); enableScroll(); if (elem.getAttribute("class") != "modal") { var parent_window = findParentNode("modal", elem, "class"); }else{ var parent_window = elem; } parent_window.removeAttribute("status"); var objects = parent_window.querySelectorAll('object,iframe'); for (var i = 0; i < objects.length; i++) { //if (objects[i].getAttribute("data").indexOf('youtube.com') + 1 || objects[i].getAttribute("src").indexOf('youtube.com') + 1) { var code_video = parent_window.querySelectorAll('code')[0]; if (code_video) { if (code_video.innerHTML.length < 1) { code_video.innerHTML = objects[i].outerHTML; } function video_stop() { objects[i].outerHTML = code_video.innerHTML; } setTimeout(video_stop(objects[i], code_video), 10); //} } } var video = parent_window.querySelectorAll('video'); for (var i = 0; i < video.length; i++) { var videoID = video[i].getAttribute("id"); var videoID = videoID.split("_"); videojs(videoID[0]).pause(); } if (location.search != "") { var st = unescape(location.pathname); var i = false; var r = st.substring( st.lastIndexOf('/') + 1, st.length ); window.history.pushState(null, null, '/'+r); } } } var keys = {37: 1, 38: 1, 39: 1, 40: 1}; function preventDefault(e) { e = e || window.parent.event; if (e.preventDefault) e.preventDefault(); e.returnValue = false; } function preventDefaultForScrollKeys(e) { if (keys[e.keyCode]) { preventDefault(e); return false; } } function disableScroll() { document.body.style.overflowY = "hidden"; document.body.style.overflowX = "hidden"; document.getElementsByTagName("html")[0].style.overflowY = "hidden"; document.getElementsByTagName("html")[0].style.overflowX = "hidden"; if (window.parent.addEventListener) // older FF window.parent.addEventListener('DOMMouseScroll', preventDefault, false); window.parent.onwheel = preventDefault; // modern standard window.parent.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE window.parent.ontouchmove = preventDefault; // mobile document.onkeydown = preventDefaultForScrollKeys; } function enableScroll() { document.body.style.overflowY = "auto"; document.body.style.overflowX = "hidden"; document.getElementsByTagName("html")[0].style.overflowY = "auto"; document.getElementsByTagName("html")[0].style.overflowX = "hidden"; if (window.parent.removeEventListener) window.parent.removeEventListener('DOMMouseScroll', preventDefault, false); window.parent.onmousewheel = document.onmousewheel = null; window.parent.onwheel = null; window.parent.ontouchmove = null; document.onkeydown = null; } function WindContent(page) { var page_split = page.split('.'); if (page_split[1] === undefined) { disableScroll(); }else{ disableScroll(); } var window = document.getElementById(page_split[0]); var parent_window = findParentNode("modal", window, "class"); var parent_window_content = parent_window.getElementsByTagName('*'); var window_content = window.getElementsByTagName('*'); parent_window.setAttribute("status", "show"); for (var i = 0; i < parent_window_content.length; i++) { var data_image = false; var elem = parent_window_content[i]; if (elem.hasAttribute("id")) { if (elem.getAttribute("id") == "touch-scroll_window") { var touch_scroll_window = elem; $(touch_scroll_window).touchScrolling(); } } } } function openurl (url) { window.open(url,"_blank") } function download_doc (file) { document.location.href = "doc/download.php?file="+file; } function DocContent(doc) { if (!device.mobile()) { WindContent(doc); }else{ openurl("doc/doc.html?url="+doc); } } function GallContent(id, page, type) { if (!page) { var page = '1';} if (type == "") { var type = 'img';} WindContent(id); gallery(this, 'nope', id, page.toString()); }(function() { var _addClass, _doc_element, _find, _handleOrientation, _hasClass, _orientation_event, _removeClass, _supports_orientation, _user_agent; window.device = {}; _doc_element = window.document.documentElement; _user_agent = window.navigator.userAgent.toLowerCase(); device.ios = function() { return device.iphone() || device.ipod() || device.ipad(); }; device.iphone = function() { return _find('iphone'); }; device.ipod = function() { return _find('ipod'); }; device.ipad = function() { return _find('ipad'); }; device.android = function() { return _find('android'); }; device.androidPhone = function() { return device.android() && _find('mobile'); }; device.androidTablet = function() { return device.android() && !_find('mobile'); }; device.blackberry = function() { return _find('blackberry') || _find('bb10') || _find('rim'); }; device.blackberryPhone = function() { return device.blackberry() && !_find('tablet'); }; device.blackberryTablet = function() { return device.blackberry() && _find('tablet'); }; device.windows = function() { return _find('windows'); }; device.windowsPhone = function() { return device.windows() && _find('phone'); }; device.windowsTablet = function() { return device.windows() && _find('touch'); }; device.fxos = function() { return _find('(mobile; rv:') || _find('(tablet; rv:'); }; device.fxosPhone = function() { return device.fxos() && _find('mobile'); }; device.fxosTablet = function() { return device.fxos() && _find('tablet'); }; device.mobile = function() { return device.androidPhone() || device.iphone() || device.ipod() || device.windowsPhone() || device.blackberryPhone() || device.fxosPhone(); }; device.tablet = function() { return device.ipad() || device.androidTablet() || device.blackberryTablet() || device.windowsTablet() || device.fxosTablet(); }; device.portrait = function() { return Math.abs(window.orientation) !== 90; }; device.landscape = function() { return Math.abs(window.orientation) === 90; }; _find = function(needle) { return _user_agent.indexOf(needle) !== -1; }; _hasClass = function(class_name) { var regex; regex = new RegExp(class_name, 'i'); return _doc_element.className.match(regex); }; _addClass = function(class_name) { if (!_hasClass(class_name)) { return _doc_element.className += " " + class_name; } }; _removeClass = function(class_name) { if (_hasClass(class_name)) { return _doc_element.className = _doc_element.className.replace(class_name, ""); } }; if (device.ios()) { if (device.ipad()) { _addClass("ios ipad tablet"); } else if (device.iphone()) { _addClass("ios iphone mobile"); } else if (device.ipod()) { _addClass("ios ipod mobile"); } } else if (device.android()) { if (device.androidTablet()) { _addClass("android tablet"); } else { _addClass("android mobile"); } } else if (device.blackberry()) { if (device.blackberryTablet()) { _addClass("blackberry tablet"); } else { _addClass("blackberry mobile"); } } else if (device.windows()) { if (device.windowsTablet()) { _addClass("windows tablet"); } else if (device.windowsPhone()) { _addClass("windows mobile"); } else { _addClass("desktop"); } } else if (device.fxos()) { if (device.fxosTablet()) { _addClass("fxos tablet"); } else { _addClass("fxos mobile"); } } else { _addClass("desktop"); } _handleOrientation = function() { if (device.landscape()) { _removeClass("portrait"); return _addClass("landscape"); } else { _removeClass("landscape"); return _addClass("portrait"); } }; _supports_orientation = "onorientationchange" in window; _orientation_event = _supports_orientation ? "orientationchange" : "resize"; if (window.addEventListener) { window.addEventListener(_orientation_event, _handleOrientation, false); } else if (window.attachEvent) { window.attachEvent(_orientation_event, _handleOrientation); } else { window[_orientation_event] = _handleOrientation; } _handleOrientation(); }).call(this); function slider(sliderid, arrow){ var parent_slider = findParentNode("slider", sliderid, "class"); var slider = parent_slider.getElementsByTagName('*'); for (var i = 0; i < slider.length; i++) { if (slider[i].getAttribute("name") == "select_page") { var select_page = slider[i]; } if (slider[i].getAttribute("name") == "arrows") { var arrows = slider[i]; } if (slider[i].getAttribute("name") == "page") { var page_block = slider[i]; } if (slider[i].getAttribute("name") == "points") { var points = slider[i]; } if (slider[i].getAttribute("name") == "pages") { var pages = slider[i]; } } var pages_count = pages.children.length; var points_count = ""; var select_page_number = select_page.innerHTML; if (select_page_number != "") { page = Number(select_page_number); }else{ page = 0; } if (points.children.length != pages_count) { for (var i = 0; i < pages_count; i++) { points_count = points_count + points.innerHTML; } points.innerHTML = points_count; } if (page != pages_count-1 && arrow == "right") { page += 1; } if (page != 0 && arrow == "left") { page -= 1; } var point_find = points.children; for (var i = 0; i < point_find.length; i++) { point_find[i].removeAttribute("status"); } if (arrow == "point") { var point_count = sliderid.parentElement.children; for (var i = 0; i < point_count.length; i++) { point_count[i].removeAttribute("status"); if (point_count[i] == sliderid) { page = i; } } } var find_arrows = arrows.getElementsByTagName('s'); if (page > 0) { find_arrows[0].removeAttribute("status"); }else{ find_arrows[0].setAttribute("status", "hidden"); } if (page != pages_count-1) { find_arrows[1].removeAttribute("status"); }else{ find_arrows[1].setAttribute("status", "hidden"); } points.children[page].setAttribute("status", "select"); select_page.innerHTML = page; page_block.children[0].innerHTML = pages.children[page].innerHTML; page_block.children[0].removeAttribute("status"); function anim() { page_block.children[0].setAttribute("status", "anim"); } setTimeout(anim, 10); }function findParentNode(parentName, childObj, typefind) { var testObj = childObj.parentNode; var count = 1; while(testObj != document && testObj.getAttribute(typefind) != parentName) { testObj = testObj.parentNode; count++; } if (testObj != document && testObj.getAttribute(typefind) == parentName) { return testObj; console.log(testObj); }else{ return ""; } }function input_file_text(elem) { if (elem.value != "") { elem.setAttribute('status','active'); }else{ elem.removeAttribute('status'); } } $.fn.touchScrolling = function(){ var startPos = 0, self = $(this); self.bind('touchstart', function(event) { var e = event.originalEvent; startPos = self.scrollTop() + e.touches[0].pageY; }); self.bind('touchcancel', function(event) { e.preventDefault(); }); self.bind('touchmove', function(event) { var e = event.originalEvent; self.scrollTop(startPos - e.touches[0].pageY); e.preventDefault(); }); }; $(function() { $('#touch-scroll').touchScrolling(); $('#touch-scroll_menu').touchScrolling(); /* var scroll_windows = document.querySelectorAll("#touch-scroll_window"); for (var i = 0; i < scroll_windows.length; i++) { $(scroll_windows[i]).scroll_windows; } */ }); function preloadiframe(iframe) { var parent_iframe = findParentNode("iframe", iframe, "class"); var preloader = parent_iframe.getElementsByTagName("p")[0]; preloader.setAttribute("status","loaded"); }function call_phone(phone, form) { var call = "tel:+7"; var number = phone.innerHTML.replace(/[^0-9]/gim,'').slice(1); if (device.mobile()) { window.open(call+number,"_top"); }else{ WindContent(form); } }function gallery(galleryid, arrow, stringid, photo_number) { if (stringid == null && photo == null) { var gallery = galleryid.parentElement.parentElement.getElementsByTagName('*'); photo_number = 0; }else{ var gallery = document.getElementById(stringid).getElementsByTagName('*'); photo_number -= 1; } var type; for (var i = 0; i < gallery.length; i++) { if (gallery[i].id == "gallery_photo") { var photo = gallery[i]; var photo2 = gallery[i].getElementsByTagName('img')[0]; type = ""; if (photo.hasAttribute("type")) { type = photo.getAttribute("type"); } } if (gallery[i].id == "counter") { var counter = gallery[i]; } if (gallery[i].id == "counter_all") { var counter_all = gallery[i]; } if (gallery[i].id == "gallery_photos") { var gallery_photos = gallery[i]; } } var photos = gallery_photos.getElementsByTagName('img'); if (type == "" || type == "img") { photo.setAttribute("style", "background-image: url("+photos[photo_number].src+")"); } if (type == "doc") { photo2.setAttribute("src", photos[photo_number].src); } var photo_max = photos.length; if (stringid != null && photo != null) { counter.innerHTML = photo_number + 1; } var gallery_count = Number(counter.innerHTML) -1; if (arrow == "left") { gallery_count -= 1; } if (arrow == "right" && gallery_count != photo_max) { gallery_count += 1; } if (arrow == "left" && gallery_count == -1) { gallery_count = photo_max-1; } if (arrow == "right" && gallery_count == photo_max) { gallery_count = 0; } if (arrow == "left" && gallery_count != 0 || arrow == "right" && gallery_count != photo_max) { if (type == "" || type == "img") { photo.setAttribute("style", "background-image: url("+photos[gallery_count].src+")"); } if (type == "doc") { photo2.setAttribute("src", photos[gallery_count].src); } } counter_all.innerHTML = photo_max; counter.innerHTML = gallery_count+1; }var ww = document.documentElement.clientWidth; var scrolled; var scrolled_stop; var toggle = true; var ww = document.body.clientWidth; function toggleMenuPosition() { /* var scrolled = window.pageYOffset || document.documentElement.scrollTop; if (device.mobile()) { if (toggle == false) { $(".container").css("position", "absolute"); $(".container").css("top", scrolled); } if (scrolled < scrolled_stop) { scrolled_stop = scrolled; $(".container").css("position", "absolute"); $(".container").css("top", scrolled); } } */ } $(document).ready(function() { $(".nav li a").each(function() { if ($(this).next().length > 0) { $(this).addClass("parent"); } }); $(".toggleMenu").click(function(e) { e.preventDefault(); $(this).toggleClass("toggle_menu_active"); $(".container").toggleClass("container_active"); $(".nav").toggle(); if (device.mobile()) { if ($(".toggleMenu").hasClass("toggle_menu_active")) { scrolled_stop = scrolled; toggle = true; }else{ toggle = false; toggleMenuPosition(); } } }); adjustMenu(); }); $(window).bind('resize orientationchange', function() { ww = document.body.clientWidth; adjustMenu(); }); var adjustMenu = function() { if (ww < 769) { $(".toggleMenu").css("display", "inline-block"); if (!$(".toggleMenu").hasClass("active")) { $(".nav").hide(); } else { $(".nav").show(); } $(".nav li").unbind('mouseenter mouseleave'); $(".nav li a.parent").unbind('click').bind('click', function(e) { // must be attached to anchor element to prevent bubbling e.preventDefault(); $(this).parent("li").toggleClass("hover"); }); } else if (ww >= 769) { $(".toggleMenu").css("display", "none"); $(".nav").show(); $(".nav li").removeClass("hover"); $(".nav li a").unbind('click'); $(".nav li").unbind('mouseenter').bind('mouseenter', function() { // must be attached to li so that mouseleave is not triggered when hover over submenu $(this).toggleClass('hover'); }); $(".nav li").unbind('mouseleave').bind('mouseleave', function() { $(this).removeClass('hover'); }); } window.onclick=function(e){ var elem = e ? e.target : window.event.srcElement; var class_string1 = "toggleMenu toggle_menu_active"; var class_string2 = "container container_active"; var ignore; var menu = document.getElementsByClassName(class_string1)[0]; if (menu) { var parent_menu = findParentNode(class_string2, elem, "class"); var parent_menu2 = document.getElementsByClassName(class_string2)[0]; var parent_window = findParentNode("modal", elem, "class"); var parent_menu_elements = parent_menu2.getElementsByTagName('*'); for (var i = 0; i < parent_menu_elements.length; i++) { if (parent_menu_elements[i] == elem) { var ignore = true; } } if (!parent_menu && !ignore && !parent_window) { menu.click(); } } } } /* if (first_run == 0) { for (var i = 0; i < menu.length; i++) { if (menu[i].hasAttribute("class")) { if (menu[i].getAttribute("class") == "hover") { menu[i].removeAttribute("class") } } } } function test() { if (first_run == 0) { var first_run = 1; var menu = document.getElementById("menu").getElementsByTagName('*'); for (var i = 0; i < menu.length; i++) { if (menu[i].hasAttribute("class")) { if (menu[i].getAttribute("class") == "hover") { menu[i].removeAttribute("class") } } } } } test(); */ /* if (device.mobile()) { toggle = false; toggleMenuPosition(); } window.onscroll = function() { toggleMenuPosition(); } */ /* $(document).bind('pageinit', function(){ $(document).vclick(function(e) { close_menu_fon(e); }); }); */