spacevillain (spacevillain) wrote in changelog,
spacevillain
spacevillain
changelog

[livejournal] r22597: LJSUP-13085: RTE - edit image dialog

Committer: atyurin
LJSUP-13085: RTE - edit image dialog
U   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	2012-08-08 11:05:13 UTC (rev 22596)
+++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2012-08-08 11:44:50 UTC (rev 22597)
@@ -668,11 +668,11 @@
 
 			// LJ Image
 			(function() {
-				var button = "LJImage";
+				var button = "LJImage", selectedImage = null;
 
 				// registered in jquery/mixins/editpic.js
 				LiveJournal.register_hook('editpic_response', function(data) {
-					var selected = editor.getSelection().getSelectedElement(),
+					var selected = selectedImage,
 						parent = selected && selected.getParent();
 
 					if (!selected) return;
@@ -763,7 +763,7 @@
 							selected.insertBeforeMe(link);
 							link.append(selected);
 
-							editor.getSelection().selectElement(link);
+							editor.getSelection() && editor.getSelection().selectElement(link);
 						}
 					} else {
 						// on empty link remove parent 'a' and replace it with selected image
@@ -779,11 +779,14 @@
 					} else {
 						selected.removeStyle('float');
 					}
+
+					selectedImage = null;
 				});
 
 				editor.addCommand(button, {
 					exec: function (editor, fromDoubleClick) {
 						var selected = editor.getSelection().getSelectedElement();
+						selectedImage = selected;
 							
 						if (selected) {
 							var parent = selected && selected.getParent(),

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