<!-- Быстрое редактирование постов © Alex_63 // V.3 -->
<script type="text/javascript">
if($('#pun-viewtopic').length)(function() {
//====.serialize() под Win 1251 ====//
var transAnsiAjaxSys = [];
var arr=[0x402,0x403,0x201A,0x453,0x201E,0x2026,0x2020,0x2021,0x20AC,0x2030,0x409,0x2039,
0x40A,0x40C,0x40B,0x40F,0x452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,'0',0x2122,
0x459,0x203A,0x45A,0x45C,0x45B,0x45F,0x0A0,0x40E,0x45E,0x408,0x0A4,0x490,0x0A6,0x0A7,0x401,
0x0A9,0x404,0x0AB,0x0AC,0x0AD,0x0AE,0x407,0x0B0,0x0B1,0x406,0x456,0x491,0x0B5,0x0B6,0x0B7,
0x451,0x2116,0x454,0x0BB,0x458,0x405,0x455,0x457,0x410,0x411,0x412,0x413,0x414,0x415,0x416,
0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,
0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x430,0x431,0x432,0x433,0x434,
0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,
0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F];
var arLng = arr.length;
for (var i = 0; i < arLng; i++)transAnsiAjaxSys[arr[i]]=i+128;
for (var i = 0x410; i <= 0x44F; i++) transAnsiAjaxSys[i] = i - 0x350; // А-Яа-я
var encodeURIwin1251 = function(str){
var L = str.split('');str = '';
for(var i = 0; i < L.length; i++){
var code = escape(L[i]);
if (code.search(/%u[0-9A-Z]+/i)==0){
сode = parseInt(code.substr(2), 16);
if(сode > 1200) L[i] ='&#' + сode + ';';
}
str+= L[i] ;
}
var ret = [];
for (var i = 0; i < str.length; i++) {
var n = str.charCodeAt(i);
if (typeof transAnsiAjaxSys[n] != 'undefined')n = transAnsiAjaxSys[n];
if (n <= 0xFF)ret.push(n);
}
return escape(String.fromCharCode.apply(null, ret)).replace(/\+/mg,'%2B');
}
$.fn.extend({serialize : function() {
var s='';var obj=this.serializeArray();var Lng=obj.length;
for(var i=0;i<Lng;i++){
if(i)s+='&';
s+=encodeURIwin1251(obj[i].name)+'='+encodeURIwin1251(obj[i].value);
}return s; }
});
//====//END// .serialize() под Win 1251 ====//
var lang = $('#pun').attr('class').match(/^(\w{2})/)[1];
var txtCancel = {ru: 'Отмена',en: 'Cancel'}[lang];
var txtPreview = {ru: 'Расширенный режим',en: 'Advanced mode'}[lang];
//======== function loadToMain() ===========//
function loadToMain(){/*=|=;
(function () {
function removeRating(a){try {a=a.replace(/<div class="post-rating">[\s\S]*<\/div>/mgi,'').replace(/<div class="post-vote">[\s\S]*<\/div>/mgi,'');}catch(e){};return a;}
if(window.name.indexOf('reLoadPst_')==0 ){
var $f = $(this.document), $p = $(parent.document);
var d = window.name.split('_')[1];
$f.find('#p'+d+'.post').find('img').on('error',function(e){ $(this).replaceWith($(this).clone(true,true)).addClass('reloaded').off('error')});
var LL = $f.find('#p'+d+'.post').find('.post-content').clone(true,true);
var post = $p.find('#p'+d); post.find('#post').replaceWith(LL);
if(typeof(QuoteImg)!='undefined'){ parent.setLinkAndAva(post);}
jQuery.ready();$(window).trigger('load');
function remFram(){$p.find('iframe[name="reLoadPst_'+d+'"]').detach();}
post.find('.pl-edit>a').removeClass('disabled');
if(!post.hasClass('topicpost')){remFram();return;}
var newTname = $f.find('#pun-main h1 > span').text();
var namOld = $p.find('#pun-main h1 > span').html();
newTname = newTname.replace(/‡.*&/mgi,'').replace(/†.*¤/mgi,'').replace(/¤.*¤/mgi,'');
top.document.title = newTname;
$p.find('#pun-main h1 > span:first').html(newTname);
var txt = $('#pun-crumbs1').html();
txt = txt.replace('» '+namOld,'» '+newTname);
$p.find('#pun-crumbs1,#pun-crumbs2').html(txt);
remFram ()
}
if(window.name.indexOf('rLFRam_')==0){
var $f = $(this.document), $p = $(parent.document);
var d = window.name.split('_')[1];
$f.find('#post script').remove();
jQuery.ready();$(window).trigger('load');
$f.find('#post').find('img').on('error',function(e){ $(this).replaceWith($(this).clone(true,true)).addClass('reloaded').off('error')});
var form = $f.find('#post').clone(true,true);
var hght = $p.find('#p'+d).height();// console.log(hght);
var $sel = $p.find('#p'+d).find('.pl-edit');
var cnt = removeRating ($sel.parents('.post').find('.post-box').html());
cnt = cnt.replace(/\n/g,'\\n').replace(/"/g,'"');
$sel.parents('.post').find('.post-content,form').replaceWith(form);
$sel.parents('.post').find('input[name="preview"]')[0].value = '#$1#';
$sel.parents('.post').find('textarea#main-reply')[0].rows = '13';
var btn_c=' <input type="button" class="button" id="cncl" data-pst-text="'+cnt+'" onclick="cancelEdit(this)" value="#$2#"/>';
$sel.parents('.post').find('input[name="preview"]').after(btn_c);
$sel.parents('.post').find('#post').addClass('formal').find('#post-preview').remove();
//$sel.parents('.post').find('#post').find('img[src="/i/blank.gif"]').attr('src','http://forum.mybb.ru/i/blank.gif');
//$sel.parents('.post').find('#post').find('.iconid+img').map(function(){var s=$(this).attr('src');$(this).attr('src',s.substr(5))});
if(hght>=500){var offs=$sel.parents('.post').offset().top;$('html,body',$p).scrollTop(offs);}
parent.$.getScript('/files/0015/c4/3f/81764.js');//.appendTo($sel.parents('.post').find('#post'));
$p.find('iframe[name="rLFRam_'+d+'"]').detach();
};
})()
=|=;*/}
loadToMain = '<script type="text/javascript">' + (loadToMain.toString().split('=|=;')[1].replace('#$1#',txtPreview).replace('#$2#',txtCancel)) + '<\/script>';
//====End::// loadToMain() ================//
//============ ОТПРАВКА ФОРМЫ =============//
function ajaxSendForm(form){
var d=form.serialize(),a=form.attr('action'),pid=form.parents('.post').attr('id').substr(1);
$('<iframe src="about:blank" style="position:absolute;" name="reLoadPst_'+pid+'" data="'+pid+'"></iframe>').appendTo('head');
$.ajax({url:a,dataType:'html',type:'POST',data:d,success:function(response) {
var pstErrs = $(response).find('#post-errors');
if(pstErrs.html()!=null){var errTxt=pstErrs.text().replace(/ /g,'');
alert(errTxt);$('.post #post .button').removeAttr('disabled');return false;
}
var pstGet = form.parents('.post').attr('id');
$(response).find('#'+pstGet).find('.post-rating,.post-vote').remove();
$(response).find('.section[style*="border:"]').remove();
if($(response).find('#pun-viewtopic').length){
setFrameContent(response,pid,'reLoadPst_');
} else {
$.get(document.URL,function(data) {
$(data).find('#p'+pstGet).find('.post-rating,.post-vote').remove();
setFrameContent(data,pid,'reLoadPst_');
});
}
},error:function(){alert('Не удается соединиться с сервером.');
$('.post #post .button').removeAttr('disabled');
}});
}
//========END:/// ОТПРАВКА ФОРМЫ =============//
var clr_bg_pst= $('.post.topicpost,.post.toppost').find(' >.container .post-body').css('background-color');
var add_Style = '<style type="text/css">.post #post{margin-bottom:3em;border:none;background:transparent;}</style>';
var add_StL02 = '<style type="text/css">.post #post .container{padding:1.7em 2.3em 1.1em 2.3em!important;}</style>';
var add_StL03 = '<style type="text/css">.post #post fieldset,.post #post legend>span{background:'+clr_bg_pst+'!important;}</style>';
$('.punbb').prepend(add_Style + add_StL02 + add_StL03);
//======== Отмена редактирования ========//
window.cancelEdit = function(sel){
var $s = $(sel);
var cnt = $s.attr('data-pst-text').replace(/\\n/g,'\n');
$s.parents('.post').find('.pl-edit > a').removeClass('disabled');
$s.parents('.post').find('#post').replaceWith(cnt);
}
//======== End:Отмена редактирования ========//
//===== function setFrameContent() ==========//
function setFrameContent(a,pid,s){
var ifr = document.getElementsByName(s+pid)[0];
a=a.toString().replace(/<link.*?rel="stylesheet".*?\s\/>/mgi,'');
a=a.replace(/(?:<div class="section" style="border:0 !important.*?>(?:<div.*?><\/div>?)?<\/div>)/mgi,'');
a=a.replace(/<div id="on_OfMobile">[\s\S]*saveDay\s=\s(\d+)[\s\S]*tipsy\s=\s'.*'[\s\S]*<script.*16328\.js"><\/script>/mgi,'');
var reg = /<div id="pun".*?>[\s\S]*?<div id="pun-.*?" class="punbb">|(?:<div\sid="html-header"|<!-- html_header -->)/gim;
var partner_sc = a.split(reg)[1]; a=a.replace(partner_sc,(window.Rusff?'<script type="text/javascript">RusffCore={init:function(){}}<\/script>':''));
a+=loadToMain;//console.log(a);
ifr.contentWindow.document.write(a);
}
//========== End: setFrameContent() =========//
//============= Обработка кликов ============//
var winLoad = false; $(window).load(function(){winLoad=true});
$('.post .pl-edit>a').live('click',function(e) {
e.preventDefault();
if($(this).hasClass('disabled')){return false;}
if(!winLoad){$(window).trigger('load');window.stop();}
$(this).addClass('disabled');var href = $(this).attr('href');
href = href.replace(/&(amp;?)?.+?$/mgi,'');
var pid = href.replace(/^.*id=(\d+)$/mgi,'$1');
$('<iframe src="about:blank" style="position:absolute;" name="rLFRam_'+pid+'" data="'+pid+'"></iframe>').appendTo('head');
var sel = $(this); var hght = $(sel).parents('.post').height();
$.get(href,function(data) {setFrameContent(data,pid,'rLFRam_');});
});
$('.post').find('input[name="preview"]').live('click',function() {
history.replaceState(null, null, $(this).parents('.post').find('.pl-edit>a').attr('href'));
});
$('.post').find('input[name="submit"]').live('click',function(e) {
e.preventDefault();var stDoc=document.URL,
L2=$(this).parents('.post').find('.pl-edit>a').attr('href');
history.replaceState(null, null, L2);
setTimeout(function(){history.replaceState(null, null, stDoc);},20);
$(this).attr('disabled','disabled');
var form = $(this).parents('form');
setTimeout(function(){ajaxSendForm(form);},12);
});
//======== End:== Обработка кликов ============//
}());
</script>