133 |
133 |
try {
|
134 |
134 |
if ("undefined" == typeof sheet || "undefined" == typeof txmstyle) {
|
135 |
135 |
txmstyle = document.createElement("style");
|
136 |
|
txmstyle.title="txm_btt"
|
137 |
|
try { txmstyle.appendChild(document.createTextNode("")); } catch (e) {};
|
138 |
|
document.head.appendChild(txmstyle);
|
|
136 |
txmstyle.title = "txm_btt"
|
|
137 |
try {
|
|
138 |
txmstyle.appendChild(document.createTextNode(""));
|
|
139 |
} catch (e) {
|
|
140 |
}
|
|
141 |
|
|
142 |
document.body.appendChild(txmstyle);
|
139 |
143 |
sheet = txmstyle.sheet;
|
140 |
144 |
}
|
141 |
145 |
} catch (e) {
|
142 |
146 |
sheet = 'error';
|
143 |
147 |
}
|
144 |
148 |
|
145 |
|
//try {
|
|
149 |
// try {
|
146 |
150 |
|
147 |
|
//if (!Element.prototype.scrollIntoViewIfNeeded) {
|
148 |
|
//Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView;
|
149 |
|
////Element.prototype.scrollIntoViewIfNeeded = function(centerIfNeeded) {
|
150 |
|
////centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
|
151 |
|
////var parent = this.parentNode, parentComputedStyle = window
|
152 |
|
////.getComputedStyle(parent, null), parentBorderTopWidth = parseInt(parentComputedStyle
|
153 |
|
////.getPropertyValue('border-top-width')), parentBorderLeftWidth = parseInt(parentComputedStyle
|
154 |
|
////.getPropertyValue('border-left-width')), overTop = this.offsetTop
|
155 |
|
////- parent.offsetTop < parent.scrollTop, overBottom = (this.offsetTop
|
156 |
|
////- parent.offsetTop + this.clientHeight - parentBorderTopWidth) > (parent.scrollTop + parent.clientHeight), overLeft = this.offsetLeft
|
157 |
|
////- parent.offsetLeft < parent.scrollLeft, overRight = (this.offsetLeft
|
158 |
|
////- parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth), alignWithTop = overTop
|
159 |
|
////&& !overBottom;
|
160 |
|
////if ((overTop || overBottom) && centerIfNeeded) {
|
161 |
|
////parent.scrollTop = this.offsetTop - parent.offsetTop
|
162 |
|
////- parent.clientHeight / 2 - parentBorderTopWidth
|
163 |
|
////+ this.clientHeight / 2;
|
164 |
|
////}
|
165 |
|
////if ((overLeft || overRight) && centerIfNeeded) {
|
166 |
|
////parent.scrollLeft = this.offsetLeft - parent.offsetLeft
|
167 |
|
////- parent.clientWidth / 2 - parentBorderLeftWidth
|
168 |
|
////+ this.clientWidth / 2;
|
169 |
|
////}
|
170 |
|
////if ((overTop || overBottom || overLeft || overRight)
|
171 |
|
////&& !centerIfNeeded) {
|
172 |
|
////this.scrollIntoView(alignWithTop);
|
173 |
|
////}
|
174 |
|
////};
|
175 |
|
//}
|
176 |
|
//} catch (e) {
|
177 |
|
//Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView
|
178 |
|
//}
|
|
151 |
// if (!Element.prototype.scrollIntoViewIfNeeded) {
|
|
152 |
// Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView;
|
|
153 |
// //Element.prototype.scrollIntoViewIfNeeded = function(centerIfNeeded) {
|
|
154 |
// //centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
|
|
155 |
// //var parent = this.parentNode, parentComputedStyle = window
|
|
156 |
// //.getComputedStyle(parent, null), parentBorderTopWidth =
|
|
157 |
// parseInt(parentComputedStyle
|
|
158 |
// //.getPropertyValue('border-top-width')), parentBorderLeftWidth =
|
|
159 |
// parseInt(parentComputedStyle
|
|
160 |
// //.getPropertyValue('border-left-width')), overTop = this.offsetTop
|
|
161 |
// //- parent.offsetTop < parent.scrollTop, overBottom = (this.offsetTop
|
|
162 |
// //- parent.offsetTop + this.clientHeight - parentBorderTopWidth) >
|
|
163 |
// (parent.scrollTop + parent.clientHeight), overLeft = this.offsetLeft
|
|
164 |
// //- parent.offsetLeft < parent.scrollLeft, overRight = (this.offsetLeft
|
|
165 |
// //- parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) >
|
|
166 |
// (parent.scrollLeft + parent.clientWidth), alignWithTop = overTop
|
|
167 |
// //&& !overBottom;
|
|
168 |
// //if ((overTop || overBottom) && centerIfNeeded) {
|
|
169 |
// //parent.scrollTop = this.offsetTop - parent.offsetTop
|
|
170 |
// //- parent.clientHeight / 2 - parentBorderTopWidth
|
|
171 |
// //+ this.clientHeight / 2;
|
|
172 |
// //}
|
|
173 |
// //if ((overLeft || overRight) && centerIfNeeded) {
|
|
174 |
// //parent.scrollLeft = this.offsetLeft - parent.offsetLeft
|
|
175 |
// //- parent.clientWidth / 2 - parentBorderLeftWidth
|
|
176 |
// //+ this.clientWidth / 2;
|
|
177 |
// //}
|
|
178 |
// //if ((overTop || overBottom || overLeft || overRight)
|
|
179 |
// //&& !centerIfNeeded) {
|
|
180 |
// //this.scrollIntoView(alignWithTop);
|
|
181 |
// //}
|
|
182 |
// //};
|
|
183 |
// }
|
|
184 |
// } catch (e) {
|
|
185 |
// Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView
|
|
186 |
// }
|
179 |
187 |
|
180 |
188 |
function showElementIfNeeded(el) {
|
181 |
189 |
if (!Element.prototype.scrollIntoViewIfNeeded) {
|
182 |
|
if (!isAnyPartOfElementInViewport(el)) el.scrollIntoView(false);
|
|
190 |
if (!isAnyPartOfElementInViewport(el))
|
|
191 |
el.scrollIntoView(false);
|
183 |
192 |
} else {
|
184 |
193 |
el.scrollIntoViewIfNeeded();
|
185 |
194 |
}
|
186 |
195 |
}
|
187 |
196 |
|
188 |
197 |
function isAnyPartOfElementInViewport(el) {
|
189 |
|
try {
|
|
198 |
try {
|
190 |
199 |
const rect = el.getBoundingClientRect();
|
191 |
|
// DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 }
|
|
200 |
// DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108,
|
|
201 |
// bottom: 108, left: 8 }
|
192 |
202 |
const windowHeight = (window.innerHeight || document.documentElement.clientHeight);
|
193 |
203 |
const windowWidth = (window.innerWidth || document.documentElement.clientWidth);
|
194 |
204 |
|
195 |
205 |
// http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap
|
196 |
|
const vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0);
|
197 |
|
const horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);
|
|
206 |
const vertInView = (rect.top <= windowHeight)
|
|
207 |
&& ((rect.top + rect.height) >= 0);
|
|
208 |
const horInView = (rect.left <= windowWidth)
|
|
209 |
&& ((rect.left + rect.width) >= 0);
|
198 |
210 |
|
199 |
211 |
return (vertInView && horInView);
|
200 |
212 |
} catch (e) {
|