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
Eugene Shen
todomvc
Commits
5490f4de
Commit
5490f4de
authored
Jun 19, 2014
by
Duilio Protti
Committed by
Sindre Sorhus
Jun 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close GH-920: Typescript-backbone: do not create item on empty input. Fixes #919
parent
d14b9463
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
labs/architecture-examples/typescript-backbone/js/app.js
labs/architecture-examples/typescript-backbone/js/app.js
+6
-6
labs/architecture-examples/typescript-backbone/js/app.ts
labs/architecture-examples/typescript-backbone/js/app.ts
+6
-5
No files found.
labs/architecture-examples/typescript-backbone/js/app.js
View file @
5490f4de
...
...
@@ -179,14 +179,14 @@ var TodoView = (function (_super) {
// If you hit `enter`, we're through editing the item.
TodoView
.
prototype
.
updateOnEnter
=
function
(
e
)
{
if
(
e
.
which
==
TodoView
.
ENTER_KEY
)
if
(
e
.
which
==
=
TodoView
.
ENTER_KEY
)
this
.
close
();
};
// If you're pressing `escape` we revert your change by simply leaving
// the `editing` state.
TodoView
.
prototype
.
revertOnEscape
=
function
(
e
)
{
if
(
e
.
which
==
TodoView
.
ESC_KEY
)
{
if
(
e
.
which
==
=
TodoView
.
ESC_KEY
)
{
this
.
$el
.
removeClass
(
'
editing
'
);
// Also reset the hidden input back to the original value.
...
...
@@ -285,10 +285,10 @@ var AppView = (function (_super) {
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
AppView
.
prototype
.
createOnEnter
=
function
(
e
)
{
if
(
e
.
keyCode
!=
13
)
return
;
Todos
.
create
(
this
.
newAttributes
()
);
this
.
input
.
val
(
''
);
if
(
e
.
which
===
TodoView
.
ENTER_KEY
&&
this
.
input
.
val
().
trim
())
{
Todos
.
create
(
this
.
newAttributes
())
;
this
.
input
.
val
(
''
);
}
};
// Clear all done todo items, destroying their models.
...
...
labs/architecture-examples/typescript-backbone/js/app.ts
View file @
5490f4de
...
...
@@ -238,13 +238,13 @@ class TodoView extends Backbone.View {
// If you hit `enter`, we're through editing the item.
updateOnEnter
(
e
)
{
if
(
e
.
which
==
TodoView
.
ENTER_KEY
)
this
.
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
)
{
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
'
));
...
...
@@ -348,9 +348,10 @@ class AppView extends Backbone.View {
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
createOnEnter
(
e
)
{
if
(
e
.
keyCode
!=
13
)
return
;
Todos
.
create
(
this
.
newAttributes
());
this
.
input
.
val
(
''
);
if
(
e
.
which
===
TodoView
.
ENTER_KEY
&&
this
.
input
.
val
().
trim
())
{
Todos
.
create
(
this
.
newAttributes
());
this
.
input
.
val
(
''
);
}
}
// Clear all done todo items, destroying their models.
...
...
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