Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
exposed w.overthrow.enabledClassName to fix a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Jehl committed Aug 2, 2013
1 parent a862f1b commit 5853220
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions dist/overthrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions dist/overthrow.sidescroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions src/overthrow-detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
<link rel="stylesheet" href="qunit/qunit.css" media="screen">
<script src="qunit/qunit.js"></script>
<link href="test.css" rel="stylesheet" />
<script src="../overthrow.js"></script>
<script src="../src/overthrow-detect.js"></script>
<script src="../src/overthrow-polyfill.js"></script>
<script src="../src/overthrow-toss.js"></script>
<script src="../src/overthrow-init.js"></script>
<script src="tests.js"></script>

</head>
Expand Down
4 changes: 2 additions & 2 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
});
Expand All @@ -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();
});

Expand Down

0 comments on commit 5853220

Please sign in to comment.