/* Authors: * Petr Vobornik * * Copyright (C) 2012 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/Evented', 'dojo/router' ], function(declare, lang, Evented, router) { /** * Router * * This component keeps menu and routes in sync. It signalizes * other components to display facet by sending 'show-facet' event. * Other components can use navigate_to_* methods to change currently * displayed facet. This change can be canceled in 'facet-change' * event handler. * @class navigation.Router */ var navigation = declare([Evented], { /** * Holds references to register route handlers. * Can be used for unregistering routes. * @property {Array.} */ route_handlers: [], /** * Prefix of all routes for this navigation. Useful for multiple * navigation objects in one application. * @property {string} */ route_prefix: '', /** * Used during facet changing. Set it to true in 'facet-change' * event handler to stop the change. * @property {boolean} */ canceled: false, /** * Flag to indicate that next hash change should not invoke showing a * facet. * Main purpose: updating hash. * @property {boolean} */ ignore_next: false, /** * Register a route-handler pair to a dojo.router * Handler will be run in context of this object * * @param {string|Array.} route or routes to register * @param {Function} handler to be associated with the route(s) */ register_route: function(route, handler) { if (route instanceof Array) { for (var i=0, l=route.length; i