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
| // 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
| ## 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
| myTemplateHelpers = { | |
| foo: "foo", | |
| bar: function(){} | |
| } | |
| $("#something").kendoTreeView({ | |
| templateHelpers: myTemplateHelpers, | |
| template: JST["path/to/template"] // this is a 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
| #= require support/spec_helper | |
| class View extends App.Views.ItemView | |
| template: "tooltips" | |
| describe "Tooltip Concerns", -> | |
| beforeEach -> | |
| @view = new View | |
| @view.onRender = => | |
| @tooltip = sinon.spy(@view.ui.tooltips, "tooltip") |
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 Views.CompositeView extends Marionette.CompositeView | |
| itemViewEventPrefix: "childview" | |
| itemViewOptions: (model, index) -> | |
| options = {} | |
| options.tagName = "tr" if @itemViewContainer is "tbody" | |
| options | |
| class Views.CollectionView extends Marionette.CollectionView | |
| itemViewEventPrefix: "childview" |
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
| showRealView: (realView, loadingView, config) -> | |
| xhrs = App.request "fetched:entities", config.entities | |
| ## ...after the entities are successfully fetched, execute this callback | |
| $.when(xhrs...).done => | |
| ## ================================================================ ## | |
| ## If the region we are trying to insert is not the loadingView then | |
| ## we know the user has navigated to a different page while the loading | |
| ## view was still open. In that case, we know to manually close the original | |
| ## view so its controller is also closed. We also prevent showing the real |
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
| ##Folder structure | |
| /backbone | |
| app.js | |
| /apps | |
| /entities | |
| /lib | |
| ##Inside Apps | |
| /apps |
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
| ## this is the mixin | |
| Concerns.Kendo = | |
| onBeforeClose: -> | |
| @destroyKendos() | |
| destroyKendos: -> | |
| for key, el of @ui | |
| widget = kendo.widgetInstance(el, kendo.ui) | |
| widget?.destroy?() | |
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 Views.CompositeView extends Marionette.CompositeView | |
| itemViewEventPrefix: "childview" | |
| itemViewOptions: (model, index) -> | |
| options = {} | |
| options.tagName = "tr" if @isTbody() | |
| options.tagName = "li" if @isUl() | |
| options.tableColumns = @$el.find("th").length if @isTbody() | |
| options |