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