From 29758c296658725f09e2d03ce923ac965ca1d8e3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 28 Jan 2016 20:53:12 +0100 Subject: [PATCH] Added polyfill for smooth scrooling --- wcfsetup/install/files/js/WCF.Assets.js | 12 +++++++++++- .../install/files/js/WoltLab/WCF/Dom/Util.js | 8 ++++---- .../files/js/WoltLab/WCF/Ui/Page/JumpToTop.js | 2 ++ .../install/files/js/WoltLab/WCF/Ui/Tooltip.js | 17 ++++++----------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Assets.js b/wcfsetup/install/files/js/WCF.Assets.js index f4baf65a9b..145db8d8bf 100644 --- a/wcfsetup/install/files/js/WCF.Assets.js +++ b/wcfsetup/install/files/js/WCF.Assets.js @@ -44,4 +44,14 @@ (function(e){var t={init:function(){var t=["paddingTop","paddingRight","paddingBottom","paddingLeft","fontSize","lineHeight","fontFamily","width","fontWeight","border-top-width","border-right-width","border-bottom-width","border-left-width","-moz-box-sizing","-webkit-box-sizing","box-sizing"];return this.each(function(){function i(){for(var e=0;e/g,">").replace(/&/g,"&").replace(/\n/g,"
");r.html(e+" ");h()}function h(){var e=r.height();var t="hidden";var i=s?e+a+o:e+a;if(i>l){i=l;t="auto"}else if(i").css({position:"absolute",display:"none","word-wrap":"break-word","white-space":"pre-wrap","border-style":"solid"}).appendTo(document.body);i();var s=n.css("box-sizing")=="border-box"||n.css("-moz-box-sizing")=="border-box"||n.css("-webkit-box-sizing")=="border-box";var o=parseInt(n.css("border-top-width"))+parseInt(n.css("padding-top"))+parseInt(n.css("padding-bottom"))+parseInt(n.css("border-bottom-width"));var u=parseInt(n.css("height"),10);var a=parseInt(n.css("line-height"),10)||parseInt(n.css("font-size"),10);var f=a*2>u?a*2:u;var l=parseInt(n.css("max-height"),10)>-1?parseInt(n.css("max-height"),10):Number.MAX_VALUE;n.bind("keyup change cut paste",function(){c()});e(window).bind("resize",function(){var e=parseInt(n.width(),10);if(r.width()!==e){r.css({width:e+"px"});c()}});n.bind("blur",function(){h()});n.bind("updateHeight",function(){i();c()});e(function(){c()})})}};e.fn.flexible=function(n){if(t[n]){return t[n].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof n==="object"||!n){return t.init.apply(this,arguments)}else{e.error("Method "+n+" does not exist on jQuery.flexible")}}})(jQuery); /*! (C) WebReflection Mit Style License */ -(function(e,t,n,r){"use strict";function rt(e,t){for(var n=0,r=e.length;n>0),s="attached",o="detached",u="extends",a="ADDITION",f="MODIFICATION",l="REMOVAL",c="DOMAttrModified",h="DOMContentLoaded",p="DOMSubtreeModified",d="<",v="=",m=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,g=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],y=[],b=[],w="",E=t.documentElement,S=y.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},x=n.prototype,T=x.hasOwnProperty,N=x.isPrototypeOf,C=n.defineProperty,k=n.getOwnPropertyDescriptor,L=n.getOwnPropertyNames,A=n.getPrototypeOf,O=n.setPrototypeOf,M=!!n.__proto__,_=n.create||function vt(e){return e?(vt.prototype=e,new vt):this},D=O||(M?function(e,t){return e.__proto__=t,e}:L&&k?function(){function e(e,t){for(var n,r=L(t),i=0,s=r.length;i>0),s="attached",o="detached",u="extends",a="ADDITION",f="MODIFICATION",l="REMOVAL",c="DOMAttrModified",h="DOMContentLoaded",p="DOMSubtreeModified",d="<",v="=",m=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,g=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],y=[],b=[],w="",E=t.documentElement,S=y.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},x=n.prototype,T=x.hasOwnProperty,N=x.isPrototypeOf,C=n.defineProperty,k=n.getOwnPropertyDescriptor,L=n.getOwnPropertyNames,A=n.getPrototypeOf,O=n.setPrototypeOf,M=!!n.__proto__,_=n.create||function vt(e){return e?(vt.prototype=e,new vt):this},D=O||(M?function(e,t){return e.__proto__=t,e}:L&&k?function(){function e(e,t){for(var n,r=L(t),i=0,s=r.length;i1?1:d,u=o(d),p=l+(t-l)*u,g=i+(r-i)*u,m(p,g),p===t&&g===r?(l=i=s=null,void e.cancelAnimationFrame(c)):void(c=e.requestAnimationFrame(a))}var l=e.scrollX||e.pageXOffset,i=e.scrollY||e.pageYOffset,s=n();c&&e.cancelAnimationFrame(c),c=e.requestAnimationFrame(a)}function u(t,r){function a(){var r,g,v,d=n(),h=(d-p)/f;return h=h>1?1:h,r=o(h),g=i+(u-i)*r,v=s+(m-s)*r,l(t,g,v),g===u&&v===m?(i=s=p=null,void e.cancelAnimationFrame(c)):void(c=e.requestAnimationFrame(a))}var i=t.scrollLeft,s=t.scrollTop,u=r.left,m=r.top,p=n();c&&e.cancelAnimationFrame(c),c=e.requestAnimationFrame(a)}if(!("scrollBehavior"in t.documentElement.style)){var c,f=768,m=e.scrollTo,p=e.scrollBy,g=e.Element.prototype.scrollIntoView;e.scroll=e.scrollTo=function(){return a(arguments[0])?m.call(e,arguments[0].left||arguments[0],arguments[0].top||arguments[1]):s.call(e,~~arguments[0].left,~~arguments[0].top)},e.scrollBy=function(){if(a(arguments[0]))return p.call(e,arguments[0].left||arguments[0],arguments[0].top||arguments[1]);var t=e.scrollX||e.pageXOffset,r=e.scrollY||e.pageYOffset;return s(~~arguments[0].left+t,~~arguments[0].top+r)},Element.prototype.scrollIntoView=function(){var t,r,n,o,l,s;return a(arguments[0])?g.call(this,arguments[0]||!0):(l=i(this),l&&(s=e.getComputedStyle(l,null),r=parseInt(s.getPropertyValue("padding-left"),10),n=parseInt(s.getPropertyValue("padding-top"),10),t={top:this.offsetTop-2*n,left:this.offsetLeft-2*r},o=u(l,t)),o)}}}(window,document); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js b/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js index 3d4754e83d..d2acaae6c9 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js @@ -125,8 +125,8 @@ define([], function() { /** * Returns the outer dimensions of an element including margins. * - * @param {Element} el element - * @return {{height: integer, width: integer}} dimensions in px + * @param {Element} el element + * @return {{height: int, width: int}} dimensions in px */ outerDimensions: function(el) { var styles = window.getComputedStyle(el); @@ -140,8 +140,8 @@ define([], function() { /** * Returns the element's offset relative to the document's top left corner. * - * @param {Element} el element - * @return {{left: integer, top: integer}} offset relative to top left corner + * @param {Element} el element + * @return {{left: int, top: int}} offset relative to top left corner */ offset: function(el) { var rect = el.getBoundingClientRect(); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpToTop.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpToTop.js index 41e82bda13..f286043312 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpToTop.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpToTop.js @@ -50,6 +50,8 @@ define(['Environment', 'Language', './Action'], function(Environment, Language, */ _jump: function(event) { event.preventDefault(); + + elById('top').scrollIntoView({ behavior: 'smooth' }); }, /** diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js index bd579569a4..26fda8b889 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js @@ -17,7 +17,7 @@ define(['Environment', 'Dom/ChangeListener', 'Ui/Alignment'], function(Environme /** * @exports WoltLab/WCF/Ui/Tooltip */ - var UiTooltip = { + return { /** * Initializes the tooltip element and binds event listener. */ @@ -51,13 +51,12 @@ define(['Environment', 'Dom/ChangeListener', 'Ui/Alignment'], function(Environme * Initializes tooltip elements. */ init: function() { + var element, title; while (_elements.length) { - var element = _elements[0]; + element = _elements[0]; element.classList.remove('jsTooltip'); - var title = elAttr(element, 'title'); - title = (typeof title === 'string') ? title.trim() : ''; - + title = elAttr(element, 'title').trim(); if (title.length) { elData(element, 'tooltip', title); element.removeAttribute('title'); @@ -72,7 +71,7 @@ define(['Environment', 'Dom/ChangeListener', 'Ui/Alignment'], function(Environme /** * Displays the tooltip on mouse enter. * - * @param {object} event event object + * @param {Event} event event object */ _mouseEnter: function(event) { var element = event.currentTarget; @@ -111,13 +110,9 @@ define(['Environment', 'Dom/ChangeListener', 'Ui/Alignment'], function(Environme /** * Hides the tooltip once the mouse leaves the element. - * - * @param {object} event event object */ - _mouseLeave: function(event) { + _mouseLeave: function() { _tooltip.classList.remove('active'); } }; - - return UiTooltip; }); -- 2.20.1