1(function (window) { 2 if (!!window.ItRKomiToTop) { 3 return; 4 } 5 6 window.ItRKomiToTop = function (params) { 7 this.params = params; 8 this.id = null; 9 this.obToTop = null; 10 this.bottom = 50; 11 this.left = 100; 12 this.shown = false; 13 this.showInProgress = false; 14 this.scrollInProgress = false; 15 this.duration = 500; 16 this.windowHeight = window.innerHeight; 17 var _this = this; 18 this.showParams = { 19 duration: 500, 20 start: { 21 opacity: 0 22 }, 23 finish: { 24 opacity: 100 25 }, 26 transition: BX.easing.transitions.quart, 27 step: function (state) { 28 BX.adjust (_this.obToTop, { 29 style: { 30 opacity: state.opacity / 100 31 } 32 }); 33 }, 34 complete: function () { 35 _this.shown = true; 36 _this.showInProgress = false; 37 } 38 }; 39 40 this.hideParams = { 41 duration: 500, 42 start: { 43 opacity: 100 44 }, 45 finish: { 46 opacity: 0 47 }, 48 transition: BX.easing.transitions.quart, 49 step: function (state) { 50 BX.adjust (_this.obToTop, { 51 style: { 52 opacity: state.opacity / 100 53 } 54 }); 55 }, 56 complete: function () { 57 _this.shown = false; 58 _this.showInProgress = false; 59 BX.addClass(_this.obToTop, 'hidden'); 60 } 61 }; 62 63 this.scrollParams = { 64 duration: this.duration, 65 start: { 66 scroll: window.scrollY 67 }, 68 finish: { 69 scroll: 0 70 }, 71 transition: BX.easing.transitions.quart, 72 step: function (state) { 73 window.scrollTo(0, state.scroll); 74 }, 75 complete: function () { 76 _this.scrollInProgress = false; 77 } 78 }; 79 80 if (!!params.WRAPPER_NAME) { 81 this.id = params.WRAPPER_NAME; 82 this.obToTop = BX (this.id); 83 } 84 85 if (!!params.LEFT) { 86 this.left = params.LEFT; 87 } 88 89 if (!!params.BOTTOM) { 90 this.bottom = params.BOTTOM; 91 } 92 93 if (!!params.DURATION) { 94 this.duration = params.DURATION; 95 } 96 97 this.init (); 98 }; 99 100 window.ItRKomiToTop.prototype = { 101 init: function () { 102 if (!!this.obToTop) { 103 BX.bind (document, 'scroll', BX.delegate (this.scrollHandler, this)); 104 BX.adjust (this.obToTop, { 105 style: { 106 right: this.left + 'px', 107 bottom: this.bottom + 'px' 108 } 109 }); 110 111 BX.bind(this.obToTop, 'click', BX.delegate(this.scrollToTop, this)); 112 } 113 114 this.scrollHandler (); 115 }, 116 117 scrollHandler: function () { 118 if (window.scrollY > this.windowHeight) { 119 this.showButton (); 120 } else { 121 this.hideButton (); 122 } 123 }, 124 125 showButton: function () { 126 if (this.shown || this.showInProgress) { 127 return; 128 } 129 130 this.showInProgress = true; 131 BX.removeClass(this.obToTop, 'hidden'); 132 var easing = new BX.easing (this.showParams); 133 easing.animate (); 134 }, 135 136 hideButton: function () { 137 if (!this.shown || this.showInProgress) { 138 return; 139 } 140 141 this.showInProgress = true; 142 var easing = new BX.easing (this.hideParams); 143 easing.animate (); 144 }, 145 146 scrollToTop: function() { 147 if (this.scrollInProgress) { 148 return; 149 } 150 151 this.scrollInProgress = true; 152 this.scrollParams.start = { 153 scroll: window.scrollY 154 }; 155 var easing = new BX.easing (this.scrollParams); 156 easing.animate (); 157 } 158 }; 159}) (window);
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.