Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
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 () {
...
@@ -761,6 +761,7 @@ var RenderJs = (function () {
/*
/*
* A gadget that defines possible routes (i.e. URL changes) between gadgets.
* A gadget that defines possible routes (i.e. URL changes) between gadgets.
*/
*/
var
route_list
=
[];
return
{
return
{
route
:
function
(
gadget_dom
)
{
route
:
function
(
gadget_dom
)
{
...
@@ -791,6 +792,10 @@ var RenderJs = (function () {
...
@@ -791,6 +792,10 @@ var RenderJs = (function () {
body
body
.
route
(
"
add
"
,
path
,
1
)
.
route
(
"
add
"
,
path
,
1
)
.
done
(
handler_func
);
.
done
(
handler_func
);
// save locally
route_list
.
push
({
"
path
"
:
path
,
"
handler_func
"
:
handler_func
,
"
priority
"
:
priority
});
},
},
go
:
function
(
path
,
handler_func
,
priority
)
{
go
:
function
(
path
,
handler_func
,
priority
)
{
...
@@ -801,6 +806,21 @@ var RenderJs = (function () {
...
@@ -801,6 +806,21 @@ var RenderJs = (function () {
body
body
.
route
(
"
go
"
,
path
,
priority
)
.
route
(
"
go
"
,
path
,
priority
)
.
fail
(
handler_func
);
.
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(){
...
@@ -257,6 +257,13 @@ function setupRenderJSTest(){
$
(
"
div[data-gadget-route]
"
).
each
(
function
(
index
,
element
)
{
$
(
"
div[data-gadget-route]
"
).
each
(
function
(
index
,
element
)
{
RenderJs
.
RouteGadget
.
route
(
$
(
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
// listen to event and do actual routing
$
.
url
.
onhashchange
(
function
()
{
$
.
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