diff --git a/src/js/lib/helper.js b/src/js/lib/helper.js index ea2d748..69e0c10 100644 --- a/src/js/lib/helper.js +++ b/src/js/lib/helper.js @@ -1,7 +1,7 @@ 'use strict'; var cls = require('./class') - , d = require('./dom'); + , dom = require('./dom'); var toInt = exports.toInt = function (x) { return parseInt(x, 10) || 0; @@ -32,10 +32,10 @@ exports.extend = function (original, source) { }; 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]"); + return dom.matches(el, "input,[contenteditable]") || + dom.matches(el, "select,[contenteditable]") || + dom.matches(el, "textarea,[contenteditable]") || + dom.matches(el, "button,[contenteditable]"); }; exports.removePsClasses = function (element) { @@ -49,11 +49,11 @@ exports.removePsClasses = function (element) { }; exports.outerWidth = function (element) { - return toInt(d.css(element, 'width')) + - toInt(d.css(element, 'paddingLeft')) + - toInt(d.css(element, 'paddingRight')) + - toInt(d.css(element, 'borderLeftWidth')) + - toInt(d.css(element, 'borderRightWidth')); + return toInt(dom.css(element, 'width')) + + toInt(dom.css(element, 'paddingLeft')) + + toInt(dom.css(element, 'paddingRight')) + + toInt(dom.css(element, 'borderLeftWidth')) + + toInt(dom.css(element, 'borderRightWidth')); }; exports.startScrolling = function (element, axis) { diff --git a/src/js/plugin/destroy.js b/src/js/plugin/destroy.js index 21dbc3d..9c03d06 100644 --- a/src/js/plugin/destroy.js +++ b/src/js/plugin/destroy.js @@ -1,6 +1,6 @@ 'use strict'; -var d = require('../lib/dom') +var dom = require('../lib/dom') , _ = require('../lib/helper') , instances = require('./instances'); @@ -12,10 +12,10 @@ module.exports = function (element) { } i.event.unbindAll(); - d.remove(i.scrollbarX); - d.remove(i.scrollbarY); - d.remove(i.scrollbarXRail); - d.remove(i.scrollbarYRail); + dom.remove(i.scrollbarX); + dom.remove(i.scrollbarY); + dom.remove(i.scrollbarXRail); + dom.remove(i.scrollbarYRail); _.removePsClasses(element); instances.remove(element); diff --git a/src/js/plugin/handler/drag-scrollbar.js b/src/js/plugin/handler/drag-scrollbar.js index c15fd6c..57acfda 100644 --- a/src/js/plugin/handler/drag-scrollbar.js +++ b/src/js/plugin/handler/drag-scrollbar.js @@ -1,6 +1,6 @@ 'use strict'; -var d = require('../../lib/dom') +var dom = require('../../lib/dom') , _ = require('../../lib/helper') , instances = require('../instances') , updateGeometry = require('../update-geometry') @@ -40,7 +40,7 @@ function bindMouseScrollXHandler(element, i) { i.event.bind(i.scrollbarX, 'mousedown', function (e) { currentPageX = e.pageX; - currentLeft = _.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio; + currentLeft = _.toInt(dom.css(i.scrollbarX, 'left')) * i.railXRatio; _.startScrolling(element, 'x'); i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); @@ -85,7 +85,7 @@ function bindMouseScrollYHandler(element, i) { i.event.bind(i.scrollbarY, 'mousedown', function (e) { currentPageY = e.pageY; - currentTop = _.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio; + currentTop = _.toInt(dom.css(i.scrollbarY, 'top')) * i.railYRatio; _.startScrolling(element, 'y'); i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); diff --git a/src/js/plugin/handler/keyboard.js b/src/js/plugin/handler/keyboard.js index fa9719a..3632e86 100644 --- a/src/js/plugin/handler/keyboard.js +++ b/src/js/plugin/handler/keyboard.js @@ -1,7 +1,7 @@ 'use strict'; var _ = require('../../lib/helper') - , d = require('../../lib/dom') + , dom = require('../../lib/dom') , instances = require('../instances') , updateGeometry = require('../update-geometry') , updateScroll = require('../update-scroll'); @@ -44,8 +44,8 @@ function bindKeyboardHandler(element, i) { return; } - var focused = d.matches(i.scrollbarX, ':focus') || - d.matches(i.scrollbarY, ':focus'); + var focused = dom.matches(i.scrollbarX, ':focus') || + dom.matches(i.scrollbarY, ':focus'); if (!hovered && !focused) { return; diff --git a/src/js/plugin/instances.js b/src/js/plugin/instances.js index e10bcc6..0448929 100644 --- a/src/js/plugin/instances.js +++ b/src/js/plugin/instances.js @@ -1,7 +1,7 @@ 'use strict'; var cls = require('../lib/class') - , d = require('../lib/dom') + , dom = require('../lib/dom') , defaultSettings = require('./default-setting') , EventManager = require('../lib/event-manager') , guid = require('../lib/guid') @@ -18,7 +18,7 @@ function Instance(element) { i.contentWidth = null; i.contentHeight = null; - i.isRtl = d.css(element, 'direction') === "rtl"; + i.isRtl = dom.css(element, 'direction') === "rtl"; i.isNegativeScroll = (function () { var originalScrollLeft = element.scrollLeft; var result = null; @@ -39,41 +39,41 @@ function Instance(element) { cls.remove(element, 'ps-focus'); } - 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.scrollbarXRail = dom.appendTo(dom.e('div', 'ps-scrollbar-x-rail'), element); + i.scrollbarX = dom.appendTo(dom.e('div', 'ps-scrollbar-x'), i.scrollbarXRail); i.scrollbarX.setAttribute('tabindex', 0); i.event.bind(i.scrollbarX, 'focus', focus); i.event.bind(i.scrollbarX, 'blur', blur); i.scrollbarXActive = null; i.scrollbarXWidth = null; i.scrollbarXLeft = null; - i.scrollbarXBottom = _.toInt(d.css(i.scrollbarXRail, 'bottom')); + i.scrollbarXBottom = _.toInt(dom.css(i.scrollbarXRail, 'bottom')); i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN - i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : _.toInt(d.css(i.scrollbarXRail, 'top')); - i.railBorderXWidth = _.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + _.toInt(d.css(i.scrollbarXRail, 'borderRightWidth')); + i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : _.toInt(dom.css(i.scrollbarXRail, 'top')); + i.railBorderXWidth = _.toInt(dom.css(i.scrollbarXRail, 'borderLeftWidth')) + _.toInt(dom.css(i.scrollbarXRail, 'borderRightWidth')); // Set rail to display:block to calculate margins - d.css(i.scrollbarXRail, 'display', 'block'); - i.railXMarginWidth = _.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(d.css(i.scrollbarXRail, 'marginRight')); - d.css(i.scrollbarXRail, 'display', ''); + dom.css(i.scrollbarXRail, 'display', 'block'); + i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight')); + dom.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.scrollbarYRail = dom.appendTo(dom.e('div', 'ps-scrollbar-y-rail'), element); + i.scrollbarY = dom.appendTo(dom.e('div', 'ps-scrollbar-y'), i.scrollbarYRail); i.scrollbarY.setAttribute('tabindex', 0); i.event.bind(i.scrollbarY, 'focus', focus); i.event.bind(i.scrollbarY, 'blur', blur); i.scrollbarYActive = null; i.scrollbarYHeight = null; i.scrollbarYTop = null; - i.scrollbarYRight = _.toInt(d.css(i.scrollbarYRail, 'right')); + i.scrollbarYRight = _.toInt(dom.css(i.scrollbarYRail, 'right')); i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN - i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : _.toInt(d.css(i.scrollbarYRail, 'left')); + i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : _.toInt(dom.css(i.scrollbarYRail, 'left')); i.scrollbarYOuterWidth = i.isRtl ? _.outerWidth(i.scrollbarY) : null; - i.railBorderYWidth = _.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + _.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth')); - d.css(i.scrollbarYRail, 'display', 'block'); - i.railYMarginHeight = _.toInt(d.css(i.scrollbarYRail, 'marginTop')) + _.toInt(d.css(i.scrollbarYRail, 'marginBottom')); - d.css(i.scrollbarYRail, 'display', ''); + i.railBorderYWidth = _.toInt(dom.css(i.scrollbarYRail, 'borderTopWidth')) + _.toInt(dom.css(i.scrollbarYRail, 'borderBottomWidth')); + dom.css(i.scrollbarYRail, 'display', 'block'); + i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom')); + dom.css(i.scrollbarYRail, 'display', ''); i.railYHeight = null; i.railYRatio = null; } diff --git a/src/js/plugin/update-geometry.js b/src/js/plugin/update-geometry.js index 31a2cf6..97fa742 100644 --- a/src/js/plugin/update-geometry.js +++ b/src/js/plugin/update-geometry.js @@ -1,7 +1,7 @@ 'use strict'; var cls = require('../lib/class') - , d = require('../lib/dom') + , dom = require('../lib/dom') , _ = require('../lib/helper') , instances = require('./instances') , updateScroll = require('./update-scroll'); @@ -28,7 +28,7 @@ function updateCss(element, i) { } else { xRailOffset.top = i.scrollbarXTop + element.scrollTop; } - d.css(i.scrollbarXRail, xRailOffset); + dom.css(i.scrollbarXRail, xRailOffset); var yRailOffset = {top: element.scrollTop, height: i.railYHeight}; if (i.isScrollbarYUsingRight) { @@ -44,10 +44,10 @@ function updateCss(element, i) { yRailOffset.left = i.scrollbarYLeft + element.scrollLeft; } } - d.css(i.scrollbarYRail, yRailOffset); + dom.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}); + dom.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth}); + dom.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth}); } module.exports = function (element) { @@ -60,22 +60,22 @@ module.exports = function (element) { var existingRails; if (!element.contains(i.scrollbarXRail)) { - existingRails = d.queryChildren(element, '.ps-scrollbar-x-rail'); + existingRails = dom.queryChildren(element, '.ps-scrollbar-x-rail'); if (existingRails.length > 0) { existingRails.forEach(function (rail) { - d.remove(rail); + dom.remove(rail); }); } - d.appendTo(i.scrollbarXRail, element); + dom.appendTo(i.scrollbarXRail, element); } if (!element.contains(i.scrollbarYRail)) { - existingRails = d.queryChildren(element, '.ps-scrollbar-y-rail'); + existingRails = dom.queryChildren(element, '.ps-scrollbar-y-rail'); if (existingRails.length > 0) { existingRails.forEach(function (rail) { - d.remove(rail); + dom.remove(rail); }); } - d.appendTo(i.scrollbarYRail, element); + dom.appendTo(i.scrollbarYRail, element); } if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) { diff --git a/src/js/plugin/update.js b/src/js/plugin/update.js index c758934..bba7573 100644 --- a/src/js/plugin/update.js +++ b/src/js/plugin/update.js @@ -1,6 +1,6 @@ 'use strict'; -var d = require('../lib/dom') +var dom = require('../lib/dom') , _ = require('../lib/helper') , instances = require('./instances') , updateGeometry = require('./update-geometry') @@ -17,14 +17,14 @@ module.exports = function (element) { 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 = _.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(d.css(i.scrollbarXRail, 'marginRight')); - i.railYMarginHeight = _.toInt(d.css(i.scrollbarYRail, 'marginTop')) + _.toInt(d.css(i.scrollbarYRail, 'marginBottom')); + dom.css(i.scrollbarXRail, 'display', 'block'); + dom.css(i.scrollbarYRail, 'display', 'block'); + i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight')); + i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom')); // Hide scrollbars not to affect scrollWidth and scrollHeight - d.css(i.scrollbarXRail, 'display', 'none'); - d.css(i.scrollbarYRail, 'display', 'none'); + dom.css(i.scrollbarXRail, 'display', 'none'); + dom.css(i.scrollbarYRail, 'display', 'none'); updateGeometry(element); @@ -32,6 +32,6 @@ module.exports = function (element) { updateScroll(element, 'top', element.scrollTop); updateScroll(element, 'left', element.scrollLeft); - d.css(i.scrollbarXRail, 'display', ''); - d.css(i.scrollbarYRail, 'display', ''); + dom.css(i.scrollbarXRail, 'display', ''); + dom.css(i.scrollbarYRail, 'display', ''); };