"making jshint (almost) happy"

This commit is contained in:
Bartek Szopka
2012-03-10 18:26:12 +00:00
parent 92181f58f0
commit a20c50db25

View File

@@ -44,7 +44,7 @@
} }
return memory[ prop ]; return memory[ prop ];
} };
})(); })();
@@ -57,13 +57,13 @@
for ( key in props ) { for ( key in props ) {
if ( props.hasOwnProperty(key) ) { if ( props.hasOwnProperty(key) ) {
pkey = pfx(key); pkey = pfx(key);
if ( pkey != null ) { if ( pkey !== null ) {
el.style[pkey] = props[key]; el.style[pkey] = props[key];
} }
} }
} }
return el; return el;
} };
var toNumber = function (numeric, fallback) { var toNumber = function (numeric, fallback) {
return isNaN(numeric) ? (fallback || 0) : Number(numeric); return isNaN(numeric) ? (fallback || 0) : Number(numeric);
@@ -71,7 +71,7 @@
var byId = function ( id ) { var byId = function ( id ) {
return document.getElementById(id); return document.getElementById(id);
} };
var $ = function ( selector, context ) { var $ = function ( selector, context ) {
context = context || document; context = context || document;
@@ -113,7 +113,7 @@
var body = document.body; var body = document.body;
var ua = navigator.userAgent.toLowerCase(); var ua = navigator.userAgent.toLowerCase();
var impressSupported = ( pfx("perspective") != null ) && var impressSupported = ( pfx("perspective") !== null ) &&
( body.classList ) && ( body.classList ) &&
( body.dataset ) && ( body.dataset ) &&
( ua.search(/(iphone)|(ipod)|(android)/) == -1 ); ( ua.search(/(iphone)|(ipod)|(android)/) == -1 );
@@ -137,7 +137,7 @@
perspective: 1000, perspective: 1000,
transitionDuration: 1000, transitionDuration: 1000
}; };
var impress = window.impress = function ( rootId ) { var impress = window.impress = function ( rootId ) {
@@ -173,8 +173,8 @@
perspective: toNumber(rootData.perspective, defaults.perspective), perspective: toNumber(rootData.perspective, defaults.perspective),
transitionDuration: toNumber(rootData.transitionDuration, defaults.transitionDuration), transitionDuration: toNumber(rootData.transitionDuration, defaults.transitionDuration)
} };
var canvas = document.createElement("div"); var canvas = document.createElement("div");
canvas.className = "canvas"; canvas.className = "canvas";
@@ -201,7 +201,7 @@
transformOrigin: "top left", transformOrigin: "top left",
transition: "all 0s ease-in-out", transition: "all 0s ease-in-out",
transformStyle: "preserve-3d" transformStyle: "preserve-3d"
} };
css(root, props); css(root, props);
css(root, { css(root, {
@@ -319,7 +319,7 @@
rotate: { rotate: {
x: -step.rotate.x, x: -step.rotate.x,
y: -step.rotate.y, y: -step.rotate.y,
z: -step.rotate.z, z: -step.rotate.z
}, },
translate: { translate: {
x: -step.translate.x, x: -step.translate.x,
@@ -341,11 +341,12 @@
windowScale = computeWindowScale(); windowScale = computeWindowScale();
} }
var targetScale = target.scale * windowScale;
css(root, { css(root, {
// to keep the perspective look similar for different scales // to keep the perspective look similar for different scales
// we need to 'scale' the perspective, too // we need to 'scale' the perspective, too
transform: perspective( config.perspective / (target.scale * windowScale) ) transform: perspective( config.perspective / targetScale ) + scale( targetScale ),
+ scale(target.scale * windowScale),
transitionDuration: duration, transitionDuration: duration,
transitionDelay: (zoomin ? delay : "0ms") transitionDelay: (zoomin ? delay : "0ms")
}); });
@@ -394,7 +395,7 @@
prev: prev prev: prev
}); });
} };
})(document, window); })(document, window);
// EVENTS // EVENTS
@@ -402,6 +403,8 @@
(function ( document, window ) { (function ( document, window ) {
'use strict'; 'use strict';
var impress = window.impress;
// throttling function calls, by Remy Sharp // throttling function calls, by Remy Sharp
// http://remysharp.com/2010/07/21/throttling-function-calls/ // http://remysharp.com/2010/07/21/throttling-function-calls/
var throttle = function (fn, delay) { var throttle = function (fn, delay) {
@@ -428,15 +431,15 @@
document.addEventListener("keyup", function ( event ) { document.addEventListener("keyup", function ( event ) {
if ( event.keyCode == 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { if ( event.keyCode == 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) {
switch( event.keyCode ) { switch( event.keyCode ) {
case 33: ; // pg up case 33: // pg up
case 37: ; // left case 37: // left
case 38: // up case 38: // up
impress().prev(); impress().prev();
break; break;
case 9: ; // tab case 9: // tab
case 32: ; // space case 32: // space
case 34: ; // pg down case 34: // pg down
case 39: ; // right case 39: // right
case 40: // down case 40: // down
impress().next(); impress().next();
break; break;
@@ -505,7 +508,7 @@
}, false); }, false);
// rescale presentation when window is resized // rescale presentation when window is resized
window.addEventListener("resize", throttle(function (event) { window.addEventListener("resize", throttle(function () {
// force going to active step again, to trigger rescaling // force going to active step again, to trigger rescaling
impress().stepTo( document.querySelector(".active"), true ); impress().stepTo( document.querySelector(".active"), true );
}, 250), false); }, 250), false);