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
| ## jQuery Deferred way | |
| App.reqres.setHandler "folder:type:picker", -> | |
| dfd = $.Deferred() | |
| App.load "pickers", -> | |
| dfd.resolve API.list() | |
| dfd.promise() | |
| promise = App.request "folder:type:picker" | |
| promise.done (folderTypePicker) => | |
| @listenToOnce folderTypePicker, "folder:types:submitted" |
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
| // JSON tree is this kind: | |
| [ | |
| { | |
| name: "Ob1", | |
| subobjects: [ | |
| {name: "Un1", age: 2}, | |
| {name: "Un2", age: 5}, | |
| {name: "Un3", age: 4}, | |
| {name: "Un4", age: 5}, |
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
| @PlanetExpress.module "Entities", (Entities, App, Backbone, Marionette, $, _) -> | |
| App.commands.setHandler "when:fetched", (entities, callback) -> | |
| xhrs = _.chain([entities]).flatten().pluck("_fetch").value() | |
| # if _.isArray(entities) | |
| # xhrs.push(entity._fetch) for entity in entities | |
| # else | |
| # xhrs.push(entities._fetch) | |
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 List.Event extends Marionette.ItemView | |
| template: "events/list/templates/_event" | |
| tagName: "tr" | |
| triggers: | |
| "click button" : "edit:event:clicked" | |
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
| #mixin = | |
| #bar: -> alert "bar" | |
| class Bar | |
| #bar: -> alert "bar" | |
| #baz: (b) -> console.log "baz", b, @ | |
| Bar.baz = (b) -> console.log "baz", b, @ | |
| class Foo extends Bar |
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
| _delegate = Backbone.Marionette.View::delegateEvents | |
| _close = Backbone.Marionette.View::close | |
| _.extend Backbone.Marionette.View::, | |
| delegateEvents: (events) -> | |
| _delegate.call(@, events) | |
| @bindShortCuts() | |
| bindShortCuts: -> | |
| for key, method of _.result(@, "shortCuts") |
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
| do (Backbone) -> | |
| _.extend Backbone.Marionette.Application::, | |
| register: (instance, id) -> | |
| @_registry ?= {} | |
| @_registry[id] = instance | |
| unregister: (instance, id) -> | |
| delete @_registry[id] |
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
| CanSing = | |
| sing: -> | |
| console.log "I am #{@name} la la la" | |
| include = (ctr, mixin) -> | |
| console.log "including", ctr | |
| for key of mixin | |
| ctr.prototype[key] = mixin[key] | |
| class Man |
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
| ## /backbone/apps | |
| ## /backbone/entities | |
| ## /backbone/mixins | |
| ## /backbone/components | |
| ## Example Component as a class instantiated from an app's controller | |
| ## /backbone/components/pattern_selector/pattern_selector.js | |
| @YOURAPP.module "Components", (Components, App, Backbone, Marionette, $, _) -> | |
| class Components.PatternSelector |
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
| var FadeTransitionRegion = Backbone.Marionette.Region.extend({ | |
| show: function(view){ | |
| this.ensureEl(); | |
| view.render(); | |
| this.close(function() { | |
| if (this.currentView && this.currentView !== view) { return; } | |
| this.currentView = view; |