Created
October 31, 2013 11:52
-
-
Save nicohvi/7248457 to your computer and use it in GitHub Desktop.
Modular javascript
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 Order = function($el) { | |
// private variables | |
el = $el; | |
// public API | |
var Order = { | |
removeTarget: function() { | |
el.find('#order-target').remove(); | |
removePersonalia(); | |
updateView(); | |
}, | |
removeDirectMail: function() { | |
el.find('#order-direct-mail').remove(); | |
updateView(); | |
} | |
} | |
// private functions | |
function removePersonalia() { | |
el.find('.personalia').remove(); | |
} | |
function updateView() { | |
if( !hasTarget() ) addTargetButton() | |
} | |
function hasTarget() { | |
return el.find('#order-target').length > 0; | |
} | |
function addTargetButton() { | |
el.find('#target').prepend('<div class="push-3-2 order-button">'+ | |
'<a class="btn" href="http://localhost:3000/malgruppe" id="add-target-to-order">'+ | |
'Legg til målgruppe'+ | |
'</a></div>'); | |
} | |
return Order; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Det er sant!
Laget egentlig bare deklarasjonen av gamle vaner :p