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
# handle ajax events (loading and auth errors) | |
$(document).ajaxStart -> | |
settings = lines: 12, length: 6, width: 4, radius: 8, trail: 75, color: '#fff' | |
$('.loading-main').html new r.ui.spinner( settings ).spin().el | |
$('[data-section=logo]').addClass('loading') | |
$(document).ajaxStop -> | |
$('[data-section=logo]').removeClass('loading') | |
$(document).ajaxComplete (e, xhr, options) -> | |
r.errorHandler.handle(xhr) |
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
it "calls response when a button is clicked", -> | |
spyOn @view, 'clickAction' | |
@view.$el.find('button.yes').click() | |
expect(@view.clickAction).toHaveBeenCalled() | |
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
initialize: (models, @options) -> | |
@.on 'all', (ev, route) -> | |
if route is 'activity' | |
console.log ev, route | |
return |
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
# backbone fetch + async lib helper method, automatically routes | |
# the callback from success/error to the async required callback | |
async.fetch = (model) -> | |
return (callback) -> | |
model.fetch | |
success: (model, response) -> | |
callback null, model | |
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
//in your application, rather than using window.location to get the current url | |
App.getLocation = function(){ | |
return window.location.protocol + '//' + window.location.host | |
+ '/' + Backbone.history.options.root + Backbone.history.getFragment() | |
} |
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
Backbone.history.start({ | |
pushState: Modernizr.history, | |
silent: true | |
}); | |
if (!Modernizr.history) { | |
rootLength = Backbone.history.options.root.length; | |
fragment = window.location.pathname.substr(rootLength); | |
search = window.location.search; | |
return Backbone.history.navigate(fragment + search, { |
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
### | |
Example view usage | |
### | |
# add popovers to all elements | |
# with the popover class, but | |
# don't trigger the fuckers |
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
getSteps: () -> | |
# hold the steps for this test in a collection | |
@stepCollection = new StepCollection({ testId: @testModel.get('_id') }) | |
# when a step is added to the collection create a new step view | |
@stepCollection.bind 'all', @added | |
# fetch the collection |
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
checkTurk: () -> | |
# If the turk browser chars do not match assignment requirements, redirect | |
requirements = @assignmentModel.get('requirements') | |
if /\d/.test(requirements.browser) is true and requirements.browser != (@browser.browser + @browser.version) | |
new JobHoldingView({ assignmentId: @assignment, state: @state, browser: @browser }) | |
# or when the version is not required but the browser doesn't match | |
else if /\d/.test(requirements.browser) is false and requirements.browser != @browser.browser |
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
checkTurk: () -> | |
# If the turk browser chars do not match assignment requirements, redirect | |
requirements = @assignmentModel.get('requirements') | |
if /\d/.test(requirements.browser) is true and requirements.browser != (@browser.browser + @browser.version) | |
# The beef is requirements does not appear in the view | |
new JobHoldingView({ assignmentId: @assignment, state: @state, browser: @browser, requirements: 'lol' }) | |
NewerOlder