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
| #!/usr/bin/env ruby | |
| if `git diff --cached spec` =~ /,\s?(:focus|focus:\s?true|:focus\s?=>\s?true)/ | |
| puts "\e[31mRemove your :focus tags before committing!\e[0m" | |
| exit 1 | |
| end | |
| if `git diff --cached spec` =~ /console\.log/ | |
| puts "\e[31mRemove your console.log before committing!\e[0m" | |
| exit 1 |
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 gulp = require('gulp'); | |
| var coffee = require('gulp-coffee'); | |
| var concat = require('gulp-concat'); | |
| var jade = require('gulp-jade'); | |
| var batmanTemplates = require("gulp-batman-templates") | |
| gulp.task('default', function(){ | |
| gulp.watch('./**/*', ["build", "html", "javascripts", "stylesheets", "finalize"]) | |
| }); |
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 App.Sale extends Batman.Model | |
| @hasMany 'sale_items' | |
| @accessor 'total_price', -> | |
| memo = 0 | |
| # adds 'sale_items' and each item as a source | |
| @get('sale_items').forEach (item) -> | |
| memo += item.get('subtotal') | |
| memo | |
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 gulp = require('gulp'); | |
| var coffee = require('gulp-coffee'); | |
| var concat = require('gulp-concat'); | |
| var jade = require('gulp-jade'); | |
| var batmanTemplates = require("gulp-batman-templates") | |
| gulp.task('default', function(){ | |
| gulp.watch('./**/*', ["build", "html", "finalize"]) | |
| }); |
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
| # Taken from Batman.RailsStorage https://github.com/batmanjs/batman/blob/master/src/extras/batman.rails.coffee#L62 | |
| # | |
| # Usage: | |
| # #= require ./json_storage | |
| # class MyApp.Model extends Batman.Model | |
| # @persist Batman.JSONStorage | |
| # | |
| class Batman.JSONStorage extends Batman.RestStorage | |
| # override the default URL functions to add .json: | |
| urlForRecord: -> @_addJsonExtension(super) |
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
| # Props to @theberg for making this | |
| # | |
| # usage: | |
| # | |
| # select data-view='Select2View' data-view-bind='item.option_id' | |
| # option value='' None | |
| # option data-foreach-opt='Option.all' data-bind='opt.name' data-bind-value='opt.id' | |
| # | |
| class App.Select2View extends Batman.View | |
| @option 'bind', 'placeholder' |
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
| Loader = | |
| show: -> | |
| hide: -> | |
| window.activeXhrCount = 0 | |
| window.globalLoaderEnabled = true | |
| $(document).ajaxSend -> | |
| window.activeXhrCount++ | |
| Loader.show() | |
| .ajaxComplete -> |
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 gulp = require('gulp'); | |
| var coffee = require('gulp-coffee'); | |
| var concat = require('gulp-concat'); | |
| var jade = require('gulp-jade'); | |
| var batmanTemplates = require("gulp-batman-templates") | |
| gulp.task('default', function(){ | |
| gulp.watch('./**/*', ["build", "html", "finalize"]) | |
| }); |
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 MyApp.Thing extends Batman.Model | |
| constructor: -> | |
| super | |
| # Whenever someProperty changes, capitalized property will be updated | |
| @observe 'someProperty', (newValue, oldValue) -> | |
| @set('capitalizedProperty', newValue?.toUpperCase()) |
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 App.Model extends Batman.Model | |
| toJSON: -> | |
| builtJSON = super | |
| builtJSON.nested_items_attributes = builtJSON.nested_items | |
| delete builtJSON.nested_items | |
| builtJSON |