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
| resortView: -> | |
| @collection.each (model, index) => | |
| view = @children.findByModel(model) | |
| @moveViewToIndex(view, index) if view._index isnt index | |
| moveViewToIndex: (view, index) -> | |
| view._index = index | |
| sibling = view.$el.siblings().eq(index) | |
| view.$el.insertBefore(sibling) |
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.sync = (method, entity, options = {}) -> | |
| ## THIS WORKS | |
| _.each ["beforeSend", "complete", "error"], (fn) -> | |
| options[fn] or= -> | |
| orig = options[fn] | |
| options[fn] = -> | |
| orig.apply(entity, arguments) | |
| methods[fn].apply(entity, arguments) |
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
| // All Backbone objects have the extend method built in. | |
| // This serves the same primary purpose as Coffeescript's extends keyword. | |
| // After all, they were actually written by the same person: Jeremey Ashkenas | |
| // Coffeescript Implementation for Backbone Model | |
| class Entities.User extends Backbone.Model | |
| defaults: | |
| firstName: "Brian" | |
| initialize: -> |
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 |
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
| ##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
| 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
| 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
| #= 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
| myTemplateHelpers = { | |
| foo: "foo", | |
| bar: function(){} | |
| } | |
| $("#something").kendoTreeView({ | |
| templateHelpers: myTemplateHelpers, | |
| template: JST["path/to/template"] // this is a function | |
| }) |