Commit 839abc9a authored by goldledoigt's avatar goldledoigt

speed of rendering + show/hide clear button + css fix

parent c3992424
...@@ -21,6 +21,7 @@ div, h1, span { ...@@ -21,6 +21,7 @@ div, h1, span {
h1 { h1 {
margin: 0; margin: 0;
line-height: 1;
font-size: 36px; font-size: 36px;
text-align: center; text-align: center;
padding: 20px 0 30px; padding: 20px 0 30px;
...@@ -58,9 +59,11 @@ input[type="text"] { ...@@ -58,9 +59,11 @@ input[type="text"] {
.row span { .row span {
cursor: pointer; cursor: pointer;
margin-left: 5px;
} }
.row span.checked { .row span.checked {
color: #777777;
text-decoration: line-through; text-decoration: line-through;
} }
...@@ -79,7 +82,7 @@ input[type="text"] { ...@@ -79,7 +82,7 @@ input[type="text"] {
.x-toolbar button { .x-toolbar button {
float: right; float: right;
width: 120px; width: 170px;
border: 0 none; border: 0 none;
color: #555555; color: #555555;
cursor: pointer; cursor: pointer;
......
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
</head> </head>
<body> <body>
<div id="todo"></div> <div id="todo">
<h1>Todos</h1>
<input type="text" id="taskfield" placeholder="What needs to be done?" />
</div>
<div class="credits"> <div class="credits">
Credits:<br /><a href="http://revolunet.com/">Revolunet</a> Credits:<br /><a href="http://revolunet.com/">Revolunet</a>
</div> </div>
......
...@@ -9,10 +9,8 @@ Ext.application({ ...@@ -9,10 +9,8 @@ Ext.application({
Ext.create('Ext.container.Container', { Ext.create('Ext.container.Container', {
renderTo: 'todo', renderTo: 'todo',
items: [{ items: [{
xtype: 'container', xtype: 'taskField',
html: '<h1>Todos</h1>' contentEl: 'taskfield'
}, {
xtype: 'taskField'
}, { }, {
xtype: 'taskList' xtype: 'taskList'
}, { }, {
......
...@@ -63,21 +63,30 @@ Ext.define('Todo.controller.Tasks', { ...@@ -63,21 +63,30 @@ Ext.define('Todo.controller.Tasks', {
}, },
onStoreDataChanged: function() { onStoreDataChanged: function() {
var info = '', var info = '', text = '',
store = this.getTasksStore(), store = this.getTasksStore(),
totalCount = store.getCount(),
toolbar = this.getTaskToolbar(), toolbar = this.getTaskToolbar(),
button = toolbar.items.first(),
container = toolbar.items.last(), container = toolbar.items.last(),
records = store.queryBy(function(record) { records = store.queryBy(function(record) {
return !record.get('checked'); return !record.get('checked');
}), }),
count = records.getCount(); count = records.getCount(),
checkedCount = totalCount - count;
if (count) { if (count) {
info = count + ' item' + (count > 1 ? 's' : '') + ' left.'; info = '<b>' + count + '</b> item' + (count > 1 ? 's' : '') + ' left.';
}
if (checkedCount) {
text = 'Clear '+ checkedCount +' completed item' + (checkedCount > 1 ? 's' : '');
} }
container.update(info); container.update(info);
toolbar.setVisible(store.getCount()); button.setText(text);
button.setVisible(checkedCount);
toolbar.setVisible(totalCount);
} }
}); });
Ext.define('Todo.view.TaskField' , { Ext.define('Todo.view.TaskField' , {
enableKeyEvents: true, enableKeyEvents: true,
alias : 'widget.taskField', alias : 'widget.taskField',
extend: 'Ext.form.TextField',
emptyText: 'What needs to be done?' extend: 'Ext.Component',
emptyText: 'What needs to be done?',
afterRender: function() {
this.callParent(arguments);
this.field = this.el.first();
this.field.on('keyup', this.onKeyup, this);
},
onKeyup: function(event) {
this.fireEvent('keyup', this, event);
},
getValue: function() {
return this.field.dom.value;
},
setValue: function(value) {
this.field.dom.value = value;
},
reset: function() {
this.setValue('');
}
}); });
...@@ -4,7 +4,7 @@ Ext.define('Todo.view.TaskToolbar' , { ...@@ -4,7 +4,7 @@ Ext.define('Todo.view.TaskToolbar' , {
alias : 'widget.taskToolbar', alias : 'widget.taskToolbar',
items: [{ items: [{
xtype: 'button', xtype: 'button',
text: 'Clear completed' hidden: true
}, { }, {
xtype: 'container' xtype: 'container'
}] }]
......
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