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
8e1adcf4
Commit
8e1adcf4
authored
May 14, 2012
by
Rhsy
Committed by
Sindre Sorhus
May 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close GH-169: inline makeEditable for PlastronJS.
parent
34674022
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
29 deletions
+14
-29
labs/architecture-examples/plastronjs/js/controllers/todocontrol.js
...tecture-examples/plastronjs/js/controllers/todocontrol.js
+4
-19
labs/architecture-examples/plastronjs/template/templates.soy
labs/architecture-examples/plastronjs/template/templates.soy
+10
-10
No files found.
labs/architecture-examples/plastronjs/js/controllers/todocontrol.js
View file @
8e1adcf4
...
...
@@ -54,13 +54,15 @@ todomvc.todocontrol.prototype.enterDocument = function() {
model
.
dispose
();
},
'
destroy
'
);
var
inputEl
=
this
.
getEls
(
'
.edit
'
)[
0
];
// Dblclick to edit
this
.
on
(
goog
.
events
.
EventType
.
DBLCLICK
,
function
(
e
)
{
this
.
makeEditable
(
true
);
goog
.
dom
.
classes
.
add
(
this
.
getElement
(),
'
editing
'
);
inputEl
.
value
=
model
.
get
(
'
title
'
);
inputEl
.
select
();
},
'
view
'
);
// Save on edit
var
inputEl
=
this
.
getEls
(
'
.edit
'
)[
0
];
this
.
on
(
goog
.
events
.
EventType
.
KEYUP
,
function
(
e
)
{
if
(
e
.
keyCode
===
goog
.
events
.
KeyCodes
.
ENTER
)
{
model
.
set
(
'
title
'
,
inputEl
.
value
);
...
...
@@ -71,20 +73,3 @@ todomvc.todocontrol.prototype.enterDocument = function() {
model
.
set
(
'
title
'
,
inputEl
.
value
);
},
'
edit
'
);
};
/**
* make (un)editable
*
* @param {boolean} editable whether to make editable.
*/
todomvc
.
todocontrol
.
prototype
.
makeEditable
=
function
(
editable
)
{
var
inputEl
=
this
.
getEls
(
'
.edit
'
)[
0
];
goog
.
dom
.
classes
.
enable
(
this
.
getElement
(),
'
editing
'
,
editable
);
if
(
editable
)
{
inputEl
.
value
=
this
.
getModel
().
get
(
'
title
'
);
inputEl
.
select
();
}
};
\ No newline at end of file
labs/architecture-examples/plastronjs/template/templates.soy
View file @
8e1adcf4
...
...
@@ -4,19 +4,19 @@
* @param model
*/
{template .todoItem}
<li {if $model['completed']}class="completed"{/if}>
<div class="view">
<input class="toggle" type="checkbox" {if $model['completed']}checked{/if}>
<label>{$model['title']}</label>
<button class="destroy"></button>
</div>
<input class="edit">
</li>
<li {if $model['completed']}class="completed"{/if}>
<div class="view">
<input class="toggle" type="checkbox" {if $model['completed']}checked{/if}>
<label>{$model['title']}</label>
<button class="destroy"></button>
</div>
<input class="edit">
</li>
{/template}
/**
* @param left
*/
{template .itemsLeft}
<strong>{$left}</strong> item{if $left != 1}s{/if} left
{/template}
\ No newline at end of file
<strong>{$left}</strong> item{if $left != 1}s{/if} left
{/template}
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