From aa7e488cd5bfe63b75f3b59041cc694602b3234e Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 4 Feb 2015 22:41:30 +0100 Subject: [PATCH] Refactor getBrowserCapabilities --- Gruntfile.js | 1 + js/common.js | 27 +++++++++++++++++++++++++++ js/sliders.js | 18 ++---------------- js/toggles.js | 16 +--------------- 4 files changed, 31 insertions(+), 31 deletions(-) create mode 100755 js/common.js diff --git a/Gruntfile.js b/Gruntfile.js index 2d3a39b..74c2086 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -50,6 +50,7 @@ module.exports = function (grunt) { banner: '<%= banner %>' }, src: [ + 'js/common.js', 'js/modals.js', 'js/popovers.js', 'js/push.js', diff --git a/js/common.js b/js/common.js new file mode 100755 index 0000000..f183993 --- /dev/null +++ b/js/common.js @@ -0,0 +1,27 @@ +/* ======================================================================== + * Ratchet: common.js v2.0.2 + * http://goratchet.com/ + * ======================================================================== + * Copyright 2015 Connor Sears + * Licensed under MIT (https://github.com/twbs/ratchet/blob/master/LICENSE) + * ======================================================================== */ + +!(function () { + 'use strict'; + + // Original script from http://davidwalsh.name/vendor-prefix + var getBrowserCapabilities = (function () { + var styles = window.getComputedStyle(document.documentElement, ''); + var pre = (Array.prototype.slice + .call(styles) + .join('') + .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']) + )[1]; + return { + prefix: '-' + pre + '-', + transform: pre[0].toUpperCase() + pre.substr(1) + 'Transform' + }; + })(); + + window.getBrowserCapabilities = getBrowserCapabilities; +}()); diff --git a/js/sliders.js b/js/sliders.js index be9cc98..22efcb5 100644 --- a/js/sliders.js +++ b/js/sliders.js @@ -25,22 +25,8 @@ var scrollableArea; var startedMoving; - // Original script from http://davidwalsh.name/vendor-prefix - var getBrowserCapabilities = (function () { - var styles = window.getComputedStyle(document.documentElement, ''); - var pre = (Array.prototype.slice - .call(styles) - .join('') - .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']) - )[1]; - return { - prefix: '-' + pre + '-', - transform: pre[0].toUpperCase() + pre.substr(1) + 'Transform' - }; - })(); - - var transformPrefix = getBrowserCapabilities.prefix; - var transformProperty = getBrowserCapabilities.transform; + var transformPrefix = window.getBrowserCapabilities.prefix; + var transformProperty = window.getBrowserCapabilities.transform; var getSlider = function (target) { var i; diff --git a/js/toggles.js b/js/toggles.js index 56d2523..fadbb23 100644 --- a/js/toggles.js +++ b/js/toggles.js @@ -14,21 +14,7 @@ var touchMove = false; var distanceX = false; var toggle = false; - - // Original script from http://davidwalsh.name/vendor-prefix - var getBrowserCapabilities = (function () { - var styles = window.getComputedStyle(document.documentElement, ''); - var pre = (Array.prototype.slice - .call(styles) - .join('') - .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']) - )[1]; - return { - transform: pre[0].toUpperCase() + pre.substr(1) + 'Transform' - }; - })(); - - var transformProperty = getBrowserCapabilities.transform; + var transformProperty = window.getBrowserCapabilities.transform; var findToggle = function (target) { var i;