Палсеич— (lusever) wrote in changelog,
Палсеич—
lusever
changelog

[livejournal] r16071: LJSUP-5235: jQuery refactoring.

Committer: pkornilov
LJSUP-5235: jQuery refactoring.
U   trunk/htdocs/js/commentmanage.js
U   trunk/htdocs/js/thread_expander.js
Modified: trunk/htdocs/js/commentmanage.js
===================================================================
--- trunk/htdocs/js/commentmanage.js	2009-12-23 07:21:10 UTC (rev 16070)
+++ trunk/htdocs/js/commentmanage.js	2009-12-23 10:15:43 UTC (rev 16071)
@@ -99,25 +99,6 @@
     return [v,p,q];
 }
 
-
-function scrollTop () {
-    if (window.innerHeight)
-        return window.pageYOffset;
-    if (document.documentElement && document.documentElement.scrollTop)
-        return document.documentElement.scrollTop;
-    if (document.body)
-        return document.body.scrollTop;
-}
-
-function scrollLeft () {
-    if (window.innerWidth)
-        return window.pageXOffset;
-    if (document.documentElement && document.documentElement.scrollLeft)
-        return document.documentElement.scrollLeft;
-    if (document.body)
-        return document.body.scrollLeft;
-}
-
 var curPopup = null;
 var curPopup_id = 0;
 
@@ -237,9 +218,7 @@
 
 function createDeleteFunction (ae, dItemid) {
     return function (e) {
-        if (!e) e = window.event;
 		e = jQuery.event.fix(e || window.event);
-        var FS = arguments.callee;
 
         var finalHeight = 115;
 
@@ -251,6 +230,7 @@
         // immediately delete on shift key
         if (e.shiftKey) {
             doIT = 1;
+			deleteComment(dItemid);
         } else {
             if (! LJ_cmtinfo)
                 return true;
@@ -260,21 +240,18 @@
             if (!com || !remoteUser)
                 return true;
             var canAdmin = LJ_cmtinfo["canAdmin"];
-
-			var clickTarget = e.target;
 			
 			var pos_offset = jQuery(ae).position(),
 				offset = jQuery(ae).offset();
-			var diff_x = offset.left - pos_offset.left;
-			var diff_y = offset.top - pos_offset.top;
-			var lx = e.pageX - diff_x + 5 - 250;
-            if (lx < 5) lx = 5;
+			var pos_x = e.pageX - offset.left + pos_offset.left;
+			var pos_y = e.pageY - offset.top + pos_offset.top;
+			var lx = Math.max(pos_x + 5 - 250, 5);
             var de;
 
             if (curPopup && curPopup_id == dItemid) {
                 de = curPopup;
                 de.style.left = lx + "px";
-				de.style.top = (e.pageY - diff_y + 5) + "px";
+				de.style.top = pos_y + 5 + 'px';
                 return Event.stop(e);
             }
 
@@ -285,7 +262,7 @@
             de.style.overflow = "hidden";
             de.style.position = "absolute";
             de.style.left = lx + "px";
-            de.style.top = (e.pageY - diff_y + 5) + "px";
+            de.style.top = pos_y + 5 + 'px';
             de.style.width = "250px";
             de.style.zIndex = 3;
             DOM.addEventListener(de, 'click', function (e) {
@@ -295,14 +272,14 @@
 
             var inHTML = "<form style='display: inline' id='ljdelopts" + dItemid + "'><span style='font-face: Arial; font-size: 8pt'><b>Delete comment?</b><br />";
             var lbl;
-            if (remoteUser != "" && com.u != "" && com.u != remoteUser && canAdmin) {
+            if (com.u != "" && com.u != remoteUser && canAdmin) {
                 lbl = "ljpopdel" + dItemid + "ban";
                 inHTML += "<input type='checkbox' name='ban' id='" + lbl + "'> <label for='" + lbl + "'>Ban <b>" + com.u + "</b> from commenting</label><br />";
             } else {
                 finalHeight -= 15;
             }
 
-            if (remoteUser != "" && remoteUser != com.u) {
+            if (remoteUser != com.u) {
                 lbl = "ljpopdel" + dItemid + "spam";
                 inHTML += "<input type='checkbox' name='spam' id='" + lbl + "'> <label for='" + lbl + "'>Mark this comment as spam</label><br />";
             } else {
@@ -344,13 +321,7 @@
                 }
             };
             grow();
-
         }
-
-        if (doIT) {
-            deleteComment(dItemid);
-        }
-
         Event.stop(e);
     }
 }

Modified: trunk/htdocs/js/thread_expander.js
===================================================================
--- trunk/htdocs/js/thread_expander.js	2009-12-23 07:21:10 UTC (rev 16070)
+++ trunk/htdocs/js/thread_expander.js	2009-12-23 10:15:43 UTC (rev 16071)
@@ -89,7 +89,7 @@
 Expander.prototype.getS1width = function(canvas){
   //TODO:  may be we should should add somie ID to the spacer img instead of searching it
   //yet, this works until we have not changed the spacers url = 'dot.gif');
-  var img, imgs, found;
+  var img, imgs;
   imgs = canvas.getElementsByTagName('img');
   for(var j=0;j<imgs.length;j++){
     img=imgs[j];
@@ -104,7 +104,6 @@
 Expander.prototype.setS1width = function(canvas,w){
   var img, imgs;
   imgs = canvas.getElementsByTagName('img');
-  if(!imgs)return false;
   for(var j=0;j<imgs.length;j++){
     img=imgs[j];
     if(/dot\.gif$/.test(img.src)){
@@ -135,7 +134,7 @@
                                                 w =obj.getS1width(comments_page[id].canvas);
                                             }
                                             comments_page[id].canvas.innerHTML = new_comment.canvas.innerHTML;
-                                            if(obj.is_S1 && w!==null){
+                                            if(obj.is_S1 && w!==false){
                                                     obj.setS1width(comments_page[id].canvas,w);
                                             }
                                             //TODO: may be this should be uncommented

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