Created
January 19, 2017 02:53
-
-
Save anonymous/18403a278318ad0da9ceae18b1829744 to your computer and use it in GitHub Desktop.
example of breaking jquery code up into features
This file contains 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 Modal = { | |
open: false, | |
init: function() { | |
$('.modal-trigger').on('click', function() { | |
if (!Modal.open) { | |
Modal.open() | |
} else { | |
Modal.close() | |
} | |
}) | |
} | |
open: function() { | |
$('.modal-wrap').show() | |
Modal.open = true | |
}, | |
close: function() { | |
$('.modal-wrap').hide() | |
Modal.open = false | |
} | |
} | |
var SomeOtherFeature = { | |
init: function() { | |
... | |
} | |
... | |
} | |
$(document).ready(function() { | |
Modal.init() | |
SomeOtherFeature.init() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment