Commit ac6d76c8 authored by gstof's avatar gstof

Batman: fix mixed indentation that cause coffee to generate incorrect js

parent 4dbafb90
......@@ -4,7 +4,7 @@ class Alfred extends Batman.App
@route '/active', 'todos#active'
class Alfred.TodosController extends Batman.Controller
constructor: ->
constructor: ->
super
@set('newTodo', new Alfred.Todo(completed: false))
......@@ -14,74 +14,74 @@ class Alfred.TodosController extends Batman.Controller
@accessor 'currentTodos', -> Alfred.Todo.get(@get('currentTodoSet'))
all: ->
@set('currentTodoSet', 'all')
completed: ->
@set 'currentTodoSet', 'completed'
@render(source: 'todos/all')
active: ->
@set 'currentTodoSet', 'active'
@render(source: 'todos/all')
createTodo: ->
@get('newTodo').save (err, todo) =>
if err
throw err unless err instanceof Batman.ErrorsSet
else
@set 'newTodo', new Alfred.Todo(completed: false, title: "")
todoDoneChanged: (node, event, context) ->
todo = context.get('todo')
todo.save (err) ->
throw err if err && !err instanceof Batman.ErrorsSet
destroyTodo: (node, event, context) ->
todo = context.get('todo')
todo.destroy (err) -> throw err if err
toggleAll: (node, context) ->
Alfred.Todo.get('all').forEach (todo) ->
todo.set('completed', !!node.checked)
todo.save (err) ->
throw err if err && !err instanceof Batman.ErrorsSet
clearCompleted: ->
Alfred.Todo.get('completed').forEach (todo) ->
todo.destroy (err) -> throw err if err
toggleEditing: (node, event, context) ->
todo = context.get('todo')
editing = todo.set('editing', !todo.get('editing'))
if editing
input = document.getElementById("todo-input-#{todo.get('id')}")
input.focus()
else
if todo.get('title')?.length > 0
todo.save (err, todo) ->
throw err if err && !err instanceof Batman.ErrorsSet
else
todo.destroy (err, todo) ->
throw err if err
disableEditingUponSubmit: (node, event, context) ->
if Batman.DOM.events.isEnter(event)
@toggleEditing(node, event, context)
@set('currentTodoSet', 'all')
completed: ->
@set 'currentTodoSet', 'completed'
@render(source: 'todos/all')
active: ->
@set 'currentTodoSet', 'active'
@render(source: 'todos/all')
createTodo: ->
@get('newTodo').save (err, todo) =>
if err
throw err unless err instanceof Batman.ErrorsSet
else
@set 'newTodo', new Alfred.Todo(completed: false, title: "")
todoDoneChanged: (node, event, context) ->
todo = context.get('todo')
todo.save (err) ->
throw err if err && !err instanceof Batman.ErrorsSet
destroyTodo: (node, event, context) ->
todo = context.get('todo')
todo.destroy (err) -> throw err if err
toggleAll: (node, context) ->
Alfred.Todo.get('all').forEach (todo) ->
todo.set('completed', !!node.checked)
todo.save (err) ->
throw err if err && !err instanceof Batman.ErrorsSet
clearCompleted: ->
Alfred.Todo.get('completed').forEach (todo) ->
todo.destroy (err) -> throw err if err
toggleEditing: (node, event, context) ->
todo = context.get('todo')
editing = todo.set('editing', !todo.get('editing'))
if editing
input = document.getElementById("todo-input-#{todo.get('id')}")
input.focus()
else
if todo.get('title')?.length > 0
todo.save (err, todo) ->
throw err if err && !err instanceof Batman.ErrorsSet
else
todo.destroy (err, todo) ->
throw err if err
disableEditingUponSubmit: (node, event, context) ->
if Batman.DOM.events.isEnter(event)
@toggleEditing(node, event, context)
class Alfred.Todo extends Batman.Model
@encode 'title', 'completed'
@persist Batman.LocalStorage
@validate 'title', presence: true
@storageKey: 'todos-batman'
@encode 'title', 'completed'
@persist Batman.LocalStorage
@validate 'title', presence: true
@storageKey: 'todos-batman'
@classAccessor 'active', ->
@get('all').filter (todo) -> !todo.get('completed')
@classAccessor 'active', ->
@get('all').filter (todo) -> !todo.get('completed')
@classAccessor 'completed', ->
@get('all').filter (todo) -> todo.get('completed')
@classAccessor 'completed', ->
@get('all').filter (todo) -> todo.get('completed')
@wrapAccessor 'title', (core) ->
set: (key, value) -> core.set.call(@, key, value?.trim())
@wrapAccessor 'title', (core) ->
set: (key, value) -> core.set.call(@, key, value?.trim())
window.Alfred = Alfred
Alfred.run()
// Generated by CoffeeScript 1.3.3
(function() {
var Alfred,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
var Alfred,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Alfred = (function(_super) {
Alfred = (function(_super) {
__extends(Alfred, _super);
__extends(Alfred, _super);
function Alfred() {
return Alfred.__super__.constructor.apply(this, arguments);
}
Alfred.root('todos#all');
function Alfred() {
return Alfred.__super__.constructor.apply(this, arguments);
}
Alfred.route('/completed', 'todos#completed');
Alfred.root('todos#all');
Alfred.route('/active', 'todos#active');
Alfred.route('/completed', 'todos#completed');
return Alfred;
Alfred.route('/active', 'todos#active');
})(Batman.App);
return Alfred;
Alfred.TodosController = (function(_super) {
})(Batman.App);
__extends(TodosController, _super);
Alfred.TodosController = (function(_super) {
function TodosController() {
TodosController.__super__.constructor.apply(this, arguments);
this.set('newTodo', new Alfred.Todo({
completed: false
}));
}
__extends(TodosController, _super);
TodosController.prototype.routingKey = 'todos';
function TodosController() {
TodosController.__super__.constructor.apply(this, arguments);
this.set('newTodo', new Alfred.Todo({
completed: false
}));
}
TodosController.prototype.currentTodoSet = 'all';
TodosController.prototype.routingKey = 'todos';
TodosController.accessor('currentTodos', function() {
return Alfred.Todo.get(this.get('currentTodoSet'));
});
TodosController.prototype.currentTodoSet = 'all';
TodosController.prototype.all = function() {};
TodosController.accessor('currentTodos', function() {
return Alfred.Todo.get(this.get('currentTodoSet'));
});
TodosController.set('currentTodoSet', 'all');
TodosController.prototype.all = function() {
return this.set('currentTodoSet', 'all');
};
TodosController.prototype.completed = function() {
this.set('currentTodoSet', 'completed');
return this.render({
source: 'todos/all'
});
};
TodosController.prototype.completed = function() {
this.set('currentTodoSet', 'completed');
return this.render({
source: 'todos/all'
});
};
TodosController.prototype.active = function() {
this.set('currentTodoSet', 'active');
return this.render({
source: 'todos/all'
});
};
TodosController.prototype.active = function() {
this.set('currentTodoSet', 'active');
return this.render({
source: 'todos/all'
});
};
TodosController.prototype.createTodo = function() {
var _this = this;
return this.get('newTodo').save(function(err, todo) {
if (err) {
if (!(err instanceof Batman.ErrorsSet)) {
throw err;
}
} else {
return _this.set('newTodo', new Alfred.Todo({
completed: false,
title: ""
}));
TodosController.prototype.createTodo = function() {
var _this = this;
return this.get('newTodo').save(function(err, todo) {
if (err) {
if (!(err instanceof Batman.ErrorsSet)) {
throw err;
}
});
};
} else {
return _this.set('newTodo', new Alfred.Todo({
completed: false,
title: ""
}));
}
});
};
TodosController.prototype.todoDoneChanged = function(node, event, context) {
var todo;
todo = context.get('todo');
return todo.save(function(err) {
if (err && !err instanceof Batman.ErrorsSet) {
throw err;
}
});
};
TodosController.prototype.destroyTodo = function(node, event, context) {
var todo;
todo = context.get('todo');
return todo.destroy(function(err) {
if (err) {
throw err;
}
});
};
TodosController.prototype.todoDoneChanged = function(node, event, context) {
var todo;
todo = context.get('todo');
TodosController.prototype.toggleAll = function(node, context) {
return Alfred.Todo.get('all').forEach(function(todo) {
todo.set('completed', !!node.checked);
return todo.save(function(err) {
if (err && !err instanceof Batman.ErrorsSet) {
throw err;
}
});
};
});
};
TodosController.prototype.destroyTodo = function(node, event, context) {
var todo;
todo = context.get('todo');
TodosController.prototype.clearCompleted = function() {
return Alfred.Todo.get('completed').forEach(function(todo) {
return todo.destroy(function(err) {
if (err) {
throw err;
}
});
};
TodosController.prototype.toggleAll = function(node, context) {
return Alfred.Todo.get('all').forEach(function(todo) {
todo.set('completed', !!node.checked);
return todo.save(function(err) {
});
};
TodosController.prototype.toggleEditing = function(node, event, context) {
var editing, input, todo, _ref;
todo = context.get('todo');
editing = todo.set('editing', !todo.get('editing'));
if (editing) {
input = document.getElementById("todo-input-" + (todo.get('id')));
return input.focus();
} else {
if (((_ref = todo.get('title')) != null ? _ref.length : void 0) > 0) {
return todo.save(function(err, todo) {
if (err && !err instanceof Batman.ErrorsSet) {
throw err;
}
});
});
};
TodosController.prototype.clearCompleted = function() {
return Alfred.Todo.get('completed').forEach(function(todo) {
return todo.destroy(function(err) {
} else {
return todo.destroy(function(err, todo) {
if (err) {
throw err;
}
});
});
};
TodosController.prototype.toggleEditing = function(node, event, context) {
var editing, input, todo, _ref;
todo = context.get('todo');
editing = todo.set('editing', !todo.get('editing'));
if (editing) {
input = document.getElementById("todo-input-" + (todo.get('id')));
return input.focus();
} else {
if (((_ref = todo.get('title')) != null ? _ref.length : void 0) > 0) {
return todo.save(function(err, todo) {
if (err && !err instanceof Batman.ErrorsSet) {
throw err;
}
});
} else {
return todo.destroy(function(err, todo) {
if (err) {
throw err;
}
});
}
}
};
TodosController.prototype.disableEditingUponSubmit = function(node, event, context) {
if (Batman.DOM.events.isEnter(event)) {
return this.toggleEditing(node, event, context);
}
};
}
};
return TodosController;
TodosController.prototype.disableEditingUponSubmit = function(node, event, context) {
if (Batman.DOM.events.isEnter(event)) {
return this.toggleEditing(node, event, context);
}
};
})(Batman.Controller);
return TodosController;
Alfred.Todo = (function(_super) {
})(Batman.Controller);
__extends(Todo, _super);
Alfred.Todo = (function(_super) {
function Todo() {
return Todo.__super__.constructor.apply(this, arguments);
}
__extends(Todo, _super);
Todo.encode('title', 'completed');
function Todo() {
return Todo.__super__.constructor.apply(this, arguments);
}
Todo.persist(Batman.LocalStorage);
Todo.encode('title', 'completed');
Todo.validate('title', {
presence: true
});
Todo.persist(Batman.LocalStorage);
Todo.storageKey = 'todos-batman';
Todo.validate('title', {
presence: true
});
Todo.classAccessor('active', function() {
return this.get('all').filter(function(todo) {
return !todo.get('completed');
});
});
Todo.storageKey = 'todos-batman';
Todo.classAccessor('completed', function() {
return this.get('all').filter(function(todo) {
return todo.get('completed');
});
Todo.classAccessor('active', function() {
return this.get('all').filter(function(todo) {
return !todo.get('completed');
});
});
Todo.wrapAccessor('title', function(core) {
return {
set: function(key, value) {
return core.set.call(this, key, value != null ? value.trim() : void 0);
}
};
Todo.classAccessor('completed', function() {
return this.get('all').filter(function(todo) {
return todo.get('completed');
});
});
return Todo;
Todo.wrapAccessor('title', function(core) {
return {
set: function(key, value) {
return core.set.call(this, key, value != null ? value.trim() : void 0);
}
};
});
})(Batman.Model);
return Todo;
window.Alfred = Alfred;
})(Batman.Model);
Alfred.run();
window.Alfred = Alfred;
}).call(this);
Alfred.run();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment