Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
4e76428c
Commit
4e76428c
authored
Feb 19, 2013
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some basic route introspection for RouteGadget.
parent
efe5890c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
renderjs.js
renderjs.js
+20
-0
test/renderjs_test.js
test/renderjs_test.js
+7
-0
No files found.
renderjs.js
View file @
4e76428c
...
...
@@ -761,6 +761,7 @@ var RenderJs = (function () {
/*
* A gadget that defines possible routes (i.e. URL changes) between gadgets.
*/
var
route_list
=
[];
return
{
route
:
function
(
gadget_dom
)
{
...
...
@@ -791,6 +792,10 @@ var RenderJs = (function () {
body
.
route
(
"
add
"
,
path
,
1
)
.
done
(
handler_func
);
// save locally
route_list
.
push
({
"
path
"
:
path
,
"
handler_func
"
:
handler_func
,
"
priority
"
:
priority
});
},
go
:
function
(
path
,
handler_func
,
priority
)
{
...
...
@@ -801,6 +806,21 @@ var RenderJs = (function () {
body
.
route
(
"
go
"
,
path
,
priority
)
.
fail
(
handler_func
);
},
remove
:
function
(
path
)
{
/*
* Remove a route.
*/
// XXX: implement remove a route when route.js supports it
},
getRouteList
:
function
()
{
/*
* Get list of all router
*/
return
route_list
;
}
};
}())
...
...
test/renderjs_test.js
View file @
4e76428c
...
...
@@ -257,6 +257,13 @@ function setupRenderJSTest(){
$
(
"
div[data-gadget-route]
"
).
each
(
function
(
index
,
element
)
{
RenderJs
.
RouteGadget
.
route
(
$
(
element
));
});
var
path_list
=
[];
$
.
each
(
RenderJs
.
RouteGadget
.
getRouteList
(),
function
(
index
,
value
)
{
path_list
.
push
(
value
.
path
);
});
equal
(
3
,
RenderJs
.
RouteGadget
.
getRouteList
().
length
);
deepEqual
([
"
/gadget-one/
"
,
"
/gadget-two/
"
,
"
/gadget-three/
"
],
path_list
);
// listen to event and do actual routing
$
.
url
.
onhashchange
(
function
()
{
...
...
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