Commit 569c2b74 authored by Pascal Hartig's avatar Pascal Hartig

atmajs: cleanup

- Blur saves instead of discarding changes
- Whitespace consistency
- Pass JSHint
parent dd9c2c6b
module.exports = {
action: 'build',
file: 'index.html',
outputMain: 'build/index.html',
outputSources: 'build/lib/',
includejsFile: 'atma-',
minify: true
};
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html lang="en" data-framework="atmajs"> <html lang="en" data-framework="atmajs">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Template • TodoMVC</title> <title>Atma.js • TodoMVC</title>
<link rel="stylesheet" href="bower_components/todomvc-common/base.css"> <link rel="stylesheet" href="bower_components/todomvc-common/base.css">
</head> </head>
<body> <body>
...@@ -91,4 +91,4 @@ ...@@ -91,4 +91,4 @@
<script src="js/app.js"></script> <script src="js/app.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
/*global include, mask, Compo*/ /*jshint newcap:false */
/*global include, Compo */
'use strict'; 'use strict';
...@@ -58,4 +59,4 @@ include ...@@ -58,4 +59,4 @@ include
}); });
Compo.initialize(Application, todos, document.body); Compo.initialize(Application, todos, document.body);
}); });
\ No newline at end of file
/*global include, mask, Compo */ /*jshint newcap:false */
/*global mask, Compo */
/** /**
* Extend INPUT tag to edit a todo's title * Extend INPUT tag to edit a todo's title
* - format string * - format string
* - complete edit on ENTER * - complete edit on ENTER
* - cancel edit on BLUR * - complete edit on BLUR
* *
* Used as * Used as
* - a main application's input * - a main application's input
...@@ -33,35 +34,36 @@ ...@@ -33,35 +34,36 @@
}, },
events: { events: {
'keydown': function (event) { 'keydown': function (event) {
switch (event.which) { switch (event.which) {
case ENTER_KEY: case ENTER_KEY:
var value = this.$.val().trim(); this.save();
this.$.trigger('enter', value);
this.afterEdit();
// prevent IE from button click - `Clear Completed` // prevent IE from button click - `Clear Completed`
event.preventDefault(); event.preventDefault();
break; break;
case ESCAPE_KEY: case ESCAPE_KEY:
this.cancel(); this.cancel();
break; break;
} }
}, },
'blur': 'cancel' 'blur': 'save'
}, },
focus: function () { focus: function focus() {
this.$.focus(); this.$.focus();
}, },
cancel: function () { cancel: function cancel() {
this.$.trigger('cancel'); this.$.trigger('cancel');
this.afterEdit(); this.afterEdit();
}, },
save: function save() {
var value = this.$.val().trim();
this.$.trigger('enter', value);
this.afterEdit();
},
afterEdit: function () { afterEdit: function () {
this.$.val(this.attr.preserve ? this.model.title : ''); this.$.val(this.attr.preserve ? this.model.title : '');
...@@ -69,4 +71,4 @@ ...@@ -69,4 +71,4 @@
})); }));
}()); }());
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
include include
.load('filter.mask::Template') .load('filter.mask::Template')
.done(function (resp) { .done(function (resp) {
'use strict';
// `Compo` function creates components constructor, // `Compo` function creates components constructor,
// but it doesnt have ClassJS features, like inhertince and // but it doesnt have ClassJS features, like inhertince and
...@@ -46,7 +47,7 @@ include ...@@ -46,7 +47,7 @@ include
}, },
Self: { Self: {
applyFilter: function (route){ applyFilter: function (route) {
this.action = _setSelectedFilter(route.current, this.model); this.action = _setSelectedFilter(route.current, this.model);
...@@ -68,4 +69,4 @@ include ...@@ -68,4 +69,4 @@ include
return action; return action;
} }
}); });
\ No newline at end of file
/*jshint newcap:false */
/*global include, mask, Compo*/ /*global include, mask, Compo*/
/* /*
...@@ -16,10 +17,8 @@ include ...@@ -16,10 +17,8 @@ include
mask.registerHandler(':todoList', Compo({ mask.registerHandler(':todoList', Compo({
template: response.load.todoList, template: response.load.todoList,
action: '', action: '',
pipes: { pipes: {
// To manage the communication within hierarchical components // To manage the communication within hierarchical components
...@@ -41,7 +40,6 @@ include ...@@ -41,7 +40,6 @@ include
// defined in the template and in a single tasks's template // defined in the template and in a single tasks's template
toggleAll: function (event) { toggleAll: function (event) {
this this
.model .model
.each(function (task) { .each(function (task) {
...@@ -51,15 +49,12 @@ include ...@@ -51,15 +49,12 @@ include
}, },
taskChanged: function () { taskChanged: function () {
this.model.save(); this.model.save();
}, },
taskRemoved: function (event, task) { taskRemoved: function (event, task) {
this.model.del(task); this.model.del(task);
} }
} }
})); }));
});
});
\ No newline at end of file
/*jshint newcap:false */
/*global include, mask, Compo */ /*global include, mask, Compo */
/** /**
...@@ -17,14 +18,14 @@ include ...@@ -17,14 +18,14 @@ include
.done(function (response) { .done(function (response) {
'use strict'; 'use strict';
var state_VIEW = ''; var STATE_VIEW = '';
var state_EDIT = 'editing'; var STATE_EDIT = 'editing';
mask.registerHandler(':todoTask', Compo({ mask.registerHandler(':todoTask', Compo({
//= Properties //= Properties
state: state_VIEW, state: STATE_VIEW,
//= Component Definition //= Component Definition
...@@ -52,9 +53,9 @@ include ...@@ -52,9 +53,9 @@ include
return [this.model]; return [this.model];
}, },
edit: function (){ edit: function () {
this.state = state_EDIT; this.state = STATE_EDIT;
this.compos.input.focus(); this.compos.input.focus();
// stop signal propagation (example purpose) // stop signal propagation (example purpose)
...@@ -66,11 +67,10 @@ include ...@@ -66,11 +67,10 @@ include
input: 'compo: todo:input' input: 'compo: todo:input'
}, },
//= Private Methods //= Private Methods
_editEnd: function () { _editEnd: function () {
this.state = state_VIEW; this.state = STATE_VIEW;
}, },
_isVisible: function (completed, action) { _isVisible: function (completed, action) {
...@@ -85,6 +85,4 @@ include ...@@ -85,6 +85,4 @@ include
return true; return true;
} }
})); }));
});
});
\ No newline at end of file
/*global Class, ruqq */ /*jshint newcap:false */
/*global Class, ruqq, include */
(function () { (function () {
'use strict'; 'use strict';
...@@ -59,4 +60,4 @@ ...@@ -59,4 +60,4 @@
} }
}); });
}()); }());
\ No newline at end of file
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