Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/bower_components/jScrollPane/script/jquery.jscrollpane.js')
-rw-r--r--libs/bower_components/jScrollPane/script/jquery.jscrollpane.js186
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);
-
+}));