Rename dom module variable name 'd' to 'dom'
Enhance readability.
This commit is contained in:
parent
d277a363b0
commit
e63d4c03cb
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var cls = require('./class')
|
var cls = require('./class')
|
||||||
, d = require('./dom');
|
, dom = require('./dom');
|
||||||
|
|
||||||
var toInt = exports.toInt = function (x) {
|
var toInt = exports.toInt = function (x) {
|
||||||
return parseInt(x, 10) || 0;
|
return parseInt(x, 10) || 0;
|
||||||
@ -32,10 +32,10 @@ exports.extend = function (original, source) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.isEditable = function (el) {
|
exports.isEditable = function (el) {
|
||||||
return d.matches(el, "input,[contenteditable]") ||
|
return dom.matches(el, "input,[contenteditable]") ||
|
||||||
d.matches(el, "select,[contenteditable]") ||
|
dom.matches(el, "select,[contenteditable]") ||
|
||||||
d.matches(el, "textarea,[contenteditable]") ||
|
dom.matches(el, "textarea,[contenteditable]") ||
|
||||||
d.matches(el, "button,[contenteditable]");
|
dom.matches(el, "button,[contenteditable]");
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.removePsClasses = function (element) {
|
exports.removePsClasses = function (element) {
|
||||||
@ -49,11 +49,11 @@ exports.removePsClasses = function (element) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.outerWidth = function (element) {
|
exports.outerWidth = function (element) {
|
||||||
return toInt(d.css(element, 'width')) +
|
return toInt(dom.css(element, 'width')) +
|
||||||
toInt(d.css(element, 'paddingLeft')) +
|
toInt(dom.css(element, 'paddingLeft')) +
|
||||||
toInt(d.css(element, 'paddingRight')) +
|
toInt(dom.css(element, 'paddingRight')) +
|
||||||
toInt(d.css(element, 'borderLeftWidth')) +
|
toInt(dom.css(element, 'borderLeftWidth')) +
|
||||||
toInt(d.css(element, 'borderRightWidth'));
|
toInt(dom.css(element, 'borderRightWidth'));
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.startScrolling = function (element, axis) {
|
exports.startScrolling = function (element, axis) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var d = require('../lib/dom')
|
var dom = require('../lib/dom')
|
||||||
, _ = require('../lib/helper')
|
, _ = require('../lib/helper')
|
||||||
, instances = require('./instances');
|
, instances = require('./instances');
|
||||||
|
|
||||||
@ -12,10 +12,10 @@ module.exports = function (element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i.event.unbindAll();
|
i.event.unbindAll();
|
||||||
d.remove(i.scrollbarX);
|
dom.remove(i.scrollbarX);
|
||||||
d.remove(i.scrollbarY);
|
dom.remove(i.scrollbarY);
|
||||||
d.remove(i.scrollbarXRail);
|
dom.remove(i.scrollbarXRail);
|
||||||
d.remove(i.scrollbarYRail);
|
dom.remove(i.scrollbarYRail);
|
||||||
_.removePsClasses(element);
|
_.removePsClasses(element);
|
||||||
|
|
||||||
instances.remove(element);
|
instances.remove(element);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var d = require('../../lib/dom')
|
var dom = require('../../lib/dom')
|
||||||
, _ = require('../../lib/helper')
|
, _ = require('../../lib/helper')
|
||||||
, instances = require('../instances')
|
, instances = require('../instances')
|
||||||
, updateGeometry = require('../update-geometry')
|
, updateGeometry = require('../update-geometry')
|
||||||
@ -40,7 +40,7 @@ function bindMouseScrollXHandler(element, i) {
|
|||||||
|
|
||||||
i.event.bind(i.scrollbarX, 'mousedown', function (e) {
|
i.event.bind(i.scrollbarX, 'mousedown', function (e) {
|
||||||
currentPageX = e.pageX;
|
currentPageX = e.pageX;
|
||||||
currentLeft = _.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio;
|
currentLeft = _.toInt(dom.css(i.scrollbarX, 'left')) * i.railXRatio;
|
||||||
_.startScrolling(element, 'x');
|
_.startScrolling(element, 'x');
|
||||||
|
|
||||||
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
|
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
|
||||||
@ -85,7 +85,7 @@ function bindMouseScrollYHandler(element, i) {
|
|||||||
|
|
||||||
i.event.bind(i.scrollbarY, 'mousedown', function (e) {
|
i.event.bind(i.scrollbarY, 'mousedown', function (e) {
|
||||||
currentPageY = e.pageY;
|
currentPageY = e.pageY;
|
||||||
currentTop = _.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio;
|
currentTop = _.toInt(dom.css(i.scrollbarY, 'top')) * i.railYRatio;
|
||||||
_.startScrolling(element, 'y');
|
_.startScrolling(element, 'y');
|
||||||
|
|
||||||
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
|
i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var _ = require('../../lib/helper')
|
var _ = require('../../lib/helper')
|
||||||
, d = require('../../lib/dom')
|
, dom = require('../../lib/dom')
|
||||||
, instances = require('../instances')
|
, instances = require('../instances')
|
||||||
, updateGeometry = require('../update-geometry')
|
, updateGeometry = require('../update-geometry')
|
||||||
, updateScroll = require('../update-scroll');
|
, updateScroll = require('../update-scroll');
|
||||||
@ -44,8 +44,8 @@ function bindKeyboardHandler(element, i) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var focused = d.matches(i.scrollbarX, ':focus') ||
|
var focused = dom.matches(i.scrollbarX, ':focus') ||
|
||||||
d.matches(i.scrollbarY, ':focus');
|
dom.matches(i.scrollbarY, ':focus');
|
||||||
|
|
||||||
if (!hovered && !focused) {
|
if (!hovered && !focused) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var cls = require('../lib/class')
|
var cls = require('../lib/class')
|
||||||
, d = require('../lib/dom')
|
, dom = require('../lib/dom')
|
||||||
, defaultSettings = require('./default-setting')
|
, defaultSettings = require('./default-setting')
|
||||||
, EventManager = require('../lib/event-manager')
|
, EventManager = require('../lib/event-manager')
|
||||||
, guid = require('../lib/guid')
|
, guid = require('../lib/guid')
|
||||||
@ -18,7 +18,7 @@ function Instance(element) {
|
|||||||
i.contentWidth = null;
|
i.contentWidth = null;
|
||||||
i.contentHeight = null;
|
i.contentHeight = null;
|
||||||
|
|
||||||
i.isRtl = d.css(element, 'direction') === "rtl";
|
i.isRtl = dom.css(element, 'direction') === "rtl";
|
||||||
i.isNegativeScroll = (function () {
|
i.isNegativeScroll = (function () {
|
||||||
var originalScrollLeft = element.scrollLeft;
|
var originalScrollLeft = element.scrollLeft;
|
||||||
var result = null;
|
var result = null;
|
||||||
@ -39,41 +39,41 @@ function Instance(element) {
|
|||||||
cls.remove(element, 'ps-focus');
|
cls.remove(element, 'ps-focus');
|
||||||
}
|
}
|
||||||
|
|
||||||
i.scrollbarXRail = d.appendTo(d.e('div', 'ps-scrollbar-x-rail'), element);
|
i.scrollbarXRail = dom.appendTo(dom.e('div', 'ps-scrollbar-x-rail'), element);
|
||||||
i.scrollbarX = d.appendTo(d.e('div', 'ps-scrollbar-x'), i.scrollbarXRail);
|
i.scrollbarX = dom.appendTo(dom.e('div', 'ps-scrollbar-x'), i.scrollbarXRail);
|
||||||
i.scrollbarX.setAttribute('tabindex', 0);
|
i.scrollbarX.setAttribute('tabindex', 0);
|
||||||
i.event.bind(i.scrollbarX, 'focus', focus);
|
i.event.bind(i.scrollbarX, 'focus', focus);
|
||||||
i.event.bind(i.scrollbarX, 'blur', blur);
|
i.event.bind(i.scrollbarX, 'blur', blur);
|
||||||
i.scrollbarXActive = null;
|
i.scrollbarXActive = null;
|
||||||
i.scrollbarXWidth = null;
|
i.scrollbarXWidth = null;
|
||||||
i.scrollbarXLeft = 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.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN
|
||||||
i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : _.toInt(d.css(i.scrollbarXRail, 'top'));
|
i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : _.toInt(dom.css(i.scrollbarXRail, 'top'));
|
||||||
i.railBorderXWidth = _.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + _.toInt(d.css(i.scrollbarXRail, 'borderRightWidth'));
|
i.railBorderXWidth = _.toInt(dom.css(i.scrollbarXRail, 'borderLeftWidth')) + _.toInt(dom.css(i.scrollbarXRail, 'borderRightWidth'));
|
||||||
// Set rail to display:block to calculate margins
|
// Set rail to display:block to calculate margins
|
||||||
d.css(i.scrollbarXRail, 'display', 'block');
|
dom.css(i.scrollbarXRail, 'display', 'block');
|
||||||
i.railXMarginWidth = _.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(d.css(i.scrollbarXRail, 'marginRight'));
|
i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight'));
|
||||||
d.css(i.scrollbarXRail, 'display', '');
|
dom.css(i.scrollbarXRail, 'display', '');
|
||||||
i.railXWidth = null;
|
i.railXWidth = null;
|
||||||
i.railXRatio = null;
|
i.railXRatio = null;
|
||||||
|
|
||||||
i.scrollbarYRail = d.appendTo(d.e('div', 'ps-scrollbar-y-rail'), element);
|
i.scrollbarYRail = dom.appendTo(dom.e('div', 'ps-scrollbar-y-rail'), element);
|
||||||
i.scrollbarY = d.appendTo(d.e('div', 'ps-scrollbar-y'), i.scrollbarYRail);
|
i.scrollbarY = dom.appendTo(dom.e('div', 'ps-scrollbar-y'), i.scrollbarYRail);
|
||||||
i.scrollbarY.setAttribute('tabindex', 0);
|
i.scrollbarY.setAttribute('tabindex', 0);
|
||||||
i.event.bind(i.scrollbarY, 'focus', focus);
|
i.event.bind(i.scrollbarY, 'focus', focus);
|
||||||
i.event.bind(i.scrollbarY, 'blur', blur);
|
i.event.bind(i.scrollbarY, 'blur', blur);
|
||||||
i.scrollbarYActive = null;
|
i.scrollbarYActive = null;
|
||||||
i.scrollbarYHeight = null;
|
i.scrollbarYHeight = null;
|
||||||
i.scrollbarYTop = 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.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.scrollbarYOuterWidth = i.isRtl ? _.outerWidth(i.scrollbarY) : null;
|
||||||
i.railBorderYWidth = _.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + _.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth'));
|
i.railBorderYWidth = _.toInt(dom.css(i.scrollbarYRail, 'borderTopWidth')) + _.toInt(dom.css(i.scrollbarYRail, 'borderBottomWidth'));
|
||||||
d.css(i.scrollbarYRail, 'display', 'block');
|
dom.css(i.scrollbarYRail, 'display', 'block');
|
||||||
i.railYMarginHeight = _.toInt(d.css(i.scrollbarYRail, 'marginTop')) + _.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
|
i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom'));
|
||||||
d.css(i.scrollbarYRail, 'display', '');
|
dom.css(i.scrollbarYRail, 'display', '');
|
||||||
i.railYHeight = null;
|
i.railYHeight = null;
|
||||||
i.railYRatio = null;
|
i.railYRatio = null;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var cls = require('../lib/class')
|
var cls = require('../lib/class')
|
||||||
, d = require('../lib/dom')
|
, dom = require('../lib/dom')
|
||||||
, _ = require('../lib/helper')
|
, _ = require('../lib/helper')
|
||||||
, instances = require('./instances')
|
, instances = require('./instances')
|
||||||
, updateScroll = require('./update-scroll');
|
, updateScroll = require('./update-scroll');
|
||||||
@ -28,7 +28,7 @@ function updateCss(element, i) {
|
|||||||
} else {
|
} else {
|
||||||
xRailOffset.top = i.scrollbarXTop + element.scrollTop;
|
xRailOffset.top = i.scrollbarXTop + element.scrollTop;
|
||||||
}
|
}
|
||||||
d.css(i.scrollbarXRail, xRailOffset);
|
dom.css(i.scrollbarXRail, xRailOffset);
|
||||||
|
|
||||||
var yRailOffset = {top: element.scrollTop, height: i.railYHeight};
|
var yRailOffset = {top: element.scrollTop, height: i.railYHeight};
|
||||||
if (i.isScrollbarYUsingRight) {
|
if (i.isScrollbarYUsingRight) {
|
||||||
@ -44,10 +44,10 @@ function updateCss(element, i) {
|
|||||||
yRailOffset.left = i.scrollbarYLeft + element.scrollLeft;
|
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});
|
dom.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.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function (element) {
|
module.exports = function (element) {
|
||||||
@ -60,22 +60,22 @@ module.exports = function (element) {
|
|||||||
|
|
||||||
var existingRails;
|
var existingRails;
|
||||||
if (!element.contains(i.scrollbarXRail)) {
|
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) {
|
if (existingRails.length > 0) {
|
||||||
existingRails.forEach(function (rail) {
|
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)) {
|
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) {
|
if (existingRails.length > 0) {
|
||||||
existingRails.forEach(function (rail) {
|
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) {
|
if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var d = require('../lib/dom')
|
var dom = require('../lib/dom')
|
||||||
, _ = require('../lib/helper')
|
, _ = require('../lib/helper')
|
||||||
, instances = require('./instances')
|
, instances = require('./instances')
|
||||||
, updateGeometry = require('./update-geometry')
|
, updateGeometry = require('./update-geometry')
|
||||||
@ -17,14 +17,14 @@ module.exports = function (element) {
|
|||||||
i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
|
i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
|
||||||
|
|
||||||
// Recalculate rail margins
|
// Recalculate rail margins
|
||||||
d.css(i.scrollbarXRail, 'display', 'block');
|
dom.css(i.scrollbarXRail, 'display', 'block');
|
||||||
d.css(i.scrollbarYRail, 'display', 'block');
|
dom.css(i.scrollbarYRail, 'display', 'block');
|
||||||
i.railXMarginWidth = _.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(d.css(i.scrollbarXRail, 'marginRight'));
|
i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight'));
|
||||||
i.railYMarginHeight = _.toInt(d.css(i.scrollbarYRail, 'marginTop')) + _.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
|
i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom'));
|
||||||
|
|
||||||
// Hide scrollbars not to affect scrollWidth and scrollHeight
|
// Hide scrollbars not to affect scrollWidth and scrollHeight
|
||||||
d.css(i.scrollbarXRail, 'display', 'none');
|
dom.css(i.scrollbarXRail, 'display', 'none');
|
||||||
d.css(i.scrollbarYRail, 'display', 'none');
|
dom.css(i.scrollbarYRail, 'display', 'none');
|
||||||
|
|
||||||
updateGeometry(element);
|
updateGeometry(element);
|
||||||
|
|
||||||
@ -32,6 +32,6 @@ module.exports = function (element) {
|
|||||||
updateScroll(element, 'top', element.scrollTop);
|
updateScroll(element, 'top', element.scrollTop);
|
||||||
updateScroll(element, 'left', element.scrollLeft);
|
updateScroll(element, 'left', element.scrollLeft);
|
||||||
|
|
||||||
d.css(i.scrollbarXRail, 'display', '');
|
dom.css(i.scrollbarXRail, 'display', '');
|
||||||
d.css(i.scrollbarYRail, 'display', '');
|
dom.css(i.scrollbarYRail, 'display', '');
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user