documentAutoScroller: function (el, interval, timeout) { var self = this, htmlbody = $('html, body'), $window = $(window), scroll_time = (new Date).getTime(), scroll_interval, old_scroll_top = 0, abs_value = typeof el != "object" && $.isNumeric(el) ? parseInt(el) : null; interval = interval || 200; timeout = timeout || 30000; var events = "touchmove.auto_scroller touchstart.auto_scroller keydown.auto_scroller click.auto_scroller " + "MozMousePixelScroll.auto_scroller mousewheel.auto_scroller wheel.auto_scroller scroll.auto_scroller"; var disable_scroll = function (e) { if (e && !e.originalEvent) return; if (e && e.type == "scroll" && e.originalEvent && old_scroll_top == $window.scrollTop()) return; clearInterval(scroll_interval); scroll_interval = null; $window.off('.auto_scroller'); }; var scroller = function () { htmlbody.scrollTop(abs_value !== null ? abs_value : parseInt(el.offset().top)); old_scroll_top = $window.scrollTop(); if ((new Date).getTime() - scroll_time > timeout) disable_scroll(); }; scroll_interval = setInterval(scroller, interval); scroller(); $window.on(events, disable_scroll); self.onRequestStart("auto_scroller", disable_scroll); }, scrollDocument: function (hash) { var self = this, scroll_val = parseInt(hash); if (isNaN(scroll_val) && hash && (typeof hash == "object" || hash.length > 0)) { if (typeof hash == "string" && hash.substr(0, 1) == '/') return; // Эмуляция скролла по якорю try { var el = typeof hash == "object" ? $(hash) : $('#' + hash + ', a[name="' + hash + '"]'); if (el.length > 0) { self.documentAutoScroller(el, 200, 30000); return; } } catch (e) { console.error(e.toString()); } } if (Device.browser == "firefox") { // Mobile FireFox не нужен >_< $('html, body').scrollTop(scroll_val || 0); setTimeout(function () { $('html, body').scrollTop(scroll_val || 0); }, 15); } else $('html, body').scrollTop(scroll_val || 0); },