Current Path : /var/www/html/clients/rebirth.e-nk.ru/skin_acp/clientscripts/ |
Current File : /var/www/html/clients/rebirth.e-nk.ru/skin_acp/clientscripts/ipd_titleedit.js |
var _this;function titleedit(){this.var_ajax_url=null;this.var_click_delay=1200;this.var_link_id_text='pages-link';this.var_span_id_text='pages-page';this.var_div_main='pages-main';this.lang_click_and_hold=null;this._tid_timeout=null;this._new_text=null;this._tid_links_init=0;this._tid_date=new Array();this._span_contents=new Array();this._link_contents=new Array();this.UNEDITABLES=new Array();this.uneditable_id_text='titleedit-uneditable';this.div_main_wrap=document.getElementById(this.var_div_main);this.edit_box='text';this.edit_box_ta_rows=5;this.edit_box_ta_cols=45;this.var_real_id_text='';}titleedit.prototype.init=function(){var pagelinks=document.getElementsByTagName('*');_this=this;for(var i=0;i<=pagelinks.length;i++){try{if(!pagelinks[i].id){continue;}}catch(e){continue;}var linkid=pagelinks[i].id;var linkname=linkid.replace( /^(.*)-(\d+)$/,"$1");var linknum=linkid.replace( /^(.*)-(\d+)$/,"$2");if(linkname==this.var_link_id_text){if(this.UNEDITABLES[linknum]){pagelinks[i].onmouseover=this.title_mouseover;pagelinks[i].onmouseout=this.title_mouseout;}else{pagelinks[i].onmousedown=this.title_mousedown;pagelinks[i].onmouseup=this.title_mouseup;if(!this._tid_links_init){pagelinks[i].title=pagelinks[i].title?pagelinks[i].title+". "+this.lang_click_and_hold:this.lang_click_and_hold;}}}}this._tid_links_init=1;};titleedit.prototype.title_mouseover=function(event){event=ipsclass.cancel_bubble(event,true);var tid=_this.get_tid_from_id(this.id);var check_for_id=_this.UNEDITABLES[tid];if(check_for_id){var alert_object=null;try{alert_object=document.getElementById(_this.uneditable_id_text);}catch(error){}if(alert_object){var root_obj=document.getElementById(_this.var_link_id_text+'-'+check_for_id);if(is_safari){root_obj.style.position='relative';}alert_object.style.top=ipsclass.get_obj_toppos(root_obj)-4+'px';alert_object.style.left=ipsclass.get_obj_leftpos(root_obj)+5+root_obj.offsetWidth+'px';alert_object.style.position='absolute';alert_object.style.display='';}return false;}};titleedit.prototype.title_mouseout=function(event){event=ipsclass.cancel_bubble(event,true);var tid=_this.get_tid_from_id(this.id);var check_for_id=_this.UNEDITABLES[tid];if(check_for_id){var alert_object=null;try{alert_object=document.getElementById(_this.uneditable_id_text);}catch(error){}if(alert_object){alert_object.style.display='none';}return false;}};titleedit.prototype.title_mousedown=function(event){event=ipsclass.cancel_bubble(event,true);var tid=_this.get_tid_from_id(this.id);_this._tid_date[tid]=_this.get_time_now();_this._tid_timeout=setTimeout("_this.link_event_timer("+tid+")",5);};titleedit.prototype.link_event_timer=function(tid){var timenow=this.get_time_now();if(timenow>0&&this._tid_date[tid]>0&&((timenow-this._tid_date[tid])>this.var_click_delay)){this._tid_date[tid]=0;this.span_to_input(tid);return false;}if(this._tid_date[tid]>0){this._tid_timeout=setTimeout("_this.link_event_timer("+tid+")",5);}else{return false;}};titleedit.prototype.span_to_input=function(tid){if(!use_enhanced_js){return false;}this._span_contents[tid]=document.getElementById(this.var_span_id_text+'-'+tid).innerHTML;this._link_contents[tid]=document.getElementById(this.var_link_id_text+'-'+tid).innerHTML;var value='';if(this.var_real_id_text){value=document.getElementById(this.var_real_id_text+'-'+tid).innerHTML;}else{value=this._link_contents[tid];}if(this.edit_box=='text'){value=value.replace( /"/g,'"');document.getElementById(this.var_span_id_text+'-'+tid).innerHTML='<input id="edit-'+tid+'" class="dny-edit-title" type="text" size="30" onblur="_this.edit_blur(\''+tid+'\')" onkeypress="_this.edit_keypress(event, \''+tid+'\')" value="'+value+'" />';}else{value=value.replace( /<\/textarea>/g,'</textarea>');document.getElementById(this.var_span_id_text+'-'+tid).innerHTML='<textarea id="edit-'+tid+'" class="dny-edit-title" cols="'+this.edit_box_ta_cols+'" rows="'+this.edit_box_ta_rows+'" onblur="_this.edit_blur(\''+tid+'\')" onkeypress="_this.edit_keypress(event, \''+tid+'\')">'+value+'</textarea>';}document.getElementById('edit-'+tid).focus();return false;};titleedit.prototype.title_mouseup=function(event){event=ipsclass.cancel_bubble(event,true);var tid=_this.get_tid_from_id(this.id);_this._tid_date[tid]=0;};titleedit.prototype.edit_blur=function(tid,type){_this._new_text=document.getElementById('edit-'+tid).value;if(_this._new_text!=""){_this.title_save(tid,_this._new_text,type);}};titleedit.prototype.edit_keypress=function(evt,tid,type){evt=(evt)?evt:window.event;_this._new_text=document.getElementById('edit-'+tid).value;if(_this.edit_box=='text'){if((evt.keyCode==13||evt.keyCode==3)&&_this._new_text!=""){_this.title_save(tid,_this._new_text,type);}}};titleedit.prototype.title_save=function(tid,new_text,type){var donotedit=0;if(new_text==_this._span_contents[tid]){donotedit=1;}document.getElementById(_this.var_span_id_text+'-'+tid).innerHTML=_this._span_contents[tid];document.getElementById(_this.var_link_id_text+'-'+tid).innerHTML=new_text;if(_this.var_real_id_text){document.getElementById(_this.var_real_id_text+'-'+tid).innerHTML=new_text;}_this.init();if(donotedit){return false;}var fields=new Array();fields['tid']=tid;fields['name']=new_text;fields['md5check']=ipb_md5_check;do_request_function=function(){if(!xmlobj.readystate_ready_and_ok()){xmlobj.show_loading("Saving...");return;}xmlobj.hide_loading();var returned=xmlobj.xmlhandler.responseText;if(returned.match( /<null>(0|-|\=)<\/null>/)){alert("Error occured, not saved");}};xmlobj=new ajax_request();xmlobj.onreadystatechange(do_request_function);xmlobj.process(_this.var_ajax_url,'POST',xmlobj.format_for_post(fields));return false;};titleedit.prototype.get_time_now=function(){var mydate=new Date();return mydate.getTime();};titleedit.prototype.get_tid_from_id=function(id){return id.replace( /.*\-(\d+)/,"$1");};titleedit.prototype.add_id_to_uneditables=function(tid){this.UNEDITABLES[tid]=tid;};