(function(){var t,e,i=function(t,e){return function(){return t.apply(e,arguments)}};window.Formify||(window.Formify={}),window.Formify.Input=e=function(){function t(t){this.id=t.id||t.name,this.name=t.name,this.value=t.value,this.type=t.type,this.checked=t.checked}return t}(),window.Formify.Form=t=function(){function t(t){this._bindSubmitEvent=i(this._bindSubmitEvent,this),this._serialize=i(this._serialize,this),this._bindInputChangeEvent=i(this._bindInputChangeEvent,this),this.clearLocalStorage=i(this.clearLocalStorage,this),this.loadFromLocalStorage=i(this.loadFromLocalStorage,this),this.saveToLocalStorage=i(this.saveToLocalStorage,this),this.id=t,this.$element=$("#"+t),this.fields=this.$element.find(":input"),this._bindInputChangeEvent(),this._bindSubmitEvent(),this.loadFromLocalStorage()}return t.prototype.saveToLocalStorage=function(){var t;return t=this._serialize(),localStorage.setItem(this.id,t)},t.prototype.loadFromLocalStorage=function(){var t,e,i,n;for(e=JSON.parse(localStorage.getItem(this.id))||[],i=0,n=e.length;n>i;i++)t=e[i],$("#"+t.id).prop(t),$("[name='"+t.name+"'").val(t.value);return void 0},t.prototype.clearLocalStorage=function(){return localStorage.removeItem(this.id)},t.prototype._bindInputChangeEvent=function(){var t;return t=this,this.fields.each(function(){return $(this).on("input change",function(e){return t.clearLocalStorage(),t.saveToLocalStorage()})})},t.prototype._serialize=function(){var t;return t=[],this.fields.each(function(){return t.push(new e(this))}),JSON.stringify(t)},t.prototype._bindSubmitEvent=function(){return this.$element.on("submit",function(t){return function(e){return t.clearLocalStorage()}}(this))},t}()}).call(this);