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
/** | |
* So, obviously this is by no means a "new trick", | |
* but encapsulation in classes works the same as | |
* it does in "Modules" (IIFE pattern): You hide them | |
* in a scope, and define the methods that need access | |
* to them within that same scope. The constructor is | |
* as good a place as any for that. | |
*/ | |
import _ from 'underscore'; |
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 plan = require('flightplan'); | |
var moment = require('moment'); | |
var currentTime = new Date().getTime(); | |
var formattedCurrentTime = moment(currentTime).format('YYYY-MM-DD_HH-mm'); | |
var backupsFilename = 'backups.json'; | |
plan.target('staging', { | |
host: 'staging.some-host.com', | |
username: 'root-level-user', |
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
describe "Saving", -> | |
before -> | |
@syncSpy = sinon.spy() | |
@syncStub = sinon.stub(Backbone, 'sync', @syncSpy) | |
@changeSpy = sinon.spy() | |
afterEach -> | |
@syncSpy.reset() | |
it 'sets errors on the model when trying to save', -> |
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
class Model extends Backbone.Model | |
fetchUnless: (key, options = {}) -> | |
defer = $.Deferred() | |
if @has(key) | |
defer.resolve(@) | |
else | |
@fetch(options).done => | |
defer.resolve(@) |
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
@AnalyticsApp.module "Views", (Views, App, Backbone, Marionette, $, _) -> | |
_.extend Marionette.View::, | |
templateHelpers: -> | |
form: | |
App.request "get:form" | |
i18n: | |
App.request "get:i18n" |
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
// Generated on 2014-03-05 using generator-webapp 0.4.7 | |
'use strict'; | |
// # Globbing | |
// for performance reasons we're only matching one level down: | |
// 'test/spec/**/*.js' | |
// use this if you want to recursively match all subfolders: | |
// 'test/spec/**/*.js' | |
module.exports = function (grunt) { |
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
<script type="text/handlebars" id="my_list_template"> | |
<div class="{{whichuser}}"> | |
<img src="{{ image }}"> | |
<div class="message_body"> | |
{{{message_body}}} | |
</div> | |
</div> | |
</script> |
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 M = Backbone.Marionette; | |
var App = new M.Application(); | |
var ListItem = M.ItemView.extend({ | |
tagName: 'li', | |
template: _.template('<h4 class="question"><%= question %></h4><p style="display: none;"><%= answer %></p>') | |
}); | |
var List = M.CollectionView.extend({ |
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
_.extend Marionette.Renderer, | |
render: (template, data) -> | |
throw "Template #{template} not found!" unless JST[template] | |
JST[template](data) |
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
@App.module 'MapApp', (MapApp, App, Backbone, Marionette, $, _) -> | |
@startWithParent = false | |
API = | |
showMap: -> | |
new MapApp.List.Controller | |
@on 'start', -> | |
API.showMap() |