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
9fc18e15
Commit
9fc18e15
authored
Jun 24, 2014
by
Duilio Protti
Committed by
Sindre Sorhus
Jun 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close GH-924: Spine - cancel editing on escape keypress. Fixes #789
parent
5b1af514
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
16 deletions
+38
-16
architecture-examples/spine/js/app.js
architecture-examples/spine/js/app.js
+5
-5
architecture-examples/spine/js/controllers/todos.js
architecture-examples/spine/js/controllers/todos.js
+16
-2
architecture-examples/spine/js/models/todo.js
architecture-examples/spine/js/models/todo.js
+7
-9
architecture-examples/spine/src/controllers/todos.coffee
architecture-examples/spine/src/controllers/todos.coffee
+10
-0
No files found.
architecture-examples/spine/js/app.js
View file @
9fc18e15
// Generated by CoffeeScript 1.
6.3
// Generated by CoffeeScript 1.
7.1
(
function
()
{
var
TodoApp
,
__bind
=
function
(
fn
,
me
){
return
function
(){
return
fn
.
apply
(
me
,
arguments
);
};
},
...
...
@@ -43,10 +43,10 @@
this
.
routes
({
'
/:filter
'
:
function
(
param
)
{
this
.
filter
=
param
.
filter
;
/*
TODO: Need to figure out why the route doesn't trigger `change` event
*/
Todo
.
trigger
(
'
refresh
'
);
return
this
.
filters
.
removeClass
(
'
selected
'
).
filter
(
"
[href='#/
"
+
this
.
filter
+
"
']
"
).
addClass
(
'
selected
'
);
}
...
...
@@ -97,11 +97,11 @@
TodoApp
.
prototype
.
toggleAll
=
function
(
e
)
{
return
Todo
.
each
(
function
(
todo
)
{
/*
TODO: Model updateAttribute sometimes won't stick:
https://github.com/maccman/spine/issues/219
*/
todo
.
updateAttribute
(
'
completed
'
,
e
.
target
.
checked
);
return
todo
.
trigger
(
'
update
'
,
todo
);
});
...
...
architecture-examples/spine/js/controllers/todos.js
View file @
9fc18e15
// Generated by CoffeeScript 1.
6.3
// Generated by CoffeeScript 1.
7.1
(
function
()
{
var
__bind
=
function
(
fn
,
me
){
return
function
(){
return
fn
.
apply
(
me
,
arguments
);
};
},
__hasProp
=
{}.
hasOwnProperty
,
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
window
.
Todos
=
(
function
(
_super
)
{
var
ENTER_KEY
,
TPL
;
var
ENTER_KEY
,
ESCAPE_KEY
,
TPL
;
__extends
(
Todos
,
_super
);
ENTER_KEY
=
13
;
ESCAPE_KEY
=
27
;
TPL
=
Handlebars
.
compile
(
$
(
'
#todo-template
'
).
html
());
Todos
.
prototype
.
elements
=
{
...
...
@@ -21,6 +23,7 @@
'
click .destroy
'
:
'
remove
'
,
'
click .toggle
'
:
'
toggleStatus
'
,
'
dblclick label
'
:
'
edit
'
,
'
keydown .edit
'
:
'
revertEditOnEscape
'
,
'
keyup .edit
'
:
'
finishEditOnEnter
'
,
'
blur .edit
'
:
'
finishEdit
'
};
...
...
@@ -67,6 +70,17 @@
}
};
Todos
.
prototype
.
revertEdit
=
function
()
{
this
.
el
.
removeClass
(
'
editing
'
);
return
this
.
editElem
.
val
(
this
.
todo
.
title
);
};
Todos
.
prototype
.
revertEditOnEscape
=
function
(
e
)
{
if
(
e
.
which
===
ESCAPE_KEY
)
{
return
this
.
revertEdit
();
}
};
return
Todos
;
})(
Spine
.
Controller
);
...
...
architecture-examples/spine/js/models/todo.js
View file @
9fc18e15
// Generated by CoffeeScript 1.
6.3
// Generated by CoffeeScript 1.
7.1
(
function
()
{
var
_ref
,
__hasProp
=
{}.
hasOwnProperty
,
var
__hasProp
=
{}.
hasOwnProperty
,
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
window
.
Todo
=
(
function
(
_super
)
{
__extends
(
Todo
,
_super
);
function
Todo
()
{
_ref
=
Todo
.
__super__
.
constructor
.
apply
(
this
,
arguments
);
return
_ref
;
return
Todo
.
__super__
.
constructor
.
apply
(
this
,
arguments
);
}
Todo
.
configure
(
'
Todo
'
,
'
title
'
,
'
completed
'
);
...
...
@@ -29,11 +27,11 @@
};
Todo
.
destroyCompleted
=
function
()
{
var
todo
,
_i
,
_len
,
_ref
1
,
_results
;
_ref
1
=
this
.
completed
();
var
todo
,
_i
,
_len
,
_ref
,
_results
;
_ref
=
this
.
completed
();
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
1
.
length
;
_i
<
_len
;
_i
++
)
{
todo
=
_ref
1
[
_i
];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
todo
=
_ref
[
_i
];
_results
.
push
(
todo
.
destroy
());
}
return
_results
;
...
...
architecture-examples/spine/src/controllers/todos.coffee
View file @
9fc18e15
class
window
.
Todos
extends
Spine
.
Controller
ENTER_KEY
=
13
ESCAPE_KEY
=
27
TPL
=
Handlebars
.
compile
$
(
'#todo-template'
).
html
()
elements
:
...
...
@@ -9,6 +10,7 @@ class window.Todos extends Spine.Controller
'click .destroy'
:
'remove'
'click .toggle'
:
'toggleStatus'
'dblclick label'
:
'edit'
'keydown .edit'
:
'revertEditOnEscape'
'keyup .edit'
:
'finishEditOnEnter'
'blur .edit'
:
'finishEdit'
...
...
@@ -38,3 +40,11 @@ class window.Todos extends Spine.Controller
finishEditOnEnter
:
(
e
)
->
@
finishEdit
()
if
e
.
which
is
ENTER_KEY
revertEdit
:
->
@
el
.
removeClass
'editing'
@
editElem
.
val
(
@
todo
.
title
)
revertEditOnEscape
:
(
e
)
->
@
revertEdit
()
if
e
.
which
is
ESCAPE_KEY
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