Skip to content

Commit

Permalink
atmajs: cleanup
Browse files Browse the repository at this point in the history
- Blur saves instead of discarding changes
- Whitespace consistency
- Pass JSHint
  • Loading branch information
passy committed Nov 3, 2013
1 parent dd9c2c6 commit 569c2b7
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 53 deletions.
8 changes: 0 additions & 8 deletions labs/architecture-examples/atmajs/build.js

This file was deleted.

4 changes: 2 additions & 2 deletions labs/architecture-examples/atmajs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -91,4 +91,4 @@
<script src="js/app.js"></script>

</body>
</html>
</html>
5 changes: 3 additions & 2 deletions labs/architecture-examples/atmajs/js/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*global include, mask, Compo*/
/*jshint newcap:false */
/*global include, Compo */

'use strict';

Expand Down Expand Up @@ -58,4 +59,4 @@ include
});

Compo.initialize(Application, todos, document.body);
});
});
42 changes: 22 additions & 20 deletions labs/architecture-examples/atmajs/js/cntrl/input.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*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
Expand Down Expand Up @@ -33,40 +34,41 @@
},
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 : '');
}

}));

}());
}());
5 changes: 3 additions & 2 deletions labs/architecture-examples/atmajs/js/compo/filter/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +47,7 @@ include
},

Self: {
applyFilter: function (route){
applyFilter: function (route) {

this.action = _setSelectedFilter(route.current, this.model);

Expand All @@ -68,4 +69,4 @@ include
return action;
}

});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint newcap:false */
/*global include, mask, Compo*/

/*
Expand All @@ -16,10 +17,8 @@ include
mask.registerHandler(':todoList', Compo({
template: response.load.todoList,


action: '',


pipes: {

// To manage the communication within hierarchical components
Expand All @@ -41,7 +40,6 @@ include
// defined in the template and in a single tasks's template

toggleAll: function (event) {

this
.model
.each(function (task) {
Expand All @@ -51,15 +49,12 @@ include
},

taskChanged: function () {

this.model.save();
},

taskRemoved: function (event, task) {

this.model.del(task);
}
}
}));

});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint newcap:false */
/*global include, mask, Compo */

/**
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -85,6 +85,4 @@ include
return true;
}
}));


});
});
5 changes: 3 additions & 2 deletions labs/architecture-examples/atmajs/js/model/Todos.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*global Class, ruqq */
/*jshint newcap:false */
/*global Class, ruqq, include */

(function () {
'use strict';
Expand Down Expand Up @@ -59,4 +60,4 @@
}
});

}());
}());

0 comments on commit 569c2b7

Please sign in to comment.