Permalink
Browse files

clean class trimming/adding/removing

  • Loading branch information...
2 parents e086e91 + 3d2e278 commit 1402d44d8cfdf6f5bf88a4ea8d7d15e4a6336c79 @tholman committed Aug 19, 2016
Showing with 14 additions and 15 deletions.
  1. +14 −15 intense.js
View
@@ -13,7 +13,7 @@ window.cancelRequestAnimFrame = ( function() {
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
- clearTimeout
+ clearTimeout;
} )();
var Intense = (function() {
@@ -148,19 +148,18 @@ var Intense = (function() {
function setState (element, newClassName) {
if (element) {
- element.classList.remove("intense--loading");
- element.classList.remove("intense--viewing");
+ element.className = element.className.replace('intense--loading', '');
+ element.className = element.className.replace('intense--viewing', '');
element.className += " " + newClassName;
} else {
// Remove element with class .view
- var elems = document.querySelectorAll(".intense--viewing");
-
+ var elems = document.querySelectorAll('.intense--viewing');
[].forEach.call(elems, function(el) {
- el.classList.remove("intense--viewing");
- });
+ el.className = el.className.replace('intense--viewing', '').trim();
+ });
}
}
-
+
function createViewer( title, caption ) {
/*
@@ -181,14 +180,14 @@ var Intense = (function() {
'transition': 'opacity 150ms cubic-bezier( 0, 0, .26, 1 )',
'webkitBackfaceVisibility': 'hidden',
'opacity': '0'
- }
+ };
container = document.createElement( 'figure' );
container.appendChild( target );
applyProperties( container, containerProperties );
var imageProperties = {
'cursor': 'url( "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSw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tbwq5ETbJ2CLBss70dfbsWSvmpZzsnJTzo6KiEhoaGoaVWlXkwE0mkyXk4+PjE6gUCUpMTMz86urq48gOkIjFWYHfEqf0EkkyJ06cyCMB/iah5OTkTCVIUDQajQf8wl+QNaune/2/c+eOS9olkb+YiYyM9FJ6NGhaHA2OBJV5e6uZI6LVaq2YTSTSz9zatWsfc8X84JzYtGlTJtXeauaorFy5cr7IXieRdubWrFnzpCtIJCYmWpZYKvNKksE/34q5g0RamQsNDV3sKhLy74ySZJYtW2bF3EIidZaFeOnSp5wl0t/fb4aYbJGwRYZlWcfR/mSYL8idRhOcxuTpdBoHBgZuY5Pk0LfrPqdRnE8080Fubm60Aru34QeRoLCMoyQoxCpItFnnCIVBB2kj5GHZj8iw/iDfWJHIaGBgYAyj4u5OghiBdZ00fqby9V0iMK8rSMoYMGZo392JECOwehAztHNipPFjxiGw0UnYuXPnInclQWzEKI0fCH1kL9JoCdAZjcZzAQEB77sjkZ6env3YjK22G6AT8i7DkSzI8KS7kSAmQWJQYL3HabwrjKVK4mQKX9w0g8EQ6i4k9u7dqyUm8TNNYJVsmpbMxL5EkuouxwopKSn+xcXFeeJYoRgkUmVYJyXirgc9ldBnbB302NxYiYJcGc6wgcLCwvysrCztTJgT+xYkzhCTvUPR//9hqBgZkxiZYjao1+vf4vLH4XalKbEP9iVIFIuRME2K9b92MOHCAEOdZS66MJAAAp5iiX0DBI4+ANfUiIhKvMLxOfRVSXaFA2ZQnpmZWefIFY68vLxVMNf4CVc4vuV3wiVXOCZUjkLygXTvpRoTL9Uw9NrS0tJVX1/fc/78+ettbW2WIPXy5cvnRkdHP6rT6QK0Wm0QNkXhGo0mUrjikvTvpZpPQODCFLA4bw6ya06/OnHNqXnGrjnZIyWNXzyjC0GPYIk0fvHM+h+XXzxjnOCcNH7x7KqT/VrSfwQYAOAcX9HTDttYAAAAAElFTkSuQmCC" ) 25 25, no-drop'
- }
+ };
applyProperties( target, imageProperties );
/*
@@ -204,7 +203,7 @@ var Intense = (function() {
'wordSpacing': '0.2px',
'webkitFontSmoothing': 'antialiased',
'textShadow': '-1px 0px 1px rgba(0,0,0,0.4)'
- }
+ };
var captionContainer = document.createElement( 'figcaption' );
applyProperties( captionContainer, captionContainerProperties );
@@ -220,7 +219,7 @@ var Intense = (function() {
'letterSpacing': '0.5px',
'lineHeight': '35px',
'textAlign': 'left'
- }
+ };
var captionTitle = document.createElement( 'h1' );
applyProperties( captionTitle, captionTitleProperties );
captionTitle.innerHTML = title;
@@ -238,7 +237,7 @@ var Intense = (function() {
'textAlign': 'left',
'background': 'none',
'marginTop': '5px'
- }
+ };
var captionText = document.createElement( 'h2' );
applyProperties( captionText, captionTextProperties );
captionText.innerHTML = caption;
@@ -319,7 +318,7 @@ var Intense = (function() {
container.removeEventListener( 'touchmove', onTouchMove, false);
window.removeEventListener( 'resize', setDimensions, false );
window.removeEventListener( 'keyup', onKeyUp, false );
- target.removeEventListener( 'click', removeViewer, false )
+ target.removeEventListener( 'click', removeViewer, false );
}
function onMouseMove( event ) {
@@ -410,4 +409,4 @@ var Intense = (function() {
if (typeof module !== 'undefined' && module.exports){
module.exports = Intense;
-}
+}

0 comments on commit 1402d44

Please sign in to comment.