<commit_before>define(
[
    'models',
    'views/common',
    'views/cluster_page',
    'views/cluster_page_tabs/nodes_tab',
    'views/clusters_page',
    'views/releases_page',
    'views/notifications_page',
    'views/support_page'
],
function(models, commonViews, ClusterPage, NodesTab, ClustersPage, ReleasesPage, NotificationsPage, SupportPage) {
    'use strict';

    var AppRouter = Backbone.Router.extend({
        routes: {
            'clusters': 'listClusters',
            'cluster/:id': 'showCluster',
            'cluster/:id/:tab(/:opt1)(/:opt2)': 'showClusterTab',
            'releases': 'listReleases',
            'notifications': 'showNotifications',
            'support': 'showSupportPage',
            '*default': 'listClusters'
        },
        initialize: function() {
            this.content = $('#content');
            this.navbar = new commonViews.Navbar({elements: [
                ['OpenStack Environments', '#clusters'],
                ['Support', '#support']
            ]});
            this.content.before(this.navbar.render().el);
            this.breadcrumbs = new commonViews.Breadcrumbs();
            this.content.before(this.breadcrumbs.render().el);
            this.footer = new commonViews.Footer();
            $('#footer').html(this.footer.render().el);
            this.content.find('.loading').addClass('layout-loaded');
        },
        setPage: function(NewPage, options) {
            if (this.page) {
                this.page.tearDown();
            }
            this.page = new NewPage(options);
            this.page.updateNavbar();
            this.page.updateBreadcrumbs();
            this.page.updateTitle();
            this.content.html(this.page.render().el);
        },
        showCluster: function(id) {
            this.navigate('#cluster/' + id + '/nodes', {trigger: true, replace: true});
        },
        showClusterTab: function(id, activeTab) {
            if (!_.contains(ClusterPage.prototype.tabs, activeTab)) {
                this.showCluster(id);
                return;
            }

            var tabOptions = _.toArray(arguments).slice(2);

            if (activeTab == 'nodes') {
                // special case for nodes tab screen change
                try {
                    if (app.page.constructor == ClusterPage && app.page.model.id == id && app.page.tab.constructor == NodesTab) {
                        app.page.tab.tabOptions = tabOptions;
                        app.page.tab.routeScreen();
                        return;
                    }
                } catch(e) {}
            }

            var cluster;
            var render = function() {
                this.setPage(ClusterPage, {model: cluster, activeTab: activeTab, tabOptions: tabOptions});
            };

            if (app.page && app.page.constructor == ClusterPage && app.page.model.id == id) {
                // just another tab has been chosen, do not load cluster again
                cluster = app.page.model;
                render.call(this);
            } else {
                cluster = new models.Cluster({id: id});
                $.when(cluster.fetch(), cluster.fetchRelated('nodes'), cluster.fetchRelated('tasks'))
                    .done(_.bind(render, this))
                    .fail(_.bind(this.listClusters, this));
            }
        },<commit_msg>Fix animated transition between screens<commit_after>define(
[
    'models',
    'views/common',
    'views/cluster_page',
    'views/cluster_page_tabs/nodes_tab',
    'views/clusters_page',
    'views/releases_page',
    'views/notifications_page',
    'views/support_page'
],
function(models, commonViews, ClusterPage, NodesTab, ClustersPage, ReleasesPage, NotificationsPage, SupportPage) {
    'use strict';

    var AppRouter = Backbone.Router.extend({
        routes: {
            'clusters': 'listClusters',
            'cluster/:id': 'showCluster',
            'cluster/:id/:tab(/:opt1)(/:opt2)': 'showClusterTab',
            'releases': 'listReleases',
            'notifications': 'showNotifications',
            'support': 'showSupportPage',
            '*default': 'listClusters'
        },
        initialize: function() {
            this.content = $('#content');
            this.navbar = new commonViews.Navbar({elements: [
                ['OpenStack Environments', '#clusters'],
                ['Support', '#support']
            ]});
            this.content.before(this.navbar.render().el);
            this.breadcrumbs = new commonViews.Breadcrumbs();
            this.content.before(this.breadcrumbs.render().el);
            this.footer = new commonViews.Footer();
            $('#footer').html(this.footer.render().el);
            this.content.find('.loading').addClass('layout-loaded');
        },
        setPage: function(NewPage, options) {
            if (this.page) {
                this.page.tearDown();
            }
            this.page = new NewPage(options);
            this.page.updateNavbar();
            this.page.updateBreadcrumbs();
            this.page.updateTitle();
            this.content.html(this.page.render().el);
        },
        showCluster: function(id) {
            this.navigate('#cluster/' + id + '/nodes', {trigger: true, replace: true});
        },
        showClusterTab: function(id, activeTab) {
            if (!_.contains(ClusterPage.prototype.tabs, activeTab)) {
                this.showCluster(id);
                return;
            }

            var tabOptions = _.toArray(arguments).slice(2);

            if (activeTab == 'nodes') {
                // special case for nodes tab screen change
                try {
                    if (app.page.constructor == ClusterPage && app.page.model.id == id && app.page.tab.constructor == NodesTab) {
                        app.page.tab.routeScreen(tabOptions);
                        return;
                    }
                } catch(e) {}
            }

            var cluster;
            var render = function() {
                this.setPage(ClusterPage, {model: cluster, activeTab: activeTab, tabOptions: tabOptions});
            };

            if (app.page && app.page.constructor == ClusterPage && app.page.model.id == id) {
                // just another tab has been chosen, do not load cluster again
                cluster = app.page.model;
                render.call(this);
            } else {
                cluster = new models.Cluster({id: id});
                $.when(cluster.fetch(), cluster.fetchRelated('nodes'), cluster.fetchRelated('tasks'))
                    .done(_.bind(render, this))
                    .fail(_.bind(this.listClusters, this));
            }
        },
{'fraction_non_alphanumeric': 0.1383995222454464, 'fraction_numerical': 0.0008957897879964168, 'mean_word_length': 1.7309417040358743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3794462', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1755, 'n_words': 320}