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 Shift < ActiveRecord::Base | |
| validates :starts_at, presence: true | |
| def parsable_start_time | |
| starts_at.strftime("%-I.%M%P") if starts_at | |
| end | |
| def parsable_start_time=(time_string) | |
| self.starts_at = Chronic.parse(time_string) | |
| end |
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
| # Collection.fetch() returns a Xhr that you can store in a variable. | |
| # The request can be aborted if the Xhr readystate is 1,2 or 3. | |
| # | |
| # Note: If readystate == 3 the request has already been sent and the | |
| # server will continue to process it, the response will be ignored. | |
| class App.Routers.Posts extends Backbone.Router | |
| routes: | |
| '': 'index' | |
| ':id': 'show' |
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
| # OPTION 1: | |
| # Automatically wrap everything | |
| do -> | |
| 'use strict' | |
| return unless window.trackJs? | |
| for klass in ['View', 'Model', 'Collection', 'Router'] | |
| old = Backbone[klass] |
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
| window.MyApp = | |
| Models: {} | |
| Collections: {} | |
| Views: {} | |
| Routers: {} | |
| initialize: -> | |
| new MyApp.Routers.Items() | |
| Backbone.history.start() |
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
| addToBookmarks = -> | |
| e.preventDefault() | |
| title = document.title | |
| url = document.location.href | |
| # IE | |
| if window.external?.AddFavourite | |
| window.external.AddFavorite(url, title) | |
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
| # E.g. backbone.view.js.coffee | |
| Backbone.View::close = (remove = true) -> | |
| if remove | |
| # Remove the view element, unbinding events and destroying data | |
| @remove() | |
| else | |
| # Undelegate events and stop listening without removing the view element | |
| @undelegateEvents() | |
| @stopListening() | |
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
| // Set up the current user | |
| app.services.factory('CurrentUser', function(User) { | |
| var bootstrapCurrentUser = function() { | |
| var data = JSON.parse(currentUser); | |
| var user = new User(data); | |
| return user; | |
| } | |
| return bootstrapCurrentUser() || User.me(); |
OlderNewer