Browse Source

Refactor getBrowserCapabilities

pull/745/head
Johann-S 10 years ago
parent
commit
aa7e488cd5
  1. 1
      Gruntfile.js
  2. 27
      js/common.js
  3. 18
      js/sliders.js
  4. 16
      js/toggles.js

1
Gruntfile.js

@ -50,6 +50,7 @@ module.exports = function (grunt) {
banner: '<%= banner %>' banner: '<%= banner %>'
}, },
src: [ src: [
'js/common.js',
'js/modals.js', 'js/modals.js',
'js/popovers.js', 'js/popovers.js',
'js/push.js', 'js/push.js',

27
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;
}());

18
js/sliders.js

@ -25,22 +25,8 @@
var scrollableArea; var scrollableArea;
var startedMoving; var startedMoving;
// Original script from http://davidwalsh.name/vendor-prefix var transformPrefix = window.getBrowserCapabilities.prefix;
var getBrowserCapabilities = (function () { var transformProperty = window.getBrowserCapabilities.transform;
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 getSlider = function (target) { var getSlider = function (target) {
var i; var i;

16
js/toggles.js

@ -14,21 +14,7 @@
var touchMove = false; var touchMove = false;
var distanceX = false; var distanceX = false;
var toggle = false; var toggle = false;
var transformProperty = window.getBrowserCapabilities.transform;
// 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 findToggle = function (target) { var findToggle = function (target) {
var i; var i;

Loading…
Cancel
Save