Skip to content

Commit

Permalink
speed of rendering + show/hide clear button + css fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goldledoigt committed Nov 9, 2011
1 parent c399242 commit 839abc9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 13 deletions.
5 changes: 4 additions & 1 deletion todo-example/extjs/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ div, h1, span {

h1 {
margin: 0;
line-height: 1;
font-size: 36px;
text-align: center;
padding: 20px 0 30px;
Expand Down Expand Up @@ -58,9 +59,11 @@ input[type="text"] {

.row span {
cursor: pointer;
margin-left: 5px;
}

.row span.checked {
color: #777777;
text-decoration: line-through;
}

Expand All @@ -79,7 +82,7 @@ input[type="text"] {

.x-toolbar button {
float: right;
width: 120px;
width: 170px;
border: 0 none;
color: #555555;
cursor: pointer;
Expand Down
5 changes: 4 additions & 1 deletion todo-example/extjs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
</head>

<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">
Credits:<br /><a href="http://revolunet.com/">Revolunet</a>
</div>
Expand Down
6 changes: 2 additions & 4 deletions todo-example/extjs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ Ext.application({
Ext.create('Ext.container.Container', {
renderTo: 'todo',
items: [{
xtype: 'container',
html: '<h1>Todos</h1>'
}, {
xtype: 'taskField'
xtype: 'taskField',
contentEl: 'taskfield'
}, {
xtype: 'taskList'
}, {
Expand Down
17 changes: 13 additions & 4 deletions todo-example/extjs/js/controller/Tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,30 @@ Ext.define('Todo.controller.Tasks', {
},

onStoreDataChanged: function() {
var info = '',
var info = '', text = '',
store = this.getTasksStore(),
totalCount = store.getCount(),
toolbar = this.getTaskToolbar(),
button = toolbar.items.first(),
container = toolbar.items.last(),
records = store.queryBy(function(record) {
return !record.get('checked');
}),
count = records.getCount();
count = records.getCount(),
checkedCount = totalCount - 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);
toolbar.setVisible(store.getCount());
button.setText(text);
button.setVisible(checkedCount);
toolbar.setVisible(totalCount);
}

});
31 changes: 29 additions & 2 deletions todo-example/extjs/js/view/TaskField.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
Ext.define('Todo.view.TaskField' , {

enableKeyEvents: true,

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('');
}

});
2 changes: 1 addition & 1 deletion todo-example/extjs/js/view/TaskToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Ext.define('Todo.view.TaskToolbar' , {
alias : 'widget.taskToolbar',
items: [{
xtype: 'button',
text: 'Clear completed'
hidden: true
}, {
xtype: 'container'
}]
Expand Down

0 comments on commit 839abc9

Please sign in to comment.