spacevillain (spacevillain) wrote in changelog,
spacevillain
spacevillain
changelog

[livejournal] r22949: LJSUP-13744: Alignment buttons don't wor...

Committer: atyurin
LJSUP-13744: Alignment buttons don't work while selecting
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-09-21 09:41:30 UTC (rev 22948)
+++ trunk/htdocs/js/ck/ckeditor.js	2012-09-21 09:45:29 UTC (rev 22949)
@@ -141,8 +141,8 @@
 else{E.removeStyle('border-width');E.removeStyle('border-style');}if(D.vspace)E.setStyles({'margin-top':D.vspace+'px','margin-bottom':D.vspace+'px'});else{E.removeStyle('margin-top');E.removeStyle('margin-bottom');}if(D.hspace)E.setStyles({'margin-left':D.hspace+'px','margin-right':D.hspace+'px'});else{E.removeStyle('margin-left');E.removeStyle('margin-right');}var F=E&&E.getParent();if(D.link){D.link=D.link.replace(/^[\s\t]*(?:http:\/\/)?/,'http://');if(F&&F.getName()==='a'){F.setAttribute('href',D.link);F.setAttribute('data-cke-saved-href',D.link);if(D.blank)F.setAttribute('target','_blank');else F.removeAttribute('target');}else{var G=new h('a',t.document);G.setAttribute('href',D.link);if(D.blank)G.setAttribute('target','_blank');E.insertBeforeMe(G);G.append(E);t.getSelection()&&t.getSelection().selectElement(G);}}else if(F.getName()==='a'){F.insertBeforeMe(E);F.remove();}if(D.aligment&&D.aligment!=='none')E.setStyle('float',D.aligment);else E.removeStyle('float');C=null;});t.addCommand(B,{exec:function(D,E){var F=D.getSelection();F=F?F.getSelectedElement():null;C=F;if(F){var G=F&&F.getParent(),H=G.getName()==='a',I=H&&G,J=H&&G.getAttribute('href'),K={};if('naturalWidth' in F.$){K.width=F.$.naturalWidth;K.height=F.$.naturalHeight;}else{var L=new Image();L.src=F.$.src;K={width:L.width,height:L.height};}D.rteButton(B,'editpic',{picData:{url:F.getAttribute('src'),title:F.getAttribute('title'),width:F.getAttribute('width')||F.$.width,height:F.getAttribute('height')||F.$.height,defaultWidth:K.width,defaultHeight:K.height,link:J||'',blank:H?!!I.getAttribute('target'):true,border:parseInt(F.getStyle('border-width'),10),vspace:parseInt(F.getStyle('margin-top'),10),hspace:parseInt(F.getStyle('margin-left'),10),aligment:F.getStyle('float')||'none'}});}else jQuery('.b-updatepage-event-section').editor('handleImageUpload','upload');},editorFocus:false});t.ui.addButton(B,{label:m.LJImage_Title,command:B});})();(function(){var B=null;t.on('selectionChange',function(F){var G=F.data.element;if(G.is('iframe'))B=G;else B=null;});var C='LJEmbedLink',D='video';function E(F){var G=new h('iframe',t.document);if(F!==LiveJournal.getEmbed(F)){var H=h.createFromHtml(LiveJournal.getEmbed(F)),I='',J=LiveJournal.parseMediaLink(F);if(J.preview)I='style="background-image: url('+J.preview+');"';G.setAttribute('lj-url',H.getAttribute('src'));G.setAttribute('data-link',F);G.setAttribute('lj-class','lj-iframe');G.setAttribute('class','lj-iframe-wrap lj-rtebox');G.setAttribute('style','width: 490px; height:370px;');
 G.setAttribute('lj-style','width: 480px; height:360px;');G.setAttribute('allowfullscreen','true');G.setAttribute('lj-content',encodeURIComponent('<div '+I+" class='lj-embed-inner lj-rtebox-inner'>iframe</div>"));}else{G.setAttribute('lj-class','lj-embed');G.setAttribute('class','lj-embed-wrap lj-rtebox');G.setAttribute('lj-content',encodeURIComponent('<div '+I+" class='lj-embed-inner lj-rtebox-inner'>Embed</div>"));}G.setAttribute('lj-data',encodeURIComponent(LiveJournal.getEmbed(F)));G.setAttribute('frameBorder',0);G.setAttribute('allowTransparency','true');G.setAttribute('lj-cmd',C);t.insertElement(G);y();};LiveJournal.register_hook(D+'_response',function(F){E(F);});t.addCommand(C,{exec:function(F){var G=p[C].node||B;if(G)n(C,D,{defaultText:G&&decodeURIComponent(G.getAttribute('data-link')||G.getAttribute('lj-url')||G.getAttribute('lj-data')),editMode:true});else n(C,D);}});t.ui.addButton(C,{label:m.LJEmbed,command:C});})();function A(B,C,D){var E,F=p[C].node;if(F){if(E=D.skip||prompt(D.title,F.getAttribute('text')||D.text))if(E==D.text)F.removeAttribute('text');else F.setAttribute('text',E);}else if(E=D.skip||prompt(D.title,D.text)){t.focus();var G=new d.selection(t.document),H=G.getRanges(),I=new h('iframe',t.document),J=I.clone();I.setAttribute('lj-cmd',C);I.setAttribute('lj-class',B+' '+B+'-open');I.setAttribute('class',B+'-wrap');I.setAttribute('frameBorder',0);I.setAttribute('allowTransparency','true');if(E!=D.text)I.setAttribute('text',E);J.setAttribute('lj-class',B+' '+B+'-close');J.setAttribute('class',B+'-wrap');J.setAttribute('frameBorder',0);J.setAttribute('allowTransparency','true');var K=H[0];G.lock();var L=new h('br',t.document),M=L.clone(),N=L.clone(),O=new d.documentFragment(t.document);O.append(L.clone());O.append(I);O.append(M);if(K.collapsed===false)for(var P=0,Q=H.length;P<Q;P++){if(G.getSelectedElement())H[P].enlarge(1);O.append(H[P].extractContents());}O.append(N);t.insertElement(J);L.clone().insertAfter(J);J.insertBeforeMe(O);K.setStart(M,0);K.setEnd(N,0);G.unlock();G.selectRanges(H);t.fire('updateSnapshot');y();}};(function(){var B='LJMap',C='map';LiveJournal.register_hook('map_response',function(D){var E=new h('iframe',t.document),F=425,G=350,H='',I='';if(!isNaN(F)){H+='width:'+F+'px;';I+='width:'+(F-2)+'px;';}if(!isNaN(G)){H+='height:'+G+'px;';I+='height:'+(G-2)+'px;';}var J=p[B].node;if(J)J.setAttributes({'lj-url':D});else{E.setAttributes({'lj-url':D,'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:H,'lj-style':I});
 t.insertElement(E);}y();});t.addCommand(B,{exec:function(){var D=p[B].node;n(B,C,{defaultText:D?D.getAttribute('lj-url'):'',editMode:D?true:false});},editorFocus:false});t.ui.addButton(B,{label:m.LJMap_Title,command:B});})();(function(){var B='LJCut',C='cut';LiveJournal.register_hook('cut_response',function(D){A('lj-cut',B,{title:m.LJCut_PromptTitle,text:m.LJCut_PromptText,skip:D});});t.addCommand('LJCut',{exec:function(){var D=p[B].node;n(B,C,{defaultText:D?D.getAttribute('text'):'',editMode:D?true:false});},editorFocus:false});t.ui.addButton(B,{label:m.LJCut_Title,command:B});})();(function(){var B='LJSpoiler',C='spoiler';LiveJournal.register_hook('spoiler_response',function(D){A('lj-spoiler',B,{title:m.LJCut_PromptTitle,text:m.LJCut_PromptText,skip:D});});t.addCommand(B,{exec:function(){var D=p[B].node;n(B,C,{defaultText:D?D.getAttribute('text'):'',editMode:D?true:false});},editorFocus:false});t.ui.addButton(B,{label:m.LJSpoiler_Title,command:B});})();(function(){function B(I,J){J=J===undefined||J;var K,L=p.LJLike.node;if(L){var M=I.getAttribute('lj-style');K=M?M.replace(/text-align:\s*(left|right|center)/i,'$1'):'left';}else if(J)K=I.getComputedStyle('text-align');else{while(!I.hasAttribute||!(I.hasAttribute('align')||I.getStyle('text-align'))){var N=I.getParent();if(!N)break;I=N;}K=I.getStyle('text-align')||I.getAttribute('align')||'';}K&&(K=K.replace(/-moz-|-webkit-|start|auto/i,''));!K&&J&&(K=I.getComputedStyle('direction')=='rtl'?'right':'left');return K;};function C(I){if(I.editor.readOnly)return;var J=I.editor.getCommand(this.name),K=I.data.element;if((K.type==1&&K.hasAttribute('lj-cmd')&&K.getAttribute('lj-cmd'))=='LJLike')J.state=B(K,t.config.useComputedState)==this.value?1:2;else if(!K||K.type!=1||K.getName()=='body'||K.getName()=='iframe')J.state=2;else J.state=B(K,t.config.useComputedState)==this.value?1:2;J.fire('state');};function D(I,J,K){var M=this;M.name=J;M.value=K;var L=I.config.justifyClasses;if(L){switch(K){case 'left':M.cssClassName=L[0];break;case 'center':M.cssClassName=L[1];break;case 'right':M.cssClassName=L[2];break;}M.cssClassRegex=new RegExp('(?:^|\\s+)(?:'+L.join('|')+')(?=$|\\s)');}};function E(I){var J=I.editor,K=new d.range(J.document);K.setStartBefore(I.data.node);K.setEndAfter(I.data.node);var L=new d.walker(K),M;while(M=L.next()){if(M.type==1){var N='text-align',O=J.config.justifyClasses;if(!M.equals(I.data.node)&&M.getDirection()){K.setStartAfter(M);L=new d.walker(K);continue;}if(O)if(M.hasClass(O[0])){M.removeClass(O[0]);
-M.addClass(O[2]);}else if(M.hasClass(O[2])){M.removeClass(O[2]);M.addClass(O[0]);}switch(M.getStyle(N)){case 'left':M.setStyle(N,'right');break;case 'right':M.setStyle(N,'left');break;}}}};D.prototype={exec:function(I){var W=this;var J=I.getSelection(),K=I.config.enterMode;if(!J)return;var L=J.createBookmarks();if(p.LJLike.node)p.LJLike.node.setAttribute('lj-style','text-align: '+W.value);else{var M=J.getRanges(true),N=W.cssClassName,O,P,Q=I.config.useComputedState;Q=Q===undefined||Q;for(var R=M.length-1;R>=0;R--){var S=M[R],T=S.getEnclosedNode();if(T&&T.is('iframe'))return;O=S.createIterator();O.enlargeBr=K!=2;while(P=O.getNextParagraph(K==1?'p':'div')){P.removeAttribute('align');P.removeStyle('text-align');var U=N&&(P.$.className=e.ltrim(P.$.className.replace(W.cssClassRegex,''))),V=W.state==2&&(!Q||B(P,true)!=W.value);if(N){if(V)P.addClass(N);else if(!U)P.removeAttribute('class');}else if(V)P.setStyle('text-align',W.value);}}}I.focus();I.forceNextSelectionCheck();J.selectBookmarks(L);}};var F=new D(t,'LJJustifyLeft','left'),G=new D(t,'LJJustifyCenter','center'),H=new D(t,'LJJustifyRight','right');t.addCommand('LJJustifyLeft',F);t.addCommand('LJJustifyCenter',G);t.addCommand('LJJustifyRight',H);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(C,F));t.on('selectionChange',e.bind(C,H));t.on('selectionChange',e.bind(C,G));t.on('dirChanged',E);})();(function(){var B='LJPollLink';if(!LJ.pageVar('remoteUser',true))return;LiveJournal.register_hook('poll_response',function(C){var D=new Poll(C),E="<div class='lj-poll-inner lj-rtebox-inner'>"+D.outputHTML()+'</div>',F=D.outputLJtags(),G=p[B].node;if(G){G.setAttribute('lj-content',E);G.setAttribute('lj-data',F);G.removeAttribute('style');}else{G=new h('iframe',t.document);G.setAttribute('lj-content',E);G.setAttribute('lj-cmd','LJPollLink');G.setAttribute('lj-data',F);G.setAttribute('lj-class','lj-poll lj-rtebox');G.setAttribute('class','lj-poll-wrap');G.setAttribute('frameBorder',0);G.setAttribute('allowTransparency','true');t.insertElement(G);}y();});t.addCommand(B,{exec:function(C){var D=p.LJPollLink.node;if(D)n(B,'poll',{ljData:decodeURIComponent(D.getAttribute('lj-data')),editMode:true,disabled:D&&(D.getAttribute('data-disabledPoll')?true:false)});else n(B,'poll');},editorFocus:false});
-t.ui.addButton(B,{label:m.LJPoll_Title,command:B});})();(function(){var B='LJLike',C='like';o.defaultButtons=[];for(var D=0;D<o.length;D++){btn=o[D];o[btn.id]=o[btn.abbr]=btn;o.defaultButtons.push(btn.id);}LiveJournal.register_hook('like_response',function(E){var F=[],G=[],H=typeof E==='string';for(var I=0,J;I<o.length;I++){J=o[I];if(H&&J.checked||E.indexOf(J.id)!=-1){F.push(J.id);G.push(J.html);}}var K=p[B].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(B,{exec:function(E){var F=p[B].node;if(F)n(B,C,{buttons:F.getAttribute('buttons'),editMode:true});else n(B,C);},editorFocus:false});t.ui.addButton(B,{label:m.LJLike_Title,command:B});})();},afterInit:function(t){var u=t.dataProcessor;function v(w,x,y,z){z=z||'text';var A=new a.htmlParser.element('iframe');A.attributes['lj-class']=x+' '+x+'-open';A.attributes['class']=x+'-wrap';A.attributes['lj-cmd']=y;A.attributes.frameBorder=0;A.attributes.allowTransparency='true';if(w.attributes.hasOwnProperty(z))A.attributes.text=w.attributes[z];w.children.unshift(A);var B=new a.htmlParser.element('iframe');B.attributes['lj-class']=x+' '+x+'-close';B.attributes['class']=x+'-wrap';B.attributes.frameBorder=0;B.attributes.allowTransparency='true';w.children.push(B);delete w.name;};u.dataFilter.addRules({elements:{'lj-like':function(w){var x=[],y=new a.htmlParser.element('iframe');y.attributes['lj-class']='lj-like';y.attributes['class']='lj-like-wrap lj-rtebox';if(w.attributes.hasOwnProperty('style'))y.attributes['lj-style']=w.attributes.style;y.attributes['lj-cmd']='LJLike';y.attributes['lj-content']='<div class="lj-rtebox-inner lj-like-inner"><span class="lj-like-wrapper">';y.attributes.frameBorder=0;y.attributes.allowTransparency='true';var z=w.attributes.buttons&&w.attributes.buttons.split(',')||o.defaultButtons,A=w.attributes.buttons?true:false,B=z.length;for(var C=0;C<B;C++){var D=z[C].replace(/^\s*([a-z]{2,})\s*$/i,'$1'),E=o[D];if(E&&(A||E.checked)){y.attributes['lj-content']+=encodeURIComponent(E.html);
+M.addClass(O[2]);}else if(M.hasClass(O[2])){M.removeClass(O[2]);M.addClass(O[0]);}switch(M.getStyle(N)){case 'left':M.setStyle(N,'right');break;case 'right':M.setStyle(N,'left');break;}}}};D.prototype={exec:function(I){var W=this;var J=I.getSelection(),K=I.config.enterMode;if(!J)return;var L=J.createBookmarks();if(p.LJLike.node)p.LJLike.node.setAttribute('lj-style','text-align: '+W.value);else{var M=J.getRanges(true),N=W.cssClassName,O,P,Q=I.config.useComputedState;Q=Q===undefined||Q;for(var R=M.length-1;R>=0;R--){var S=M[R],T=S.getEnclosedNode();if(T&&T.type===1&&T.is('iframe'))return;O=S.createIterator();O.enlargeBr=K!=2;while(P=O.getNextParagraph(K==1?'p':'div')){P.removeAttribute('align');P.removeStyle('text-align');var U=N&&(P.$.className=e.ltrim(P.$.className.replace(W.cssClassRegex,''))),V=W.state==2&&(!Q||B(P,true)!=W.value);if(N){if(V)P.addClass(N);else if(!U)P.removeAttribute('class');}else if(V)P.setStyle('text-align',W.value);}}}I.focus();I.forceNextSelectionCheck();J.selectBookmarks(L);}};var F=new D(t,'LJJustifyLeft','left'),G=new D(t,'LJJustifyCenter','center'),H=new D(t,'LJJustifyRight','right');t.addCommand('LJJustifyLeft',F);t.addCommand('LJJustifyCenter',G);t.addCommand('LJJustifyRight',H);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(C,F));t.on('selectionChange',e.bind(C,H));t.on('selectionChange',e.bind(C,G));t.on('dirChanged',E);})();(function(){var B='LJPollLink';if(!LJ.pageVar('remoteUser',true))return;LiveJournal.register_hook('poll_response',function(C){var D=new Poll(C),E="<div class='lj-poll-inner lj-rtebox-inner'>"+D.outputHTML()+'</div>',F=D.outputLJtags(),G=p[B].node;if(G){G.setAttribute('lj-content',E);G.setAttribute('lj-data',F);G.removeAttribute('style');}else{G=new h('iframe',t.document);G.setAttribute('lj-content',E);G.setAttribute('lj-cmd','LJPollLink');G.setAttribute('lj-data',F);G.setAttribute('lj-class','lj-poll lj-rtebox');G.setAttribute('class','lj-poll-wrap');G.setAttribute('frameBorder',0);G.setAttribute('allowTransparency','true');t.insertElement(G);}y();});t.addCommand(B,{exec:function(C){var D=p.LJPollLink.node;if(D)n(B,'poll',{ljData:decodeURIComponent(D.getAttribute('lj-data')),editMode:true,disabled:D&&(D.getAttribute('data-disabledPoll')?true:false)});else n(B,'poll');
+},editorFocus:false});t.ui.addButton(B,{label:m.LJPoll_Title,command:B});})();(function(){var B='LJLike',C='like';o.defaultButtons=[];for(var D=0;D<o.length;D++){btn=o[D];o[btn.id]=o[btn.abbr]=btn;o.defaultButtons.push(btn.id);}LiveJournal.register_hook('like_response',function(E){var F=[],G=[],H=typeof E==='string';for(var I=0,J;I<o.length;I++){J=o[I];if(H&&J.checked||E.indexOf(J.id)!=-1){F.push(J.id);G.push(J.html);}}var K=p[B].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(B,{exec:function(E){var F=p[B].node;if(F)n(B,C,{buttons:F.getAttribute('buttons'),editMode:true});else n(B,C);},editorFocus:false});t.ui.addButton(B,{label:m.LJLike_Title,command:B});})();},afterInit:function(t){var u=t.dataProcessor;function v(w,x,y,z){z=z||'text';var A=new a.htmlParser.element('iframe');A.attributes['lj-class']=x+' '+x+'-open';A.attributes['class']=x+'-wrap';A.attributes['lj-cmd']=y;A.attributes.frameBorder=0;A.attributes.allowTransparency='true';if(w.attributes.hasOwnProperty(z))A.attributes.text=w.attributes[z];w.children.unshift(A);var B=new a.htmlParser.element('iframe');B.attributes['lj-class']=x+' '+x+'-close';B.attributes['class']=x+'-wrap';B.attributes.frameBorder=0;B.attributes.allowTransparency='true';w.children.push(B);delete w.name;};u.dataFilter.addRules({elements:{'lj-like':function(w){var x=[],y=new a.htmlParser.element('iframe');y.attributes['lj-class']='lj-like';y.attributes['class']='lj-like-wrap lj-rtebox';if(w.attributes.hasOwnProperty('style'))y.attributes['lj-style']=w.attributes.style;y.attributes['lj-cmd']='LJLike';y.attributes['lj-content']='<div class="lj-rtebox-inner lj-like-inner"><span class="lj-like-wrapper">';y.attributes.frameBorder=0;y.attributes.allowTransparency='true';var z=w.attributes.buttons&&w.attributes.buttons.split(',')||o.defaultButtons,A=w.attributes.buttons?true:false,B=z.length;for(var C=0;C<B;C++){var D=z[C].replace(/^\s*([a-z]{2,})\s*$/i,'$1'),E=o[D];if(E&&(A||E.checked)){y.attributes['lj-content']+=encodeURIComponent(E.html);
 x.push(D);}}if(!w.attributes.buttons)y.attributes.defaults=true;y.attributes['lj-content']+='</span></div>';y.attributes.buttons=x.join(',');return y;},'lj-map':function(w){var x=new a.htmlParser.element('iframe'),y='',z='',A=Number(w.attributes.width),B=Number(w.attributes.height);if(!isNaN(A)){y+='width:'+A+'px;';z+='width:'+(A-2)+'px;';}if(!isNaN(B)){y+='height:'+B+'px;';z+='height:'+(B-2)+'px;';}if(y.length){x.attributes.style=y;x.attributes['lj-style']=z;}x.attributes['lj-url']=w.attributes.url?encodeURIComponent(w.attributes.url):'';x.attributes['lj-class']='lj-map';x.attributes['class']='lj-map-wrap lj-rtebox';x.attributes['lj-content']='<div class="lj-map-inner lj-rtebox-inner"><p class="lj-map">map</p></div>';x.attributes.frameBorder=0;x.attributes.allowTransparency='true';return x;},'lj-raw':function(w){w.name='lj:raw';},'lj-wishlist':function(w){w.name='lj:wishlist';},'lj-template':function(w){var x=new a.htmlParser.element('iframe');x.attributes['lj-class']='lj-template';x.attributes['class']='lj-template-wrap';x.attributes.frameBorder=0;x.attributes.allowTransparency='true';x.attributes['lj-attributes']=encodeURIComponent(LiveJournal.JSON.stringify(w.attributes));return x;},'lj-cut':function(w){v(w,'lj-cut','LJCut');},'lj-spoiler':function(w){v(w,'lj-spoiler','LJSpoiler','title');},iframe:function(w){if(w.attributes['data-update']==='false')return w;var x='';if(w.attributes['data-link']){var y=LiveJournal.parseMediaLink(w.attributes['data-link']);if(y.preview)x='style="background-image: url('+y.preview+');"';}var z=w.attributes.src;if(w.attributes['lj-class']&&w.attributes['lj-class'].indexOf('lj-')+1==1)return w;var A=new a.htmlParser.element('iframe'),B='',C='',D=Number(w.attributes.width),E=Number(w.attributes.height);if(!isNaN(D)){B+='width:'+D+'px;';C+='width:'+(D-10)+'px;';}if(!isNaN(E)){B+='height:'+E+'px;';C+='height:'+(E-10)+'px;';}if(B.length){A.attributes.style=B;A.attributes['lj-style']=C;}A.attributes['lj-url']=w.attributes.src?encodeURIComponent(w.attributes.src):'';A.attributes['lj-class']='lj-iframe';A.attributes['class']='lj-iframe-wrap lj-rtebox';A.attributes['lj-content']='<div '+x+' class="lj-rtebox-inner">'+(x?'':'iframe')+'</div>';A.attributes.frameBorder=0;A.attributes.allowTransparency='true';if(z!=LiveJournal.getEmbed(decodeURIComponent(w.attributes.src))){A.attributes['lj-cmd']='LJEmbedLink';A.attributes['data-link']=w.attributes['data-link'];}return A;},a:function(w){if(w.parent.attributes&&!w.parent.attributes['lj:user'])w.attributes['lj-cmd']='LJLink2';
 },img:function(w){var x=w.parent&&w.parent.parent;if(!x||!x.attributes||!x.attributes['lj:user'])w.attributes['lj-cmd']='LJImage';},div:function(w){if(w.attributes['class']=='lj-cut')v(w,'lj-cut','LJCut');}}},5);u.htmlFilter.addRules({elements:{iframe:function(w){var x=w,y=false,z='text',A=/lj-[a-z]+/i.exec(w.attributes['lj-class']);if(A)A=A[0];else return w;switch(A){case 'lj-like':x=new a.htmlParser.element('lj-like');if(w.attributes.defaults!='true')x.attributes.buttons=w.attributes.buttons;if(w.attributes.hasOwnProperty('lj-style'))x.attributes.style=w.attributes['lj-style'];x.isEmpty=true;x.isOptionalClose=true;break;case 'lj-embed':var B=decodeURIComponent(w.attributes['lj-data']);x=new a.htmlParser.element('lj-embed');x.attributes.id=w.attributes.id;if(w.attributes.id)x.isEmpty=true;if(w.attributes.hasOwnProperty('source_user'))x.attributes.source_user=w.attributes.source_user;x.children=new a.htmlParser.fragment.fromHtml(decodeURIComponent(w.attributes['lj-data'])).children;x.isOptionalClose=true;break;case 'lj-map':x=new a.htmlParser.element('lj-map');x.attributes.url=decodeURIComponent(w.attributes['lj-url']);w.attributes.style&&(w.attributes.style+';').replace(/([a-z-]+):(.*?);/gi,function(G,H,I){x.attributes[H.toLowerCase()]=parseInt(I);});x.isOptionalClose=x.isEmpty=true;break;case 'lj-iframe':x=new a.htmlParser.element('iframe');x.attributes.src=decodeURIComponent(w.attributes['lj-url']);w.attributes.style&&(w.attributes.style+';').replace(/([a-z-]+):(.*?);/gi,function(G,H,I){x.attributes[H.toLowerCase()]=parseInt(I);});x.attributes.frameBorder=0;if(w.attributes['data-link'])x.attributes['data-link']=w.attributes['data-link'];break;case 'lj-poll':var B=decodeURIComponent(w.attributes['lj-data']);x=new a.htmlParser.fragment.fromHtml(B).children[0];break;case 'lj-repost':x=new a.htmlParser.element('lj-repost');x.attributes.button=w.attributes['lj-button'];x.children=new a.htmlParser.fragment.fromHtml(w.attributes['lj-text']).children;break;case 'lj-template':x=new a.htmlParser.element('lj-template');x.attributes=LiveJournal.JSON.parse(encodeURIComponent(w.attributes['lj-attributes']));x.isOptionalClose=x.isEmpty=true;break;case 'lj-spoiler':y=true;z='title';case 'lj-cut':if(w.attributes['lj-class'].indexOf(A+'-open')+1){var C=w.next,D=0;x=new a.htmlParser.element(A);if(w.attributes.hasOwnProperty('text'))x.attributes[z]=w.attributes.text;while(C){if(C.name=='iframe'){var E=C.attributes['lj-class'];if(E.indexOf(A+'-close')+1){if(y&&D)D--;else{x.next=C;
 break;}}else if(E.indexOf(A+'-open')+1)if(y)D++;else{x.next=C;break;}}C.parent.children.remove(C);x.add(C);var F=C.next;C.next=null;C=F;}}else x=false;break;default:if(!w.children.length)x=false;}return x;},span:function(w){var x=w.attributes['lj:user'];if(x){var y=new a.htmlParser.element('lj');y.attributes.user=x;try{var z=w.children[1].children[0].children[0].value;}catch(A){return false;}if(z&&z!=x)y.attributes.title=z;y.isOptionalClose=y.isEmpty=true;return y;}else if(w.attributes.style=='display: none;'||!w.children.length)return false;},div:function(w){if(!w.children.length)return false;},'lj:raw':function(w){w.name='lj-raw';},'lj:wishlist':function(w){w.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];

Modified: trunk/htdocs/js/ck/plugins/livejournal/plugin.js
===================================================================
--- trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2012-09-21 09:41:30 UTC (rev 22948)
+++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2012-09-21 09:45:29 UTC (rev 22949)
@@ -1393,7 +1393,7 @@
 							for (var i = ranges.length - 1; i >= 0; i--) {
 								var range = ranges[i];
 								var encloseNode = range.getEnclosedNode();
-								if (encloseNode && encloseNode.is('iframe')) {
+								if (encloseNode && encloseNode.type === CKEDITOR.NODE_ELEMENT && encloseNode.is('iframe')) {
 									return;
 								}
 

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