Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
600abbac
Commit
600abbac
authored
Jun 19, 2014
by
Duilio Protti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Typescript-backbone: fixes for #824
parent
9017b22b
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
9 deletions
+134
-9
labs/architecture-examples/typescript-backbone/js/app.js
labs/architecture-examples/typescript-backbone/js/app.js
+111
-5
labs/architecture-examples/typescript-backbone/js/app.ts
labs/architecture-examples/typescript-backbone/js/app.ts
+23
-4
No files found.
labs/architecture-examples/typescript-backbone/js/app.js
View file @
600abbac
This diff is collapsed.
Click to expand it.
labs/architecture-examples/typescript-backbone/js/app.ts
View file @
600abbac
...
...
@@ -179,6 +179,7 @@ class TodoView extends Backbone.View {
input
:
any
;
static
ENTER_KEY
:
number
=
13
;
static
ESC_KEY
:
number
=
27
;
constructor
(
options
?
)
{
//... is a list tag.
...
...
@@ -189,8 +190,9 @@ class TodoView extends Backbone.View {
'
click .check
'
:
'
toggleDone
'
,
'
dblclick label.todo-content
'
:
'
edit
'
,
'
click button.destroy
'
:
'
clear
'
,
'
keypress .todo-input
'
:
'
updateOnEnter
'
,
'
blur .todo-input
'
:
'
close
'
'
keypress .edit
'
:
'
updateOnEnter
'
,
'
keydown .edit
'
:
'
revertOnEscape
'
,
'
blur .edit
'
:
'
close
'
};
super
(
options
);
...
...
@@ -223,13 +225,30 @@ class TodoView extends Backbone.View {
// Close the `'editing'` mode, saving changes to the todo.
close
()
{
this
.
model
.
save
({
content
:
this
.
input
.
val
()
});
var
trimmedValue
=
this
.
input
.
val
().
trim
();
if
(
trimmedValue
)
{
this
.
model
.
save
({
content
:
trimmedValue
});
}
else
{
this
.
clear
();
}
this
.
$el
.
removeClass
(
'
editing
'
);
}
// If you hit `enter`, we're through editing the item.
updateOnEnter
(
e
)
{
if
(
e
.
keyCode
==
TodoView
.
ENTER_KEY
)
close
();
if
(
e
.
which
==
TodoView
.
ENTER_KEY
)
this
.
close
();
}
// If you're pressing `escape` we revert your change by simply leaving
// the `editing` state.
revertOnEscape
(
e
)
{
if
(
e
.
which
==
TodoView
.
ESC_KEY
)
{
this
.
$el
.
removeClass
(
'
editing
'
);
// Also reset the hidden input back to the original value.
this
.
input
.
val
(
this
.
model
.
get
(
'
content
'
));
}
}
// Remove the item, destroy the model.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment