Commit f3c2b113 authored by Ivan Tyagov's avatar Ivan Tyagov

Use dedicated gadget to show and auto hide messages.

Recreate default route using proper RouteGadget.
parent e417ed3b
<html>
<head></head>
<body>
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {
gadget = RenderJs.getSelfGadget();
gadget.showMessage = function (msg){
$("#portal-status-message").html(msg);
window.setTimeout(function () {
$("#portal-status-message").empty();
}, 2000);
};
});
//]]>
</script>
</body>
</html>
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
</head> </head>
<body> <body>
<div id="portal-status-message"
data-gadget="gadget-portal-status-message.html"></div>
<div data-gadget="" <div data-gadget=""
id="main-router" id="main-router"
data-gadget-route="[ data-gadget-route="[
......
...@@ -33,11 +33,12 @@ require([ "renderjs", "require-renderjs", "jquery", "route", "url" ], function(d ...@@ -33,11 +33,12 @@ require([ "renderjs", "require-renderjs", "jquery", "route", "url" ], function(d
RenderJs.RouteGadget.go($.url.getPath(), RenderJs.RouteGadget.go($.url.getPath(),
function () { function () {
// Method to display error to the user // Method to display error to the user
$(this).html( gadget = RenderJs.GadgetIndex.getGadgetById("portal-status-message");
gadget.showMessage(
"<p>Oups, seems the route '<b>" + $.url.getPath() + "<\/b>' doesn't exist!<\/p>" + "<p>Oups, seems the route '<b>" + $.url.getPath() + "<\/b>' doesn't exist!<\/p>" +
"<a href='" + $.url.generateUrl("") + "'>Go back to home<\/a>"); "<a href='" + $.url.generateUrl("") + "'>Go back to home<\/a>");
// All routes have been deleted by fail. // All routes have been deleted by fail.
// XXX: Recreate the default routes using RouteGadget // So recreate the default routes using RouteGadget
$("div[data-gadget-route]").each(function (index, element) { $("div[data-gadget-route]").each(function (index, element) {
RenderJs.RouteGadget.route($(element)); RenderJs.RouteGadget.route($(element));
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment