From bbab2a3c5360cbf8b4dcfd13af2503e29911ab0e Mon Sep 17 00:00:00 2001 From: Hyunje Alex Jun Date: Sat, 24 Jan 2015 15:15:42 +0000 Subject: [PATCH] Separate env helpers. --- src/js/lib/helper.js | 8 ++++++-- src/js/plugin/ps.js | 9 +++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/js/lib/helper.js b/src/js/lib/helper.js index 482c609..c87206c 100644 --- a/src/js/lib/helper.js +++ b/src/js/lib/helper.js @@ -13,8 +13,6 @@ exports.toInt = function (x) { } }; -exports.isWebKit = 'WebkitAppearance' in document.documentElement.style; - exports.clone = function (obj) { if (obj === null) { return null; @@ -43,3 +41,9 @@ exports.isEditable = function (el) { d.matches(el, "textarea,[contenteditable]") || d.matches(el, "button,[contenteditable]"); }; + +exports.env = { + isWebKit: 'WebkitAppearance' in document.documentElement.style, + supportsTouch: (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch), + supportsIePointer: window.navigator.msMaxTouchPoints !== null +}; diff --git a/src/js/plugin/ps.js b/src/js/plugin/ps.js index bd640ed..4db586a 100644 --- a/src/js/plugin/ps.js +++ b/src/js/plugin/ps.js @@ -349,7 +349,7 @@ module.exports = function (element, settingOrCommand) { // FIXME: this is a quick fix for the select problem in FF and IE. // If there comes an effective way to deal with the problem, // this lines should be removed. - if (!h.isWebKit && element.querySelector('select:focus')) { + if (!h.env.isWebKit && element.querySelector('select:focus')) { return; } @@ -769,9 +769,6 @@ module.exports = function (element, settingOrCommand) { isPluginAlive = false; } - var supportsTouch = (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch); - var supportsIePointer = window.navigator.msMaxTouchPoints !== null; - function initialize() { updateGeometry(); bindScrollHandler(); @@ -781,8 +778,8 @@ module.exports = function (element, settingOrCommand) { bindSelectionHandler(); bindMouseWheelHandler(); - if (supportsTouch || supportsIePointer) { - bindTouchHandler(supportsTouch, supportsIePointer); + if (h.env.supportsTouch || h.env.supportsIePointer) { + bindTouchHandler(h.env.supportsTouch, h.env.supportsIePointer); } if (settings.useKeyboard) { bindKeyboardHandler();