From 58532206a78a621e17615569cf4fa29ce49ca241 Mon Sep 17 00:00:00 2001 From: Scott Jehl Date: Fri, 2 Aug 2013 14:58:31 -0500 Subject: [PATCH] exposed w.overthrow.enabledClassName to fix a failing test --- README.md | 1 + dist/overthrow.js | 2 ++ dist/overthrow.sidescroller.js | 2 ++ src/overthrow-detect.js | 8 +++++--- test/index.html | 5 ++++- test/tests.js | 4 ++-- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index feb1775..451df72 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Overthrow exposes various properties you can access via the `overthrow` object: Many `overthrow` settings are exposed and configurable via the `overthrow` object. If needed, you can redefine these before calling `set()`. +- `overthrow.enabledClassName`: The class name added to the `html` element in supported browsers. Default is `overthrow-enabled` - `overthrow.scrollIndicatorClassName`: The class name used to identify scrollable `overthrow` elements. Default is `overthrow` ## Methods diff --git a/dist/overthrow.js b/dist/overthrow.js index cb4b9a2..312eaa9 100644 --- a/dist/overthrow.js +++ b/dist/overthrow.js @@ -57,6 +57,8 @@ // Expose overthrow API w.overthrow = {}; + w.overthrow.enabledClassName = enabledClassName; + w.overthrow.addClass = function(){ if( docElem.className.indexOf( enabledClassName ) === -1 ){ docElem.className += " " + enabledClassName; diff --git a/dist/overthrow.sidescroller.js b/dist/overthrow.sidescroller.js index fb0723c..1936fee 100644 --- a/dist/overthrow.sidescroller.js +++ b/dist/overthrow.sidescroller.js @@ -57,6 +57,8 @@ // Expose overthrow API w.overthrow = {}; + w.overthrow.enabledClassName = enabledClassName; + w.overthrow.addClass = function(){ if( docElem.className.indexOf( enabledClassName ) === -1 ){ docElem.className += " " + enabledClassName; diff --git a/src/overthrow-detect.js b/src/overthrow-detect.js index 854fc8b..836e59c 100644 --- a/src/overthrow-detect.js +++ b/src/overthrow-detect.js @@ -55,14 +55,16 @@ // Expose overthrow API w.overthrow = {}; + w.overthrow.enabledClassName = enabledClassName; + w.overthrow.addClass = function(){ - if( docElem.className.indexOf( enabledClassName ) === -1 ){ - docElem.className += " " + enabledClassName; + if( docElem.className.indexOf( w.overthrow.enabledClassName ) === -1 ){ + docElem.className += " " + w.overthrow.enabledClassName; } }; w.overthrow.removeClass = function(){ - docElem.className = docElem.className.replace( enabledClassName, "" ); + docElem.className = docElem.className.replace( w.overthrow.enabledClassName, "" ); }; // Enable and potentially polyfill overflow diff --git a/test/index.html b/test/index.html index 3786af0..149d45a 100644 --- a/test/index.html +++ b/test/index.html @@ -6,7 +6,10 @@ - + + + + diff --git a/test/tests.js b/test/tests.js index 2c24e11..0ef6f59 100644 --- a/test/tests.js +++ b/test/tests.js @@ -74,7 +74,7 @@ window.onload = function(){ test( 'overthrow.set adds HTML class with custom name', function() { overthrow.forget(); - overthrow.configure({enabledClassName: "prefixed-overthrow-enabled"}); + overthrow.enabledClassName = "prefixed-overthrow-enabled"; overthrow.set(); ok( document.documentElement.className.indexOf( "prefixed-overthrow-enabled" ) > -1 ); }); @@ -84,7 +84,7 @@ window.onload = function(){ ok( document.documentElement.className.indexOf( "prefixed-overthrow-enabled" ) === -1 ); //since the following tests assume the class name to be the default, we set it back - overthrow.configure({enabledClassName: "overthrow-enabled"}); + overthrow.enabledClassName = "overthrow-enabled"; overthrow.set(); });