spacevillain (spacevillain) wrote in changelog,
spacevillain
spacevillain
changelog

[livejournal] r23421: LJSUP-14448: [Visual editor] Paste adds ...

Committer: atyurin
LJSUP-14448: [Visual editor] Paste adds line break
U   trunk/htdocs/js/ck/ckeditor.js
U   trunk/htdocs/js/ck/plugins/livejournal/plugin.js
Modified: trunk/htdocs/js/ck/ckeditor.js
===================================================================
--- trunk/htdocs/js/ck/ckeditor.js	2012-12-05 12:08:16 UTC (rev 23420)
+++ trunk/htdocs/js/ck/ckeditor.js	2012-12-05 12:14:02 UTC (rev 23421)
@@ -137,12 +137,12 @@
 A.selectNodeContents(u.document.getBody());A.collapse(true);v.selectRanges([A]);}},100);};a.editor.prototype.isFocusAt=function(t){var u=this.getSelection(),v=u.getRanges()[0],w=this.document.getBody();if(t==='end'&&v.checkEndOfBlock())if(w.equals(v.endContainer)||w.getLast().equals(v.endContainer))return true;if(t==='start')throw new Error('Not implemented');return false;};a.editor.prototype.isSelectionCollapsed=function(){var t=this.getSelection(),u=t&&t.getRanges()[0];if(u)return!!u.collapsed;return false;};var m=a.lang[a.lang.detect()]||{};jQuery.extend(m,LJ.pageVar('rtedata'));window.CKLang=a.CKLang=m;if(Site.page.ljpost)a.styleText=Site.statprefix+'/js/ck/contents_new.css?t='+Site.version;else a.styleText=Site.statprefix+'/js/ck/contents.css?t='+Site.version;var n='@focus@',o='<input type="hidden" id="__focus"/>';function p(t,u,v){v=v||{};v&&jQuery.extend(v,{fromDoubleClick:this.execFromEditor});LiveJournal.run_hook('rteButton',u,jQuery('.cke_button_'+t),v);this.execFromEditor=false;};var q=[{label:m.LJLike_button_repost,id:'repost',abbr:'rp',checked:true,html:'<span class="lj-like-item rp">'+m.LJLike_button_repost+'</span>',htmlOpt:'<li class="like-rp"><input type="checkbox" id="like-rp" /><label for="like-rp">'+m.LJLike_button_repost+'</label></li>'},{label:m.LJLike_button_facebook,id:'facebook',abbr:'fb',checked:true,html:'<span class="lj-like-item fb">'+m.LJLike_button_facebook+'</span>',htmlOpt:'<li class="like-fb"><input type="checkbox" id="like-fb" /><label for="like-fb">'+m.LJLike_button_facebook+'</label></li>'},{label:m.LJLike_button_twitter,id:'twitter',abbr:'tw',checked:true,html:'<span class="lj-like-item tw">'+m.LJLike_button_twitter+'</span>',htmlOpt:'<li class="like-tw"><input type="checkbox" id="like-tw" /><label for="like-tw">'+m.LJLike_button_twitter+'</label></li>'},{label:m.LJLike_button_google,id:'google',abbr:'go',checked:true,html:'<span class="lj-like-item go">'+m.LJLike_button_google+'</span>',htmlOpt:'<li class="like-go"><input type="checkbox" id="like-go" /><label for="like-go">'+m.LJLike_button_google+'</label></li>'},{label:m.LJLike_button_vkontakte,id:'vkontakte',abbr:'vk',checked:Site.remote_is_sup?true:false,html:'<span class="lj-like-item vk">'+m.LJLike_button_vkontakte+'</span>',htmlOpt:Site.remote_is_sup?'<li class="like-vk"><input type="checkbox" id="like-vk" /><label for="like-vk">'+m.LJLike_button_vkontakte+'</label></li>':''},{label:m.LJLike_button_surfingbird,id:'surfingbird',abbr:'sb',checked:Site.remote_is_sup?true:false,html:'<span class="lj-like-item sb">'+m.LJLike_button_surfingbird+'</span>',htmlOpt:Site.remote_is_sup?'<li class="like-sb"><input type="checkbox" id="like-sb" /><label for="like-sb">'+m.LJLike_button_surfingbird+'</label></li>':''},{label:m.LJLike_button_tumblr,id:'tumblr',abbr:'tb',checked:true,html:'<span class="lj-like-item tb">'+m.LJLike_button_tumblr+'</span>',htmlOpt:'<li class="like-tb"><input type="checkbox" id="like-tb" /><label for="like-tb">'+m.LJLike_button_tumblr+'</label></li>'},{label:m.LJLike_button_give,id:'livejournal',abbr:'lj',checked:false,html:'<span class="lj-like-item lj">'+m.LJLike_button_give+'</span>',htmlOpt:'<li class="like-lj"><input type="checkbox" id="like-lj" /><label for="like-lj">'+m.LJLike_button_give+'</label></li>'}],r={LJPollLink:{html:encodeURIComponent(m.Poll_PollWizardNotice+'<br /><a href="#" lj-cmd="LJPollLink">'+m.Poll_PollWizardNoticeLink+'</a>')},LJLike:{html:encodeURIComponent(m.LJLike_WizardNotice+'<br /><a href="#" lj-cmd="LJLike">'+m.LJLike_WizardNoticeLink+'</a>')},LJLink2:{html:encodeURIComponent(m.LJLink_WizardNotice+'<br /><a href="#" lj-cmd="LJLink2">'+m.LJLink_WizardNoticeLink+'</a>')},LJImage:{html:encodeURIComponent(m.LJImage_WizardNotice+'<br /><a href="#" lj-cmd="LJImage">'+m.LJImage_WizardNoticeLink+'</a>')},LJCut:{html:encodeURIComponent(m.LJCut_WizardNotice+'<br /><a href="#" lj-cmd="LJCut">'+m.LJCut_WizardNoticeLink+'</a>')},LJSpoiler:{html:encodeURIComponent(m.LJSpoiler_WizardNotice+'<br /><a href="#" lj-cmd="LJSpoiler">'+m.LJSpoiler_WizardNoticeLink+'</a>')},LJEmbedLink:{},LJMap:{}},s=f;
 s.$block['lj-template']=1;s.$block['lj-raw']=1;s.$block['lj-cut']=1;s.$block['lj-spoiler']=1;s.$block['lj-poll']=1;s.$block['lj-repost']=1;s.$block['lj-pq']=1;s.$block['lj-pi']=1;s.$nonEditable['lj-template']=1;s.$empty['lj-random']=1;s['lj-template']={};s['lj-map']={};s['lj-repost']={};s['lj-raw']=s.div;s['lj-poll']={'lj-pq':1};s['lj-pq']={'#':1,'lj-pi':1};s['lj-pi']={'#':1};['a','b','em','i','img','strong','u','lj-user'].forEach(function(t){s['lj-pq'][t]=1;s['lj-pi'][t]=1;});s.$block.iframe=s.$inline.iframe;delete s.$inline.iframe;e.extend(s['lj-cut']={},s.$block);e.extend(s['lj-spoiler']={},s.$block);e.extend(s['lj-cut'],s.$inline);e.extend(s['lj-spoiler'],s.$inline);e.extend(s.div,s.$block);e.extend(s.$body,s.$block);delete s['lj-cut']['lj-cut'];f.p.iframe=1;f['lj-cut'].iframe=1;f['lj-spoiler'].iframe=1;j.add('livejournal',{init:function(t){t.rteButton=p;function u(A){var B=A.data.element||A.data.getTarget();if(B.type!=1)B=B.getParent();while(B){var C=B.getAttribute('lj-cmd');if(r.hasOwnProperty(C)){var D=t.getCommand(C);if(D.state==1){var E=new d.selection(t.document);r[C].node=B.is('body')?new h.get(B.getWindow().$.frameElement):B;E.selectElement(r[C].node);A.data.dialog='';t.execFromEditor=true;t.execCommand(C,true);break;}}B=B.getParent();}};function v(A){var B=this;if(B.$!=t.document.$){B.$.className=(B.frame.getAttribute('lj-class')||'')+' lj-selected';if(B.getAttribute('lj-cmd')=='LJPollLink')B.frame.setStyle('height',B.getDocument().$.body.scrollHeight+'px');t.focus();new d.selection(t.document).selectElement(B.frame);}A.data.getKey()==1&&A.data.preventDefault();};function w(A){if(A.data.getKey()==46){var B=new d.selection(t.document).getRanges(),C=B.length;while(C--)B[C].deleteContents();}};function x(){var D=this;var A=D.$.contentWindow,B=A.document,C=new h.get(B.body);if(C.on&&!Site.page.disabled_input){C.on('dblclick',u);C.on('click',v);C.on('keyup',w);if(D.getAttribute('lj-cmd')=='LJPollLink'&&D.hasAttribute('style'))B.body.className='lj-poll lj-poll-open';}B=new h.get(B);B.frame=C.frame=D;};function y(){var A=t.document.getElementsByTag('iframe'),B=A.count(),C,D,E,F,G;t.execFromEditor=false;while(B--){C=A.getItem(B),D=C.getAttribute('lj-cmd'),E=C.$.contentWindow,F=E.document,G=C.getAttribute('lj-style')||'';if(C.getAttribute('data-update')==='false')continue;if(F&&F.body&&F.body.getAttribute('data-loaded'))continue;C.removeListener('load',x);C.on('load',x);F.open();F.write('<!DOCTYPE html><html style="'+G+'">'+'<head><link rel="stylesheet" href="'+a.styleText+'" /></head>'+'<body data-loaded="true" scroll="no" class="'+(C.getAttribute('lj-class')||'')+'" style="'+G+'" '+(D?'lj-cmd="'+D+'"':'')+'>'+decodeURIComponent(C.getAttribute('lj-content')||'')+'</body>'+'</html>');
 F.close();}};t.updateFrames=y;t.on('dataReady',function(){setTimeout(y,100);});function z(A){t.fire('updateSnapshot');if(t.onSwitch===true){delete t.onSwitch;return;}var B,C=A.name=='click',D=A.name=='selectionChange'||C,E=A.data.element||A.data.getTarget(),F,G;if(C&&(A.data.getKey()===1||A.data.$.button===0))A.data.preventDefault();if(E.type!=1)E=E.getParent();F=E;if(D){var H=t.document.getElementsByTag('iframe'),I,J;if(C&&F.is('iframe')){J=F.$.contentWindow.document.body;J.className=(F.getAttribute('lj-class')||'')+' lj-selected';if(F.getAttribute('lj-cmd')=='LJPollLink')F.setStyle('height',J.scrollHeight+'px');}for(var K=0,L=H.count();K<L;K++){I=H.getItem(K);if(I.$!=F.$){J=I.$.contentWindow.document.body;J.className=I.getAttribute('lj-class')||'';if(I.getAttribute('lj-cmd')=='LJPollLink'&&J.className.indexOf('lj-poll')!=-1)I.removeAttribute('style');}}}do{var M=F.getAttribute('lj-cmd');if(!M&&F.type==1){var N=F.getParent();if(F.is('img')&&!F.hasAttribute('data-user')&&N.getParent()&&!N.getParent().hasAttribute('data-user')){M='LJImage';F.setAttribute('lj-cmd',M);}else if(F.is('a')&&!F.hasAttribute('data-user')&&!N.hasAttribute('lj:user')){M='LJLink2';F.setAttribute('lj-cmd',M);}}if(M&&r.hasOwnProperty(M)){if(D){r[M].node=F;t.getCommand(M).setState(1);}(B||(B={}))[M]={content:r[M].html,node:F};}}while(F=F.getParent());var O;if(D)for(G in r){if(r.hasOwnProperty(G)&&(!B||!B.hasOwnProperty(G))){delete r[G].node;O=t.getCommand(G);if(O)O.setState(2);}}t.fire('updateSnapshot');};(function(){function A(I){return I.slice(-2)=='/>'?I:I.slice(0,-1)+'/>';};function B(I){var J=new Poll(I),K="<div class='lj-poll-inner lj-rtebox-inner'>"+J.outputHTML()+'</div>';return '<iframe class="lj-poll-wrap lj-rtebox" lj-class="lj-poll" frameborder="0" lj-cmd="LJPollLink" allowTransparency="true" lj-data="'+J.outputLJtags()+'" lj-content="'+K+'"></iframe>';};function C(I,J){var K="<div class='lj-poll-inner lj-rtebox-inner'>Poll id: "+J+'</div>';return '<iframe class="lj-poll-wrap lj-poll-wrap-done lj-rtebox" lj-class="lj-poll" frameborder="0" lj-cmd="LJPollLink" allowTransparency="true" lj-data="'+escape(I)+'" lj-content="'+K+'" data-disabledPoll="true"></iframe>';};function D(I,J,K){var L="<div class='lj-embed-inner lj-rtebox-inner'>Embed video</div>";return '<iframe class="lj-embed-wrap lj-rtebox" lj-class="lj-embed" frameborder="0" lj-cmd="LJEmbedLink" allowTransparency="true" lj-data="'+encodeURIComponent(K)+'"'+J+'lj-content="'+L+'"></iframe>';};function E(I,J,K,L){return J+K.replace(/\n/g,'')+L;
-};function F(I,J,K,L){var M=J||K||m.LJRepost_Value,N=L.replace(/"/g,'&quot;');L=N+('<br /><input type="button" value="'+M+'" />').replace(/"/g,'&quot;');return '<iframe class="lj-repost-wrap" lj-class="lj-repost" frameborder="0" allowTransparency="true" lj-text="'+N+'" lj-button="'+M+'" lj-content="'+L+'"></iframe>';};function G(I,J){return I.replace(/<(.|\n)*?>/g,function(K){var L=K;if(L.indexOf(J)!==-1){L=L.replace(J,'');return L+J;}else return K;});};function H(I,J,K){return[I.slice(0,J),K,I.slice(J)].join('');};t.on('contentDom',function(I){var J=I.editor.document.getById('__focus');if(J){this._domBuilt=true;setTimeout(function(){I.editor.focus();var K=I.editor.getSelection();if(K){var L=new d.range(I.editor.document);L.setEndAfter(J);K.selectRanges([L]);}J.remove();t.fire('updateSnapshot');},this._domBuilt?0:100);}});t.dataProcessor.toHtml=function(I,J){var K=Site.page.__htmlLast;if(typeof K==='number')if(I.length>0)I=G(H(I,K,n),n).replace(n,o);else I=o;I=I.replace(/<lj [^>]*?>/gi,A).replace(/<lj-map [^>]*?>/gi,A).replace(/<lj-template[^>]*?>/gi,A).replace(/(<lj-cut[^>]*?)\/>/gi,'$1>').replace(/<((?!br)[^\s>]+)([^>]*?)\/>/gi,'<$1$2></$1>').replace(/<lj-poll.*?>[\s\S]*?<\/lj-poll>/gi,B).replace(/<lj-poll-([0-9]+)>/gi,C).replace(/<lj-repost\s*(?:button\s*=\s*(?:"([^"]*?)")|(?:"([^']*?)"))?.*?>([\s\S]*?)<\/lj-repost>/gi,F).replace(/<lj-embed(.*?)>([\s\S]*?)<\/lj-embed>/gi,D);I=I.replace(/>\s+<tr/ig,'><tr').replace(/>\s+<\/tr/ig,'></tr').replace(/>\s+<td/ig,'><td').replace(/>\s+<\/td/ig,'></td').replace(/<\/tr>\s+<\/table>/ig,'</tr></table>').replace(/<tr>\n/ig,'<tr>').replace(/\n<\/tr>/ig,'</tr>').replace(/<td>\n/ig,'<td>').replace(/\n<\/td>/ig,'</td>');if(!$('event_format').checked){I=I.replace(/(<lj-raw.*?>)([\s\S]*?)(<\/lj-raw>)/gi,E);I=I.replace(/\n/g,'<br/>');}I=a.htmlDataProcessor.prototype.toHtml.call(this,I,J);if(c)I='<xml:namespace ns="livejournal" prefix="lj" />'+I;return I;};})();t.dataProcessor.toDataFormat=function(A,B){A=a.htmlDataProcessor.prototype.toDataFormat.call(this,A,B);if(!$('event_format').checked)A=A.replace(/<br\s*\/>/gi,'\n');return A.replace(/\t/g,' ');};t.dataProcessor.writer.indentationChars='';t.dataProcessor.writer.lineBreakChars='';t.on('selectionChange',z);t.on('doubleclick',u);t.on('afterCommandExec',y);t.on('dialogHide',y);t.on('dataReady',function(){if(c){t.document.getBody().on('dragend',y);t.document.getBody().on('paste',function(){setTimeout(y,0);});}if(!Site.page.disabled_input){t.document.on('click',z);t.document.on('mouseover',z);
-t.document.getBody().on('keyup',w);y();}});(function(){var A='LJImage',B=null;LiveJournal.register_hook('editpic_response',function(C){var D=B,E=D&&D.getParent();if(!D)return;if(C.url){D.setAttribute('src',C.url);D.setAttribute('data-cke-saved-src',C.url);}else{if(E&&E.getName()==='a')E.remove();else D.remove();return;}if(C.width)D.setAttribute('width',C.width);else D.removeAttribute('width');if(C.height)D.setAttribute('height',C.height);else D.removeAttribute('height');if(C.title)D.setAttribute('title',C.title);else D.removeAttribute('title');if(C.border)D.setStyle('border-width',C.border+'px');else{D.removeStyle('border-width');D.removeStyle('border-style');}if(C.vspace)D.setStyles({'margin-top':C.vspace+'px','margin-bottom':C.vspace+'px'});else{D.removeStyle('margin-top');D.removeStyle('margin-bottom');}if(C.hspace)D.setStyles({'margin-left':C.hspace+'px','margin-right':C.hspace+'px'});else{D.removeStyle('margin-left');D.removeStyle('margin-right');}var E=D&&D.getParent();if(C.link){C.link=C.link.replace(/^[\s\t]*(?:http:\/\/)?/,'http://');if(E&&E.getName()==='a'){E.setAttribute('href',C.link);E.setAttribute('data-cke-saved-href',C.link);if(C.blank)E.setAttribute('target','_blank');else E.removeAttribute('target');}else{var F=new h('a',t.document);F.setAttribute('href',C.link);if(C.blank)F.setAttribute('target','_blank');D.insertBeforeMe(F);F.append(D);t.getSelection()&&t.getSelection().selectElement(F);}}else if(E.getName()==='a'){E.insertBeforeMe(D);E.remove();}if(C.aligment&&C.aligment!=='none')D.setStyle('float',C.aligment);else D.removeStyle('float');B=null;});t.addCommand(A,{exec:function(C,D){var E=C.getSelection();E=E?E.getSelectedElement():null;B=E;if(E){var F=E&&E.getParent(),G=F.getName()==='a',H=G&&F,I=G&&F.getAttribute('href'),J={};if('naturalWidth' in E.$){J.width=E.$.naturalWidth;J.height=E.$.naturalHeight;}else{var K=new Image();K.src=E.$.src;J={width:K.width,height:K.height};}C.rteButton(A,'editpic',{picData:{url:E.getAttribute('src'),title:E.getAttribute('title'),width:E.getAttribute('width')||E.$.width,height:E.getAttribute('height')||E.$.height,defaultWidth:J.width,defaultHeight:J.height,link:I||'',blank:G?!!H.getAttribute('target'):true,border:parseInt(E.getStyle('border-width'),10),vspace:parseInt(E.getStyle('margin-top'),10),hspace:parseInt(E.getStyle('margin-left'),10),aligment:E.getStyle('float')||'none'}});}else jQuery('.b-updatepage-event-section').editor('handleImageUpload','upload');},editorFocus:false});t.ui.addButton(A,{label:m.LJImage_Title,command:A});
-})();(function(){var A=null;t.on('selectionChange',function(E){var F=E.data.element;if(F.is('iframe'))A=F;else A=null;});var B='LJEmbedLink',C='video';function D(E){var F=new h('iframe',t.document);if(E!==LiveJournal.getEmbed(E)){var G=h.createFromHtml(LiveJournal.getEmbed(E)),H='',I=LiveJournal.parseMediaLink(E);if(I.preview)H='style="background-image: url('+I.preview+');"';F.setAttribute('lj-url',G.getAttribute('src'));F.setAttribute('data-link',E);F.setAttribute('lj-class','lj-iframe');F.setAttribute('class','lj-iframe-wrap lj-rtebox');F.setAttribute('style','width: 490px; height:370px;');F.setAttribute('lj-style','width: 480px; height:360px;');F.setAttribute('allowfullscreen','true');F.setAttribute('lj-content',encodeURIComponent('<div '+H+" class='lj-embed-inner lj-rtebox-inner'>"+(H?'':'iframe')+'</div>'));}else{F.setAttribute('lj-class','lj-embed');F.setAttribute('class','lj-embed-wrap lj-rtebox');F.setAttribute('lj-content',encodeURIComponent('<div '+H+" class='lj-embed-inner lj-rtebox-inner'>Embed</div>"));}F.setAttribute('lj-data',encodeURIComponent(LiveJournal.getEmbed(E)));F.setAttribute('frameBorder',0);F.setAttribute('allowTransparency','true');F.setAttribute('lj-cmd',B);t.insertElement(F);y();};LiveJournal.register_hook(C+'_response',function(E){D(E);});t.addCommand(B,{exec:function(E){var F=r[B].node||A;if(F)E.rteButton(B,C,{defaultText:F&&decodeURIComponent(F.getAttribute('data-link')||F.getAttribute('lj-url')||F.getAttribute('lj-data')),editMode:true});else E.rteButton(B,C);}});t.ui.addButton(B,{label:m.LJEmbed,command:B});})();(function(){var A='LJMap',B='map';LiveJournal.register_hook('map_response',function(C){var D=new h('iframe',t.document),E=425,F=350,G='',H='';if(!isNaN(E)){G+='width:'+E+'px;';H+='width:'+(E-2)+'px;';}if(!isNaN(F)){G+='height:'+F+'px;';H+='height:'+(F-2)+'px;';}var I=r[A].node;if(I)I.setAttributes({'lj-url':C});else{D.setAttributes({'lj-url':C,'class':'lj-map-wrap lj-rtebox','lj-content':'<div class="lj-map-inner lj-rtebox-inner"><p class="lj-map">map</p></div>','lj-cmd':'LJMap','lj-class':'lj-map',frameborder:0,allowTransparency:'true',style:G,'lj-style':H});t.insertElement(D);}y();});t.addCommand(A,{exec:function(){var C=r[A].node;t.rteButton(A,B,{defaultText:C?C.getAttribute('lj-url'):'',editMode:C?true:false});},editorFocus:false});t.ui.addButton(A,{label:m.LJMap_Title,command:A});})();(function(){function A(H,I){I=I===undefined||I;var J,K=r.LJLike.node;if(K){var L=H.getAttribute('lj-style');J=L?L.replace(/text-align:\s*(left|right|center)/i,'$1'):'left';
-}else if(I)J=H.getComputedStyle('text-align');else{while(!H.hasAttribute||!(H.hasAttribute('align')||H.getStyle('text-align'))){var M=H.getParent();if(!M)break;H=M;}J=H.getStyle('text-align')||H.getAttribute('align')||'';}J&&(J=J.replace(/-moz-|-webkit-|start|auto/i,''));!J&&I&&(J=H.getComputedStyle('direction')=='rtl'?'right':'left');return J;};function B(H){if(H.editor.readOnly)return;var I=H.editor.getCommand(this.name),J=H.data.element;if((J.type==1&&J.hasAttribute('lj-cmd')&&J.getAttribute('lj-cmd'))=='LJLike')I.state=A(J,t.config.useComputedState)==this.value?1:2;else if(!J||J.type!=1||J.getName()=='body'||J.getName()=='iframe')I.state=2;else I.state=A(J,t.config.useComputedState)==this.value?1:2;I.fire('state');};function C(H,I,J){var L=this;L.name=I;L.value=J;var K=H.config.justifyClasses;if(K){switch(J){case 'left':L.cssClassName=K[0];break;case 'center':L.cssClassName=K[1];break;case 'right':L.cssClassName=K[2];break;}L.cssClassRegex=new RegExp('(?:^|\\s+)(?:'+K.join('|')+')(?=$|\\s)');}};function D(H){var I=H.editor,J=new d.range(I.document);J.setStartBefore(H.data.node);J.setEndAfter(H.data.node);var K=new d.walker(J),L;while(L=K.next()){if(L.type==1){var M='text-align',N=I.config.justifyClasses;if(!L.equals(H.data.node)&&L.getDirection()){J.setStartAfter(L);K=new d.walker(J);continue;}if(N)if(L.hasClass(N[0])){L.removeClass(N[0]);L.addClass(N[2]);}else if(L.hasClass(N[2])){L.removeClass(N[2]);L.addClass(N[0]);}switch(L.getStyle(M)){case 'left':L.setStyle(M,'right');break;case 'right':L.setStyle(M,'left');break;}}}};C.prototype={exec:function(H){var V=this;var I=H.getSelection(),J=H.config.enterMode;if(!I)return;var K=I.createBookmarks();if(r.LJLike.node)r.LJLike.node.setAttribute('lj-style','text-align: '+V.value);else{var L=I.getRanges(true),M=V.cssClassName,N,O,P=H.config.useComputedState;P=P===undefined||P;for(var Q=L.length-1;Q>=0;Q--){var R=L[Q],S=R.getEnclosedNode();if(S&&S.type===1&&S.is('iframe'))return;N=R.createIterator();N.enlargeBr=J!=2;while(O=N.getNextParagraph(J==1?'p':'div')){O.removeAttribute('align');O.removeStyle('text-align');var T=M&&(O.$.className=e.ltrim(O.$.className.replace(V.cssClassRegex,''))),U=V.state==2&&(!P||A(O,true)!=V.value);if(M){if(U)O.addClass(M);else if(!T)O.removeAttribute('class');}else if(U)O.setStyle('text-align',V.value);}}}H.focus();H.forceNextSelectionCheck();I.selectBookmarks(K);}};var E=new C(t,'LJJustifyLeft','left'),F=new C(t,'LJJustifyCenter','center'),G=new C(t,'LJJustifyRight','right');t.addCommand('LJJustifyLeft',E);
-t.addCommand('LJJustifyCenter',F);t.addCommand('LJJustifyRight',G);t.ui.addButton('LJJustifyLeft',{label:t.lang.justify.left,command:'LJJustifyLeft'});t.ui.addButton('LJJustifyCenter',{label:t.lang.justify.center,command:'LJJustifyCenter'});t.ui.addButton('LJJustifyRight',{label:t.lang.justify.right,command:'LJJustifyRight'});t.on('selectionChange',e.bind(B,E));t.on('selectionChange',e.bind(B,G));t.on('selectionChange',e.bind(B,F));t.on('dirChanged',D);})();(function(){var A='LJPollLink';if(!LJ.pageVar('remoteUser',true))return;LiveJournal.register_hook('poll_response',function(B){var C=new Poll(B),D="<div class='lj-poll-inner lj-rtebox-inner'>"+C.outputHTML()+'</div>',E=C.outputLJtags(),F=r[A].node;if(F){F.setAttribute('lj-content',D);F.setAttribute('lj-data',E);F.removeAttribute('style');}else{F=new h('iframe',t.document);F.setAttribute('lj-content',D);F.setAttribute('lj-cmd','LJPollLink');F.setAttribute('lj-data',E);F.setAttribute('lj-class','lj-poll lj-rtebox');F.setAttribute('class','lj-poll-wrap');F.setAttribute('frameBorder',0);F.setAttribute('allowTransparency','true');t.insertElement(F);}y();});t.addCommand(A,{exec:function(B){var C=r.LJPollLink.node;if(C)B.rteButton(A,'poll',{ljData:decodeURIComponent(C.getAttribute('lj-data')),editMode:true,disabled:C&&(C.getAttribute('data-disabledPoll')?true:false)});else B.rteButton(A,'poll');},editorFocus:false});t.ui.addButton(A,{label:m.LJPoll_Title,command:A});})();(function(){var A='LJLike',B='like',C;q.defaultButtons=[];for(var D=0;D<q.length;D++){C=q[D];q[C.id]=q[C.abbr]=C;q.defaultButtons.push(C.id);}LiveJournal.register_hook('like_response',function(E){var F=[],G=[],H=typeof E==='string';for(var I=0,J;I<q.length;I++){J=q[I];if(H&&J.checked||E.indexOf(J.id)!=-1){F.push(J.id);G.push(J.html);}}var K=r[A].node,L=encodeURIComponent('<div class="lj-rtebox-inner lj-like-inner"><span class="lj-like-wrapper">'+G.join('')+'</span></div>');if(K){K.setAttribute('buttons',F.join(','));K.setAttribute('lj-content',L);K.removeAttribute('defaults');}else{K=new h('iframe',t.document);K.setAttribute('lj-class','lj-like');K.setAttribute('class','lj-like-wrap lj-rtebox');K.setAttribute('buttons',F.join(','));K.setAttribute('lj-content',L);K.setAttribute('lj-cmd','LJLike');K.setAttribute('frameBorder',0);K.setAttribute('allowTransparency','true');K.setAttribute('defaults',H);t.insertElement(K);}y();});t.addCommand(A,{exec:function(E){var F=r[A].node;if(F)E.rteButton(A,B,{buttons:F.getAttribute('buttons'),editMode:true});else E.rteButton(A,B);
-},editorFocus:false});t.ui.addButton(A,{label:m.LJLike_Title,command:A});})();},afterInit:function(t){var u=t.dataProcessor;u.dataFilter.addRules({elements:{'lj-like':function(v){var w=[],x=new a.htmlParser.element('iframe');x.attributes['lj-class']='lj-like';x.attributes['class']='lj-like-wrap lj-rtebox';if(v.attributes.hasOwnProperty('style'))x.attributes['lj-style']=v.attributes.style;x.attributes['lj-cmd']='LJLike';x.attributes['lj-content']='<div class="lj-rtebox-inner lj-like-inner"><span class="lj-like-wrapper">';x.attributes.frameBorder=0;x.attributes.allowTransparency='true';var y=v.attributes.buttons&&v.attributes.buttons.split(',')||q.defaultButtons,z=v.attributes.buttons?true:false,A=y.length;for(var B=0;B<A;B++){var C=y[B].replace(/^\s*([a-z]{2,})\s*$/i,'$1'),D=q[C];if(D&&(z||D.checked)){x.attributes['lj-content']+=encodeURIComponent(D.html);w.push(C);}}if(!v.attributes.buttons)x.attributes.defaults=true;x.attributes['lj-content']+='</span></div>';x.attributes.buttons=w.join(',');return x;},'lj-map':function(v){var w=new a.htmlParser.element('iframe'),x='',y='',z=Number(v.attributes.width),A=Number(v.attributes.height);if(!isNaN(z)){x+='width:'+z+'px;';y+='width:'+(z-2)+'px;';}if(!isNaN(A)){x+='height:'+A+'px;';y+='height:'+(A-2)+'px;';}if(x.length){w.attributes.style=x;w.attributes['lj-style']=y;}w.attributes['lj-url']=v.attributes.url?encodeURIComponent(v.attributes.url):'';w.attributes['lj-class']='lj-map';w.attributes['class']='lj-map-wrap lj-rtebox';w.attributes['lj-content']='<div class="lj-map-inner lj-rtebox-inner"><p class="lj-map">map</p></div>';w.attributes.frameBorder=0;w.attributes.allowTransparency='true';return w;},'lj-raw':function(v){v.name='lj:raw';},'lj-wishlist':function(v){v.name='lj:wishlist';},'lj-template':function(v){var w=new a.htmlParser.element('iframe');w.attributes['lj-class']='lj-template';w.attributes['class']='lj-template-wrap';w.attributes.frameBorder=0;w.attributes.allowTransparency='true';w.attributes['lj-attributes']=encodeURIComponent(LiveJournal.JSON.stringify(v.attributes));return w;},iframe:function(v){if(v.attributes['data-update']==='false')return v;var w='';if(v.attributes['data-link']){var x=LiveJournal.parseMediaLink(v.attributes['data-link']);if(x.preview)w='style="background-image: url('+x.preview+');"';}var y=v.attributes.src;if(v.attributes['lj-class']&&v.attributes['lj-class'].indexOf('lj-')+1==1)return v;var z=new a.htmlParser.element('iframe'),A='',B='',C=Number(v.attributes.width),D=Number(v.attributes.height);
+};function F(I,J,K,L){var M=J||K||m.LJRepost_Value,N=L.replace(/"/g,'&quot;');L=N+('<br /><input type="button" value="'+M+'" />').replace(/"/g,'&quot;');return '<iframe class="lj-repost-wrap" lj-class="lj-repost" frameborder="0" allowTransparency="true" lj-text="'+N+'" lj-button="'+M+'" lj-content="'+L+'"></iframe>';};function G(I,J){return I.replace(/<(.|\n)*?>/g,function(K){var L=K;if(L.indexOf(J)!==-1){L=L.replace(J,'');return L+J;}else return K;});};function H(I,J,K){return[I.slice(0,J),K,I.slice(J)].join('');};t.on('contentDom',function(I){var J=I.editor.document.getById('__focus');if(J){this._domBuilt=true;setTimeout(function(){I.editor.focus();var K=I.editor.getSelection();if(K){var L=new d.range(I.editor.document);L.setEndAfter(J);K.selectRanges([L]);}J.remove();t.fire('updateSnapshot');},this._domBuilt?0:100);}});t.dataProcessor.toHtml=function(I,J){var K=Site.page.__htmlLast;if(typeof K==='number')if(I.length>0)I=G(H(I,K,n),n).replace(n,o);else I=o;I=I.replace(/<lj [^>]*?>/gi,A).replace(/<lj-map [^>]*?>/gi,A).replace(/<lj-template[^>]*?>/gi,A).replace(/(<lj-cut[^>]*?)\/>/gi,'$1>').replace(/<((?!br)[^\s>]+)([^>]*?)\/>/gi,'<$1$2></$1>').replace(/<lj-poll.*?>[\s\S]*?<\/lj-poll>/gi,B).replace(/<lj-poll-([0-9]+)>/gi,C).replace(/<lj-repost\s*(?:button\s*=\s*(?:"([^"]*?)")|(?:"([^']*?)"))?.*?>([\s\S]*?)<\/lj-repost>/gi,F).replace(/<lj-embed(.*?)>([\s\S]*?)<\/lj-embed>/gi,D);I=I.replace(/>\s+<tr/ig,'><tr').replace(/>\s+<\/tr/ig,'></tr').replace(/>\s+<td/ig,'><td').replace(/>\s+<\/td/ig,'></td').replace(/<\/tr>\s+<\/table>/ig,'</tr></table>').replace(/<tr>\n/ig,'<tr>').replace(/\n<\/tr>/ig,'</tr>').replace(/<td>\n/ig,'<td>').replace(/\n<\/td>/ig,'</td>');if(!$('event_format').checked){I=I.replace(/(<lj-raw.*?>)([\s\S]*?)(<\/lj-raw>)/gi,E);I=I.replace(/\n/g,'<br/>');}I=a.htmlDataProcessor.prototype.toHtml.call(this,I,J);if(c)I='<xml:namespace ns="livejournal" prefix="lj" />'+I;return I;};})();t.dataProcessor.toDataFormat=function(A,B){A=a.htmlDataProcessor.prototype.toDataFormat.call(this,A,B);if(!$('event_format').checked)A=A.replace(/<br\s*\/>/gi,'\n');return A.replace(/\t/g,' ');};t.dataProcessor.writer.indentationChars='';t.dataProcessor.writer.lineBreakChars='';t.on('selectionChange',z);t.on('doubleclick',u);t.on('afterCommandExec',y);t.on('dialogHide',y);(function(){var A=/<br\s*\/?>$/i;t.on('paste',function(B){B.data.html=B.data.html.replace(A,'');});})();t.on('dataReady',function(){if(c){t.document.getBody().on('dragend',y);t.document.getBody().on('paste',function(){setTimeout(y,0);
+});}if(!Site.page.disabled_input){t.document.on('click',z);t.document.on('mouseover',z);t.document.getBody().on('keyup',w);y();}});(function(){var A='LJImage',B=null;LiveJournal.register_hook('editpic_response',function(C){var D=B,E=D&&D.getParent();if(!D)return;if(C.url){D.setAttribute('src',C.url);D.setAttribute('data-cke-saved-src',C.url);}else{if(E&&E.getName()==='a')E.remove();else D.remove();return;}if(C.width)D.setAttribute('width',C.width);else D.removeAttribute('width');if(C.height)D.setAttribute('height',C.height);else D.removeAttribute('height');if(C.title)D.setAttribute('title',C.title);else D.removeAttribute('title');if(C.border)D.setStyle('border-width',C.border+'px');else{D.removeStyle('border-width');D.removeStyle('border-style');}if(C.vspace)D.setStyles({'margin-top':C.vspace+'px','margin-bottom':C.vspace+'px'});else{D.removeStyle('margin-top');D.removeStyle('margin-bottom');}if(C.hspace)D.setStyles({'margin-left':C.hspace+'px','margin-right':C.hspace+'px'});else{D.removeStyle('margin-left');D.removeStyle('margin-right');}var E=D&&D.getParent();if(C.link){C.link=C.link.replace(/^[\s\t]*(?:http:\/\/)?/,'http://');if(E&&E.getName()==='a'){E.setAttribute('href',C.link);E.setAttribute('data-cke-saved-href',C.link);if(C.blank)E.setAttribute('target','_blank');else E.removeAttribute('target');}else{var F=new h('a',t.document);F.setAttribute('href',C.link);if(C.blank)F.setAttribute('target','_blank');D.insertBeforeMe(F);F.append(D);t.getSelection()&&t.getSelection().selectElement(F);}}else if(E.getName()==='a'){E.insertBeforeMe(D);E.remove();}if(C.aligment&&C.aligment!=='none')D.setStyle('float',C.aligment);else D.removeStyle('float');B=null;});t.addCommand(A,{exec:function(C,D){var E=C.getSelection();E=E?E.getSelectedElement():null;B=E;if(E){var F=E&&E.getParent(),G=F.getName()==='a',H=G&&F,I=G&&F.getAttribute('href'),J={};if('naturalWidth' in E.$){J.width=E.$.naturalWidth;J.height=E.$.naturalHeight;}else{var K=new Image();K.src=E.$.src;J={width:K.width,height:K.height};}C.rteButton(A,'editpic',{picData:{url:E.getAttribute('src'),title:E.getAttribute('title'),width:E.getAttribute('width')||E.$.width,height:E.getAttribute('height')||E.$.height,defaultWidth:J.width,defaultHeight:J.height,link:I||'',blank:G?!!H.getAttribute('target'):true,border:parseInt(E.getStyle('border-width'),10),vspace:parseInt(E.getStyle('margin-top'),10),hspace:parseInt(E.getStyle('margin-left'),10),aligment:E.getStyle('float')||'none'}});}else jQuery('.b-updatepage-event-section').editor('handleImageUpload','upload');
+},editorFocus:false});t.ui.addButton(A,{label:m.LJImage_Title,command:A});})();(function(){var A=null;t.on('selectionChange',function(E){var F=E.data.element;if(F.is('iframe'))A=F;else A=null;});var B='LJEmbedLink',C='video';function D(E){var F=new h('iframe',t.document);if(E!==LiveJournal.getEmbed(E)){var G=h.createFromHtml(LiveJournal.getEmbed(E)),H='',I=LiveJournal.parseMediaLink(E);if(I.preview)H='style="background-image: url('+I.preview+');"';F.setAttribute('lj-url',G.getAttribute('src'));F.setAttribute('data-link',E);F.setAttribute('lj-class','lj-iframe');F.setAttribute('class','lj-iframe-wrap lj-rtebox');F.setAttribute('style','width: 490px; height:370px;');F.setAttribute('lj-style','width: 480px; height:360px;');F.setAttribute('allowfullscreen','true');F.setAttribute('lj-content',encodeURIComponent('<div '+H+" class='lj-embed-inner lj-rtebox-inner'>"+(H?'':'iframe')+'</div>'));}else{F.setAttribute('lj-class','lj-embed');F.setAttribute('class','lj-embed-wrap lj-rtebox');F.setAttribute('lj-content',encodeURIComponent('<div '+H+" class='lj-embed-inner lj-rtebox-inner'>Embed</div>"));}F.setAttribute('lj-data',encodeURIComponent(LiveJournal.getEmbed(E)));F.setAttribute('frameBorder',0);F.setAttribute('allowTransparency','true');F.setAttribute('lj-cmd',B);t.insertElement(F);y();};LiveJournal.register_hook(C+'_response',function(E){D(E);});t.addCommand(B,{exec:function(E){var F=r[B].node||A;if(F)E.rteButton(B,C,{defaultText:F&&decodeURIComponent(F.getAttribute('data-link')||F.getAttribute('lj-url')||F.getAttribute('lj-data')),editMode:true});else E.rteButton(B,C);}});t.ui.addButton(B,{label:m.LJEmbed,command:B});})();(function(){var A='LJMap',B='map';LiveJournal.register_hook('map_response',function(C){var D=new h('iframe',t.document),E=425,F=350,G='',H='';if(!isNaN(E)){G+='width:'+E+'px;';H+='width:'+(E-2)+'px;';}if(!isNaN(F)){G+='height:'+F+'px;';H+='height:'+(F-2)+'px;';}var I=r[A].node;if(I)I.setAttributes({'lj-url':C});else{D.setAttributes({'lj-url':C,'class':'lj-map-wrap lj-rtebox','lj-content':'<div class="lj-map-inner lj-rtebox-inner"><p class="lj-map">map</p></div>','lj-cmd':'LJMap','lj-class':'lj-map',frameborder:0,allowTransparency:'true',style:G,'lj-style':H});t.insertElement(D);}y();});t.addCommand(A,{exec:function(){var C=r[A].node;t.rteButton(A,B,{defaultText:C?C.getAttribute('lj-url'):'',editMode:C?true:false});},editorFocus:false});t.ui.addButton(A,{label:m.LJMap_Title,command:A});})();(function(){function A(H,I){I=I===undefined||I;var J,K=r.LJLike.node;
+if(K){var L=H.getAttribute('lj-style');J=L?L.replace(/text-align:\s*(left|right|center)/i,'$1'):'left';}else if(I)J=H.getComputedStyle('text-align');else{while(!H.hasAttribute||!(H.hasAttribute('align')||H.getStyle('text-align'))){var M=H.getParent();if(!M)break;H=M;}J=H.getStyle('text-align')||H.getAttribute('align')||'';}J&&(J=J.replace(/-moz-|-webkit-|start|auto/i,''));!J&&I&&(J=H.getComputedStyle('direction')=='rtl'?'right':'left');return J;};function B(H){if(H.editor.readOnly)return;var I=H.editor.getCommand(this.name),J=H.data.element;if((J.type==1&&J.hasAttribute('lj-cmd')&&J.getAttribute('lj-cmd'))=='LJLike')I.state=A(J,t.config.useComputedState)==this.value?1:2;else if(!J||J.type!=1||J.getName()=='body'||J.getName()=='iframe')I.state=2;else I.state=A(J,t.config.useComputedState)==this.value?1:2;I.fire('state');};function C(H,I,J){var L=this;L.name=I;L.value=J;var K=H.config.justifyClasses;if(K){switch(J){case 'left':L.cssClassName=K[0];break;case 'center':L.cssClassName=K[1];break;case 'right':L.cssClassName=K[2];break;}L.cssClassRegex=new RegExp('(?:^|\\s+)(?:'+K.join('|')+')(?=$|\\s)');}};function D(H){var I=H.editor,J=new d.range(I.document);J.setStartBefore(H.data.node);J.setEndAfter(H.data.node);var K=new d.walker(J),L;while(L=K.next()){if(L.type==1){var M='text-align',N=I.config.justifyClasses;if(!L.equals(H.data.node)&&L.getDirection()){J.setStartAfter(L);K=new d.walker(J);continue;}if(N)if(L.hasClass(N[0])){L.removeClass(N[0]);L.addClass(N[2]);}else if(L.hasClass(N[2])){L.removeClass(N[2]);L.addClass(N[0]);}switch(L.getStyle(M)){case 'left':L.setStyle(M,'right');break;case 'right':L.setStyle(M,'left');break;}}}};C.prototype={exec:function(H){var V=this;var I=H.getSelection(),J=H.config.enterMode;if(!I)return;var K=I.createBookmarks();if(r.LJLike.node)r.LJLike.node.setAttribute('lj-style','text-align: '+V.value);else{var L=I.getRanges(true),M=V.cssClassName,N,O,P=H.config.useComputedState;P=P===undefined||P;for(var Q=L.length-1;Q>=0;Q--){var R=L[Q],S=R.getEnclosedNode();if(S&&S.type===1&&S.is('iframe'))return;N=R.createIterator();N.enlargeBr=J!=2;while(O=N.getNextParagraph(J==1?'p':'div')){O.removeAttribute('align');O.removeStyle('text-align');var T=M&&(O.$.className=e.ltrim(O.$.className.replace(V.cssClassRegex,''))),U=V.state==2&&(!P||A(O,true)!=V.value);if(M){if(U)O.addClass(M);else if(!T)O.removeAttribute('class');}else if(U)O.setStyle('text-align',V.value);}}}H.focus();H.forceNextSelectionCheck();I.selectBookmarks(K);}};var E=new C(t,'LJJustifyLeft','left'),F=new C(t,'LJJustifyCenter','center'),G=new C(t,'LJJustifyRight','right');
+t.addCommand('LJJustifyLeft',E);t.addCommand('LJJustifyCenter',F);t.addCommand('LJJustifyRight',G);t.ui.addButton('LJJustifyLeft',{label:t.lang.justify.left,command:'LJJustifyLeft'});t.ui.addButton('LJJustifyCenter',{label:t.lang.justify.center,command:'LJJustifyCenter'});t.ui.addButton('LJJustifyRight',{label:t.lang.justify.right,command:'LJJustifyRight'});t.on('selectionChange',e.bind(B,E));t.on('selectionChange',e.bind(B,G));t.on('selectionChange',e.bind(B,F));t.on('dirChanged',D);})();(function(){var A='LJPollLink';if(!LJ.pageVar('remoteUser',true))return;LiveJournal.register_hook('poll_response',function(B){var C=new Poll(B),D="<div class='lj-poll-inner lj-rtebox-inner'>"+C.outputHTML()+'</div>',E=C.outputLJtags(),F=r[A].node;if(F){F.setAttribute('lj-content',D);F.setAttribute('lj-data',E);F.removeAttribute('style');}else{F=new h('iframe',t.document);F.setAttribute('lj-content',D);F.setAttribute('lj-cmd','LJPollLink');F.setAttribute('lj-data',E);F.setAttribute('lj-class','lj-poll lj-rtebox');F.setAttribute('class','lj-poll-wrap');F.setAttribute('frameBorder',0);F.setAttribute('allowTransparency','true');t.insertElement(F);}y();});t.addCommand(A,{exec:function(B){var C=r.LJPollLink.node;if(C)B.rteButton(A,'poll',{ljData:decodeURIComponent(C.getAttribute('lj-data')),editMode:true,disabled:C&&(C.getAttribute('data-disabledPoll')?true:false)});else B.rteButton(A,'poll');},editorFocus:false});t.ui.addButton(A,{label:m.LJPoll_Title,command:A});})();(function(){var A='LJLike',B='like',C;q.defaultButtons=[];for(var D=0;D<q.length;D++){C=q[D];q[C.id]=q[C.abbr]=C;q.defaultButtons.push(C.id);}LiveJournal.register_hook('like_response',function(E){var F=[],G=[],H=typeof E==='string';for(var I=0,J;I<q.length;I++){J=q[I];if(H&&J.checked||E.indexOf(J.id)!=-1){F.push(J.id);G.push(J.html);}}var K=r[A].node,L=encodeURIComponent('<div class="lj-rtebox-inner lj-like-inner"><span class="lj-like-wrapper">'+G.join('')+'</span></div>');if(K){K.setAttribute('buttons',F.join(','));K.setAttribute('lj-content',L);K.removeAttribute('defaults');}else{K=new h('iframe',t.document);K.setAttribute('lj-class','lj-like');K.setAttribute('class','lj-like-wrap lj-rtebox');K.setAttribute('buttons',F.join(','));K.setAttribute('lj-content',L);K.setAttribute('lj-cmd','LJLike');K.setAttribute('frameBorder',0);K.setAttribute('allowTransparency','true');K.setAttribute('defaults',H);t.insertElement(K);}y();});t.addCommand(A,{exec:function(E){var F=r[A].node;if(F)E.rteButton(A,B,{buttons:F.getAttribute('buttons'),editMode:true});
+else E.rteButton(A,B);},editorFocus:false});t.ui.addButton(A,{label:m.LJLike_Title,command:A});})();},afterInit:function(t){var u=t.dataProcessor;u.dataFilter.addRules({elements:{'lj-like':function(v){var w=[],x=new a.htmlParser.element('iframe');x.attributes['lj-class']='lj-like';x.attributes['class']='lj-like-wrap lj-rtebox';if(v.attributes.hasOwnProperty('style'))x.attributes['lj-style']=v.attributes.style;x.attributes['lj-cmd']='LJLike';x.attributes['lj-content']='<div class="lj-rtebox-inner lj-like-inner"><span class="lj-like-wrapper">';x.attributes.frameBorder=0;x.attributes.allowTransparency='true';var y=v.attributes.buttons&&v.attributes.buttons.split(',')||q.defaultButtons,z=v.attributes.buttons?true:false,A=y.length;for(var B=0;B<A;B++){var C=y[B].replace(/^\s*([a-z]{2,})\s*$/i,'$1'),D=q[C];if(D&&(z||D.checked)){x.attributes['lj-content']+=encodeURIComponent(D.html);w.push(C);}}if(!v.attributes.buttons)x.attributes.defaults=true;x.attributes['lj-content']+='</span></div>';x.attributes.buttons=w.join(',');return x;},'lj-map':function(v){var w=new a.htmlParser.element('iframe'),x='',y='',z=Number(v.attributes.width),A=Number(v.attributes.height);if(!isNaN(z)){x+='width:'+z+'px;';y+='width:'+(z-2)+'px;';}if(!isNaN(A)){x+='height:'+A+'px;';y+='height:'+(A-2)+'px;';}if(x.length){w.attributes.style=x;w.attributes['lj-style']=y;}w.attributes['lj-url']=v.attributes.url?encodeURIComponent(v.attributes.url):'';w.attributes['lj-class']='lj-map';w.attributes['class']='lj-map-wrap lj-rtebox';w.attributes['lj-content']='<div class="lj-map-inner lj-rtebox-inner"><p class="lj-map">map</p></div>';w.attributes.frameBorder=0;w.attributes.allowTransparency='true';return w;},'lj-raw':function(v){v.name='lj:raw';},'lj-wishlist':function(v){v.name='lj:wishlist';},'lj-template':function(v){var w=new a.htmlParser.element('iframe');w.attributes['lj-class']='lj-template';w.attributes['class']='lj-template-wrap';w.attributes.frameBorder=0;w.attributes.allowTransparency='true';w.attributes['lj-attributes']=encodeURIComponent(LiveJournal.JSON.stringify(v.attributes));return w;},iframe:function(v){if(v.attributes['data-update']==='false')return v;var w='';if(v.attributes['data-link']){var x=LiveJournal.parseMediaLink(v.attributes['data-link']);if(x.preview)w='style="background-image: url('+x.preview+');"';}var y=v.attributes.src;if(v.attributes['lj-class']&&v.attributes['lj-class'].indexOf('lj-')+1==1)return v;var z=new a.htmlParser.element('iframe'),A='',B='',C=Number(v.attributes.width),D=Number(v.attributes.height);
 if(v.attributes.src.indexOf('kroogi.com')!==-1&&v.attributes.style){var E=v.attributes.style.match(/width:\s([0-9]+)px;/i),F=v.attributes.style.match(/height:\s([0-9]+)px;/i);if(F.length===2&&E.length===2){C=Number(E.pop());D=Number(F.pop());}}if(!isNaN(C)){A+='width:'+C+'px;';B+='width:'+(C-10)+'px;';}if(!isNaN(D)){A+='height:'+D+'px;';B+='height:'+(D-10)+'px;';}if(A.length){z.attributes.style=A;z.attributes['lj-style']=B;}z.attributes['lj-url']=v.attributes.src?encodeURIComponent(v.attributes.src):'';z.attributes['lj-class']='lj-iframe';z.attributes['class']='lj-iframe-wrap lj-rtebox';z.attributes['lj-content']='<div '+w+' class="lj-rtebox-inner">'+(w?'':'iframe')+'</div>';z.attributes.frameBorder=0;z.attributes.allowTransparency='true';if(y!=LiveJournal.getEmbed(decodeURIComponent(v.attributes.src))){z.attributes['lj-cmd']='LJEmbedLink';z.attributes['data-link']=v.attributes['data-link'];}return z;},a:function(v){if(v.attributes['data-user'])return;if(v.parent&&v.parent.attributes&&!v.parent.attributes['lj:user'])v.attributes['lj-cmd']='LJLink2';},img:function(v){if(v.attributes['data-user'])return;var w=v.parent&&v.parent.parent;if(!w||!v.attributes['data-user']||!w.attributes||!w.attributes['data-user'])v.attributes['lj-cmd']='LJImage';}}},5);u.htmlFilter.addRules({elements:{input:function(v){if(v.attributes&&v.attributes.id==='__focus')return false;return v;}}});u.htmlFilter.addRules({elements:{iframe:function(v){var w=v,x=false,y='text',z=/lj-[a-z]+/i.exec(v.attributes['lj-class']);if(z)z=z[0];else return v;switch(z){case 'lj-like':w=new a.htmlParser.element('lj-like');if(v.attributes.defaults!='true')w.attributes.buttons=v.attributes.buttons;if(v.attributes.hasOwnProperty('lj-style'))w.attributes.style=v.attributes['lj-style'];w.isEmpty=true;w.isOptionalClose=true;break;case 'lj-embed':var A=decodeURIComponent(v.attributes['lj-data']);w=new a.htmlParser.element('lj-embed');w.attributes.id=v.attributes.id;if(v.attributes.id)w.isEmpty=true;if(v.attributes.hasOwnProperty('source_user'))w.attributes.source_user=v.attributes.source_user;w.children=new a.htmlParser.fragment.fromHtml(decodeURIComponent(v.attributes['lj-data'])).children;w.isOptionalClose=true;break;case 'lj-map':w=new a.htmlParser.element('lj-map');w.attributes.url=decodeURIComponent(v.attributes['lj-url']);v.attributes.style&&(v.attributes.style+';').replace(/([a-z-]+):(.*?);/gi,function(F,G,H){w.attributes[G.toLowerCase()]=parseInt(H);});w.isOptionalClose=w.isEmpty=true;break;case 'lj-iframe':w=new a.htmlParser.element('iframe');
 w.attributes.src=decodeURIComponent(v.attributes['lj-url']);v.attributes.style&&(v.attributes.style+';').replace(/([a-z-]+):(.*?);/gi,function(F,G,H){w.attributes[G.toLowerCase()]=parseInt(H);});w.attributes.frameBorder=0;if(v.attributes['data-link'])w.attributes['data-link']=v.attributes['data-link'];break;case 'lj-poll':var A=decodeURIComponent(v.attributes['lj-data']);w=new a.htmlParser.fragment.fromHtml(A).children[0];break;case 'lj-repost':w=new a.htmlParser.element('lj-repost');w.attributes.button=v.attributes['lj-button'];w.children=new a.htmlParser.fragment.fromHtml(v.attributes['lj-text']).children;break;case 'lj-template':w=new a.htmlParser.element('lj-template');w.attributes=LiveJournal.JSON.parse(encodeURIComponent(v.attributes['lj-attributes']));w.isOptionalClose=w.isEmpty=true;break;case 'lj-spoiler':x=true;y='title';case 'lj-cut':if(v.attributes['lj-class'].indexOf(z+'-open')+1){var B=v.next,C=0;w=new a.htmlParser.element(z);if(v.attributes.hasOwnProperty('text'))w.attributes[y]=v.attributes.text;while(B){if(B.name=='iframe'){var D=B.attributes['lj-class'];if(D&&D.indexOf(z+'-close')+1){if(x&&C)C--;else{w.next=B;break;}}else if(D&&D.indexOf(z+'-open')+1)if(x)C++;else{w.next=B;break;}}B.parent.children.remove(B);w.add(B);var E=B.next;B.next=null;B=E;}}else w=false;break;default:if(!v.children.length)w=false;}return w;},div:function(v){if(!v.children.length)return false;},'lj:raw':function(v){v.name='lj-raw';},'lj:wishlist':function(v){v.name='lj-wishlist';}},attributes:{'lj-cmd':function(){return false;},contenteditable:function(){return false;}}});},requires:['fakeobjects','domiterator']});})();(function(m,n){var o;function p(v){return v.type==3&&v.getLength()>0&&(!o||!v.isReadOnly());};function q(v){return!(v.type==1&&v.isBlockBoundary(e.extend({},f.$empty,f.$nonEditable)));};var r=function(){var v=this;return{textNode:v.textNode,offset:v.offset,character:v.textNode?v.textNode.getText().charAt(v.offset):null,hitMatchBoundary:v._.matchBoundary};},s,t=function(v,w){s=new a.style(e.extend({attributes:{'data-cke-highlight':1,'data-incorrect':1,'data-id':0},fullMatch:1,ignoreReadonly:1,childRule:function(){return 1;}},{element:'span',styles:{'border-bottom':'1px solid red',cursor:'pointer'}},true));var x=function(J,K){var L=this,M=new d.walker(J);M.guard=K?q:function(N){!q(N)&&(L._.matchBoundary=true);};M.evaluator=p;M.breakOnFalse=1;if(J.startContainer.type==3){this.textNode=J.startContainer;this.offset=J.startOffset-1;}this._={matchWord:K,walker:M,matchBoundary:false};
 };x.prototype={next:function(){return this.move();},back:function(){return this.move(true);},move:function(J){var L=this;var K=L.textNode;if(K===null)return r.call(L);L._.matchBoundary=false;if(K&&J&&L.offset>0){L.offset--;return r.call(L);}else if(K&&L.offset<K.getLength()-1){L.offset++;return r.call(L);}else{K=null;while(!K){K=L._.walker[J?'previous':'next'].call(L._.walker);if(L._.matchWord&&!K||L._.walker._.end)break;}L.textNode=K;if(K)L.offset=J?K.getLength()-1:0;else L.offset=0;}return r.call(L);}};var y=function(J,K){this._={walker:J,cursors:[],rangeLength:K,highlightRange:null,isMatched:0};};y.prototype={toDomRange:function(){var J=new d.range(v.document),K=this._.cursors;if(K.length<1){var L=this._.walker.textNode;if(L)J.setStartAfter(L);else return null;}else{var M=K[0],N=K[K.length-1];J.setStart(M.textNode,M.offset);J.setEnd(N.textNode,N.offset+1);}return J;},updateFromDomRange:function(J){var M=this;var K,L=new x(J);M._.cursors=[];do{K=L.next();if(K.character)M._.cursors.push(K);}while(K.character);M._.rangeLength=M._.cursors.length;},setMatched:function(){this._.isMatched=true;},clearMatched:function(){this._.isMatched=false;},isMatched:function(){return this._.isMatched;},highlight:function(){var M=this;if(M._.cursors.length<1)return;if(M._.highlightRange)M.removeHighlight();var J=M.toDomRange(),K=J.createBookmark();s.applyToRange(J);J.moveToBookmark(K);M._.highlightRange=J;var L=J.startContainer;if(L.type!=1)L=L.getParent();M.updateFromDomRange(J);},highlightx:function(){var L=this;if(L._.cursors.length<1)return;if(L._.highlightRange)L.removeHighlight();var J=L.toDomRange(),K=J.createBookmark();J.moveToBookmark(K);L.updateFromDomRange(J);},removeHighlight:function(J){var L=this;if(!L._.highlightRange)return;var K=L._.highlightRange.createBookmark();s.removeFromRange(J||L._.highlightRange);L._.highlightRange.moveToBookmark(K);L.updateFromDomRange(L._.highlightRange);L._.highlightRange=null;},isReadOnly:function(){if(!this._.highlightRange)return 0;return this._.highlightRange.startContainer.isReadOnly();},moveBack:function(){var L=this;var J=L._.walker.back(),K=L._.cursors;if(J.hitMatchBoundary)L._.cursors=K=[];K.unshift(J);if(K.length>L._.rangeLength)K.pop();return J;},moveNext:function(){var L=this;var J=L._.walker.next(),K=L._.cursors;if(J.hitMatchBoundary)L._.cursors=K=[];K.push(J);if(K.length>L._.rangeLength)K.shift();return J;},getEndCharacter:function(){var J=this._.cursors;if(J.length<1)return null;return J[J.length-1].character;},getNextCharacterRange:function(J){var K,L,M=this._.cursors;

Modified: trunk/htdocs/js/ck/plugins/livejournal/plugin.js
===================================================================
--- trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2012-12-05 12:08:16 UTC (rev 23420)
+++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2012-12-05 12:14:02 UTC (rev 23421)
@@ -76,16 +76,16 @@
 		        s.selectElement(node);
 		        selected_ranges = s.getRanges();
 		        selected_ranges[0].collapse(false);
-		        s.selectRanges(selected_ranges);			
+		        s.selectRanges(selected_ranges);
 			}
 
 			if (where === 'start') {
-				
+
 					var range = new CKEDITOR.dom.range( self.document );
 					range.selectNodeContents( self.document.getBody() );
 					range.collapse(true);
 					s.selectRanges([ range ]);
-				
+
 			}
 		}, 100); // need some time for selection
 	};
@@ -153,8 +153,8 @@
 
 		this.execFromEditor = false;
 	}
-	
 
+
 	var likeButtons = [
 		{
 			label: CKLang.LJLike_button_repost,
@@ -272,7 +272,7 @@
 
 	// set allowed tags for poll, for reference check
 	// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dtd.html
-	
+
 	dtd['lj-poll'] = {
 		'lj-pq': 1
 	};
@@ -392,7 +392,7 @@
 				var frames = editor.document.getElementsByTag('iframe'),
 					length = frames.count(), frame,
 					cmd, frameWin, doc, ljStyle;
-				
+
 				editor.execFromEditor = false;
 
 				while (length--) {
@@ -401,7 +401,7 @@
 					frameWin = frame.$.contentWindow,
 					doc = frameWin.document,
 					ljStyle = frame.getAttribute('lj-style') || '';
-					
+
 					if (frame.getAttribute('data-update') === 'false') {
 						continue;
 					}
@@ -557,7 +557,7 @@
 				function moveToken(s, token) {
 				    return s.replace(/<(.|\n)*?>/g, function(match) {
 				        var z = match;
-				    
+
 				        if (z.indexOf(token) !== -1) {
 				            z = z.replace(token, '');
 				            return z + token;
@@ -593,7 +593,7 @@
 								selection.selectRanges([range]);
 							}
 							htmlFocus.remove();
-							
+
 							editor.fire('updateSnapshot');
 						}, this._domBuilt ? 0 : 100);
 					}
@@ -613,7 +613,7 @@
 							html = focusTransformed;
 						}
 					}
-					
+
 					html = html.replace(/<lj [^>]*?>/gi, closeTag)
 						.replace(/<lj-map [^>]*?>/gi, closeTag)
 						.replace(/<lj-template[^>]*?>/gi, closeTag)
@@ -669,6 +669,18 @@
 			editor.on('afterCommandExec', updateFrames);
 			editor.on('dialogHide', updateFrames);
 
+			/*
+			 * Fix paste by removing last line break,
+			 * which occurs every time (LJSUP-14448).
+			 */
+			(function() {
+				var lastBr = /<br\s*\/?>$/i;
+				editor.on('paste', function(e) {
+					e.data.html = e.data.html.replace(lastBr, '');
+				});
+			})();
+
+
 			editor.on('dataReady', function() {
 				if (CKEDITOR.env.ie) {
 					editor.document.getBody().on('dragend', updateFrames);
@@ -770,7 +782,7 @@
 						if (parent && parent.getName() === 'a') {
 							parent.setAttribute('href', data.link);
 							parent.setAttribute('data-cke-saved-href', data.link);
-							
+
 							if (data.blank) {
 								parent.setAttribute('target', '_blank');
 							} else {
@@ -913,7 +925,7 @@
 					}
 					iframe.setAttribute('lj-data', encodeURIComponent(LiveJournal.getEmbed(content)));
 
-					
+
 					iframe.setAttribute('frameBorder', 0);
 					iframe.setAttribute('allowTransparency', 'true');
 					iframe.setAttribute('lj-cmd', button);
@@ -1544,7 +1556,7 @@
 						} else {
 							return element;
 						}
-						
+
 						switch (className) {
 							case 'lj-like':
 								newElement = new CKEDITOR.htmlParser.element('lj-like');
@@ -1552,7 +1564,7 @@
 								if (element.attributes.defaults != 'true') {
 									newElement.attributes.buttons = element.attributes.buttons;
 								}
-								
+
 								if (element.attributes.hasOwnProperty('lj-style')) {
 									newElement.attributes.style = element.attributes['lj-style'];
 								}

Tags: atyurin, js, livejournal, spacevillain
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments