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
.pulsate path { | |
stroke: #2980b9; | |
-webkit-animation: pulsate 5s ease-out; | |
-webkit-animation-iteration-count: infinite; | |
-moz-animation: pulsate 5s ease-out; | |
-moz-animation-iteration-count: infinite; | |
-ms-animation: pulsate 5s ease-out; | |
-ms-animation-iteration-count: infinite; | |
animation: pulsate 5s ease-out; | |
animation-iteration-count: infinite; |
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
// Listen for DOM events and trigger applicable methods | |
this.domListen = function(element) { | |
// Using jQuery's .on() for DOM events | |
(element || this.$element).on("click", ".close", null, self.unload); | |
} | |
// Tear down this presenter | |
this.unload = function(e) { | |
if (e) { e.preventDefault(); }; | |
self.unlisten.call(self); |
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
App.ItemPresenter = (function() { | |
var ItemPresenter = function($element, options) { | |
var self = this; | |
this.$element = $element; | |
this.bus = options.bus; | |
this.model = options.model; | |
this.clasName = "item"; | |
this.listen = function() { |
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
// Search for a selector within $el | |
function finder(selector) { | |
return (function() { | |
return $(selector, this.$el); | |
}) | |
} |
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
// DOM hooks | |
this.$form = finder("form"); | |
this.$inputEmail = finder("input[name='email']"); | |
this.$inputPassword = finder("input[name='password']"); | |
this.$errorMessages = finder(".error"); | |
// Handle login form submit | |
this.logIn = function(e) { | |
e.preventDefault(); | |
this.$errorMessages.remove(); |
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
it("renders an error message if credentials incorrect", function() { | |
loginPresenter.render(); | |
loginPresenter.bindDomEvents(); | |
expect(loginPresenter.$errorMessages().length).toBe(0); | |
loginPresenter.$inputEmail().val("wrong"); | |
loginPresenter.$inputPassword().val("wrong"); | |
loginPresenter.$form().trigger("submit"); |
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
// DOM Hooks | |
this.$form = function() { | |
return $("form", this.$el); | |
}; | |
this.$inputEmail = function() { | |
return $("input[name='email']", this.$el); | |
}; | |
this.$inputPassword = function() { |
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
it("renders an error message if credentials incorrect", function() { | |
loginPresenter.render(); | |
loginPresenter.listen(); | |
expect($(".error", loginPresenter.$el).length).toBe(0); | |
$("input[name='email']", loginPresenter.$el).val("wrong"); | |
$("input[name='email']", loginPresenter.$el).val("wrong"); | |
$("form", loginPresenter.$el).trigger("submit"); |
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
// Handle login form submit | |
this.logIn = function(e) { | |
e.preventDefault(); | |
$(".error", this.$el).remove(); | |
options.user.login({ | |
email: $("input[name='email']", this.$el).val(); | |
password: $("input[name='password']", this.$el).val(); | |
}) | |
.fail(this.loginError.bind(this)) |
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
App.LoginPresenter = (function() { | |
var Login = function($el, options) { | |
this.$el = $el; | |
this.name = "login"; | |
this.errorMessage = $.render( | |
App.templates.error, { text: "Wrong credentials" } | |
); | |
// Listen to relevant events |
NewerOlder