Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Meteor app cleanup

Remove trailing whitespace
Convert to tabs
Improve readme
Update base.css
  • Loading branch information...
commit 3cdea4c13c5f4659263beb01592700c0de39fdce 1 parent e904feb
@sindresorhus sindresorhus authored
View
88 labs/architecture-examples/meteor/app.html
@@ -1,66 +1,66 @@
<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Meteor • TodoMVC</title>
</head>
<body>
- <section id="todoapp">
- {{> todoapp}}
- </section>
- <footer id="info">
- <p>Double-click to edit a todo</p>
- <p>Created by <a href="https://github.com/MStumpp">Matthias Stumpp</a></p>
- <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
- </footer>
+ <section id="todoapp">
+ {{> todoapp}}
+ </section>
+ <footer id="info">
+ <p>Double-click to edit a todo</p>
+ <p>Created by <a href="https://github.com/MStumpp">Matthias Stumpp</a></p>
+ <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
+ </footer>
</body>
<template name="todoapp">
- <header id="header">
- <h1>todos</h1>
- <input id="new-todo" placeholder="What needs to be done?" autofocus>
- </header>
- {{#if todos}}
- {{> main}}
- {{> footer}}
- {{/if}}
+ <header id="header">
+ <h1>todos</h1>
+ <input id="new-todo" placeholder="What needs to be done?" autofocus>
+ </header>
+ {{#if todos}}
+ {{> main}}
+ {{> footer}}
+ {{/if}}
</template>
<template name="main">
- <section id="main">
- <input id="toggle-all" type="checkbox" {{#unless todos_not_completed}}checked="checked"{{/unless}}>
- <label for="toggle-all">Mark all as complete</label>
- <ul id="todo-list">
- {{#each todos}}
- {{> todo}}
- {{/each}}
- </ul>
- </section>
+ <section id="main">
+ <input id="toggle-all" type="checkbox" {{#unless todos_not_completed}}checked="checked"{{/unless}}>
+ <label for="toggle-all">Mark all as complete</label>
+ <ul id="todo-list">
+ {{#each todos}}
+ {{> todo}}
+ {{/each}}
+ </ul>
+ </section>
</template>
<template name="todo">
<li class="{{#if todo_completed}}completed{{/if}}{{#if todo_editing}}editing{{/if}}">
- <div class="view">
- <input class="toggle" type="checkbox" {{#if todo_completed}}checked="checked"{{/if}}>
- <label>{{title}}</label>
- <button class="destroy"></button>
- </div>
- <input class="edit" value="{{title}}">
- </li>
+ <div class="view">
+ <input class="toggle" type="checkbox" {{#if todo_completed}}checked="checked"{{/if}}>
+ <label>{{title}}</label>
+ <button class="destroy"></button>
+ </div>
+ <input class="edit" value="{{title}}">
+ </li>
</template>
<template name="footer">
- <footer id="footer">
- <span id="todo-count"><strong>{{todos_not_completed}}</strong>
- {{#if todos_one_not_completed}}item{{else}}items{{/if}} left</span>
- <ul id="filters">
+ <footer id="footer">
+ <span id="todo-count"><strong>{{todos_not_completed}}</strong>
+ {{#if todos_one_not_completed}}item{{else}}items{{/if}} left</span>
+ <ul id="filters">
{{#each filters}}
<li>
<a class="{{#if filter_selected this}} selected {{/if}}" href="#/{{this}}">{{this}}</a>
</li>
{{/each}}
- </ul>
- {{#if todos_completed}}
- <button id="clear-completed">Clear completed ({{todos_completed}})</button>
- {{/if}}
- </footer>
-</template>
+ </ul>
+ {{#if todos_completed}}
+ <button id="clear-completed">Clear completed ({{todos_completed}})</button>
+ {{/if}}
+ </footer>
+</template>
View
64 labs/architecture-examples/meteor/app.js
@@ -19,7 +19,7 @@ if (Meteor.is_client) {
// Get selector types as array
var filters = _.keys(filter_selections);
-
+
// Bind route handlers to filter types
var routes = {};
_.each(filters, function(filter) {
@@ -27,13 +27,13 @@ if (Meteor.is_client) {
Session.set('filter', filter);
};
});
-
+
// Initialize router with routes
var router = Router(routes);
router.init();
/////////////////////////////////////////////////////////////////////////
- // The following two functions are taken from the official Meteor
+ // The following two functions are taken from the official Meteor
// "Todos" example
// The original code can be viewed at: https://github.com/meteor/meteor
/////////////////////////////////////////////////////////////////////////
@@ -43,19 +43,19 @@ if (Meteor.is_client) {
var okcancel_events = function (selector) {
return 'keyup '+selector+', keydown '+selector+', focusout '+selector;
};
-
+
// Creates an event handler for interpreting "escape", "return", and "blur"
// on a text field and calling "ok" or "cancel" callbacks.
var make_okcancel_handler = function (options) {
var ok = options.ok || function () {};
var cancel = options.cancel || function () {};
-
+
return function (evt) {
if (evt.type === 'keydown' && evt.which === 27) {
// escape = cancel
cancel.call(this, evt);
-
- } else if (evt.type === 'keyup' && evt.which === 13 ||
+
+ } else if (evt.type === 'keyup' && evt.which === 13 ||
evt.type === 'focusout') {
// blur/return/enter = ok/submit if non-empty
var value = String(evt.target.value || '');
@@ -67,19 +67,19 @@ if (Meteor.is_client) {
}
};
};
-
+
// Some helpers
-
+
// Get the number of todos completed
var todos_completed_helper = function() {
return Todos.find({completed: true}).count();
};
-
+
// Get the number of todos not completed
var todos_not_completed_helper = function() {
return Todos.find({completed: false}).count();
};
-
+
////
// Logic for the 'todoapp' partial which represents the whole app
////
@@ -88,35 +88,35 @@ if (Meteor.is_client) {
Template.todoapp.todos = function() {
return Todos.find().count();
};
-
+
Template.todoapp.events = {};
-
+
// Register key events for adding new todo
Template.todoapp.events[okcancel_events('#new-todo')] =
make_okcancel_handler({
ok: function (title, evt) {
- Todos.insert({title: $.trim(title), completed: false,
+ Todos.insert({title: $.trim(title), completed: false,
created_at: new Date().getTime()});
evt.target.value = '';
}
});
-
+
////
// Logic for the 'main' partial which wraps the actual todo list
////
-
+
// Get the todos considering the current filter type
Template.main.todos = function() {
return Todos.find(filter_selections[Session.get('filter')], {sort: {created_at: 1}});
};
-
+
Template.main.todos_not_completed = todos_not_completed_helper;
-
+
// Register click event for toggling complete/not complete button
Template.main.events = {
'click input#toggle-all': function(evt) {
var completed = true;
- if (!Todos.find({completed: false}).count()) {
+ if (!Todos.find({completed: false}).count()) {
completed = false;
}
Todos.find({}).forEach(function(todo) {
@@ -124,21 +124,21 @@ if (Meteor.is_client) {
});
}
};
-
+
////
// Logic for the 'todo' partial representing a todo
////
-
+
// True of current todo is completed, false otherwise
Template.todo.todo_completed = function() {
return this.completed;
};
-
+
// Get the current todo which is in editing mode, if any
Template.todo.todo_editing = function() {
return Session.equals('editing_todo', this._id);
};
-
+
// Register events for toggling todo's state, editing mode and destroying a todo
Template.todo.events = {
'click input.toggle': function() {
@@ -151,7 +151,7 @@ if (Meteor.is_client) {
Todos.remove(this._id);
}
};
-
+
// Register key events for updating title of an existing todo
Template.todo.events[okcancel_events('li.editing input.edit')] =
make_okcancel_handler({
@@ -164,34 +164,34 @@ if (Meteor.is_client) {
Todos.remove(this._id);
}
});
-
+
////
// Logic for the 'footer' partial
////
Template.footer.todos_completed = todos_completed_helper;
-
+
Template.footer.todos_not_completed = todos_not_completed_helper;
-
+
// True if exactly one todo is not completed, false otherwise
// Used for handling pluralization of "item"/"items" word
Template.footer.todos_one_not_completed = function() {
return Todos.find({completed: false}).count() == 1;
};
-
+
// Prepare array with keys of filter_selections only
Template.footer.filters = filters;
-
+
// True if the requested filter type is currently selected,
// false otherwise
- Template.footer.filter_selected = function(type) {
+ Template.footer.filter_selected = function(type) {
return Session.equals('filter', type);
};
-
+
// Register click events for clearing completed todos
Template.footer.events = {
'click button#clear-completed': function() {
Todos.remove({completed: true});
}
};
-};
+}
View
4 labs/architecture-examples/meteor/client/css/app.css
@@ -1,5 +1,3 @@
-/* base.css overrides */
-
#filters li a {
- text-transform:capitalize;
+ text-transform: capitalize;
}
View
4 labs/architecture-examples/meteor/client/css/base.css 100644 → 100755
@@ -403,4 +403,8 @@ label[for='toggle-all'] {
#todo-list li .toggle {
background: none;
}
+}
+
+.hidden{
+ display:none;
}
View
10 labs/architecture-examples/meteor/client/lib/base.js
@@ -1,7 +1,7 @@
(function( window ) {
- 'use strict';
+ 'use strict';
- if ( location.hostname === 'todomvc.com' ) {
- var _gaq=[['_setAccount','UA-31081062-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'));
- }
-})( window );
+ if ( location.hostname === 'todomvc.com' ) {
+ var _gaq=[['_setAccount','UA-31081062-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'));
+ }
+})( window );
View
24 labs/architecture-examples/meteor/readme.md
@@ -1,31 +1,23 @@
-Meteor TodoMVC
----------------
+# Meteor TodoMVC app
A todo app built using [Meteor](http://meteor.com), inspired by [TodoMVC](https://github.com/addyosmani/todomvc).
-Demo online: http://todomvcapp.meteor.com
+[Demo](http://todomvcapp.meteor.com)
-Setup
-=======
+
+## Setup
* Install Meteor ```$ curl install.meteor.com | /bin/sh```
* $ cd meteor
* $ meteor
-The app should now be running on http://localhost:3000/
+The app should now be running on http://localhost:3000
-To deploy to meteor.com simply do this:
+To deploy to meteor.com simply run:
```$ meteor deploy myapp.meteor.com```
-Credits
-=======
-
-- Stylesheet from [TodoMVC](https://github.com/addyosmani/todomvc)
-- Meteor from [Meteor](http://meteor.com)
-- This app by [MStumpp](https://github.com/MStumpp)
-License
-=======
+## Credits
-Public Domain
+Created by [MStumpp](https://github.com/MStumpp)
Please sign in to comment.
Something went wrong with that request. Please try again.