Created
December 5, 2015 17:41
-
-
Save asciimo/5631ceb0800cfee47b3e to your computer and use it in GitHub Desktop.
Example of a JS object with public/private methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Utility for ducking Discovery under fixed agent navigation bars and ads | |
var discoDuck = (function() { | |
var _discoveryContainer = $("#discoveryContainer"); | |
var _proNavBarHeight = $("#navbarAgent").outerHeight(); | |
var _proCatcherHeight = $("#pro_catcher").outerHeight(); | |
var _adjustMarginTop = function(pixels, addOrRemove) { | |
if(_discoveryContainer.length < 1) { | |
return; | |
} | |
var currentMarginTop = _discoveryContainer.css("margin-top").replace("px", ""); | |
var newMarginTop; | |
if(addOrRemove === "add") { | |
newMarginTop = parseInt(currentMarginTop) + parseInt(pixels); | |
} else { | |
newMarginTop = parseInt(currentMarginTop) - parseInt(pixels); | |
} | |
_discoveryContainer.css('margin-top', newMarginTop); | |
}; | |
// ᕕ( ⁰ ਊ ⁰ )ᕗ ♪♬ | |
return { | |
duckProNavBar: function () { | |
_adjustMarginTop(_proNavBarHeight, 'add'); | |
}, | |
unDuckProNavBar: function () { | |
_adjustMarginTop(_proNavBarHeight, 'remove'); | |
}, | |
duckProCatcher: function () { | |
_adjustMarginTop(_proCatcherHeight, 'add'); | |
}, | |
unDuckProCatcher: function () { | |
_adjustMarginTop(_proCatcherHeight, 'remove'); | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment