one of many positioning fixes
[wolnelektury.git] / src / wolnelektury / static / js / book_text / references.js
index 1460675..6abd103 100644 (file)
             leftoffset = x - margin;
         } else {
             right = '';
             leftoffset = x - margin;
         } else {
             right = '';
-        
-            // default position.
-            leftoffset = 40;
+
             leftoffset = $elem.data('default-leftoffset');
             leftoffset = $elem.data('default-leftoffset');
+            if (leftoffset === undefined) {
+                leftoffset = $elem.width() / 2;
+            }
             
             nx = x - leftoffset;
 
             
             nx = x - leftoffset;
 
 
             // Do we need to move away from the right?
             if (nx + boxwidth > maxx) {
 
             // Do we need to move away from the right?
             if (nx + boxwidth > maxx) {
-                // ACTUALLY CALCULATE STUFF
-                // if maxx - minx < 470 px -- daj z lewej do prawej i już!
-                
                 right = '';
                 let d = nx + boxwidth - maxx;
                 right = '';
                 let d = nx + boxwidth - maxx;
-                //if (leftoffset + d > $elem.width() - 10) d = $elem.width() - leftoffset - 10;
                 nx -= d;
                 leftoffset += d;
             }
                 nx -= d;
                 leftoffset += d;
             }
             let text = window.location.protocol + '//' +
                 window.location.host +
                 window.location.pathname;
             let text = window.location.protocol + '//' +
                 window.location.host +
                 window.location.pathname;
-            if (anchor) text += anchor;
+            if (anchor) text += '#' + anchor;
             navigator.clipboard.writeText(text);
             
             this.hideCopied();
             navigator.clipboard.writeText(text);
             
             this.hideCopied();