Committer: vkurkin
LJSV-1792: Link wizard shows blank URL for existing link in RTE / removes link if cursor is inside link itselfU trunk/htdocs/js/ck/plugins/livejournal/plugin.js
Modified: trunk/htdocs/js/ck/plugins/livejournal/plugin.js =================================================================== --- trunk/htdocs/js/ck/plugins/livejournal/plugin.js 2011-09-22 07:28:01 UTC (rev 20109) +++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js 2011-09-22 07:53:11 UTC (rev 20110) @@ -382,7 +382,8 @@ if (ljNoteData.hasOwnProperty(cmd)) { cmd = editor.getCommand(cmd); if (cmd.state == CKEDITOR.TRISTATE_ON) { - editor.getSelection().selectElement(node); + var selection = new CKEDITOR.dom.selection(editor.document); + selection.selectElement(node); evt.data.dialog = ''; cmd.exec(); break; @@ -410,7 +411,7 @@ editor.addCommand('LJUserLink', { exec: function(editor) { var userName = '', - selection = editor.getSelection(), + selection = new CKEDITOR.dom.selection(editor.document), LJUser = ljNoteData.LJUserLink.node; if (LJUser) { @@ -472,7 +473,8 @@ var state = editor.getCommand('LJImage').state; if (ljNoteData.LJImage.node) { - editor.getSelection().selectElement(ljNoteData.LJImage.node); + var selection = new CKEDITOR.dom.selection(editor.document); + selection && selection.selectElement(ljNoteData.LJImage.node); editor.openDialog('image'); } else if (state === CKEDITOR.TRISTATE_OFF) { if (window.ljphotoEnabled) { @@ -503,7 +505,8 @@ var state = editor.getCommand('LJLink').state; if (currentNoteNode && ljNoteData.LJLink.node) { - editor.getSelection().selectElement(ljNoteData.LJLink.node); + var selection = new CKEDITOR.dom.selection(editor.document); + selection && selection.selectElement(ljNoteData.LJLink.node); editor.openDialog('link'); } else if (state === CKEDITOR.TRISTATE_OFF) { editor.openDialog('link'); @@ -640,13 +643,13 @@ JustifyCommand.prototype = { exec : function(editor) { var LJNode = ljNoteData.LJLike.node || ljNoteData.LJUserLink.node; + var selection = new CKEDITOR.dom.selection(editor.document); if (LJNode) { LJNode.removeAttribute('contenteditable'); - editor.getSelection().selectElement(LJNode); + selection.selectElement(LJNode); } - var selection = editor.getSelection(), - enterMode = editor.config.enterMode; + var enterMode = editor.config.enterMode; if (!selection) { return; @@ -770,7 +773,7 @@ } else { text = prompt(top.CKLang.CutPrompt, top.CKLang.ReadMore); if (text) { - var selection = editor.document.getSelection(); + var selection = new CKEDITOR.dom.selection(editor.document); ljNoteData.LJCut.node = new CKEDITOR.dom.element('lj:cut', editor.document); ljNoteData.LJCut.node.setAttribute('lj-cmd', 'LJCut');