PageSourceSearch

https://rbxd.ru/local/templates/redbox/js/scroll_button.js

js rbxd.ru collected 2026-10-08 23:51:02 UTC 4,774 bytes, 53 lines download raw bytes

1;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
2
3jQuery.extend(jQuery.fn, {
4		toplinkwidth: function () {
5			totalContentWidth = jQuery('.b-main-container').outerWidth(); // ширина блока с контентом, включая padding
6			totalTopLinkWidth = jQuery('#top-link').children('a').outerWidth(true); // ширина самой кнопки наверх, включая padding и margin
7			h = jQuery(window).width() / 2 - totalContentWidth / 2 - totalTopLinkWidth;
8			if (h < 0) {
9				// если кнопка не умещается, скрываем её
10				jQuery(this).hide();
11				return false;
12			} else {
13				if (jQuery(window).scrollTop() >= 1) {
14					jQuery(this).show();
15				}
16				jQuery(this).css({'padding-right': h + 'px'});
17				return true;
18			}
19		}
20
21});
22
23jQuery(function($){
24    if( jQuery('.b-main-container').length > 0 ) {
25        var topLink = $('#top-link');
26        topLink.css({'padding-bottom': $(window).height()});
27        // если вам не нужно, чтобы кнопка подстраивалась под ширину экрана - удалите следующие четыре строчки в коде
28        topLink.toplinkwidth();
29        $(window).resize(function () {
30            topLink.toplinkwidth();
31        });
32        $(window).scroll(function () {
33            if (topLink.toplinkwidth()) {
34                if ($(window).scrollTop() >= 1) {
35                    topLink.fadeIn(300).children('a').html('<span id="topicon"></span>наверх').parent().removeClass('bottom_button').addClass('top_button');
36                } else {
37                    topLink.children('a').html('<span id="backicon"></span>вниз').parent().removeClass('top_button').addClass('bottom_button');
38                }
39            }
40        });
41        topLink.click(function (e) {
42            if ($(this).hasClass('bottom_button')) {
43                // при нажатии на кнопку «Вниз» переходим туда, где прекратили чтение
44                $("body").scrollTo(pos + 'px', 500);
45            } else {
46                // определяем и запоминаем координаты того места страницы, откуда был совершен переход наверх
47                pos = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
48                $("body,html").animate({scrollTop: 0}, 500);
49            }
50            return false;
51        });
52    }
53});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.