Skip to content

Instantly share code, notes, and snippets.

@mbajoras
mbajoras / navbar_example.html
Created August 22, 2013 04:14
Example from Bootstrap website showing the navbar.
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
@mbajoras
mbajoras / template.html
Last active December 18, 2015 05:38
Underscore.js template for my blog article about Marionette.js stateful views.
<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 %>">
@mbajoras
mbajoras / loginView.coffee
Created June 8, 2013 02:45
Marionette.js item view for my blog article about Marionette.js stateful views.
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:
@mbajoras
mbajoras / loginModel.coffee
Created June 8, 2013 02:44
Backbone.js model for my blog article about Marionette.js stateful views.
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'
@mbajoras
mbajoras / loginModule.coffee
Last active December 18, 2015 05:38
Marionette.js module for my blog article about Marionette.js stateful views.
# 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) ->