spacevillain (spacevillain) wrote in changelog,
spacevillain
spacevillain
changelog

[livejournal] r22352: LJSUP-12745: Replace windows (pop-up) in...

Committer: atyurin
LJSUP-12745: Replace windows (pop-up) in RTE with the new windows (from HTML tab)
U   trunk/htdocs/js/ck/config.js
U   trunk/htdocs/js/ck/plugins/livejournal/plugin.js
Modified: trunk/htdocs/js/ck/config.js
===================================================================
--- trunk/htdocs/js/ck/config.js	2012-06-29 08:52:09 UTC (rev 22351)
+++ trunk/htdocs/js/ck/config.js	2012-06-29 11:37:23 UTC (rev 22352)
@@ -4,15 +4,15 @@
  */
 
 CKEDITOR.editorConfig = function(config) {
-	var ljplugins = ['ljspell', 'livejournal'],
+	CKEDITOR.plugins.addExternal( 'ljcolor', 'plugins/lj/ljcolor/plugin.js' );
+
+	var ljplugins = [/*'ljspell', */'livejournal', 'ljcolor'],
 		plugins = [
 			'ajax',
 			'basicstyles',
 			'bidi',
 			'blockquote',
 			'button',
-			'colorbutton',
-			'colordialog',
 			'dialog',
 			'enterkey',
 			'entities',
@@ -40,6 +40,8 @@
 	config.docType = '<!DOCTYPE html>';
 	config.contentsCss = '/js/ck/contents.css?t=' + Site.version;
 
+	config.styleText = Site.statprefix + '/js/ck/contents.css?t=' + Site.version;
+
 	//config.scayt_autoStartup = true;
 
 	config.fillEmptyBlocks = false;
@@ -70,7 +72,7 @@
 			'Italic',
 			'Underline',
 			'Strike',
-			'TextColor',
+			'LJColor',
 			'FontSize',
 			'-',
 			'LJLink',

Modified: trunk/htdocs/js/ck/plugins/livejournal/plugin.js
===================================================================
--- trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2012-06-29 08:52:09 UTC (rev 22351)
+++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2012-06-29 11:37:23 UTC (rev 22352)
@@ -547,11 +547,12 @@
 
 			// LJ User Button
 			(function () {
-				var url = top.Site.siteroot + '/tools/endpoints/ljuser.bml';
+				var url = top.Site.siteroot + '/tools/endpoints/ljuser.bml',
+					button = 'LJUserLink';
 
 				function onData(data, userName, LJUser) {
 					if (data.error) {
-						alert(data.error);
+						LiveJournal.run_hook('incorrect_user');
 						return;
 					}
 
@@ -572,6 +573,7 @@
 
 				}
 
+				var hooked = false;
 				editor.addCommand('LJUserLink', {
 					exec: function(editor) {
 						var userName = '',
@@ -579,32 +581,52 @@
 							LJUser = ljTagsData.LJUserLink.node,
 							currentUserName;
 
+						function checkInsert(username) {
+							parent.HTTPReq.getJSON({
+								data: parent.HTTPReq.formEncoded({
+									username: username
+								}),
+								method: 'POST',
+								url: url,
+								onData: function (data) {
+									onData(data, username, ljTagsData.LJUserLink.node);
+								}
+							});
+						}
+
+						if (!hooked) {
+							var lj = LJUser;
+							LiveJournal.register_hook('buttonResponse', function(type, user) {
+								console.log('got response', arguments);
+								checkInsert(user);
+							});
+							hooked = true;
+						}
+
 						if (LJUser) {
 							CKEDITOR.note && CKEDITOR.note.hide(true);
 							currentUserName = ljTagsData.LJUserLink.node.getElementsByTag('b').getItem(0).getText();
-							userName = prompt(CKLang.UserPrompt, currentUserName);
+
+							console.log(LJUser);
+							LiveJournal.run_hook('rteButton', 'user', jQuery('.cke_button_' + button), {
+								user: currentUserName
+							});
+
+							return;
 						} else if (selection.getType() == 2) {
 							userName = selection.getSelectedText();
 						}
 
 						if (userName == '') {
-							userName = prompt(CKLang.UserPrompt, userName);
+							LiveJournal.run_hook('rteButton', 'user', jQuery('.cke_button_' + button));
+							return;
 						}
 
 						if (!userName || currentUserName == userName) {
 							return;
 						}
 
-						parent.HTTPReq.getJSON({
-							data: parent.HTTPReq.formEncoded({
-								username: userName
-							}),
-							method: 'POST',
-							url: url,
-							onData: function (data) {
-								onData(data, userName, LJUser);
-							}
-						});
+						checkInsert(userName, LJUser);
 					}
 				});
 

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