Aralot (aralot) wrote in changelog,
Aralot
aralot
changelog

[livejournal] r18221: LJSUP-7800: close event for "delete comm...

Committer: szhirkov
LJSUP-7800: close event for "delete comment" popup
U   trunk/htdocs/js/commentmanage.js
Modified: trunk/htdocs/js/commentmanage.js
===================================================================
--- trunk/htdocs/js/commentmanage.js	2011-02-07 05:14:31 UTC (rev 18220)
+++ trunk/htdocs/js/commentmanage.js	2011-02-07 05:44:33 UTC (rev 18221)
@@ -230,7 +230,7 @@
   // we didn't handle anything, who are we kidding
 }
 
-function createDeleteFunction (ae, dItemid, isS1) {
+function createDeleteFunction(ae, dItemid, isS1) {
     return function (e) {
 		e = jQuery.event.fix(e || window.event);
 
@@ -279,7 +279,8 @@
 			var de = jQuery('<div class="ljcmtmanage b-popup" style="text-align:left;position:absolute;visibility:hidden;width:250px;left:0;top:0;z-index:3"><div class="b-popup-outer"><div class="b-popup-inner"><div class="ljcmtmanage-content"></div><i class="i-popup-arr i-popup-arrt"></i><i class="i-popup-close"></i></div></div></div>')
 						.click(function(e){
 							e.stopPropagation()
-						});
+						})
+						.delegate('.i-popup-close', 'click', killPopup);
 			
             var inHTML = "<form style='display: inline' id='ljdelopts" + dItemid + "'><span style='font-face: Arial; font-size: 8pt'><strong>" + getLocalizedStr( 'comment.delete.q', com.u ) + "</strong><br />";
             var lbl;
@@ -321,7 +322,8 @@
 				left: left,
 				top: top,
 				height: 10,
-				visibility: 'visible'
+				visibility: 'visible',
+				overflow: 'hidden'
 			});
 			
 			curPopup = de[0];
@@ -404,13 +406,16 @@
 }
 
 var tsInProg = {}  // dict of { ditemid => 1 }
-function createModerationFunction(ae, dItemid, isS1)
+function createModerationFunction(ae, dItemid, isS1, action)
 {
+	var action = action || 'screen'; // "screen" action by default
+	
 	return function(e)
 	{
 		var e = jQuery.event.fix(e || window.event);
 			pos = { x: e.pageX, y: e.pageY },
-			postUrl = ae.href.replace(/.+talkscreen\.bml/, LiveJournal.getAjaxUrl('talkscreen')),
+			bmlName = { 'screen' : 'talkscreen', 'spam' : 'spamcomment' }[action],
+			postUrl = ae.href.replace(new RegExp('.+' + bmlName + '\.bml'), LiveJournal.getAjaxUrl(bmlName)),
 			hourglass = jQuery(e).hourglass()[0];
 			
 		var xhr = jQuery.post(postUrl + '&jsmode=1',
@@ -477,12 +482,13 @@
 									}
 
 									newNode = ExpanderEx.prepareCommentBlock(
-											result[i].html,
-											result[ i ].thread,
+											result[i].html || '',
+											result[i].thread || '',
 											showExpand
 									);
 
 									setupAjax( newNode[0], isS1 );
+									
 									jQuery("#ljcmtxt" + result[i].thread).replaceWith( newNode );
 								}
 							}
@@ -559,7 +565,7 @@
             var id = reMatch[1];
             if (!document.getElementById('ljcmt' + id)) continue;
 
-            ae.onclick = createModerationFunction(ae, id, isS1);
+            ae.onclick = createModerationFunction(ae, id, isS1, 'screen');
         } else if (ae.href.indexOf('delcomment.bml') != -1) {
             if (LJ_cmtinfo && LJ_cmtinfo.disableInlineDelete) continue;
 
@@ -570,21 +576,34 @@
             if (!document.getElementById('ljcmt' + id)) continue;
 
             ae.onclick = createDeleteFunction(ae, id, isS1);
-        }
+        } else if (ae.href.indexOf('spamcomment.bml') != -1) {
+            var reMatch = rex_id.exec(ae.href);
+            if (!reMatch) continue;
+
+            var id = reMatch[1];
+            if (!document.getElementById('ljcmt' + id)) continue;			
+			
+			ae.onclick = createModerationFunction(ae, id, isS1, 'spam');			
+		}
     }
 }
 
 function getThreadJSON(threadId, success, getSingle)
 {
     var postid = location.href.match(/\/(\d+).html/)[1],
+		modeParam = LiveJournal.parseGetArgs(location.href).mode,
         params = [
             'journal=' + Site.currentJournal,
             'itemid=' + postid,
             'thread=' + threadId,
             'depth=' + LJ_cmtinfo[ threadId ].depth
         ];
-    if( getSingle)
+		
+    if (getSingle)
         params.push( 'single=1' );
+		
+	if (modeParam)
+		params.push( 'mode=' + modeParam )
 
     var url = LiveJournal.getAjaxUrl('get_thread') + '?' + params.join( '&' );
     jQuery.get( url, success, 'json' );
@@ -593,3 +612,4 @@
 jQuery(function(){setupAjax( false, ("is_s1" in LJ_cmtinfo ) )});
 
 DOM.addEventListener(document, 'click', docClicked);
+document.write("<style> div.ljcmtmanage { color: #000; background: #e0e0e0; border: 2px solid #000; padding: 3px; }</style>");

Tags: aralot, 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