Your IP : 18.216.202.111
(function(e){if(BX.CAutoSave&&top.BX.CAutoSave)return;BX.CAutoSave=function(e){this.FORM_NAME=e.form;this.FORM_MARKER=e.form_marker;this.FORM_ID=e.form_id;this.PERIOD=e.period||[4001,20990];this.RESTORE_DATA=null;this.TIMERS=[null,null];this.bInited=false;this.bRestoreInProgress=false;this.DISABLE_STANDARD_NOTIFY=e.DISABLE_STANDARD_NOTIFY;this.NOTIFY_CONTEXT=null;BX.ready(BX.defer(this.Prepare,this));BX.garbage(BX.delegate(this.Clear,this))};BX.CAutoSave.prototype.Prepare=function(){var e;if(this.FORM_NAME&&BX.type.isString(this.FORM_NAME))this.FORM=document.forms[this.FORM_NAME];else if(this.FORM_MARKER&&BX.type.isString(this.FORM_MARKER))this.FORM=(BX(this.FORM_MARKER)||{form:null}).form;if(!BX.type.isDomNode(this.FORM))return;this.FORM.BXAUTOSAVE=this;BX.bind(this.FORM,"submit",BX.proxy(this.ClearTimers,this));for(e=0;e<this.FORM.elements.length;e++){this.RegisterInput(this.FORM.elements[e])}setTimeout(BX.delegate(this._PrepareAfter,this),10)};BX.CAutoSave.prototype.RegisterInput=function(e){if(BX.type.isString(e)){setTimeout(BX.delegate(function(){this.RegisterInput(this.FORM[e]||BX(e))},this),10)}else if(BX.type.isDomNode(e)){if(e.type!="button"&&e.type!="submit"&&e.type!="reset"&&e.type!="image"&&e.type!="hidden"){BX.bind(e,"change",BX.proxy(this.Init,this));if(e.type=="text"||e.type=="textarea"){BX.bind(e,"keyup",BX.proxy(this.Init,this))}if(e.type=="checkbox"||e.type=="radio"){BX.bind(e,"click",BX.proxy(this.Init,this))}}}};BX.CAutoSave.prototype.UnRegisterInput=function(e){if(BX.type.isString(e))e=this.FORM[e]||BX(e);if(BX.type.isDomNode(e)){BX.unbind(e,"change",BX.proxy(this.Init,this));BX.unbind(e,"keyup",BX.proxy(this.Init,this));BX.unbind(e,"click",BX.proxy(this.Init,this))}};BX.CAutoSave.prototype._PrepareAfter=function(){BX.onCustomEvent(this.FORM,"onAutoSavePrepare",[this,BX.proxy(this.Init,this)]);if(this.RESTORE_DATA){var e=this.FORM.name||Math.random();BX.addCustomEvent("onExtAutoSaveRestoreClick_"+e,BX.proxy(this.Restore,this));var t=this._NotifyContext();if(t){t.Notify(BX.message("AUTOSAVE")+' <a href="javascript:void(0)" onclick="BX.CAutoSave.Restore(\''+BX.util.urlencode(e)+"', this); return false;\">"+BX.message("AUTOSAVE_R")+"</a>")}BX.onCustomEvent(this.FORM,"onAutoSaveRestoreFound",[this,this.RESTORE_DATA])}};BX.CAutoSave.prototype.Init=function(){if(this.TIMERS[0]){clearTimeout(this.TIMERS[0]);this.TIMERS[0]=null}this.TIMERS[0]=setTimeout(BX.proxy(this.TimerHandler,this),this.PERIOD[0]);if(!this.TIMERS[1]){this.TIMERS[1]=setInterval(BX.proxy(this.Save,this),this.PERIOD[1])}BX.onCustomEvent(this.FORM,"onAutoSaveInit",[this]);return true};BX.CAutoSave.prototype.TimerHandler=function(){if(this.TIMERS[1]){clearInterval(this.TIMERS[1]);this.TIMERS[1]=null}this.Save()};BX.CAutoSave.prototype.Save=function(){if(this.FORM&&BX.isNodeInDom(this.FORM)){var e,i,s,o={autosave_id:this.FORM_ID,form_data:{}};for(e=0;e<this.FORM.elements.length;e++){s=this.FORM.elements[e];if(s.name&&s.name!="sessid"&&s.name!="lang"&&s.name!="autosave_id"){var n=s.name,a="",r=s.type.toLowerCase();switch(r){case"button":case"submit":case"reset":case"image":case"file":case"password":break;case"radio":case"checkbox":if(s.checked)a=s.value||"on";break;case"select-multiple":n=n.substring(0,n.length-2);a=[];for(i=0;i<s.options.length;i++){if(s.options[i].selected){a.push(s.options[i].value)}}break;default:a=s.value}if(n.indexOf("[]")>0){n=t(n);if(typeof o.form_data[n]=="undefined")o.form_data[n]=[a];else o.form_data[n].push(a)}else o.form_data[t(n)]=a}}BX.onCustomEvent(this.FORM,"onAutoSave",[this,o.form_data]);BX.ajax.post("/bitrix/tools/autosave.php?bxsender=core_autosave&sessid="+BX.bitrix_sessid(),o,BX.proxy(this._Save,this))}else{this.Clear()}};BX.CAutoSave.prototype._Save=function(e){BX.onCustomEvent(this.FORM,"onAutoSaveFinished",[this,e])};BX.CAutoSave.prototype.Restore=function(e,t){if(e){this.RESTORE_DATA=s(e)}else if(this.FORM&&this.RESTORE_DATA){BX.onCustomEvent(this.FORM,"onAutoSaveRestore",[this,this.RESTORE_DATA]);this.bRestoreInProgress=true;for(var i=0;i<this.FORM.elements.length;i++){var o=this.FORM.elements[i];if(o&&BX.type.isDomNode(o)&&o.name){var n=undefined,a=o.name;if(o.type=="select-multiple")a=o.name.substring(0,o.name.length-2);n=this.RESTORE_DATA[a];if(a.indexOf("[]")>0&&BX.type.isArray(n))n=this.RESTORE_DATA[a].shift();if(o.type!="checkbox"&&typeof n=="undefined")continue;var r=false;switch(o.type){case"radio":if(!o.checked&&!!(n==o.value)){r=true;BX.fireEvent(o,"click")}break;case"checkbox":if(o.checked!=!!(n==o.value)){r=true;BX.fireEvent(o,"click")}break;case"select-one":for(var h=0;h<o.options.length;h++){var u=o.options[h].selected;o.options[h].selected=!!(n==o.options[h].value);r|=o.options[h].selected!=u}break;case"select-multiple":n=this.RESTORE_DATA[o.name.substring(0,o.name.length-2)];for(h=0;h<o.options.length;h++){u=o.options[h].selected;o.options[h].selected=!!(BX.type.isArray(n)&&BX.util.in_array(o.options[h].value,n));r|=o.options[h].selected!=u}break;case"file":case"button":case"image":case"submit":case"reset":case"password":break;default:r=n!=o.value;o.value=n}if(r)BX.fireEvent(o,"change")}}var l=this._NotifyContext();if(l)l.hideNotify(t.parentNode.parentNode);this.bRestoreInProgress=false;BX.onCustomEvent(this.FORM,"onAutoSaveRestoreFinished",[this,this.RESTORE_DATA])}};BX.CAutoSave.prototype._NotifyContext=function(){var e=null;if(!this.DISABLE_STANDARD_NOTIFY){if(this.NOTIFY_CONTEXT)e=this.NOTIFY_CONTEXT;else if(BX.WindowManager&&BX.WindowManager.Get())e=BX.WindowManager.Get();else if(BX.adminPanel)e=BX.adminPanel;else if(BX.admin&&BX.admin.panel)e=BX.admin.panel;this.NOTIFY_CONTEXT=e}return e};BX.CAutoSave.prototype.ClearTimers=function(){if(this.TIMERS){clearTimeout(this.TIMERS[0]);clearInterval(this.TIMERS[1])}};BX.CAutoSave.prototype.Clear=function(){if(this.FORM){this.FORM.BXAUTOSAVE=null;for(var e=0;e<this.FORM.elements.length;e++){this.UnRegisterInput(this.FORM.elements[e])}}this.ClearTimers();BX.onCustomEvent(this.FORM,"onAutoSaveClear",[this]);this.FORM=null;this.TIMERS=null};BX.CAutoSave.Restore=function(e,t){BX.onCustomEvent("onExtAutoSaveRestoreClick_"+e,[null,t])};function t(e){var t;while(t=/[^a-zA-Z0-9_\-]/.exec(e)){e=e.replace(t[0],"X"+BX.util.str_pad_left(t[0].charCodeAt(0).toString(),6,"0")+"X")}return e}function i(e){var t;while(t=/X[\d]{6}X/.exec(e)){e=e.replace(t[0],String.fromCharCode(parseInt(t[0].replace(/(^X[0]*)|(X$)/g,""))))}return e}function s(e){var t={};for(var s in e){t[i(s)]=e[s]}return t}top.BX.CAutoSave=BX.CAutoSave})(window);
//# sourceMappingURL=core_autosave.map.js