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
5cd9e6d6
Commit
5cd9e6d6
authored
Nov 26, 2015
by
Arthur Verschaeve
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1531 from dmethvin/thorax-escape
thorax: Cancel editing with the Escape key
parents
f50d5507
66a4eee8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
.jscsrc
.jscsrc
+7
-6
examples/thorax/js/app.js
examples/thorax/js/app.js
+1
-0
examples/thorax/js/views/todo-item.js
examples/thorax/js/views/todo-item.js
+18
-6
No files found.
.jscsrc
View file @
5cd9e6d6
...
...
@@ -26,16 +26,17 @@
"excludeFiles": [
"**/node_modules/**",
"**/bower_components/**",
"examples/vanilladart/**/*.js",
"examples/duel/www/**",
"examples/duel/src/main/webapp/js/lib/**",
"**/generated/**",
"examples/ampersand/todomvc.bundle.js",
"examples/angular2/**/*.js",
"examples/polymer/elements/elements.build.js",
"examples/duel/www/**",
"examples/duel/src/main/webapp/js/lib/**",
"examples/humble/js/**",
"examples/js_of_ocaml/js/*.js",
"examples/polymer/elements/elements.build.js",
"examples/thorax/js/lib/backbone-localstorage.js",
"examples/typescript-*/js/**/*.js",
"**/generated/**",
"examples/humble/js/**"
"examples/vanilladart/**/*.js"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
...
...
examples/thorax/js/app.js
View file @
5cd9e6d6
/*global Thorax, Backbone*/
/*jshint unused:false*/
var
ENTER_KEY
=
13
;
var
ESCAPE_KEY
=
27
;
(
function
()
{
'
use strict
'
;
...
...
examples/thorax/js/views/todo-item.js
View file @
5cd9e6d6
/*global Thorax, ENTER_KEY*/
/*global Thorax, ENTER_KEY
, ESCAPE_KEY
*/
(
function
()
{
'
use strict
'
;
...
...
@@ -19,7 +19,7 @@
'
click .toggle
'
:
'
toggleCompleted
'
,
'
dblclick label
'
:
'
edit
'
,
'
click .destroy
'
:
'
clear
'
,
'
key
press .edit
'
:
'
updateOnEnt
er
'
,
'
key
up .edit
'
:
'
keyListen
er
'
,
'
blur .edit
'
:
'
close
'
,
// The "rendered" event is triggered by Thorax each time render()
// is called and the result of the template has been appended
...
...
@@ -37,11 +37,16 @@
// Switch this view into `"editing"` mode, displaying the input field.
edit
:
function
()
{
this
.
$el
.
addClass
(
'
editing
'
);
this
.
$
(
'
.edit
'
).
focus
();
this
.
$
(
'
.edit
'
).
val
(
this
.
model
.
get
(
'
title
'
)).
focus
();
},
// Close the `"editing"` mode
, saving changes to the todo
.
// Close the `"editing"` mode.
close
:
function
()
{
// If editing was cancelled, don't save
if
(
!
this
.
$el
.
hasClass
(
'
editing
'
))
{
return
;
}
var
value
=
this
.
$
(
'
.edit
'
).
val
().
trim
();
if
(
value
)
{
...
...
@@ -53,10 +58,17 @@
this
.
$el
.
removeClass
(
'
editing
'
);
},
// If you hit `enter`, we're through editing the item.
updateOnEnter
:
function
(
e
)
{
// User cancelled editing, don't update the todo.
cancelEdits
:
function
()
{
this
.
$el
.
removeClass
(
'
editing
'
);
},
// Enter completes the editing, Escape cancels it
keyListener
:
function
(
e
)
{
if
(
e
.
which
===
ENTER_KEY
)
{
this
.
close
();
}
else
if
(
e
.
which
===
ESCAPE_KEY
)
{
this
.
cancelEdits
();
}
},
...
...
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