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
40d9d467
Commit
40d9d467
authored
Mar 23, 2014
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Vue implementation to use 0.10.0
parent
e8f8532b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2445 additions
and
1503 deletions
+2445
-1503
labs/architecture-examples/vue/bower.json
labs/architecture-examples/vue/bower.json
+1
-1
labs/architecture-examples/vue/bower_components/vue/vue.js
labs/architecture-examples/vue/bower_components/vue/vue.js
+2402
-1451
labs/architecture-examples/vue/index.html
labs/architecture-examples/vue/index.html
+1
-1
labs/architecture-examples/vue/js/app.js
labs/architecture-examples/vue/js/app.js
+31
-43
labs/architecture-examples/vue/js/routes.js
labs/architecture-examples/vue/js/routes.js
+8
-1
labs/architecture-examples/vue/js/store.js
labs/architecture-examples/vue/js/store.js
+2
-6
No files found.
labs/architecture-examples/vue/bower.json
View file @
40d9d467
{
"name"
:
"todomvc-vue"
,
"dependencies"
:
{
"vue"
:
"~0.
8.3
"
,
"vue"
:
"~0.
10.0
"
,
"todomvc-common"
:
"~0.1.9"
}
}
\ No newline at end of file
labs/architecture-examples/vue/bower_components/vue/vue.js
View file @
40d9d467
This diff is collapsed.
Click to expand it.
labs/architecture-examples/vue/index.html
View file @
40d9d467
...
...
@@ -14,7 +14,7 @@
<section
id=
"main"
v-show=
"todos.length"
>
<input
id=
"toggle-all"
type=
"checkbox"
v-model=
"allDone"
>
<ul
id=
"todo-list"
>
<li
class=
"todo"
v-repeat=
"todos
"
v-if=
"filterTodo(this)
"
v-class=
"completed: completed, editing: this == editedTodo"
>
<li
class=
"todo"
v-repeat=
"todos
| filterTodos
"
v-class=
"completed: completed, editing: this == editedTodo"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
v-model=
"completed"
v-on=
"change: toggleTodo"
>
<label
v-text=
"title"
v-on=
"dblclick: editTodo(this)"
></label>
...
...
labs/architecture-examples/vue/js/app.js
View file @
40d9d467
...
...
@@ -4,7 +4,19 @@
'
use strict
'
;
exports
.
app
=
new
Vue
({
var
filters
=
{
all
:
function
()
{
return
true
;
},
active
:
function
(
todo
)
{
return
!
todo
.
completed
;
},
completed
:
function
(
todo
)
{
return
todo
.
completed
;
}
};
var
app
=
exports
.
app
=
new
Vue
({
// the root element that will be compiled
el
:
'
#todoapp
'
,
...
...
@@ -13,7 +25,15 @@
data
:
{
todos
:
todoStorage
.
fetch
(),
newTodo
:
''
,
editedTodo
:
null
editedTodo
:
null
,
filter
:
'
all
'
},
// ready hook, watch todos change for data persistence
ready
:
function
()
{
this
.
$watch
(
'
todos
'
,
function
(
todos
)
{
todoStorage
.
save
(
todos
);
});
},
// a custom directive to wait for the DOM to be updated
...
...
@@ -31,35 +51,17 @@
}
},
// the `created` lifecycle hook.
// this is where we do the initialization work.
// http://vuejs.org/api/instantiation-options.html#created
created
:
function
()
{
// setup filters
this
.
filters
=
{
all
:
function
(
todo
)
{
// collect dependency.
// http://vuejs.org/guide/computed.html#Dependency_Collection_Gotcha
/* jshint expr:true */
todo
.
completed
;
return
true
;
},
active
:
function
(
todo
)
{
return
!
todo
.
completed
;
},
completed
:
function
(
todo
)
{
return
todo
.
completed
;
}
};
// default filter
this
.
setFilter
(
'
all
'
);
filters
:
{
filterTodos
:
function
(
todos
)
{
return
todos
.
filter
(
filters
[
this
.
filter
]);
}
},
// computed property
// http://vuejs.org/guide/computed.html
computed
:
{
remaining
:
function
()
{
return
this
.
todos
.
filter
(
this
.
filters
.
active
).
length
;
return
this
.
todos
.
filter
(
filters
.
active
).
length
;
},
allDone
:
{
$get
:
function
()
{
...
...
@@ -69,7 +71,6 @@
this
.
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
value
;
});
todoStorage
.
save
();
}
}
},
...
...
@@ -78,11 +79,6 @@
// note there's no DOM manipulation here at all.
methods
:
{
setFilter
:
function
(
filter
)
{
this
.
filter
=
filter
;
this
.
filterTodo
=
this
.
filters
[
filter
];
},
addTodo
:
function
()
{
var
value
=
this
.
newTodo
&&
this
.
newTodo
.
trim
();
if
(
!
value
)
{
...
...
@@ -90,16 +86,10 @@
}
this
.
todos
.
push
({
title
:
value
,
completed
:
false
});
this
.
newTodo
=
''
;
todoStorage
.
save
();
},
removeTodo
:
function
(
todo
)
{
this
.
todos
.
remove
(
todo
.
$data
);
todoStorage
.
save
();
},
toggleTodo
:
function
()
{
todoStorage
.
save
();
this
.
todos
.
$remove
(
todo
.
$data
);
},
editTodo
:
function
(
todo
)
{
...
...
@@ -116,7 +106,6 @@
if
(
!
todo
.
title
)
{
this
.
removeTodo
(
todo
);
}
todoStorage
.
save
();
},
cancelEdit
:
function
(
todo
)
{
...
...
@@ -125,12 +114,11 @@
},
removeCompleted
:
function
()
{
this
.
todos
.
remove
(
function
(
todo
)
{
return
todo
.
completed
;
});
todoStorage
.
save
();
this
.
todos
=
this
.
todos
.
filter
(
filters
.
active
);
}
}
});
app
.
filters
=
filters
;
})(
window
);
\ No newline at end of file
labs/architecture-examples/vue/js/routes.js
View file @
40d9d467
...
...
@@ -8,10 +8,17 @@
Object
.
keys
(
app
.
filters
).
forEach
(
function
(
filter
)
{
router
.
on
(
filter
,
function
()
{
app
.
setFilter
(
filter
)
;
app
.
filter
=
filter
;
});
});
router
.
configure
({
notfound
:
function
()
{
window
.
location
.
hash
=
''
;
app
.
filter
=
'
all
'
;
}
});
router
.
init
();
})(
app
,
Router
);
\ No newline at end of file
labs/architecture-examples/vue/js/store.js
View file @
40d9d467
...
...
@@ -5,16 +5,12 @@
'
use strict
'
;
var
STORAGE_KEY
=
'
todos-vuejs
'
;
var
todos
=
null
;
exports
.
todoStorage
=
{
fetch
:
function
()
{
if
(
!
todos
)
{
todos
=
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_KEY
)
||
'
[]
'
);
}
return
todos
;
return
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_KEY
)
||
'
[]
'
);
},
save
:
function
()
{
save
:
function
(
todos
)
{
localStorage
.
setItem
(
STORAGE_KEY
,
JSON
.
stringify
(
todos
));
}
};
...
...
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