Created
November 11, 2012 17:46
-
-
Save clooth/4055666 to your computer and use it in GitHub Desktop.
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
var App = { | |
// Configuration container | |
Config: {} | |
}; | |
// Common utilities | |
App.Util = { | |
// Format bytes into human readable size notation | |
formatFileSize: function(bytes) { | |
if (typeof bytes !== 'number') { return ''; } | |
if (bytes >= 1000000000) { | |
return (bytes / 1000000000).toFixed(2) + ' GB'; | |
} | |
if (bytes >= 1000000) { | |
return (bytes / 1000000).toFixed(2) + ' MB'; | |
} | |
return (bytes / 1000).toFixed(2) + ' KB'; | |
} | |
}; | |
// Flyout menu | |
App.Config.Flyout = { | |
selector: '.flyout', | |
duration: 120 | |
}; | |
App.Flyout = (function(container, config) { | |
// Elements used with the flyout menu | |
var doc = $(document), | |
toggle = $('h3 a', container); | |
// Toggling of the flyout menu | |
toggle.bind('click', function(e) { | |
e.preventDefault(); | |
container.fadeToggle(config.duration); | |
}); | |
// Don't bubble up events inside the container | |
container.bind('click', function(e) { | |
e.stopPropagation(); | |
}); | |
// Close flyout menu when focus lost | |
doc.bind('click', function(e) { | |
if (container.is(':visible')) { | |
container.fadeOut(config.duration); | |
} | |
}) | |
})($(App.Config.Flyout.selector), App.Config.Flyout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment