From e93156427ea71162943691ea6b384109e1fe8369 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 28 Dec 2015 23:16:34 +0100 Subject: [PATCH 1/4] use perfect-scrollbars for nav-notifications-menu (and in vier aside) --- js/main.js | 7 + .../perfect-scrollbar/perfect-scrollbar.css | 106 ++ .../perfect-scrollbar.jquery.js | 1617 +++++++++++++++++ .../perfect-scrollbar.min.css | 2 + view/templates/head.tpl | 2 + 5 files changed, 1734 insertions(+) create mode 100644 library/perfect-scrollbar/perfect-scrollbar.css create mode 100644 library/perfect-scrollbar/perfect-scrollbar.jquery.js create mode 100644 library/perfect-scrollbar/perfect-scrollbar.min.css diff --git a/js/main.js b/js/main.js index b28b1079b7..c27d743bc4 100644 --- a/js/main.js +++ b/js/main.js @@ -167,6 +167,10 @@ var notifications_mark = unescape($('
').append( $("#nav-notifications-mark-all").clone() ).html()); //outerHtml hack var notifications_empty = unescape($("#nav-notifications-menu").html()); + /* enable perfect-scrollbars for nav-notivications-menu */ + $('#nav-notifications-menu').perfectScrollbar(); + $('aside').perfectScrollbar(); + /* nav update event */ $('nav').bind('nav-update', function(e,data){ var invalid = $(data).find('invalid').text(); @@ -311,6 +315,9 @@ $.jGrowl(text, { sticky: false, theme: 'info', life: 5000 }); }); + /* update the js scrollbars */ + $('#nav-notifications-menu').perfectScrollbar('update'); + }); NavUpdate(); diff --git a/library/perfect-scrollbar/perfect-scrollbar.css b/library/perfect-scrollbar/perfect-scrollbar.css new file mode 100644 index 0000000000..32cf99b0a3 --- /dev/null +++ b/library/perfect-scrollbar/perfect-scrollbar.css @@ -0,0 +1,106 @@ +/* perfect-scrollbar v0.6.8 */ +.ps-container { + -ms-touch-action: none; + overflow: hidden !important; } + .ps-container.ps-active-x > .ps-scrollbar-x-rail, + .ps-container.ps-active-y > .ps-scrollbar-y-rail { + display: block; } + .ps-container.ps-in-scrolling { + pointer-events: none; } + .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #999; } + .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #999; } + .ps-container > .ps-scrollbar-x-rail { + display: none; + position: absolute; + /* please don't change 'position' */ + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + -ms-border-radius: 4px; + border-radius: 4px; + opacity: 0; + -webkit-transition: background-color 0.2s linear, opacity 0.2s linear; + -moz-transition: background-color 0.2s linear, opacity 0.2s linear; + -o-transition: background-color 0.2s linear, opacity 0.2s linear; + transition: background-color 0.2s linear, opacity 0.2s linear; + bottom: 3px; + /* there must be 'bottom' for ps-scrollbar-x-rail */ + height: 8px; } + .ps-container > .ps-scrollbar-x-rail > .ps-scrollbar-x { + position: absolute; + /* please don't change 'position' */ + background-color: #aaa; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + -ms-border-radius: 4px; + border-radius: 4px; + -webkit-transition: background-color 0.2s linear; + -moz-transition: background-color 0.2s linear; + -o-transition: background-color 0.2s linear; + transition: background-color 0.2s linear; + bottom: 0; + /* there must be 'bottom' for ps-scrollbar-x */ + height: 8px; } + .ps-container > .ps-scrollbar-y-rail { + display: none; + position: absolute; + /* please don't change 'position' */ + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + -ms-border-radius: 4px; + border-radius: 4px; + opacity: 0; + -webkit-transition: background-color 0.2s linear, opacity 0.2s linear; + -moz-transition: background-color 0.2s linear, opacity 0.2s linear; + -o-transition: background-color 0.2s linear, opacity 0.2s linear; + transition: background-color 0.2s linear, opacity 0.2s linear; + right: 3px; + /* there must be 'right' for ps-scrollbar-y-rail */ + width: 8px; } + .ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y { + position: absolute; + /* please don't change 'position' */ + background-color: #aaa; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + -ms-border-radius: 4px; + border-radius: 4px; + -webkit-transition: background-color 0.2s linear; + -moz-transition: background-color 0.2s linear; + -o-transition: background-color 0.2s linear; + transition: background-color 0.2s linear; + right: 0; + /* there must be 'right' for ps-scrollbar-y */ + width: 8px; } + .ps-container:hover.ps-in-scrolling { + pointer-events: none; } + .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #999; } + .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #999; } + .ps-container:hover > .ps-scrollbar-x-rail, + .ps-container:hover > .ps-scrollbar-y-rail { + opacity: 0.6; } + .ps-container:hover > .ps-scrollbar-x-rail:hover { + background-color: #eee; + opacity: 0.9; } + .ps-container:hover > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x { + background-color: #999; } + .ps-container:hover > .ps-scrollbar-y-rail:hover { + background-color: #eee; + opacity: 0.9; } + .ps-container:hover > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y { + background-color: #999; } diff --git a/library/perfect-scrollbar/perfect-scrollbar.jquery.js b/library/perfect-scrollbar/perfect-scrollbar.jquery.js new file mode 100644 index 0000000000..e872d8f30b --- /dev/null +++ b/library/perfect-scrollbar/perfect-scrollbar.jquery.js @@ -0,0 +1,1617 @@ +/* perfect-scrollbar v0.6.8 */ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0) { + classes.splice(idx, 1); + } + element.className = classes.join(' '); +} + +exports.add = function (element, className) { + if (element.classList) { + element.classList.add(className); + } else { + oldAdd(element, className); + } +}; + +exports.remove = function (element, className) { + if (element.classList) { + element.classList.remove(className); + } else { + oldRemove(element, className); + } +}; + +exports.list = function (element) { + if (element.classList) { + return Array.prototype.slice.apply(element.classList); + } else { + return element.className.split(' '); + } +}; + +},{}],3:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var DOM = {}; + +DOM.e = function (tagName, className) { + var element = document.createElement(tagName); + element.className = className; + return element; +}; + +DOM.appendTo = function (child, parent) { + parent.appendChild(child); + return child; +}; + +function cssGet(element, styleName) { + return window.getComputedStyle(element)[styleName]; +} + +function cssSet(element, styleName, styleValue) { + if (typeof styleValue === 'number') { + styleValue = styleValue.toString() + 'px'; + } + element.style[styleName] = styleValue; + return element; +} + +function cssMultiSet(element, obj) { + for (var key in obj) { + var val = obj[key]; + if (typeof val === 'number') { + val = val.toString() + 'px'; + } + element.style[key] = val; + } + return element; +} + +DOM.css = function (element, styleNameOrObject, styleValue) { + if (typeof styleNameOrObject === 'object') { + // multiple set with object + return cssMultiSet(element, styleNameOrObject); + } else { + if (typeof styleValue === 'undefined') { + return cssGet(element, styleNameOrObject); + } else { + return cssSet(element, styleNameOrObject, styleValue); + } + } +}; + +DOM.matches = function (element, query) { + if (typeof element.matches !== 'undefined') { + return element.matches(query); + } else { + if (typeof element.matchesSelector !== 'undefined') { + return element.matchesSelector(query); + } else if (typeof element.webkitMatchesSelector !== 'undefined') { + return element.webkitMatchesSelector(query); + } else if (typeof element.mozMatchesSelector !== 'undefined') { + return element.mozMatchesSelector(query); + } else if (typeof element.msMatchesSelector !== 'undefined') { + return element.msMatchesSelector(query); + } + } +}; + +DOM.remove = function (element) { + if (typeof element.remove !== 'undefined') { + element.remove(); + } else { + if (element.parentNode) { + element.parentNode.removeChild(element); + } + } +}; + +DOM.queryChildren = function (element, selector) { + return Array.prototype.filter.call(element.childNodes, function (child) { + return DOM.matches(child, selector); + }); +}; + +module.exports = DOM; + +},{}],4:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var EventElement = function (element) { + this.element = element; + this.events = {}; +}; + +EventElement.prototype.bind = function (eventName, handler) { + if (typeof this.events[eventName] === 'undefined') { + this.events[eventName] = []; + } + this.events[eventName].push(handler); + this.element.addEventListener(eventName, handler, false); +}; + +EventElement.prototype.unbind = function (eventName, handler) { + var isHandlerProvided = (typeof handler !== 'undefined'); + this.events[eventName] = this.events[eventName].filter(function (hdlr) { + if (isHandlerProvided && hdlr !== handler) { + return true; + } + this.element.removeEventListener(eventName, hdlr, false); + return false; + }, this); +}; + +EventElement.prototype.unbindAll = function () { + for (var name in this.events) { + this.unbind(name); + } +}; + +var EventManager = function () { + this.eventElements = []; +}; + +EventManager.prototype.eventElement = function (element) { + var ee = this.eventElements.filter(function (eventElement) { + return eventElement.element === element; + })[0]; + if (typeof ee === 'undefined') { + ee = new EventElement(element); + this.eventElements.push(ee); + } + return ee; +}; + +EventManager.prototype.bind = function (element, eventName, handler) { + this.eventElement(element).bind(eventName, handler); +}; + +EventManager.prototype.unbind = function (element, eventName, handler) { + this.eventElement(element).unbind(eventName, handler); +}; + +EventManager.prototype.unbindAll = function () { + for (var i = 0; i < this.eventElements.length; i++) { + this.eventElements[i].unbindAll(); + } +}; + +EventManager.prototype.once = function (element, eventName, handler) { + var ee = this.eventElement(element); + var onceHandler = function (e) { + ee.unbind(eventName, onceHandler); + handler(e); + }; + ee.bind(eventName, onceHandler); +}; + +module.exports = EventManager; + +},{}],5:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +module.exports = (function () { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1); + } + return function () { + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + + s4() + '-' + s4() + s4() + s4(); + }; +})(); + +},{}],6:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var cls = require('./class') + , d = require('./dom'); + +exports.toInt = function (x) { + return parseInt(x, 10) || 0; +}; + +exports.clone = function (obj) { + if (obj === null) { + return null; + } else if (typeof obj === 'object') { + var result = {}; + for (var key in obj) { + result[key] = this.clone(obj[key]); + } + return result; + } else { + return obj; + } +}; + +exports.extend = function (original, source) { + var result = this.clone(original); + for (var key in source) { + result[key] = this.clone(source[key]); + } + return result; +}; + +exports.isEditable = function (el) { + return d.matches(el, "input,[contenteditable]") || + d.matches(el, "select,[contenteditable]") || + d.matches(el, "textarea,[contenteditable]") || + d.matches(el, "button,[contenteditable]"); +}; + +exports.removePsClasses = function (element) { + var clsList = cls.list(element); + for (var i = 0; i < clsList.length; i++) { + var className = clsList[i]; + if (className.indexOf('ps-') === 0) { + cls.remove(element, className); + } + } +}; + +exports.outerWidth = function (element) { + return this.toInt(d.css(element, 'width')) + + this.toInt(d.css(element, 'paddingLeft')) + + this.toInt(d.css(element, 'paddingRight')) + + this.toInt(d.css(element, 'borderLeftWidth')) + + this.toInt(d.css(element, 'borderRightWidth')); +}; + +exports.startScrolling = function (element, axis) { + cls.add(element, 'ps-in-scrolling'); + if (typeof axis !== 'undefined') { + cls.add(element, 'ps-' + axis); + } else { + cls.add(element, 'ps-x'); + cls.add(element, 'ps-y'); + } +}; + +exports.stopScrolling = function (element, axis) { + cls.remove(element, 'ps-in-scrolling'); + if (typeof axis !== 'undefined') { + cls.remove(element, 'ps-' + axis); + } else { + cls.remove(element, 'ps-x'); + cls.remove(element, 'ps-y'); + } +}; + +exports.env = { + isWebKit: 'WebkitAppearance' in document.documentElement.style, + supportsTouch: (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch), + supportsIePointer: window.navigator.msMaxTouchPoints !== null +}; + +},{"./class":2,"./dom":3}],7:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var destroy = require('./plugin/destroy') + , initialize = require('./plugin/initialize') + , update = require('./plugin/update'); + +module.exports = { + initialize: initialize, + update: update, + destroy: destroy +}; + +},{"./plugin/destroy":9,"./plugin/initialize":17,"./plugin/update":21}],8:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +module.exports = { + maxScrollbarLength: null, + minScrollbarLength: null, + scrollXMarginOffset: 0, + scrollYMarginOffset: 0, + stopPropagationOnClick: true, + suppressScrollX: false, + suppressScrollY: false, + swipePropagation: true, + useBothWheelAxes: false, + useKeyboard: true, + useSelectionScroll: false, + wheelPropagation: false, + wheelSpeed: 1 +}; + +},{}],9:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var d = require('../lib/dom') + , h = require('../lib/helper') + , instances = require('./instances'); + +module.exports = function (element) { + var i = instances.get(element); + + if (!i) { + return; + } + + i.event.unbindAll(); + d.remove(i.scrollbarX); + d.remove(i.scrollbarY); + d.remove(i.scrollbarXRail); + d.remove(i.scrollbarYRail); + h.removePsClasses(element); + + instances.remove(element); +}; + +},{"../lib/dom":3,"../lib/helper":6,"./instances":18}],10:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var h = require('../../lib/helper') + , instances = require('../instances') + , updateGeometry = require('../update-geometry') + , updateScroll = require('../update-scroll'); + +function bindClickRailHandler(element, i) { + function pageOffset(el) { + return el.getBoundingClientRect(); + } + var stopPropagation = window.Event.prototype.stopPropagation.bind; + + if (i.settings.stopPropagationOnClick) { + i.event.bind(i.scrollbarY, 'click', stopPropagation); + } + i.event.bind(i.scrollbarYRail, 'click', function (e) { + var halfOfScrollbarLength = h.toInt(i.scrollbarYHeight / 2); + var positionTop = i.railYRatio * (e.pageY - window.pageYOffset - pageOffset(i.scrollbarYRail).top - halfOfScrollbarLength); + var maxPositionTop = i.railYRatio * (i.railYHeight - i.scrollbarYHeight); + var positionRatio = positionTop / maxPositionTop; + + if (positionRatio < 0) { + positionRatio = 0; + } else if (positionRatio > 1) { + positionRatio = 1; + } + + updateScroll(element, 'top', (i.contentHeight - i.containerHeight) * positionRatio); + updateGeometry(element); + + e.stopPropagation(); + }); + + if (i.settings.stopPropagationOnClick) { + i.event.bind(i.scrollbarX, 'click', stopPropagation); + } + i.event.bind(i.scrollbarXRail, 'click', function (e) { + var halfOfScrollbarLength = h.toInt(i.scrollbarXWidth / 2); + var positionLeft = i.railXRatio * (e.pageX - window.pageXOffset - pageOffset(i.scrollbarXRail).left - halfOfScrollbarLength); + var maxPositionLeft = i.railXRatio * (i.railXWidth - i.scrollbarXWidth); + var positionRatio = positionLeft / maxPositionLeft; + + if (positionRatio < 0) { + positionRatio = 0; + } else if (positionRatio > 1) { + positionRatio = 1; + } + + updateScroll(element, 'left', ((i.contentWidth - i.containerWidth) * positionRatio) - i.negativeScrollAdjustment); + updateGeometry(element); + + e.stopPropagation(); + }); +} + +module.exports = function (element) { + var i = instances.get(element); + bindClickRailHandler(element, i); +}; + +},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var d = require('../../lib/dom') + , h = require('../../lib/helper') + , instances = require('../instances') + , updateGeometry = require('../update-geometry') + , updateScroll = require('../update-scroll'); + +function bindMouseScrollXHandler(element, i) { + var currentLeft = null; + var currentPageX = null; + + function updateScrollLeft(deltaX) { + var newLeft = currentLeft + (deltaX * i.railXRatio); + var maxLeft = Math.max(0, i.scrollbarXRail.getBoundingClientRect().left) + (i.railXRatio * (i.railXWidth - i.scrollbarXWidth)); + + if (newLeft < 0) { + i.scrollbarXLeft = 0; + } else if (newLeft > maxLeft) { + i.scrollbarXLeft = maxLeft; + } else { + i.scrollbarXLeft = newLeft; + } + + var scrollLeft = h.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment; + updateScroll(element, 'left', scrollLeft); + } + + var mouseMoveHandler = function (e) { + updateScrollLeft(e.pageX - currentPageX); + updateGeometry(element); + e.stopPropagation(); + e.preventDefault(); + }; + + var mouseUpHandler = function () { + h.stopScrolling(element, 'x'); + i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); + }; + + i.event.bind(i.scrollbarX, 'mousedown', function (e) { + currentPageX = e.pageX; + currentLeft = h.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio; + h.startScrolling(element, 'x'); + + i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); + i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); + + e.stopPropagation(); + e.preventDefault(); + }); +} + +function bindMouseScrollYHandler(element, i) { + var currentTop = null; + var currentPageY = null; + + function updateScrollTop(deltaY) { + var newTop = currentTop + (deltaY * i.railYRatio); + var maxTop = Math.max(0, i.scrollbarYRail.getBoundingClientRect().top) + (i.railYRatio * (i.railYHeight - i.scrollbarYHeight)); + + if (newTop < 0) { + i.scrollbarYTop = 0; + } else if (newTop > maxTop) { + i.scrollbarYTop = maxTop; + } else { + i.scrollbarYTop = newTop; + } + + var scrollTop = h.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight))); + updateScroll(element, 'top', scrollTop); + } + + var mouseMoveHandler = function (e) { + updateScrollTop(e.pageY - currentPageY); + updateGeometry(element); + e.stopPropagation(); + e.preventDefault(); + }; + + var mouseUpHandler = function () { + h.stopScrolling(element, 'y'); + i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); + }; + + i.event.bind(i.scrollbarY, 'mousedown', function (e) { + currentPageY = e.pageY; + currentTop = h.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio; + h.startScrolling(element, 'y'); + + i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); + i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); + + e.stopPropagation(); + e.preventDefault(); + }); +} + +module.exports = function (element) { + var i = instances.get(element); + bindMouseScrollXHandler(element, i); + bindMouseScrollYHandler(element, i); +}; + +},{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],12:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var h = require('../../lib/helper') + , instances = require('../instances') + , updateGeometry = require('../update-geometry') + , updateScroll = require('../update-scroll'); + +function bindKeyboardHandler(element, i) { + var hovered = false; + i.event.bind(element, 'mouseenter', function () { + hovered = true; + }); + i.event.bind(element, 'mouseleave', function () { + hovered = false; + }); + + var shouldPrevent = false; + function shouldPreventDefault(deltaX, deltaY) { + var scrollTop = element.scrollTop; + if (deltaX === 0) { + if (!i.scrollbarYActive) { + return false; + } + if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) { + return !i.settings.wheelPropagation; + } + } + + var scrollLeft = element.scrollLeft; + if (deltaY === 0) { + if (!i.scrollbarXActive) { + return false; + } + if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) { + return !i.settings.wheelPropagation; + } + } + return true; + } + + i.event.bind(i.ownerDocument, 'keydown', function (e) { + if (e.isDefaultPrevented && e.isDefaultPrevented()) { + return; + } + + if (!hovered) { + return; + } + + var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement; + if (activeElement) { + // go deeper if element is a webcomponent + while (activeElement.shadowRoot) { + activeElement = activeElement.shadowRoot.activeElement; + } + if (h.isEditable(activeElement)) { + return; + } + } + + var deltaX = 0; + var deltaY = 0; + + switch (e.which) { + case 37: // left + deltaX = -30; + break; + case 38: // up + deltaY = 30; + break; + case 39: // right + deltaX = 30; + break; + case 40: // down + deltaY = -30; + break; + case 33: // page up + deltaY = 90; + break; + case 32: // space bar + if (e.shiftKey) { + deltaY = 90; + } else { + deltaY = -90; + } + break; + case 34: // page down + deltaY = -90; + break; + case 35: // end + if (e.ctrlKey) { + deltaY = -i.contentHeight; + } else { + deltaY = -i.containerHeight; + } + break; + case 36: // home + if (e.ctrlKey) { + deltaY = element.scrollTop; + } else { + deltaY = i.containerHeight; + } + break; + default: + return; + } + + updateScroll(element, 'top', element.scrollTop - deltaY); + updateScroll(element, 'left', element.scrollLeft + deltaX); + updateGeometry(element); + + shouldPrevent = shouldPreventDefault(deltaX, deltaY); + if (shouldPrevent) { + e.preventDefault(); + } + }); +} + +module.exports = function (element) { + var i = instances.get(element); + bindKeyboardHandler(element, i); +}; + +},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],13:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var instances = require('../instances') + , updateGeometry = require('../update-geometry') + , updateScroll = require('../update-scroll'); + +function bindMouseWheelHandler(element, i) { + var shouldPrevent = false; + + function shouldPreventDefault(deltaX, deltaY) { + var scrollTop = element.scrollTop; + if (deltaX === 0) { + if (!i.scrollbarYActive) { + return false; + } + if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) { + return !i.settings.wheelPropagation; + } + } + + var scrollLeft = element.scrollLeft; + if (deltaY === 0) { + if (!i.scrollbarXActive) { + return false; + } + if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) { + return !i.settings.wheelPropagation; + } + } + return true; + } + + function getDeltaFromEvent(e) { + var deltaX = e.deltaX; + var deltaY = -1 * e.deltaY; + + if (typeof deltaX === "undefined" || typeof deltaY === "undefined") { + // OS X Safari + deltaX = -1 * e.wheelDeltaX / 6; + deltaY = e.wheelDeltaY / 6; + } + + if (e.deltaMode && e.deltaMode === 1) { + // Firefox in deltaMode 1: Line scrolling + deltaX *= 10; + deltaY *= 10; + } + + if (deltaX !== deltaX && deltaY !== deltaY/* NaN checks */) { + // IE in some mouse drivers + deltaX = 0; + deltaY = e.wheelDelta; + } + + return [deltaX, deltaY]; + } + + function shouldBeConsumedByTextarea(deltaX, deltaY) { + var hoveredTextarea = element.querySelector('textarea:hover'); + if (hoveredTextarea) { + var maxScrollTop = hoveredTextarea.scrollHeight - hoveredTextarea.clientHeight; + if (maxScrollTop > 0) { + if (!(hoveredTextarea.scrollTop === 0 && deltaY > 0) && + !(hoveredTextarea.scrollTop === maxScrollTop && deltaY < 0)) { + return true; + } + } + var maxScrollLeft = hoveredTextarea.scrollLeft - hoveredTextarea.clientWidth; + if (maxScrollLeft > 0) { + if (!(hoveredTextarea.scrollLeft === 0 && deltaX < 0) && + !(hoveredTextarea.scrollLeft === maxScrollLeft && deltaX > 0)) { + return true; + } + } + } + return false; + } + + function mousewheelHandler(e) { + var delta = getDeltaFromEvent(e); + + var deltaX = delta[0]; + var deltaY = delta[1]; + + if (shouldBeConsumedByTextarea(deltaX, deltaY)) { + return; + } + + shouldPrevent = false; + if (!i.settings.useBothWheelAxes) { + // deltaX will only be used for horizontal scrolling and deltaY will + // only be used for vertical scrolling - this is the default + updateScroll(element, 'top', element.scrollTop - (deltaY * i.settings.wheelSpeed)); + updateScroll(element, 'left', element.scrollLeft + (deltaX * i.settings.wheelSpeed)); + } else if (i.scrollbarYActive && !i.scrollbarXActive) { + // only vertical scrollbar is active and useBothWheelAxes option is + // active, so let's scroll vertical bar using both mouse wheel axes + if (deltaY) { + updateScroll(element, 'top', element.scrollTop - (deltaY * i.settings.wheelSpeed)); + } else { + updateScroll(element, 'top', element.scrollTop + (deltaX * i.settings.wheelSpeed)); + } + shouldPrevent = true; + } else if (i.scrollbarXActive && !i.scrollbarYActive) { + // useBothWheelAxes and only horizontal bar is active, so use both + // wheel axes for horizontal bar + if (deltaX) { + updateScroll(element, 'left', element.scrollLeft + (deltaX * i.settings.wheelSpeed)); + } else { + updateScroll(element, 'left', element.scrollLeft - (deltaY * i.settings.wheelSpeed)); + } + shouldPrevent = true; + } + + updateGeometry(element); + + shouldPrevent = (shouldPrevent || shouldPreventDefault(deltaX, deltaY)); + if (shouldPrevent) { + e.stopPropagation(); + e.preventDefault(); + } + } + + if (typeof window.onwheel !== "undefined") { + i.event.bind(element, 'wheel', mousewheelHandler); + } else if (typeof window.onmousewheel !== "undefined") { + i.event.bind(element, 'mousewheel', mousewheelHandler); + } +} + +module.exports = function (element) { + var i = instances.get(element); + bindMouseWheelHandler(element, i); +}; + +},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],14:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var instances = require('../instances') + , updateGeometry = require('../update-geometry'); + +function bindNativeScrollHandler(element, i) { + i.event.bind(element, 'scroll', function () { + updateGeometry(element); + }); +} + +module.exports = function (element) { + var i = instances.get(element); + bindNativeScrollHandler(element, i); +}; + +},{"../instances":18,"../update-geometry":19}],15:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var h = require('../../lib/helper') + , instances = require('../instances') + , updateGeometry = require('../update-geometry') + , updateScroll = require('../update-scroll'); + +function bindSelectionHandler(element, i) { + function getRangeNode() { + var selection = window.getSelection ? window.getSelection() : + document.getSelection ? document.getSelection() : ''; + if (selection.toString().length === 0) { + return null; + } else { + return selection.getRangeAt(0).commonAncestorContainer; + } + } + + var scrollingLoop = null; + var scrollDiff = {top: 0, left: 0}; + function startScrolling() { + if (!scrollingLoop) { + scrollingLoop = setInterval(function () { + if (!instances.get(element)) { + clearInterval(scrollingLoop); + return; + } + + updateScroll(element, 'top', element.scrollTop + scrollDiff.top); + updateScroll(element, 'left', element.scrollLeft + scrollDiff.left); + updateGeometry(element); + }, 50); // every .1 sec + } + } + function stopScrolling() { + if (scrollingLoop) { + clearInterval(scrollingLoop); + scrollingLoop = null; + } + h.stopScrolling(element); + } + + var isSelected = false; + i.event.bind(i.ownerDocument, 'selectionchange', function () { + if (element.contains(getRangeNode())) { + isSelected = true; + } else { + isSelected = false; + stopScrolling(); + } + }); + i.event.bind(window, 'mouseup', function () { + if (isSelected) { + isSelected = false; + stopScrolling(); + } + }); + + i.event.bind(window, 'mousemove', function (e) { + if (isSelected) { + var mousePosition = {x: e.pageX, y: e.pageY}; + var containerGeometry = { + left: element.offsetLeft, + right: element.offsetLeft + element.offsetWidth, + top: element.offsetTop, + bottom: element.offsetTop + element.offsetHeight + }; + + if (mousePosition.x < containerGeometry.left + 3) { + scrollDiff.left = -5; + h.startScrolling(element, 'x'); + } else if (mousePosition.x > containerGeometry.right - 3) { + scrollDiff.left = 5; + h.startScrolling(element, 'x'); + } else { + scrollDiff.left = 0; + } + + if (mousePosition.y < containerGeometry.top + 3) { + if (containerGeometry.top + 3 - mousePosition.y < 5) { + scrollDiff.top = -5; + } else { + scrollDiff.top = -20; + } + h.startScrolling(element, 'y'); + } else if (mousePosition.y > containerGeometry.bottom - 3) { + if (mousePosition.y - containerGeometry.bottom + 3 < 5) { + scrollDiff.top = 5; + } else { + scrollDiff.top = 20; + } + h.startScrolling(element, 'y'); + } else { + scrollDiff.top = 0; + } + + if (scrollDiff.top === 0 && scrollDiff.left === 0) { + stopScrolling(); + } else { + startScrolling(); + } + } + }); +} + +module.exports = function (element) { + var i = instances.get(element); + bindSelectionHandler(element, i); +}; + +},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],16:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var instances = require('../instances') + , updateGeometry = require('../update-geometry') + , updateScroll = require('../update-scroll'); + +function bindTouchHandler(element, i, supportsTouch, supportsIePointer) { + function shouldPreventDefault(deltaX, deltaY) { + var scrollTop = element.scrollTop; + var scrollLeft = element.scrollLeft; + var magnitudeX = Math.abs(deltaX); + var magnitudeY = Math.abs(deltaY); + + if (magnitudeY > magnitudeX) { + // user is perhaps trying to swipe up/down the page + + if (((deltaY < 0) && (scrollTop === i.contentHeight - i.containerHeight)) || + ((deltaY > 0) && (scrollTop === 0))) { + return !i.settings.swipePropagation; + } + } else if (magnitudeX > magnitudeY) { + // user is perhaps trying to swipe left/right across the page + + if (((deltaX < 0) && (scrollLeft === i.contentWidth - i.containerWidth)) || + ((deltaX > 0) && (scrollLeft === 0))) { + return !i.settings.swipePropagation; + } + } + + return true; + } + + function applyTouchMove(differenceX, differenceY) { + updateScroll(element, 'top', element.scrollTop - differenceY); + updateScroll(element, 'left', element.scrollLeft - differenceX); + + updateGeometry(element); + } + + var startOffset = {}; + var startTime = 0; + var speed = {}; + var easingLoop = null; + var inGlobalTouch = false; + var inLocalTouch = false; + + function globalTouchStart() { + inGlobalTouch = true; + } + function globalTouchEnd() { + inGlobalTouch = false; + } + + function getTouch(e) { + if (e.targetTouches) { + return e.targetTouches[0]; + } else { + // Maybe IE pointer + return e; + } + } + function shouldHandle(e) { + if (e.targetTouches && e.targetTouches.length === 1) { + return true; + } + if (e.pointerType && e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) { + return true; + } + return false; + } + function touchStart(e) { + if (shouldHandle(e)) { + inLocalTouch = true; + + var touch = getTouch(e); + + startOffset.pageX = touch.pageX; + startOffset.pageY = touch.pageY; + + startTime = (new Date()).getTime(); + + if (easingLoop !== null) { + clearInterval(easingLoop); + } + + e.stopPropagation(); + } + } + function touchMove(e) { + if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) { + var touch = getTouch(e); + + var currentOffset = {pageX: touch.pageX, pageY: touch.pageY}; + + var differenceX = currentOffset.pageX - startOffset.pageX; + var differenceY = currentOffset.pageY - startOffset.pageY; + + applyTouchMove(differenceX, differenceY); + startOffset = currentOffset; + + var currentTime = (new Date()).getTime(); + + var timeGap = currentTime - startTime; + if (timeGap > 0) { + speed.x = differenceX / timeGap; + speed.y = differenceY / timeGap; + startTime = currentTime; + } + + if (shouldPreventDefault(differenceX, differenceY)) { + e.stopPropagation(); + e.preventDefault(); + } + } + } + function touchEnd() { + if (!inGlobalTouch && inLocalTouch) { + inLocalTouch = false; + + clearInterval(easingLoop); + easingLoop = setInterval(function () { + if (!instances.get(element)) { + clearInterval(easingLoop); + return; + } + + if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) { + clearInterval(easingLoop); + return; + } + + applyTouchMove(speed.x * 30, speed.y * 30); + + speed.x *= 0.8; + speed.y *= 0.8; + }, 10); + } + } + + if (supportsTouch) { + i.event.bind(window, 'touchstart', globalTouchStart); + i.event.bind(window, 'touchend', globalTouchEnd); + i.event.bind(element, 'touchstart', touchStart); + i.event.bind(element, 'touchmove', touchMove); + i.event.bind(element, 'touchend', touchEnd); + } + + if (supportsIePointer) { + if (window.PointerEvent) { + i.event.bind(window, 'pointerdown', globalTouchStart); + i.event.bind(window, 'pointerup', globalTouchEnd); + i.event.bind(element, 'pointerdown', touchStart); + i.event.bind(element, 'pointermove', touchMove); + i.event.bind(element, 'pointerup', touchEnd); + } else if (window.MSPointerEvent) { + i.event.bind(window, 'MSPointerDown', globalTouchStart); + i.event.bind(window, 'MSPointerUp', globalTouchEnd); + i.event.bind(element, 'MSPointerDown', touchStart); + i.event.bind(element, 'MSPointerMove', touchMove); + i.event.bind(element, 'MSPointerUp', touchEnd); + } + } +} + +module.exports = function (element, supportsTouch, supportsIePointer) { + var i = instances.get(element); + bindTouchHandler(element, i, supportsTouch, supportsIePointer); +}; + +},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var cls = require('../lib/class') + , h = require('../lib/helper') + , instances = require('./instances') + , updateGeometry = require('./update-geometry'); + +// Handlers +var clickRailHandler = require('./handler/click-rail') + , dragScrollbarHandler = require('./handler/drag-scrollbar') + , keyboardHandler = require('./handler/keyboard') + , mouseWheelHandler = require('./handler/mouse-wheel') + , nativeScrollHandler = require('./handler/native-scroll') + , selectionHandler = require('./handler/selection') + , touchHandler = require('./handler/touch'); + +module.exports = function (element, userSettings) { + userSettings = typeof userSettings === 'object' ? userSettings : {}; + + cls.add(element, 'ps-container'); + + // Create a plugin instance. + var i = instances.add(element); + + i.settings = h.extend(i.settings, userSettings); + + clickRailHandler(element); + dragScrollbarHandler(element); + mouseWheelHandler(element); + nativeScrollHandler(element); + + if (i.settings.useSelectionScroll) { + selectionHandler(element); + } + + if (h.env.supportsTouch || h.env.supportsIePointer) { + touchHandler(element, h.env.supportsTouch, h.env.supportsIePointer); + } + if (i.settings.useKeyboard) { + keyboardHandler(element); + } + + updateGeometry(element); +}; + +},{"../lib/class":2,"../lib/helper":6,"./handler/click-rail":10,"./handler/drag-scrollbar":11,"./handler/keyboard":12,"./handler/mouse-wheel":13,"./handler/native-scroll":14,"./handler/selection":15,"./handler/touch":16,"./instances":18,"./update-geometry":19}],18:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var d = require('../lib/dom') + , defaultSettings = require('./default-setting') + , EventManager = require('../lib/event-manager') + , guid = require('../lib/guid') + , h = require('../lib/helper'); + +var instances = {}; + +function Instance(element) { + var i = this; + + i.settings = h.clone(defaultSettings); + i.containerWidth = null; + i.containerHeight = null; + i.contentWidth = null; + i.contentHeight = null; + + i.isRtl = d.css(element, 'direction') === "rtl"; + i.isNegativeScroll = (function () { + var originalScrollLeft = element.scrollLeft; + var result = null; + element.scrollLeft = -1; + result = element.scrollLeft < 0; + element.scrollLeft = originalScrollLeft; + return result; + })(); + i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0; + i.event = new EventManager(); + i.ownerDocument = element.ownerDocument || document; + + i.scrollbarXRail = d.appendTo(d.e('div', 'ps-scrollbar-x-rail'), element); + i.scrollbarX = d.appendTo(d.e('div', 'ps-scrollbar-x'), i.scrollbarXRail); + i.scrollbarX.setAttribute('tabindex', 0); + i.scrollbarXActive = null; + i.scrollbarXWidth = null; + i.scrollbarXLeft = null; + i.scrollbarXBottom = h.toInt(d.css(i.scrollbarXRail, 'bottom')); + i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN + i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : h.toInt(d.css(i.scrollbarXRail, 'top')); + i.railBorderXWidth = h.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + h.toInt(d.css(i.scrollbarXRail, 'borderRightWidth')); + // Set rail to display:block to calculate margins + d.css(i.scrollbarXRail, 'display', 'block'); + i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight')); + d.css(i.scrollbarXRail, 'display', ''); + i.railXWidth = null; + i.railXRatio = null; + + i.scrollbarYRail = d.appendTo(d.e('div', 'ps-scrollbar-y-rail'), element); + i.scrollbarY = d.appendTo(d.e('div', 'ps-scrollbar-y'), i.scrollbarYRail); + i.scrollbarY.setAttribute('tabindex', 0); + i.scrollbarYActive = null; + i.scrollbarYHeight = null; + i.scrollbarYTop = null; + i.scrollbarYRight = h.toInt(d.css(i.scrollbarYRail, 'right')); + i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN + i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : h.toInt(d.css(i.scrollbarYRail, 'left')); + i.scrollbarYOuterWidth = i.isRtl ? h.outerWidth(i.scrollbarY) : null; + i.railBorderYWidth = h.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + h.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth')); + d.css(i.scrollbarYRail, 'display', 'block'); + i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom')); + d.css(i.scrollbarYRail, 'display', ''); + i.railYHeight = null; + i.railYRatio = null; +} + +function getId(element) { + if (typeof element.dataset === 'undefined') { + return element.getAttribute('data-ps-id'); + } else { + return element.dataset.psId; + } +} + +function setId(element, id) { + if (typeof element.dataset === 'undefined') { + element.setAttribute('data-ps-id', id); + } else { + element.dataset.psId = id; + } +} + +function removeId(element) { + if (typeof element.dataset === 'undefined') { + element.removeAttribute('data-ps-id'); + } else { + delete element.dataset.psId; + } +} + +exports.add = function (element) { + var newId = guid(); + setId(element, newId); + instances[newId] = new Instance(element); + return instances[newId]; +}; + +exports.remove = function (element) { + delete instances[getId(element)]; + removeId(element); +}; + +exports.get = function (element) { + return instances[getId(element)]; +}; + +},{"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var cls = require('../lib/class') + , d = require('../lib/dom') + , h = require('../lib/helper') + , instances = require('./instances') + , updateScroll = require('./update-scroll'); + +function getThumbSize(i, thumbSize) { + if (i.settings.minScrollbarLength) { + thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength); + } + if (i.settings.maxScrollbarLength) { + thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength); + } + return thumbSize; +} + +function updateCss(element, i) { + var xRailOffset = {width: i.railXWidth}; + if (i.isRtl) { + xRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth - i.contentWidth; + } else { + xRailOffset.left = element.scrollLeft; + } + if (i.isScrollbarXUsingBottom) { + xRailOffset.bottom = i.scrollbarXBottom - element.scrollTop; + } else { + xRailOffset.top = i.scrollbarXTop + element.scrollTop; + } + d.css(i.scrollbarXRail, xRailOffset); + + var yRailOffset = {top: element.scrollTop, height: i.railYHeight}; + if (i.isScrollbarYUsingRight) { + if (i.isRtl) { + yRailOffset.right = i.contentWidth - (i.negativeScrollAdjustment + element.scrollLeft) - i.scrollbarYRight - i.scrollbarYOuterWidth; + } else { + yRailOffset.right = i.scrollbarYRight - element.scrollLeft; + } + } else { + if (i.isRtl) { + yRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth * 2 - i.contentWidth - i.scrollbarYLeft - i.scrollbarYOuterWidth; + } else { + yRailOffset.left = i.scrollbarYLeft + element.scrollLeft; + } + } + d.css(i.scrollbarYRail, yRailOffset); + + d.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth}); + d.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth}); +} + +module.exports = function (element) { + var i = instances.get(element); + + i.containerWidth = element.clientWidth; + i.containerHeight = element.clientHeight; + i.contentWidth = element.scrollWidth; + i.contentHeight = element.scrollHeight; + + var existingRails; + if (!element.contains(i.scrollbarXRail)) { + existingRails = d.queryChildren(element, '.ps-scrollbar-x-rail'); + if (existingRails.length > 0) { + existingRails.forEach(function (rail) { + d.remove(rail); + }); + } + d.appendTo(i.scrollbarXRail, element); + } + if (!element.contains(i.scrollbarYRail)) { + existingRails = d.queryChildren(element, '.ps-scrollbar-y-rail'); + if (existingRails.length > 0) { + existingRails.forEach(function (rail) { + d.remove(rail); + }); + } + d.appendTo(i.scrollbarYRail, element); + } + + if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) { + i.scrollbarXActive = true; + i.railXWidth = i.containerWidth - i.railXMarginWidth; + i.railXRatio = i.containerWidth / i.railXWidth; + i.scrollbarXWidth = getThumbSize(i, h.toInt(i.railXWidth * i.containerWidth / i.contentWidth)); + i.scrollbarXLeft = h.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth)); + } else { + i.scrollbarXActive = false; + } + + if (!i.settings.suppressScrollY && i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight) { + i.scrollbarYActive = true; + i.railYHeight = i.containerHeight - i.railYMarginHeight; + i.railYRatio = i.containerHeight / i.railYHeight; + i.scrollbarYHeight = getThumbSize(i, h.toInt(i.railYHeight * i.containerHeight / i.contentHeight)); + i.scrollbarYTop = h.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight)); + } else { + i.scrollbarYActive = false; + } + + if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) { + i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth; + } + if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) { + i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight; + } + + updateCss(element, i); + + if (i.scrollbarXActive) { + cls.add(element, 'ps-active-x'); + } else { + cls.remove(element, 'ps-active-x'); + i.scrollbarXWidth = 0; + i.scrollbarXLeft = 0; + updateScroll(element, 'left', 0); + } + if (i.scrollbarYActive) { + cls.add(element, 'ps-active-y'); + } else { + cls.remove(element, 'ps-active-y'); + i.scrollbarYHeight = 0; + i.scrollbarYTop = 0; + updateScroll(element, 'top', 0); + } +}; + +},{"../lib/class":2,"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-scroll":20}],20:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var instances = require('./instances'); + +var upEvent = document.createEvent('Event') + , downEvent = document.createEvent('Event') + , leftEvent = document.createEvent('Event') + , rightEvent = document.createEvent('Event') + , yEvent = document.createEvent('Event') + , xEvent = document.createEvent('Event') + , xStartEvent = document.createEvent('Event') + , xEndEvent = document.createEvent('Event') + , yStartEvent = document.createEvent('Event') + , yEndEvent = document.createEvent('Event') + , lastTop + , lastLeft; + +upEvent.initEvent('ps-scroll-up', true, true); +downEvent.initEvent('ps-scroll-down', true, true); +leftEvent.initEvent('ps-scroll-left', true, true); +rightEvent.initEvent('ps-scroll-right', true, true); +yEvent.initEvent('ps-scroll-y', true, true); +xEvent.initEvent('ps-scroll-x', true, true); +xStartEvent.initEvent('ps-x-reach-start', true, true); +xEndEvent.initEvent('ps-x-reach-end', true, true); +yStartEvent.initEvent('ps-y-reach-start', true, true); +yEndEvent.initEvent('ps-y-reach-end', true, true); + +module.exports = function (element, axis, value) { + if (typeof element === 'undefined') { + throw 'You must provide an element to the update-scroll function'; + } + + if (typeof axis === 'undefined') { + throw 'You must provide an axis to the update-scroll function'; + } + + if (typeof value === 'undefined') { + throw 'You must provide a value to the update-scroll function'; + } + + if (axis === 'top' && value <= 0) { + element.scrollTop = 0; + element.dispatchEvent(yStartEvent); + return; // don't allow negative scroll + } + + if (axis === 'left' && value <= 0) { + element.scrollLeft = 0; + element.dispatchEvent(xStartEvent); + return; // don't allow negative scroll + } + + var i = instances.get(element); + + if (axis === 'top' && value >= i.contentHeight - i.containerHeight) { + element.scrollTop = i.contentHeight - i.containerHeight; + element.dispatchEvent(yEndEvent); + return; // don't allow scroll past container + } + + if (axis === 'left' && value >= i.contentWidth - i.containerWidth) { + element.scrollLeft = i.contentWidth - i.containerWidth; + element.dispatchEvent(xEndEvent); + return; // don't allow scroll past container + } + + if (!lastTop) { + lastTop = element.scrollTop; + } + + if (!lastLeft) { + lastLeft = element.scrollLeft; + } + + if (axis === 'top' && value < lastTop) { + element.dispatchEvent(upEvent); + } + + if (axis === 'top' && value > lastTop) { + element.dispatchEvent(downEvent); + } + + if (axis === 'left' && value < lastLeft) { + element.dispatchEvent(leftEvent); + } + + if (axis === 'left' && value > lastLeft) { + element.dispatchEvent(rightEvent); + } + + if (axis === 'top') { + element.scrollTop = lastTop = value; + element.dispatchEvent(yEvent); + } + + if (axis === 'left') { + element.scrollLeft = lastLeft = value; + element.dispatchEvent(xEvent); + } + +}; + +},{"./instances":18}],21:[function(require,module,exports){ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var d = require('../lib/dom') + , h = require('../lib/helper') + , instances = require('./instances') + , updateGeometry = require('./update-geometry') + , updateScroll = require('./update-scroll'); + +module.exports = function (element) { + var i = instances.get(element); + + if (!i) { + return; + } + + // Recalcuate negative scrollLeft adjustment + i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0; + + // Recalculate rail margins + d.css(i.scrollbarXRail, 'display', 'block'); + d.css(i.scrollbarYRail, 'display', 'block'); + i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight')); + i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom')); + + // Hide scrollbars not to affect scrollWidth and scrollHeight + d.css(i.scrollbarXRail, 'display', 'none'); + d.css(i.scrollbarYRail, 'display', 'none'); + + updateGeometry(element); + + // Update top/left scroll to trigger events + updateScroll(element, 'top', element.scrollTop); + updateScroll(element, 'left', element.scrollLeft); + + d.css(i.scrollbarXRail, 'display', ''); + d.css(i.scrollbarYRail, 'display', ''); +}; + +},{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19,"./update-scroll":20}]},{},[1]); diff --git a/library/perfect-scrollbar/perfect-scrollbar.min.css b/library/perfect-scrollbar/perfect-scrollbar.min.css new file mode 100644 index 0000000000..288671cfcc --- /dev/null +++ b/library/perfect-scrollbar/perfect-scrollbar.min.css @@ -0,0 +1,2 @@ +/* perfect-scrollbar v0.6.8 */ +.ps-container{-ms-touch-action:none;overflow:hidden !important}.ps-container.ps-active-x>.ps-scrollbar-x-rail,.ps-container.ps-active-y>.ps-scrollbar-y-rail{display:block}.ps-container.ps-in-scrolling{pointer-events:none}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container>.ps-scrollbar-x-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color 0.2s linear,opacity 0.2s linear;-moz-transition:background-color 0.2s linear,opacity 0.2s linear;-o-transition:background-color 0.2s linear,opacity 0.2s linear;transition:background-color 0.2s linear,opacity 0.2s linear;bottom:3px;height:8px}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;-webkit-transition:background-color 0.2s linear;-moz-transition:background-color 0.2s linear;-o-transition:background-color 0.2s linear;transition:background-color 0.2s linear;bottom:0;height:8px}.ps-container>.ps-scrollbar-y-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color 0.2s linear,opacity 0.2s linear;-moz-transition:background-color 0.2s linear,opacity 0.2s linear;-o-transition:background-color 0.2s linear,opacity 0.2s linear;transition:background-color 0.2s linear,opacity 0.2s linear;right:3px;width:8px}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;-webkit-transition:background-color 0.2s linear;-moz-transition:background-color 0.2s linear;-o-transition:background-color 0.2s linear;transition:background-color 0.2s linear;right:0;width:8px}.ps-container:hover.ps-in-scrolling{pointer-events:none}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container:hover>.ps-scrollbar-x-rail,.ps-container:hover>.ps-scrollbar-y-rail{opacity:0.6}.ps-container:hover>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container:hover>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999} diff --git a/view/templates/head.tpl b/view/templates/head.tpl index f2f2d3487a..17c459c4d8 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -6,6 +6,7 @@ + @@ -37,6 +38,7 @@ + From f8256fc53b9188aa6da51fcb9800a85e39ac3409 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 30 Dec 2015 03:12:52 +0100 Subject: [PATCH 2/4] make perfect scrollbars work with quattro --- js/main.js | 1 + view/theme/quattro/dark/style.css | 5 ----- view/theme/quattro/green/style.css | 5 ----- view/theme/quattro/lilac/style.css | 5 ----- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/js/main.js b/js/main.js index c27d743bc4..3a77fdd802 100644 --- a/js/main.js +++ b/js/main.js @@ -147,6 +147,7 @@ } else { last_popup_menu = menu; last_popup_button = parent; + $('#nav-notifications-menu').perfectScrollbar('update'); } return false; }); diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 1b021687cd..a45584a700 100644 --- a/view/theme/quattro/dark/style.css +++ b/view/theme/quattro/dark/style.css @@ -544,7 +544,6 @@ header { margin: 0; padding: 0; /*width: 100%; height: 12px; */ - z-index: 110; color: #ffffff; } @@ -922,7 +921,6 @@ aside .posted-date-selector-months { overflow: auto; height: auto; /*.contact-block-div { width:60px; height: 60px; }*/ - } #contact-block .contact-block-h4 { float: left; @@ -1004,7 +1002,6 @@ aside .posted-date-selector-months { margin-bottom: 2em; /*.action .s10 { width: 10px; overflow: hidden; padding: 0;} .action .s16 { width: 16px; overflow: hidden; padding: 0;}*/ - } .widget h3 { padding: 0; @@ -1308,7 +1305,6 @@ section { height: 32px; margin-left: 16px; /*background: url(../../../images/icons/22/user.png) no-repeat center center;*/ - } .comment-edit-preview .contact-photo-menu-button { top: 15px !important; @@ -2241,7 +2237,6 @@ ul.tabs li .active { min-height: 22px; padding-top: 6px; /* a { display: block;}*/ - } #photo-caption { display: block; diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index 4c50fb35fa..e3463e289d 100644 --- a/view/theme/quattro/green/style.css +++ b/view/theme/quattro/green/style.css @@ -544,7 +544,6 @@ header { margin: 0; padding: 0; /*width: 100%; height: 12px; */ - z-index: 110; color: #ffffff; } @@ -922,7 +921,6 @@ aside .posted-date-selector-months { overflow: auto; height: auto; /*.contact-block-div { width:60px; height: 60px; }*/ - } #contact-block .contact-block-h4 { float: left; @@ -1004,7 +1002,6 @@ aside .posted-date-selector-months { margin-bottom: 2em; /*.action .s10 { width: 10px; overflow: hidden; padding: 0;} .action .s16 { width: 16px; overflow: hidden; padding: 0;}*/ - } .widget h3 { padding: 0; @@ -1308,7 +1305,6 @@ section { height: 32px; margin-left: 16px; /*background: url(../../../images/icons/22/user.png) no-repeat center center;*/ - } .comment-edit-preview .contact-photo-menu-button { top: 15px !important; @@ -2241,7 +2237,6 @@ ul.tabs li .active { min-height: 22px; padding-top: 6px; /* a { display: block;}*/ - } #photo-caption { display: block; diff --git a/view/theme/quattro/lilac/style.css b/view/theme/quattro/lilac/style.css index 7fb505dec5..750b3b995c 100644 --- a/view/theme/quattro/lilac/style.css +++ b/view/theme/quattro/lilac/style.css @@ -544,7 +544,6 @@ header { margin: 0; padding: 0; /*width: 100%; height: 12px; */ - z-index: 110; color: #ffffff; } @@ -922,7 +921,6 @@ aside .posted-date-selector-months { overflow: auto; height: auto; /*.contact-block-div { width:60px; height: 60px; }*/ - } #contact-block .contact-block-h4 { float: left; @@ -1004,7 +1002,6 @@ aside .posted-date-selector-months { margin-bottom: 2em; /*.action .s10 { width: 10px; overflow: hidden; padding: 0;} .action .s16 { width: 16px; overflow: hidden; padding: 0;}*/ - } .widget h3 { padding: 0; @@ -1308,7 +1305,6 @@ section { height: 32px; margin-left: 16px; /*background: url(../../../images/icons/22/user.png) no-repeat center center;*/ - } .comment-edit-preview .contact-photo-menu-button { top: 15px !important; @@ -2241,7 +2237,6 @@ ul.tabs li .active { min-height: 22px; padding-top: 6px; /* a { display: block;}*/ - } #photo-caption { display: block; From 8a51e470e73c8159a56cf9c2785346a552e887e1 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 30 Dec 2015 14:22:13 +0100 Subject: [PATCH 3/4] perfect scrollbars: added README --- library/perfect-scrollbar/README.md | 405 ++++++++++++++++++++++++++++ 1 file changed, 405 insertions(+) create mode 100644 library/perfect-scrollbar/README.md diff --git a/library/perfect-scrollbar/README.md b/library/perfect-scrollbar/README.md new file mode 100644 index 0000000000..b0e732827d --- /dev/null +++ b/library/perfect-scrollbar/README.md @@ -0,0 +1,405 @@ +# `perfect-scrollbar` + +Minimalistic but perfect custom scrollbar plugin + +[![Travis CI](https://travis-ci.org/noraesae/perfect-scrollbar.svg?branch=master)](https://travis-ci.org/noraesae/perfect-scrollbar) + +If you want information of old versions<0.6.0, please refer to +[an old documentation](https://github.com/noraesae/perfect-scrollbar/tree/0.5.9). + +## Why perfect-scrollbar? + +I was once working on a personal project, and trying to find the jQuery +scrollbar plugin that's *perfect*. But there was no *perfect* one. +That's why I decided to make one. + +perfect-scrollbar is minimalistic but *perfect* (for me, and maybe for most developers) +scrollbar plugin working with jQuery or vanilla JavaScript as well. + +I hope you love it! + +## [Demo](http://noraesae.github.com/perfect-scrollbar/) + +[It's on the GitHub Pages](http://noraesae.github.com/perfect-scrollbar/). + +## What does *perfect* mean? + +*perfect* means... + +* There should be no css change on any original element. +* The scrollbar should not affect the original design layout. +* The design of the scrollbar should be (nearly) fully customizable. +* If the size of the container or the content changes, the scrollbar + size and position should be able to change. +* *New!* It should work with vanilla JavaScript and major tools like + NPM or Browserify. + +## Then perfect-scrollbar is really *perfect*? + +* perfect-scrollbar has some requirements, but doesn't change or add + any style on original elements. +* perfect-scrollbar is designed not to have width or height. It's fixed + on the right and bottom side of the container. +* You can change nearly all css styles of the scrollbar. The scrollbar + design has no dependency on scripts. +* perfect-scrollbar supports an 'update' function. Whenever you need + to update the size or position of the scrollbar, just update. +* Additionally, perfect-scrollbar uses 'scrollTop' and 'scrollLeft', + not absolute positioning or something messy. +* perfect-scrollbar supports RTL perfectly on both WebKit and Gecko based browsers. + +It's cool, isn't it? + +## Install + +The best way to install and use perfect-scrollbar is with NPM. +It's registered on [npm](https://www.npmjs.org/package/perfect-scrollbar) as `perfect-scrollbar`. + +``` +$ npm install perfect-scrollbar +``` + +You can download the latest stable version with download links [here](http://noraesae.github.io/perfect-scrollbar/). +You also can find all releases on [Releases](https://github.com/noraesae/perfect-scrollbar/releases). + +If you want to use the development version of the plugin, use the +source files which are not minified. They're in the `src` directory. +The development version may be unstable, but some known bugs may +have been fixed. + +``` +$ git clone https://github.com/noraesae/perfect-scrollbar.git +$ cd perfect-scrollbar/src +$ npm install +$ gulp # will lint and build the source code. +``` + + +There is a Bower package for perfect-scrollbar as well. It is managed +under the [perfect-scrollbar-bower](https://github.com/noraesae/perfect-scrollbar-bower) +repository. The plugin is registered as `perfect-scrollbar`. + +``` +$ bower install perfect-scrollbar +``` + + +You can also load it from [cdnjs](http://cdnjs.com/). +It is registered as [`jquery.perfect-scrollbar`](http://www.cdnjs.com/libraries/jquery.perfect-scrollbar). + +## Requirements + +To make this plugin *perfect*, some requirements were unavoidable. +But, they're all very trivial and there is nothing to worry about. + +The following requirements should meet. + +* the container must have a 'position' css style. + +The following requirements are included in the basic CSS, but please +keep in mind when you'd like to change the CSS files. + +* the container must have an 'overflow:hidden' css style. +* the scrollbar's position must be 'absolute'. +* the scrollbar-x must have a 'bottom' css style, and the scrollbar-y + must have a 'right' css style. + +## How to use + +First of all, please check if the container element meets the +requirements. + +```html + + +``` + +I would recommend using the plugin with NPM and CommonJS module system +like Browserify. + +```javascript +var Ps = require('perfect-scrollbar'); +``` + +Or you can just load the script file as usual. + +```html + +``` + +To initialise the plugin, `Ps.initialize` is used. + +```javascript +var container = document.getElementById('container'); +Ps.initialize(container); +``` + +It can be initialised with optional parameters. + +```javascript +Ps.initialize(container, { + wheelSpeed: 2, + wheelPropagation: true, + minScrollbarLength: 20 +}); +``` + +If the size of your container or content changes, call `update`. + +```javascript +Ps.update(container); +``` + +If you want to destory the scrollbar, use `destroy`. + +```javascript +Ps.destroy(container); +``` + +If you want to scroll to somewhere, just use a `scrollTop` +property and update. + +```javascript +container.scrollTop = 0; +Ps.update(container); +``` + +You can also get information about how to use the plugin +from code in the `examples` directory of the source tree. + +## jQuery + +As you may already know, perfect-scrollbar was a jQuery plugin. +And it *is* as well. There's a jQuery adaptor and the plugin can +be used in the same way it used to be used before. + +I also recommend using NPM and CommonJS here, but it's not mandatory. + +```javascript +var $ = require('jquery'); +require('perfect-scrollbar/jquery')($); +``` + +For sure, you can just import a built script. + +```html + +``` + +After importing it, you can use the plugin in the usual way. + +```javascript +$('#container').perfectScrollbar(); // Initialize +$('#container').perfectScrollbar({ ... }); // with options +$('#container').perfectScrollbar('update'); // Update +$('#container').perfectScrollbar('destroy'); // Destroy +``` + +## RequireJS usage + +For RequireJS loader, no need to write shim, simply import two libs: + +```javascript +require.config({ + paths: { + perfectScrollbarJQuery: '.../perfect-scrollbar.jquery', + perfectScrollbar: '.../perfect-scrollbar', + } + ... +}) +``` + + +and load `perfectScrollbar` in the initialiser of your app: + +```javascript +// for vanilla JS: +window.Ps = require('perfectScrollbar'); + +// for jQuery: +require('perfectScrollbarJQuery'); +``` + + +## AngularJS + RequireJS usage + +With the require.config settings above, at the beginning of your app module +definition, you can have following code: + +```javascript +define([ + 'angular', + 'perfectScrollbar', + 'perfectScrollbarJquery' +], +function (angular) { + var myApp = angular.module('myApp', []) + .run(function() { + window.Ps = require('perfectScrollbar'); + require('perfectScrollbarJQuery'); + }) + return myApp; +}); +``` + +And initialise perfectScrollbar in a controller: + +```javascript +// by vanilla JS: +var container = document.getElementById('imgLoader'); +Ps.initialize(container); +Ps.update(container); + +// or by jQuery: +var imgLoader = $("#imgLoader") +imgLoader.perfectScrollbar(); +``` + +## Optional parameters + +perfect-scrollbar supports optional parameters. + +### wheelSpeed +The scroll speed applied to mousewheel event. +**Default: 1** + +### wheelPropagation +If this option is true, when the scroll reaches the end of the side, mousewheel event will be propagated to parent element. +**Default: false** + +### swipePropagation +If this option is true, when the scroll reaches the end of the side, touch scrolling will be propagated to parent element. +**Default: true** + +### minScrollbarLength +When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels. +**Default: null** + +### maxScrollbarLength +When set to an integer value, the thumb part of the scrollbar will not expand over that number of pixels. +**Default: null** + +### useBothWheelAxes +When set to true, and only one (vertical or horizontal) scrollbar is visible then both vertical and horizontal scrolling will affect the scrollbar. +**Default: false** + +### useKeyboard +When set to true, the scroll works with arrow keys on the keyboard. The element is scrolled only when the mouse cursor hovers the element. +**Default: true** + +### suppressScrollX +When set to true, the scroll bar in X axis will not be available, regardless of the content width. +**Default: false** + +### suppressScrollY +When set to true, the scroll bar in Y axis will not be available, regardless of the content height. +**Default: false** + +### scrollXMarginOffset +The number of pixels the content width can surpass the container width without enabling the X axis scroll bar. Allows some "wiggle room" or "offset break", so that X axis scroll bar is not enabled just because of a few pixels. +**Default: 0** + +### scrollYMarginOffset +The number of pixels the content height can surpass the container height without enabling the Y axis scroll bar. Allows some "wiggle room" or "offset break", so that Y axis scroll bar is not enabled just because of a few pixels. +**Default: 0** + +### stopPropagationOnClick +When set to false, when clicking on a rail, the click event will be allowed to propagate. +**Default: true** + +### useSelectionScroll +When set to true, you can scroll the container by selecting text and move the cursor. +**Default: false** + +## Events + +perfect-scrollbar dispatches custom events. + +### ps-scroll-y +This event fires when the y-axis is scrolled in either direction. + +### ps-scroll-x +This event fires when the x-axis is scrolled in either direction. + +### ps-scroll-up +This event fires when scrolling upwards. + +### ps-scroll-down +This event fires when scrolling downwards. + +### ps-scroll-left +This event fires when scrolling to the left. + +### ps-scroll-right +This event fires when scrolling to the right. + +### ps-y-reach-start +This event fires when scrolling reaches the start of the y-axis. + +### ps-y-reach-end +This event fires when scrolling reaches the end of the y-axis (useful for infinite scroll). + +### ps-x-reach-start +This event fires when scrolling reaches the start of the x-axis. + +### ps-x-reach-end +This event fires when scrolling reaches the end of the x-axis. + +You can listen to these events either with vanilla JavaScript +```javascript +document.addEventListener('ps-scroll-x', function () { + // ... +}) +``` +or with jQuery +```javascript +$(document).on('ps-scroll-x', function () { + // ... +}) +``` + +## Contribution + +#### Please read [Contributing](https://github.com/noraesae/perfect-scrollbar/wiki/Contributing) in the wiki before making any contribution. + + +I *really* welcome contributions! Please feel free to fork and issue pull requests when... + +* You have a very nice idea to improve this plugin! +* You found a bug! +* You're good at English and can help my bad English! + +For IE problems, please refer to [IE Support](https://github.com/noraesae/perfect-scrollbar#ie-support). + +## IE Support + +The plugin would work in IEs >= IE9 (not well, though). + +**The patches to fix problems in IE<=8 won't be accepted.** + +When old IEs should be supported, please fork the project and +make patches personally. + +## Helpdesk + +If you have any idea to improve this project or any problem +using this, please feel free to upload an +[issue](https://github.com/noraesae/perfect-scrollbar/issues). + +For common problems there is a +[FAQ](https://github.com/noraesae/perfect-scrollbar/wiki/FAQ) wiki page. Please check the page before uploading an issue. + +## License + +The MIT License (MIT) Copyright (c) 2015 Hyunje Alex Jun and other contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 77a230342f3dd23be721580554979f80732f35e4 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 30 Dec 2015 16:26:57 +0100 Subject: [PATCH 4/4] perfect-scrollbar: added Source link to the lib --- library/perfect-scrollbar/perfect-scrollbar.jquery.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/perfect-scrollbar/perfect-scrollbar.jquery.js b/library/perfect-scrollbar/perfect-scrollbar.jquery.js index e872d8f30b..2bc3b2f939 100644 --- a/library/perfect-scrollbar/perfect-scrollbar.jquery.js +++ b/library/perfect-scrollbar/perfect-scrollbar.jquery.js @@ -2,6 +2,8 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o