]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tpl/default/js/shaarli.js
Fix jumpy textarea with long content in post edit
[github/shaarli/Shaarli.git] / tpl / default / js / shaarli.js
index 4ebb7815a1d4c4860224228e65f4f9f5f68af00f..55656f80ea39032dd62b321cf6e707aa3e786868 100644 (file)
@@ -275,8 +275,14 @@ window.onload = function () {
     };
     function init () {
         function resize () {
+            /* Fix jumpy resizing: https://stackoverflow.com/a/18262927/1484919 */
+            var scrollTop  = window.pageYOffset ||
+                (document.documentElement || document.body.parentNode || document.body).scrollTop;
+
             description.style.height = 'auto';
             description.style.height = description.scrollHeight+10+'px';
+
+            window.scrollTo(0, scrollTop);
         }
         /* 0-timeout to get the already changed text */
         function delayedResize () {
@@ -401,14 +407,14 @@ window.onload = function () {
 
             var message = 'Are you sure you want to delete '+ links.length +' links?\n';
             message += 'This action is IRREVERSIBLE!\n\nTitles:\n';
-            var ids = '';
+            var ids = [];
             links.forEach(function(item) {
                 message += '  - '+ item['title'] +'\n';
-                ids += item['id'] +'+';
+                ids.push(item['id']);
             });
 
             if (window.confirm(message)) {
-                window.location = '?delete_link&lf_linkdate='+ ids +'&token='+ token.value;
+                window.location = '?delete_link&lf_linkdate='+ ids.join('+') +'&token='+ token.value;
             }
         });
     }
@@ -418,7 +424,8 @@ window.onload = function () {
      *
      * TODO: support error code in the backend for AJAX requests
      */
-    var existingTags = document.querySelector('input[name="taglist"]').value.split(' ');
+    var tagList = document.querySelector('input[name="taglist"]');
+    var existingTags = tagList ? tagList.value.split(' ') : [];
     var awesomepletes = [];
 
     // Display/Hide rename form
@@ -515,7 +522,7 @@ window.onload = function () {
         });
     });
 
-    updateAwesompleteList('.rename-tag-input', document.querySelector('input[name="taglist"]').value.split(' '), awesomepletes);
+    updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes);
 };
 
 /**
@@ -605,11 +612,12 @@ function htmlEntities(str)
 
 function activateFirefoxSocial(node) {
     var loc = location.href;
-    var baseURL = loc.substring(0, loc.lastIndexOf("/"));
+    var baseURL = loc.substring(0, loc.lastIndexOf("/") + 1);
+    var title = document.title;
 
     // Keeping the data separated (ie. not in the DOM) so that it's maintainable and diffable.
     var data = {
-        name: "{$shaarlititle}",
+        name: title,
         description: "The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community.",
         author: "Shaarli",
         version: "1.0.0",
@@ -618,7 +626,7 @@ function activateFirefoxSocial(node) {
         icon32URL: baseURL + "/images/favicon.ico",
         icon64URL: baseURL + "/images/favicon.ico",
 
-        shareURL: baseURL + "{noparse}?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi{/noparse}",
+        shareURL: baseURL + "?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi",
         homepageURL: baseURL
     };
     node.setAttribute("data-service", JSON.stringify(data));