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
<script id="login-template" type="text/template"> | |
<div class="msg-success hide">You are now logged in.</div> | |
<div class="error-bad-auth hide">Username and/or password incorrect.</div> | |
<div class="error-unknown hide"><%- stateDetails %></div> | |
<form action="#" method="post"> | |
<h1>Login</h1> | |
<input name="username" type="text" value="<%- username %>"> | |
<input name="password" type="password" value="<%- password %>"> |
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
class @ALoginView extends Backbone.Marionette.ItemView | |
# Specifies the Underscore.js template to use. | |
template: '#login-template' | |
# Properties of the DOM element that will be created/inserted by this view. | |
tagName: 'div' | |
className: 'login-area' | |
# Shortcut references to components within the UI. | |
ui: |
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
class @ALoginModel extends Backbone.Model | |
defaults: -> | |
username: '' | |
password: '' | |
state: @notAuthState # This is where you set the initial state. | |
stateDetails: '' | |
# Define constants to represent the various states and give them descriptive | |
# values to help with debugging. | |
notAuthState: 'Not Authenticated' |
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
# Initializes Marionette.js global application object. | |
@gApp = new Backbone.Marionette.Application() | |
# Prepares the DOM by assigning regions to various elements. | |
@gApp.addInitializer (options) -> | |
@addRegions(content: 'body') | |
# Login page controller. | |
@gApp.module 'LoginPage', (module, app, backbone, marionette, $, _) -> | |
module.addInitializer (options) -> |