Vlad Kurkin (b_vladi) wrote in changelog,
Vlad Kurkin
b_vladi
changelog

[livejournal] r19780: LJSV-1721: Changes in entries not saved ...

Committer: vkurkin
LJSV-1721: Changes in entries not saved and still showed old content, if user use RTE for editing
U   trunk/htdocs/js/ck/config.js
U   trunk/htdocs/js/ck/plugins/livejournal/plugin.js
U   trunk/htdocs/js/rte.js
Modified: trunk/htdocs/js/ck/config.js
===================================================================
--- trunk/htdocs/js/ck/config.js	2011-08-19 04:33:53 UTC (rev 19779)
+++ trunk/htdocs/js/ck/config.js	2011-08-19 06:44:59 UTC (rev 19780)
@@ -31,6 +31,7 @@
 		'link,' +
 		'list,' +
 		'liststyle,' +
+		'pastefromword,' +
 		'specialchar,' +
 		'tab,' +
 		'toolbar,' +
@@ -46,6 +47,7 @@
 	config.entities_additional = '#39';
 	config.entities_greek = true;
 	config.entities_latin = true;
+	config.enableTabKeyTools = true;
 	config.fillEmptyBlocks = false;
 	config.startupFocus = false;
 	config.forcePasteAsPlainText = false;

Modified: trunk/htdocs/js/ck/plugins/livejournal/plugin.js
===================================================================
--- trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2011-08-19 04:33:53 UTC (rev 19779)
+++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2011-08-19 06:44:59 UTC (rev 19780)
@@ -343,8 +343,8 @@
 					}
 
 					note = {
-						show: function(data, cmd, node) {
-							if (data == tempData.data && cmd == tempData.cmd && node === tempData.node) {
+						show: function(data, cmd, node, isNow) {
+							if (!isNow && data == tempData.data && cmd == tempData.cmd && node === tempData.node) {
 								return;
 							}
 
@@ -354,11 +354,12 @@
 							}
 
 							state = 1;
-							timer = setTimeout(applyNote, 1000);
 
 							tempData.data = data;
 							tempData.cmd = cmd;
 							tempData.node = node;
+
+							isNow === true ? applyNote() : timer = setTimeout(applyNote, 1000);
 						},
 						hide: function(isNow) {
 							if (state) {
@@ -906,7 +907,7 @@
 			} else {
 				editor.addCommand('LJPollLink', {
 					exec: function() {
-						note.show(top.CKLang.Poll_AccountLevelNotice);
+						note.show(top.CKLang.Poll_AccountLevelNotice, null, null, true);
 					}
 				});
 

Modified: trunk/htdocs/js/rte.js
===================================================================
--- trunk/htdocs/js/rte.js	2011-08-19 04:33:53 UTC (rev 19779)
+++ trunk/htdocs/js/rte.js	2011-08-19 06:44:59 UTC (rev 19780)
@@ -4,40 +4,43 @@
 	var CKEditor,
 		draftData;
 
+	function initDraftData(){
+		draftData = {
+			textArea: $('#draft'),
+			statusNode: $('#draftstatus')
+		};
+		
+		draftData.lastValue = draftData.textArea.val();
+		draftData.textArea.val(draftData.lastValue.replace(/<br\s?\/>\n?/g, '\n'));
+	}
+
 	window.initDraft = function(data) {
-		draftData = data;
+		initDraftData();
 
-		data.textArea = $('#draft');
-		data.lastValue = draftData.textArea.val();
-		data.statusNode = $('#draftstatus');
+		for(var prop in data){
+			if(data.hasOwnProperty(prop)){
+				draftData[prop] = data[prop];
+			}
+		}
 
-		if (data.ask && data.restoreData) {
-			if (confirm(data.confirmMsg)) {
-				data.lastValue = data.restoreData;
-				data.statusNode.val(data.draftStatus);
+		if (draftData.ask && draftData.restoreData) {
+			if (confirm(draftData.confirmMsg)) {
+				draftData.lastValue = draftData.restoreData;
+				draftData.statusNode.val(draftData.draftStatus);
 			}
 		} else {
-			data.statusNode.val('');
+			draftData.statusNode.val('');
 		}
 
-		draftData.textArea.val(draftData.lastValue.replace(/<br\s?\/>\n?/g, '\n'));
-
 		$('#updateForm').delegate('#draft', 'keypress click', checkDraftTimer);
 	};
 
 	window.useRichText = function (statPrefix) {
+		if (!draftData) {
+			initDraftData();
+		}
+
 		if (!window.switchedRteOn) {
-			if(!draftData){
-				draftData = {
-					textArea: $('#draft'),
-					statusNode: $('#draftstatus')
-				};
-
-				draftData.lastValue = draftData.textArea.val();
-
-				draftData.textArea.val(draftData.lastValue.replace(/<br\s?\/>\n?/g, '\n'));
-			}
-
 			window.switchedRteOn = true;
 			$('#switched_rte_on').value = '1';
 
@@ -52,15 +55,32 @@
 
 				editor.on('instanceReady', function() {
 					CKEditor = editor;
-
 					editor.resetDirty();
 
+					var isSetFocuse;
+
 					$('#updateForm')[0].onsubmit = function() {
 						if (window.switchedRteOn) {
 							draftData.textArea.val(CKEditor.getData());
 						}
 					};
 
+					$('#subject').blur(function(){
+						if(isSetFocuse){
+							$('#draft').focus();
+						}
+
+						return false;
+					});
+
+					$('#prop_taglist').bind('focus', function(){
+						return isSetFocuse = false;
+					});
+
+					$(document).bind('keypress', function(evt){
+						isSetFocuse = !evt.shiftKey;
+					});
+
 					CKEditor.on('dataReady', function() {
 						$('#entry-form-wrapper').attr('class', 'hide-html');
 
@@ -96,6 +116,10 @@
 	};
 
 	window.usePlainText = function() {
+		if (!draftData) {
+			initDraftData();
+		}
+
 		if (window.switchedRteOn) {
 			window.switchedRteOn = false;
 			$('#switched_rte_on').value = '0';

Tags: b_vladi, js, livejournal
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 

  • 6 comments