import Cookie from '../cookie'; export class Store{ /** * Store, persistence manager * @param {Object} tf TableFilter instance * * TODO: use localStorage and fallback to cookie persistence */ constructor(tf){ var f = tf.config(); this.duration = !isNaN(f.set_cookie_duration) ? parseInt(f.set_cookie_duration, 10) : 100000; this.tf = tf; this.emitter = tf.emitter; } init(){ this.emitter.on('after-filtering', ()=> this.saveFilterValues(this.tf.fltsValuesCookie)); } /** * Store filters' values in cookie * @param {String} cookie name */ saveFilterValues(name){ var tf = this.tf; var fltValues = []; //store filters' values for(var i=0; i this.saveFilterValues(this.tf.fltsValuesCookie)); } }