diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2016-08-29 04:30:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-29 04:30:52 +0300 |
commit | 0c9c30b731ccbacf47e154b9f7a590af49e3d799 (patch) | |
tree | c5cf2f6437bb2ee7f3675350ee4b0b6acbbae7d3 /libs/bower_components/jScrollPane/script/jquery.jscrollpane.js | |
parent | bfdf0bed670f247bf9b1d466e3bcf651e98ab634 (diff) |
Better UI for Piwik 3, more responsive, faster, lots of other fixes (#10397)
* improved ui and responsiveness
* improve rss widget
* commit changes for ui again, got lost after the last commit
* fix more tests
* restoring files
* fix fonts
* fix more tests
* more test fixes
* fix some system tests
* fix tests
* fix system and ui tests
* fix updater tests
* make a page as loaded once the callback is called
* enable verbose
* more verbose output
* enable phantomjs debug flag
* debug should be a phantomjs option
* trying to fix installation tests
* fixes #10173 to not compile css files as less
* trying to minimize js/css requests to hopefully prevent random ui test fails
* disable verbose mode
* fix updater and installation
* lots of bugfixes and ui tweaks
* fix reset dashboard
* various bugfixes
* fix integration tests
* fix text color
* hoping to fix installation tests this way
* cache css/js resources for an hour, should speed up tests and prevent some random issues
* we need to avoid installing plugins multiple times at the same time when requesting resources
* finally getting the colors right again
* fix most tests, more tests for theme
* use an h2 element for titles for better accessibility
* fix headline color
* use actual theme text color (piwik-black)
* fix small font size was applied on all p elements
* fix tests
* now improving all the datatables
* trying to ignore images for visitor log
* Revert "trying to ignore images for visitor log"
This reverts commit ad1ff7267aae14ad905bef130e956c8593c4fb22.
* fix tests
* fix we had always ignored a max label width
* trying to fix file permissions
* fix more file permissions
* Improved plugins update API (#10028)
* refs #7983 let plugins add or remove fields to websites and better settings api
* * Hide CorePluginsAdmin API methods
* More documentation
* Added some more tests
* improved updates API for plugins
* better error code as duplicate column cannot really happen when not actually renaming a colum
Conflicts:
core/Updates/3.0.0-b1.php
plugins/CoreUpdater/Commands/Update/CliUpdateObserver.php
* fix DB field piwik_log_visit.location_provider too small (#10003)
* fixes #9564 fix DB field piwik_log_visit.location_provider too small
* use new plugins updater API
* DB field piwik_log_visit.visit_total_actions too small (#10002)
* fixes #9565 DB field piwik_log_visit.visit_total_actions too small
* change type of some db columns that are too small
* fix tests (#10040)
Conflicts:
plugins/CoreAdminHome/Menu.php
plugins/Goals/Menu.php
plugins/MobileMessaging/Menu.php
plugins/SitesManager/Menu.php
plugins/UsersManager/Menu.php
tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata.xml
* fix more file permissions
* repair more file permissions
* repair more file permissions
* trying to make ui tests work again, the table was missing
* fix some encoding issues
* cross browser fixes and usability improvement
* move back the config icon, need to find a better solution later
* more cross browser fixes
* bugfixes
* fix ui tests
* fix encoding issue
* fix various issues with the ui tests when a test gets aborted
* also skip this visitor log test when aborted
* there were 3 css files that were loaded separately, merge them instead into one css
* forgot to add the actual manifest
* do not add manifest if custom logo is specified
* load font css files first as it was before merging them into big css
* fix link icon was not aligned anymore
* minor fixes
* setting it back to 4px
* in popovers the font variable was always ignored and a different font loaded
* forgot to update screenshots
* fix remaining tests
* this should fix an update error
* added 3 new widgets system check, system summary and plugin updates
* tweak new widgets content
* no page reload when changing date or segment
* in admin home show only enabled widgets
* refs #10295 use getMockBuilder instead of deprecated getMock
* fix some ui tests
* fix various bugs
* fix more tests
* fix ui tests
* add a space between loading image and loading message
* fix docs so they appear on developer.piwik.org
* improved documentation
* introduce new Widget::renderTemplate method for consistency with controllers
* remove no longer needed files
* testing system fonts
* fix strong was not really bold
* more useful system summary
* remove ubuntu font
* fix most tests and removed most em elements
* fix tests
* fix headline was very thin
* update submodule
* update submodules
* update submodule
* fix failing ui tests
* update submodules
Diffstat (limited to 'libs/bower_components/jScrollPane/script/jquery.jscrollpane.js')
-rw-r--r-- | libs/bower_components/jScrollPane/script/jquery.jscrollpane.js | 186 |
1 files changed, 131 insertions, 55 deletions
diff --git a/libs/bower_components/jScrollPane/script/jquery.jscrollpane.js b/libs/bower_components/jScrollPane/script/jquery.jscrollpane.js index 9bc41f914e..6db96c7afc 100644 --- a/libs/bower_components/jScrollPane/script/jquery.jscrollpane.js +++ b/libs/bower_components/jScrollPane/script/jquery.jscrollpane.js @@ -1,14 +1,14 @@ /*! - * jScrollPane - v2.0.14 - 2013-05-01 + * jScrollPane - v2.0.23 - 2016-01-28 * http://jscrollpane.kelvinluck.com/ * - * Copyright (c) 2010 Kelvin Luck + * Copyright (c) 2014 Kelvin Luck * Dual licensed under the MIT or GPL licenses. */ // Script: jScrollPane - cross browser customisable scrollbars // -// *Version: 2.0.14, Last updated: 2013-05-01* +// *Version: 2.0.23, Last updated: 2016-01-28* // // Project Home - http://jscrollpane.kelvinluck.com/ // GitHub - http://github.com/vitch/jScrollPane @@ -17,7 +17,7 @@ // // About: License // -// Copyright (c) 2013 Kelvin Luck +// Copyright (c) 2014 Kelvin Luck // Dual licensed under the MIT or GPL Version 2 licenses. // http://jscrollpane.kelvinluck.com/MIT-LICENSE.txt // http://jscrollpane.kelvinluck.com/GPL-LICENSE.txt @@ -32,13 +32,22 @@ // This plugin is tested on the browsers below and has been found to work reliably on them. If you run // into a problem on one of the supported browsers then please visit the support section on the jScrollPane // website (http://jscrollpane.kelvinluck.com/) for more information on getting support. You are also -// welcome to fork the project on GitHub if you can contribute a fix for a given issue. +// welcome to fork the project on GitHub if you can contribute a fix for a given issue. // // jQuery Versions - tested in 1.4.2+ - reported to work in 1.3.x // Browsers Tested - Firefox 3.6.8, Safari 5, Opera 10.6, Chrome 5.0, IE 6, 7, 8 // // About: Release History // +// 2.0.23 - (2016-01-28) Various +// 2.0.22 - (2015-04-25) Resolve a memory leak due to an event handler that isn't cleaned up in destroy (thanks @timjnh) +// 2.0.21 - (2015-02-24) Simplify UMD pattern: fixes browserify when loading jQuery outside of bundle +// 2.0.20 - (2014-10-23) Adds AMD support (thanks @carlosrberto) and support for overflow-x/overflow-y (thanks @darimpulso) +// 2.0.19 - (2013-11-16) Changes for more reliable scroll amount with latest mousewheel plugin (thanks @brandonaaron) +// 2.0.18 - (2013-10-23) Fix for issue with gutters and scrollToElement (thanks @Dubiy) +// 2.0.17 - (2013-08-17) Working correctly when box-sizing is set to border-box (thanks @pieht) +// 2.0.16 - (2013-07-30) Resetting left position when scroll is removed. Fixes #189 +// 2.0.15 - (2013-07-29) Fixed issue with scrollToElement where the destX and destY are undefined. // 2.0.14 - (2013-05-01) Updated to most recent mouse wheel plugin (see #106) and related changes for sensible scroll speed // 2.0.13 - (2013-05-01) Switched to semver compatible version name // 2.0.0beta12 - (2012-09-27) fix for jQuery 1.8+ @@ -56,7 +65,18 @@ // elements and dynamically sized elements. // 1.x - (2006-12-31 - 2010-07-31) Initial version, hosted at googlecode, deprecated -(function($,window,undefined){ +(function (factory) { + if ( typeof define === 'function' && define.amd ) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS style for Browserify + module.exports = factory(require('jquery')); + } else { + // Browser globals + factory(jQuery); + } +}(function($){ $.fn.jScrollPane = function(settings) { @@ -73,12 +93,17 @@ originalElement = elem.clone(false, false).empty(), mwEvent = $.fn.mwheelIntent ? 'mwheelIntent.jsp' : 'mousewheel.jsp'; - originalPadding = elem.css('paddingTop') + ' ' + - elem.css('paddingRight') + ' ' + - elem.css('paddingBottom') + ' ' + - elem.css('paddingLeft'); - originalPaddingTotalWidth = (parseInt(elem.css('paddingLeft'), 10) || 0) + - (parseInt(elem.css('paddingRight'), 10) || 0); + if (elem.css('box-sizing') === 'border-box') { + originalPadding = 0; + originalPaddingTotalWidth = 0; + } else { + originalPadding = elem.css('paddingTop') + ' ' + + elem.css('paddingRight') + ' ' + + elem.css('paddingBottom') + ' ' + + elem.css('paddingLeft'); + originalPaddingTotalWidth = (parseInt(elem.css('paddingLeft'), 10) || 0) + + (parseInt(elem.css('paddingRight'), 10) || 0); + } function initialise(s) { @@ -105,7 +130,7 @@ paneHeight = elem.innerHeight(); elem.width(paneWidth); - + pane = $('<div class="jspPane" />').css('padding', originalPadding).append(elem.children()); container = $('<div class="jspContainer" />') .css({ @@ -116,7 +141,7 @@ /* // Move any margins from the first and last children up to the container so they can still - // collapse with neighbouring elements as they would before jScrollPane + // collapse with neighbouring elements as they would before jScrollPane firstChild = pane.find(':first-child'); lastChild = pane.find(':last-child'); elem.css( @@ -151,7 +176,7 @@ return; } previousContentWidth = contentWidth; - + pane.css('width', ''); elem.width(paneWidth); @@ -178,7 +203,8 @@ if (!(isScrollableH || isScrollableV)) { elem.removeClass('jspScrollable'); pane.css({ - top: 0, + top: 0, + left: 0, width: container.width() - originalPaddingTotalWidth }); removeMousewheel(); @@ -206,14 +232,14 @@ initFocusHandler(); initMousewheel(); initTouch(); - + if (settings.enableKeyboardNavigation) { initKeyboardNav(); } if (settings.clickOnTrack) { initClickOnTrack(); } - + observeHash(); if (settings.hijackInternalLinks) { hijackInternalLinks(); @@ -474,7 +500,7 @@ function appendArrows(ele, p, a1, a2) { var p1 = "before", p2 = "after", aTemp; - + // Sniff for mac... Is there a better way to determine whether the arrows would naturally appear // at the top or the bottom of the bar? if (p == "os") { @@ -589,7 +615,7 @@ } ); } - + if (isScrollableH) { horizontalTrack.bind( 'mousedown.jsp', @@ -674,15 +700,33 @@ destY = dragMaxY; } + // allow for devs to prevent the JSP from being scrolled + var willScrollYEvent = new $.Event("jsp-will-scroll-y"); + elem.trigger(willScrollYEvent, [destY]); + + if (willScrollYEvent.isDefaultPrevented()) { + return; + } + + var tmpVerticalDragPosition = destY || 0; + + var isAtTop = tmpVerticalDragPosition === 0, + isAtBottom = tmpVerticalDragPosition == dragMaxY, + percentScrolled = destY/ dragMaxY, + destTop = -percentScrolled * (contentHeight - paneHeight); + // can't just check if(animate) because false is a valid value that could be passed in... if (animate === undefined) { animate = settings.animateScroll; } if (animate) { - jsp.animate(verticalDrag, 'top', destY, _positionDragY); + jsp.animate(verticalDrag, 'top', destY, _positionDragY, function() { + elem.trigger('jsp-user-scroll-y', [-destTop, isAtTop, isAtBottom]); + }); } else { verticalDrag.css('top', destY); _positionDragY(destY); + elem.trigger('jsp-user-scroll-y', [-destTop, isAtTop, isAtBottom]); } } @@ -694,7 +738,7 @@ } container.scrollTop(0); - verticalDragPosition = destY; + verticalDragPosition = destY || 0; var isAtTop = verticalDragPosition === 0, isAtBottom = verticalDragPosition == dragMaxY, @@ -706,7 +750,7 @@ wasAtBottom = isAtBottom; elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]); } - + updateVerticalArrows(isAtTop, isAtBottom); pane.css('top', destTop); elem.trigger('jsp-scroll-y', [-destTop, isAtTop, isAtBottom]).trigger('scroll'); @@ -723,14 +767,33 @@ destX = dragMaxX; } + + // allow for devs to prevent the JSP from being scrolled + var willScrollXEvent = new $.Event("jsp-will-scroll-x"); + elem.trigger(willScrollXEvent, [destX]); + + if (willScrollXEvent.isDefaultPrevented()) { + return; + } + + var tmpHorizontalDragPosition = destX ||0; + + var isAtLeft = tmpHorizontalDragPosition === 0, + isAtRight = tmpHorizontalDragPosition == dragMaxX, + percentScrolled = destX / dragMaxX, + destLeft = -percentScrolled * (contentWidth - paneWidth); + if (animate === undefined) { animate = settings.animateScroll; } if (animate) { - jsp.animate(horizontalDrag, 'left', destX, _positionDragX); + jsp.animate(horizontalDrag, 'left', destX, _positionDragX, function() { + elem.trigger('jsp-user-scroll-x', [-destLeft, isAtLeft, isAtRight]); + }); } else { horizontalDrag.css('left', destX); _positionDragX(destX); + elem.trigger('jsp-user-scroll-x', [-destLeft, isAtLeft, isAtRight]); } } @@ -741,7 +804,7 @@ } container.scrollTop(0); - horizontalDragPosition = destX; + horizontalDragPosition = destX ||0; var isAtLeft = horizontalDragPosition === 0, isAtRight = horizontalDragPosition == dragMaxX, @@ -753,7 +816,7 @@ wasAtRight = isAtRight; elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]); } - + updateHorizontalArrows(isAtLeft, isAtRight); pane.css('left', destLeft); elem.trigger('jsp-scroll-x', [-destLeft, isAtLeft, isAtRight]).trigger('scroll'); @@ -803,7 +866,7 @@ container.scrollTop(0); container.scrollLeft(0); - + // loop through parents adding the offset top of any elements that are relatively positioned between // the focused element and the jspPane so we can get the true distance from the top // of the focused element to the top of the scrollpane... @@ -820,14 +883,14 @@ viewportTop = contentPositionY(); maxVisibleEleTop = viewportTop + paneHeight; if (eleTop < viewportTop || stickToTop) { // element is above viewport - destY = eleTop - settings.verticalGutter; + destY = eleTop - settings.horizontalGutter; } else if (eleTop + eleHeight > maxVisibleEleTop) { // element is below viewport - destY = eleTop - paneHeight + eleHeight + settings.verticalGutter; + destY = eleTop - paneHeight + eleHeight + settings.horizontalGutter; } - if (destY) { + if (!isNaN(destY)) { scrollToY(destY, animate); } - + viewportLeft = contentPositionX(); maxVisibleEleLeft = viewportLeft + paneWidth; if (eleLeft < viewportLeft || stickToTop) { // element is to the left of viewport @@ -835,7 +898,7 @@ } else if (eleLeft + eleWidth > maxVisibleEleLeft) { // element is to the right viewport destX = eleLeft - paneWidth + eleWidth + settings.horizontalGutter; } - if (destX) { + if (!isNaN(destX)) { scrollToX(destX, animate); } @@ -868,8 +931,12 @@ container.unbind(mwEvent).bind( mwEvent, function (event, delta, deltaX, deltaY) { - var dX = horizontalDragPosition, dY = verticalDragPosition; - jsp.scrollBy(deltaX * settings.mouseWheelSpeed, -deltaY * settings.mouseWheelSpeed, false); + + if (!horizontalDragPosition) horizontalDragPosition = 0; + if (!verticalDragPosition) verticalDragPosition = 0; + + var dX = horizontalDragPosition, dY = verticalDragPosition, factor = event.deltaFactor || settings.mouseWheelSpeed; + jsp.scrollBy(deltaX * factor, -deltaY * factor, false); // return true if there was no movement so rest of screen can scroll return dX == horizontalDragPosition && dY == verticalDragPosition; } @@ -901,21 +968,22 @@ { pane.find(':input,a').unbind('focus.jsp'); } - + function initKeyboardNav() { var keyDown, elementHasScrolled, validParents = []; isScrollableH && validParents.push(horizontalBar[0]); isScrollableV && validParents.push(verticalBar[0]); - + // IE also focuses elements that don't have tabindex set. - pane.focus( + pane.bind( + 'focus.jsp', function() { elem.focus(); } ); - + elem.attr('tabindex', 0) .unbind('keydown.jsp keypress.jsp') .bind( @@ -957,10 +1025,14 @@ if (e.keyCode == keyDown) { keyDownHandler(); } + // If the keypress is not related to the area, ignore it. Fixes problem with inputs inside scrolled area. Copied from line 955. + if (e.target !== this && !(validParents.length && $(e.target).closest(validParents).length)){ + return; + } return !elementHasScrolled; } ); - + if (settings.hideFocus) { elem.css('outline', 'none'); if ('hideFocus' in container[0]){ @@ -972,7 +1044,7 @@ elem.attr('hideFocus', false); } } - + function keyDownHandler() { var dX = horizontalDragPosition, dY = verticalDragPosition; @@ -1002,12 +1074,14 @@ return elementHasScrolled; } } - + function removeKeyboardNav() { elem.attr('tabindex', '-1') .removeAttr('tabindex') .unbind('keydown.jsp keypress.jsp'); + + pane.unbind('.jsp'); } function observeHash() @@ -1057,7 +1131,7 @@ $(document.body).data('jspHijack', true); // use live handler to also capture newly created links - $(document.body).delegate('a[href*=#]', 'click', function(event) { + $(document.body).delegate('a[href*="#"]', 'click', function(event) { // does the link point to the same page? // this also takes care of cases with a <base>-Tag or Links not starting with the hash # // e.g. <a href="index.html#test"> when the current url already is index.html @@ -1114,7 +1188,7 @@ event.preventDefault(); }); } - + // Init touch on iPad, iPhone, iPod, Android function initTouch() { @@ -1124,7 +1198,7 @@ touchStartY, moved, moving = false; - + container.unbind('touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick').bind( 'touchstart.jsp', function(e) @@ -1144,14 +1218,14 @@ if(!moving) { return; } - + var touchPos = ev.originalEvent.touches[0], dX = horizontalDragPosition, dY = verticalDragPosition; - + jsp.scrollTo(startX + touchStartX - touchPos.pageX, startY + touchStartY - touchPos.pageY); - + moved = moved || Math.abs(touchStartX - touchPos.pageX) > 5 || Math.abs(touchStartY - touchPos.pageY) > 5; - + // return true if there was no movement so rest of screen can scroll return dX == horizontalDragPosition && dY == verticalDragPosition; } @@ -1175,11 +1249,12 @@ } ); } - + function destroy(){ var currentY = contentPositionY(), currentX = contentPositionX(); elem.removeClass('jspScrollable').unbind('.jsp'); + pane.unbind('.jsp'); elem.replaceWith(originalElement.append(pane.children())); originalElement.scrollTop(currentY); originalElement.scrollLeft(currentX); @@ -1291,8 +1366,9 @@ // * prop - the property that is being animated // * value - the value it's being animated to // * stepCallback - a function that you must execute each time you update the value of the property + // * completeCallback - a function that will be executed after the animation had finished // You can use the default implementation (below) as a starting point for your own implementation. - animate: function(ele, prop, value, stepCallback) + animate: function(ele, prop, value, stepCallback, completeCallback) { var params = {}; params[prop] = value; @@ -1302,7 +1378,8 @@ 'duration' : settings.animateDuration, 'easing' : settings.animateEase, 'queue' : false, - 'step' : stepCallback + 'step' : stepCallback, + 'complete' : completeCallback } ); }, @@ -1372,13 +1449,13 @@ } } ); - + initialise(s); } // Pluginifying code... settings = $.extend({}, $.fn.jScrollPane.defaults, settings); - + // Apply default speed $.each(['arrowButtonSpeed', 'trackClickSpeed', 'keyboardSpeed'], function() { settings[this] = settings[this] || settings.speed; @@ -1434,5 +1511,4 @@ scrollPagePercent : .8 // Percent of visible area scrolled when pageUp/Down or track area pressed }; -})(jQuery,this); - +})); |