/* cookie state provider */

Ext.define('TP.CookieProvider', {
    extend: 'Ext.state.CookieProvider',

    /* return all saved states */
    readValues: function() {
        return TP.clone(this.readCookies());
    },

    /* clear all cookies */
    clearAll: function() {
        var data = this.readCookies();
        for(var key in data) {
            this.clear(key);
        }
    },

    /* set state from object */
    loadData: function(data) {
        for(var key in data) {
            this.set(key, data[key]);
        }
    }
});


var cp = Ext.create('TP.CookieProvider', {
    path: "[% url_prefix %]",
    expires: new Date(new Date().getTime()+(1000*60*60*24*364)) // 1 year
});

Ext.state.Manager.setProvider(cp);
