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

[livejournal] r19778: LJSUP-9515: Incorrect behavior for repos...

Committer: vkurkin
LJSUP-9515: Incorrect behavior for reposting
U   trunk/htdocs/js/ck/contents.css
U   trunk/htdocs/js/ck/plugins/livejournal/plugin.js
U   trunk/htdocs/js/entry.js
U   trunk/htdocs/js/rte.js
Modified: trunk/htdocs/js/ck/contents.css
===================================================================
--- trunk/htdocs/js/ck/contents.css	2011-08-19 03:42:02 UTC (rev 19777)
+++ trunk/htdocs/js/ck/contents.css	2011-08-19 04:33:01 UTC (rev 19778)
@@ -45,7 +45,7 @@
 }
 
 lj\:cut,
-lj-cut {
+.lj-cut {
 	display: block;
 	border: #000 1px dotted;
 	background-color: #d2d2d2;
@@ -146,19 +146,4 @@
 	margin-top: 20px;
 	background: #D2D2D2;
 	border: 1px dotted #000;
-	text-align: center;
 	}
-	.lj-map P {
-		position: relative;
-		top: 40%;
-		display: inline-block;
-		padding: 5px 15px;
-		margin: 0;
-		background: #FFF;
-		border: 1px solid #FF0000;
-		text-align: center;
-		text-transform: uppercase;
-		line-height: 12px;
-		font-size: 12px;
-		color: #FF0000;
-		}

Modified: trunk/htdocs/js/ck/plugins/livejournal/plugin.js
===================================================================
--- trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2011-08-19 03:42:02 UTC (rev 19777)
+++ trunk/htdocs/js/ck/plugins/livejournal/plugin.js	2011-08-19 04:33:01 UTC (rev 19778)
@@ -726,7 +726,7 @@
 				+ 'background-repeat: no-repeat;'
 				+ 'background-color: #CCCCCC;'
 				+ 'border: 1px dotted #000000;'
-				+ 'min-height: 80px;'
+				+ 'height: 80px;'
 			+ '}');
 
 			function doEmbed(content) {
@@ -760,8 +760,9 @@
 					} else {
 						text = prompt(top.CKLang.CutPrompt, top.CKLang.ReadMore);
 						if (text) {
-							ljNoteData.LJCut.node = editor.document.createElement('lj-cut');
+							ljNoteData.LJCut.node = editor.document.createElement('div');
 							ljNoteData.LJCut.node.setAttribute('lj-cmd', 'LJCut');
+							ljNoteData.LJCut.node.setAttribute('class', 'lj-cut');
 							if (text != top.CKLang.ReadMore) {
 								ljNoteData.LJCut.node.setAttribute('text', text);
 							}
@@ -1058,7 +1059,11 @@
 			dataProcessor.dataFilter.addRules({
 				elements: {
 					'lj-cut': function(element) {
-						element.attributes['lj-cmd'] = 'LJCut';
+						var fakeElement = new CKEDITOR.htmlParser.element('div');
+						fakeElement.attributes['lj-cmd'] = 'LJCut';
+						fakeElement.attributes['class'] = 'lj-cut';
+						fakeElement.children = element.children;
+						return fakeElement;
 					},
 					'lj-embed': function(element){
 						var fakeElement = new CKEDITOR.htmlParser.element('div');
@@ -1179,33 +1184,45 @@
 			dataProcessor.htmlFilter.addRules({
 				elements: {
 					div: function(element) {
-						if (element.attributes['class'] == 'lj-like') {
-							var ljLikeNode = new CKEDITOR.htmlParser.element('lj-like');
-							ljLikeNode.attributes.buttons = element.attributes.buttons;
-							if (element.attributes.style) {
-								ljLikeNode.attributes.style = element.attributes.style;
-							}
-							ljLikeNode.isEmpty = true;
-							ljLikeNode.isOptionalClose = true;
-							return ljLikeNode;
-						} else if(element.attributes['class'] == 'lj-embed'){
-							var ljEmbedNode = new CKEDITOR.htmlParser.element('lj-embed');
-							ljEmbedNode.attributes.id = element.attributes.embedid;
-							ljEmbedNode.children = element.children;
+						var newElement = element;
+						switch(element.attributes['class']){
+							case 'lj-like':
+								newElement = new CKEDITOR.htmlParser.element('lj-like');
+								newElement.attributes.buttons = element.attributes.buttons;
+								if (element.attributes.style) {
+									newElement.attributes.style = element.attributes.style;
+								}
+								newElement.isEmpty = true;
+								newElement.isOptionalClose = true;
+							break;
+							case 'lj-embed':
+								newElement = new CKEDITOR.htmlParser.element('lj-embed');
+								newElement.attributes.id = element.attributes.embedid;
+								newElement.children = element.children;
+							break;
+							case 'lj-map':
+								newElement = new CKEDITOR.htmlParser.element('lj-map');
+								newElement.attributes.url = decodeURIComponent(element.attributes['lj-url']);
+								element.attributes.style.replace(/([a-z-]+):(.*?);/gi, function(relust, name, value) {
+									newElement.attributes[name] = parseInt(value);
+								});
 
-							return ljEmbedNode;
-						} else if (element.attributes['class'] == 'lj-map') {
-							var ljMapNode = new CKEDITOR.htmlParser.element('lj-map');
-							ljMapNode.attributes.url = decodeURIComponent(element.attributes['lj-url']);
-							element.attributes.style.replace(/([a-z-]+):(.*?);/gi, function(relust, name, value){
-								ljMapNode.attributes[name] = parseInt(value);
-							});
+								newElement.isOptionalClose = newElement.isEmpty = true;
+							break;
+							case 'lj-cut':
+								newElement = new CKEDITOR.htmlParser.element('lj-cut');
+								if(element.attributes.hasOwnProperty('text')){
+									newElement.attributes.text = element.attributes.text;
+								}
+								newElement.children = element.children;
+							break;
+							default:
+								if (!element.children.length) {
+									newElement = false;
+								}
+						}
 
-							ljMapNode.isOptionalClose = ljMapNode.isEmpty = true;
-							return ljMapNode;
-						} else if (!element.children.length) {
-							return false;
-						}
+						return newElement;
 					},
 					span: function(element) {
 						var userName = element.attributes['lj:user'];

Modified: trunk/htdocs/js/entry.js
===================================================================
--- trunk/htdocs/js/entry.js	2011-08-19 03:42:02 UTC (rev 19777)
+++ trunk/htdocs/js/entry.js	2011-08-19 04:33:01 UTC (rev 19778)
@@ -466,8 +466,8 @@
 	window
 		.open('', 'preview', 'width=760,height=600,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,scrollbars=yes');
 	entryForm.submit();
+	entryForm.target = '_self';
 	entryForm.action = action;
-	entryForm.target = '_self';
 	return false;
 }
 
@@ -919,14 +919,14 @@
 	InOb.onClosePopup();
 
 	//var iframe = document.createElement("iframe");
-	var container = document.createElement("div");
-	container.id = "updateinsobject";
+	var container = document.createElement('div');
+	container.id = 'updateinsobject';
 	container.className = 'updateinsobject';
-	container.style.overflow = "hidden";
-	container.style.position = "absolute";
-	container.style.border = "0";
-	container.style.backgroundColor = "#fff";
+	container.style.overflow = 'hidden';
+	container.style.border = '0';
+	container.style.backgroundColor = '#fff';
 	container.style.zIndex = 1000;
+	container.style.position = 'fixed';
 
 	var iframe = document.createElement('iframe');
 	iframe.id = 'popupsIframe';
@@ -939,6 +939,8 @@
 	container.appendChild(iframe);
 	currentPopup = container;
 	InOb.smallCenter();
+
+
 	InOb.onresize = function(){
 		return InOb.smallCenter();
 	};
@@ -1273,10 +1275,12 @@
 
 	DOM.setHeight(currentPopup, 300);
 	DOM.setWidth(currentPopup, 700);
-	DOM.setTop(currentPopup, (windims.y - 300) / 2);
-	DOM.setLeft(currentPopup, (windims.x - 715) / 2);
 
-	scroll(0, 0);
+	currentPopup.style.top = '50%';
+	currentPopup.style.marginTop = '-150px';
+
+	currentPopup.style.left = '50%';
+	currentPopup.style.marginLeft = '-350px';
 };
 
 InOb.setPreviousCb = function (cb){

Modified: trunk/htdocs/js/rte.js
===================================================================
--- trunk/htdocs/js/rte.js	2011-08-19 03:42:02 UTC (rev 19777)
+++ trunk/htdocs/js/rte.js	2011-08-19 04:33:01 UTC (rev 19778)
@@ -27,6 +27,17 @@
 
 	window.useRichText = function (statPrefix) {
 		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';
 
@@ -44,11 +55,11 @@
 
 					editor.resetDirty();
 
-					$('#updateForm').bind('submit', function() {
+					$('#updateForm')[0].onsubmit = function() {
 						if (window.switchedRteOn) {
 							draftData.textArea.val(CKEditor.getData());
 						}
-					});
+					};
 
 					CKEditor.on('dataReady', function() {
 						$('#entry-form-wrapper').attr('class', 'hide-html');
@@ -56,7 +67,7 @@
 						CKEditor.container.show();
 						CKEditor.element.hide();
 
-						if (draftData) {
+						if (draftData.hasOwnProperty('draftStatus')) {
 							editor.on('dialogHide', checkDraftTimer);
 							editor.on('afterCommandExec', checkDraftTimer);
 							editor.on('insertElement', checkDraftTimer);

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

  • 0 comments