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