Commit 8faf14d0 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Throw away history grid.

parent fe56adfd
Loading
Loading
Loading
Loading
+0 −55
Original line number Diff line number Diff line
@@ -2,13 +2,8 @@
 * Browser history management using Ext.util.History.
 */
Ext.define("Docs.History", {
    extend: 'Docs.LocalStore',
    storeName: 'History',
    singleton: true,

    // Maximum number of items to keep in history store
    maxHistoryLength: 25,

    /**
     * Initializes history management.
     */
@@ -17,16 +12,10 @@ Ext.define("Docs.History", {
            this.navigate(Ext.util.History.getToken());
        }, this);
        Ext.util.History.on("change", this.navigate, this);
        this.callParent();
    },

    // Parses current URL and navigates to the page
    navigate: function(token) {
        if (this.ignoreChange) {
            this.ignoreChange = false;
            return;
        }

        var url = this.parseToken(token);
        if (url.type === "api") {
            Docs.App.getController('Classes').loadClass(url.key, true);
@@ -45,56 +34,12 @@ Ext.define("Docs.History", {
        return matches ? {type: matches[1], key: matches[2]} : {};
    },

    // Extracts class name from history token
    // Returns false when it's not class-related token.
    parseClassName: function(token) {
        var url = this.parseToken(token);
        if (url.type === "api") {
            return url.key.replace(/-.*$/, '');
        }
        else {
            return false;
        }
    },

    /**
     * Adds URL to history
     *
     * @param {String} token  the part of URL after #
     */
    push: function(token) {
        this.ignoreChange = true;
        Ext.util.History.add(token);

        // Add class name to history store if it's not there already
        var cls = this.parseClassName(token);
        if (cls) {
            // When class already in history remove it and add again.
            // This way the most recently visited items will always be at the top.
            var oldIndex = this.store.findExact('cls', cls);
            if (oldIndex > -1) {
                this.store.removeAt(oldIndex);
            }

            // Add new item at the beginning
            this.store.insert(0, {cls: cls});

            // Remove items from the end of history if there are too many
            while (this.store.getAt(this.maxHistoryLength)) {
                this.store.removeAt(this.maxHistoryLength);
            }
            this.syncStore();
        }
    },

    /**
     * Removes class from History store
     *
     * @param {String} cls
     */
    removeClass: function(cls) {
        var index = this.store.findExact('cls', cls);
        this.store.removeAt(index);
        this.syncStore();
    }
});
+1 −1
Original line number Diff line number Diff line
/**
 * Provides methods dealing with localStorage- and memory-store.
 *
 * Base class for History and Favorites.
 * Base class for Favorites and Settings.
 */
Ext.define("Docs.LocalStore", {
    storeName: '',
+0 −3
Original line number Diff line number Diff line
@@ -12,13 +12,11 @@ Ext.define('Docs.controller.Classes', {

    stores: [
        'Favorites',
        'History',
        'Settings'
    ],

    models: [
        'Favorite',
        'History',
        'Setting'
    ],

@@ -203,7 +201,6 @@ Ext.define('Docs.controller.Classes', {
        this.currentCls = cls;

        this.getFavoritesGrid().selectClass(cls.name);
        this.getHistoryGrid().selectClass(cls.name);
    },

    showGuide: function(name, noHistory) {

template/app/model/History.js

deleted100644 → 0
+0 −11
Original line number Diff line number Diff line
/**
 * Previously visited classes / guides
 */
Ext.define('Docs.model.History', {
    fields: ['id', 'cls'],
    extend: 'Ext.data.Model',
    proxy: {
        type: ('localStorage' in window && window['localStorage'] !== null) ? 'localstorage' : 'memory',
        id  : 'docs-history'
    }
});

template/app/store/History.js

deleted100644 → 0
+0 −11
Original line number Diff line number Diff line
/**
 * History Store
 */
Ext.define('Docs.store.History', {
    extend: 'Ext.data.Store',
    model: 'Docs.model.History',
    // Sort history with latest on top
    sorters: [
        { property: 'id', direction: 'DESC' }
    ]
});
Loading